/* 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]
#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
{
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;
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);
&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 = "";
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";