version 1.86, 2009/10/27 23:59:40 |
version 1.87, 2010/03/20 15:15:45 |
|
|
rotate(struct conf_entry *ent, const char *oldlog) |
rotate(struct conf_entry *ent, const char *oldlog) |
{ |
{ |
char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix; |
char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix; |
int numdays = ent->numlogs; |
int numdays = ent->numlogs - 1; |
|
int done = 0; |
|
|
/* Remove oldest log (may not exist) */ |
/* Remove old logs */ |
(void)snprintf(file1, sizeof(file1), "%s.%d", oldlog, numdays); |
do { |
(void)snprintf(file2, sizeof(file2), "%s.%d%s", oldlog, numdays, |
(void)snprintf(file1, sizeof(file1), "%s.%d", oldlog, numdays); |
COMPRESS_POSTFIX); |
(void)snprintf(file2, sizeof(file2), "%s.%d%s", oldlog, |
|
numdays, COMPRESS_POSTFIX); |
|
if (noaction) { |
|
printf("\trm -f %s %s\n", file1, file2); |
|
done = access(file1, 0) && access(file2, 0); |
|
} else { |
|
done = unlink(file1) && unlink(file2); |
|
} |
|
numdays++; |
|
} while (done == 0); |
|
|
if (noaction) { |
|
printf("\trm -f %s %s\n", file1, file2); |
|
} else { |
|
(void)unlink(file1); |
|
(void)unlink(file2); |
|
} |
|
|
|
/* Move down log files */ |
/* Move down log files */ |
while (numdays--) { |
for (numdays = ent->numlogs - 2; numdays >= 0; numdays--) { |
/* |
/* |
* If both the compressed archive and the non-compressed archive |
* If both the compressed archive and the non-compressed archive |
* exist, we decide which to rotate based on the CE_COMPACT flag |
* exist, we decide which to rotate based on the CE_COMPACT flag |