/*****************************************************************************/ /* CGIplusTest.c Script for testing the relative efficiencies of CGI and CGIplus. Also for scripting benchmarks between the WASD, OSU and Apache environments! USAGE ----- Supply a query string ("?blah-blah") of/to ... * list all CGI(plus) variables integer output number of 80 character lines before=integer sleep number of seconds before beginning output after=integer sleep number of seconds after completing output non-cgi-response upset the server by outputting a non-CGI response CGIPLUS_VAR_RECORD ------------------ To "force" the use of 'record' mode (perhaps for performance comparison purposes) assign a non-empty environment variable (symbol or logical) named CGIPLUS_VAR_RECORD. This is detected in the CGIPLUS_CGIVAR.C module. VERSION HISTORY (update SOFTWAREVN as well!) --------------- 19-OCT-2009 MGD v1.5.0, use CGILIB to make the OSU test-bench more equitable and "Pragma: no-cache" - gotcha! 23-DEC-2003 MGD v1.4.2, minor conditional mods to support IA64 18-JUN-2003 MGD v1.4.1, CSWS APACHE_SHARED_SOCKET to APACHE$SHARED_SOCKET, 09-APR-2001 MGD v1.4.0, facility to test/measure CGIplus 'struct' mode 11-JAN-2001 MGD v1.3.0, CSWS V1.0-1 (Apache) "fixbg" support 23-SEP-2000 MGD v1.2,0, minor mods for comparison with VMS Apache 05-MAR-1999 MGD v1.1.0, minor mods for comparison with OSU 08-JUN-1997 MGD v1.0.0, initial development */ /*****************************************************************************/ #define SOFTWAREVN "1.5.0" #define SOFTWARENM "CGIPLUSTEST" #ifdef __ALPHA # define SOFTWAREID SOFTWARENM " AXP-" SOFTWAREVN #endif #ifdef __ia64 # define SOFTWAREID SOFTWARENM " IA64-" SOFTWAREVN #endif #ifdef __VAX # define SOFTWAREID SOFTWARENM " VAX-" SOFTWAREVN #endif /* standard C headers */ #include #include #include #include #include #include #include int AfterCount, BeforeCount, Debug, IsCgiPlus, RequestedCount; char Utility [] = "CGIPLUSTEST", Line80Chars [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789\ !@#$%^&*()_+-=<>,\n"; /*****************************************************************************/ /* */ main (int argc, char* argv[]) { char *cptr; /*********/ /* begin */ /*********/ Debug = getenv ("CGIPLUSTEST$DBUG") != NULL; CgiLibEnvironmentInit (argc, argv, TRUE); if (Debug) CgiLibEnvironmentRecordOut (); else if (!CgiLibEnvironmentIsOsu()) if (getenv("SYS$NET")) stdout = freopen ("SYS$OUTPUT:", "w", stdout, "ctx=bin", "mrs=4096"); IsCgiPlus = CgiLibEnvironmentIsCgiPlus (); for (;;) { /* once for standard CGI, multiple times for CGIplus */ RequestedCount = -1; if (IsCgiPlus) { /* synchronize and read the CGIplus variable stream */ CgiLibVar (""); } else if (Debug) { /* won't work for OSU! */ fprintf (stdout, "Content-Type: text/plain\n\n"); system ("show sym *"); } cptr = CgiLibVar ("WWW_QUERY_STRING"); AfterCount = BeforeCount = RequestedCount = 0; if (isdigit(*cptr)) RequestedCount = atoi(cptr); else if (!strncmp (cptr, "after=", 6)) { RequestedCount = 10; AfterCount = atoi(cptr+6); } else if (!strncmp (cptr, "before=", 7)) { RequestedCount = 10; BeforeCount = atoi(cptr+7); } else if (!strncmp (cptr, "non-cgi", 6)) fprintf (stdout, "Output to make it a non-CGI-compliant response\n"); if (BeforeCount) sleep (BeforeCount); fprintf (stdout, "Status: 200\r\n\ Content-Type: text/plain\r\n\ Content-Length: %d\r\n\ Script-Control: X-stream-mode\r\n\ Pragma: no-cache\r\n\ Expires: Fri, 13 Jan 1978 14:00:00 GMT\r\n\ \r\n", RequestedCount * (sizeof(Line80Chars)-1)); fflush (stdout); if (*cptr == '*') { /* return all CGIplus variables in successive calls */ while ((cptr = CgiLibVar ("*")) != NULL) fprintf (stdout, "|%s|\n", cptr); } else if (RequestedCount < 0) { fprintf (stdout, "Usage: Supply a URL with a query string containing \ an integer representing the number of 80 character lines \ to be returned during the test.\n"); } else { while (RequestedCount--) fputs (Line80Chars, stdout); } if (AfterCount) sleep (AfterCount); if (!IsCgiPlus) break; CgiLibCgiPlusEOF (); } exit (1); } /*****************************************************************************/