X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/67805159a972397342c342ee735c8acd640e1399..d1b2a10e6c720fbac770e01e0bc2080e86665bec:/regtape/empconv.qc diff --git a/regtape/empconv.qc b/regtape/empconv.qc deleted file mode 100644 index 0fb3211c..00000000 --- a/regtape/empconv.qc +++ /dev/null @@ -1,262 +0,0 @@ -/* $Header$ - */ - -#include -#include -#include -#include -#include -#include - - -##define WHO 11859 /* root */ -##define PROG "emp-tape" - -#define MAX_ID_VALUE 32766 -#define MIN_ID_VALUE 101 - -/* File format is: - -0-8 id number -9-38 name -39-62 office address -63-74 phone1 -75-86 phone2 -87-106 dept -107-156 title -157-186 username -187-241 host - -*/ - -#define LOC_ID 0 -#define LOC_NAME 9 -#define LOC_OFFICE 39 -#define LOC_PHONE 63 -#define LOC_PHONE2 75 -#define LOC_DEPT 87 -#define LOC_TITLE 107 -#define LOC_USERNAME 157 -#define LOC_HOST 187 - -#define LEN_ID 9 -#define LEN_NAME 30 -#define LEN_OFFICE 24 -#define LEN_PHONE 12 -#define LEN_PHONE2 12 -#define LEN_DEPT 20 -#define LEN_TITLE 50 -#define LEN_USERNAME 30 -#define LEN_HOST 55 - - -struct entry { - char *name; - char *last; - char *first; - char *middle; - char *title; - char *class; - char *id; - char *eid; - char *dept; - char *address; - char *phone; - char *phone2; - char *email; -}; - - -char *whoami; -int newfinger = 0; -int addxuser = 0; - - -main(argc, argv) -int argc; -char **argv; -##{ - FILE *in; - struct entry *e, *get_next_entry(); - int i, wait = 0; - char buf[BUFSIZ], *file = NULL; - - whoami = rindex(argv[0], '/'); - if (whoami) - whoami++; - else - whoami = argv[0]; - - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-w")) - wait++; - else if (!strcmp(argv[i], "-D")) - 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); - else - file = argv[i]; - } - - in = fopen(file, "r"); - if (in == NULL) { - fprintf(stderr, "Unable to open %s for input\n", file); - exit(1); - } - -## ingres sms -## range of u is users - - while (e = get_next_entry(in)) { - process_entry(e); - if (wait) { - printf("Next"); - fflush(stdout); - gets(buf); - } - } - -## exit - exit(0); -##} - - -char *substr(buf, key) -char *buf; -char *key; -{ - int l; - - for (l = strlen(key); *buf; buf++) - if (!strncmp(buf, key, l)) - return(buf); - return(NULL); -} - - -struct entry *get_next_entry(in) -FILE *in; -{ - static struct entry e; - static char buf[BUFSIZ], mid[16], eid[16], email[256]; - static char name[LEN_NAME+1], sname[LEN_NAME+1], id[LEN_ID+1]; - static char office[LEN_OFFICE+1], phone[LEN_PHONE+1], phone2[LEN_PHONE2+1]; - static char dept[LEN_DEPT+1], title[LEN_TITLE+1], username[LEN_USERNAME+1]; - static char host[LEN_HOST+1]; - int ends_sr, ends_jr, ends_iii, ends_iv; - char *p; - - if (fgets(buf, sizeof(buf), in) == NULL) - return((struct entry *)NULL); - - strncpy(id, &buf[LOC_ID], LEN_ID); id[LEN_ID] = 0; - strncpy(name, &buf[LOC_NAME], LEN_NAME); name[LEN_NAME] = 0; - strncpy(office, &buf[LOC_OFFICE], LEN_OFFICE); office[LEN_OFFICE] = 0; - strncpy(phone, &buf[LOC_PHONE], LEN_PHONE); phone[LEN_PHONE] = 0; - strncpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2); phone2[LEN_PHONE2] = 0; - strncpy(dept, &buf[LOC_DEPT], LEN_DEPT); dept[LEN_DEPT] = 0; - strncpy(title, &buf[LOC_TITLE], LEN_TITLE); title[LEN_TITLE] = 0; - strncpy(username, &buf[LOC_USERNAME], LEN_USERNAME); username[LEN_USERNAME] = 0; - strncpy(host, &buf[LOC_HOST], LEN_HOST); host[LEN_HOST] = 0; - - strcpy(sname, name); - e.name = strtrim(sname); - p = index(name, ','); - if (p) - *p = 0; - e.last = strtrim(name); - if (p) { - p++; - while (isspace(*p)) - p++; - e.first = p; - if (p = index(e.first, ' ')) { - *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 = ""; - } - ends_sr = ends_jr = ends_iii = ends_iv = 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); - FixCase(e.last); - FixCase(e.first); - FixCase(e.middle); - - e.id = id; - e.eid = eid; - EncryptID(e.eid, e.id, e.first, e.last); - - e.address = strtrim(office); - e.phone = strtrim(phone); - e.phone2 = strtrim(phone2); - e.dept = strtrim(dept); - 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")) - e.class = "FACULTY"; - else if (!strcmp(e.title, "VISITING SCIENTIST")) - e.class = "VSCIENTI"; - - strcpy(email, strtrim(username)); - if (host[0] == '@') - strncat(email, strtrim(host)); - e.email = email; - - return(&e); -} - - -process_entry(e) -struct entry *e; -##{ - int changed, nochange; - char buf[BUFSIZ], *from, *to; -## char *first, *last, *eid, *sid, *name, *title, *phone2; -## char class[9], oaddr[25], ophone[17], dept[128]; -## int id, status; - - first = e->first; - if (strlen(first) > 16) - first[16] = 0; - last = e->last; - if (strlen(last) > 16) - last[16] = 0; - eid = e->eid; - id = 0; -## repeat retrieve (id = u.users_id, class = u.mit_year, oaddr = u.office_addr, -## ophone = u.office_phone, dept = u.mit_dept, status = u.#status) -## where u.#last = @last and u.#first = @first and u.mit_id = @eid - if (id == 0) { - com_err(whoami, 0, "New user found: %s %s\n", first, last); - return; - } - eid = e->id; -## repeat replace u (mit_id=@eid) where u.users_id = @id - sid = e->id; - name = e->name; - strcpy(dept, e->dept); - title = e->title; - strcpy(oaddr, e->address); - phone2 = e->phone2; -## repeat replace u (xname = @name, xdept = @dept, xtitle = @title, -## xaddress = @oaddr, xphone1 = @ophone, xphone2 = @phone2, -## xmodtime = "now") -## where u.users_id = @id -##} -