Subversion Repositories wimsdev

Rev

Rev 16133 | 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 {
15847 bpr 66
    int active;
8185 bpr 67
    float weight, require;
68
} exodata; /* General information of an exercise. Size: 10 bytes. */
69
 
15847 bpr 70
typedef struct sheetdata {
71
    unsigned short int start, indstart, exocnt, techcnt, techval, techoffset;
72
} sheetdata; /* General information of a sheet. Size: xx bytes. */
73
 
8185 bpr 74
extern struct classdata {
75
    char name[MAX_CLASSLEN+1];
18421 czzmrn 76
    char sclass[MAX_CLASSLEN+1];
15847 bpr 77
    char techs[MAX_LINELEN];
8185 bpr 78
    time_t start, last, modif;
15847 bpr 79
    int sheetcnt, exocnt, examcnt, examstart, access;
8185 bpr 80
    struct exodata exos[MAX_CLASSEXOS];
81
    char ctbuf[CTBUFLEN];
82
    short int ctptr[MAX_EXOS];
16133 bpr 83
    struct sheetdata exam, sheets[MAX_SHEETS+1];
8185 bpr 84
} classdata[MAX_CLASSCACHE];
85
int search_data(void *list, int items, size_t item_size, unsigned short int t);
86
struct classdata *getclasscache(char *cl);
87
extern char opt_class[MAX_CLASSLEN+1];
88
extern char **environ;
89
extern int classcaches, sheetcaches;
90
void cleancache(void);
91
 
92
/* from cleaning.c */
93
void cleaning(int withmain); /* Clean obsolete session directories. */
94
 
95
/* from cmd.c */
96
extern struct cmdlist {
97
    char *name;
98
    void (*routine) (char *p);
99
} cmdlist[];
100
extern int cmdcnt;
101
 
102
/* from homedir.c */
103
void homedir(void);
104
 
105
/* from housekeep.c */
106
void backup(void);
107
void housekeep(void);
108
void modupdate(void); /* module update */
109
 
110
/* from options.c */
111
extern int options(void);
112
extern char opt_user[MAX_FNAME+1];
113
void cmd(void);
114
 
8251 bpr 115
/* from wimslogdscore.c */
8185 bpr 116
void cmd_getscore(char *p);
117
void cmd_scorelog(char *p);
118
 
119
/* from socket.c */
120
void sockerror(int type, char *p,...);
121
void opensock(void);
122
void answer(int fh);
123
 
124
/* from wimslogd.c */
125
extern char cwd[MAX_FNAME+1];
126
extern int cwdtype;
127
enum {dir_home, dir_class, dir_session, dir_module};
128
extern char qbuf[MAX_LINELEN+1]; /* quota buffer */
129
extern char ipbuf[64];
130
extern char loadavg[MAX_LINELEN+1]; /* dans wims.h extern char loadavg[64];*/
131
extern time_t nowtime, lastcleantime;
132
extern int idle_time, idle_time2, idle_time3, anti_time;
133
extern char keepdate[32];
134
extern char nowstr[64];
135
extern char mupdate[32], backdate[32];
15509 bpr 136
extern int GEN_LOG_LIMIT, MODULE_LOG_LIMIT, OLD_LOG_FILES, LOG_DELETE;
8251 bpr 137
 
8185 bpr 138
/* from fork.c */
139
extern int forkcnt;
140
void addfork(pid_t pid, int type);
141
void forkman(int kz);
142
void wait_children(void);
143
void dispatch_log(void);
8251 bpr 144
 
8185 bpr 145
/*from files.c */
8251 bpr 146
void readfile(char *fname, char buf[], long int buflen); /* read the content of a file */
8185 bpr 147
/* datafile structure: number of records.
148
 * tag=1 if direct access
149
 */
150
unsigned int datafile_recordnum(char *p);
8251 bpr 151
char *datafile_fnd_record(char *p, int n, char bf[]); /* datafile structure: find record n, starting from 1 */
8185 bpr 152
int ftest(char *fname);
153
enum{is_file, is_dir, is_exec, is_fifo, is_socket, is_unknown};
154
 
155
/* from wimslogdlines.c */
8195 bpr 156
void wimslogd_error(char *msg);
8185 bpr 157
extern int commsock, answerlen, debugging;
158
extern char commbuf[BUFFERLEN+1];
159
#define textbuf (commbuf+sizeof(int))
160
void debug(char *p,...);
15847 bpr 161
void my_debug(char *p,...);
8185 bpr 162
extern char *textptr;
8342 bpr 163
void wlogdaccessfile(char *content, char *type, char *s,...);
8185 bpr 164
int call_ssh(int wait,char *s,...);
165
int call_sh(int wait,char *s,...);
166
extern int exec_wait;
18421 czzmrn 167
void getdef(char *fname, char *name, char value[]);