3 * This generates the input file for the mkdirdb program for the MIT.EDU
6 * (c) Copyright 1989 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, please see the file
12 #include <mit-copyright.h>
17 #include <sys/types.h>
23 char *whoami = "finger.gen";
24 char *ingres_date_and_time();
33 char filename[64], *targetfile;
40 initialize_sms_error_table();
42 ## set lockmode session where level = table
45 if (stat(argv[1], &sb) == 0) {
46 filetime = ingres_date_and_time(sb.st_mtime);
47 ## retrieve (flag1 = int4(interval("min",tblstats.modtime - filetime)))
48 ## where tblstats.table = "users"
50 fprintf(stderr, "File %s does not need to be rebuilt.\n",
56 sprintf(filename, "%s~", targetfile);
57 if ((out = fopen(filename, "w")) == NULL) {
58 fprintf(stderr, "unable to open %s for output\n", filename);
61 } else if (argc != 1) {
62 fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
72 perror("close failed");
83 * ingerr: (supposedly) called when Ingres indicates an error.
84 * I have not yet been able to get this to work to intercept a
85 * database open error.
87 #define INGRES_DEADLOCK 4700
89 static int ingerr(num)
97 ingres_errno = SMS_DEADLOCK;
100 ingres_errno = SMS_INGRES_ERR;
102 com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
103 critical_alert("DCM", "Alias build encountered INGRES ERROR %d", *num);
111 ## int id, pid, bid, mid;
112 ## char name[129], type[9], buf[257], fname[17], mname[17], lname[17];
113 ## char year[9], dept[13], oaddr[17], ophone[13], haddr[81], hphone[17];
114 char stuemp, *mhost, *uname, *pob;
115 struct hash *strings;
118 ## retrieve (buf = users.modtime) where users.users_id = 0
120 strings = create_hash(2000);
121 ## retrieve (id = strings.string_id, name = strings.string) {
122 hash_store(strings, id, strsave(strtrim(name)));
126 ## range of u is users
127 ## retrieve (id = u.users_id, name = u.login,
128 ## fname = u.first, mname = u.middle, lname = u.last,
129 ## year = u.mit_year, dept = u.mit_dept,
130 ## oaddr = u.office_addr, ophone = u.office_phone,
131 ## haddr = u.home_addr, hphone = u.home_phone,
132 ## type = u.potype, bid = u.box_id)
133 ## where u.status != 3 {
139 if (atoi(year) || !strcmp(year, "G"))
141 else if (!strcmp(year, "FACULTY") || !strcmp(year, "MITS") ||
142 !strcmp(year, "STAFF"))
144 else if (!strcmp(year, "PROJECT") || !strcmp(year, "SYSTEM"))
149 if (type[0] == 'S' & (pob = hash_lookup(strings, bid)) != NULL) {
151 mhost = index(pob, '@');
155 mhost = &uname[strlen(uname) + 1];
156 } else if (type[0] == 'N') {
160 mhost = "ATHENA.MIT.EDU";
161 uname = strtrim(name);
164 fprintf(out, "%c:%s:%s:%s:%s:",
165 stuemp, "", strtrim(lname), strtrim(fname), strtrim(mname));
166 fprintf(out, "%s:%s:%s:%s:%s:%s:%s:%s:",
167 strtrim(oaddr), "", strtrim(ophone), "",
168 "", "", uname, mhost);
169 fprintf(out, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%d\n",
170 strtrim(haddr), "", "", "", strtrim(hphone),
171 "", "", "", "", year, "", id);