Annotation of capa/capa51/pProj/capaHTML.c, revision 1.3
1.3 ! albertel 1: /* wrapper for capasbin/html
! 2: Copyright (C) 1992-2000 Michigan State University
! 3:
! 4: The CAPA system is free software; you can redistribute it and/or
! 5: modify it under the terms of the GNU Library General Public License as
! 6: published by the Free Software Foundation; either version 2 of the
! 7: License, or (at your option) any later version.
! 8:
! 9: The CAPA system is distributed in the hope that it will be useful,
! 10: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! 12: Library General Public License for more details.
! 13:
! 14: You should have received a copy of the GNU Library General Public
! 15: License along with the CAPA system; see the file COPYING. If not,
! 16: write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
! 17: Boston, MA 02111-1307, USA. */
1.1 albertel 18:
19: /* ||>> ================================================================ <<|| */
20: /* 1 2 3 4 5 6 7 */
21: /* 45678901234567890123456789012345678901234567890123456789012345678901234567 */
22: /* created by Isaac Tsai 1996 */
23: /* ||>> ================================================================ <<|| */
24:
25: #include <signal.h>
26:
27: #include "capaParser.h"
28: #include "capaCommon.h"
29: #include "ranlib.h"
30:
31: #define _MAIN_PROGRAM_
32: #include "capaCGI.h"
33:
34: /* |>> ====================== begin of main() =========================== <<| */
35:
36: int main(int argc, char *argv[])
37: {
38: #ifdef __alpha
39: struct timespec a_ts, b_ts;
40: #endif
41: /*
42: time_t curtime;
43: char *time_str;
44: double tdiff;
45: long sec_diff, nsec_diff;
46: char log_str[FILE_NAME_LENGTH];
47: */
48: #ifdef CGI_DBUG
49: char filename[FILE_NAME_LENGTH];
50: #endif
51: int tmp_int;
52:
53: #ifdef __alpha
54: getclock(TIMEOFDAY, &a_ts);
55: #endif
56: signal(SIGFPE, SIG_IGN);
57: strcpy(g_prog_name,argv[0]);
58: setbuf(stdout,NULL); /* non-buffered STREAM io */
59:
60: #ifdef CGI_DBUG
61: sprintf(filename,"cgi.DBUG");
62: if ((g_cgi=fopen(filename,"a"))==NULL) {
63: fprintf(stdout,"Error : can't open cgi debug\n");
64: fflush(stdout); return 2;
65: }
66: setbuf(g_cgi,NULL); /* non-buffered STREAM io */
67: #endif /* CGI_DBUG */
68:
69: fprintf(stdout,"Content-type: text/html%c%c",LF,LF);
70: /* fprintf(stdout,"<HTML><HEAD>\n");
71: fprintf(stdout,"<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#EE1100\">\n");
72: fflush(stdout);
73: */
74:
75: /* HTML header can not be shown until input has been parsed, so that I can
76: be in the class directory */
77: tmp_int = w_get_input();
78: if ((tmp_int!=0) && (!((tmp_int == 32)||(tmp_int == 64)||(tmp_int == (32|64))))) {
79: /* <== let's get rid of errcode 32 and 64, */
80: /* REMOTE_HOST */
81: web_printheader(stdout);
1.2 albertel 82: #ifdef CAPA_WEB
83: fprintf(stdout,"<!-- capasbin, CAPA Version %s, %s -->\n",
84: CAPA_VER,COMPILE_DATE);
85: #else
86: fprintf(stdout,"<!-- capahtml, CAPA Version %s, %s -->\n",
87: CAPA_VER,COMPILE_DATE);
88: #endif
1.1 albertel 89: fprintf(stdout,"<!-- w_get_input returned error code %d. -->\n",tmp_int);
90: fprintf(stdout,"<!-- getinput error -->\n"); fflush(stdout);
91: fprintf(stdout,"</BODY></HTML>\n");
92: #ifdef CGI_DBUG
93: fprintf(g_cgi,"w_get_input(): error\n"); fflush(g_cgi);
94: #endif /* CGI_DBUG */
95: web_printfooter(stdout);
96: return (1);
97: } else {
98: #ifdef CGI_DBUG
99: fprintf(g_cgi,"w_get_input(): %d error, run_mode=%d\n",tmp_int,
100: g_run_mode); fflush(g_cgi);
101: #endif /* CGI_DBUG */
102: web_printheader(stdout);
103: switch( g_run_mode ) {
104: case 0: break;
105: case M_CHECKIN: print_mainmenu(g_class_name, g_student_number, g_entered_pin); break;
106: case M_TRYSET: process_mode(TRY_SET_MODE); break;
107: case M_VIEWPREV: process_mode(VIEW_PREVIOUS_MODE); break;
108: case M_VIEWSUMM: print_summary(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set);
109: break;
110: case M_EXAMSUMM:
111: case M_QUIZSUMM: process_summary(g_run_mode); break;
112: #ifdef CAPA_WEB
113: case M_CHECKANS: process_mode(CHECK_ANSWER_MODE); break;
114: #endif
115: case M_TERMSCORE: print_termscore_page(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set,stdout);
116: break;
117: default: break;
118: }
119: web_printfooter(stdout);
120: }
121:
122: /* fprintf(stdout,"</BODY></HTML>\n"); fflush(stdout);*/
123:
124: #ifdef CGI_DBUG
125: fflush(g_cgi); fclose(g_cgi);
126: #endif /* CGI_DBUG */
127:
128: /*
129: getclock(TIMEOFDAY, &b_ts);
130: sec_diff = b_ts.tv_sec - a_ts.tv_sec;
131: nsec_diff = b_ts.tv_nsec - a_ts.tv_nsec;
132: tdiff = (double)1000000000.0 * sec_diff + (double)nsec_diff;
133: sprintf(log_str,"%s %s %lg",getenv("REMOTE_HOST"),getenv("HTTP_USER_AGENT"),tdiff);
134: w_log_timing(g_student_number,g_login_set,g_student_data.s_sec,log_str);
135: */
136: return (0);
137: }
138:
139:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>