9 #include <moira_site.h>
12 ##define WHO 11859 /* root */
13 ##define PROG "emp-tape"
15 #define MAX_ID_VALUE 32766
16 #define MIN_ID_VALUE 101
39 #define LOC_USERNAME 157
49 #define LEN_USERNAME 30
80 struct entry *e, *get_next_entry();
82 char buf[BUFSIZ], *file = NULL;
84 whoami = rindex(argv[0], '/');
90 for (i = 1; i < argc; i++) {
91 if (!strcmp(argv[i], "-w"))
93 else if (!strcmp(argv[i], "-D"))
94 setenv("ING_SET", "set printqry");
95 else if (!strcmp(argv[i], "-n"))
97 else if (!strcmp(argv[i], "-u"))
99 else if (file != NULL)
100 fprintf(stderr, "Usage: %s [-w] [-D] [-n] [-u] inputfile\n", whoami);
105 in = fopen(file, "r");
107 fprintf(stderr, "Unable to open %s for input\n", file);
112 ## range of u is users
114 while (e = get_next_entry(in)) {
128 char *substr(buf, key)
134 for (l = strlen(key); *buf; buf++)
135 if (!strncmp(buf, key, l))
141 struct entry *get_next_entry(in)
144 static struct entry e;
145 static char buf[BUFSIZ], mid[16], eid[16], email[256];
146 static char name[LEN_NAME+1], sname[LEN_NAME+1], id[LEN_ID+1];
147 static char office[LEN_OFFICE+1], phone[LEN_PHONE+1], phone2[LEN_PHONE2+1];
148 static char dept[LEN_DEPT+1], title[LEN_TITLE+1], username[LEN_USERNAME+1];
149 static char host[LEN_HOST+1];
150 int ends_sr, ends_jr, ends_iii, ends_iv;
153 if (fgets(buf, sizeof(buf), in) == NULL)
154 return((struct entry *)NULL);
156 strncpy(id, &buf[LOC_ID], LEN_ID); id[LEN_ID] = 0;
157 strncpy(name, &buf[LOC_NAME], LEN_NAME); name[LEN_NAME] = 0;
158 strncpy(office, &buf[LOC_OFFICE], LEN_OFFICE); office[LEN_OFFICE] = 0;
159 strncpy(phone, &buf[LOC_PHONE], LEN_PHONE); phone[LEN_PHONE] = 0;
160 strncpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2); phone2[LEN_PHONE2] = 0;
161 strncpy(dept, &buf[LOC_DEPT], LEN_DEPT); dept[LEN_DEPT] = 0;
162 strncpy(title, &buf[LOC_TITLE], LEN_TITLE); title[LEN_TITLE] = 0;
163 strncpy(username, &buf[LOC_USERNAME], LEN_USERNAME); username[LEN_USERNAME] = 0;
164 strncpy(host, &buf[LOC_HOST], LEN_HOST); host[LEN_HOST] = 0;
167 e.name = strtrim(sname);
168 p = index(name, ',');
171 e.last = strtrim(name);
177 if (p = index(e.first, ' ')) {
179 e.first = strtrim(e.first);
180 e.middle = strtrim(p + 1);
182 e.first = strtrim(e.first);
189 ends_sr = ends_jr = ends_iii = ends_iv = 0;
192 LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
193 LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv);
200 EncryptID(e.eid, e.id, e.first, e.last);
202 e.address = strtrim(office);
203 e.phone = strtrim(phone);
204 e.phone2 = strtrim(phone2);
205 e.dept = strtrim(dept);
206 e.title = strtrim(title);
209 if (!strcmp(e.dept, "PROJECT ATHENA"))
211 else if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
213 else if (!strcmp(e.title, "VISITING SCIENTIST"))
214 e.class = "VSCIENTI";
216 strcpy(email, strtrim(username));
218 strncat(email, strtrim(host));
228 int changed, nochange;
229 char buf[BUFSIZ], *from, *to;
230 ## char *first, *last, *eid, *sid, *name, *title, *phone2;
231 ## char class[9], oaddr[25], ophone[17], dept[128];
235 if (strlen(first) > 16)
238 if (strlen(last) > 16)
242 ## repeat retrieve (id = u.users_id, class = u.mit_year, oaddr = u.office_addr,
243 ## ophone = u.office_phone, dept = u.mit_dept, status = u.#status)
244 ## where u.#last = @last and u.#first = @first and u.mit_id = @eid
246 com_err(whoami, 0, "New user found: %s %s\n", first, last);
250 ## repeat replace u (mit_id=@eid) where u.users_id = @id
253 strcpy(dept, e->dept);
255 strcpy(oaddr, e->address);
257 ## repeat replace u (xname = @name, xdept = @dept, xtitle = @title,
258 ## xaddress = @oaddr, xphone1 = @ophone, xphone2 = @phone2,
260 ## where u.users_id = @id