Files
yasnd/daemon/yasnd.c
T
Pinkbyte a1c83a3df2 Split out GAMMU-related code from library into daemon.
Add proper optional support for GAMMU via build-time options.
This commit fixes #4, but some additional checks maybe needed.
2013-09-02 22:54:14 +04:00

427 lines
10 KiB
C

#include "config.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <getopt.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <confuse.h>
#include "yasnd.h"
#include "yasnd-gammu.h"
#include "yasnd-log.h"
#include "yasnd-lpt.h"
#include "yasnd-sock.h"
cfg_t *cfg; // pointer to configuration structure
char pidfile[]="/var/run/yasnd.pid"; // pidfile path
host_decl* hosts=NULL; // structure with hosts' definitions
int hosts_count=0; // count of hosts
bool sms_enable=false; // use SMS messages for control and reports?
char* recipient_number=NULL; // recipient of sms alerts
bool loop_locked=false; // flag for locking main loop while config re-reading
long failures_first=0; // count of failures while hosts checking, that triggers SMS sending
long failures_second=0; // count of failures while hosts checking, that triggers host's reset
long failures_third=0; // count of failures while hosts checking, that clean failure statistics
pthread_t mainloop_handle; // handle of main loop thread
void* allocate_memory(int bytes)
{
void* result=malloc(bytes);