/
common.h
84 lines (72 loc) · 1.61 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __COMMON_H__
#define __COMMON_H__ 1
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <signal.h>
#include <limits.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
#include <syslog.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <poll.h>
#include <dlfcn.h>
#include <spawn.h>
#define VERSION_MAJOR 1
#ifndef __GNUC__
# ifdef __attribute__
# undef __attribute__
# endif
# define __attribute__(a)
#endif
#ifndef environ
# ifdef __APPLE__
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
# else
extern char **environ;
# endif
#endif
#if defined(__APPLE__) && !defined(__clang__)
# define USE_INTERPOSERS 1
#endif
#ifdef USE_INTERPOSERS
# define INTERPOSE(F) sixjack_interposed_ ## F
#else
# define INTERPOSE(F) F
#endif
#if defined(__SUNPRO_C)
# define DLL_LOCAL __attribute__ __hidden
# define DLL_PUBLIC __attribute__ __global
#elif defined(_MSG_VER)
# define DLL_LOCAL
# define DLL_PUBLIC extern __declspec(dllexport)
#else
# define DLL_LOCAL __attribute__ ((visibility ("hidden")))
# define DLL_PUBLIC __attribute__ ((visibility ("default")))
#endif
#ifdef DEFINE_HOOK_GLOBALS
# define HOOK_GLOBAL
# ifndef DONT_BYPASS_HOOKS
# error HOOK_GLOBAL can't be defined without DONT_BYPASS_HOOKS
# endif
#else
# define HOOK_GLOBAL extern
#endif
typedef struct AppContext_ {
bool initialized;
int log_fd;
struct Filter_ *filter;
} AppContext;
AppContext *sixjack_get_context(void);
void sixjack_free_context(void);
#include "hooks.h"
#endif