]> andersk Git - moira.git/blobdiff - regtape/students.dc
Case-insensitive stuff.
[moira.git] / regtape / students.dc
index 37d29ff560bf682c54cfb94253f57c2bf456e0ba..0a23b9ea0016c97e1a2c557e544e5bf96f521fec 100644 (file)
@@ -39,7 +39,7 @@
 #define LOC_DORM_ROOM 110
 #define LOC_CITY 125
 #define LOC_STATE 145
-#define LOC_DPHONE 159
+#define LOC_DPHONE 155
 #define LOC_MPHONE 243
 
 #define LEN_NAME 30
@@ -49,9 +49,9 @@
 #define LEN_ADDRESS 30
 #define LEN_DORM_ROOM 15
 #define LEN_CITY 20
-#define LEN_STATE 14
-#define LEN_DPHONE 9
-#define LEN_MPHONE 9
+#define LEN_STATE 10
+#define LEN_DPHONE 12
+#define LEN_MPHONE 12
 
 struct entry {
     char *name;
@@ -75,7 +75,6 @@ struct entry {
 
 char *whoami;
 int newfinger = 0;
-int addxuser = 0;
 
 
 main(argc, argv)
@@ -100,10 +99,8 @@ char **argv;
          setenv("ING_SET", "set printqry");
        else if (!strcmp(argv[i], "-n"))
          newfinger++;
-       else if (!strcmp(argv[i], "-u"))
-         addxuser++;
        else if (file != NULL)
-         fprintf(stderr, "Usage: %s [-w] [-D] [-n] [-u] inputfile\n", whoami);
+         fprintf(stderr, "Usage: %s [-w] [-D] [-n] inputfile\n", whoami);
        else
          file = argv[i];
     }
@@ -114,6 +111,9 @@ char **argv;
        exit(1);
     }
 
+    setlinebuf(stdout);
+    setlinebuf(stderr);
+
 ##  ingres sms
 ##  range of u is users
 
@@ -142,7 +142,7 @@ FILE *in;
     static char state[LEN_STATE+1], dphone[LEN_DPHONE+1], mphone[LEN_MPHONE+1];
     static char sname[LEN_NAME+1], title[128];
     static int nyear = 0;
-    int ends_jr, ends_iii, ends_iv, ends_sr;
+    int ends_jr, ends_iii, ends_iv, ends_sr, ends_ii, ends_v;
     char *p;
 
     if (nyear == 0) {
@@ -185,18 +185,21 @@ FILE *in;
            *p = 0;
            e.first = strtrim(e.first);
            e.middle = strtrim(p + 1);
-       } else
-         e.first = strtrim(e.first);
-         e.middle = "";
+       } else {
+           e.first = strtrim(e.first);
+           e.middle = "";
+       }
     } else {
        e.first = "";
        e.middle = "";
     }
-    ends_jr = ends_iii = ends_iv = ends_sr = 0;
+    ends_jr = ends_iii = ends_iv = ends_sr = ends_ii = ends_v = 0;
     LookForSt(e.last);
     LookForO(e.last);
-    LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
-    LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
+    LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
+                   &ends_ii, &ends_v);
+    LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
+                   &ends_ii, &ends_v);
     FixCase(e.last);
     FixCase(e.first);
     FixCase(e.middle);
@@ -231,10 +234,11 @@ FILE *in;
 process_entry(e)
 struct entry *e;
 ##{
-    int changed, nochange;
+    int changed, nochange, encrypted;
     char buf[BUFSIZ], *from, *to;
-##  char *first, *last, *eid, *title, *sid, *name;
-##  char class[9], haddr[128], hphone[17], ophone[13], dept[24];
+##  char *first, *last, *eid, *title, *sid, *name, *rname, *rdept, *rtitle;
+##  char *rophone, *rhphone;
+##  char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
 ##  int id, status;
 
     first = e->first;
@@ -244,15 +248,31 @@ struct entry *e;
     if (strlen(last) > 16)
       last[16] = 0;
     eid = e->eid;
+    sid = e->id;
     id = 0;
