|
|
#ifndef __CORE_MODULES_ASSEMBLY_
#define __CORE_MODULES_ASSEMBLY_
//#define _REENTRANT
#define _ENABLE_LOG_MESSAGES_
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <map>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <netdb.h>
#include <fcntl.h>
#include <signal.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <linux/tcp.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <pthread.h>
#include <ncurses.h>
#include <stddef.h>
#include <assert.h>
#include <locale.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <mysql/mysql.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <dirent.h>
#include <sys/types.h>
#include <ifaddrs.h>
#include <sys/statvfs.h>
//#include <curl/curl.h>
// Default Data Types
using namespace std;
typedef unsigned short U16;typedef unsigned int U32;typedef unsigned char U8;typedef unsigned long long U64;typedef char * CSTR;
//typedef map < char *, char * > Assoc;
typedef map < string, string > Assoc;typedef vector < Assoc * > AAssoc;typedef vector < string * > SArray;typedef vector < CSTR > CArray;
typedef vector < char * > enumeratorInfo;
// Default Settings for Server Configuration
#define MAX_PATH 1024
#define MAX_PATH_LEN 1024
#define DEFAULT_SERVER_PORT 2222
#define DEFAULT_SERVER_CONFIG_PATH "/etc/video-sever.conf"
#define DEFAULT_SERVER_CONFIG_FILE "video-sever.conf"
#define DEFAULT_SERVER_PID_FILE "video-sever.pid"
#define DEFAULT_SERVER_LOG_FILE "video-sever.log"
#define DEFAULT_SERVER_SOCKET_PATH "/tmp/video-sever.soc"
#define DEFAULT_CONNECTION_LIFE_TIME 300 // 5 Minutes
#define VERSION_NUMBER "0.9.0"
#define CTEXT 256
#define CQUERY 1024
#define CLOG 1024
// Global Data Structs and functions
typedef enum { _BLADE_UNKNOWN_ = -1, _BLADE_FILE_ = 0, _BLADE_CURL_ = 1} _ENUM_BLADES;
typedef enum { _LOG_NONE = 0, _LOG_CRITICAL = 1, _LOG_ERROR, _LOG_VERBOSE, _LOG_DEBUG, _LOG_ALL} _LOG_LEVEL;
#define _DEFAULT_LOG_LEVEL_ _LOG_CRITICAL
#define _WORKING_LOG_LEVEL_ _LOG_ALL
typedef struct scr_t { U16 tile : 10; U16 hflip : 1; U16 vflip : 1; U16 pal : 4;} scr_t;
typedef enum { _CRITICAL_ERROR = 0, _ERROR = 1, _VERBOSE_MESSAGE, _DEBUG_MESSAGE, _MESSAGE} _ERROR_LEVEL;
typedef enum{ SKIP_PROCESSING = -1, PROCESS_RESPONCE = 0, PROCESS_QUERY, PROCESS_ERROR} PROCESSING_TYPE; typedef enum { SC_NOCOMMAND = -1, SC_REGISTER_DEVICE = 0, SC_PROCEED_LOGIN = 1, SC_RETRIVE_CONFIG_SETTING, SC_SET_CONFIG_SETTING, SC_FORWARD_SMS_MESSAGE, SC_TURN_ALARM_ON, SC_TURN_ALARM_OFF, SC_TURN_ENGINE_ON, SC_TURN_ENGINE_OFF, SC_TURN_LOCK_ON, SC_TURN_LOCK_OFF} SERVER_COMMANDS;
//Global Functions
int fileExist( const char *strFilename );CSTR trim( CSTR string );CArray *explode( char Delim, CSTR S_Str );CSTR implode( CArray *Data, CSTR S_Str, U8 Start, U8 End );CSTR getTStr( CSTR Fmt = NULL );
inline long long getMilliseconds( void ){ struct timeval tData; struct timezone tTZ; long long tMilliseconds; tMilliseconds = 0; tTZ.tz_minuteswest = 0; tTZ.tz_dsttime = 0; if( gettimeofday( &tData, &tTZ ) == -1 ){ } else { tMilliseconds = tData.tv_sec; tMilliseconds = tMilliseconds *1000; tMilliseconds += tData.tv_usec / 1000; }; return tMilliseconds;};
struct if_info{ CSTR if_name; CSTR if_addr;};
int getIP4( if_info **arrParam, int max_ifs = 10 );
long long getTotalSpace( CSTR DirName );long long getFreeSpace( CSTR DirName );
bool enumerateDevices( enumeratorInfo *mlist, const char *dTemplate = "video" );
extern U64 gnCFG_SERVER_ID;extern CSTR gsCFG_ADDRESS;extern U16 guCFG_PORT;extern CSTR gsCFG_LICENSE;extern CSTR gsCFG_DB_SERVER;extern CSTR gsCFG_DB_NAME;extern CSTR gsCFG_PID_FILE;extern CSTR gsCFG_DB_USER;extern CSTR gsCFG_DB_PASSWORD;
extern bool gModule_GeoFence_Enabled;extern bool gModule_SMS_Enabled;extern bool gModule_Email_Enabled;
#endif
|