Annotation of capa/capa51/pProj/capaHTML.c, revision 1.7

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
1.6       albertel    5:    modify it under the terms of the GNU General Public License as
1.3       albertel    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
1.6       albertel   12:    General Public License for more details.
1.3       albertel   13: 
1.6       albertel   14:    You should have received a copy of the GNU General Public
1.3       albertel   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,
1.4       albertel   17:    Boston, MA 02111-1307, USA.
                     18: 
                     19:    As a special exception, you have permission to link this program
                     20:    with the TtH/TtM library and distribute executables, as long as you
                     21:    follow the requirements of the GNU GPL in regard to all of the
                     22:    software in the executable aside from TtH/TtM.
                     23: */
1.1       albertel   24: 
                     25: /* ||>> ================================================================ <<|| */
                     26: /*       1         2         3         4         5         6         7        */
                     27: /* 45678901234567890123456789012345678901234567890123456789012345678901234567 */
                     28: /* created by Isaac Tsai 1996                                                 */
                     29: /* ||>> ================================================================ <<|| */
                     30: 
                     31: #include <signal.h>
                     32: 
                     33: #include "capaParser.h"
                     34: #include "capaCommon.h"
                     35: #include "ranlib.h"
                     36: 
                     37: #define   _MAIN_PROGRAM_
                     38: #include "capaCGI.h"
                     39: 
                     40: /* |>> ====================== begin of main() =========================== <<| */
                     41: 
                     42: int main(int argc, char *argv[]) 
                     43: { 
                     44: #ifdef __alpha
                     45:   struct timespec      a_ts, b_ts;
                     46: #endif
                     47:   /*
                     48:   time_t               curtime;
                     49:   char                *time_str;
                     50:   double               tdiff;
                     51:   long                 sec_diff, nsec_diff;
                     52:   char                 log_str[FILE_NAME_LENGTH];
                     53:   */
                     54: #ifdef CGI_DBUG
                     55:   char                 filename[FILE_NAME_LENGTH];
                     56: #endif
                     57:   int                  tmp_int;
                     58:   
                     59: #ifdef __alpha  
                     60:   getclock(TIMEOFDAY, &a_ts);
                     61: #endif   
                     62:   signal(SIGFPE, SIG_IGN);
                     63:   strcpy(g_prog_name,argv[0]);
                     64:   setbuf(stdout,NULL);  /* non-buffered STREAM io */
                     65: 
                     66: #ifdef CGI_DBUG
                     67:    sprintf(filename,"cgi.DBUG");
                     68:    if ((g_cgi=fopen(filename,"a"))==NULL) {
                     69:      fprintf(stdout,"Error : can't open cgi debug\n"); 
                     70:      fflush(stdout);  return 2; 
                     71:    }
                     72:    setbuf(g_cgi,NULL);  /* non-buffered STREAM io */
                     73: #endif /* CGI_DBUG */
                     74: 
                     75:     fprintf(stdout,"Content-type: text/html%c%c",LF,LF);
                     76:     /*   fprintf(stdout,"<HTML><HEAD>\n");
                     77:       fprintf(stdout,"<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#EE1100\">\n");
                     78:       fflush(stdout);  
                     79:    */
                     80: 
                     81:    /* HTML header can not be shown until input has been parsed, so that I can
                     82:       be in the class directory */
                     83:     tmp_int = w_get_input();
1.7     ! albertel   84:     web_printheader(stdout);
        !            85: #ifdef  CAPA_WEB
        !            86:     fprintf(stdout,"<!-- capasbin, CAPA Version %s, %s -->\n",
        !            87: 	    CAPA_VER,COMPILE_DATE);
        !            88: #else
        !            89:     fprintf(stdout,"<!-- capahtml, CAPA Version %s, %s -->\n",
        !            90: 	    CAPA_VER,COMPILE_DATE);
        !            91: #endif
        !            92:     fprintf(stdout,"<!-- CAPA is released under the GNU GPL v2 see COPYING for details. -->\n");
1.1       albertel   93:     if ((tmp_int!=0) && (!((tmp_int == 32)||(tmp_int == 64)||(tmp_int == (32|64))))) { 
                     94:       /* <== let's get rid of errcode 32 and 64, */
                     95:       /* REMOTE_HOST */
                     96:       fprintf(stdout,"<!-- w_get_input returned error code %d. -->\n",tmp_int);
                     97:       fprintf(stdout,"<!-- getinput error -->\n"); fflush(stdout);
                     98:       fprintf(stdout,"</BODY></HTML>\n"); 
                     99: #ifdef CGI_DBUG
                    100:       fprintf(g_cgi,"w_get_input(): error\n"); fflush(g_cgi);
                    101: #endif /* CGI_DBUG */
                    102:       web_printfooter(stdout);
                    103:       return (1);
                    104:     } else {
                    105: #ifdef CGI_DBUG
                    106:       fprintf(g_cgi,"w_get_input(): %d error, run_mode=%d\n",tmp_int,
                    107: 	      g_run_mode); fflush(g_cgi);
                    108: #endif /* CGI_DBUG */    
                    109:       switch( g_run_mode ) {
                    110:       case 0:  break;
                    111:       case M_CHECKIN:  print_mainmenu(g_class_name, g_student_number, g_entered_pin); break;
                    112:       case M_TRYSET:   process_mode(TRY_SET_MODE);       break;
                    113:       case M_VIEWPREV: process_mode(VIEW_PREVIOUS_MODE); break;
                    114:       case M_VIEWSUMM: print_summary(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set);
                    115: 	   break;
                    116:       case M_EXAMSUMM: 
                    117:       case M_QUIZSUMM: process_summary(g_run_mode); break;
                    118: #ifdef   CAPA_WEB
                    119:       case M_CHECKANS: process_mode(CHECK_ANSWER_MODE); break;
                    120: #endif
                    121:       case M_TERMSCORE: print_termscore_page(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set,stdout);
                    122:            break;
                    123:       default: break;
                    124:       }
                    125:       web_printfooter(stdout);
                    126:     }
                    127:     
                    128:     /*    fprintf(stdout,"</BODY></HTML>\n"); fflush(stdout);*/
                    129: 
                    130: #ifdef CGI_DBUG
                    131:     fflush(g_cgi); fclose(g_cgi);
                    132: #endif /* CGI_DBUG */
                    133: 
                    134:     /*
                    135:     getclock(TIMEOFDAY, &b_ts);
                    136:     sec_diff  = b_ts.tv_sec  - a_ts.tv_sec;
                    137:     nsec_diff = b_ts.tv_nsec - a_ts.tv_nsec;
                    138:     tdiff = (double)1000000000.0 * sec_diff + (double)nsec_diff;
                    139:     sprintf(log_str,"%s %s %lg",getenv("REMOTE_HOST"),getenv("HTTP_USER_AGENT"),tdiff);
                    140:     w_log_timing(g_student_number,g_login_set,g_student_data.s_sec,log_str);
                    141:     */
                    142:     return (0);
                    143: }
                    144: 
                    145: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>