X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=libfcgi%2Ffcgiapp.c;h=23e55ac087b3804e6025bc21d0886fad0ca8192d;hb=55d1f206f2bd7400f6f5f6677f7a2edadfa113e0;hp=26473cef85013840e4ea634a7fda06a33af437a8;hpb=2fe790fca7e57127be62ea485eff0c08a46a1503;p=catagits%2Ffcgi2.git diff --git a/libfcgi/fcgiapp.c b/libfcgi/fcgiapp.c index 26473ce..23e55ac 100644 --- a/libfcgi/fcgiapp.c +++ b/libfcgi/fcgiapp.c @@ -11,15 +11,9 @@ * */ #ifndef lint -static const char rcsid[] = "$Id: fcgiapp.c,v 1.19 2001/06/03 21:46:43 robs Exp $"; +static const char rcsid[] = "$Id: fcgiapp.c,v 1.24 2001/06/22 09:12:03 skimo Exp $"; #endif /* not lint */ -#include "fcgi_config.h" - -#ifdef _WIN32 -#define DLLAPI __declspec(dllexport) -#endif - #include #include #include /* for fcntl */ @@ -31,6 +25,8 @@ static const char rcsid[] = "$Id: fcgiapp.c,v 1.19 2001/06/03 21:46:43 robs Exp #include #include +#include "fcgi_config.h" + #ifdef HAVE_SYS_SOCKET_H #include /* for getpeername */ #endif @@ -43,11 +39,20 @@ static const char rcsid[] = "$Id: fcgiapp.c,v 1.19 2001/06/03 21:46:43 robs Exp #include #endif -#include "fcgimisc.h" +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifdef _WIN32 +#define DLLAPI __declspec(dllexport) +#endif + +#include "fcgiapp.h" #include "fcgiappmisc.h" + +#include "fcgimisc.h" #include "fastcgi.h" #include "fcgios.h" -#include "fcgiapp.h" /* * This is a workaround for one version of the HP C compiler @@ -184,6 +189,7 @@ char *FCGX_GetLine(char *str, int n, FCGX_Stream *stream) { int c; char *p = str; + n--; while (n > 0) { c = FCGX_GetChar(stream); @@ -193,7 +199,7 @@ char *FCGX_GetLine(char *str, int n, FCGX_Stream *stream) else break; } - *p++ = c; + *p++ = (char) c; n--; if(c == '\n') break; @@ -223,7 +229,7 @@ int FCGX_UnGetChar(int c, FCGX_Stream *stream) { || stream->rdNext == stream->stopUnget) return EOF; --(stream->rdNext); - *stream->rdNext = c; + *stream->rdNext = (unsigned char) c; return c; } @@ -264,12 +270,12 @@ int FCGX_HasSeenEOF(FCGX_Stream *stream) { int FCGX_PutChar(int c, FCGX_Stream *stream) { if(stream->wrNext != stream->stop) - return (*stream->wrNext++ = c); + return (*stream->wrNext++ = (unsigned char) c); if(stream->isClosed || stream->isReader) return EOF; stream->emptyBuffProc(stream, FALSE); if(stream->wrNext != stream->stop) - return (*stream->wrNext++ = c); + return (*stream->wrNext++ = (unsigned char) c); ASSERT(stream->isClosed); /* bug in emptyBuffProc if not */ return EOF; } @@ -393,8 +399,8 @@ static void CopyAndAdvance(char **destPtr, char **srcPtr, int n); int FCGX_VFPrintF(FCGX_Stream *stream, const char *format, va_list arg) { char *f, *fStop, *percentPtr, *p, *fmtBuffPtr, *buffPtr; - int op, performedOp, sizeModifier, buffCount, buffLen, specifierLength; - int fastPath, n, auxBuffLen, buffReqd, minWidth, precision, exp; + int op, performedOp, sizeModifier, buffCount = 0, buffLen, specifierLength; + int fastPath, n, auxBuffLen = 0, buffReqd, minWidth, precision, exp; char *auxBuffPtr = NULL; int streamCount = 0; char fmtBuff[FMT_BUFFLEN]; @@ -406,13 +412,13 @@ int FCGX_VFPrintF(FCGX_Stream *stream, const char *format, va_list arg) unsigned unsignedArg; unsigned long uLongArg; unsigned short uShortArg; - char *charPtrArg; + char *charPtrArg = NULL; void *voidPtrArg; int *intPtrArg; long *longPtrArg; short *shortPtrArg; - double doubleArg; - LONG_DOUBLE lDoubleArg; + double doubleArg = 0.0; + LONG_DOUBLE lDoubleArg = 0.0L; fmtBuff[0] = '%'; f = (char *) format; @@ -451,14 +457,14 @@ int FCGX_VFPrintF(FCGX_Stream *stream, const char *format, va_list arg) case 'h': sizeModifier = op; op = *(percentPtr + 2); - fmtBuff[1] = sizeModifier; - fmtBuff[2] = op; + fmtBuff[1] = (char) sizeModifier; + fmtBuff[2] = (char) op; fmtBuff[3] = '\0'; specifierLength = 3; break; default: sizeModifier = ' '; - fmtBuff[1] = op; + fmtBuff[1] = (char) op; fmtBuff[2] = '\0'; specifierLength = 2; break; @@ -588,11 +594,13 @@ int FCGX_VFPrintF(FCGX_Stream *stream, const char *format, va_list arg) switch(sizeModifier) { case ' ': doubleArg = va_arg(arg, double); - frexp(doubleArg, &exp); + frexp(doubleArg, &exp); break; case 'L': lDoubleArg = va_arg(arg, LONG_DOUBLE); - frexp(lDoubleArg, &exp); + /* XXX Need to check for the presence of + * frexpl() and use it if available */ + frexp((double) lDoubleArg, &exp); break; default: goto ErrorReturn; @@ -751,8 +759,8 @@ int FCGX_VFPrintF(FCGX_Stream *stream, const char *format, va_list arg) *longPtrArg = streamCount; break; case 'h': - shortPtrArg = va_arg(arg, short *); - *shortPtrArg = streamCount; + shortPtrArg = (short *) va_arg(arg, short *); + *shortPtrArg = (short) streamCount; break; default: goto ErrorReturn; @@ -1187,12 +1195,12 @@ static FCGI_Header MakeHeader( ASSERT(contentLength >= 0 && contentLength <= FCGI_MAX_LENGTH); ASSERT(paddingLength >= 0 && paddingLength <= 0xff); header.version = FCGI_VERSION_1; - header.type = type; - header.requestIdB1 = (requestId >> 8) & 0xff; - header.requestIdB0 = (requestId ) & 0xff; - header.contentLengthB1 = (contentLength >> 8) & 0xff; - header.contentLengthB0 = (contentLength ) & 0xff; - header.paddingLength = paddingLength; + header.type = (unsigned char) type; + header.requestIdB1 = (unsigned char) ((requestId >> 8) & 0xff); + header.requestIdB0 = (unsigned char) ((requestId ) & 0xff); + header.contentLengthB1 = (unsigned char) ((contentLength >> 8) & 0xff); + header.contentLengthB0 = (unsigned char) ((contentLength ) & 0xff); + header.paddingLength = (unsigned char) paddingLength; header.reserved = 0; return header; } @@ -1211,11 +1219,11 @@ static FCGI_EndRequestBody MakeEndRequestBody( int protocolStatus) { FCGI_EndRequestBody body; - body.appStatusB3 = (appStatus >> 24) & 0xff; - body.appStatusB2 = (appStatus >> 16) & 0xff; - body.appStatusB1 = (appStatus >> 8) & 0xff; - body.appStatusB0 = (appStatus ) & 0xff; - body.protocolStatus = protocolStatus; + body.appStatusB3 = (unsigned char) ((appStatus >> 24) & 0xff); + body.appStatusB2 = (unsigned char) ((appStatus >> 16) & 0xff); + body.appStatusB1 = (unsigned char) ((appStatus >> 8) & 0xff); + body.appStatusB0 = (unsigned char) ((appStatus ) & 0xff); + body.protocolStatus = (unsigned char) protocolStatus; memset(body.reserved, 0, sizeof(body.reserved)); return body; } @@ -1233,7 +1241,7 @@ static FCGI_UnknownTypeBody MakeUnknownTypeBody( int type) { FCGI_UnknownTypeBody body; - body.type = type; + body.type = (unsigned char) type; memset(body.reserved, 0, sizeof(body.reserved)); return body; } @@ -1437,7 +1445,7 @@ static int ProcessManagementRecord(int type, FCGX_Stream *stream) char **pPtr; char response[64]; /* 64 = 8 + 3*(1+1+14+1)* + padding */ char *responseP = &response[FCGI_HEADER_LEN]; - char *name, value; + char *name, value = '\0'; int len, paddedLen; if(type == FCGI_GET_VALUES) { ReadParams(paramsPtr, stream); @@ -2116,9 +2124,10 @@ int FCGX_Accept( { int rc; - if (!libInitialized) { - if ((rc = FCGX_Init())) { - return (rc < 0) ? rc : -rc; + if (! libInitialized) { + rc = FCGX_Init(); + if (rc) { + return rc; } } @@ -2224,6 +2233,7 @@ int FCGX_Accept_r(FCGX_Request *reqDataPtr) * Close the connection and try again. */ TryAgain: + reqDataPtr->keepConnection = 0; FCGX_Free(reqDataPtr); } /* for (;;) */