]> andersk Git - moira.git/blame - server/qsupport.pc
Check for a message, even if we got back MRCL_SUCCESS.
[moira.git] / server / qsupport.pc
CommitLineData
7ac48069 1/* $Id$
b070f8a1 2 *
7ac48069 3 * Special query routines
b070f8a1 4 *
7ac48069 5 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
7 * <mit-copyright.h>.
b070f8a1 8 */
9
b070f8a1 10#include <mit-copyright.h>
b070f8a1 11#include "mr_server.h"
03c05291 12#include "query.h"
7ac48069 13#include "qrtn.h"
14
b070f8a1 15#include <ctype.h>
7ac48069 16#include <stdlib.h>
03c05291 17#include <string.h>
7ac48069 18
5d677c81 19EXEC SQL INCLUDE sqlca;
7ac48069 20
21RCSID("$Header$");
b070f8a1 22
03c05291 23extern char *whoami, *table_name[];
24extern int dbms_errno, mr_errcode;
b070f8a1 25
0fc7ab46 26EXEC SQL BEGIN DECLARE SECTION;
45bf7573 27extern char stmt_buf[];
0fc7ab46 28EXEC SQL END DECLARE SECTION;
5d677c81 29
03c05291 30EXEC SQL WHENEVER SQLERROR DO dbmserr();
31
7ac48069 32int get_ace_internal(char *atypex, int aid,
33 int (*action)(int, char *[], void *), void *actarg);
7ac48069 34int qualified_get(struct query *q, char *argv[],
35 int (*action)(int, char *[], void *), void *actarg,
03c05291 36 char *start, char *range, char *field, char *flags[]);
453b99fe 37
0fc7ab46 38
0659551f 39/* set_pobox - this does all of the real work.
40 * argv = user_id, type, box
41 * if type is POP, then box should be a machine, and its ID should be put in
17cb3de8 42 * pop_id. If type is IMAP, then box should be a filesys, and its ID should
43 * be put in pop_id. If type is SMTP, then box should be a string and its
44 * ID should be put in box_id. If type is NONE, then box doesn't matter.
0fc7ab46 45 */
b070f8a1 46
5eaef520 47int set_pobox(struct query *q, char **argv, client *cl)
5d677c81 48{
5eaef520 49 EXEC SQL BEGIN DECLARE SECTION;
50 int user, id;
e688520a 51 char *box, potype[USERS_POTYPE_SIZE];
5eaef520 52 EXEC SQL END DECLARE SECTION;
53 int status;
54
55 box = argv[2];
56 user = *(int *)argv[0];
57
58 EXEC SQL SELECT pop_id, potype INTO :id, :potype FROM users
59 WHERE users_id = :user;
60 if (dbms_errno)
61 return mr_errcode;
450849e9 62 if (!strcmp(strtrim(potype), "POP") ||
63 (!strcmp(strtrim(potype), "SPLIT") && id))
5eaef520 64 set_pop_usage(id, -1);
65
66 if (!strcmp(argv[1], "POP"))
67 {
68 status = name_to_id(box, MACHINE_TABLE, &id);
69 if (status == MR_NO_MATCH)
70 return MR_MACHINE;
71 else if (status)
72 return status;
17cb3de8 73 EXEC SQL UPDATE users SET potype = 'POP', pop_id = :id, imap_id = 0
5eaef520 74 WHERE users_id = :user;
75 set_pop_usage(id, 1);
76 }
450849e9 77 else if (!strcmp(argv[1], "SMTP") || !strcmp(argv[1], "SPLIT"))
5eaef520 78 {
79 if (strchr(box, '/') || strchr(box, '|'))
80 return MR_BAD_CHAR;
81 status = name_to_id(box, STRINGS_TABLE, &id);
82 if (status == MR_NO_MATCH)
83 id = add_string(box);
84 else if (status)
85 return status;
450849e9 86
87 /* If going from SMTP or NONE to SPLIT, make sure we have a valid
88 * POP or IMAP box.
89 */
730a5904 90 if ((!strcmp(potype, "SMTP") || !strcmp(potype, "NONE")) &&
91 !strcmp(argv[1], "SPLIT"))
450849e9 92 {
93 status = set_pobox_pop(q, argv, cl);
94 if (status)
95 return status;
96 }
97 strlcpy(potype, argv[1], sizeof(potype));
98 EXEC SQL UPDATE users SET potype = :potype, box_id = :id
5eaef520 99 WHERE users_id = :user;
100 }
7b3eb008 101 else if (!strcmp(argv[1], "IMAP"))
102 {
17cb3de8 103 EXEC SQL SELECT filsys_id INTO :id FROM filesys
104 WHERE label = :box AND type = 'IMAP';
105 if (sqlca.sqlcode)
7b3eb008 106 return MR_FILESYS;
17cb3de8 107 EXEC SQL UPDATE users SET potype = 'IMAP', imap_id = :id, pop_id = 0
7b3eb008 108 WHERE users_id = :user;
109 }
5eaef520 110 else /* argv[1] == "NONE" */
111 {
112 EXEC SQL UPDATE users SET potype = 'NONE'
113 WHERE users_id = :user;
b070f8a1 114 }
115
5eaef520 116 set_pobox_modtime(q, argv, cl);
117 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
118 WHERE table_name = 'users';
119 if (dbms_errno)
120 return mr_errcode;
121 return MR_SUCCESS;
5d677c81 122}
b070f8a1 123
17cb3de8 124/* set_pobox_pop: Revert to existing POP or IMAP pobox.
125 * Also take care of keeping track of the post office usage.
126 */
127int set_pobox_pop(struct query *q, char **argv, client *cl)
128{
129 EXEC SQL BEGIN DECLARE SECTION;
130 int id, pid, iid, mid;
131 char type[USERS_POTYPE_SIZE];
132 EXEC SQL END DECLARE SECTION;
133
134 id = *(int *)argv[0];
135 EXEC SQL SELECT potype, pop_id, imap_id INTO :type, :pid, :iid
136 FROM users WHERE users_id = :id;
137 if (sqlca.sqlerrd[2] == 0 || (pid == 0 && iid == 0))
138 return MR_MACHINE;
139
140 if (pid)
141 {
142 EXEC SQL SELECT mach_id INTO :mid FROM machine
143 WHERE mach_id = :pid;
144 if (sqlca.sqlerrd[2] == 0)
145 return MR_MACHINE;
146 EXEC SQL UPDATE users SET potype = 'POP' WHERE users_id = :id;
450849e9 147 if (!strcmp(strtrim(type), "POP"))
17cb3de8 148 set_pop_usage(mid, 1);
149 }
150 else
151 {
152 EXEC SQL SELECT filsys_id INTO :mid FROM filesys
153 WHERE filsys_id = :iid;
154 if (sqlca.sqlerrd[2] == 0)
155 return MR_MACHINE;
156 EXEC SQL UPDATE users SET potype = 'IMAP' WHERE users_id = :id;
157 }
158
159 set_pobox_modtime(q, argv, cl);
160 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
161 WHERE table_name = 'users';
162 if (dbms_errno)
163 return mr_errcode;
164 return MR_SUCCESS;
165}
166
167
0659551f 168/* Add_member_to_list: do list flattening as we go! MAXLISTDEPTH is
169 * how many different ancestors a member is allowed to have.
b070f8a1 170 */
171
0659551f 172#define MAXLISTDEPTH 1024
b070f8a1 173
5eaef520 174int add_member_to_list(struct query *q, char **argv, client *cl)
5d677c81 175{
5eaef520 176 EXEC SQL BEGIN DECLARE SECTION;
46b6f1f6 177 int id, lid, mid, tag, error, who, ref, rowcnt;
e688520a 178 char *mtype, dtype[IMEMBERS_MEMBER_TYPE_SIZE], *entity;
5eaef520 179 EXEC SQL END DECLARE SECTION;
180 int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
181 int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
182 int status;
183 char *dtypes[MAXLISTDEPTH];
184 char *iargv[3], *buf;
185
186 lid = *(int *)argv[0];
187 mtype = argv[1];
188 mid = *(int *)argv[2];
46b6f1f6 189 tag = !strcmp(q->shortname, "atml") ? *(int *)argv[3] : 0;
a37b0b99 190
191 if (acl_access_check(lid, cl))
192 return MR_PERM;
193
5eaef520 194 /* if the member is already a direct member of the list, punt */
195 EXEC SQL SELECT COUNT(list_id) INTO :rowcnt FROM imembers
196 WHERE list_id = :lid AND member_id = :mid
197 AND member_type = :mtype AND direct = 1;
198 if (rowcnt > 0)
199 return MR_EXISTS;
200 if (!strcasecmp(mtype, "STRING"))
201 {
202 buf = malloc(0);
203 status = id_to_name(mid, STRINGS_TABLE, &buf);
204 if (status)
205 return status;
206 if (strchr(buf, '/') || strchr(buf, '|'))
207 {
208 free(buf);
209 return MR_BAD_CHAR;
0659551f 210 }
5eaef520 211 free(buf);
0659551f 212 }
b070f8a1 213
5eaef520 214 ancestors[0] = lid;
215 aref[0] = 1;
216 acount = 1;
217 EXEC SQL DECLARE csr103 CURSOR FOR
218 SELECT list_id, ref_count FROM imembers
219 WHERE member_id = :lid AND member_type = 'LIST';
220 if (dbms_errno)
221 return mr_errcode;
222 EXEC SQL OPEN csr103;
223 if (dbms_errno)
224 return mr_errcode;
225 while (1)
226 {
227 EXEC SQL FETCH csr103 INTO :id, :ref;
228 if (sqlca.sqlcode)
229 break;
230 aref[acount] = ref;
231 ancestors[acount++] = id;
232 if (acount >= MAXLISTDEPTH)
233 break;
0659551f 234 }
5eaef520 235 EXEC SQL CLOSE csr103;
236 if (dbms_errno)
237 return mr_errcode;
238 if (acount >= MAXLISTDEPTH)
239 return MR_INTERNAL;
240 descendants[0] = mid;
241 dtypes[0] = mtype;
242 dref[0] = 1;
243 dcount = 1;
244 error = 0;
245 if (!strcmp(mtype, "LIST"))
246 {
247 EXEC SQL DECLARE csr104 CURSOR FOR
248 SELECT member_id, member_type, ref_count
249 FROM imembers
250 WHERE list_id = :mid;
251 if (dbms_errno)
252 return mr_errcode;
253 EXEC SQL OPEN csr104;
254 if (dbms_errno)
255 return mr_errcode;
256 while (1)
257 {
258 EXEC SQL FETCH csr104 INTO :id, :dtype, :ref;
259 if (sqlca.sqlcode)
260 break;
261 switch (dtype[0])
262 {
0659551f 263 case 'L':
5eaef520 264 dtypes[dcount] = "LIST";
265 break;
0659551f 266 case 'U':
5eaef520 267 dtypes[dcount] = "USER";
268 break;
0659551f 269 case 'S':
5eaef520 270 dtypes[dcount] = "STRING";
271 break;
0659551f 272 case 'K':
5eaef520 273 dtypes[dcount] = "KERBEROS";
274 break;
0659551f 275 default:
5eaef520 276 error++;
277 break;
0659551f 278 }
5eaef520 279 dref[dcount] = ref;
280 descendants[dcount++] = id;
281 if (dcount >= MAXLISTDEPTH)
282 {
283 error++;
284 break;
0659551f 285 }
286 }
5eaef520 287 EXEC SQL CLOSE csr104;
288 if (dbms_errno)
289 return mr_errcode;
290 if (error)
291 return MR_INTERNAL;
b070f8a1 292 }
5eaef520 293 for (a = 0; a < acount; a++)
294 {
295 lid = ancestors[a];
296 for (d = 0; d < dcount; d++)
297 {
298 mid = descendants[d];
299 mtype = dtypes[d];
300 if (mid == lid && !strcmp(mtype, "LIST"))
301 return MR_LISTLOOP;
302 EXEC SQL SELECT COUNT(ref_count) INTO :rowcnt
303 FROM imembers
304 WHERE list_id = :lid AND member_id = :mid
305 AND member_type = :mtype;
306 ref = aref[a] * dref[d];
307 if (rowcnt > 0)
308 {
309 if (a == 0 && d == 0)
310 {
311 EXEC SQL UPDATE imembers
46b6f1f6 312 SET ref_count = ref_count + :ref, direct = 1, tag = :tag
5eaef520 313 WHERE list_id = :lid AND member_id = :mid
314 AND member_type = :mtype;
0659551f 315 }
5eaef520 316 else
317 {
318 EXEC SQL UPDATE imembers
319 SET ref_count = ref_count + :ref
320 WHERE list_id = :lid AND member_id = :mid
321 AND member_type = :mtype;
322 }
323 }
324 else
325 {
326 incremental_clear_before();
327 if (a == 0 && d == 0)
328 {
03c05291 329 EXEC SQL INSERT INTO imembers
46b6f1f6 330 (list_id, member_type, member_id, tag, direct, ref_count)
331 VALUES (:lid, :mtype, :mid, :tag, 1, 1);
5eaef520 332 }
333 else
334 {
03c05291 335 EXEC SQL INSERT INTO imembers
46b6f1f6 336 (list_id, member_type, member_id, tag, direct, ref_count)
337 VALUES (:lid, :mtype, :mid, :tag, 0, 1);
0659551f 338 }
5eaef520 339 iargv[0] = (char *)lid;
340 iargv[1] = mtype;
341 iargv[2] = (char *)mid;
342 incremental_after(IMEMBERS_TABLE, 0, iargv);
0659551f 343 }
344 }
b070f8a1 345 }
5eaef520 346 lid = *(int *)argv[0];
347 entity = cl->entity;
348 who = cl->client_id;
349 EXEC SQL UPDATE list
350 SET modtime = SYSDATE, modby = :who, modwith = :entity
351 WHERE list_id = :lid;
352 if (dbms_errno)
353 return mr_errcode;
354 return MR_SUCCESS;
5d677c81 355}
b070f8a1 356
357
0659551f 358/* Delete_member_from_list: do list flattening as we go!
b070f8a1 359 */
360
5eaef520 361int delete_member_from_list(struct query *q, char **argv, client *cl)
5d677c81 362{
5eaef520 363 EXEC SQL BEGIN DECLARE SECTION;
364 int id, lid, mid, cnt, error, who, ref;
e688520a 365 char *mtype, dtype[IMEMBERS_MEMBER_TYPE_SIZE], *entity;
5eaef520 366 EXEC SQL END DECLARE SECTION;
367 int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
368 int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
369 char *dtypes[MAXLISTDEPTH];
370 char *iargv[3];
371
372 lid = *(int *)argv[0];
373 mtype = argv[1];
374 mid = *(int *)argv[2];
a37b0b99 375
376 if (acl_access_check(lid, cl))
377 return MR_PERM;
378
5eaef520 379 /* if the member is not a direct member of the list, punt */
380 EXEC SQL SELECT COUNT(list_id) INTO :cnt FROM imembers
381 WHERE list_id = :lid AND member_id = :mid
382 AND member_type = :mtype AND direct = 1;
383 if (dbms_errno)
384 return mr_errcode;
385 if (cnt == 0)
386 return MR_NO_MATCH;
387 ancestors[0] = lid;
388 aref[0] = 1;
389 acount = 1;
390 EXEC SQL DECLARE csr105 CURSOR FOR
391 SELECT list_id, ref_count FROM imembers
392 WHERE member_id = :lid AND member_type = 'LIST';
393 if (dbms_errno)
394 return mr_errcode;
395 EXEC SQL OPEN csr105;
396 if (dbms_errno)
397 return mr_errcode;
398 while (1)
399 {
400 EXEC SQL FETCH csr105 INTO :id, :ref;
401 if (sqlca.sqlcode)
402 break;
403 aref[acount] = ref;
404 ancestors[acount++] = id;
405 if (acount >= MAXLISTDEPTH)
406 break;
b070f8a1 407 }
5eaef520 408 EXEC SQL CLOSE csr105;
409 if (dbms_errno)
410 return mr_errcode;
411 if (acount >= MAXLISTDEPTH)
412 return MR_INTERNAL;
413 descendants[0] = mid;
414 dtypes[0] = mtype;
415 dref[0] = 1;
416 dcount = 1;
417 error = 0;
418 if (!strcmp(mtype, "LIST"))
419 {
420 EXEC SQL DECLARE csr106 CURSOR FOR
421 SELECT member_id, member_type, ref_count FROM imembers
422 WHERE list_id = :mid;
423 if (dbms_errno)
424 return mr_errcode;
425 EXEC SQL OPEN csr106;
426 if (dbms_errno)
427 return mr_errcode;
428 while (1)
429 {
430 EXEC SQL FETCH csr106 INTO :id, :dtype, :ref;
431 if (sqlca.sqlcode)
432 break;
433 switch (dtype[0])
434 {
0659551f 435 case 'L':
5eaef520 436 dtypes[dcount] = "LIST";
437 break;
0659551f 438 case 'U':
5eaef520 439 dtypes[dcount] = "USER";
440 break;
0659551f 441 case 'S':
5eaef520 442 dtypes[dcount] = "STRING";
443 break;
0659551f 444 case 'K':
5eaef520 445 dtypes[dcount] = "KERBEROS";
446 break;
0659551f 447 default:
5eaef520 448 error++;
449 break;
0659551f 450 }
5eaef520 451 dref[dcount] = ref;
452 descendants[dcount++] = id;
453 if (dcount >= MAXLISTDEPTH)
454 break;
0659551f 455 }
5eaef520 456 EXEC SQL CLOSE csr106;
457 if (dbms_errno)
458 return mr_errcode;
459 if (error)
460 return MR_INTERNAL;
3beadd83 461 }
5eaef520 462 for (a = 0; a < acount; a++)
463 {
464 lid = ancestors[a];
465 for (d = 0; d < dcount; d++)
466 {
467 mid = descendants[d];
468 mtype = dtypes[d];
469 if (mid == lid && !strcmp(mtype, "LIST"))
470 return MR_LISTLOOP;
471 EXEC SQL SELECT ref_count INTO :cnt FROM imembers
472 WHERE list_id = :lid AND member_id = :mid AND member_type = :mtype;
473 ref = aref[a] * dref[d];
474 if (cnt <= ref)
475 {
476 iargv[0] = (char *)lid;
477 iargv[1] = mtype;
478 iargv[2] = (char *)mid;
479 incremental_before(IMEMBERS_TABLE, 0, iargv);
480 EXEC SQL DELETE FROM imembers
481 WHERE list_id = :lid AND member_id = :mid
482 AND member_type= :mtype;
483 incremental_clear_after();
0659551f 484 }
5eaef520 485 else if (a == 0 && d == 0)
486 {
487 EXEC SQL UPDATE imembers
488 SET ref_count = ref_count - :ref, direct = 0
489 WHERE list_id = :lid AND member_id = :mid
490 AND member_type = :mtype;
491 }
492 else
493 {
494 EXEC SQL UPDATE imembers
495 SET ref_count = ref_count - :ref
496 WHERE list_id = :lid AND member_id = :mid
497 AND member_type = :mtype;
0659551f 498 }
499 }
3beadd83 500 }
5eaef520 501 lid = *(int *)argv[0];
502 entity = cl->entity;
503 who = cl->client_id;
504 EXEC SQL UPDATE list SET modtime = SYSDATE, modby = :who, modwith = :entity
505 WHERE list_id = :lid;
506 if (dbms_errno)
507 return mr_errcode;
508 return MR_SUCCESS;
5d677c81 509}
b070f8a1 510
20541c25 511int tag_member_of_list(struct query *q, char **argv, client *cl)
512{
513 EXEC SQL BEGIN DECLARE SECTION;
514 int lid, mid, cnt, tag;
515 char *mtype;
516 EXEC SQL END DECLARE SECTION;
517 char *iargv[3];
518
519 lid = *(int *)argv[0];
520 mtype = argv[1];
521 mid = *(int *)argv[2];
522 tag = *(int *)argv[3];
523
524 EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
525 WHERE member_id = :mid AND member_type = :mtype AND
526 list_id = :lid;
527 if (dbms_errno)
528 return mr_errcode;
529 if (cnt == 0)
530 return MR_NO_MATCH;
531
532 incremental_clear_before();
533 EXEC SQL UPDATE imembers SET tag = :tag WHERE list_id = :lid
534 AND member_type = :mtype AND member_id = :mid;
535 if (dbms_errno)
536 return mr_errcode;
537
538 iargv[0] = (char *)lid;
539 iargv[1] = mtype;
540 iargv[2] = (char *)mid;
541 incremental_after(IMEMBERS_TABLE, 0, iargv);
542
543 return MR_SUCCESS;
544}
b070f8a1 545
7f6ea9fd 546/* Don't allow someone to add someone to a list which is the acl of a
547 * query unless they're on the list acl, even if they're on the amtl
548 * query acl! Also, don't allow someone proxying to add someone to a
549 * capacl.
550 */
a37b0b99 551int acl_access_check(int list_id, client *cl)
552{
553 EXEC SQL BEGIN DECLARE SECTION;
59c3208b 554 int c1, c2, lid = list_id, acl_id, memacl_id;
555 char acl_type[LIST_ACL_TYPE_SIZE], memacl_type[LIST_ACL_TYPE_SIZE];
a37b0b99 556 EXEC SQL END DECLARE SECTION;
557
558 /* Check if the list is directly a capacl */
559 EXEC SQL SELECT COUNT(list_id) INTO :c1 FROM capacls WHERE list_id=:lid;
560
561 /* Check if the list is a member (direct or indirect) of a list that
562 is a capacl */
563 EXEC SQL SELECT COUNT(l1.list_id) INTO :c2 FROM list l1, list l2,
564 imembers im, capacls c WHERE c.list_id = l2.list_id AND
565 im.list_id = l2.list_id AND im.member_type = 'LIST' AND
566 im.member_id = l1.list_id AND l1.list_id = :lid;
567
568 if (c1 == 0 && c2 == 0)
569 return 0;
570
7f6ea9fd 571 if (cl->proxy_id)
572 return 1;
573
59c3208b 574 EXEC SQL SELECT acl_type, acl_id, memacl_type, memacl_id
575 INTO :acl_type, :acl_id, :memacl_type, :memacl_id
a37b0b99 576 FROM list WHERE list_id=:lid;
59c3208b 577
578 if (!find_member(acl_type, acl_id, cl))
579 {
580 if (!find_member(memacl_type, memacl_id, cl))
581 return 1;
582 }
583
584 return 0;
a37b0b99 585}
586
587
0659551f 588/* get_ace_use - given a type and a name, return a type and a name.
589 * The ace_type is one of "LIST", "USER", "RLIST", or "RUSER" in argv[0],
590 * and argv[1] will contain the ID of the entity in question. The R*
591 * types mean to recursively look at every containing list, not just
592 * when the object in question is a direct member. On return, the
593 * usage type will be one of LIST, SERVICE, FILESYS, QUOTA, QUERY, or ZEPHYR.
b070f8a1 594 */
595
5eaef520 596int get_ace_use(struct query *q, char *argv[], client *cl,
7ac48069 597 int (*action)(int, char *[], void *), void *actarg)
5d677c81 598{
5eaef520 599 int found = 0;
600 EXEC SQL BEGIN DECLARE SECTION;
601 char *atype;
602 int aid, listid, id;
603 EXEC SQL END DECLARE SECTION;
7ac48069 604 struct save_queue *sq;
5eaef520 605
606 atype = argv[0];
607 aid = *(int *)argv[1];
608 if (!strcmp(atype, "LIST") || !strcmp(atype, "USER") ||
609 !strcmp(atype, "KERBEROS"))
610 return get_ace_internal(atype, aid, action, actarg);
611
612 sq = sq_create();
613 if (!strcmp(atype, "RLIST"))
614 {
7ac48069 615 sq_save_data(sq, (void *)aid);
5eaef520 616 /* get all the list_id's of containing lists */
617 EXEC SQL DECLARE csr107 CURSOR FOR
618 SELECT list_id FROM imembers
619 WHERE member_type = 'LIST' AND member_id = :aid;
620 if (dbms_errno)
621 return mr_errcode;
622 EXEC SQL OPEN csr107;
623 if (dbms_errno)
624 return mr_errcode;
625 while (1)
626 {
627 EXEC SQL FETCH csr107 INTO :listid;
628 if (sqlca.sqlcode)
629 break;
7ac48069 630 sq_save_unique_data(sq, (void *)listid);
0659551f 631 }
5eaef520 632 EXEC SQL CLOSE csr107;
633 /* now process each one */
634 while (sq_get_data(sq, &id))
635 {
636 if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
637 found++;
0659551f 638 }
639 }
b070f8a1 640
5eaef520 641 if (!strcmp(atype, "RUSER"))
642 {
643 EXEC SQL DECLARE csr108 CURSOR FOR
644 SELECT list_id FROM imembers
645 WHERE member_type = 'USER' AND member_id = :aid;
646 if (dbms_errno)
647 return mr_errcode;
648 EXEC SQL OPEN csr108;
649 if (dbms_errno)
650 return mr_errcode;
651 while (1)
652 {
653 EXEC SQL FETCH csr108 INTO :listid;
654 if (sqlca.sqlcode)
655 break;
7ac48069 656 sq_save_data(sq, (void *)listid);
0659551f 657 }
5eaef520 658 EXEC SQL CLOSE csr108;
659 /* now process each one */
660 while (sq_get_data(sq, &id))
661 {
662 if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
663 found++;
0659551f 664 }
5eaef520 665 if (get_ace_internal("USER", aid, action, actarg) == MR_SUCCESS)
666 found++;
0659551f 667 }
45bf7573 668
5eaef520 669 if (!strcmp(atype, "RKERBEROS"))
670 {
671 EXEC SQL DECLARE csr109 CURSOR FOR
672 SELECT list_id FROM imembers
673 WHERE member_type = 'KERBEROS' AND member_id = :aid;
674 if (dbms_errno)
675 return mr_errcode;
676 EXEC SQL OPEN csr109;
677 if (dbms_errno)
678 return mr_errcode;
679 while (1)
680 {
681 EXEC SQL FETCH csr109 INTO :listid;
682 if (sqlca.sqlcode)
683 break;
7ac48069 684 sq_save_data(sq, (void *)listid);
0659551f 685 }
5eaef520 686 EXEC SQL CLOSE csr109;
687 /* now process each one */
688 while (sq_get_data(sq, &id))
689 {
690 if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
691 found++;
0659551f 692 }
5eaef520 693 if (get_ace_internal("KERBEROS", aid, action, actarg) == MR_SUCCESS)
694 found++;
0659551f 695 }
b3ce33fe 696
5eaef520 697 sq_destroy(sq);
698 if (dbms_errno)
699 return mr_errcode;
700 if (!found)
701 return MR_NO_MATCH;
702 return MR_SUCCESS;
5d677c81 703}
b070f8a1 704
705
0659551f 706/* This looks up a single list or user for ace use. atype must be "USER"
707 * or "LIST", and aid is the ID of the corresponding object. This is used
708 * by get_ace_use above.
b070f8a1 709 */
710
7ac48069 711int get_ace_internal(char *atype, int aid,
712 int (*action)(int, char *[], void *), void *actarg)
5d677c81 713{
5eaef520 714 char *rargv[2];
715 int found = 0;
716 EXEC SQL BEGIN DECLARE SECTION;
d3051625 717 char name[MAX_FIELD_WIDTH], *type = atype;
5eaef520 718 int id = aid;
719 EXEC SQL END DECLARE SECTION;
720
721 rargv[1] = name;
722 if (!strcmp(atype, "LIST"))
723 {
724 rargv[0] = "FILESYS";
725 EXEC SQL DECLARE csr110 CURSOR FOR
726 SELECT label FROM filesys
727 WHERE owners = :id;
728 if (dbms_errno)
729 return mr_errcode;
730 EXEC SQL OPEN csr110;
731 if (dbms_errno)
732 return mr_errcode;
733 while (1)
734 {
735 EXEC SQL FETCH csr110 INTO :name;
736 if (sqlca.sqlcode)
737 break;
738 (*action)(2, rargv, actarg);
739 found++;
b070f8a1 740 }
5eaef520 741 EXEC SQL CLOSE csr110;
742
743 rargv[0] = "QUERY";
744 EXEC SQL DECLARE csr111 CURSOR FOR
745 SELECT capability FROM capacls
746 WHERE list_id = :id;
747 if (dbms_errno)
748 return mr_errcode;
749 EXEC SQL OPEN csr111;
750 if (dbms_errno)
751 return mr_errcode;
752 while (1)
753 {
754 EXEC SQL FETCH csr111 INTO :name;
755 if (sqlca.sqlcode)
756 break;
757 (*action)(2, rargv, actarg);
758 found++;
b070f8a1 759 }
5eaef520 760 EXEC SQL CLOSE csr111;
761 }
762 else if (!strcmp(atype, "USER"))
763 {
764 rargv[0] = "FILESYS";
765 EXEC SQL DECLARE csr112 CURSOR FOR
766 SELECT label FROM filesys
767 WHERE owner = :id;
768 if (dbms_errno)
769 return mr_errcode;
770 EXEC SQL OPEN csr112;
771 if (dbms_errno)
772 return mr_errcode;
773 while (1)
774 {
775 EXEC SQL FETCH csr112 INTO :name;
776 if (sqlca.sqlcode)
777 break;
778 (*action)(2, rargv, actarg);
779 found++;
b070f8a1 780 }
5eaef520 781 EXEC SQL CLOSE csr112;
b070f8a1 782 }
0fc7ab46 783
5eaef520 784 rargv[0] = "LIST";
785 EXEC SQL DECLARE csr113 CURSOR FOR
786 SELECT name FROM list
787 WHERE acl_type = :type AND acl_id = :id;
788 if (dbms_errno)
789 return mr_errcode;
790 EXEC SQL OPEN csr113;
791 if (dbms_errno)
792 return mr_errcode;
793 while (1)
794 {
795 EXEC SQL FETCH csr113 INTO :name;
796 if (sqlca.sqlcode)
797 break;
798 (*action)(2, rargv, actarg);
799 found++;
5d677c81 800 }
5eaef520 801 EXEC SQL CLOSE csr113;
802
803 rargv[0] = "SERVICE";
804 EXEC SQL DECLARE csr114 CURSOR FOR
805 SELECT name FROM servers
806 WHERE acl_type = :type AND acl_id = :id;
807 if (dbms_errno)
808 return mr_errcode;
809 EXEC SQL OPEN csr114;
810 if (dbms_errno)
811 return mr_errcode;
812 while (1)
813 {
814 EXEC SQL FETCH csr114 INTO :name;
815 if (sqlca.sqlcode)
816 break;
817 (*action)(2, rargv, actarg);
818 found++;
0fc7ab46 819 }
5eaef520 820 EXEC SQL CLOSE csr114;
b070f8a1 821
5eaef520 822 rargv[0] = "HOSTACCESS";
823 EXEC SQL DECLARE csr115 CURSOR FOR
824 SELECT name FROM machine m, hostaccess ha
825 WHERE m.mach_id = ha.mach_id AND ha.acl_type = :type
826 AND ha.acl_id = :id;
d3051625 827 if (dbms_errno)
828 return mr_errcode;
829 EXEC SQL OPEN csr115;
830 if (dbms_errno)
831 return mr_errcode;
832 while (1)
833 {
834 EXEC SQL FETCH csr115 INTO :name;
835 if (sqlca.sqlcode)
836 break;
837 (*action)(2, rargv, actarg);
838 found++;
839 }
840 EXEC SQL CLOSE csr115;
841
842 rargv[0] = "MACHINE";
843 EXEC SQL DECLARE csr115a CURSOR FOR
844 SELECT name FROM machine m
845 WHERE m.owner_type = :type
846 AND m.owner_id = :id;
847 if (dbms_errno)
848 return mr_errcode;
849 EXEC SQL OPEN csr115a;
850 if (dbms_errno)
851 return mr_errcode;
852 while (1)
853 {
854 EXEC SQL FETCH csr115a INTO :name;
855 if (sqlca.sqlcode)
856 break;
857 (*action)(2, rargv, actarg);
858 found++;
859 }
860 EXEC SQL CLOSE csr115a;
861
862 rargv[0] = "ZEPHYR";
863 EXEC SQL DECLARE csr116 CURSOR FOR
864 SELECT class FROM zephyr z
865 WHERE z.xmt_type = :type AND z.xmt_id = :id
866 OR z.sub_type = :type AND z.sub_id = :id
867 OR z.iws_type = :type AND z.iws_id = :id
868 OR z.iui_type = :type AND z.iui_id = :id;
869 if (dbms_errno)
870 return mr_errcode;
871 EXEC SQL OPEN csr116;
872 if (dbms_errno)
873 return mr_errcode;
874 while (1)
875 {
876 EXEC SQL FETCH csr116 INTO :name;
877 if (sqlca.sqlcode)
878 break;
879 (*action)(2, rargv, actarg);
880 found++;
881 }
882 EXEC SQL CLOSE csr116;
883
884 if (!found)
885 return MR_NO_MATCH;
886 return MR_SUCCESS;
887}
888
889/* ghbo_internal */
890int ghbo_internal(char *atype, int aid,
891 int (*action)(int, char *[], void *), void *actarg)
892{
893 char *rargv[1];
894 int found = 0;
895 EXEC SQL BEGIN DECLARE SECTION;
896 char name[MACHINE_NAME_SIZE], *type = atype;
897 int id = aid;
898 EXEC SQL END DECLARE SECTION;
899
900 rargv[0] = name;
901 EXEC SQL DECLARE csr115b CURSOR FOR
902 SELECT name FROM machine m
903 WHERE m.owner_type = :type
904 AND m.owner_id = :id;
905 if (dbms_errno)
906 return mr_errcode;
907 EXEC SQL OPEN csr115b;
908 if (dbms_errno)
909 return mr_errcode;
910 while (1)
911 {
912 EXEC SQL FETCH csr115b INTO :name;
913 if (sqlca.sqlcode)
914 break;
915 (*action)(1, rargv, actarg);
916 found++;
917 }
918 EXEC SQL CLOSE csr115b;
919
920 if (!found)
921 return MR_NO_MATCH;
922 return MR_SUCCESS;
923}
924
925/* get_host_by_owner - like gaus but limited to hosts */
926int get_host_by_owner(struct query *q, char *argv[], client *cl,
927 int (*action)(int, char *[], void *), void *actarg)
928{
929 int found = 0;
930 EXEC SQL BEGIN DECLARE SECTION;
931 char *atype;
932 int aid, listid, id;
933 EXEC SQL END DECLARE SECTION;
934 struct save_queue *sq;
935
936 atype = argv[0];
937 aid = *(int *)argv[1];
938 if (!strcmp(atype, "LIST") || !strcmp(atype, "USER") ||
939 !strcmp(atype, "KERBEROS"))
940 return ghbo_internal(atype, aid, action, actarg);
941
942 sq = sq_create();
943 if (!strcmp(atype, "RLIST"))
944 {
945 sq_save_data(sq, (void *)aid);
946 /* get all the list_id's of containing lists */
947 EXEC SQL DECLARE csr107q CURSOR FOR
948 SELECT list_id FROM imembers
949 WHERE member_type = 'LIST' AND member_id = :aid;
950 if (dbms_errno)
951 return mr_errcode;
952 EXEC SQL OPEN csr107q;
953 if (dbms_errno)
954 return mr_errcode;
955 while (1)
956 {
957 EXEC SQL FETCH csr107q INTO :listid;
958 if (sqlca.sqlcode)
959 break;
960 sq_save_unique_data(sq, (void *)listid);
961 }
962 EXEC SQL CLOSE csr107q;
963 /* now process each one */
964 while (sq_get_data(sq, &id))
965 {
966 if (ghbo_internal("LIST", id, action, actarg) == MR_SUCCESS)
967 found++;
968 }
969 }
970
971 if (!strcmp(atype, "RUSER"))
972 {
973 EXEC SQL DECLARE csr108q CURSOR FOR
974 SELECT list_id FROM imembers
975 WHERE member_type = 'USER' AND member_id = :aid;
976 if (dbms_errno)
5eaef520 977 return mr_errcode;
d3051625 978 EXEC SQL OPEN csr108q;
979 if (dbms_errno)
5eaef520 980 return mr_errcode;
d3051625 981 while (1)
982 {
983 EXEC SQL FETCH csr108q INTO :listid;
984 if (sqlca.sqlcode)
985 break;
986 sq_save_data(sq, (void *)listid);
987 }
988 EXEC SQL CLOSE csr108q;
989 /* now process each one */
990 while (sq_get_data(sq, &id))
991 {
992 if (ghbo_internal("LIST", id, action, actarg) == MR_SUCCESS)
993 found++;
994 }
995 if (ghbo_internal("USER", aid, action, actarg) == MR_SUCCESS)
0659551f 996 found++;
d3051625 997 }
998
999 if (!strcmp(atype, "RKERBEROS"))
1000 {
1001 EXEC SQL DECLARE csr109q CURSOR FOR
1002 SELECT list_id FROM imembers
1003 WHERE member_type = 'KERBEROS' AND member_id = :aid;
1004 if (dbms_errno)
1005 return mr_errcode;
1006 EXEC SQL OPEN csr109q;
1007 if (dbms_errno)
1008 return mr_errcode;
1009 while (1)
1010 {
1011 EXEC SQL FETCH csr109q INTO :listid;
1012 if (sqlca.sqlcode)
1013 break;
1014 sq_save_data(sq, (void *)listid);
1015 }
1016 EXEC SQL CLOSE csr109q;
1017 /* now process each one */
1018 while (sq_get_data(sq, &id))
1019 {
1020 if (ghbo_internal("LIST", id, action, actarg) == MR_SUCCESS)
1021 found++;
1022 }
1023 if (ghbo_internal("KERBEROS", aid, action, actarg) == MR_SUCCESS)
0659551f 1024 found++;
d3051625 1025 }
b070f8a1 1026
d3051625 1027 sq_destroy(sq);
1028 if (dbms_errno)
1029 return mr_errcode;
1030 if (!found)
1031 return MR_NO_MATCH;
1032 return MR_SUCCESS;
5d677c81 1033}
b070f8a1 1034
0659551f 1035/* get_lists_of_member - given a type and a name, return the name and flags
1036 * of all of the lists of the given member. The member_type is one of
1037 * "LIST", "USER", "STRING", "RLIST", "RUSER", or "RSTRING" in argv[0],
1038 * and argv[1] will contain the ID of the entity in question. The R*
1039 * types mean to recursively look at every containing list, not just
1040 * when the object in question is a direct member.
1041 */
b070f8a1 1042
5eaef520 1043int get_lists_of_member(struct query *q, char *argv[], client *cl,
7ac48069 1044 int (*action)(int, char *[], void *), void *actarg)
0659551f 1045{
5eaef520 1046 int found = 0, direct = 1;
1047 char *rargv[6];
1048 EXEC SQL BEGIN DECLARE SECTION;
1049 char *atype;
1050 int aid;
e688520a 1051 char name[LIST_NAME_SIZE];
1052 char active[5], public[5], hidden[5], maillist[5], grouplist[5];
5eaef520 1053 EXEC SQL END DECLARE SECTION;
1054
1055 atype = argv[0];
1056 aid = *(int *)argv[1];
1057 if (!strcmp(atype, "RLIST"))
1058 {
1059 atype = "LIST";
1060 direct = 0;
0659551f 1061 }
5eaef520 1062 if (!strcmp(atype, "RUSER"))
1063 {
1064 atype = "USER";
1065 direct = 0;
0659551f 1066 }
5eaef520 1067 if (!strcmp(atype, "RSTRING"))
1068 {
1069 atype = "STRING";
1070 direct = 0;
0659551f 1071 }
5eaef520 1072 if (!strcmp(atype, "RKERBEROS"))
1073 {
1074 atype = "KERBEROS";
1075 direct = 0;
0659551f 1076 }
b070f8a1 1077
5eaef520 1078 rargv[0] = name;
1079 rargv[1] = active;
1080 rargv[2] = public;
1081 rargv[3] = hidden;
1082 rargv[4] = maillist;
1083 rargv[5] = grouplist;
1084 if (direct)
1085 {
1086 EXEC SQL DECLARE csr117a CURSOR FOR
1087 SELECT l.name, l.active, l.publicflg, l.hidden, l.maillist, l.grouplist
1088 FROM list l, imembers im
1089 WHERE l.list_id = im.list_id AND im.direct = 1
1090 AND im.member_type = :atype AND im.member_id = :aid;
1091 if (dbms_errno)
1092 return mr_errcode;
1093 EXEC SQL OPEN csr117a;
1094 if (dbms_errno)
1095 return mr_errcode;
1096 while (1)
1097 {
1098 EXEC SQL FETCH csr117a
1099 INTO :name, :active, :public, :hidden, :maillist, :grouplist;
1100 if (sqlca.sqlcode)
1101 break;
1102 (*action)(6, rargv, actarg);
1103 found++;
0659551f 1104 }
5eaef520 1105 EXEC SQL CLOSE csr117a;
1106 }
1107 else
1108 {
1109 EXEC SQL DECLARE csr117b CURSOR FOR
1110 SELECT l.name, l.active, l.publicflg, l.hidden, l.maillist, l.grouplist
1111 FROM list l, imembers im
1112 WHERE l.list_id = im.list_id
1113 AND im.member_type = :atype AND im.member_id = :aid;
1114 if (dbms_errno)
1115 return mr_errcode;
1116 EXEC SQL OPEN csr117b;
1117 if (dbms_errno)
1118 return mr_errcode;
1119 while (1)
1120 {
1121 EXEC SQL FETCH csr117b
1122 INTO :name, :active, :public, :hidden, :maillist, :grouplist;
1123 if (sqlca.sqlcode)
1124 break;
1125 (*action)(6, rargv, actarg);
1126 found++;
0659551f 1127 }
5eaef520 1128 EXEC SQL CLOSE csr117b;
038fd8a4 1129 }
0659551f 1130
5eaef520 1131 if (dbms_errno)
1132 return mr_errcode;
1133 if (!found)
1134 return MR_NO_MATCH;
1135 return MR_SUCCESS;
038fd8a4 1136}
1137
b070f8a1 1138
0659551f 1139/* qualified_get_lists: passed "TRUE", "FALSE", or "DONTCARE" for each of
1140 * the five flags associated with each list. It will return the name of
1141 * each list that meets the quailifications. It does this by building a
1142 * where clause based on the arguments, then doing a retrieve.
1143 */
1144
1145static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "grouplist" };
b070f8a1 1146
5eaef520 1147int qualified_get_lists(struct query *q, char *argv[], client *cl,
7ac48069 1148 int (*action)(int, char *[], void *), void *actarg)
5d677c81 1149{
5eaef520 1150 return qualified_get(q, argv, action, actarg, "l.list_id != 0",
1151 "l", "name", lflags);
0659551f 1152}
0fc7ab46 1153
5d677c81 1154
5eaef520 1155int get_members_of_list(struct query *q, char *argv[], client *cl,
7ac48069 1156 int (*action)(int, char *[], void *), void *actarg)
0659551f 1157{
5eaef520 1158 EXEC SQL BEGIN DECLARE SECTION;
7ac48069 1159 int list_id, direct;
46b6f1f6 1160 char member_name[MAX_FIELD_WIDTH], tag[STRINGS_STRING_SIZE];
5eaef520 1161 EXEC SQL END DECLARE SECTION;
46b6f1f6 1162 char *targv[3];
1163 int targc;
5eaef520 1164
46b6f1f6 1165 /* For gmol or gtml, only get direct members. For geml, get all. */
1166 if (!strcmp(q->shortname, "geml"))
1167 direct = -1;
1168 else
5eaef520 1169 direct = 0;
46b6f1f6 1170
1171 /* For gmol or geml, only return type and name. For gtml, return tag too. */
1172 if (!strcmp(q->shortname, "gtml"))
1173 targc = 3;
5eaef520 1174 else
46b6f1f6 1175 targc = 2;
5eaef520 1176
1177 list_id = *(int *)argv[0];
1178
1179 targv[1] = member_name;
46b6f1f6 1180 targv[2] = tag;
1181
5eaef520 1182 targv[0] = "USER";
1183 EXEC SQL DECLARE csr119 CURSOR FOR
46b6f1f6 1184 SELECT u.login, s.string FROM users u, imembers im, strings s
5eaef520 1185 WHERE im.list_id = :list_id AND im.member_type = 'USER'
1186 AND im.member_id = u.users_id AND im.direct > :direct
46b6f1f6 1187 AND s.string_id = im.tag ORDER BY 1;
5eaef520 1188 if (dbms_errno)
1189 return mr_errcode;
1190 EXEC SQL OPEN csr119;
1191 if (dbms_errno)
1192 return mr_errcode;
1193 while (1)
1194 {
46b6f1f6 1195 EXEC SQL FETCH csr119 INTO :member_name, :tag;
5eaef520 1196 if (sqlca.sqlcode)
1197 break;
46b6f1f6 1198 (*action)(targc, targv, actarg);
b070f8a1 1199 }
5eaef520 1200 EXEC SQL CLOSE csr119;
1201 if (dbms_errno)
1202 return mr_errcode;
1203
1204 targv[0] = "LIST";
1205 EXEC SQL DECLARE csr120 CURSOR FOR
46b6f1f6 1206 SELECT l.name, s.string FROM list l, imembers im, strings s
5eaef520 1207 WHERE im.list_id = :list_id AND im.member_type = 'LIST'
1208 AND im.member_id = l.list_id AND im.direct > :direct
46b6f1f6 1209 AND s.string_id = im.tag ORDER BY 1;
5eaef520 1210 if (dbms_errno)
1211 return mr_errcode;
1212 EXEC SQL OPEN csr120;
1213 if (dbms_errno)
1214 return mr_errcode;
1215 while (1)
1216 {
46b6f1f6 1217 EXEC SQL FETCH csr120 INTO :member_name, :tag;
5eaef520 1218 if (sqlca.sqlcode)
1219 break;
46b6f1f6 1220 (*action)(targc, targv, actarg);
b070f8a1 1221 }
5eaef520 1222 EXEC SQL CLOSE csr120;
1223 if (dbms_errno)
1224 return mr_errcode;
1225
1226 targv[0] = "STRING";
1227 EXEC SQL DECLARE csr121 CURSOR FOR
46b6f1f6 1228 SELECT str.string, s.string FROM strings str, imembers im, strings s
5eaef520 1229 WHERE im.list_id = :list_id AND im.member_type = 'STRING'
1230 AND im.member_id = str.string_id AND im.direct > :direct
46b6f1f6 1231 AND s.string_id = im.tag ORDER BY 1;
5eaef520 1232 if (dbms_errno)
1233 return mr_errcode;
1234 EXEC SQL OPEN csr121;
1235 if (dbms_errno)
1236 return mr_errcode;
1237 while (1)
1238 {
46b6f1f6 1239 EXEC SQL FETCH csr121 INTO :member_name, :tag;
5eaef520 1240 if (sqlca.sqlcode)
1241 break;
46b6f1f6 1242 (*action)(targc, targv, actarg);
b070f8a1 1243 }
5eaef520 1244 EXEC SQL CLOSE csr121;
1245 if (dbms_errno)
1246 return mr_errcode;
1247
1248 targv[0] = "KERBEROS";
1249 EXEC SQL DECLARE csr122 CURSOR FOR
46b6f1f6 1250 SELECT str.string, s.string FROM strings str, imembers im, strings s
5eaef520 1251 WHERE im.list_id = :list_id AND im.member_type = 'KERBEROS'
46b6f1f6 1252 AND im.member_id = str.string_id AND im.direct > :direct
1253 AND s.string_id = im.tag ORDER BY 1;
5eaef520 1254 if (dbms_errno)
1255 return mr_errcode;
1256 EXEC SQL OPEN csr122;
1257 if (dbms_errno)
1258 return mr_errcode;
1259 while (1)
1260 {
46b6f1f6 1261 EXEC SQL FETCH csr122 INTO :member_name, :tag;
5eaef520 1262 if (sqlca.sqlcode)
1263 break;
46b6f1f6 1264 (*action)(targc, targv, actarg);
0659551f 1265 }
5eaef520 1266 EXEC SQL CLOSE csr122;
1267 if (dbms_errno)
1268 return mr_errcode;
b070f8a1 1269
5eaef520 1270 return MR_SUCCESS;
5d677c81 1271}
b070f8a1 1272
1273
0659551f 1274/* count_members_of_list: this is a simple query, but it cannot be done
1275 * through the dispatch table.
1276 */
b070f8a1 1277
5eaef520 1278int count_members_of_list(struct query *q, char *argv[], client *cl,
7ac48069 1279 int (*action)(int, char *[], void *), void *actarg)
5d677c81 1280{
5eaef520 1281 EXEC SQL BEGIN DECLARE SECTION;
1282 int list, ct = 0;
1283 EXEC SQL END DECLARE SECTION;
1284 char *rargv[1], countbuf[5];
1285
1286 list = *(int *)argv[0];
1287 rargv[0] = countbuf;
1288 EXEC SQL SELECT count (*) INTO :ct FROM imembers
1289 WHERE list_id = :list AND direct = 1;
1290 if (dbms_errno)
1291 return mr_errcode;
1292 sprintf(countbuf, "%d", ct);
1293 (*action)(1, rargv, actarg);
1294 return MR_SUCCESS;
5d677c81 1295}
b070f8a1 1296
b070f8a1 1297
0659551f 1298/* qualified_get_server: passed "TRUE", "FALSE", or "DONTCARE" for each of
1299 * the three flags associated with each service. It will return the name of
1300 * each service that meets the quailifications. It does this by building a
1301 * where clause based on the arguments, then doing a retrieve.
1302 */
b070f8a1 1303
0659551f 1304static char *sflags[3] = { "enable", "inprogress", "harderror" };
b070f8a1 1305
5eaef520 1306int qualified_get_server(struct query *q, char *argv[], client *cl,
7ac48069 1307 int (*action)(int, char *[], void *), void *actarg)
5d677c81 1308{
5eaef520 1309 return qualified_get(q, argv, action, actarg, "s.name is not null",
1310 "s", "name", sflags);
1311 /* of course, name will never be null, but we need something there
1312 to make qualified_get happy */
5d677c81 1313}
b070f8a1 1314
1315
0659551f 1316/* generic qualified get routine, used by qualified_get_lists,
1317 * qualified_get_server, and qualified_get_serverhost.
1318 * Args:
1319 * start - a simple where clause, must not be empty
1320 * range - the name of the range variable
1321 * field - the field to return
1322 * flags - an array of strings, names of the flag variables
b070f8a1 1323 */
1324
7ac48069 1325int qualified_get(struct query *q, char *argv[],
1326 int (*action)(int, char *[], void *), void *actarg,
5eaef520 1327 char *start, char *range, char *field, char *flags[])
453b99fe 1328{
5eaef520 1329 char qual[256];
1330 int i;
1331 char buf[32];
1332
1333 strcpy(qual, start);
1334 for (i = 0; i < q->argc; i++)
1335 {
1336 if (!strcmp(argv[i], "TRUE"))
1337 {
1338 sprintf(buf, " AND %s.%s != 0", range, flags[i]);
1339 strcat(qual, buf);
1340 }
1341 else if (!strcmp(argv[i], "FALSE"))
1342 {
1343 sprintf(buf, " AND %s.%s = 0", range, flags[i]);
1344 strcat(qual, buf);
0659551f 1345 }
453b99fe 1346 }
1347
5eaef520 1348 sprintf(stmt_buf, "SELECT %s.%s FROM %s %s WHERE %s", range, field,
1349 table_name[q->rtable], range, qual);
1350 return do_for_all_rows(stmt_buf, 1, action, actarg);
453b99fe 1351}
1352
1353
0659551f 1354/* qualified_get_serverhost: passed "TRUE", "FALSE", or "DONTCARE" for each of
1355 * the five flags associated with each serverhost. It will return the name of
1356 * each service and host that meets the quailifications. It does this by
1357 * building a where clause based on the arguments, then doing a retrieve.
45bf7573 1358 */
45bf7573 1359
0659551f 1360static char *shflags[6] = { "service", "enable", "override", "success",
1361 "inprogress", "hosterror" };
45bf7573 1362
5eaef520 1363int qualified_get_serverhost(struct query *q, char *argv[], client *cl,
7ac48069 1364 int (*action)(int, char *[], void *),
1365 void *actarg)
45bf7573 1366{
5eaef520 1367 char qual[256], buf[32];
1368 int i;
1369
1370 sprintf(qual, "m.mach_id = sh.mach_id AND sh.service = UPPER('%s')",
1371 argv[0]);
1372 for (i = 1; i < q->argc; i++)
1373 {
1374 if (!strcmp(argv[i], "TRUE"))
1375 {
1376 sprintf(buf, " AND sh.%s != 0", shflags[i]);
1377 strcat(qual, buf);
1378 }
1379 else if (!strcmp(argv[i], "FALSE"))
1380 {
1381 sprintf(buf, " AND sh.%s = 0", shflags[i]);
1382 strcat(qual, buf);
0659551f 1383 }
1384 }
45bf7573 1385
5eaef520 1386 sprintf(stmt_buf, "SELECT sh.service, m.name FROM serverhosts sh, "
1387 "machine m WHERE %s", qual);
1388 return do_for_all_rows(stmt_buf, 2, action, actarg);
45bf7573 1389}
1390
0659551f 1391
1392/* register_user - change user's login name and allocate a pobox, group,
1393 * filesystem, and quota for them. The user's status must start out as 0,
b4bfb4d1 1394 * and is left as 2. Arguments are: user's UID, new login name, and
edf666a5 1395 * pobox type ("POP" = POP, "IMAP" or numeric = IMAP)
99e09b48 1396 */
0659551f 1397
5eaef520 1398int register_user(struct query *q, char **argv, client *cl)
99e09b48 1399{
5eaef520 1400 EXEC SQL BEGIN DECLARE SECTION;
e688520a 1401 char *login, *entity;
1402 char directory[FILESYS_NAME_SIZE], machname[MACHINE_NAME_SIZE];
b4bfb4d1 1403 char dir[NFSPHYS_DIR_SIZE], *potype;
1404 int who, rowcount, mid, uid, users_id;
1405 int ostatus, nstatus, fsidval, popid;
1406 int npid, tmp;
edf666a5 1407 int po_exists = 0;
b4bfb4d1 1408 static int m_id, def_quota, def_imap_quota, list_id;
5eaef520 1409 EXEC SQL END DECLARE SECTION;
1410 char buffer[256], *aargv[3];
1411
b4bfb4d1 1412 if (!m_id)
1413 {
1414 EXEC SQL SELECT list_id INTO :list_id FROM list
1415 WHERE name = 'wheel';
1416
1417 EXEC SQL SELECT mach_id INTO :m_id FROM machine
1418 WHERE name = 'ATHENA.MIT.EDU';
1419
1420 EXEC SQL SELECT value INTO :def_quota FROM numvalues
1421 WHERE name = 'def_quota';
1422 if (sqlca.sqlerrd[2] != 1)
1423 return MR_NO_QUOTA;
1424
1425 EXEC SQL SELECT value INTO :def_imap_quota FROM numvalues
1426 WHERE name = 'def_imap_quota';
1427 if (sqlca.sqlerrd[2] != 1)
1428 return MR_NO_QUOTA;
1429 }
1430
5eaef520 1431 entity = cl->entity;
1432 who = cl->client_id;
1433
1434 uid = atoi(argv[0]);
1435 login = argv[1];
b4bfb4d1 1436 potype = argv[2];
5eaef520 1437
1438 /* find user */
1439 EXEC SQL SELECT users_id, status INTO :users_id, :ostatus
1440 FROM users
1441 WHERE unix_uid = :uid AND (status = 0 OR status = 5 OR status = 6);
1442
1443 if (sqlca.sqlerrd[2] == 0)
1444 return MR_NO_MATCH;
1445 if (sqlca.sqlerrd[2] > 1)
1446 return MR_NOT_UNIQUE;
1447
1448 /* check new login name */
1449 EXEC SQL SELECT COUNT(login) INTO :rowcount FROM users
1450 WHERE login = :login AND users_id != :users_id;
1451 if (dbms_errno)
1452 return mr_errcode;
1453 if (rowcount > 0)
1454 return MR_IN_USE;
1455 EXEC SQL SELECT COUNT(name) INTO :rowcount FROM list
ec0b8003 1456 WHERE LOWER(name) = :login;
5eaef520 1457 if (dbms_errno)
1458 return mr_errcode;
1459 if (rowcount > 0)
1460 return MR_IN_USE;
1461 EXEC SQL SELECT COUNT(label) INTO :rowcount FROM filesys
edf666a5 1462 WHERE label = :login;
5eaef520 1463 if (dbms_errno)
1464 return mr_errcode;
1465 if (rowcount > 0)
1466 return MR_IN_USE;
edf666a5 1467 EXEC SQL SELECT COUNT(label) INTO :rowcount
1468 FROM filesys WHERE label = :login || '.po';
1469 if (dbms_errno)
1470 return mr_errcode;
1471 if (rowcount > 0)
1472 {
1473 EXEC SQL SELECT owner INTO :tmp FROM filesys
1474 WHERE label = :login || '.po';
1475 if (dbms_errno)
1476 return mr_errcode;
1477 if ((ostatus == 0) || (tmp != users_id))
1478 return MR_IN_USE;
1479 EXEC SQL SELECT count(potype) INTO :rowcount FROM users WHERE
1480 login = :login AND potype = 'IMAP';
1481 if (dbms_errno)
1482 return mr_errcode;
1483 if (rowcount > 0)
1484 po_exists = 1;
1485 }
5eaef520 1486 EXEC SQL SELECT COUNT(name) INTO :rowcount FROM alias
b4bfb4d1 1487 WHERE ( name = :login OR name = :login || '.po' )
1488 AND type = 'FILESYS';
5eaef520 1489 if (dbms_errno)
1490 return mr_errcode;
1491 if (rowcount > 0)
1492 return MR_IN_USE;
1493 com_err(whoami, 0, "login name OK");
1494
edf666a5 1495 EXEC SQL SELECT COUNT(potype) INTO :rowcount FROM users WHERE
1496 login = :login AND potype = 'POP';
1497 if (dbms_errno)
1498 return mr_errcode;
1499 if (rowcount > 0)
1500 po_exists = 1;
1501
b4bfb4d1 1502 /* choose type and location for pobox */
edf666a5 1503 if (!po_exists)
5eaef520 1504 {
edf666a5 1505 if (!strcmp(potype, "POP"))
b4bfb4d1 1506 {
edf666a5 1507
1508 EXEC SQL DECLARE csr130 CURSOR FOR
1509 SELECT sh.mach_id, m.name FROM serverhosts sh, machine m
1510 WHERE sh.service = 'POP' AND sh.mach_id = m.mach_id
1511 AND sh.value2 - sh.value1 =
1512 (SELECT MAX(value2 - value1) FROM serverhosts WHERE service = 'POP');
b4bfb4d1 1513 if (dbms_errno)
1514 return mr_errcode;
edf666a5 1515 EXEC SQL OPEN csr130;
1516 if (dbms_errno)
1517 return mr_errcode;
1518 EXEC SQL FETCH csr130 INTO :popid, :machname;
1519 if (sqlca.sqlerrd[2] == 0)
1520 {
1521 EXEC SQL CLOSE csr130;
1522 if (dbms_errno)
1523 return mr_errcode;
1524 return MR_NO_POBOX;
1525 }
1526 else
1527 {
1528 EXEC SQL CLOSE csr130;
1529 if (dbms_errno)
1530 return mr_errcode;
1531 }
1532
1533 EXEC SQL UPDATE users SET potype = 'POP', pop_id = :popid
1534 WHERE users_id = :users_id;
1535 com_err(whoami, 0, "pobox set to POP:%s", strtrim(machname));
1536 }
b4bfb4d1 1537 else
1538 {
edf666a5 1539 /* Select all IMAP nfsphys entries in order of increasing
1540 * (allocated - partsize). The partitions will almost always be
1541 * overallocated, but we choose the one that is the least
1542 * overallocated.
1543 */
1544 potype = "IMAP";
1545
1546 EXEC SQL DECLARE csr_rusr_imap CURSOR FOR
1547 SELECT np.allocated - np.partsize, np.nfsphys_id, np.mach_id,
1548 np.dir, m.name FROM serverhosts sh, nfsphys np, machine m
1549 WHERE sh.service = 'POSTOFFICE' AND sh.mach_id = np.mach_id
1550 AND m.mach_id = np.mach_id
1551 ORDER BY 1;
b4bfb4d1 1552 if (dbms_errno)
1553 return mr_errcode;
edf666a5 1554 EXEC SQL OPEN csr_rusr_imap;
1555 if (dbms_errno)
1556 return mr_errcode;
1557 EXEC SQL FETCH csr_rusr_imap INTO :tmp, :npid, :mid, :dir, :machname;
1558 if (sqlca.sqlerrd[2] == 0)
1559 {
1560 EXEC SQL CLOSE csr_rusr_imap;
1561 if (dbms_errno)
1562 return mr_errcode;
1563 return MR_NO_POBOX;
1564 }
1565 else
1566 {
1567 EXEC SQL CLOSE csr_rusr_imap;
1568 if (dbms_errno)
1569 return mr_errcode;
1570 }
b4bfb4d1 1571
edf666a5 1572 /* create filesystem */
1573 if (set_next_object_id("filsys_id", FILESYS_TABLE, 0))
1574 return MR_NO_ID;
1575 incremental_clear_before();
1576
1577 EXEC SQL SELECT value INTO :popid FROM numvalues
1578 WHERE numvalues.name = 'filsys_id';
1579 EXEC SQL INSERT INTO filesys
1580 (filsys_id, phys_id, label, type, mach_id, name,
1581 mount, rwaccess, comments, owner, owners, createflg,
1582 lockertype, modtime, modby, modwith)
1583 VALUES
1584 (:popid, :npid, :login || '.po', 'IMAP', :mid, :dir,
1585 CHR(0), 'w', 'IMAP box', :users_id, :list_id, 1,
9f3ee749 1586 'USER', SYSDATE, :who, :entity);
b4bfb4d1 1587
b4bfb4d1 1588 if (dbms_errno)
1589 return mr_errcode;
edf666a5 1590 if (sqlca.sqlerrd[2] != 1)
1591 return MR_INTERNAL;
1592 sprintf(buffer, "fs.filsys_id = %d", popid);
1593 incremental_after(FILESYS_TABLE, buffer, 0);
1594
1595 /* set quota */
1596 incremental_clear_before();
1597 EXEC SQL INSERT INTO quota
1598 (entity_id, filsys_id, type, quota, phys_id, modtime, modby, modwith)
1599 VALUES (:users_id, :popid, 'USER', :def_imap_quota, :npid,
1600 SYSDATE, :who, :entity);
1601 if (dbms_errno)
1602 return mr_errcode;
1603 if (sqlca.sqlerrd[2] != 1)
1604 return MR_INTERNAL;
1605 aargv[0] = login;
1606 aargv[1] = "USER";
1607 aargv[2] = login;
1608 sprintf(buffer, "q.entity_id = %d and q.filsys_id = %d and "
1609 "q.type = 'USER'", users_id, popid);
1610 incremental_after(QUOTA_TABLE, buffer, aargv);
b4bfb4d1 1611 if (dbms_errno)
1612 return mr_errcode;
99e09b48 1613
edf666a5 1614 EXEC SQL UPDATE nfsphys SET allocated = allocated + :def_imap_quota
1615 WHERE nfsphys_id = :npid;
1616
1617 EXEC SQL UPDATE users SET potype = 'IMAP', imap_id = :popid
1618 WHERE users_id = :users_id;
1619 com_err(whoami, 0, "pobox set to IMAP:%s:%s", strtrim(machname),
1620 strtrim(dir));
1621 }
b4bfb4d1 1622 }
1623
5eaef520 1624 /* change login name, set pobox */
1625 sprintf(buffer, "u.users_id = %d", users_id);
1626 incremental_before(USERS_TABLE, buffer, 0);
1627 nstatus = 2;
1628 if (ostatus == 5 || ostatus == 6)
1629 nstatus = 1;
1630 EXEC SQL UPDATE users SET login = :login, status = :nstatus,
b4bfb4d1 1631 modtime = SYSDATE, modby = :who, modwith = :entity,
1632 pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity
5eaef520 1633 WHERE users_id = :users_id;
1634
1635 if (dbms_errno)
1636 return mr_errcode;
1637 if (sqlca.sqlerrd[2] != 1)
1638 return MR_INTERNAL;
edf666a5 1639
1640 /* Only update usage count if we created a POP pobox. */
1641 if (!strcmp(potype, "POP") && !po_exists)
1642 set_pop_usage(mid, 1);
1643
b4bfb4d1 1644 com_err(whoami, 0, "set login name to %s", login);
5eaef520 1645 incremental_after(USERS_TABLE, buffer, 0);
1646
2f52e762 1647 /* We've just changed the login name in the DB; recache it in case
1648 the wrong thing got into the cache earlier. */
1649 cache_entry(login, USERS_TABLE, users_id);
1650
5eaef520 1651 /* create filesystem */
1652 if (set_next_object_id("filsys_id", FILESYS_TABLE, 0))
1653 return MR_NO_ID;
1654 incremental_clear_before();
1655 if (islower(login[0]) && islower(login[1]))
1656 {
1657 sprintf(directory, "/afs/athena.mit.edu/user/%c/%c/%s",
1658 login[0], login[1], login);
0659551f 1659 }
5eaef520 1660 else
1661 sprintf(directory, "/afs/athena.mit.edu/user/other/%s", login);
1662
1663 EXEC SQL SELECT value INTO :fsidval FROM numvalues
1664 WHERE numvalues.name = 'filsys_id';
1665 EXEC SQL INSERT INTO filesys
1666 (filsys_id, phys_id, label, type, mach_id, name,
1667 mount, rwaccess, comments, owner, owners, createflg,
1668 lockertype, modtime, modby, modwith)
1669 VALUES
1670 (:fsidval, 0, :login, 'AFS', :m_id, :directory,
1671 '/mit/' || :login, 'w', 'User Locker', :users_id, :list_id, 1,
1672 'HOMEDIR', SYSDATE, :who, :entity);
1673
1674 if (dbms_errno)
1675 return mr_errcode;
1676 if (sqlca.sqlerrd[2] != 1)
1677 return MR_INTERNAL;
1678 sprintf(buffer, "fs.filsys_id = %d", fsidval);
1679 incremental_after(FILESYS_TABLE, buffer, 0);
1680
1681 /* set quota */
5eaef520 1682 incremental_clear_before();
1683 EXEC SQL INSERT INTO quota
1684 (entity_id, filsys_id, type, quota, phys_id, modtime, modby, modwith)
1685 VALUES (0, :fsidval, 'ANY', :def_quota, 0, SYSDATE, :who, :entity);
1686 if (dbms_errno)
1687 return mr_errcode;
1688 if (sqlca.sqlerrd[2] != 1)
1689 return MR_INTERNAL;
1690 aargv[0] = login;
1691 aargv[1] = "ANY";
1692 aargv[2] = login;
1693 sprintf(buffer, "q.entity_id = 0 and q.filsys_id = %d and q.type = 'ANY'",
1694 fsidval);
1695 incremental_after(QUOTA_TABLE, buffer, aargv);
1696 com_err(whoami, 0, "quota of %d assigned", def_quota);
1697 if (dbms_errno)
1698 return mr_errcode;
1699
5eaef520 1700 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
1701 WHERE table_name = 'users';
1702 EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
1703 WHERE table_name = 'filesys' OR table_name = 'quota';
1704 if (dbms_errno)
1705 return mr_errcode;
1706 return MR_SUCCESS;
3afb5524 1707}
1708
0659551f 1709/** set_pop_usage - incr/decr usage count for pop server in serverhosts talbe
1710 **
1711 ** Inputs:
1712 ** id of machine
1713 ** delta (will be +/- 1)
1714 **
1715 ** Description:
1716 ** - incr/decr value field in serverhosts table for pop/mach_id
1717 **
1718 **/
1719
1720int set_pop_usage(id, cnt)
03c05291 1721 int id, cnt;
0659551f 1722{
5eaef520 1723 EXEC SQL BEGIN DECLARE SECTION;
1724 int iid = id, icnt = cnt;
1725 EXEC SQL END DECLARE SECTION;
03c05291 1726
5eaef520 1727 EXEC SQL UPDATE serverhosts SET value1 = value1 + :icnt
1728 WHERE serverhosts.service = 'POP' AND serverhosts.mach_id = :iid;
835aabee 1729
5eaef520 1730 if (dbms_errno)
1731 return mr_errcode;
1732 return MR_SUCCESS;
835aabee 1733}
1734
77eb4bdf 1735
1736int do_user_reservation(struct query *q, char *argv[], client *cl)
1737{
1738 EXEC SQL BEGIN DECLARE SECTION;
1739 char resv[USERS_RESERVATIONS_SIZE];
1740 char *trans, name[ALIAS_NAME_SIZE];
1741 int uid;
1742 EXEC SQL END DECLARE SECTION;
1743
1744 uid = *(int *)argv[0];
1745 trans = argv[1];
1746
1747 EXEC SQL SELECT UPPER(name) INTO :name FROM alias
1748 WHERE type = 'RESERVE' AND LOWER(trans) = LOWER(:trans);
1749 if (dbms_errno)
1750 return mr_errcode;
1751 if (sqlca.sqlerrd[2] != 1)
1752 return MR_STRING;
1753 name[1] = '\0';
1754
1755 EXEC SQL SELECT reservations INTO :resv FROM users
1756 WHERE users_id = :uid;
1757 if (dbms_errno)
1758 return mr_errcode;
1759 strtrim(resv);
1760
1761 if (!strcmp(q->shortname, "aurv"))
1762 {
1763 if (strchr(resv, *name))
1764 return MR_EXISTS;
1765 if (strlen(resv) == USERS_RESERVATIONS_SIZE - 1)
1766 return MR_ARG_TOO_LONG;
1767
1768 strcat(resv, name);
1769 }
1770 else
1771 {
1772 char *p = strchr(resv, *name);
1773 if (!p)
1774 return MR_NO_MATCH;
1775 memmove(p, p + 1, strlen(p));
1776 }
1777
1778 EXEC SQL UPDATE users SET reservations = NVL(:resv, CHR(0))
1779 WHERE users_id = :uid;
1780 if (dbms_errno)
1781 return mr_errcode;
1782
1783 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
1784 WHERE table_name = 'users';
1785 return set_modtime_by_id(q, argv, cl);
1786}
1787
1788int get_user_reservations(struct query *q, char **argv, client *cl,
1789 int (*action)(int, char *[], void *), void *actarg)
1790{
1791 EXEC SQL BEGIN DECLARE SECTION;
1792 char resv[USERS_RESERVATIONS_SIZE], *p;
1793 char trans[ALIAS_TRANS_SIZE], name[2] = { 0, 0 };
1794 int uid;
1795 EXEC SQL END DECLARE SECTION;
1796 char *targv[1];
1797
1798 uid = *(int *)argv[0];
1799
1800 EXEC SQL SELECT reservations INTO :resv FROM users
1801 WHERE users_id = :uid;
1802 if (dbms_errno)
1803 return mr_errcode;
1804
1805 targv[0] = trans;
1806 p = resv;
1807 while (*p && !isspace(*p))
1808 {
1809 name[0] = toupper(*p);
1810 EXEC SQL SELECT trans INTO :trans FROM alias
1811 WHERE type = 'RESERVE' AND UPPER(name) = :name;
1812 if (dbms_errno)
1813 return mr_errcode;
1814 if (sqlca.sqlerrd[2] != 1)
1815 sprintf(trans, "Unknown (%s)", name);
1816 (*action)(1, targv, actarg);
1817 p++;
1818 }
1819 return MR_SUCCESS;
1820}
1821
1822int get_user_by_reservation(struct query *q, char **argv, client *cl,
1823 int (*action)(int, char *[], void *), void *actarg)
1824{
1825 EXEC SQL BEGIN DECLARE SECTION;
1826 char resv[USERS_RESERVATIONS_SIZE], login[USERS_LOGIN_SIZE];
1827 char *trans, name[ALIAS_NAME_SIZE];
1828 int uid;
1829 EXEC SQL END DECLARE SECTION;
1830 char *targv[1];
1831
1832 trans = argv[0];
1833
1834 EXEC SQL SELECT UPPER(name) INTO :name FROM alias
1835 WHERE type = 'RESERVE' AND LOWER(trans) = LOWER(:trans);
1836 if (dbms_errno)
1837 return mr_errcode;
1838 if (sqlca.sqlerrd[2] != 1)
1839 return MR_STRING;
1840 name[1] = '\0';
1841
1842 EXEC SQL DECLARE csr_gubr CURSOR FOR
1843 SELECT login FROM users WHERE reservations LIKE '%' || :name || '%';
1844 EXEC SQL OPEN csr_gubr;
1845 if (dbms_errno)
1846 return mr_errcode;
1847
1848 targv[0] = login;
1849 while (1)
1850 {
1851 EXEC SQL FETCH csr_gubr INTO :login;
1852 if (sqlca.sqlcode)
1853 break;
1854 (*action)(1, targv, actarg);
1855 }
1856 EXEC SQL CLOSE csr_gubr;
1857
1858 return MR_SUCCESS;
1859}
This page took 0.402537 seconds and 5 git commands to generate.