[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.8 and 1.9

version 1.8, 1997/01/15 23:42:56 version 1.9, 1997/04/27 13:48:55
Line 46 
Line 46 
 #endif  #endif
   
 #include <stdio.h>  #include <stdio.h>
   #include <sys/types.h>
   #include <sys/time.h>
   #include <sys/stat.h>
   #include <sys/param.h>
   #include <sys/wait.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <ctype.h>  #include <ctype.h>
 #include <signal.h>  #include <signal.h>
   #include <fcntl.h>
 #include <pwd.h>  #include <pwd.h>
 #include <grp.h>  #include <grp.h>
 #include <sys/types.h>  #include <unistd.h>
 #include <sys/time.h>  
 #include <sys/stat.h>  
 #include <sys/param.h>  
 #include <sys/wait.h>  
   
 #define kbytes(size)  (((size) + 1023) >> 10)  #define kbytes(size)  (((size) + 1023) >> 10)
 #ifdef _IBMR2  
 /* Calculates (db * DEV_BSIZE) */  
 #define dbtob(db)  ((unsigned)(db) << UBSHIFT)  
 #endif  
   
 #define CE_COMPACT 1            /* Compact the achived log files */  #define CE_COMPACT 1            /* Compact the achived log files */
 #define CE_BINARY 2             /* Logfile is in binary, don't add */  #define CE_BINARY 2             /* Logfile is in binary, don't add */
Line 81 
Line 79 
         struct conf_entry       *next; /* Linked list pointer */          struct conf_entry       *next; /* Linked list pointer */
 };  };
   
 extern int      optind;  
 extern char     *optarg;  
 extern char *malloc();  
 extern uid_t getuid(),geteuid();  
 extern time_t time();  
   
 char    *progname;              /* contains argv[0] */  char    *progname;              /* contains argv[0] */
 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 */
Line 100 
Line 92 
 char    *daytime;               /* timenow in human readable form */  char    *daytime;               /* timenow in human readable form */
   
   
 struct conf_entry *parse_file();  void do_entry __P((struct conf_entry *));
 char *sob(), *son(), *strdup(), *missing_field();  void PRS __P((int, char **));
   void usage __P((void));
   struct conf_entry *parse_file __P((void));
   char *missing_field __P((char *, char *));
   void dotrim __P((char *, int, int, int, int, int));
   int log_trim __P((char *));
   void compress_log __P((char *));
   int sizefile __P((char *));
   int age_old_log __P((char *));
   char *sob __P((char *));
   char *son __P((char *));
   int isnumber __P((char *));
   
 main(argc,argv)  int main(argc, argv)
         int argc;          int argc;
         char **argv;          char **argv;
 {  {
Line 124 
Line 127 
         exit(0);          exit(0);
 }  }
   
 do_entry(ent)  void do_entry(ent)
         struct conf_entry       *ent;          struct conf_entry       *ent;
   
 {  {
Line 168 
Line 171 
         }          }
 }  }
   
 PRS(argc,argv)  void PRS(argc, argv)
         int argc;          int argc;
         char **argv;          char **argv;
 {  {
Line 194 
Line 197 
         (void) gethostname(hostname, sizeof(hostname));          (void) gethostname(hostname, sizeof(hostname));
   
         /* Truncate domain */          /* Truncate domain */
         if (p = strchr(hostname, '.')) {          p = strchr(hostname, '.');
           if (p)
                 *p = '\0';                  *p = '\0';
         }  
   
         optind = 1;             /* Start options parsing */          optind = 1;             /* Start options parsing */
         while ((c = getopt(argc,argv,"nrvf:t:")) != -1)          while ((c = getopt(argc,argv,"nrvf:t:")) != -1) {
                 switch (c) {                  switch (c) {
                 case 'n':                  case 'n':
                         noaction++; /* This implies needroot as off */                          noaction++; /* This implies needroot as off */
Line 217 
Line 220 
                         usage();                          usage();
                 }                  }
         }          }
   }
   
 usage()  void usage()
 {  {
         fprintf(stderr,          fprintf(stderr,
                 "Usage: %s <-nrv> <-f config-file>\n", progname);                  "Usage: %s <-nrv> <-f config-file>\n", progname);
Line 357 
Line 361 
         return(first);          return(first);
 }  }
   
 char *missing_field(p,errline)  char *missing_field(p, errline)
         char    *p,*errline;          char    *p,*errline;
 {  {
         if (!p || !*p) {          if (!p || !*p) {
Line 368 
Line 372 
         return(p);          return(p);
 }  }
   
 dotrim(log,numdays,flags,perm,owner_uid,group_gid)  void dotrim(log, numdays, flags, perm, owner_uid, group_gid)
         char    *log;          char    *log;
         int     numdays;          int     numdays;
         int     flags;          int     flags;
Line 382 
Line 386 
         struct  stat st;          struct  stat st;
         int     days = numdays;          int     days = numdays;
   
 #ifdef _IBMR2  
 /* AIX 3.1 has a broken fchown- if the owner_uid is -1, it will actually */  
 /* change it to be owned by uid -1, instead of leaving it as is, as it is */  
 /* supposed to. */  
                 if (owner_uid == -1)  
                   owner_uid = geteuid();  
 #endif  
   
         /* Remove oldest log */          /* Remove oldest log */
         (void) sprintf(file1,"%s.%d",log,numdays);          (void) sprintf(file1,"%s.%d",log,numdays);
         (void) strcpy(zfile1, file1);          (void) strcpy(zfile1, file1);
Line 482 
Line 478 
 }  }
   
 /* Log the fact that the logs were turned over */  /* Log the fact that the logs were turned over */
 log_trim(log)  int log_trim(log)
         char    *log;          char    *log;
 {  {
         FILE    *f;          FILE    *f;
Line 498 
Line 494 
 }  }
   
 /* Fork of /usr/ucb/compress to compress the old log file */  /* Fork of /usr/ucb/compress to compress the old log file */
 compress_log(log)  void compress_log(log)
         char    *log;          char    *log;
 {  {
         int     pid;          int     pid;
Line 543 
Line 539 
         return( (int) (timenow - sb.st_mtime + 1800) / 3600);          return( (int) (timenow - sb.st_mtime + 1800) / 3600);
 }  }
   
   
 #ifndef OSF  
 /* Duplicate a string using malloc */  
   
 char *strdup(strp)  
 register char   *strp;  
 {  
         register char *cp;  
   
         if ((cp = malloc((unsigned) strlen(strp) + 1)) == NULL)  
                 abort();  
         return(strcpy (cp, strp));  
 }  
 #endif  
   
 /* Skip Over Blanks */  /* Skip Over Blanks */
 char *sob(p)  char *sob(p)
         register char   *p;          register char   *p;
Line 579 
Line 560 
   
 /* Check if string is actually a number */  /* Check if string is actually a number */
   
 isnumber(string)  int isnumber(string)
 char *string;  char *string;
 {  {
         while (*string != '\0') {          while (*string != '\0') {
             if (*string < '0' || *string > '9') return(0);              if (!isdigit(*string++))
             string++;                  return(0);
         }          }
         return(1);          return(1);
 }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9