** Start of listing of h2.c ** #include #include #include #include int main(void) { time_t t; struct tm* ptm; char* sTime; int slen; char* ip; unsigned char *rmstr; unsigned char *qus; char qt = '"'; printf("Content-type: text/plain\n\n"); printf("Working on new stuff...\n"); rmstr = getenv("REQUEST_METHOD"); if (rmstr == NULL) { printf("Request method returned NULL, why??\n"); return -1; } else { printf("The request method is: [%s]\n", rmstr); } if (strcmp(rmstr,"POST") == 0) { printf("*** POST method not yet implemented\n"); return -1; } else if (strcmp(rmstr,"GET") == 0) { qus = getenv("QUERY_STRING"); printf("The query string is: [%s]\n", qus); } else { printf("*** Unknown request method, neither GET nor POST\n"); return -1; } printf("* End of debug output.\n\n"); if (strstr(qus,"date") == NULL) { printf("You didn't ask for %cdate%c this time.\n", qt, qt); } else { printf("The string %cdate%c occurred, so here it is:\n", qt, qt); t = time(NULL); ptm = localtime(&t); sTime = asctime(ptm); slen = strlen(sTime); sTime[slen-1] = sTime[slen]; /* Copy null byte to clobber newline. */ slen = strlen(sTime); printf("The time is %s in California.\n", sTime); } printf("\n"); if (strstr(qus,"IP") != NULL) { ip = getenv("REMOTE_ADDR"); printf("The IP number %s is where your client/browser is located.\n", ip); } else if (strstr(qus,"ip") != NULL) { printf("No, the key %cIP%c must be in upper case to work here!\n", qt, qt); } else { printf("You didn't ask for %cIP%c this time.\n", qt, qt); } printf("\n"); if (strstr(qus,"name") != NULL) { printf("My name is Robert Elton Maas.\n"); } else { printf("You didn't ask for %cname%c this time.\n", qt, qt); } return 0; } ** End of listing of h2.c ** Here is the directory entry for that source file: -rw------- 1 rem user 1861 Feb 14 2007 h2.c ^ Note user execute permission *not* needed for source files. That gets compiled to a.out, but then renamed to something.cgi so that it will be usable by remote users via CGI: -rwx------ 1 rem user 6527 Jul 11 2005 h2-c.cgi ^ Note user execute permission needed for all CGI programs. (because compiled-C is native machine code running directly on machine)