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