Annotation of capa/capa51/pProj/capaHTML.c, revision 1.1
1.1 ! albertel 1:
! 2: /* ||>> ================================================================ <<|| */
! 3: /* 1 2 3 4 5 6 7 */
! 4: /* 45678901234567890123456789012345678901234567890123456789012345678901234567 */
! 5: /* created by Isaac Tsai 1996 */
! 6: /* copyrighted by Isaac Tsai 1996, 1997, 1998, 1999 */
! 7: /* ||>> ================================================================ <<|| */
! 8:
! 9: #include <signal.h>
! 10:
! 11: #include "capaParser.h"
! 12: #include "capaCommon.h"
! 13: #include "ranlib.h"
! 14:
! 15: #define _MAIN_PROGRAM_
! 16: #include "capaCGI.h"
! 17:
! 18: /* |>> ====================== begin of main() =========================== <<| */
! 19:
! 20: int main(int argc, char *argv[])
! 21: {
! 22: #ifdef __alpha
! 23: struct timespec a_ts, b_ts;
! 24: #endif
! 25: /*
! 26: time_t curtime;
! 27: char *time_str;
! 28: double tdiff;
! 29: long sec_diff, nsec_diff;
! 30: char log_str[FILE_NAME_LENGTH];
! 31: */
! 32: #ifdef CGI_DBUG
! 33: char filename[FILE_NAME_LENGTH];
! 34: #endif
! 35: int tmp_int;
! 36:
! 37: #ifdef __alpha
! 38: getclock(TIMEOFDAY, &a_ts);
! 39: #endif
! 40: signal(SIGFPE, SIG_IGN);
! 41: strcpy(g_prog_name,argv[0]);
! 42: setbuf(stdout,NULL); /* non-buffered STREAM io */
! 43:
! 44: #ifdef CGI_DBUG
! 45: sprintf(filename,"cgi.DBUG");
! 46: if ((g_cgi=fopen(filename,"a"))==NULL) {
! 47: fprintf(stdout,"Error : can't open cgi debug\n");
! 48: fflush(stdout); return 2;
! 49: }
! 50: setbuf(g_cgi,NULL); /* non-buffered STREAM io */
! 51: #endif /* CGI_DBUG */
! 52:
! 53: fprintf(stdout,"Content-type: text/html%c%c",LF,LF);
! 54: /* fprintf(stdout,"<HTML><HEAD>\n");
! 55: fprintf(stdout,"<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#EE1100\">\n");
! 56: fflush(stdout);
! 57: */
! 58:
! 59: /* HTML header can not be shown until input has been parsed, so that I can
! 60: be in the class directory */
! 61: tmp_int = w_get_input();
! 62: if ((tmp_int!=0) && (!((tmp_int == 32)||(tmp_int == 64)||(tmp_int == (32|64))))) {
! 63: /* <== let's get rid of errcode 32 and 64, */
! 64: /* REMOTE_HOST */
! 65: web_printheader(stdout);
! 66: fprintf(stdout,"<!-- w_get_input returned error code %d. -->\n",tmp_int);
! 67: fprintf(stdout,"<!-- getinput error -->\n"); fflush(stdout);
! 68: fprintf(stdout,"</BODY></HTML>\n");
! 69: #ifdef CGI_DBUG
! 70: fprintf(g_cgi,"w_get_input(): error\n"); fflush(g_cgi);
! 71: #endif /* CGI_DBUG */
! 72: web_printfooter(stdout);
! 73: return (1);
! 74: } else {
! 75: #ifdef CGI_DBUG
! 76: fprintf(g_cgi,"w_get_input(): %d error, run_mode=%d\n",tmp_int,
! 77: g_run_mode); fflush(g_cgi);
! 78: #endif /* CGI_DBUG */
! 79: web_printheader(stdout);
! 80: switch( g_run_mode ) {
! 81: case 0: break;
! 82: case M_CHECKIN: print_mainmenu(g_class_name, g_student_number, g_entered_pin); break;
! 83: case M_TRYSET: process_mode(TRY_SET_MODE); break;
! 84: case M_VIEWPREV: process_mode(VIEW_PREVIOUS_MODE); break;
! 85: case M_VIEWSUMM: print_summary(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set);
! 86: break;
! 87: case M_EXAMSUMM:
! 88: case M_QUIZSUMM: process_summary(g_run_mode); break;
! 89: #ifdef CAPA_WEB
! 90: case M_CHECKANS: process_mode(CHECK_ANSWER_MODE); break;
! 91: #endif
! 92: case M_TERMSCORE: print_termscore_page(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set,stdout);
! 93: break;
! 94: default: break;
! 95: }
! 96: web_printfooter(stdout);
! 97: }
! 98:
! 99: /* fprintf(stdout,"</BODY></HTML>\n"); fflush(stdout);*/
! 100:
! 101: #ifdef CGI_DBUG
! 102: fflush(g_cgi); fclose(g_cgi);
! 103: #endif /* CGI_DBUG */
! 104:
! 105: /*
! 106: getclock(TIMEOFDAY, &b_ts);
! 107: sec_diff = b_ts.tv_sec - a_ts.tv_sec;
! 108: nsec_diff = b_ts.tv_nsec - a_ts.tv_nsec;
! 109: tdiff = (double)1000000000.0 * sec_diff + (double)nsec_diff;
! 110: sprintf(log_str,"%s %s %lg",getenv("REMOTE_HOST"),getenv("HTTP_USER_AGENT"),tdiff);
! 111: w_log_timing(g_student_number,g_login_set,g_student_data.s_sec,log_str);
! 112: */
! 113: return (0);
! 114: }
! 115:
! 116:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>