2018-09-24 18:49:18 +08:00
|
|
|
#pragma once
|
2019-07-25 14:49:11 +06:00
|
|
|
#include "Maat_rule.h"
|
2018-09-24 18:49:18 +08:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/syscall.h>
|
2018-09-24 19:48:18 +08:00
|
|
|
#include <sys/types.h>//fstat
|
|
|
|
|
#include <sys/types.h>//fstat
|
|
|
|
|
#include <sys/stat.h>//fstat
|
2018-09-24 18:49:18 +08:00
|
|
|
|
|
|
|
|
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
|
|
|
|
|
#define FREE(p) {free(*p);*p=NULL;}
|
|
|
|
|
|
2018-12-05 18:00:55 +08:00
|
|
|
#if(__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ >= 411)
|
|
|
|
|
#define atomic_inc(x) __sync_add_and_fetch((x),1)
|
|
|
|
|
#define atomic_dec(x) __sync_sub_and_fetch((x),1)
|
|
|
|
|
#define atomic_add(x,y) __sync_add_and_fetch((x),(y))
|
|
|
|
|
#define atomic_sub(x,y) __sync_sub_and_fetch((x),(y))
|
|
|
|
|
typedef int atomic_t;
|
|
|
|
|
#define ATOMIC_INIT(i) { (i) }
|
|
|
|
|
#define atomic_read(x) __sync_add_and_fetch((x),0)
|
|
|
|
|
#define atomic_set(x,y) __sync_lock_test_and_set((x),y)
|
|
|
|
|
#else
|
|
|
|
|
#include <alsa/iatomic.h>
|
|
|
|
|
#endif
|
|
|
|
|
#define TRUE 1
|
|
|
|
|
#define FALSE 0
|
2018-09-24 18:49:18 +08:00
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-12-05 18:00:55 +08:00
|
|
|
#ifndef offsetof
|
|
|
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef container_of
|
|
|
|
|
#define container_of(ptr, type, member) ({ \
|
|
|
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
|
|
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-10-18 19:39:19 +08:00
|
|
|
#define UNUSED __attribute__((unused))
|
2018-09-24 18:49:18 +08:00
|
|
|
const char* module_name_str(const char*name);
|
|
|
|
|
#define maat_module (module_name_str("MAAT_Frame"))
|
|
|
|
|
|
|
|
|
|
char* _maat_strdup(const char* s);
|
|
|
|
|
char* str_unescape(char* s);
|
|
|
|
|
inline void ipv6_ntoh(unsigned int *v6_addr)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i=0;
|
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
|
{
|
|
|
|
|
v6_addr[i]=ntohl(v6_addr[i]);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int hex2bin(char *hex,int hex_len,char *binary,int size);
|
|
|
|
|
char* str_tolower(char* string);
|
|
|
|
|
char *strtok_r_esc(char *s, const char delim, char **save_ptr);
|
|
|
|
|
char *str_unescape_and(char*s);
|
|
|
|
|
char* str_unescape(char* s);
|
|
|
|
|
pid_t gettid(void);
|
|
|
|
|
int system_cmd_mkdir(const char* path);
|
|
|
|
|
int system_cmd_rm(const char* src_file);
|
2018-12-02 22:50:20 +08:00
|
|
|
int system_cmd_mv(const char* src_file,const char*dst_file);
|
|
|
|
|
int system_cmd_cp(const char* src_file,const char*dst_file);
|
|
|
|
|
char* md5_file(const char* filename, char* md5string);
|
2018-12-04 23:26:59 +08:00
|
|
|
int get_column_pos(const char* line, int column_seq, size_t *offset, size_t *len);
|
2019-07-25 14:49:11 +06:00
|
|
|
const char** charset_get_all_name(void);
|
|
|
|
|
const char* charset_get_name(enum MAAT_CHARSET charset);
|
2019-07-28 11:45:57 +06:00
|
|
|
int lqueue_destroy_cb(void *data, long data_len, void *arg);
|
2018-12-04 23:26:59 +08:00
|
|
|
|
2018-09-24 18:49:18 +08:00
|
|
|
|