version 1.51, 2002/09/17 20:03:40 |
version 1.52, 2002/09/17 20:16:43 |
|
|
int signal; |
int signal; |
}; |
}; |
|
|
int verbose = 0; /* Print out what's going on */ |
int verbose = 0; /* Print out what's going on */ |
int needroot = 1; /* Root privs are necessary */ |
int needroot = 1; /* Root privs are necessary */ |
int noaction = 0; /* Don't do anything, just show it */ |
int noaction = 0; /* Don't do anything, just show it */ |
int monitormode = 0; /* Don't do monitoring by default */ |
int monitormode = 0; /* Don't do monitoring by default */ |
char *conf = CONF; /* Configuration file to use */ |
int force = 0; /* Force the logs to be rotated */ |
time_t timenow; |
char *conf = CONF; /* Configuration file to use */ |
char hostname[MAXHOSTNAMELEN]; /* hostname */ |
time_t timenow; |
char *daytime; /* timenow in human readable form */ |
char hostname[MAXHOSTNAMELEN]; /* hostname */ |
char *arcdir; /* dir to put archives in (if it exists) */ |
char *daytime; /* timenow in human readable form */ |
|
char *arcdir; /* dir to put archives in (if it exists) */ |
|
|
void do_entry(struct conf_entry *); |
void do_entry(struct conf_entry *); |
void parse_args(int, char **); |
void parse_args(int, char **); |
|
|
DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours)); |
DPRINTF(("age (hr): %d [%d] ", modtime, ent->hours)); |
if (monitormode && ent->flags & CE_MONITOR) |
if (monitormode && ent->flags & CE_MONITOR) |
domonitor(ent->log, ent->whom); |
domonitor(ent->log, ent->whom); |
if (!monitormode && ((ent->size > 0 && size >= ent->size) || |
if (!monitormode && (force || |
|
(ent->size > 0 && size >= ent->size) || |
(ent->hours > 0 && (modtime >= ent->hours || modtime < 0) |
(ent->hours > 0 && (modtime >= ent->hours || modtime < 0) |
&& ((ent->flags & CE_BINARY) || size >= MIN_SIZE)))) { |
&& ((ent->flags & CE_BINARY) || size >= MIN_SIZE)))) { |
DPRINTF(("--> trimming log....\n")); |
DPRINTF(("--> trimming log....\n")); |
|
|
if ((p = strchr(hostname, '.')) != NULL) |
if ((p = strchr(hostname, '.')) != NULL) |
*p = '\0'; |
*p = '\0'; |
|
|
while ((ch = getopt(argc, argv, "nrvma:f:")) != -1) { |
while ((ch = getopt(argc, argv, "Fmnrva:f:")) != -1) { |
switch (ch) { |
switch (ch) { |
case 'a': |
case 'a': |
arcdir = optarg; |
arcdir = optarg; |
|
|
case 'm': |
case 'm': |
monitormode++; |
monitormode++; |
break; |
break; |
|
case 'F': |
|
force++; |
|
break; |
default: |
default: |
usage(); |
usage(); |
} |
} |
} |
} |
|
if (monitormode && force) |
|
errx(1, "cannot specify both -m and -F flags"); |
} |
} |
|
|
void |
void |
|
|
{ |
{ |
extern const char *__progname; |
extern const char *__progname; |
|
|
(void)fprintf(stderr, "usage: %s [-mnrv] [-a directory] " |
(void)fprintf(stderr, "usage: %s [-Fmnrv] [-a directory] " |
"[-f config_file]\n", __progname); |
"[-f config_file]\n", __progname); |
exit(1); |
exit(1); |
} |
} |
|
|
/* Parse a configuration file and return a linked list of all the logs |
/* |
|
* Parse a configuration file and return a linked list of all the logs |
* to process |
* to process |
*/ |
*/ |
struct conf_entry * |
struct conf_entry * |