-/*
+/*
* fcgiapp.c --
*
* FastCGI application library: request-at-a-time
*/
#ifndef lint
-static const char rcsid[] = "$Id: fcgiapp.c,v 1.4 1999/07/26 04:28:08 roberts Exp $";
+static const char rcsid[] = "$Id: fcgiapp.c,v 1.5 1999/07/27 02:17:05 roberts Exp $";
#endif /* not lint */
#ifdef _WIN32
#include "fcgios.h"
/*
- * This is a workaround for one version of the HP C compiler
+ * This is a workaround for one version of the HP C compiler
* (c89 on HP-UX 9.04, also Stratus FTX), which will dump core
* if given 'long double' for varargs.
*/
/*
- * Globals
+ * Globals
*/
static int libInitialized = 0;
static char *webServerAddressList = NULL;
if(c == EOF) {
if(p == str)
return NULL;
- else
+ else
break;
- }
+ }
*p++ = c;
n--;
if(c == '\n')
*
* Results:
* The byte, or EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_PutChar(int c, FCGX_Stream *stream)
* Results:
* Number of bytes written (n) for normal return,
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_PutStr(const char *str, int n, FCGX_Stream *stream)
* Results:
* number of bytes written for normal return,
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_PutS(const char *str, FCGX_Stream *stream)
* Results:
* number of bytes written for normal return,
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_FPrintF(FCGX_Stream *stream, const char *format, ...)
* Results:
* number of bytes written for normal return,
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
*
* Results:
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_FFlush(FCGX_Stream *stream)
*
* Results:
* EOF (-1) if an error occurred.
- *
+ *
*----------------------------------------------------------------------
*/
int FCGX_FClose(FCGX_Stream *stream)
* Results:
* None.
*
- * Side effects:
+ * Side effects:
* Parameters structure updated.
*
*----------------------------------------------------------------------
- */
+ */
static void PutParam(ParamsPtr paramsPtr, char *nameValue)
{
int size;
static int write_it_all(int fd, char *buf, int len)
{
int wrote;
-
+
while (len) {
wrote = OS_Write(fd, buf, len);
if (wrote < 0)
int FCGX_IsCGI(void)
{
static int isFastCGI = -1;
-
+
if (isFastCGI != -1) {
return !isFastCGI;
}
-
+
if (!libInitialized) {
int rc = FCGX_Init();
if (rc) {
/* exit() isn't great, but hey */
exit((rc < 0) ? rc : -rc);
}
- }
+ }
isFastCGI = OS_IsFcgi();
int errStatus = FCGX_FClose(reqDataPtr->errStream);
int outStatus = FCGX_FClose(reqDataPtr->outStream);
- if (errStatus || outStatus
- || FCGX_GetError(reqDataPtr->inStream)
- || !reqDataPtr->keepConnection)
+ if (errStatus || outStatus
+ || FCGX_GetError(reqDataPtr->inStream)
+ || !reqDataPtr->keepConnection)
{
OS_IpcClose(reqDataPtr->ipcFd);
}
int FCGX_Init(void)
{
char *p;
-
+
if (libInitialized) {
return 0;
}
/* If our compiler doesn't play by the ISO rules for struct layout, halt. */
ASSERT(sizeof(FCGI_Header) == FCGI_HEADER_LEN);
- memset(&reqData, 0, sizeof(FCGX_Request));
+ FCGX_InitRequest(&reqData);
if (OS_LibInit(NULL) == -1) {
return OS_Errno ? OS_Errno : -9997;
p = getenv("FCGI_WEB_SERVER_ADDRS");
webServerAddressList = p ? StringCopy(p) : "";
-
+
libInitialized = 1;
return 0;
}
if (rc) {
return (rc < 0) ? rc : -rc;
}
- }
+ }
return FCGX_Accept_r(in, out, err, envp, &reqData);
}
* FCGX_CALL_SEQ_ERROR.
*
* Results:
- * 0 for a normal return, < 0 for error
+ * 0 for a normal return, < 0 for error
*
*----------------------------------------------------------------------
*/