- added Sean's opendht entry
[codemux.git] / codemuxlib.h
1 #ifndef _APPLIB_H_
2 #define _APPLIB_H_
3
4 #include <stdio.h>
5 #include <sys/time.h>
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 #include <sys/mman.h>
10 #include <netdb.h>
11 #include <limits.h>
12 #include <string.h>
13 #ifdef OS_LINUX
14 #include <alloca.h>
15 #endif
16
17 #include "appdef.h"
18
19 /* stripped version of applib.c for codemux */
20
21 char *GetNextLine(FILE *file);
22 int   WordCount(char *buf);
23 char *GetField(const char *start, int whichField);
24 char *GetWord(const char *start, int whichWord);
25 int   DoesDotlessSuffixMatch(char *start, int len, char *suffix);
26 int   CreatePrivateAcceptSocket(int portNum, int nonBlocking);
27 char *StrdupLower(const char *orig);
28 void  StrcpyLower(char *dest, const char *src);
29
30 /* nice exit support */
31 void  NiceExitBack(int val, char *reason, char *file, int line);
32 #define NiceExit(val, reason) NiceExitBack(val, reason, __FILE__, __LINE__)
33
34
35 /*  allocate stack memory to copy "src" to "dest" in lower cases */
36 #define LOCAL_STR_DUP_LOWER(dest, src)    \
37   { dest = alloca(strlen(src) + 1);       \
38     StrcpyLower(dest, src);               \
39   }
40   
41 /*  allocate stack memory to copy "src" to "dest" */
42 #define LOCAL_STR_DUP(dest, src)         \
43   { dest = alloca(strlen(src) + 1);      \
44     strcpy(dest, src);                   \
45   }
46 #endif
47