Subversion Repositories wimsdev

Rev

Rev 8185 | Rev 8251 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. /* student score management, definitions */
  19.  
  20. #include <utime.h>
  21. #include <sys/socket.h>
  22. #include <sys/un.h>
  23. #include "../Lib/libwims.h"
  24.  
  25. /* how many seconds in a minute? */
  26. #define MINLENGTH 47
  27. /* maximal running minutes, in order to avoid leaking */
  28. #define MAX_MIN 300
  29. /* queue of socket requests */
  30. #define SOCKET_QUEUE 32
  31. /* socket buffer length */
  32. #define BUFFERLEN (MAX_LINELEN+sizeof(scoreresult)*MAX_CLASSEXOS)
  33. /* number of log lines */
  34. #define MAX_LOGLINES (102400)
  35. /* cuttime buffer, for all exams in a class */
  36. #define CTBUFLEN 4096
  37. /* text buffer length in a sheet cache */
  38. #define SHEETBUFLEN 8192
  39. /* number of cached classes */
  40. /* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */
  41. #define MAX_CLASSCACHE 20
  42. /* number of cached sheets */
  43. /* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */
  44. #define MAX_SHEETCACHE 32
  45. /* Refreshment rate for class caches, in seconds */
  46. #define CLASSCACHE_DELAY 100
  47. /* Refreshment rate for sheet caches, in seconds */
  48. #define SHEETCACHE_DELAY 50
  49. /* Maximal debug file length. Debug will be activated once the debug file exists. */
  50. #define MAX_DEBUGLENGTH 1000000
  51. /* delay before ins files are erased. In seconds */
  52. #define INS_DELAY 500
  53.  
  54. #define evalue strevalue
  55. #define tmpd "tmp/log"
  56. #define classd "log/classes"
  57. #define sesd "sessions"
  58. #define modd "public_html/modules"
  59. #define logd "log"
  60. #define pidfile "tmp/log/wimslogd.pid"
  61. #define sockfile "tmp/log/.wimslogd"
  62. #define debugfile "tmp/log/wimslogd.debug"
  63.  
  64. /* from cache.c */
  65. typedef struct exodata {
  66.     unsigned short int num;
  67.     float weight, require;
  68. } exodata; /* General information of an exercise. Size: 10 bytes. */
  69.  
  70. extern struct classdata {
  71.     char name[MAX_CLASSLEN+1];
  72.     time_t start, last, modif;
  73.     int exocnt, examcnt, examstart, access;
  74.     struct exodata exos[MAX_CLASSEXOS];
  75.     char ctbuf[CTBUFLEN];
  76.     short int ctptr[MAX_EXOS];
  77. } classdata[MAX_CLASSCACHE];
  78. int search_data(void *list, int items, size_t item_size, unsigned short int t);
  79. struct classdata *getclasscache(char *cl);
  80. extern char opt_class[MAX_CLASSLEN+1];
  81. extern char **environ;
  82. extern int classcaches, sheetcaches;
  83. void cleancache(void);
  84.  
  85. /* from cleaning.c */
  86. void cleaning(int withmain); /* Clean obsolete session directories. */
  87.  
  88. /* from cmd.c */
  89. extern struct cmdlist {
  90.     char *name;
  91.     void (*routine) (char *p);
  92. } cmdlist[];
  93. extern int cmdcnt;
  94.  
  95. /* from homedir.c */
  96. void homedir(void);
  97.  
  98. /* from housekeep.c */
  99. void backup(void);
  100. void housekeep(void);
  101. void modupdate(void); /* module update */
  102.  
  103. /* from options.c */
  104. extern int options(void);
  105. extern char opt_user[MAX_FNAME+1];
  106. void cmd(void);
  107.  
  108. /* from score.c */
  109. void cmd_getscore(char *p);
  110. void cmd_scorelog(char *p);
  111.  
  112. /* from socket.c */
  113. void sockerror(int type, char *p,...);
  114. void opensock(void);
  115. void answer(int fh);
  116.  
  117. /* from wimslogd.c */
  118. extern char cwd[MAX_FNAME+1];
  119. extern int cwdtype;
  120. enum {dir_home, dir_class, dir_session, dir_module};
  121. extern char qbuf[MAX_LINELEN+1]; /* quota buffer */
  122. extern char ipbuf[64];
  123. extern char loadavg[MAX_LINELEN+1]; /* dans wims.h extern char loadavg[64];*/
  124. extern time_t nowtime, lastcleantime;
  125. extern int idle_time, idle_time2, idle_time3, anti_time;
  126. extern char keepdate[32];
  127. extern char nowstr[64];
  128. extern char mupdate[32], backdate[32];
  129. extern int GEN_LOG_LIMIT, MODULE_LOG_LIMIT, OLD_LOG_FILES;
  130. /* from fork.c */
  131. extern int forkcnt;
  132. void addfork(pid_t pid, int type);
  133. void forkman(int kz);
  134. void wait_children(void);
  135. void dispatch_log(void);
  136. /*from files.c */
  137. /* read the content of a file */
  138. void readfile(char *fname, char buf[], long int buflen);
  139. /* datafile structure: number of records.
  140.  * tag=1 if direct access
  141.  */
  142. unsigned int datafile_recordnum(char *p);
  143. /* datafile structure: find record n, starting from 1 */
  144. char *datafile_fnd_record(char *p, int n, char bf[]);
  145. int ftest(char *fname);
  146. enum{is_file, is_dir, is_exec, is_fifo, is_socket, is_unknown};
  147.  
  148. /* from wimslogdlines.c */
  149. void wimslogd_error(char *msg);
  150. extern int commsock, answerlen, debugging;
  151. extern char commbuf[BUFFERLEN+1];
  152. #define textbuf (commbuf+sizeof(int))
  153. void debug(char *p,...);
  154. extern char *textptr;
  155. void accessfile(char *content, char *type, char *s,...);
  156. int call_ssh(int wait,char *s,...);
  157. int call_sh(int wait,char *s,...);
  158. extern int exec_wait;
  159.