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

Diff for /src/usr.bin/calendar/calendar.c between version 1.11 and 1.13

version 1.11, 1998/11/04 11:32:02 version 1.13, 2000/06/30 16:00:11
Line 55 
Line 55 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
   #include <tzfile.h>
 #include <unistd.h>  #include <unistd.h>
   
 #include "pathnames.h"  #include "pathnames.h"
Line 67 
Line 68 
 int f_dayAfter = 0; /* days after current date */  int f_dayAfter = 0; /* days after current date */
 int f_dayBefore = 0; /* days before current date */  int f_dayBefore = 0; /* days before current date */
   
   struct specialev spev[NUMEV];
   
 int  int
 main(argc, argv)  main(argc, argv)
         int argc;          int argc;
         char *argv[];          char *argv[];
 {  {
         int ch;          int ch, i;
         char *caldir;          char *caldir;
   
         (void) setlocale(LC_ALL, "");          (void)setlocale(LC_ALL, "");
   
         while ((ch = getopt(argc, argv, "-af:t:A:B:")) != -1)          while ((ch = getopt(argc, argv, "-af:t:A:B:")) != -1)
                 switch (ch) {                  switch (ch) {
                 case '-':               /* backward contemptible */                  case '-':               /* backward contemptible */
                 case 'a':                  case 'a':
                         if (getuid())                          if (getuid())
                                 errx(1, strerror(EPERM));                                  errx(1, "%s", strerror(EPERM));
                         doall = 1;                          doall = 1;
                         break;                          break;
   
Line 91 
Line 94 
                         break;                          break;
   
                 case 't': /* other date, undocumented, for tests */                  case 't': /* other date, undocumented, for tests */
                         if ((f_time = Mktime (optarg)) <= 0)                          if ((f_time = Mktime(optarg)) <= 0)
                                 errx(1, "specified date is outside allowed range");                                  errx(1, "specified date is outside allowed range");
                         break;                          break;
   
Line 116 
Line 119 
         if (f_time <= 0)          if (f_time <= 0)
             (void)time(&f_time);              (void)time(&f_time);
   
         settime(f_time);          if (f_dayBefore) {
                   /* Move back in time and only look forwards */
                   f_dayAfter += f_dayBefore;
                   f_time -= SECSPERDAY * f_dayBefore;
                   f_dayBefore = 0;
           }
           settime(&f_time);
   
         if (doall) {          if (doall) {
                 while ((pw = getpwent()) != NULL) {                  while ((pw = getpwent()) != NULL) {
                           (void)setlocale(LC_ALL, "");
                         (void)setegid(pw->pw_gid);                          (void)setegid(pw->pw_gid);
                         (void)initgroups(pw->pw_name, pw->pw_gid);                          (void)initgroups(pw->pw_name, pw->pw_gid);
                         (void)seteuid(pw->pw_uid);                          (void)seteuid(pw->pw_uid);
                         if (!chdir(pw->pw_dir))                          if (!chdir(pw->pw_dir)) {
                                 cal();                                  cal();
                                   /* Keep user settings from propogating */
                                   for (i = 0; i < NUMEV; i++)
                                           if (spev[i].uname != NULL)
                                                   free(spev[i].uname);
                           }
                         (void)seteuid(0);                          (void)seteuid(0);
                 }                  }
         }          }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.13