Subversion Repositories wimsdev

Compare Revisions

Ignore whitespace Rev 8184 → Rev 8185

/trunk/wims/src/Wimslogd/wimslogd.c
56,18 → 56,7
char *textptr;
 
int cwdtype;
enum {dir_home, dir_class, dir_session, dir_module};
 
#include "fork.c"
#include "wimslogdlines.c"
#include "cache.c"
#include "files.c"
#include "socket.c"
#include "log.c"
#include "cleaning.c"
#include "housekeep.c"
#include "homedir.c"
 
/* check whether there is anything to execute */
void logexec(void)
{
/trunk/wims/src/Wimslogd/homedir.c
16,6 → 16,8
*/
/* Routines to update home directory. */
 
#include "wimslogd.h"
 
/* The following directories will be relocatable.
* Clusterable directories (log, backup) should be avoided.
*/
/trunk/wims/src/Wimslogd/housekeep.c
16,6 → 16,9
*/
 
/* Daily housekeeping jobs. */
 
#include "wimslogd.h"
 
void housekeep(void)
{
char fname[1024];
/trunk/wims/src/Wimslogd/socket.c
16,6 → 16,7
*/
 
/* WIMS log daemon, socket routines */
#include "wimslogd.h"
 
void errorquit(char *p)
{
65,10 → 66,6
snprintf(textbuf,BUFFERLEN-16,"OK\n%s",p);
}
 
#include "options.c"
#include "score.c"
#include "cmd.c"
 
void answer(int fh)
{
int t,l, *ip;
/trunk/wims/src/Wimslogd/wimslogd.h
15,41 → 15,40
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
 
/* student score management, definitions */
/* student score management, definitions */
 
#include <utime.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "../Lib/libwims.h"
#include "../wims.h"
 
/* how many seconds in a minute? */
/* how many seconds in a minute? */
#define MINLENGTH 47
/* maximal running minutes, in order to avoid leaking */
/* maximal running minutes, in order to avoid leaking */
#define MAX_MIN 300
/* queue of socket requests */
/* queue of socket requests */
#define SOCKET_QUEUE 32
/* socket buffer length */
/* socket buffer length */
#define BUFFERLEN (MAX_LINELEN+sizeof(scoreresult)*MAX_CLASSEXOS)
/* number of log lines */
/* number of log lines */
#define MAX_LOGLINES (102400)
/* cuttime buffer, for all exams in a class */
/* cuttime buffer, for all exams in a class */
#define CTBUFLEN 4096
/* text buffer length in a sheet cache */
/* text buffer length in a sheet cache */
#define SHEETBUFLEN 8192
/* number of cached classes */
/* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */
/* number of cached classes */
/* Storage requirement: about MAX_CLASSCACHE*(MAX_CLASSEXOS*10+CTBUFLEN) bytes. */
#define MAX_CLASSCACHE 20
/* number of cached sheets */
/* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */
/* number of cached sheets */
/* Storage requirement: about MAX_SHEETCACHE*SHEETBUFLEN bytes. */
#define MAX_SHEETCACHE 32
/* Refreshment rate for class caches, in seconds */
/* Refreshment rate for class caches, in seconds */
#define CLASSCACHE_DELAY 100
/* Refreshment rate for sheet caches, in seconds */
/* Refreshment rate for sheet caches, in seconds */
#define SHEETCACHE_DELAY 50
/* Maximal debug file length. Debug will be activated once the debug file exists. */
/* Maximal debug file length. Debug will be activated once the debug file exists. */
#define MAX_DEBUGLENGTH 1000000
/* delay before ins files are erased. In seconds */
/* delay before ins files are erased. In seconds */
#define INS_DELAY 500
 
#define evalue strevalue
62,3 → 61,98
#define sockfile "tmp/log/.wimslogd"
#define debugfile "tmp/log/wimslogd.debug"
 
/* from cache.c */
typedef struct exodata {
unsigned short int num;
float weight, require;
} exodata; /* General information of an exercise. Size: 10 bytes. */
 
extern struct classdata {
char name[MAX_CLASSLEN+1];
time_t start, last, modif;
int exocnt, examcnt, examstart, access;
struct exodata exos[MAX_CLASSEXOS];
char ctbuf[CTBUFLEN];
short int ctptr[MAX_EXOS];
} classdata[MAX_CLASSCACHE];
int search_data(void *list, int items, size_t item_size, unsigned short int t);
struct classdata *getclasscache(char *cl);
extern char opt_class[MAX_CLASSLEN+1];
extern char **environ;
extern int classcaches, sheetcaches;
void cleancache(void);
 
/* from cleaning.c */
void cleaning(int withmain); /* Clean obsolete session directories. */
 
/* from cmd.c */
extern struct cmdlist {
char *name;
void (*routine) (char *p);
} cmdlist[];
extern int cmdcnt;
 
/* from homedir.c */
void homedir(void);
 
/* from housekeep.c */
void backup(void);
void housekeep(void);
void modupdate(void); /* module update */
 
/* from options.c */
extern int options(void);
extern char opt_user[MAX_FNAME+1];
void cmd(void);
 
/* from score.c */
void cmd_getscore(char *p);
void cmd_scorelog(char *p);
 
/* from socket.c */
void sockerror(int type, char *p,...);
void opensock(void);
void answer(int fh);
 
/* from wimslogd.c */
extern char cwd[MAX_FNAME+1];
extern int cwdtype;
enum {dir_home, dir_class, dir_session, dir_module};
extern char qbuf[MAX_LINELEN+1]; /* quota buffer */
extern char ipbuf[64];
extern char loadavg[MAX_LINELEN+1]; /* dans wims.h extern char loadavg[64];*/
extern time_t nowtime, lastcleantime;
extern int idle_time, idle_time2, idle_time3, anti_time;
extern char keepdate[32];
extern char nowstr[64];
extern char mupdate[32], backdate[32];
extern int GEN_LOG_LIMIT, MODULE_LOG_LIMIT, OLD_LOG_FILES;
/* from fork.c */
extern int forkcnt;
void addfork(pid_t pid, int type);
void forkman(int kz);
void wait_children(void);
void dispatch_log(void);
/*from files.c */
/* read the content of a file */
void readfile(char *fname, char buf[], long int buflen);
/* datafile structure: number of records.
* tag=1 if direct access
*/
unsigned int datafile_recordnum(char *p);
/* datafile structure: find record n, starting from 1 */
char *datafile_fnd_record(char *p, int n, char bf[]);
int ftest(char *fname);
enum{is_file, is_dir, is_exec, is_fifo, is_socket, is_unknown};
 
/* from wimslogdlines.c */
void error(char *msg);
extern int commsock, answerlen, debugging;
extern char commbuf[BUFFERLEN+1];
#define textbuf (commbuf+sizeof(int))
void debug(char *p,...);
extern char *textptr;
void accessfile(char *content, char *type, char *s,...);
int call_ssh(int wait,char *s,...);
int call_sh(int wait,char *s,...);
extern int exec_wait;
/trunk/wims/src/Wimslogd/options.c
16,6 → 16,7
*/
 
/* daemon option processing */
#include "wimslogd.h"
 
char opt_class[MAX_CLASSLEN+1];
char opt_module[MAX_FNAME+1];
/trunk/wims/src/Wimslogd/score.c
15,8 → 15,10
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
 
/* student score management */
/* student score management */
 
#include "wimslogd.h"
 
double oldfactor=0.85; /* quality factor, should remain stable. */
 
/* User score information of an exercise. Size: 16 bytes. */
/trunk/wims/src/Wimslogd/cleaning.c
19,6 → 19,7
* it erases obsolete session directories.
* Regular checkup every 10 minutes or so.
*/
#include "wimslogd.h"
 
/* internal */
void _cleaning(char *di,int hardcheck)
/trunk/wims/src/Wimslogd/wimslogdlines.c
17,11 → 17,10
/* line input / output / translation routines
* and error routines
*/
#include "wimslogd.h"
 
int exec_wait;
 
void accessfile(char *content, char *type, char *s,...);
 
int execredirected(char *cmdf, char *inf, char *outf, char *errf, char *arg[])
{
pid_t pid;
/trunk/wims/src/Wimslogd/Makefile.in
10,8 → 10,13
STRIP=@STRIP@
lopt=-L../../lib -lwims -lm
 
wimslogdobjects=cache.o cleaning.o cmd.o files.o fork.o homedir.o housekeep.o log.o options.o socket.o wimslogdlines.o score.o wimslogd.o
 
all: wimslogd
 
%.o: %.c wimslogd.h ../wimsdef.h ../Lib/libwims.h
$(cc) -o $@ $(cflags) $(defines) -c $<
 
clean:
rm -f *.o wimslogd
 
20,8 → 25,8
rm -f $(wims_home)/bin/wimslogd
rm -f Makefile
 
wimslogd: *.c *.h ../wimsdef.h ../Lib/libwims.h
$(cc) $(cflags) $(CPPFLAGS) $(LDFLAGS) $(defines) wimslogd.c $(lopt) -o wimslogd
wimslogd: $(wimslogdobjects)
$(cc) $(LDFLAGS) $(defines) $(wimslogdobjects) $(lopt) -o wimslogd
$(STRIP) wimslogd
rm -f $(wims_home)/tmp/log/wimslogd.pid $(wims_home)/sessions/.wimslogd
cp wimslogd $(wims_home)/tmp/log/wimslogd.new
/trunk/wims/src/Wimslogd/fork.c
16,6 → 16,7
*/
 
/* fork management */
#include "wimslogd.h"
 
#define MAX_FORK 1024
#define MAX_DELAY 1500 /* At most these seconds of execution */
/trunk/wims/src/Wimslogd/log.c
16,6 → 16,8
*/
/* Routines to write log files. */
 
#include "wimslogd.h"
 
char llbuf[4*MAX_LINELEN+4], *llptr;
char *linetab[MAX_LOGLINES];
int loglinecnt;
/trunk/wims/src/Wimslogd/files.c
14,10 → 14,10
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "wimslogd.h"
 
/* File manipulation */
 
enum{is_file, is_dir, is_exec, is_fifo, is_socket, is_unknown};
struct stat ftst;
 
/* A simple front-end of stat(). */
91,4 → 91,3
mystrncpy(bf,pp,MAX_LINELEN);
end: return bf;
}
 
/trunk/wims/src/Wimslogd/cache.c
17,20 → 17,9
 
/* Caches and its management */
 
/* General information of an exercise. Size: 10 bytes. */
typedef struct exodata {
unsigned short int num;
float weight, require;
} exodata;
#include "wimslogd.h"
 
struct classdata {
char name[MAX_CLASSLEN+1];
time_t start, last, modif;
int exocnt, examcnt, examstart, access;
struct exodata exos[MAX_CLASSEXOS];
char ctbuf[CTBUFLEN];
short int ctptr[MAX_EXOS];
} classdata[MAX_CLASSCACHE];
struct classdata classdata[MAX_CLASSCACHE];
 
struct classcache {
struct classdata *ptr;
/trunk/wims/src/Wimslogd/cmd.c
14,6 → 14,7
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "wimslogd.h"
 
/* daemon command processing */
 
64,10 → 65,7
snprintf(textbuf+3,16,"%d",datafile_recordnum(p1));
}
 
struct {
char *name;
void (*routine) (char *p);
} cmdlist[]={
struct cmdlist cmdlist[]={
{"forkcnt", cmd_forklist},
{"forkcount", cmd_forklist},
{"forklist", cmd_forklist},
82,7 → 80,7
{"scorelog", cmd_scorelog},
{"test", cmd_test},
};
#define cmdcnt (sizeof(cmdlist)/sizeof(cmdlist[0]))
int cmdcnt=(sizeof(cmdlist)/sizeof(cmdlist[0]));
 
void cmd(void)
{