1 #ifndef _NET_LIB_H_ 2 #define _NET_LIB_H_ 3 4 #include <netinet/in.h> 5 6 #ifndef TRUE 7 #define TRUE 1 8 #endif 9 10 #ifndef FALSE 11 #define FALSE 0 12 #endif 13 14 #ifndef MAX 15 #define MAX(x, y) ((x) > (y) ? (x) : (y)) 16 #endif 17 18 #ifndef MIN 19 #define MIN(x, y) ((x) < (y) ? (x) : (y)) 20 #endif 21 22 #ifndef VERIFY 23 #define VERIFY(x) if (!(x)) {fprintf(stderr, "error: FILE:%s LINE:%d FUNC: %s", __FILE__, __LINE__, __FUNCTION__); assert(0);} 24 #endif 25 26 #ifndef FREE 27 #define FREE(x) if (x) {free(x); (x) = NULL;} 28 #endif 29 30 int GetNumCPUCores(void); 31 int AffinitizeThreadToCore(int core); 32 int CreateServerSocket(int port, int isNonBlocking); 33 int CreateConnectionSocket(in_addr_t addr, int port, int isNonBlocking); 34 35 /* processing options */ 36 struct Options { 37 char *op_name; 38 char **op_varptr; 39 char *op_comment; 40 } Options; 41 void ParseOptions(int argc, const char** argv, struct Options* ops); 42 void PrintOptions(const struct Options* ops, int printVal); 43 44 45 /* HTTP header processing */ 46 char *GetHeaderString(const char *buf, const char* header, int hdrsize); 47 int GetHeaderLong(const char* buf, const char* header, int hdrsize, long int *val); 48 49 #endif 50