| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflhttp.h" char * cgi_get_input ( int iMethod)
Gets CGI data input from stdin or the enviorment vairable QUERY_STRING, to form a stream to be used by cgi_fld_by_name, cgi_fld_by_index and cgi_fld_len_by_index functions. After you have finshed with the input stream from this function you should call, cgi_free_input to free it up. Submitted by Scott Beasley jscottb@infoave.com
{ int iStdinLen = 0, iMethodWas = 0; char *strHead, *strRetBuf; if (iMethod == CGIPOST || iMethod == CGIETHER) { if (getenv ("CONTENT_LENGTH")) { iStdinLen = atoi (getenv ("CONTENT_LENGTH")); iMethodWas = 1; } } if (iMethod == CGIGET || (iMethod == CGIETHER && !iStdinLen)) { if (getenv ("QUERY_STRING")) { iStdinLen = strlen (getenv ("QUERY_STRING")); iMethodWas = 0; } } if (!iStdinLen) return (NULL); strHead = strRetBuf = (char *) malloc (sizeof (char) * iStdinLen + 1); if (strHead == NULL) return (NULL); memset (strRetBuf, 0, iStdinLen + 1); if (iMethodWas == CGIPOST) fread (strRetBuf, sizeof (char), iStdinLen, stdin); else strncpy (strRetBuf, getenv ("QUERY_STRING"), (iStdinLen + 1)); return (*strHead? strHead: NULL); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |