[BACK]Return to newsyslog.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / newsyslog

Diff for /src/usr.bin/newsyslog/newsyslog.c between version 1.79 and 1.80

version 1.79, 2004/04/09 19:21:15 version 1.80, 2004/05/10 05:32:16
Line 192 
Line 192 
 {  {
         struct conf_entry *p, *q, *x, *y;          struct conf_entry *p, *q, *x, *y;
         struct pidinfo *pidlist, *pl;          struct pidinfo *pidlist, *pl;
         char **av;  
         int status, listlen;          int status, listlen;
           char **av;
   
         parse_args(argc, argv);          parse_args(argc, argv);
         argc -= optind;          argc -= optind;
Line 295 
Line 295 
 void  void
 do_entry(struct conf_entry *ent)  do_entry(struct conf_entry *ent)
 {  {
           struct stat sb;
         int modtime;          int modtime;
         off_t size;          off_t size;
         struct stat sb;  
   
         if (lstat(ent->log, &sb) != 0)          if (lstat(ent->log, &sb) != 0)
                 return;                  return;
Line 371 
Line 371 
 void  void
 send_signal(char *pidfile, int signal)  send_signal(char *pidfile, int signal)
 {  {
         pid_t pid;  
         FILE *f;  
         char line[BUFSIZ], *ep, *err;          char line[BUFSIZ], *ep, *err;
           pid_t pid;
         long lval;          long lval;
           FILE *f;
   
         if ((f = fopen(pidfile, "r")) == NULL) {          if ((f = fopen(pidfile, "r")) == NULL) {
                 warn("can't open %s", pidfile);                  warn("can't open %s", pidfile);
Line 416 
Line 416 
 void  void
 parse_args(int argc, char **argv)  parse_args(int argc, char **argv)
 {  {
         int ch;  
         char *p;          char *p;
           int ch;
   
         timenow = time(NULL);          timenow = time(NULL);
         daytime = ctime(&timenow) + 4;          daytime = ctime(&timenow) + 4;
Line 478 
Line 478 
 struct conf_entry *  struct conf_entry *
 parse_file(int *nentries)  parse_file(int *nentries)
 {  {
         FILE *f;  
         char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;          char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;
         int lineno;          struct conf_entry *working = NULL, *first = NULL;
         long l;  
         struct conf_entry *first = NULL;  
         struct conf_entry *working = NULL;  
         struct passwd *pwd;          struct passwd *pwd;
         struct group *grp;          struct group *grp;
         struct stat sb;          struct stat sb;
           int lineno;
           FILE *f;
           long l;
   
         if (strcmp(conf, "-") == 0)          if (strcmp(conf, "-") == 0)
                 f = stdin;                  f = stdin;
Line 503 
Line 502 
                         err(1, "strdup");                          err(1, "strdup");
                 (*nentries)++;                  (*nentries)++;
                 if (!first) {                  if (!first) {
                         working = (struct conf_entry *) malloc(sizeof(struct conf_entry));                          working = malloc(sizeof(struct conf_entry));
                         if (working == NULL)                          if (working == NULL)
                                 err(1, "malloc");                                  err(1, "malloc");
                         first = working;                          first = working;
                 } else {                  } else {
                         working->next = (struct conf_entry *) malloc(sizeof(struct conf_entry));                          working->next = malloc(sizeof(struct conf_entry));
                         if (working->next == NULL)                          if (working->next == NULL)
                                 err(1, "malloc");                                  err(1, "malloc");
                         working = working->next;                          working = working->next;
Line 543 
Line 542 
                         if (*q) {                          if (*q) {
                                 if (!(isnumberstr(q))) {                                  if (!(isnumberstr(q))) {
                                         if ((grp = getgrnam(q)) == NULL)                                          if ((grp = getgrnam(q)) == NULL)
   
                                                 errx(1, "%s:%d: unknown group: %s",                                                  errx(1, "%s:%d: unknown group: %s",
                                                     conf, lineno, q);                                                      conf, lineno, q);
                                         working->gid = grp->gr_gid;                                          working->gid = grp->gr_gid;
Line 755 
Line 753 
 {  {
         char    file1[MAXPATHLEN], file2[MAXPATHLEN];          char    file1[MAXPATHLEN], file2[MAXPATHLEN];
         char    oldlog[MAXPATHLEN], *suffix;          char    oldlog[MAXPATHLEN], *suffix;
         int     fd;          int     numdays = ent->numlogs, fd;
         int     numdays = ent->numlogs;  
   
         /* Is there a separate backup dir? */          /* Is there a separate backup dir? */
         if (ent->backdir != NULL)          if (ent->backdir != NULL)
Line 864 
Line 861 
 void  void
 compress_log(struct conf_entry *ent)  compress_log(struct conf_entry *ent)
 {  {
         pid_t pid;  
         char *base, tmp[MAXPATHLEN];          char *base, tmp[MAXPATHLEN];
           pid_t pid;
   
         if (ent->backdir != NULL)          if (ent->backdir != NULL)
                 snprintf(tmp, sizeof(tmp), "%s/%s.0", ent->backdir,                  snprintf(tmp, sizeof(tmp), "%s/%s.0", ent->backdir,
Line 906 
Line 903 
 int  int
 age_old_log(struct conf_entry *ent)  age_old_log(struct conf_entry *ent)
 {  {
         struct stat sb;  
         char file[MAXPATHLEN];          char file[MAXPATHLEN];
           struct stat sb;
   
         if (ent->backdir != NULL)          if (ent->backdir != NULL)
                 (void)snprintf(file, sizeof(file), "%s/%s.0", ent->backdir,                  (void)snprintf(file, sizeof(file), "%s/%s.0", ent->backdir,
Line 958 
Line 955 
 int  int
 domonitor(struct conf_entry *ent)  domonitor(struct conf_entry *ent)
 {  {
         struct stat sb, tsb;  
         char fname[MAXPATHLEN], *flog, *p, *rb = NULL;          char fname[MAXPATHLEN], *flog, *p, *rb = NULL;
         FILE *fp;          struct stat sb, tsb;
         off_t osize;          off_t osize;
           FILE *fp;
         int rd;          int rd;
   
         if (stat(ent->log, &sb) < 0)          if (stat(ent->log, &sb) < 0)
Line 1067 
Line 1064 
 FILE *  FILE *
 openmail(void)  openmail(void)
 {  {
         FILE *ret;  
         char *cmdbuf = NULL;          char *cmdbuf = NULL;
           FILE *ret;
   
         if (asprintf(&cmdbuf, "%s -t", SENDMAIL) != -1) {          if (asprintf(&cmdbuf, "%s -t", SENDMAIL) != -1) {
                 ret = popen(cmdbuf, "w");                  ret = popen(cmdbuf, "w");
Line 1137 
Line 1134 
 time_t  time_t
 parse8601(char *s)  parse8601(char *s)
 {  {
         char *t;  
         struct tm tm, *tmp;          struct tm tm, *tmp;
           char *t;
         long l;          long l;
   
         tmp = localtime(&timenow);          tmp = localtime(&timenow);
Line 1175 
Line 1172 
         }          }
   
         /* sanity check */          /* sanity check */
         if (tm.tm_year < 70 || tm.tm_mon < 0 || tm.tm_mon > 12          if (tm.tm_year < 70 || tm.tm_mon < 0 || tm.tm_mon > 12 ||
             || tm.tm_mday < 1 || tm.tm_mday > 31)              tm.tm_mday < 1 || tm.tm_mday > 31)
                 return (-1);                  return (-1);
   
         if (*t != '\0') {          if (*t != '\0') {
Line 1201 
Line 1198 
                 }                  }
   
                 /* sanity check */                  /* sanity check */
                 if (tm.tm_sec < 0 || tm.tm_sec > 60 || tm.tm_min < 0                  if (tm.tm_sec < 0 || tm.tm_sec > 60 || tm.tm_min < 0 ||
                     || tm.tm_min > 59 || tm.tm_hour < 0 || tm.tm_hour > 23)                      tm.tm_min > 59 || tm.tm_hour < 0 || tm.tm_hour > 23)
                         return (-1);                          return (-1);
         }          }
         return (mktime(&tm));          return (mktime(&tm));
Line 1225 
Line 1222 
 time_t  time_t
 parseDWM(char *s)  parseDWM(char *s)
 {  {
         char *t;          static int mtab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
           int WMseen = 0, Dseen = 0, nd;
         struct tm tm, *tmp;          struct tm tm, *tmp;
           char *t;
         long l;          long l;
         int nd;  
         static int mtab[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};  
         int WMseen = 0;  
         int Dseen = 0;  
   
         tmp = localtime(&timenow);          tmp = localtime(&timenow);
         tm = *tmp;          tm = *tmp;

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.80