/* * echo2.c -- * * Produce a page containing all the inputs (fcgiapp version) * * * Copyright (c) 1996 Open Market, Inc. * * See the file "LICENSE.TERMS" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #ifndef lint static const char rcsid[] = "$Id: echo-x.c,v 1.1 2001/06/19 15:06:17 robs Exp $"; #endif /* not lint */ #include "fcgi_config.h" #include #ifdef HAVE_UNISTD_H #include #endif #ifdef _WIN32 #include #else extern char **environ; #endif #include "fcgiapp.h" static void PrintEnv(FCGX_Stream *out, char *label, char **envp) { FCGX_FPrintF(out, "%s:
\n
\n", label);
    for( ; *envp != NULL; envp++) {
        FCGX_FPrintF(out, "%s\n", *envp);
    }
    FCGX_FPrintF(out, "

\n"); } int main () { FCGX_Stream *in, *out, *err; FCGX_ParamArray envp; int count = 0; while (FCGX_Accept(&in, &out, &err, &envp) >= 0) { char *contentLength = FCGX_GetParam("CONTENT_LENGTH", envp); int len = 0; FCGX_FPrintF(out, "Content-type: text/html\r\n" "\r\n" "FastCGI echo (fcgiapp version)" "

FastCGI echo (fcgiapp version)

\n" "Request number %d, Process ID: %d

\n", ++count, getpid()); if (contentLength != NULL) len = strtol(contentLength, NULL, 10); if (len <= 0) { FCGX_FPrintF(out, "No data from standard input.

\n"); } else { int i, ch; FCGX_FPrintF(out, "Standard input:
\n

\n");
            for (i = 0; i < len; i++) {
                if ((ch = FCGX_GetChar(in)) < 0) {
                    FCGX_FPrintF(out,
                        "Error: Not enough bytes received on standard input

\n"); break; } FCGX_PutChar(ch, out); } FCGX_FPrintF(out, "\n

\n"); } PrintEnv(out, "Request environment", envp); PrintEnv(out, "Initial environment", environ); } /* while */ return 0; }