]> andersk Git - moira.git/commitdiff
remove -d and -n options.
authordanw <danw>
Sat, 9 Jan 1999 05:47:55 +0000 (05:47 +0000)
committerdanw <danw>
Sat, 9 Jan 1999 05:47:55 +0000 (05:47 +0000)
always log actions verbosely

regtape/employee.pc

index e5da4f5b3ffc7b477161240a23c01f644448eb0a..aac563167118a6048aeab1b4d9a3cfaf96e0a2e7 100644 (file)
@@ -86,7 +86,7 @@ void sqlexit(void);
 void dbmserr(char *where, int what);
 
 char *whoami;
-int newfinger = 0, debug = 0, highid = 0;
+int highid = 0;
 
 #define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 1403)
 #define SQL_DUPLICATE -2112
@@ -115,10 +115,6 @@ int main(int argc, char **argv)
     {
       if (!strcmp(argv[i], "-w"))
        wait++;
-      else if (!strcmp(argv[i], "-n"))
-       newfinger++;
-      else if (!strcmp(argv[i], "-d"))
-       debug++;
       else if (!strcmp(argv[i], "-h"))
        highid++;
       else if (file)
@@ -303,7 +299,7 @@ struct entry *get_next_entry(FILE *in)
 
 void process_entry(struct entry *e)
 {
-  int changed, nochange;
+  int changed;
   char buf[MAX_FIELD_WIDTH], *from, *to;
   EXEC SQL BEGIN DECLARE SECTION;
   char *first, *last, *middle, *sid, *name, *rdept;
@@ -335,7 +331,7 @@ void process_entry(struct entry *e)
     INTO :id, :dfirst, :dlast, :dmiddle, :class, :oaddr,
     :ophone, :dept, :status
     FROM users
-    WHERE clearid = :sid;
+    WHERE clearid = :sid AND status != 3;
   if (sqlfail())
     {
       if (sqlca.sqlcode == SQL_DUPLICATE)
@@ -352,30 +348,31 @@ void process_entry(struct entry *e)
       newuser(e);
       return;
     }
+  strtrim(dfirst);
+  strtrim(dlast);
+  strtrim(dmiddle);
+  strtrim(class);
 
   /* Update class/state if necessary.  (Exclude several spacial cases.) */
-  if (strcmp(e->class, strtrim(class)) &&
+  if (strcmp(e->class, class) &&
       strcmp(class, "STAFF") && strcmp(class, "SIPBMEM") &&
       strcmp(class, "KNIGHT"))
     {
-      com_err(whoami, 0, "updating class for %s %s from %s to %s",
+      com_err(whoami, 0, "updating class for %s %s from \"%s\" to \"%s\"",
              first, last, class, e->class);
       if (status == US_NOT_ALLOWED)
        status = US_NO_LOGIN_YET;
       if (status == US_ENROLL_NOT_ALLOWED)
        status = US_ENROLLED;
       strcpy(class, e->class);
-      if (!debug)
+      EXEC SQL UPDATE users
+       SET type = NVL(:class, CHR(0)), status = :status,
+       modtime = SYSDATE, modby = :who, modwith = :prog
+       WHERE users_id = :id;
+      if (sqlca.sqlcode)
        {
-         EXEC SQL UPDATE users
-           SET type = NVL(:class, CHR(0)), status = :status,
-           modtime = SYSDATE, modby = :who, modwith = :prog
-           WHERE users_id = :id;
-         if (sqlca.sqlcode)
-           {
-             dbmserr("updating user", sqlca.sqlcode);
-             exit(1);
-           }
+         dbmserr("updating user", sqlca.sqlcode);
+         exit(1);
        }
     }
 
@@ -384,58 +381,36 @@ void process_entry(struct entry *e)
       strcmp(last, strtrim(dlast)) ||
       strcmp(middle, strtrim(dmiddle)))
     {
-      com_err(whoami, 0, "updating real name for %s %s", first, last);
-      if (!debug)
-       {
-         EXEC SQL UPDATE users
-           SET first = NVL(:first, CHR(0)), last = NVL(:last, CHR(0)),
-           middle = NVL(:middle, CHR(0)), modby = :who, modwith = :prog,
-           modtime = SYSDATE
-           WHERE users_id = :id;
-         if (sqlca.sqlcode)
-           {
-             dbmserr("updating name", sqlca.sqlcode);
-             exit(1);
-           }
-       }
-      else
+      com_err(whoami, 0, "updating real name for %s%s%s %s (was %s%s%s %s)",
+             first, *middle ? " " : "", middle, last,
+             dfirst, *dmiddle ? " " : "", dmiddle, dlast);
+      EXEC SQL UPDATE users
+       SET first = NVL(:first, CHR(0)), last = NVL(:last, CHR(0)),
+       middle = NVL(:middle, CHR(0)), modby = :who, modwith = :prog,
+       modtime = SYSDATE
+       WHERE users_id = :id;
+      if (sqlca.sqlcode)
        {
-         com_err(whoami, 0, "was %s %s %s, became %s %s %s",
-                 dfirst, dmiddle, dlast, first, middle, last);
+         dbmserr("updating name", sqlca.sqlcode);
+         exit(1);
        }
     }
 
-  changed = nochange = 0;
+  changed = 0;
   strcpy(buf, e->address);
   while ((to = strchr(buf, ',')))
     *to = ';';
   while ((to = strchr(buf, ':')))
     *to = ';';
-  if (newfinger)
+  if (strncmp(strtrim(oaddr), buf, USERS_OFFICE_ADDR_SIZE - 1))
     {
-      if (oaddr[0] == ' ' && buf[0])
-       {
-         strncpy(oaddr, buf, USERS_OFFICE_ADDR_SIZE - 1);
-         oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
-         changed++;
-       }
-      else if (strncmp(strtrim(oaddr), buf, USERS_OFFICE_ADDR_SIZE - 1))
-       nochange++;
-    }
-  else
-    {
-      if (strncmp(strtrim(oaddr), buf, USERS_OFFICE_ADDR_SIZE - 1))
-       {
-         changed++;
-         if (debug)
-           {
-             com_err(whoami, 0, "office for %s %s changed from %s to %s",
-                     first, last, oaddr, buf);
-           }
-       }
-      strncpy(oaddr, buf, USERS_OFFICE_ADDR_SIZE - 1);
-      oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
+      changed++;
+      com_err(whoami, 0, "office for %s %s changed from \"%s\" to \"%s\"",
+             first, last, oaddr, buf);
     }
+  strncpy(oaddr, buf, USERS_OFFICE_ADDR_SIZE - 1);
+  oaddr[USERS_OFFICE_ADDR_SIZE - 1] = '\0';
+
   from = e->phone;
   to = buf;
   while (*from)
@@ -445,56 +420,26 @@ void process_entry(struct entry *e)
       from++;
     }
   *to = '\0';
-  if (newfinger)
+  if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
     {
-      if (ophone[0] == ' ')
-       {
-         strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
-         ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
-       }
-      else if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
-       nochange++;
-    }
-  else
-    {
-      if (strncmp(strtrim(ophone), buf, USERS_OFFICE_PHONE_SIZE - 1))
-       {
-         changed++;
-         if (debug)
-           {
-             com_err(whoami, 0, "Phone for %s %s changed from %s to %s",
-                     first, last, ophone, buf);
-           }
-       }
-      strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
-      ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
+      changed++;
+      com_err(whoami, 0, "Phone for %s %s changed from \"%s\" to \"%s\"",
+             first, last, ophone, buf);
     }
+  strncpy(ophone, buf, USERS_OFFICE_PHONE_SIZE - 1);
+  ophone[USERS_OFFICE_PHONE_SIZE - 1] = '\0';
+
   FixCase(e->dept);
   FixCase(e->title);
-  if (newfinger)
-    {
-      if (dept[0] == ' ')
-       {
-         strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
-         dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
-       }
-      else if (strncmp(strtrim(dept), e->dept, USERS_DEPARTMENT_SIZE - 1))
-       nochange++;
-    }
-  else
+  if (strncmp(strtrim(dept), e->dept, USERS_DEPARTMENT_SIZE - 1))
     {
-      if (strncmp(strtrim(dept), e->dept, USERS_DEPARTMENT_SIZE - 1))
-       {
-         changed++;
-         if (debug)
-           {
-             com_err(whoami, 0, "Department for %s %s changed from %s to %s",
-                     first, last, dept, e->dept);
-           }
-       }
-      strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
-      dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
+      changed++;
+      com_err(whoami, 0, "Department for %s %s changed from \"%s\" to \"%s\"",
+             first, last, dept, e->dept);
     }
+  strncpy(dept, e->dept, USERS_DEPARTMENT_SIZE - 1);
+  dept[USERS_DEPARTMENT_SIZE - 1] = '\0';
+
   sid = e->id;
   name = e->name;
   rdept = e->dept;
@@ -503,9 +448,6 @@ void process_entry(struct entry *e)
   rhphone = e->phone;
   rophone = e->phone2;
 
-  if (debug)
-    return;
-
   if (changed)
     {
       com_err(whoami, 0, "updating finger for %s %s", first, last);
@@ -595,8 +537,6 @@ void newuser(struct entry *e)
   rophone = e->phone2;
 
   com_err(whoami, 0, "adding user %s %s", e->first, e->last);
-  if (debug)
-    return;
 
   EXEC SQL INSERT INTO users
     (login, users_id, unix_uid, shell, last, first, middle, status,
@@ -625,9 +565,6 @@ int set_next_users_id(int limit)
   int flag, value, retval;
   EXEC SQL END DECLARE SECTION;
 
-  if (debug)
-    return 0;
-
   EXEC SQL SELECT value INTO :value FROM numvalues
     WHERE name = 'users_id';
   if (sqlfail())
@@ -680,9 +617,6 @@ int set_next_uid(int high)
   char *name;
   EXEC SQL END DECLARE SECTION;
 
-  if (debug)
-    return 0;
-
   if (high)
     name = "high_uid";
   else
This page took 0.083446 seconds and 5 git commands to generate.