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

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);
1.2     ! albertel   66: #ifdef  CAPA_WEB
        !            67:   fprintf(stdout,"<!-- capasbin, CAPA Version %s, %s -->\n",
        !            68: 	  CAPA_VER,COMPILE_DATE);
        !            69: #else
        !            70:   fprintf(stdout,"<!-- capahtml, CAPA Version %s, %s -->\n",
        !            71: 	  CAPA_VER,COMPILE_DATE);
        !            72: #endif
1.1       albertel   73:       fprintf(stdout,"<!-- w_get_input returned error code %d. -->\n",tmp_int);
                     74:       fprintf(stdout,"<!-- getinput error -->\n"); fflush(stdout);
                     75:       fprintf(stdout,"</BODY></HTML>\n"); 
                     76: #ifdef CGI_DBUG
                     77:       fprintf(g_cgi,"w_get_input(): error\n"); fflush(g_cgi);
                     78: #endif /* CGI_DBUG */
                     79:       web_printfooter(stdout);
                     80:       return (1);
                     81:     } else {
                     82: #ifdef CGI_DBUG
                     83:       fprintf(g_cgi,"w_get_input(): %d error, run_mode=%d\n",tmp_int,
                     84: 	      g_run_mode); fflush(g_cgi);
                     85: #endif /* CGI_DBUG */    
                     86:       web_printheader(stdout);
                     87:       switch( g_run_mode ) {
                     88:       case 0:  break;
                     89:       case M_CHECKIN:  print_mainmenu(g_class_name, g_student_number, g_entered_pin); break;
                     90:       case M_TRYSET:   process_mode(TRY_SET_MODE);       break;
                     91:       case M_VIEWPREV: process_mode(VIEW_PREVIOUS_MODE); break;
                     92:       case M_VIEWSUMM: print_summary(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set);
                     93: 	   break;
                     94:       case M_EXAMSUMM: 
                     95:       case M_QUIZSUMM: process_summary(g_run_mode); break;
                     96: #ifdef   CAPA_WEB
                     97:       case M_CHECKANS: process_mode(CHECK_ANSWER_MODE); break;
                     98: #endif
                     99:       case M_TERMSCORE: print_termscore_page(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set,stdout);
                    100:            break;
                    101:       default: break;
                    102:       }
                    103:       web_printfooter(stdout);
                    104:     }
                    105:     
                    106:     /*    fprintf(stdout,"</BODY></HTML>\n"); fflush(stdout);*/
                    107: 
                    108: #ifdef CGI_DBUG
                    109:     fflush(g_cgi); fclose(g_cgi);
                    110: #endif /* CGI_DBUG */
                    111: 
                    112:     /*
                    113:     getclock(TIMEOFDAY, &b_ts);
                    114:     sec_diff  = b_ts.tv_sec  - a_ts.tv_sec;
                    115:     nsec_diff = b_ts.tv_nsec - a_ts.tv_nsec;
                    116:     tdiff = (double)1000000000.0 * sec_diff + (double)nsec_diff;
                    117:     sprintf(log_str,"%s %s %lg",getenv("REMOTE_HOST"),getenv("HTTP_USER_AGENT"),tdiff);
                    118:     w_log_timing(g_student_number,g_login_set,g_student_data.s_sec,log_str);
                    119:     */
                    120:     return (0);
                    121: }
                    122: 
                    123: 

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