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

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,
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();
                     84:     if ((tmp_int!=0) && (!((tmp_int == 32)||(tmp_int == 64)||(tmp_int == (32|64))))) { 
                     85:       /* <== let's get rid of errcode 32 and 64, */
                     86:       /* REMOTE_HOST */
                     87:       web_printheader(stdout);
1.2       albertel   88: #ifdef  CAPA_WEB
                     89:   fprintf(stdout,"<!-- capasbin, CAPA Version %s, %s -->\n",
                     90: 	  CAPA_VER,COMPILE_DATE);
                     91: #else
                     92:   fprintf(stdout,"<!-- capahtml, CAPA Version %s, %s -->\n",
                     93: 	  CAPA_VER,COMPILE_DATE);
                     94: #endif
1.1       albertel   95:       fprintf(stdout,"<!-- w_get_input returned error code %d. -->\n",tmp_int);
                     96:       fprintf(stdout,"<!-- getinput error -->\n"); fflush(stdout);
                     97:       fprintf(stdout,"</BODY></HTML>\n"); 
                     98: #ifdef CGI_DBUG
                     99:       fprintf(g_cgi,"w_get_input(): error\n"); fflush(g_cgi);
                    100: #endif /* CGI_DBUG */
                    101:       web_printfooter(stdout);
                    102:       return (1);
                    103:     } else {
                    104: #ifdef CGI_DBUG
                    105:       fprintf(g_cgi,"w_get_input(): %d error, run_mode=%d\n",tmp_int,
                    106: 	      g_run_mode); fflush(g_cgi);
                    107: #endif /* CGI_DBUG */    
                    108:       web_printheader(stdout);
                    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>