23 char buf[1024], first[33], last[33];
28 struct user users[32];
29 struct user *get_user();
33 for (i = 1; i < argc; i++) {
34 if (!strcmp(argv[i], "-d"))
36 else if (!strcmp(argv[i], "-D"))
37 setenv("ING_SET", "set printqry");
38 else if (argv[i][0] == '-')
40 else if (inputfile != NULL)
42 else inputfile = argv[i];
46 in = fopen(inputfile, "r");
48 com_err(program, errno, "opening file \"%s\" for input", inputfile);
58 fgets(buf, sizeof(buf), in);
61 if (strcmp(u->last, users[0].last) ||
62 strcmp(u->first, users[0].first)) {
63 /* We've got a matching group! */
64 process_users(users, i);
65 bcopy(u, &(users[0]), sizeof(*u));
68 bcopy(u, &(users[i]), sizeof(*u));
77 fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
81 struct user *get_user(buf)
86 if (sscanf(buf, "| %d|%s |%s | %d|", &u.users_id, u.first,
87 u.last, &u.status) != 4) {
88 com_err(program, 0, " parsing input line %s", buf);
95 process_users(users, count)
101 ## char login[9], id[17], class[9], modtime[26], modwith[9], xmodtime[26];
102 ## char login2[9], id2[17], class2[9], modtime2[26],modwith2[9],xmodtime2[26];
103 ## char login3[9], id3[17], class3[9], modtime3[26],modwith3[9],xmodtime3[26];
104 ## int users_id, users_id2, users_id3, status, status2, status3, rowcount;
106 printf("\nGot %d users named %s %s\n", count, users[0].first, users[0].last);
107 if (count < 2) return;
109 users_id = users[0].users_id;
110 ## range of u is users
111 ## retrieve (login = u.#login, id = u.mit_id, class = u.mit_year,
112 ## modtime = u.#modtime, modwith = u.#modwith,
113 ## xmodtime = u.#xmodtime, status = u.#status)
114 ## where u.#users_id = users_id
116 users_id2 = users[1].users_id;
117 ## retrieve (login2 = u.#login, id2 = u.mit_id, class2 = u.mit_year,
118 ## modtime2 = u.#modtime, modwith2 = u.#modwith,
119 ## xmodtime2 = u.#xmodtime, status2 = u.#status)
120 ## where u.#users_id = users_id2
122 modtime[20] = modtime2[20] = xmodtime[20] = xmodtime2[20] = 0;
124 printf("A: %s %5d %d\t\t\tB: %s %5d %d\n", login, users_id, status,
125 login2, users_id2, status2);
126 printf(" %s %s\t\t %s %s\n", class, id, class2, id2);
127 printf(" %s %s\t %s %s\n", modtime, modwith, modtime2, modwith2);
128 printf(" %s\t\t\t %s\n", xmodtime, xmodtime2);
131 for (i = 2; i < count; i++) {
132 users_id3 = users[i].users_id;
133 ## retrieve (login3 = u.#login, id3 = u.mit_id, class3 = u.mit_year,
134 ## modtime3 = u.#modtime, modwith3 = u.#modwith,
135 ## xmodtime3 = u.#xmodtime, status3 = u.#status)
136 ## where u.#users_id = users_id3
137 modtime3[20] = xmodtime3[20] = 0;
138 printf("\n%c: %s %5d %d\n", 'A' + i,
139 login3, users_id3, status3);
140 printf(" %s %s\n", class3, id3);
141 printf(" %s %s\n", modtime3, modwith3);
142 printf(" %s\n", xmodtime3);
147 if (status == 3 || status2 == 3) return;
148 if ((status == 0 || status == 4) &&
149 !isdigit(id[0]) && !isdigit(xmodtime[0])) {
150 printf("DELETING %s\n", login);
151 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
152 ## modby=8873) where u.#users_id = users_id
153 ## inquire_equel(rowcount = "rowcount")
155 printf("Failed!\007\007\007\n");
157 printf("User %s marked for deletion.\n", login);
160 if ((status2 == 0 || status2 == 4) &&
161 !isdigit(id2[0]) && !isdigit(xmodtime2[0])) {
162 printf("DELETING %s\n", login2);
163 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
164 ## modby=8873) where u.#users_id = users_id2
165 ## inquire_equel(rowcount = "rowcount")
167 printf("Failed!\007\007\007\n");
169 printf("User %s marked for deletion.\n", login2);
174 printf("\n0,sp: Do nothing\n1: Delete B\n2: Delete A\n");
175 printf("3: A<-B's ID; Delete B\n4: B<-A's ID; Delete A\n");
177 printf("5: Delete C\n");
179 printf("6: Delete D\n");
180 printf("?");fflush(stdout);
184 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
185 ## modby=8873) where u.#users_id = users_id2
186 ## inquire_equel(rowcount = "rowcount")
188 printf("Failed!\007\007\007\n");
190 printf("User %s marked for deletion.\n", login2);
193 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
194 ## modby=8873) where u.#users_id = users_id
195 ## inquire_equel(rowcount = "rowcount")
197 printf("Failed!\007\007\007\n");
199 printf("User %s marked for deletion.\n", login);
202 ## replace u (#mit_id = id2, #modtime=date("now"), #modwith="nodups",
203 ## modby=8873) where u.#users_id = users_id
204 ## inquire_equel(rowcount = "rowcount")
206 printf("Failed!\007\007\007\n");
207 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
208 ## modby=8873) where u.#users_id = users_id2
209 ## inquire_equel(rowcount = "rowcount")
211 printf("Failed!\007\007\007\n");
213 printf("User %s updated, %s marked for deletion.\n", login, login2);
216 ## replace u (#mit_id = id, #modtime=date("now"), #modwith="nodups",
217 ## modby=8873) where u.#users_id = users_id2
218 ## inquire_equel(rowcount = "rowcount")
220 printf("Failed!\007\007\007\n");
221 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
222 ## modby=8873) where u.#users_id = users_id
223 ## inquire_equel(rowcount = "rowcount")
225 printf("Failed!\007\007\007\n");
227 printf("User %s updated, %s marked for deletion.\n", login2, login);
230 users_id = users[2].users_id;
231 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
232 ## modby=8873) where u.#users_id = users_id
233 ## inquire_equel(rowcount = "rowcount")
235 printf("Failed!\007\007\007\n");
237 printf("User %d marked for deletion.\n", users[2].users_id);
240 users_id = users[3].users_id;
241 ## replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
242 ## modby=8873) where u.#users_id = users_id
243 ## inquire_equel(rowcount = "rowcount")
245 printf("Failed!\007\007\007\n");
247 printf("User %d marked for deletion.\n", users[3].users_id);
252 printf("Leaving unchanged\n");