File:  [LON-CAPA] / capa / capa51 / pProj / capaHTML.c
Revision 1.6: download - view: text, annotated - select for diffs
Mon Aug 7 20:47:29 2000 UTC (23 years, 9 months ago) by albertel
Branches: MAIN
CVS tags: release_5-1-3, HEAD
- fixed license notices the reference the GNU GPL rather than the GNU LGPL

    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 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:    General Public License for more details.
   13: 
   14:    You should have received a copy of the GNU 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.
   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: */
   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);
   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
   95:       fprintf(stdout,"<!-- CAPA is released under the GNU GPL v2 see COPYING for details. -->\n");
   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:       web_printheader(stdout);
  110:       switch( g_run_mode ) {
  111:       case 0:  break;
  112:       case M_CHECKIN:  print_mainmenu(g_class_name, g_student_number, g_entered_pin); break;
  113:       case M_TRYSET:   process_mode(TRY_SET_MODE);       break;
  114:       case M_VIEWPREV: process_mode(VIEW_PREVIOUS_MODE); break;
  115:       case M_VIEWSUMM: print_summary(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set);
  116: 	   break;
  117:       case M_EXAMSUMM: 
  118:       case M_QUIZSUMM: process_summary(g_run_mode); break;
  119: #ifdef   CAPA_WEB
  120:       case M_CHECKANS: process_mode(CHECK_ANSWER_MODE); break;
  121: #endif
  122:       case M_TERMSCORE: print_termscore_page(g_cpath,g_class_name,g_student_number, g_entered_pin, g_login_set,stdout);
  123:            break;
  124:       default: break;
  125:       }
  126:       web_printfooter(stdout);
  127:     }
  128:     
  129:     /*    fprintf(stdout,"</BODY></HTML>\n"); fflush(stdout);*/
  130: 
  131: #ifdef CGI_DBUG
  132:     fflush(g_cgi); fclose(g_cgi);
  133: #endif /* CGI_DBUG */
  134: 
  135:     /*
  136:     getclock(TIMEOFDAY, &b_ts);
  137:     sec_diff  = b_ts.tv_sec  - a_ts.tv_sec;
  138:     nsec_diff = b_ts.tv_nsec - a_ts.tv_nsec;
  139:     tdiff = (double)1000000000.0 * sec_diff + (double)nsec_diff;
  140:     sprintf(log_str,"%s %s %lg",getenv("REMOTE_HOST"),getenv("HTTP_USER_AGENT"),tdiff);
  141:     w_log_timing(g_student_number,g_login_set,g_student_data.s_sec,log_str);
  142:     */
  143:     return (0);
  144: }
  145: 
  146: 

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