Subversion Repositories wimsdev

Rev

Rev 8177 | Rev 8195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8177 Rev 8185
Line 13... Line 13...
13
 *  You should have received a copy of the GNU General Public License
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
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
16
 */
17
 
17
 
18
                /* student score management, definitions */
18
/* student score management, definitions */
19
 
19
 
20
#include <utime.h>
20
#include <utime.h>
21
#include <sys/socket.h>
21
#include <sys/socket.h>
22
#include <sys/un.h>
22
#include <sys/un.h>
23
#include "../Lib/libwims.h"
23
#include "../Lib/libwims.h"
24
#include "../wims.h"
-
 
25
 
24
 
26
        /* how many seconds in a minute? */
25
/* how many seconds in a minute? */
27
#define MINLENGTH 47
26
#define MINLENGTH 47
28
        /* maximal running minutes, in order to avoid leaking */
27
/* maximal running minutes, in order to avoid leaking */
29
#define MAX_MIN 300
28
#define MAX_MIN 300
30
        /* queue of socket requests */
29
/* queue of socket requests */
31
#define SOCKET_QUEUE 32
30
#define SOCKET_QUEUE 32
32
        /* socket buffer length */
31
/* socket buffer length */
33
#define BUFFERLEN (MAX_LINELEN+sizeof(scoreresult)*MAX_CLASSEXOS)
32
#define BUFFERLEN (MAX_LINELEN+sizeof(scoreresult)*MAX_CLASSEXOS)
34
        /* number of log lines */
33
/* number of log lines */
35
#define MAX_LOGLINES (102400)
34
#define MAX_LOGLINES (102400)
36
        /* cuttime buffer, for all exams in a class */
35
/* cuttime buffer, for all exams in a class */
37
#define CTBUFLEN 4096
36
#define CTBUFLEN 4096
38
        /* text buffer length in a sheet cache */
37
/* text buffer length in a sheet cache */
39
#define SHEETBUFLEN 8192
38
#define SHEETBUFLEN 8192
40
        /* number of cached classes */
39
/* number of cached classes */
41
        /* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */
40
/* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */
42
#define MAX_CLASSCACHE 20
41
#define MAX_CLASSCACHE 20
43
        /* number of cached sheets */
42
/* number of cached sheets */
44
        /* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */
43
/* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */
45
#define MAX_SHEETCACHE 32
44
#define MAX_SHEETCACHE 32
46
        /* Refreshment rate for class caches, in seconds */
45
/* Refreshment rate for class caches, in seconds */
47
#define CLASSCACHE_DELAY 100
46
#define CLASSCACHE_DELAY 100
48
        /* Refreshment rate for sheet caches, in seconds */
47
/* Refreshment rate for sheet caches, in seconds */
49
#define SHEETCACHE_DELAY 50
48
#define SHEETCACHE_DELAY 50
50
        /* Maximal debug file length. Debug will be activated once the debug file exists. */
49
/* Maximal debug file length. Debug will be activated once the debug file exists. */
51
#define MAX_DEBUGLENGTH 1000000
50
#define MAX_DEBUGLENGTH 1000000
52
        /* delay before ins files are erased. In seconds */
51
/* delay before ins files are erased. In seconds */
53
#define INS_DELAY 500
52
#define INS_DELAY 500
54
 
53
 
55
#define evalue strevalue
54
#define evalue strevalue
56
#define tmpd "tmp/log"
55
#define tmpd "tmp/log"
57
#define classd "log/classes"
56
#define classd "log/classes"
Line 60... Line 59...
60
#define logd "log"
59
#define logd "log"
61
#define pidfile "tmp/log/wimslogd.pid"
60
#define pidfile "tmp/log/wimslogd.pid"
62
#define sockfile "tmp/log/.wimslogd"
61
#define sockfile "tmp/log/.wimslogd"
63
#define debugfile "tmp/log/wimslogd.debug"
62
#define debugfile "tmp/log/wimslogd.debug"
64
 
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 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;