Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. cgimin.c
  5. Abstract:
  6. This module demonstrates a minimal CGI executable for HTTP server
  7. It mimics the action of BGI program w3min.dll
  8. Author:
  9. Murali R. Krishnan (MuraliK) 19-June-1995
  10. Revision History:
  11. --*/
  12. #include <windows.h>
  13. #include <stdio.h>
  14. # include <cgi.h>
  15. # define DEFAULT_LEN ( 256)
  16. int __cdecl
  17. main( int argc, char * argv[])
  18. {
  19. char rgchMethod[DEFAULT_LEN];
  20. char rgchQuery[DEFAULT_LEN];
  21. char rgchPathInfo[DEFAULT_LEN];
  22. char rgchXlatedPathInfo[DEFAULT_LEN];
  23. DWORD dwLen;
  24. rgchMethod[0] = rgchQuery[0] =
  25. rgchPathInfo[0] = rgchXlatedPathInfo[0] = '\0';
  26. dwLen = DEFAULT_LEN;
  27. dwLen = GetEnvironmentVariableA( PSZ_REQUEST_METHOD_A, rgchMethod, dwLen);
  28. if ( dwLen > DEFAULT_LEN) {
  29. fprintf( stderr, " Environment variable %s has value of length %d\n",
  30. PSZ_REQUEST_METHOD_A, dwLen);
  31. }
  32. dwLen = DEFAULT_LEN;
  33. dwLen = GetEnvironmentVariableA( PSZ_PATH_INFO_A, rgchPathInfo, dwLen);
  34. if ( dwLen > DEFAULT_LEN) {
  35. fprintf( stderr, " Environment variable %s has value of length %d\n",
  36. PSZ_PATH_INFO_A, dwLen);
  37. }
  38. dwLen = DEFAULT_LEN;
  39. dwLen = GetEnvironmentVariableA( PSZ_QUERY_STRING_A, rgchQuery, dwLen);
  40. if ( dwLen > DEFAULT_LEN) {
  41. fprintf( stderr, " Environment variable %s has value of length %d\n",
  42. PSZ_QUERY_STRING_A, dwLen);
  43. }
  44. dwLen = DEFAULT_LEN;
  45. dwLen = GetEnvironmentVariableA( PSZ_PATH_TRANSLATED_A,
  46. rgchXlatedPathInfo, dwLen);
  47. if ( dwLen > DEFAULT_LEN) {
  48. fprintf( stderr, " Environment variable %s has value of length %d\n",
  49. PSZ_PATH_TRANSLATED_A, dwLen);
  50. }
  51. printf(
  52. "Content-Type: text/html\r\n"
  53. "\r\n"
  54. "<head><title>Minimal Server Extension Example</title></head>\n"
  55. "<body><h1>Minimal Server Extension Example (CGI)</h1>\n"
  56. "<p>Method = %s\n"
  57. "<p>Query String = %s\n"
  58. "<p>Path Info = %s\n"
  59. "<p>Translated Path Info = %s\n"
  60. "<p>"
  61. "<p>"
  62. "<form METHOD=\"POST\" ACTION=\"/scripts/w3min.dll/PathInfo/foo\">"
  63. "Enter your name: <input text name=\"Name\" size=36><br>"
  64. "<input type=\"submit\" value=\"Do Query\">"
  65. "</body>",
  66. rgchMethod,
  67. rgchQuery,
  68. rgchPathInfo,
  69. rgchXlatedPathInfo);
  70. return (1);
  71. } // main()
  72. /************************* End Of File ************************/