/**************************************************************** * * Miscellany which doesn't really fit in a module header... */ /* General system config stuff */ #define NS_AOLSERVER_3_PLUS #define NS_EXPORT #define DllExport /* nothing */ /* Protocol handling data structures */ typedef enum { Preserve, ToLower, ToUpper } Ns_HeaderCaseDisposition; #define Ns_InfoServersStarted() (Tcl_request_rec != 0) /* Critical sections */ typedef int Ns_Cs; #define Ns_CsEnter(x) (*(x) = 0) /* use the variable */ #define Ns_CsLeave(x) (*(x) = 0) /* use the variable */ /* Dealing with tcl */ void NsTclCreateCmds(Tcl_Interp *interp); typedef int Ns_TclInterpInitProc(Tcl_Interp *interp, void *ignored); typedef int ns_tcl_command (ClientData, Tcl_Interp *, int, char **); typedef struct TclCmd { char *name; Tcl_CmdProc *proc; ClientData clientData; } TclCmd; int NsTclEval(Tcl_Interp *interp, char *script); char *Ns_TclLogError(Tcl_Interp *interp); int Ns_TclGetOpenFd(Tcl_Interp *interp, char *chanId, int write, int *fdPtr); int Ns_TclGetOpenChannel(Tcl_Interp *interp, char *chanId, int write, int check, Tcl_Channel *chanPtr); #define Ns_TclInterpServer(x) nsServer /**************************************************************** * * Just plain library crud... */ #include #include #include #include #include #ifdef __sun #include /* for FIONREAD */ #endif #define NS_OK 0 #define NS_ERROR (-1) #define NS_TIMEOUT (-2) #define NS_TRUE 1 #define NS_FALSE 0 #define Ns_CheckStack() NS_OK #define STREQ(x,y) (!strcmp((x),(y))) #define STRIEQ(x,y) (!strcasecmp((x),(y))) #define UCHAR(x) ((unsigned char)(x)) #define ns_localtime localtime #define ns_gmtime gmtime /* Networking */ #define ns_inet_ntoa inet_ntoa #define ns_sockioctl ioctl #define ns_sockerrno errno #define ns_sockdup dup #define ns_sockclose close #define ns_socknbclose close #define ns_sockstrerror strerror #define INVALID_SOCKET -1 typedef int SOCKET; SOCKET Ns_SockConnect(char *host, int port); SOCKET Ns_SockAsyncConnect(char *host, int port); SOCKET Ns_SockTimedConnect(char *host, int port, int timeout); /* Use ap_palloc, etc. for these? */ #define ns_malloc malloc #define ns_calloc calloc #define ns_realloc realloc #define ns_free free #define ns_strdup strdup #define Ns_Malloc malloc #define Ns_Realloc realloc #define Ns_Free free #define Ns_StrDup strdup char *ns_strcopy(const char *x); typedef void Ns_Callback(void *);