]> andersk Git - moira.git/blobdiff - regtape/employee.dc
Diane Delgado's changes for a fixed table-locking order
[moira.git] / regtape / employee.dc
index 758b67dc858ad24fb577b5a287dd7e6c630b9372..a313c8069beac7decc6eff26c032468bdca1e2b1 100644 (file)
@@ -112,10 +112,11 @@ char **argv;
 
     setlinebuf(stdout);
     setlinebuf(stderr);
+    initialize_sms_error_table();
 
     EXEC SQL CONNECT moira;
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       com_err(whoami, 0, "ingres error %d opening database", sqlca.sqlcode);
        exit(1);
     }
 
@@ -128,7 +129,7 @@ char **argv;
                 com_err(whoami, MR_DEADLOCK, "commiting work");
                 goto again;
             } else {
-                com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+                com_err(whoami, 0, "ingres error %d committing work", sqlca.sqlcode);
                 exit(1);
             }
        }
@@ -226,12 +227,8 @@ FILE *in;
     e.title = strtrim(title);
 
     e.class = "MITS";
-    if (!strcmp(e.dept, "PROJECT ATHENA"))
-      e.class = "STAFF";
-    else if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
+    if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
       e.class = "FACULTY";
-    else if (!strcmp(e.title, "VISITING SCIENTIST"))
-      e.class = "VSCIENTI";
 
     strcpy(email, strtrim(username));
     if (host[0] == '@')
@@ -254,6 +251,10 @@ struct entry *e;
     int id, status, who;
     EXEC SQL END DECLARE SECTION;
 
+    /* Don't process Lincoln Labs */
+    if (!strncmp(e->address, "LL", 2))
+      return;
+
     who = WHO;
     prog = PROG;
     first = e->first;
@@ -304,14 +305,15 @@ struct entry *e;
        }
     }
 
-    /* Update class/state if necessary */
+    /* Update class/state if necessary.  (Exclude several spacial cases.) */
     if (strcmp(e->class, strtrim(class)) &&
-       strcmp(class, "STAFF") && strcmp(class, "SIPB")) {
+       strcmp(class, "STAFF") && strcmp(class, "SIPBMEM") &&
+       strcmp(class, "KNIGHT")) {
        com_err(whoami, 0, "updating class for %s %s from %s to %s",
                first, last, class, e->class);
-       if (status == US_NOT_ALLOWED && !strcmp(e->class, "FACULTY"))
+       if (status == US_NOT_ALLOWED)
          status = US_NO_LOGIN_YET;
-       if (status == US_ENROLL_NOT_ALLOWED && !strcmp(e->class, "FACULTY"))
+       if (status == US_ENROLL_NOT_ALLOWED)
          status = US_ENROLLED;
        strcpy(class, e->class);
        EXEC SQL UPDATE users
@@ -319,8 +321,13 @@ struct entry *e;
                modby = :who, modwith = :prog
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-           exit(1);
+            if (sqlca.sqlcode == SQL_DEADLOCK) {
+                com_err(whoami, MR_DEADLOCK, "updating user");
+               return;
+            } else {
+                com_err(whoami, 0, "ingres error %d updating user", sqlca.sqlcode);
+                exit(1);
+           }
        }
     }
 
@@ -334,8 +341,13 @@ struct entry *e;
                modby = :who, modwith = :prog, modtime = 'now'
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-           exit(1);
+            if (sqlca.sqlcode == SQL_DEADLOCK) {
+                com_err(whoami, MR_DEADLOCK, "updating name");
+               return;
+            } else {
+                com_err(whoami, 0, "ingres error %d updating name", sqlca.sqlcode);
+                exit(1);
+            }
        }
     }
 
@@ -481,9 +493,7 @@ struct entry *e;
       sprintf(fullname, "%s %s %s", first, middle, last);
     else
       sprintf(fullname, "%s %s", first, last);
-    st = US_NOT_ALLOWED;
-    if (!strcmp(e->class, "FACULTY") || !strcmp(e->class, "STAFF"))
-      st = US_NO_LOGIN_YET;
+    st = US_NO_LOGIN_YET;
 
     sid = e->id;
     name = e->name;
@@ -497,13 +507,18 @@ struct entry *e;
        clearid, type, modtime, modby, modwith, fullname, office_addr,
        office_phone, department, fmodtime, fmodby, fmodwith,
        potype, xname, xdept, xtitle, xaddress, xphone1, xphone2, xmodtime)
-      VALUES (:login, :id, :uid, '/bin/csh', :last, :first, :middle, :st,
-             :sid, :class, 'now', :who, :prog, :fullname, :oaddr, :ophone,
-             :dept, 'now', :who, :prog, 'NONE', :name, :rdept,
-             :title, :oaddr, :rhphone, :rophone, 'now');
+      VALUES (:login, :id, :uid, '/bin/athena/tcsh', :last, :first,
+             :middle, :st, :sid, :class, 'now', :who, :prog,
+             :fullname, :oaddr, :ophone, :dept, 'now', :who, :prog,
+             'NONE', :name, :rdept, :title, :oaddr, :rhphone,
+             :rophone, 'now');
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-       exit(1);
+       if (sqlca.sqlcode == SQL_DEADLOCK) {
+           com_err(whoami, MR_DEADLOCK, "adding user");
+       } else {
+           com_err(whoami, 0, "ingres error %d adding user", sqlca.sqlcode);
+           exit(1);
+       }
     } else
       com_err(whoami, 0, "adding user %s %s", e->first, e->last);
 }
@@ -549,7 +564,7 @@ set_next_users_id(limit)
     EXEC SQL REPEATED UPDATE numvalues SET value = :value
       WHERE name = 'users_id';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       com_err(whoami, 0, "ingres error %d assigning ID", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
@@ -592,7 +607,7 @@ set_next_uid(limit)
       value = MIN_ID_VALUE;
     EXEC SQL REPEATED UPDATE numvalues SET value = :value WHERE name = 'uid';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       com_err(whoami, 0, "ingres error %d assigning ID", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
This page took 0.040889 seconds and 4 git commands to generate.