home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / chap2 / 2_1 / chkserv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  854 b   |  35 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main()
  5. {
  6.     char* server_software;
  7.  
  8.     printf("Content-type: text/html\n\n");
  9.  
  10.     printf("<HTML>\n");
  11.     printf("<HEAD><TITLE>CGI Script How-to: Test Script</TITLE></HEAD>\n");
  12.     printf("<BODY>\n");
  13.  
  14.     printf("<H1>CGI Script How-to<BR>determine the type of server software</H1>\n");
  15.  
  16.     server_software = getenv("SERVER_SOFTWARE");
  17.  
  18.     if (server_software != NULL &&
  19.         strncmp(server_software, "NCSA", 4) == 0)
  20.       {
  21.         /* Do something specific for NCSA HTTPd server software */
  22.         printf("Congratulations, you have a <B>NCSA HTTPd</B> server!\n");
  23.         printf("<P>\n");
  24.         printf("The complete server name is %s.\n", server_software);
  25.       }
  26.     else
  27.       {
  28.         /* Do something else for all other servers */
  29.         printf("You have a <B>%s</B> server.\n", $server_software);
  30.       }
  31.  
  32.     printf("</BODY></HTML>\n\n");
  33.     exit(0);
  34. }
  35.