Rev 8342 | Rev 15847 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 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 | |||
8185 | bpr | 18 | /* student score management, definitions */ |
10 | reyssat | 19 | |
20 | #include <utime.h> |
||
21 | #include <sys/socket.h> |
||
22 | #include <sys/un.h> |
||
8177 | bpr | 23 | #include "../Lib/libwims.h" |
10 | reyssat | 24 | |
8185 | bpr | 25 | /* how many seconds in a minute? */ |
10 | reyssat | 26 | #define MINLENGTH 47 |
8185 | bpr | 27 | /* maximal running minutes, in order to avoid leaking */ |
10 | reyssat | 28 | #define MAX_MIN 300 |
8185 | bpr | 29 | /* queue of socket requests */ |
10 | reyssat | 30 | #define SOCKET_QUEUE 32 |
8185 | bpr | 31 | /* socket buffer length */ |
10 | reyssat | 32 | #define BUFFERLEN (MAX_LINELEN+sizeof(scoreresult)*MAX_CLASSEXOS) |
8185 | bpr | 33 | /* number of log lines */ |
10 | reyssat | 34 | #define MAX_LOGLINES (102400) |
8185 | bpr | 35 | /* cuttime buffer, for all exams in a class */ |
10 | reyssat | 36 | #define CTBUFLEN 4096 |
8185 | bpr | 37 | /* text buffer length in a sheet cache */ |
10 | reyssat | 38 | #define SHEETBUFLEN 8192 |
8185 | bpr | 39 | /* number of cached classes */ |
40 | /* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */ |
||
10 | reyssat | 41 | #define MAX_CLASSCACHE 20 |
8185 | bpr | 42 | /* number of cached sheets */ |
43 | /* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */ |
||
10 | reyssat | 44 | #define MAX_SHEETCACHE 32 |
8185 | bpr | 45 | /* Refreshment rate for class caches, in seconds */ |
10 | reyssat | 46 | #define CLASSCACHE_DELAY 100 |
8185 | bpr | 47 | /* Refreshment rate for sheet caches, in seconds */ |
10 | reyssat | 48 | #define SHEETCACHE_DELAY 50 |
8185 | bpr | 49 | /* Maximal debug file length. Debug will be activated once the debug file exists. */ |
10 | reyssat | 50 | #define MAX_DEBUGLENGTH 1000000 |
8185 | bpr | 51 | /* delay before ins files are erased. In seconds */ |
10 | reyssat | 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 | |||
8185 | bpr | 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 | |||
8251 | bpr | 108 | /* from wimslogdscore.c */ |
8185 | bpr | 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]; |
||
15509 | bpr | 129 | extern int GEN_LOG_LIMIT, MODULE_LOG_LIMIT, OLD_LOG_FILES, LOG_DELETE; |
8251 | bpr | 130 | |
8185 | bpr | 131 | /* from fork.c */ |
132 | extern int forkcnt; |
||
133 | void addfork(pid_t pid, int type); |
||
134 | void forkman(int kz); |
||
135 | void wait_children(void); |
||
136 | void dispatch_log(void); |
||
8251 | bpr | 137 | |
8185 | bpr | 138 | /*from files.c */ |
8251 | bpr | 139 | void readfile(char *fname, char buf[], long int buflen); /* read the content of a file */ |
8185 | bpr | 140 | /* datafile structure: number of records. |
141 | * tag=1 if direct access |
||
142 | */ |
||
143 | unsigned int datafile_recordnum(char *p); |
||
8251 | bpr | 144 | char *datafile_fnd_record(char *p, int n, char bf[]); /* datafile structure: find record n, starting from 1 */ |
8185 | bpr | 145 | int ftest(char *fname); |
146 | enum{is_file, is_dir, is_exec, is_fifo, is_socket, is_unknown}; |
||
147 | |||
148 | /* from wimslogdlines.c */ |
||
8195 | bpr | 149 | void wimslogd_error(char *msg); |
8185 | bpr | 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; |
||
8342 | bpr | 155 | void wlogdaccessfile(char *content, char *type, char *s,...); |
8185 | bpr | 156 | int call_ssh(int wait,char *s,...); |
157 | int call_sh(int wait,char *s,...); |
||
158 | extern int exec_wait; |