X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=include%2Ffcgiapp.h;h=7d7ec8636657a06d7afc253ab172d4d862faa34f;hb=ed436fed81c9ee69d55e8bc66903d97aabcb5ef5;hp=f0f331bcf4a55322903f640a48c3f1a9aa96e84d;hpb=344bf0566f5fc2d789dbca4a988cef35c68af497;p=catagits%2Ffcgi2.git diff --git a/include/fcgiapp.h b/include/fcgiapp.h index f0f331b..7d7ec86 100644 --- a/include/fcgiapp.h +++ b/include/fcgiapp.h @@ -9,7 +9,7 @@ * See the file "LICENSE.TERMS" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * $Id: fcgiapp.h,v 1.3 1999/07/28 00:27:51 roberts Exp $ + * $Id: fcgiapp.h,v 1.14 2003/06/22 00:16:44 robs Exp $ */ #ifndef _FCGIAPP_H @@ -22,21 +22,17 @@ #include #endif -#if defined (c_plusplus) || defined (__cplusplus) -extern "C" { -#endif - -#ifdef _WIN32 - #ifndef DLLAPI +#ifdef _WIN32 #define DLLAPI __declspec(dllimport) -#endif - -#else /* !_WIN32 */ - +#else #define DLLAPI +#endif +#endif -#endif /* !_WIN32 */ +#if defined (c_plusplus) || defined (__cplusplus) +extern "C" { +#endif /* * Error codes. Assigned to avoid conflict with EOF and errno(2). @@ -80,22 +76,37 @@ typedef struct FCGX_Stream { typedef char **FCGX_ParamArray; /* - * State associated with a request. + * FCGX_Request Flags + * + * Setting FCGI_FAIL_ACCEPT_ON_INTR prevents FCGX_Accept() from + * restarting upon being interrupted. + */ +#define FCGI_FAIL_ACCEPT_ON_INTR 1 + +/* + * FCGX_Request -- State associated with a request. * - * Its exposed for API simplicity, DON'T use it - it WILL change! + * Its exposed for API simplicity, I expect parts of it to change! */ typedef struct FCGX_Request { + int requestId; /* valid if isBeginProcessed */ + int role; + FCGX_Stream *in; + FCGX_Stream *out; + FCGX_Stream *err; + char **envp; + + /* Don't use anything below here */ + + struct Params *paramsPtr; int ipcFd; /* < 0 means no connection */ int isBeginProcessed; /* FCGI_BEGIN_REQUEST seen */ - int requestId; /* valid if isBeginProcessed */ int keepConnection; /* don't close ipcFd at end of request */ - int role; int appStatus; int nWriters; /* number of open writers (0..2) */ - FCGX_Stream *inStream; - FCGX_Stream *outStream; - FCGX_Stream *errStream; - struct Params *paramsPtr; + int flags; + int listen_sock; + int detached; } FCGX_Request; @@ -134,13 +145,35 @@ DLLAPI int FCGX_Init(void); /* *---------------------------------------------------------------------- * + * FCGX_OpenSocket -- + * + * Create a FastCGI listen socket. + * + * path is the Unix domain socket (named pipe for WinNT), or a colon + * followed by a port number. e.g. "/tmp/fastcgi/mysocket", ":5000" + * + * backlog is the listen queue depth used in the listen() call. + * + * Returns the socket's file descriptor or -1 on error. + * + *---------------------------------------------------------------------- + */ +DLLAPI int FCGX_OpenSocket(const char *path, int backlog); + +/* + *---------------------------------------------------------------------- + * * FCGX_InitRequest -- * - * Initialize a FCGX_Request for use with FCGX_Accept_r(). + * Initialize a FCGX_Request for use with FCGX_Accept_r(). + * + * sock is a file descriptor returned by FCGX_OpenSocket() or 0 (default). + * The only supported flag at this time is FCGI_FAIL_ON_INTR. * + * Returns 0 upon success. *---------------------------------------------------------------------- */ -DLLAPI void FCGX_InitRequest(FCGX_Request *request); +DLLAPI int FCGX_InitRequest(FCGX_Request *request, int sock, int flags); /* *---------------------------------------------------------------------- @@ -172,12 +205,7 @@ DLLAPI void FCGX_InitRequest(FCGX_Request *request); * *---------------------------------------------------------------------- */ -DLLAPI int FCGX_Accept_r( - FCGX_Stream **in, - FCGX_Stream **out, - FCGX_Stream **err, - FCGX_ParamArray *envp, - FCGX_Request *request); +DLLAPI int FCGX_Accept_r(FCGX_Request *request); /* *---------------------------------------------------------------------- @@ -203,6 +231,18 @@ DLLAPI void FCGX_Finish_r(FCGX_Request *request); /* *---------------------------------------------------------------------- * + * FCGX_Free -- + * + * Free the memory and, if close is true, + * IPC FD associated with the request (multi-thread safe). + * + *---------------------------------------------------------------------- + */ +DLLAPI void FCGX_Free(FCGX_Request * request, int close); + +/* + *---------------------------------------------------------------------- + * * FCGX_Accept -- * * Accept a new request (NOT multi-thread safe). @@ -540,6 +580,50 @@ DLLAPI int FCGX_GetError(FCGX_Stream *stream); */ DLLAPI void FCGX_ClearError(FCGX_Stream *stream); +/* + *---------------------------------------------------------------------- + * + * FCGX_CreateWriter -- + * + * Create a FCGX_Stream (used by cgi-fcgi). This shouldn't + * be needed by a FastCGI applictaion. + * + *---------------------------------------------------------------------- + */ +DLLAPI FCGX_Stream *FCGX_CreateWriter( + int socket, + int requestId, + int bufflen, + int streamType); + +/* + *---------------------------------------------------------------------- + * + * FCGX_FreeStream -- + * + * Free a FCGX_Stream (used by cgi-fcgi). This shouldn't + * be needed by a FastCGI applictaion. + * + *---------------------------------------------------------------------- + */ +DLLAPI void FCGX_FreeStream(FCGX_Stream **stream); + +/* ---------------------------------------------------------------------- + * + * Prevent the lib from accepting any new requests. Signal handler safe. + * + * ---------------------------------------------------------------------- + */ +DLLAPI void FCGX_ShutdownPending(void); + + +/* + * Attach/Detach an accepted request from its listen socket. + * XXX This is not fully implemented at this time (patch welcome). + */ +DLLAPI int FCGX_Attach(FCGX_Request * r); +DLLAPI int FCGX_Detach(FCGX_Request * r); + #if defined (__cplusplus) || defined (c_plusplus) } /* terminate extern "C" { */