|
|
1.1 root 1: /* calls.c - */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/others/quipu/uips/sd/RCS/calls.c,v 7.2 90/07/27 08:45:41 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/others/quipu/uips/sd/RCS/calls.c,v 7.2 90/07/27 08:45:41 mrose Exp $
9: */
10:
11: /*
12: * $Log: calls.c,v $
13: * Revision 7.2 90/07/27 08:45:41 mrose
14: * update
15: *
16: * Revision 7.1 90/07/09 14:41:49 mrose
17: * sync
18: *
19: * Revision 7.0 90/06/12 13:14:03 mrose
20: * *** empty log message ***
21: *
22: * Revision 1.6 90/04/26 10:36:16 emsrdsm
23: * *** empty log message ***
24: *
25: * Revision 1.5 90/04/25 15:07:22 emsrdsm
26: * i) lint'ed
27: *
28: * Revision 1.4 90/04/20 17:57:33 emsrdsm
29: * i) no more freeing
30: *
31: * Revision 1.3 90/04/18 18:26:06 emsrdsm
32: * fixed i) does not move to leaves
33: * ii) added default mechanism described using "typeDefaults" file.
34: * iii) added 'sorting' to attribute display
35: *
36: * Revision 1.2 90/03/15 16:29:40 emsrdsm
37: * fixes i) Prints messages correctly on exit.
38: * ii) Added rfc822 to greybook mailbox conversion
39: * iii) Removed bug that caused crash if 'local_dit' undefined
40: *
41: * Revision 1.1 90/03/09 17:40:20 emsrdsm
42: * Initial revision
43: *
44: * Revision 1.1 90/03/09 13:36:22 emsrdsm
45: * Initial revision
46: *
47: */
48:
49: #include "manifest.h"
50: #include "quipu/util.h"
51: #include "quipu/common.h"
52: #include "quipu/entry.h"
53: #include "usr.dirent.h"
54: #include "tailor.h"
55: #include "sequence.h"
56: #include "filt.h"
57: #include "y.tab.h"
58: #include "symtab.h"
59:
60: #define RESBUF 10000
61:
62: struct attrcomp * sort_attrs();
63: static dn2str ();
64:
65: typedef enum {rfc822, greybook} mailtype;
66: mailtype mailformat = rfc822;
67:
68: int scrollize;
69: PS opt;
70: Attr_Sequence read_types = 0, read_types2 = 0, oclass = 0;
71:
72: D_seq dnseq, textseq, back_seq;
73: table_entry symtab = 0;
74:
75: int current_entry, entry_number, display_entry;
76: int back_buf_num;
77:
78: int dn_print (), rdn_print(), as_print(), avs_comp_print();
79:
80: char bound = FALSE; /* indication of wether bound */
81: char * TidyString();
82:
83: /* hack to get isode/curses compatability */
84: #define WINDOW char
85:
86: #include "widget.h"
87: #include "wdgtdefs.h"
88:
89: extern text_height;
90: int text_state;
91:
92: #define DN_LIST 0
93: #define TEXT 1
94: #define BACK_LIST 3
95:
96: /* These are common operation variables */
97: #define STRINGLEN 1000
98: #define SMALLSTRING 255
99: #define MAXTYPES 255
100:
101: char goto_path[STRINGLEN]; /* Used by the 'G:goto' command*/
102: char base_path[STRINGLEN]; /* Used by all DS operations */
103: char friendly_base_path[STRINGLEN];
104: char friendly_name[STRINGLEN];
105: char namestr[STRINGLEN];
106: char cache [STRINGLEN];
107: char bindpass [STRINGLEN];
108: char srchvalue[STRINGLEN]; /* Used by search */
109: char svalue [STRINGLEN];
110: char mvalue [STRINGLEN];
111:
112: unsigned int curr_filt = 0;
113: unsigned int filt_num = 0;
114: unsigned int typeindx = 0;
115: filt_struct *filt_arr[MAXTYPES];
116: char *filtvalue[MAXTYPES];
117: static char *filttype[MAXTYPES];
118:
119: int default_num;
120: int *av_typeindx;
121: int *available_types[MAXTYPES];
122: char *levels[MAXTYPES];
123: int defaults[MAXTYPES];
124:
125: #ifndef NO_STATS
126: extern LLog *log_stat;
127: #endif
128:
129: /* These are used as the data for the binding connection */
130: char passwd[STRINGLEN];
131: extern char currentpath[];
132: extern char * myname;
133:
134: extern int sizelimit;
135: extern char *local_dit;
136: DN user_name;
137:
138: char * addobj = NULLCP;
139:
140: Filter search_filter;
141:
142: FILE *file;
143: char *file_names[MAXTYPES];
144:
145: char *get_strioid(ptr)
146: register char *ptr;
147: {
148: register char *end_ptr;
149:
150: while(*ptr == '"') ptr++;
151: while(*ptr != '"') ptr++;
152:
153: while(*ptr > '9' || *ptr < '0') ptr++;
154:
155: end_ptr = ptr;
156: while(*end_ptr != '\n') end_ptr++;
157:
158: *end_ptr = '\0';
159: return ptr;
160: }
161:
162:
163: user_tailor ()
164: {
165: char *part1;
166: char *part2;
167: char *getenv ();
168: char *ptr = "/.quipurc";
169: char *config_dir = "/.duaconfig/";
170: char *isode_config_dir = "sd/duaconfig/";
171: char *type_dir = "filterTypes/";
172: char *read_File = "readTypes";
173: char *type_defaults = "typeDefaults";
174:
175: char Dish_Home[BUFSIZ];
176: char read_Home[BUFSIZ];
177: char type_Home[BUFSIZ];
178: char type_defaults_Home[BUFSIZ];
179:
180: char stroid_buf[BUFSIZ];
181:
182: DIR *dir;
183:
184: struct dirent *dir_ent;
185:
186: char Read_in_Stuff[STRINGLEN];
187: char *p,
188: *TidyString(),
189: *SkipSpace(),
190: *end;
191:
192: int count, n, num;
193: int tempints[MAXTYPES];
194:
195: #ifndef NO_STATS
196: ll_hdinit (log_stat,"sd");
197: #endif
198:
199: if ((opt = ps_alloc (std_open)) == NULLPS)
200: fatal (-1,"ps_alloc failed");
201: if (std_setup (opt,stdout) == NOTOK)
202: fatal (-1,"std_setup failed");
203:
204: namestr[0] = '\0';
205: *passwd = '\0';
206: cache[0] = '\0';
207: currentpath[0] = '\0';
208:
209: (void) strcpy (Dish_Home, getenv ("HOME"));
210: (void) strcpy(read_Home, Dish_Home);
211: (void) strcpy(type_Home, Dish_Home);
212: (void) strcpy(type_defaults_Home, Dish_Home);
213:
214: (void) strcat(Dish_Home, ptr);
215: (void) strcat(read_Home, config_dir);
216: (void) strcat(read_Home, read_File);
217: (void) strcat(type_Home, config_dir);
218: (void) strcat(type_Home, type_dir);
219: (void) strcat(type_defaults_Home, type_defaults);
220:
221: if (!(dir = opendir(type_Home))) {
222: (void) strcpy(type_Home, isodefile(isode_config_dir,0));
223: (void) strcat(type_Home, type_dir);
224: if(!(dir = opendir(type_Home))) {
225: quit("Can't find directory filterTypes.\n", 1);
226: }
227: }
228:
229: rewinddir(dir);
230: filt_num = 0;
231: while(dir_ent = readdir(dir)) {
232: if (!(strncmp(dir_ent->d_name, "Type_", 5))) {
233: file_names[filt_num] =
234: (char *) malloc(strlen(dir_ent->d_name) + strlen(type_Home) + 2);
235: (void) strcpy(file_names[filt_num], type_Home);
236: (void) strcat(file_names[filt_num], dir_ent->d_name);
237: filt_num++;
238: }
239: }
240: (void) closedir(dir);
241:
242: if ((file = fopen (Dish_Home, "r")) == 0);
243: else {
244: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) {
245: p = SkipSpace (Read_in_Stuff);
246: if (( *p == '#') || (*p == '\0'))
247: continue; /* ignore comments and blanks */
248:
249: part1 = p;
250: if ((part2 = index (p,':')) == NULLCP)
251: continue; /* ignore it */
252:
253: *part2++ = '\0';
254: part2 = TidyString(part2);
255:
256: if (strcmp (part1, "username") == 0)
257: (void) strcpy (namestr, part2);
258: else if (strcmp (part1, "password") == 0)
259: (void) strcpy (passwd, part2);
260: else if (strcmp(part1, "prefergreybook") == 0)
261: mailformat = greybook;
262: else if (lexequ (part1, "dsap") == 0)
263: (void) tai_string (part2);
264: else if (lexequ (part1, "isode") == 0) {
265: char * split;
266: if ((split = index (part2,' ')) != NULLCP) {
267: *split++ = 0;
268: (void) isodesetvar (part2,split,0);
269: }
270: } else if (strcmp (part1, "service") == 0)
271: new_service (part2);
272: }
273: isodexport (NULLCP);
274: (void) fclose(file);
275: }
276:
277: if (!(file = fopen(read_Home, "r"))) {
278: (void) strcpy(read_Home, isodefile(isode_config_dir,0));
279: (void) strcat(read_Home, read_File);
280: if (!(file = fopen(read_Home, "r"))) {
281: quit("Can't find file readTypes.\n", 1);
282: }
283: }
284: load_oid_table("oidtable");
285:
286: while(fgets(Read_in_Stuff, STRINGLEN, file) != 0) {
287: (void) strcpy(stroid_buf, get_strioid(Read_in_Stuff));
288: if (*stroid_buf) {
289: if (!read_types)
290: read_types = as_comp_new(AttrT_new(stroid_buf), NULLAV, NULLACL_INFO);
291: else {
292: read_types2 = as_comp_new(AttrT_new(stroid_buf) ,NULLAV, NULLACL_INFO);
293: read_types = as_merge(read_types, read_types2);
294: }
295: }
296: }
297: (void) fclose(file);
298:
299: for (curr_filt = 0; curr_filt < filt_num; curr_filt++) {
300: if (!(file = fopen(file_names[curr_filt], "r"))) {
301: quit("Can't find filter template file\n", 1);
302: }
303: filtvalue[curr_filt] = (char *) malloc(STRINGLEN);
304: *filtvalue[curr_filt] = '\0';
305:
306: (void) yyparse();
307: (void) fclose(file);
308: }
309: filttype[curr_filt] = NULLCP;
310: for (count = 0; count < filt_num; count++)
311: free(file_names[count]);
312:
313: if (!(file = fopen(type_defaults_Home, "r"))) {
314: (void) strcpy(type_defaults_Home, isodefile(isode_config_dir,0));
315: (void) strcat(type_defaults_Home, type_defaults);
316: if (!(file = fopen(type_defaults_Home, "r"))) {
317: (void) strcpy(type_defaults_Home, "./sd/duaconfig/");
318: (void) strcat(type_defaults_Home, type_defaults);
319: if (!(file = fopen(type_defaults_Home, "r"))) {
320: (void) fprintf(stderr, "Can't open typeDefaults file\n");
321: quit(1);
322: }
323: }
324: }
325:
326: default_num = 0;
327: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) {
328: p = SkipSpace(Read_in_Stuff);
329: if (( *p == '#') || (*p == '\0'))
330: continue;
331:
332: part1 = p;
333: if ((part2 = index (p,':')) == NULLCP)
334: continue;
335:
336: end = part2 - 1;
337: while (isspace(*end)) end--;
338: *++end = '\0';
339:
340: *part2++ = '\0';
341:
342: while (isspace(*part2)) part2++;
343: end = part2;
344:
345: while (!isspace(*end) && *end != ',' && *end != ':') end++;
346:
347: count = 0;
348: while (*part2 != ':') {
349: n = 0;
350: while (n < filt_num && strncmp(filttype[n], part2,
351: (int) (end - part2))) n++;
352:
353: if (n == filt_num) {
354: (void) fprintf(stderr, "Parsing error in typeDefaults file!");
355: quit(1);
356: } else {
357: tempints[count] = n;
358: count++;
359: part2 = end;
360: while (!isalpha(*part2) && *part2 != ':' && part2 != '\0') part2++;
361:
362: if (*part2 == '\0') {
363: (void) fprintf(stderr, "Parsing error in typeDefaults file!");
364: quit(1);
365: }
366:
367: if (*part2 != ':') {
368: while (!isalpha(*part2)) part2++;
369: end = part2;
370: while (!isspace(*end) && *end != ',' &&
371: *end != ':' && *end != '\0') end++;
372: if (*end == '\0') {
373: (void) fprintf(stderr, "Parsing error in typeDefaults file!");
374: quit(1);
375: }
376: } else end = part2;
377: }
378: }
379: if (*end == ':') {
380: while(isspace(*++end));
381: p = end;
382: while(!isspace(*++end));
383: *end = '\0';
384:
385: n = 0;
386: while (n < filt_num && strcmp(filttype[n], p)) n++;
387:
388: if (n == filt_num) {
389: (void) fprintf(stderr, "Parsing error in typeDefaults file!");
390: quit(1);
391: } else {
392: num = 0;
393: while (num < count && n != tempints[num]) num++;
394: if (num == count) {
395: (void) fprintf(stderr, "Parsing error in typeDefaults file!");
396: quit(1);
397: }
398: }
399:
400: defaults[default_num] = n;
401:
402: levels[default_num] = malloc(strlen(part1) + 1);
403: (void) strcpy(levels[default_num], part1);
404: available_types[default_num] =
405: (int *) malloc(sizeof(int) * (count+1));
406:
407: for (n = 0; n < count; n++)
408: available_types[default_num][n] = tempints[n];
409:
410: available_types[default_num][n] = -1;
411: default_num++;
412: }
413: }
414: }
415:
416: make_type(name_val, filt)
417: char * name_val;
418: filt_struct * filt;
419: {
420: filttype[curr_filt] = (char *) malloc(strlen(name_val) + 1);
421: (void) strcpy(filttype[curr_filt], name_val);
422:
423: filt_arr[curr_filt] = filt;
424: }
425:
426: filt_struct *
427: make_item_filter(oid, match, value)
428: char *oid;
429: int match;
430: char *value;
431: {
432: register filt_struct * filt = (filt_struct *) malloc(sizeof(filt_struct));
433:
434: filt->flt_type = ITEM;
435: filt->next = 0;
436:
437: filt->fu_cont.item.fi_type = match;
438: filt->fu_cont.item.stroid = (char *) malloc(strlen(oid) + 1);
439: (void) strcpy(filt->fu_cont.item.stroid, oid);
440:
441: if (*value == '*') filt->fu_cont.item.name = (char *) 0;
442: else {
443: filt->fu_cont.item.name = (char *) malloc(strlen(value) + 1);
444: (void) strcpy(filt->fu_cont.item.name, value);
445: }
446: return filt;
447: }
448:
449: filt_struct *
450: link_filters(filt1, filt2)
451: filt_struct *filt1;
452: filt_struct *filt2;
453: {
454: filt1->next = filt2;
455: return filt1;
456: }
457:
458: filt_struct *
459: make_parent_filter(filt_type, filt1, filt2, filt3)
460: int filt_type;
461: filt_struct * filt1;
462: filt_struct * filt2;
463: filt_struct * filt3;
464: {
465: filt_struct * parent = (filt_struct *) malloc(sizeof(filt_struct));
466:
467: switch (filt_type) {
468:
469: case NOT:
470: parent->flt_type = NOT;
471: parent->fu_cont.sub_filt = filt1;
472: parent->next = 0;
473: break;
474:
475: case AND:
476: parent->flt_type = AND;
477: parent->fu_cont.sub_filt = filt1;
478: filt1->next = filt2;
479: filt2->next = filt3;
480: parent->next = 0;
481: break;
482:
483: default:
484: parent->flt_type = OR;
485: parent->fu_cont.sub_filt = filt1;
486: filt1->next = filt2;
487: filt2->next = filt3;
488: parent->next = 0;
489: break;
490: }
491:
492: return parent;
493: }
494:
495: /* These are the functions called by the main level of widgets */
496:
497: main_help()
498: {
499: cleartext();
500: killwidgets(mainwdgts);
501: setwidgets(dethelpwdgts,-1);
502: help_cncs();
503: }
504:
505: main_bind()
506: {
507: cleartext();
508: if (*passwd != 0)
509: (void) strcpy(bindpass,"******");
510: else
511: bindpass[0] = '\0';
512: }
513:
514: cnnct_quit ()
515: {
516: quit("Exiting sd.\n", 0);
517: }
518:
519: cnnct_bind()
520: {
521: struct ds_bind_arg bindarg;
522: struct ds_bind_arg bindresult;
523: struct ds_bind_error binderr;
524: extern char * dsa_address,
525: * myname;
526: extern char * tailfile;
527: FILE * fp;
528: char buf [BUFSIZ];
529:
530: /* set dsa_address */
531: dsa_address = NULLCP;
532: /* read tailor file to get address */
533: if( (fp = fopen(isodefile(tailfile,0), "r")) == (FILE *)NULL) {
534: tprint ("Cannot open tailor file %s\n",isodefile(tailfile,0));
535: return;
536: }
537: while(fgets(buf, sizeof(buf), fp) != NULLCP)
538: if ( (*buf != '#') && (*buf != '\n') )
539: (void) tai_string(buf);
540:
541: (void) fclose(fp);
542:
543: if (dsa_address == NULLCP)
544: dsa_address = myname;
545:
546: /* set password */
547: if (bindpass[0] != 0) {
548: if (strcmp (bindpass,"******") != 0)
549: (void) strcpy (passwd,bindpass);
550: } else
551: passwd[0] = 0;
552:
553: /* now bind */
554: bindarg.dba_version = DBA_VERSION_V1988;
555: if (passwd[0] == 0) {
556: bindarg.dba_passwd_len = 0;
557: bindarg.dba_passwd [0] = '\0';
558: } else {
559: bindarg.dba_passwd_len = strlen (passwd);
560: (void) strcpy (bindarg.dba_passwd,passwd);
561: }
562:
563: bindarg.dba_dn = (*namestr == 0? NULLDN: str2dn(namestr));
564:
565: if (ds_bind (&bindarg,&binderr,&bindresult) != DS_OK) {
566: if (binderr.dbe_type == DBE_TYPE_SECURITY)
567: quit("Bind security error - Check name and pasword.\n", 0);
568: else
569: quit("Bind service error - Can't contact DSA!\n", 1);
570: } else {
571: setdialogstr(getwidget(mainwdgts, '\0'), friendly_base_path, STRINGLEN);
572: setdialogstr(getwidget(mainwdgts, 's'), mvalue, STRINGLEN);
573: setdialogstr(getwidget(mainwdgts, '*'), srchvalue, 6);
574: settogglstrs(getwidget(mainwdgts, 't'), filttype, 0);
575: setwidgets (mainwdgts,-1);
576: user_name = bindarg.dba_dn;
577:
578: if(local_dit && *local_dit)
579: (void) strcpy(base_path, local_dit);
580: else
581: (void) strcpy(base_path, "The World");
582:
583: oclass = as_comp_new(AttrT_new("objectClass"), NULLAV, NULLACL_INFO);
584: make_friendly(friendly_base_path, base_path);
585: printdialog(getwidget(mainwdgts,'\0'));
586: set_default_type();
587:
588: (void) strcpy (buf, "TERM");
589:
590: #ifndef NO_STATS
591: LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address));
592: #endif
593: #ifndef NO_STATS
594: LLOG (log_stat,LLOG_NOTICE,("sd called from a ('%s')", getenv(buf)));
595: #endif
596: }
597: display_entry = current_entry = 1;
598: entry_number = 0;
599: back_buf_num = 0;
600: textseq = back_seq = dnseq = NULLDS;
601: text_state = TEXT;
602: }
603:
604: rd_start()
605: {
606: struct ds_read_arg read_arg;
607: struct ds_read_result result;
608: struct DSError error;
609: Entry read_entry;
610:
611: cleartext();
612: if (*friendly_base_path == 'T') {
613: free_seq(textseq);
614: if (text_state == DN_LIST) free_seq(dnseq);
615: dnseq = textseq = NULLDS;
616: text_state = TEXT;
617: entry_number = 0;
618: return;
619: }
620:
621: xprint("Reading data on ");
622: xprint(friendly_base_path);
623: xprint(".\n");
624: tprint("Chugging along.....");
625:
626: if ( get_default_service (&read_arg.rda_common) != 0) {
627: xprint ("Default service error -> check your .quipurc\n");
628: return ;
629: }
630:
631: read_arg.rda_common.ca_servicecontrol.svc_options = 1;
632: read_arg.rda_eis.eis_allattributes = FALSE;
633: read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
634: read_arg.rda_eis.eis_select = read_types;
635:
636: read_arg.rda_object = (*friendly_base_path != 'T'? str2dn(base_path): NULLDN);
637: if ((read_entry =
638: local_find_entry (read_arg.rda_object, FALSE)) != NULLENTRY) {
639: read_entry->e_attributes = sort_attrs(read_entry->e_attributes);
640: read_print (as_print, (caddr_t) read_entry->e_attributes);
641: return;
642: }
643:
644: #ifndef NO_STATS
645: LLOG (log_stat,LLOG_NOTICE,("read +%s",base_path));
646: #endif
647:
648: if (ds_read (&read_arg,&error,&result) != DS_OK) {
649: /* deal with error */
650: cleartext();
651: xprint("Read error due to:\n");
652: quipu_error(&error);
653: } else {
654: /* use data */
655: if (result.rdr_entry.ent_attr == NULLATTR) {
656: free_seq(textseq);
657: if (text_state == DN_LIST) free_seq(dnseq);
658: dnseq = textseq = NULLDS;
659: entry_number = 0;
660: text_state = TEXT;
661: xprint("No attributes");
662: return;
663: }
664: xprint("Result of look up ...\n");
665: if (result.rdr_common.cr_aliasdereferenced)
666: xprint("Alias dereferenced)\n");
667:
668: result.rdr_entry.ent_attr = sort_attrs(result.rdr_entry.ent_attr);
669: cache_entry(&(result.rdr_entry), TRUE, TRUE);
670: read_print(as_print, (caddr_t) result.rdr_entry.ent_attr);
671: }
672: }
673:
674: back_start()
675: {
676: if (!back_buf_num) {
677: cleartext();
678: tprint("You haven't been anywhere yet!\n");
679: sleep(3);
680: scrollbar('\0');
681: return;
682: }
683:
684: if (text_state == DN_LIST) free_seq(dnseq);
685:
686: free_seq(textseq);
687: textseq = NULLDS;
688: dnseq = back_seq;
689: text_state = BACK_LIST;
690: entry_number = back_buf_num;
691: current_entry = display_entry = 1;
692: scrollbar('\0');
693: }
694:
695: widen()
696: {
697: register char *str, *sptr;
698: int count = 0;
699:
700: str = get_from_seq(count+1, back_seq);
701: while (count < back_buf_num && strcmp(str, base_path)){
702: count++;
703: str = get_from_seq(count+1, back_seq);
704: }
705: if (count == back_buf_num) {
706: add_seq(&back_seq, base_path);
707: back_buf_num++;
708: }
709:
710: str = base_path;
711: if (*str != 'T') {
712:
713: for (sptr = str; *sptr != '\0'; sptr++)
714: if (*sptr == '@') str = sptr;
715:
716: sptr = str;
717: typetoggled = 0;
718:
719: if (str != base_path) {
720: if (*--sptr == ' ')
721: str = sptr;
722: *str = '\0';
723: } else
724: (void) strcpy(base_path, "The World");
725:
726: make_friendly(friendly_base_path, base_path);
727: set_default_type();
728: printdialog(getwidget(mainwdgts, '\0'));
729: rd_start();
730: }
731: }
732:
733: set_default_type()
734: {
735: int count, lastindx;
736: WIDGET *wdgt, *vwdgt;
737: DN base_name;
738:
739: wdgt = getwidget(mainwdgts,'t');
740: vwdgt = getwidget(mainwdgts, 's');
741:
742: if (av_typeindx)
743: lastindx = wdgt->tindx;
744: else
745: lastindx = 0;
746:
747: if (*base_path != 'T') {
748: if (!typetoggled) {
749: base_name = str2dn(base_path);
750: while (base_name->dn_parent) base_name = base_name->dn_parent;
751: for (count = 0; count < default_num &&
752: strcmp(levels[count] ,base_name->dn_rdn->rdn_at->
753: oa_ot.ot_stroid);
754: count++);
755:
756: if (count < default_num) {
757: av_typeindx = available_types[count];
758: typeindx = defaults[count];
759: } else {
760: av_typeindx = available_types[0];
761: typeindx = defaults[0];
762: }
763: count = typeindx;
764:
765: if (count < filt_num) {
766: if (lastindx)
767: (void) strcpy(filtvalue[lastindx], vwdgt->dstr);
768: wdgt->tindx = count;
769: (void) strcpy(vwdgt->dstr, filtvalue[wdgt->tindx]);
770: }
771: }
772: } else {
773: for(count = 0; count < default_num && strcmp(levels[count], "@"); count++);
774: if (count < default_num) {
775: av_typeindx = available_types[count];
776: typeindx = defaults[count];
777: } else {
778: av_typeindx = available_types[0];
779: typeindx = defaults[0];
780: }
781: count = typeindx;
782: if (count < filt_num) {
783: if (lastindx)
784: (void) strcpy(filtvalue[lastindx], vwdgt->dstr);
785: wdgt->tindx = count;
786: (void) strcpy(vwdgt->dstr, filtvalue[wdgt->tindx]);
787: }
788: }
789:
790: make_friendly(friendly_base_path, base_path);
791: typetoggled = 0;
792: printtoggle(wdgt);
793: printdialog(vwdgt);
794: }
795:
796: /* These are the functions called by the list level widgets */
797:
798: list_start()
799: {
800: struct ds_search_arg search_arg;
801: struct ds_search_result result;
802: struct DSError error;
803:
804: cleartext();
805: xprint("OK, listing.\n");
806: tprint("Chugging along.....");
807:
808: if (get_default_service (&search_arg.sra_common) != 0) {
809: xprint ("Default service error -> check your .quipurc\n");
810: return ;
811: }
812:
813: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit;
814: search_arg.sra_common.ca_servicecontrol.svc_options = 1;
815: search_arg.sra_baseobject = (*base_path != 'T'?
816: str2dn (base_path):
817: NULLDN);
818: search_arg.sra_eis.eis_allattributes = FALSE;
819: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
820: search_arg.sra_eis.eis_select = read_types;
821: search_arg.sra_subset = SRA_ONELEVEL;
822:
823: search_arg.sra_filter = filter_alloc();
824: search_arg.sra_filter->flt_type = FILTER_NOT;
825: search_arg.sra_filter->flt_next = NULLFILTER;
826: search_arg.sra_filter->flt_un.flt_un_filter = filter_alloc();
827: search_arg.sra_filter->flt_un.flt_un_filter->flt_type = FILTER_ITEM;
828: search_arg.sra_filter->flt_un.flt_un_filter->flt_next = NULLFILTER;
829: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_type
830: = FILTERITEM_EQUALITY;
831:
832: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un.
833: fi_un_ava.ava_type = AttrT_new("2.5.4.0");
834:
835: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un.
836: fi_un_ava.ava_value =
837: str2AttrV("dsa", search_arg.sra_filter->flt_un.flt_un_filter->
838: flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->
839: oa_syntax);
840:
841: if (search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.
842: fi_un.fi_un_ava.ava_value == NULLAttrV) {
843: cleartext();
844: xprint("No can do. Sorry!");
845: } else if (ds_search (&search_arg,&error,&result) != DS_OK) {
846: /* deal with error */
847: free_seq(textseq);
848: if (text_state == DN_LIST) free_seq(dnseq);
849: dnseq = textseq = NULLDS;
850: text_state = TEXT;
851: entry_number = 0;
852: cleartext();
853: xprint("Search error due to:\n");
854: quipu_error(&error);
855: } else {
856: cleartext();
857: correlate_search_results (&result);
858: if (result.CSR_entries != NULLENTRYINFO) {
859: register EntryInfo *ptr;
860:
861: xprint ("Result of search ...\n");
862: if (result.CSR_common.cr_aliasdereferenced) {
863: xprint ("(Alias dereferenced - object is ");
864: quipu_print (dn_print, (caddr_t) result.CSR_object);
865: dn_free (result.CSR_object);
866: xprint (")\n");
867: }
868:
869: if (text_state == DN_LIST) free_seq(dnseq);
870: free_seq(textseq);
871: dnseq = textseq = NULLDS;
872: display_entry = current_entry = 1;
873: entry_number = 0;
874: text_state = DN_LIST;
875:
876: for (ptr = result.CSR_entries; ptr != NULLENTRYINFO;
877: ptr = ptr->ent_next) {
878: entry_number++;
879: dn2str ((caddr_t)ptr->ent_dn, goto_path);
880: add_seq (&dnseq, goto_path);
881: cache_entry (ptr,TRUE,TRUE);
882: }
883: scrollbar('\0');
884: } else if (result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) {
885: free_seq(textseq);
886: if (text_state == DN_LIST) free_seq(dnseq);
887: dnseq = textseq = NULLDS;
888: entry_number = 0;
889: text_state = TEXT;
890: xprint("Nothing found");
891: }
892:
893: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) {
894: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) {
895: free_seq(textseq);
896: if (text_state == DN_LIST) free_seq(dnseq);
897: dnseq = textseq = NULLDS;
898: entry_number = 0;
899: text_state = TEXT;
900: xprint("(Time limit exceeded)");
901: } else
902: xprint("(Size limit exceeded)");
903: }
904:
905: entryinfo_free(result.CSR_entries, 0);
906: }
907:
908: filter_free(search_arg.sra_filter);
909: }
910:
911: rdn2str(ptr,cptr)
912: caddr_t ptr;
913: char * cptr;
914: {
915: PS ps;
916: char buffer [RESBUF];
917:
918: if ((ps = ps_alloc(str_open)) == NULLPS) {
919: return ;
920: }
921: if (str_setup(ps, buffer, RESBUF, 1) == NOTOK) {
922: return ;
923: }
924: rdn_print(ps, (RDN) ptr, READOUT);
925:
926: ps_free(ps);
927: *ps->ps_ptr = 0;
928:
929: (void) strcpy(cptr, buffer);
930: }
931:
932:
933: /* search ... */
934:
935: Filter
936: make_filter(filt)
937: filt_struct *filt;
938: {
939: int type, count;
940: char *value;
941: Filter rfilt, sfilt = filter_alloc();
942:
943: if (!filt)
944: return (Filter) 0;
945:
946: switch(filt->flt_type) {
947:
948: case ITEM:
949: sfilt->flt_type = FILTER_ITEM;
950: sfilt->flt_next = make_filter(filt->next);
951:
952: if (strcmp(filt->fu_cont.item.stroid, "2.5.4.4"))
953: (void) strcpy(svalue, (filt->fu_cont.item.name?
954: filt->fu_cont.item.name:
955: mvalue));
956: else if (!filt->fu_cont.item.name) {
957: count = strlen(mvalue);
958: value = mvalue + count - 1;
959:
960: while(!isalpha(*value) && value > mvalue) value--;
961: while (!isspace(*value) && value > mvalue) value--;
962:
963: if (mvalue < value) (void) strcpy(svalue, ++value);
964: else (void) strcpy(svalue, mvalue);
965: } else (void) strcpy(svalue, filt->fu_cont.item.name);
966: type = filt->fu_cont.item.fi_type;
967:
968: switch(type) {
969: case APPROX:
970: case EQUAL:
971: sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type =
972: AttrT_new(filt->fu_cont.item.stroid);
973:
974: if ((sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_value =
975: str2AttrV(svalue,
976: sfilt->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->
977: oa_syntax)) == NULL) {
978:
979: rfilt = sfilt->flt_next;
980: sfilt->flt_next = NULLFILTER;
981: filter_free(sfilt);
982: return rfilt;
983: }
984:
985: if (type == EQUAL)
986: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY;
987: else
988: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
989:
990: break;
991:
992: case SUBSTRING:
993: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_SUBSTRINGS;
994: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_type =
995: AttrT_new(filt->fu_cont.item.stroid);
996:
997: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_initial =
998: NULLAV;
999: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_final =
1000: NULLAV;
1001: sfilt->flt_un.flt_un_item.fi_un.fi_un_substrings.fi_sub_any =
1002: avs_comp_new(str2AttrV(svalue,
1003: sfilt->flt_un.flt_un_item.fi_un.
1004: fi_un_substrings.fi_sub_type->
1005: oa_syntax));
1006: break;
1007:
1008: default:
1009: sfilt->flt_un.flt_un_item.fi_type = FILTERITEM_APPROX;
1010: break;
1011: }
1012: return sfilt;
1013: break;
1014:
1015: case AND:
1016: sfilt->flt_type = FILTER_AND;
1017: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
1018: sfilt->flt_next = make_filter(filt->next);
1019: return sfilt;
1020: break;
1021:
1022: case OR:
1023: sfilt->flt_type = FILTER_OR;
1024: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
1025: sfilt->flt_next = make_filter(filt->next);
1026: return sfilt;
1027: break;
1028:
1029: case NOT:
1030: sfilt->flt_type = FILTER_NOT;
1031: sfilt->flt_next = make_filter(filt->next);
1032: sfilt->flt_un.flt_un_filter = make_filter(filt->fu_cont.sub_filt);
1033: return sfilt;
1034: break;
1035:
1036: default:
1037: return NULLFILTER;
1038: }
1039: }
1040:
1041:
1042: srch_start()
1043: {
1044: struct ds_search_arg search_arg;
1045: struct ds_search_result result;
1046: struct DSError error;
1047: WIDGET *wdgt;
1048: char *str = base_path;
1049:
1050: if (*mvalue == '\0') {
1051: list_start();
1052: return;
1053: }
1054:
1055: cleartext();
1056: xprint("OK. Starting search.\n");
1057: tprint("Chugging along.....");
1058:
1059: wdgt = getwidget(mainwdgts,'t');
1060:
1061: if (get_default_service (&search_arg.sra_common) != 0) {
1062: xprint ("Default service error -> check your .quipurc\n");
1063: return ;
1064: }
1065:
1066: search_arg.sra_common.ca_servicecontrol.svc_options = 1;
1067: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit;
1068: search_arg.sra_baseobject = (*base_path != 'T'?
1069: str2dn (base_path):
1070: NULLDN);
1071: search_arg.sra_eis.eis_allattributes = FALSE;
1072: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
1073: search_arg.sra_eis.eis_select = read_types;
1074:
1075: while (*str != '\0' && *str != '@') str++;
1076:
1077: search_arg.sra_subset = ((*base_path != 'T' && *str == '@')?
1078: SRA_WHOLESUBTREE:
1079: SRA_ONELEVEL);
1080: search_arg.sra_filter =
1081: make_filter(filt_arr[gettogglindx(wdgt)]);
1082:
1083: #ifndef NO_STATS
1084: LLOG (log_stat,LLOG_NOTICE,("search +%s, extent %d, val %s",base_path,search_arg.sra_subset,mvalue));
1085: #endif
1086:
1087: if(ds_search (&search_arg,&error,&result) != DS_OK) {
1088: /* deal with error */
1089: free_seq(textseq);
1090: if (text_state == DN_LIST) free_seq(dnseq);
1091: dnseq = textseq = NULLDS;
1092: entry_number = 0;
1093: text_state = TEXT;
1094: cleartext();
1095: xprint(" Search error due to:\n ");
1096: quipu_error(&error);
1097: } else {
1098: cleartext();
1099: correlate_search_results (&result);
1100:
1101: if (result.CSR_entries != NULLENTRYINFO) {
1102: register EntryInfo *ptr;
1103:
1104: if (result.CSR_common.cr_aliasdereferenced) {
1105: xprint (" (Alias dereferenced - object is ");
1106: quipu_print (dn_print, (caddr_t) result.CSR_object);
1107: dn_free (result.CSR_object);
1108: xprint (")\n");
1109: }
1110:
1111: if (text_state == DN_LIST) free_seq(dnseq);
1112: free_seq(textseq);
1113: dnseq = textseq = NULLDS;
1114: display_entry = current_entry = 1;
1115: entry_number = 0;
1116: text_state = DN_LIST;
1117:
1118: for (ptr = result.CSR_entries;
1119: ptr != NULLENTRYINFO; ptr = ptr->ent_next){
1120: entry_number++;
1121: dn2str ((caddr_t) ptr->ent_dn, goto_path);
1122: add_seq (&dnseq, goto_path);
1123: cache_entry (ptr,TRUE,TRUE);
1124: }
1125:
1126: if (entry_number != 1)
1127: scrollbar('\0');
1128: else {
1129: if (!isleaf(goto_path)) {
1130: get_listed_object('1', 0);
1131: } else {
1132: char temp[1024];
1133: (void) strcpy(temp, base_path);
1134: (void) strcpy(base_path, goto_path);
1135: rd_start();
1136: (void) strcpy(base_path, temp);
1137: }
1138: }
1139: } else if(result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) {
1140: free_seq(textseq);
1141: if (text_state == DN_LIST) free_seq(dnseq);
1142: dnseq = textseq = NULLDS;
1143: entry_number = 0;
1144: text_state = TEXT;
1145: xprint("Nothing found using current search parameters. Sorry!\n");
1146: }
1147:
1148: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM)
1149: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) {
1150: free_seq(textseq);
1151: if (text_state == DN_LIST) free_seq(dnseq);
1152: dnseq = textseq = NULLDS;
1153: entry_number = 0;
1154: text_state = TEXT;
1155: xprint("(Time limit exceeded)");
1156: } else
1157: xprint("(Size limit exceeded)");
1158:
1159: entryinfo_free(result.CSR_entries, 0);
1160: }
1161:
1162: filter_free(search_arg.sra_filter);
1163: }
1164:
1165: static dn2str (ptr,cptr)
1166: caddr_t ptr;
1167: char * cptr;
1168: {
1169: PS ps;
1170: char buffer [RESBUF];
1171:
1172: if((ps = ps_alloc(str_open)) == NULLPS) return ;
1173:
1174: if(str_setup(ps, buffer, RESBUF, 1) == NOTOK) return ;
1175:
1176: dn_print(ps, (DN) ptr, EDBOUT);
1177: *ps->ps_ptr = 0;
1178:
1179: ps_free (ps);
1180:
1181: (void) strcpy(cptr, buffer);
1182: }
1183:
1184:
1185: read_print(func,ptr)
1186: int (*func) ();
1187: caddr_t ptr;
1188: {
1189: PS ps;
1190: char buffer [RESBUF];
1191: char save;
1192: int i, size;
1193: register char *str, *sptr;
1194:
1195: if ((ps = ps_alloc (str_open)) == NULLPS) return ;
1196:
1197: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ;
1198:
1199: (*func) (ps, ptr, READOUT);
1200: *ps->ps_ptr = 0;
1201:
1202: ps_free(ps);
1203: str = buffer ;
1204: sptr = str;
1205: size = strlen(buffer);
1206:
1207: if (text_state == DN_LIST) free_seq(dnseq);
1208: dnseq = NULLDS;
1209: free_seq(textseq);
1210: textseq = NULLDS;
1211: display_entry = current_entry = 1;
1212: entry_number = 0;
1213: text_state = TEXT;
1214:
1215: for (i = 0; i <= size; i++, sptr++)
1216: if (*sptr == '\n' || *sptr == '\0') {
1217: entry_number++;
1218: save = *sptr ;
1219: *sptr = '\0';
1220:
1221: if (mailformat == greybook && indexstring(str, "rfc822") >= 0)
1222: (void) rfc2jnt(str);
1223: add_seq(&textseq, str);
1224:
1225: str = sptr+1;
1226: *sptr = save;
1227: }
1228:
1229: scrollbar('\0');
1230: }
1231:
1232: quipu_print (func,ptr)
1233: int (*func) (); /* assumes func (PS ,dataptr,(int) format); */
1234: caddr_t ptr;
1235: {
1236: /* log info to pstream */
1237: PS ps;
1238: char buffer [RESBUF];
1239: int count;
1240: register char *str, *sptr;
1241: char save;
1242:
1243: if ((ps = ps_alloc (str_open)) == NULLPS) return ;
1244:
1245: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ;
1246:
1247: (*func) (ps,ptr,READOUT);
1248: *ps->ps_ptr = 0;
1249:
1250: ps_free (ps);
1251:
1252: /* print in blocks of 100 bytes-larger seems too much for curses*/
1253: str = buffer;
1254: do {
1255: for (count = 0, sptr = str; *sptr != '\0' &&
1256: count < 100; sptr++, count++);
1257: save = *sptr;
1258: *sptr = 0;
1259: xprint (str);
1260: *sptr = save;
1261: str = sptr;
1262: } while (*sptr != '\0');
1263: }
1264:
1265: quipu_error (err)
1266: struct DSError * err;
1267: {
1268: PS ps;
1269: char buffer [RESBUF];
1270:
1271: if ((ps = ps_alloc(str_open)) == NULLPS) return ;
1272:
1273: if (str_setup (ps, buffer, RESBUF, 1) == NOTOK) return ;
1274: ds_error(ps, err);
1275:
1276: *ps->ps_ptr = 0;
1277: xprint(buffer);
1278: }
1279:
1280: returnmain()
1281: {
1282: QUITFN();
1283: setwidgets (mainwdgts,-1);
1284: rd_start();
1285: scrollbar('\0');
1286: }
1287:
1288: free_filt(filt)
1289: filt_struct *filt;
1290: {
1291: if (filt) {
1292: free_filt(filt->next);
1293:
1294: if (filt->flt_type = ITEM) {
1295: free(filt->fu_cont.item.stroid);
1296: if (filt->fu_cont.item.name) free(filt->fu_cont.item.name);
1297: } else
1298: free_filt(filt->fu_cont.sub_filt);
1299:
1300: free(filt);
1301: } else
1302: return;
1303: }
1304:
1305: get_listed_object(number, wdgt)
1306: char number;
1307: WIDGET *wdgt;
1308: {
1309: int entrynum, count = 0;
1310: char *sptr, *str;
1311: char buffer[1024];
1312:
1313: if (text_state != DN_LIST && text_state != BACK_LIST) {
1314: *wdgt->dstr = '\0';
1315: printdialog(wdgt);
1316: return;
1317: }
1318:
1319: *srchvalue = number;
1320: *(srchvalue+1) = '\0';
1321:
1322: if (wdgt) {
1323: printdialog(wdgt);
1324: dialog(wdgt);
1325: }
1326:
1327: entrynum = atoi(srchvalue);
1328:
1329: if (entrynum > entry_number) {
1330: *wdgt->dstr = '\0';
1331: printdialog(wdgt);
1332: return;
1333: }
1334:
1335: if (sptr = get_from_seq (entrynum, dnseq))
1336: if(!isleaf(sptr)) {
1337: cleartext();
1338: str = get_from_seq(count+1, back_seq);
1339:
1340: while (count < back_buf_num && strcmp(str, base_path)){
1341: count++;
1342: str = get_from_seq(count+1, back_seq);
1343: }
1344:
1345: if (count == back_buf_num) {
1346: add_seq(&back_seq, base_path);
1347: back_buf_num++;
1348: }
1349:
1350: (void) strcpy(base_path, sptr);
1351: make_friendly(friendly_base_path, base_path);
1352: wdgt = getwidget(mainwdgts, '\0');
1353: printdialog(wdgt);
1354: rd_start();
1355: typetoggled = 0;
1356: set_default_type();
1357: } else {
1358: (void) strcpy(buffer, base_path);
1359: (void) strcpy(base_path, sptr);
1360: make_friendly(friendly_base_path, base_path);
1361: rd_start();
1362: (void) strcpy(base_path, buffer);
1363: }
1364: *srchvalue = '\0';
1365: }
1366:
1367: scrollbar(command)
1368: char command;
1369: {
1370: register char *str;
1371: char *base_rdn;
1372: register int rdn_count = 0;
1373: int lines, count = 0;
1374: D_seq thisseq;
1375:
1376: if (!entry_number)
1377: return 0;
1378:
1379: if(command == '[') {
1380: if(display_entry >= entry_number)
1381: return;
1382:
1383: for (count = 0; (display_entry + count) < entry_number &&
1384: count < text_height/2; count++);
1385:
1386: current_entry += count;
1387: } else if(command == ']') {
1388:
1389: for (count = 0; (current_entry - count) > 1 &&
1390: count < text_height/2; count++);
1391:
1392: current_entry -= count;
1393: }
1394:
1395: cleartext();
1396:
1397: switch(text_state) {
1398:
1399: case BACK_LIST:
1400: thisseq = back_seq;
1401: break;
1402:
1403: case DN_LIST:
1404: base_rdn = base_path;
1405: while(*base_rdn != '\0') {
1406: if(*base_rdn == '@')
1407: rdn_count++;
1408: base_rdn++;
1409: }
1410: if (*base_path != 'T') rdn_count++;
1411: thisseq = dnseq;
1412: break;
1413:
1414: case TEXT:
1415: thisseq = textseq;
1416: break;
1417: }
1418:
1419: if (current_entry > entry_number)
1420: current_entry = 1;
1421:
1422: lines = linec()-2;
1423: count = 0;
1424:
1425: for (display_entry = current_entry; display_entry <= entry_number
1426: && gety() < lines; display_entry++) {
1427:
1428: if (text_state == DN_LIST || text_state == BACK_LIST)
1429: xprintint(" %d ", display_entry) ;
1430:
1431: base_rdn = str = get_from_seq(display_entry, thisseq);
1432:
1433: if (text_state == DN_LIST && rdn_count) {
1434: while (rdn_count) {
1435: if (*str == '@') rdn_count--;
1436: str++;
1437: }
1438:
1439: while(*str == ' ') str++;
1440: count = (int) (str - base_rdn);
1441:
1442: } else if (count) str += count;
1443:
1444: if (str) {
1445: if (text_state != TEXT) {
1446: make_friendly(friendly_name, str);
1447: xprint(friendly_name);
1448: } else
1449: xprint(str);
1450: xprint("\n");
1451: }
1452: }
1453:
1454: if (text_state == DN_LIST)
1455: if (current_entry >= entry_number) xprint("<List finished>");
1456: else xprintint("<Total of %d entries>", entry_number);
1457:
1458: printbar(entry_number, current_entry, display_entry-current_entry);
1459: display_entry--;
1460: return 1;
1461: }
1462:
1463: make_friendly(fstr, str)
1464: char *fstr;
1465: register char *str;
1466: {
1467: register char *end_ptr;
1468: char save;
1469:
1470: *fstr = '\0';
1471: if (!strcmp(str, "The World")) {
1472: (void) strcpy(fstr, str);
1473: return;
1474: }
1475:
1476: while (*str != '\0') {
1477: while (*str != '=') str++;
1478: while (*str == ' ') str++;
1479:
1480: end_ptr = ++str;
1481: while (*end_ptr != '@' && *end_ptr != '\0') end_ptr++;
1482: save = *end_ptr;
1483: *end_ptr = '\0';
1484: if (*fstr == '\0')
1485: (void) strcpy(fstr, str);
1486: else
1487: (void) strcat(fstr, str);
1488: *end_ptr = save;
1489: str = end_ptr;
1490: if (*str != '\0')
1491: (void) strcat(fstr, ", ");
1492: }
1493: }
1494:
1495:
1496: goto_addr()
1497: {
1498: set_default_type();
1499: rd_start();
1500: }
1501:
1502: int
1503: isleaf(name)
1504: char *name;
1505: {
1506: struct ds_list_arg list_arg;
1507: struct ds_list_result list_result;
1508:
1509: struct ds_read_arg read_arg;
1510: struct ds_read_result read_result;
1511:
1512: struct DSError list_error, read_error;
1513: char entry_str[1024];
1514:
1515: if (get_default_service (&read_arg.rda_common) != 0) return(1);
1516:
1517: read_arg.rda_common.ca_servicecontrol.svc_options = 1;
1518: read_arg.rda_eis.eis_allattributes = FALSE;
1519: read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
1520: read_arg.rda_eis.eis_select = oclass;
1521:
1522: read_arg.rda_object = (*name? str2dn(name): NULLDN);
1523: if (ds_read (&read_arg,&read_error,&read_result) != DS_OK) return(1);
1524: else {
1525: if (read_result.rdr_entry.ent_attr == NULLATTR) return(0);
1526: entry2str((caddr_t) read_result.rdr_entry.ent_attr, entry_str, 1024);
1527: if (issubstr(entry_str, "NonLeaf")) return(0);
1528: }
1529: if (get_default_service (&list_arg.lsa_common) != 0) return(1);
1530:
1531: list_arg.lsa_common.ca_servicecontrol.svc_sizelimit = 1;
1532: list_arg.lsa_common.ca_servicecontrol.svc_options = 1;
1533:
1534: if (*name)
1535: list_arg.lsa_object = str2dn(name);
1536: else
1537: list_arg.lsa_object = NULLDN;
1538:
1539: if (ds_list (&list_arg,&list_error,&list_result) != DS_OK)
1540: return (1);
1541: else {
1542: if (list_result.lsr_subordinates == NULLSUBORD) return(1);
1543: else return(0);
1544: }
1545: }
1546:
1547: entry2str(ptr, cptr, size)
1548: caddr_t ptr;
1549: char *cptr;
1550: int size;
1551: {
1552: PS ps;
1553:
1554: if ((ps = ps_alloc (str_open)) == NULLPS) return ;
1555: if (str_setup (ps, cptr, size, 1) == NOTOK) return ;
1556:
1557: as_print(ps, (Attr_Sequence) ptr, READOUT);
1558: *ps->ps_ptr = 0;
1559:
1560: ps_free(ps);
1561: }
1562:
1563: int issubstr(str, substr)
1564: char *str;
1565: char *substr;
1566: {
1567: register char *sptr;
1568: char c;
1569: int substrlen = strlen(substr);
1570: int count;
1571:
1572: if (*substr == '\0' || *str == '\0') return(0);
1573:
1574: sptr = str;
1575: c = *substr;
1576:
1577: while (1) {
1578: while (*sptr != '\0' && *sptr != c) sptr++;
1579: if (*sptr == '\0') return(0);
1580: for (count = 0; count >= 0 && count < substrlen; count++) {
1581: if (sptr[count] == '\0') return(0);
1582: else if (substr[count] != sptr[count]) count = -2;
1583: }
1584: if (count == substrlen) return(1);
1585: }
1586: }
1587:
1588: int indexstring(string, substring)
1589: char *string,
1590: *substring;
1591: {
1592: register char *sub, *str;
1593: char c, s;
1594: int indx = 0;
1595:
1596: while (1) {
1597: str = string + indx;;
1598: if (*str == '\0') return(-1);
1599: sub = substring;
1600:
1601: if (*str == *sub) {
1602: s = *str;
1603: c = *sub;
1604: while(c == s && c != '\0') {
1605: c = *++sub;
1606: s = *++str;
1607: }
1608: if (c == '\0') return((int) indx);
1609: else if(s == '\0') return(-1);
1610: }
1611: indx++;
1612: }
1613: }
1614:
1615: rfc2jnt(string)
1616: char *string;
1617: {
1618: char reversed[STRINGLEN];
1619: char front[STRINGLEN];
1620: register char *part;
1621: char *mailbox;
1622:
1623: mailbox = string;
1624: while (*mailbox != '-') mailbox++;
1625:
1626: reversed[0] = '\0';
1627: part = string + strlen(string);
1628:
1629: if (*part != '\0') return;
1630:
1631: while(1) {
1632: while (*part != '.' && *part != '@') --part;
1633:
1634: if (*part == '.') {
1635: if (reversed[0] != '\0') (void) strcat(reversed, ".");
1636: part++;
1637: (void) strcat(reversed, part);
1638: *--part = '\0';
1639: --part;
1640: } else {
1641: part++;
1642: (void) strcat(reversed, ".");
1643: (void) strcat(reversed, part);
1644: *part-- = '\0';
1645: while (!isspace(*part)) --part;
1646: ++part;
1647: (void) strcpy(front, part);
1648: (void) strcpy(string, "mailbox - ");
1649: (void) strcat(string, front);
1650: (void) strcat(string, reversed);
1651: return;
1652: }
1653: }
1654: }
1655:
1656: struct attrcomp *
1657: sort_attrs(entry_attrs)
1658: struct attrcomp *entry_attrs;
1659: {
1660: struct attrcomp *last, *next, *curr, *first, *firstn;
1661:
1662: first = curr = entry_attrs;
1663: firstn = last = next = 0;
1664:
1665: while (curr)
1666: if (!strcmp("2.5.4.3", curr->attr_type->oa_ot.ot_stroid) ||
1667: !strcmp("2.5.4.4", curr->attr_type->oa_ot.ot_stroid) ||
1668: !strcmp("0.9.2342.19200300.100.1.3",
1669: curr->attr_type->oa_ot.ot_stroid) ||
1670: !strcmp("0.9.2342.19200300.100.1.2",
1671: curr->attr_type->oa_ot.ot_stroid) ||
1672: !strcmp("2.5.4.20", curr->attr_type->oa_ot.ot_stroid)) {
1673:
1674: if (first == curr) first = curr->attr_link;
1675:
1676: if (next)
1677: next->attr_link = curr;
1678: else
1679: firstn = curr;
1680:
1681: next = curr;
1682:
1683: if (last)
1684: last->attr_link = curr->attr_link;
1685:
1686: curr = curr->attr_link;
1687: next->attr_link = 0;
1688: } else {
1689: last = curr;
1690: curr = curr->attr_link;
1691: }
1692:
1693: if (next) {
1694: next->attr_link = first;
1695: return firstn;
1696: } else
1697: return first;
1698: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.