Created
August 10, 2016 21:50
-
-
Save MagnusTiberius/dec82aad3b2add2fba368fc29d6675f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _EIP_EVENT_D_H_ | |
#define _EIP_EVENT_D_H_ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <signal.h> | |
#include <getopt.h> | |
#include <sys/queue.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <sys/file.h> | |
#include <sys/stat.h> | |
#include <regex.h> | |
#include <errno.h> | |
#include <syslog.h> | |
#include <time.h> | |
#ifdef SUPPORT_RUN_AS | |
#include <pwd.h> | |
#endif | |
#include <netdb.h> | |
#include <arpa/inet.h> | |
#include <signal.h> | |
#include <linux/limits.h> | |
#include <ctype.h> | |
#define xstr(s) str(s) | |
#define str(s) #s | |
#define USE_RAW_JSON true | |
#define CONF_FILE "/etc/listen.conf" | |
#define CONF_FIELD_REPORTER 0 | |
#define CONF_FIELD_ID 1 | |
#define CONF_FIELD_NAME 2 | |
#define CONF_FIELD_CATEGORY 3 | |
#define CONF_FIELD_SEVERITY 4 | |
#define CONF_FIELD_ACTION_TAKEN 5 | |
#define CONF_FIELD_KEYWORD 6 | |
#define CONF_FIELD_OFFSET 7 | |
#define CONF_FIELD_EXPRESSION 8 | |
#define NUM_CONF_FIELDS 9 | |
#ifdef DEBUG | |
#define PID_FILE "/tmp/eipeventd.pid" | |
#else | |
#define PID_FILE "/var/run/eipeventd.pid" | |
#endif | |
#ifdef SUPPORT_RUN_AS | |
#define RUN_AS_USER "daemon" | |
#endif | |
/* | |
* Define default listen port | |
*/ | |
#define DEFAULT_SERVER_PORT "7899" | |
#define PORT 7899 | |
#include <stdio.h> | |
#include <string.h> //strlen | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <unistd.h> //close | |
#include <arpa/inet.h> //close | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <sys/time.h> //FD_SET, FD_ISSET, FD_ZERO macros | |
#define TRUE 1 | |
#define FALSE 0 | |
#include "ma/ma_client.h" | |
#include "clientevent.h" | |
class EipEventD | |
{ | |
public: | |
EipEventD(); | |
~EipEventD(); | |
void Start(); | |
int help_flag = 0; | |
int version_flag = 0; | |
char *prog_name; | |
void print_usage(void); | |
void print_version(void); | |
void daemonize(void); | |
pid_t create_pidfile(void); | |
void run(const char *port); | |
static int had_hup; | |
static int destroy_pidfile(); | |
static void sighup_handler(int signum); | |
static void sigterm_handler(int signum); | |
static void child_handler(int signum); | |
static bool is_had_hup(); | |
private: | |
int opt = TRUE; | |
int master_socket , addrlen , new_socket , client_socket[30] , max_clients = 30 , activity, i , valread , sd; | |
int max_sd; | |
struct sockaddr_in address; | |
char buffer[1025]; //data buffer of 1K | |
int ctr1; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment