Subversion Repositories wimsdev

Rev

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

Rev 8100 Rev 8149
Line 19... Line 19...
19
 
19
 
20
#include "../wimsdef.h"
20
#include "../wimsdef.h"
21
#include "../includes.h"
21
#include "../includes.h"
22
#include "../Lib/libwims.h"
22
#include "../Lib/libwims.h"
23
 
23
 
24
    /* The maximal number of sessions within one day */
24
/* The maximal number of sessions within one day */
25
#define MAX_SESSIONS (128*1024)
25
#define MAX_SESSIONS (128*1024)
26
    /* The maximal number of classes within one day */
26
/* The maximal number of classes within one day */
27
#define MAX_CLASSES 8192
27
#define MAX_CLASSES 8192
28
    /* At least these minutes will be counted for each session */
28
/* At least these minutes will be counted for each session */
29
#define MIN_CONNECT 2
29
#define MIN_CONNECT 2
30
    /* Add this number of minutes to each session */
30
/* Add this number of minutes to each session */
31
#define MIN_ADD 1
31
#define MIN_ADD 1
32
    /* Accounting discontinues after this number of idle minutes */
32
/* Accounting discontinues after this number of idle minutes */
33
#define MAX_LAPSE 15
33
#define MAX_LAPSE 15
34
 
34
 
35
struct {
35
struct {
36
    char s[4], u[32];
36
    char s[4], u[32];
37
    int cl, start, end, cnt;
37
    int cl, start, end, cnt;
Line 43... Line 43...
43
struct cls {
43
struct cls {
44
    int cl, cnt;
44
    int cl, cnt;
45
} cls[MAX_CLASSES];
45
} cls[MAX_CLASSES];
46
int clscnt;
46
int clscnt;
47
 
47
 
48
/*
-
 
49
void *xmalloc(size_t n)
-
 
50
{
-
 
51
    void *p;
-
 
52
    p=malloc(n);
-
 
53
    if(p==NULL) {
-
 
54
    fprintf(stderr,"Malloc failure."); exit(1);
-
 
55
    }
-
 
56
    return p;
-
 
57
}
-
 
58
*/
-
 
59
    /* Points to the end of the word */
-
 
60
/*
-
 
61
char *find_word_end(char *p)
-
 
62
{
-
 
63
    int i;
-
 
64
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
-
 
65
    return p;
-
 
66
}
-
 
67
*/
-
 
68
    /* Strips leading spaces */
-
 
69
/*
-
 
70
char *find_word_start(char *p)
-
 
71
{
-
 
72
    int i;
-
 
73
    for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++);
-
 
74
    return p;
-
 
75
}
-
 
76
*/
-
 
77
    /* Read/write to a file with variable parms to print filename */
48
/* Read/write to a file with variable parms to print filename */
78
void accessfile(char *content, char *type, char *s,...)
49
void accessfile(char *content, char *type, char *s,...)
79
{
50
{
80
    va_list vp;
51
    va_list vp;
81
    char buf[MAX_LINELEN+1];
52
    char buf[MAX_LINELEN+1];
82
    FILE *f;
53
    FILE *f;
Line 96... Line 67...
96
    case 'r': {
67
    case 'r': {
97
        l=fread(content,1,MAX_LINELEN-1,f);
68
        l=fread(content,1,MAX_LINELEN-1,f);
98
        if(l>0 && l<MAX_LINELEN) content[l]=0;
69
        if(l>0 && l<MAX_LINELEN) content[l]=0;
99
        else content[0]=0;
70
        else content[0]=0;
100
        break;
71
        break;
101
    }
72
    }
102
    default: {
73
    default: {
103
        content[0]=0; break;
74
        content[0]=0; break;
104
    }
75
    }
105
    }
76
    }
106
    fclose(f);
77
    fclose(f);
107
}
78
}
108
 
-
 
109
/* returns -1 if error */
-
 
110
/*
-
 
111
long int filelength(char *fn,...)
-
 
112
{
-
 
113
    char buf[4096];
-
 
114
    va_list vp;
-
 
115
    struct stat st;
-
 
116
    int l;
-
 
117
 
79
 
118
    va_start(vp,fn);
-
 
119
    vsnprintf(buf,sizeof(buf),fn,vp); va_end(vp);
-
 
120
    l=stat(buf,&st); if(l) return -1;
-
 
121
    return st.st_size;
-
 
122
}
-
 
123
*/
-
 
124
    /* recursively generate a directory structure */
80
/* recursively generate a directory structure */
125
void mkdirs2(char *s)
81
void mkdirs2(char *s)
126
{
82
{
127
    struct stat st;
83
    struct stat st;
128
    char *buf;
84
    char *buf;
129
    if(stat(s,&st)==-1) {
85
    if(stat(s,&st)==-1) {