+    encrypted = 0;
+
+/* Get user info */
 ##  repeat retrieve (id = u.users_id, class = u.mit_year, haddr = u.home_addr,
 ##           hphone = u.home_phone, ophone = u.office_phone,
 ##           status = u.#status, dept = u.mit_dept)
-##     where u.#last = @last and u.#first = @first and u.mit_id = @eid
+##     where u.#last = @last and u.#first = @first and u.mit_id = @sid
     if (id == 0) {
-       newuser(e);
-       return;
+##     repeat retrieve (id = u.users_id, class = u.mit_year, haddr = u.home_addr,
+##           hphone = u.home_phone, ophone = u.office_phone,
+##           status = u.#status, dept = u.mit_dept)
+##     where u.#last = @last and u.#first = @first and u.mit_id = @eid
+       encrypted++;
+       if (id == 0) {
+           newuser(e);
+           return;
+       }
     }
+
+/* See if class changed: if it's different, and the value in the database
+ * is not STAFF or SIPB, then update the database.  Since they were on the
+ * students tape, make the account usable.
+ */
     if (strcmp(e->class, strtrim(class)) &&
        strcmp(class, "STAFF") && strcmp(class, "SIPB")) {
        com_err(whoami, 0, "updating class for user %s %s from %s to %s",
@@ -260,10 +280,13 @@ struct entry *e;
        if (status == US_NOT_ALLOWED) status = US_NO_LOGIN_YET;
        if (status == US_ENROLL_NOT_ALLOWED) status = US_ENROLLED;
        strcpy(class, e->class);
-##     repeat replace u (mit_year = @class, #status = @status, ugdefault = 1,
+##     repeat replace u (mit_year = @class, #status = @status,
 ##                modtime = "now", modby = WHO, modwith = PROG)
 ##         where u.users_id = @id
     }
+
+    /* Deal with updating the finger info if necessary */
+
     changed = nochange = 0;
     strcpy(buf, e->address);
     if (*e->dorm) {
@@ -349,41 +372,40 @@ struct entry *e;
        strncpy(dept, e->course, 12);
        dept[12] = 0;
     }
+    sid = e->id;
+    name = e->name;
+    rdept = e->course;
+    rtitle = e->title;
+    rophone = e->mphone;
+    rhphone = e->dphone;
+    strcpy(raddr, e->address);
+    if (*e->dorm) {
+       strcat(raddr, " ");
+       strcat(raddr, e->dorm);
+    }
+    if (*e->city) {
+       strcat(raddr, " ");
+       strcat(raddr, e->city);
+    }
+    FixCase(raddr);
+    if (*e->state) {
+       strcat(raddr, " ");
+       strcat(raddr, e->state);
+    }
     if (changed) {
        com_err(whoami, 0, "updating finger for %s %s", first, last);
 ##     repeat replace u (home_addr = @haddr, home_phone = @hphone,
-##                office_phone = @ophone, #mit_dept = @dept, ugdefault = 1,
-##                fmodtime = "now", fmodby = WHO, fmodwith = PROG)
+##                office_phone = @ophone, #mit_dept = @dept,
+##                fmodtime = "now", fmodby = WHO, fmodwith = PROG,
+##                xname = @name, xdept = @rdept, xtitle = @rtitle,
+##                xaddress = @raddr, xphone1 = @rhphone, xphone2 = @rophone,
+##                xmodtime = date("now"), mit_id = @sid)
+##         where u.users_id = @id
+    }  else {
+##     repeat replace u (xname = @name, xdept = @rdept, xtitle = @rtitle,
+##                xaddress = @raddr, xphone1 = @rhphone, xphone2 = @rophone,
+##                xmodtime = date("now"), mit_id = @sid)
 ##         where u.users_id = @id
-    } /* else if (nochange)
-      com_err(whoami, 0, "NOT updating finger for %s %s", first, last);
-       */
-    if (!changed && !strcmp(e->class, class)) {
-##     repeat replace u (ugdefault = 1) where u.users_id = @id
-    }
-    if (addxuser) {
-       sid = e->id;
-       name = e->name;
-       strcpy(dept, e->course);
-       title = e->title;
-       strcpy(haddr, e->address);
-       if (*e->dorm) {
-           strcat(haddr, " ");
-           strcat(haddr, e->dorm);
-       }
-       if (*e->city) {
-           strcat(haddr, " ");
-           strcat(haddr, e->city);
-       }
-       FixCase(haddr);
-       if (*e->state) {
-           strcat(haddr, " ");
-           strcat(haddr, e->state);
-       }
-       
-##     append xuser (users_id = id, #id = sid, #name = name, #dept = dept,
-##                   #title = title, address = haddr, #phone1 = hphone,
-##                   #phone2 = ophone, modtime = "now")
     }
 ##}
 
@@ -393,8 +415,8 @@ struct entry *e;
 ##{
     char buf[512], *from, *to;
 ##  int id, uid;
-##  char *last, *first, *class, *middle, login[9], *eid, fullname[65];
-##  char haddr[81], hphone[17], ophone[13], dept[24], *sid, *title;
+##  char *last, *first, *class, *middle, login[9], *sid, fullname[65];
+##  char haddr[81], hphone[17], ophone[13], dept[24], *title;
 
 
     strcpy(buf, e->address);
@@ -431,14 +453,15 @@ struct entry *e;
     strncpy(ophone, buf, 12);
     strncpy(dept, e->course, 12);
     
-    id = set_next_object_id("users_id");
-    uid = set_next_object_id("uid");
+    id = set_next_object_id("users_id", 0);
+    uid = set_next_object_id("uid", 1);
     sprintf(login, "#%d", uid);
     last = e->last;
     first = e->first;
     middle = e->middle;
-    eid = e->eid;
+    sid = e->id;
     class = e->class;
+    title = e->title;
     if (*middle)
       sprintf(fullname, "%s %s %s", first, middle, last);
     else
@@ -446,43 +469,23 @@ struct entry *e;
     
 ##  append users (#login = login, users_id = id, #uid = uid, shell = "/bin/csh",
 ##               #last = last, #first = first, #middle = middle, status = 0,
-##               #mit_id = eid, #mit_year = class, ugdefault = 1,
+##               #mit_id = sid, #mit_year = class,
 ##               modtime = "now", modby = WHO, modwith = PROG,
 ##               #fullname = fullname, home_addr = haddr, home_phone = hphone,
 ##               office_phone = ophone, #mit_dept = dept,
 ##               fmodtime = "now", fmodby = WHO, fmodwith = PROG,
-##               potype = "NONE")
+##               potype = "NONE",
+##               xname = fullname, xdept = dept, xtitle = title,
+##               xaddress = haddr, xphone1 = hphone, xphone2 = ophone,
+##               xmodtime = date("now"))
 
-    sid = e->id;
-    strcpy(fullname, e->name);
-    strcpy(dept, e->course);
-    title = e->title;
-    strcpy(haddr, e->address);
-    if (*e->dorm) {
-       strcat(haddr, " ");
-       strcat(haddr, e->dorm);
-    }
-    if (*e->city) {
-       strcat(haddr, " ");
-       strcat(haddr, e->city);
-    }
-    FixCase(haddr);
-    if (*e->state) {
-       strcat(haddr, " ");
-       strcat(haddr, e->state);
-    }
-
-    if (addxuser) {
-##     append xuser (users_id = id, #id = sid, #name = fullname, #dept = dept,
-##               #title = title, address = haddr, #phone1 = hphone,
-##               #phone2 = ophone, modtime = "now")
-    }
     com_err(whoami, 0, "adding user %s %s", e->first, e->last);
 ##}
 
 
-set_next_object_id(object)
+set_next_object_id(object, limit)
     char *object;
+    int limit;
 ##{
 ##  char *name;
 ##  int rowcount, exists, value;
@@ -504,7 +507,7 @@ set_next_object_id(object)
     }
     while (exists) {
        value++;
-       if (value > MAX_ID_VALUE)
+       if (limit && value > MAX_ID_VALUE)
            value = MIN_ID_VALUE;
 ##     retrieve (exists = any(users.name where users.name = value))
     }
This page took 0.061204 seconds and 4 git commands to generate.