#include #include #include #include #define LOG_FILE "/html/user/cgi-bin/r-log" char buf[256]; /***********************************************************/ main() { printf("Location: http://www.xxxxx.edu/xxx/\n\n"); log_access(); } /* end of main */ /*******************************************************************/ log_access() { FILE *lf; time_t t; char *strp; lf = fopen(LOG_FILE, "a"); time(&t); sprintf(buf, "\n>>>> %s", ctime(&t) ); fputs(buf, lf); if ( NULL == ( strp = (char *)getenv("REMOTE_HOST") ) ) { sprintf(buf, " REMOTE_HOST = NULL\n"); } else { sprintf(buf, " REMOTE_HOST = %s\n", strp); } fputs(buf, lf); if ( NULL == ( strp = (char *)getenv("HTTP_REFERER") ) ) { sprintf(buf, " HTTP_REFERER = NULL\n"); } else { sprintf(buf, " HTTP_REFERER = %s\n", strp); } fputs(buf, lf); if ( NULL == ( strp = (char *)getenv("HTTP_USER_AGENT") ) ) { sprintf(buf, " HTTP_USER_AGENT = NULL\n"); } else { sprintf(buf, " HTTP_USER_AGENT = %s\n", strp); } fputs(buf, lf); fclose(lf); } /* end of log_access */