#include void doctype() { printf("Content-Type: text/html\n\n"); } void nph() { printf( "HTTP/1.0: 200 OK\r\n" "Date: Wed, 26-Aug-1998 23:55:00 MST\r\n" "Server: Netscape-FastTrack/2.0\r\n" "MIME-version: 1.0\r\n"); } void head(char *a_title) { printf( "\n" " %s\n" "" ,a_title); } void tail() { printf("\n\n"); // putc(_F_EOF,stdout); } void dumpenv(char * list[]) { while(*list != NULL) printf("%s
\n",*list++); } void main(int argc, char *argv[], char *env[]) { FILE *in, *out; int ver; nph(); /* Don't let server parse header */ in = fopen("ver.bin","r"); if (in) { fscanf(in,"%d",&ver); fclose(in); in = NULL; } else ver = 0; out = fopen("ver.bin","w"); if (out) { ver++; fprintf(out,"%d",ver); fclose(out); out = NULL; } /* send mime */ doctype(); /* send html head and title */ head("My CGI script"); printf( "\n" "

Hello World!

\n" " Current version is %d
" ,ver ); /* Dump CGI environment variables */ dumpenv(env); puts("
"); /* send html closing tags */ tail(); }