]> andersk Git - moira.git/blobdiff - regtape/staff.pc
Command line printer manipulation client, and build goo.
[moira.git] / regtape / staff.pc
index a636b2f17989b70e16873dab6c1ab18443d15c89..6a384f02d85ef0be387f9112c40fdb95784193a6 100644 (file)
@@ -24,7 +24,9 @@ RCSID("$Header$");
 /* File format is:
  *
  * id number [9]
- * name (last, first middle) [30]
+ * last name [30]
+ * first name [30]
+ * middle name [30]
  * office address [24]
  * phone1 [12]
  * phone2 [12]
@@ -34,9 +36,13 @@ RCSID("$Header$");
 
 #define LOC_ID 0
 #define LEN_ID 9
-#define LOC_NAME (LOC_ID + LEN_ID)
-#define LEN_NAME 30
-#define LOC_OFFICE (LOC_NAME + LEN_NAME)
+#define LOC_LAST_NAME (LOC_ID + LEN_ID)
+#define LEN_LAST_NAME 30
+#define LOC_FIRST_NAME (LOC_LAST_NAME + LEN_LAST_NAME)
+#define LEN_FIRST_NAME 30
+#define LOC_MIDDLE_NAME (LOC_FIRST_NAME + LEN_FIRST_NAME)
+#define LEN_MIDDLE_NAME 30
+#define LOC_OFFICE (LOC_MIDDLE_NAME + LEN_MIDDLE_NAME)
 #define LEN_OFFICE 24
 #define LOC_PHONE (LOC_OFFICE + LEN_OFFICE)
 #define LEN_PHONE 12
@@ -137,7 +143,8 @@ struct entry *get_next_entry(FILE *in)
 {
   static struct entry e;
   static char buf[BUFSIZ];
-  static char name[LEN_NAME + 1], sname[LEN_NAME + 1], id[LEN_ID + 1];
+  static char last_name[LEN_LAST_NAME + 1], id[LEN_ID + 1];
+  static char first_name[LEN_FIRST_NAME + 1], middle_name[LEN_MIDDLE_NAME + 1];
   static char office[LEN_OFFICE + 1], phone[LEN_PHONE + 1];
   static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
   int ends_sr, ends_jr, ends_iii, ends_iv, ends_ii, ends_v;
@@ -147,43 +154,19 @@ struct entry *get_next_entry(FILE *in)
     return NULL;
 
   strlcpy(id, &buf[LOC_ID], LEN_ID + 1);
-  strlcpy(name, &buf[LOC_NAME], LEN_NAME + 1);
+  strlcpy(last_name, &buf[LOC_LAST_NAME], LEN_LAST_NAME + 1);
+  strlcpy(first_name, &buf[LOC_FIRST_NAME], LEN_FIRST_NAME + 1);
+  strlcpy(middle_name, &buf[LOC_MIDDLE_NAME], LEN_MIDDLE_NAME + 1);
   strlcpy(office, &buf[LOC_OFFICE], LEN_OFFICE + 1);
   strlcpy(phone, &buf[LOC_PHONE], LEN_PHONE + 1);
   strlcpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2 + 1);
   strlcpy(dept, &buf[LOC_DEPT], LEN_DEPT + 1);
   strlcpy(title, &buf[LOC_TITLE], LEN_TITLE + 1);
 
-  strcpy(sname, name);
-  e.name = strtrim(sname);
-  p = strchr(name, ',');
-  if (p)
-    *p = '\0';
-  e.last = strtrim(name);
-  if (p)
-    {
-      p++;
-      while (isspace(*p))
-       p++;
-      e.first = p;
-      p = strchr(e.first, ' ');
-      if (p)
-       {
-         *p = '\0';
-         e.first = strtrim(e.first);
-         e.middle = strtrim(p + 1);
-       }
-      else
-       {
-         e.first = strtrim(e.first);
-         e.middle = "";
-       }
-    }
-  else
-    {
-      e.first = "";
-      e.middle = "";
-    }
+  e.last = strtrim(last_name);
+  e.first = strtrim(first_name);
+  e.middle = strtrim(middle_name);
+
   ends_sr = ends_jr = ends_iii = ends_iv = ends_ii = ends_v = 0;
   LookForSt(e.last);
   LookForO(e.last);
@@ -191,9 +174,12 @@ struct entry *get_next_entry(FILE *in)
                  &ends_iv, &ends_v);
   LookForJrAndIII(e.first, &ends_jr, &ends_sr, &ends_ii, &ends_iii,
                  &ends_iv, &ends_v);
-  FixCase(e.last);
-  FixCase(e.first);
-  FixCase(e.middle);
+
+  e.name = buf;
+  if (*e.middle)
+    sprintf(e.name, "%s %s %s", e.first, e.middle, e.last);
+  else
+    sprintf(e.name, "%s %s", e.first, e.last);
 
   e.id = id;
   e.haddr = e.hphone = "";
@@ -253,7 +239,8 @@ struct entry *get_next_entry(FILE *in)
   e.xtitle = strtrim(title);
 
   e.type = "MITS";
-  if (strstr(e.xtitle, "PROF") || strstr(e.xtitle, "LECTURE"))
+  if (strstr(uppercase(e.xtitle), "PROF") ||
+      strstr(uppercase(e.xtitle), "LECTURE"))
     e.type = "FACULTY";
   if (!strcmp(e.dept, "LINCOLN LAB"))
     e.type = "LINCOLN";
This page took 0.046471 seconds and 4 git commands to generate.