Subversion Repositories wimsdev

Rev

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

Rev 15349 Rev 15487
Line 26... Line 26...
26
int llcmp(const void *c1, const void *c2)
26
int llcmp(const void *c1, const void *c2)
27
{
27
{
28
  char **p1,**p2;
28
  char **p1,**p2;
29
  p1=(char **) c1; p2=(char **) c2;
29
  p1=(char **) c1; p2=(char **) c2;
30
  return strcmp(*p1,*p2);
30
  return strcmp(*p1,*p2);
-
 
31
}
-
 
32
int stringtodays(char * dat)
-
 
33
{
-
 
34
  static int len[13] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
-
 
35
  int y = 1000*(dat[0]-'0')+100*(dat[1]-'0')+10*(dat[2]-'0')+(dat[3]-'0');
-
 
36
  int m = 10*(dat[4]-'0')+(dat[5]-'0');
-
 
37
  int d = 10*(dat[6]-'0')+(dat[7]-'0');
-
 
38
  if (m < 3) {y--; d += 365;}
-
 
39
  return d + len[m] + 365*y + y/4 - y/100 + y/400;
-
 
40
}
-
 
41
void purgefile(char *fname)
-
 
42
{
-
 
43
  char buf[8];
-
 
44
  FILE *f = fopen(fname,"r");
-
 
45
  fread (buf,1,8,f);
-
 
46
  fclose(f);
-
 
47
  int d1 = stringtodays(buf);
-
 
48
  int d2 = stringtodays(nowstr);
-
 
49
  if (d2-d1 > 100) /* to replace by FILEROT */
-
 
50
    unlink(fname);
31
}
51
}
32
 
52
 
33
void onelogfile(char *fname)
53
void onelogfile(char *fname)
34
{
54
{
35
  char namebuf[1024], *pp;
55
  char namebuf[1024], b3[1024], b4[1024], *pp;
36
  FILE *f;
56
  FILE *f;
37
  size_t l, l2;
57
  size_t l, l2;
38
  struct stat st;
58
  struct stat st;
39
  int lim;
59
  int i, lim;
40
 
60
 
41
  if(fname[0] == 0) {
61
  if(fname[0] == 0) {
42
    abort:
62
    abort:
43
    llptr=llbuf; return;
63
    llptr=llbuf; return;
44
  }
64
  }
Line 58... Line 78...
58
      strcmp(fname,"user_error.log")==0 ||
78
      strcmp(fname,"user_error.log")==0 ||
59
      strncmp(fname,"classes/",8)==0)
79
      strncmp(fname,"classes/",8)==0)
60
    lim=GEN_LOG_LIMIT;
80
    lim=GEN_LOG_LIMIT;
61
  else lim=MODULE_LOG_LIMIT;
81
  else lim=MODULE_LOG_LIMIT;
62
  if(l>=lim) {
82
  if(l>=lim) {
63
    char b3[1024], b4[1024];
-
 
64
    int i;
-
 
65
    for(i=OLD_LOG_FILES-1;i>0;i--) {
83
    for(i=OLD_LOG_FILES-1;i>0;i--) {
66
      snprintf(b3,sizeof(b3),"%s.old%d",namebuf,i);
84
      snprintf(b3,sizeof(b3),"%s.old%d",namebuf,i);
67
      snprintf(b4,sizeof(b4),"%s.old%d",namebuf,i+1);
85
      snprintf(b4,sizeof(b4),"%s.old%d",namebuf,i+1);
68
      if(stat(b3,&st)==0) rename(b3,b4);
86
      if(stat(b3,&st)==0) rename(b3,b4);
69
    }
87
    }