|
|
1.1 ! root 1: ! 2: #ifndef lint ! 3: static char *rcsid = "$Header: /f/osi/others/quipu/uips/pod/RCS/calls.c,v 7.2 90/07/27 08:45:32 mrose Exp $"; ! 4: #endif ! 5: ! 6: /* ! 7: * $Header: /f/osi/others/quipu/uips/pod/RCS/calls.c,v 7.2 90/07/27 08:45:32 mrose Exp $ ! 8: */ ! 9: ! 10: /* ! 11: * $Log: calls.c,v $ ! 12: * Revision 7.2 90/07/27 08:45:32 mrose ! 13: * update ! 14: * ! 15: * Revision 7.1 90/07/09 14:41:29 mrose ! 16: * sync ! 17: * ! 18: * Revision 7.0 90/06/12 13:15:48 mrose ! 19: * *** empty log message *** ! 20: * ! 21: * Revision 1.5 90/04/26 10:21:02 emsrdsm ! 22: * *** empty log message *** ! 23: * ! 24: * Revision 1.4 90/04/25 13:46:44 emsrdsm ! 25: * i) lint'ed ! 26: * ! 27: * Revision 1.3 90/04/20 10:27:45 emsrdsm ! 28: * *** empty log message *** ! 29: * ! 30: * Revision 1.2 90/04/18 18:47:56 emsrdsm ! 31: * i) added logging ! 32: * ! 33: * Revision 1.1 90/04/10 16:43:29 emsrdsm ! 34: * Initial revision ! 35: * ! 36: */ ! 37: ! 38: #include "manifest.h" ! 39: #include <malloc.h> ! 40: #include <string.h> ! 41: #include <ctype.h> ! 42: ! 43: #include "quipu/util.h" ! 44: #include "quipu/common.h" ! 45: #include "quipu/entry.h" ! 46: ! 47: #include "usr.dirent.h" ! 48: #include "tailor.h" ! 49: #include "sequence.h" ! 50: #include "filt.h" ! 51: #include "y.tab.h" ! 52: #include "symtab.h" ! 53: #include "defs.h" ! 54: ! 55: struct attrcomp * sort_attrs(); ! 56: static dn2str (); ! 57: ! 58: #define RESBUF 10000 ! 59: ! 60: extern Filter make_filter(); ! 61: extern void xprint(); ! 62: ! 63: typedef enum {rfc822, greybook} mailtype; ! 64: ! 65: mailtype mailformat = rfc822; ! 66: extern mode listmode; ! 67: ! 68: PS opt; ! 69: Attr_Sequence read_types = 0, read_types2 = 0, oclass = 0; ! 70: ! 71: table_entry symtab = 0; ! 72: int typetoggled = 0; ! 73: ! 74: int dn_print (), rdn_print(), as_print(), avs_comp_print(); ! 75: ! 76: char bound = FALSE; /* indication of wether bound */ ! 77: char * TidyString(); ! 78: ! 79: D_seq dnseq = NULLDS, backseq = NULLDS, showseq = NULLDS; ! 80: int entry_number, back_buf_num, dn_number; ! 81: ! 82: int two_passes = 0; ! 83: ! 84: /* These are common operation variables */ ! 85: #define STRINGLEN 1000 ! 86: #define SMALLSTRING 255 ! 87: #define MAXTYPES 255 ! 88: ! 89: char goto_path[STRINGLEN]; /* Used by the 'G:goto' command*/ ! 90: char base_path[STRINGLEN]; /* Used by all DS operations */ ! 91: char friendly_base_path[STRINGLEN]; ! 92: char friendly_name[STRINGLEN]; ! 93: char namestr[STRINGLEN]; ! 94: char cache [STRINGLEN]; ! 95: char bindpass [STRINGLEN]; ! 96: char srchvalue[STRINGLEN]; /* Used by search */ ! 97: char svalue [STRINGLEN]; ! 98: char mvalue [STRINGLEN]; ! 99: ! 100: unsigned int curr_filt = 0; ! 101: unsigned int filt_num = 0; ! 102: unsigned int typeindx = 0; ! 103: filt_struct *filt_arr[MAXTYPES]; ! 104: char *filtvalue[MAXTYPES]; ! 105: char *filttype[MAXTYPES]; ! 106: ! 107: int default_num; ! 108: int *av_typeindx; ! 109: int *available_types[MAXTYPES]; ! 110: char *levels[MAXTYPES]; ! 111: int defaults[MAXTYPES]; ! 112: ! 113: typedef struct friendlyName { ! 114: D_seq names; ! 115: char fname[256]; ! 116: } *fName; ! 117: ! 118: unsigned int fname_num = 0; ! 119: fName name_map[MAXTYPES]; ! 120: ! 121: #ifndef NO_STATS ! 122: extern LLog *log_stat; ! 123: #endif ! 124: ! 125: /* These are used as the data for the binding connection */ ! 126: char passwd[STRINGLEN]; ! 127: ! 128: extern char * myname; ! 129: extern int sizelimit; ! 130: extern char *local_dit; ! 131: ! 132: DN user_name; ! 133: ! 134: char * addobj = NULLCP; ! 135: Filter search_filter; ! 136: FILE *file; ! 137: char *file_names[MAXTYPES]; ! 138: char dua_help_dir[256]; ! 139: ! 140: char *get_strioid(ptr) ! 141: register char *ptr; ! 142: { ! 143: register char *end_ptr; ! 144: ! 145: while(*ptr == '"') ptr++; ! 146: while(*ptr != '"') ptr++; ! 147: ! 148: while(*ptr > '9' || *ptr < '0') ptr++; ! 149: ! 150: end_ptr = ptr; ! 151: while(*end_ptr != '\n') end_ptr++; ! 152: ! 153: *end_ptr = '\0'; ! 154: return ptr; ! 155: } ! 156: ! 157: ! 158: user_tailor() ! 159: { ! 160: char *part1; ! 161: char *part2; ! 162: char *getenv (); ! 163: char *ptr = "/.quipurc"; ! 164: char *config_dir = "/.duaconfig/"; ! 165: char *type_dir = "filterTypes/"; ! 166: char *read_File = "readTypes"; ! 167: char *friendly_File = "friendlyNames"; ! 168: char *options = "podOptions"; ! 169: char *type_defaults = "typeDefaults"; ! 170: ! 171: char Dish_Home[BUFSIZ]; ! 172: char read_Home[BUFSIZ]; ! 173: char type_Home[BUFSIZ]; ! 174: char optionsHome[BUFSIZ]; ! 175: char friendly_Home[BUFSIZ]; ! 176: char type_defaults_Home[BUFSIZ]; ! 177: char dua_config_dir[BUFSIZ]; ! 178: ! 179: char stroid_buf[BUFSIZ]; ! 180: char *str, *sptr; ! 181: char save; ! 182: ! 183: DIR *dir; ! 184: ! 185: struct dirent *dir_ent; ! 186: ! 187: char Read_in_Stuff[STRINGLEN]; ! 188: char *p, ! 189: *TidyString(), ! 190: *SkipSpace(), ! 191: *end; ! 192: ! 193: int count, n, num; ! 194: int tempints[MAXTYPES]; ! 195: ! 196: #ifndef NO_STATS ! 197: ll_hdinit (log_stat,"sd"); ! 198: #endif ! 199: ! 200: (void) strcpy(dua_config_dir, isodefile("xd/", 0)); ! 201: (void) strcpy(dua_help_dir, dua_config_dir); ! 202: ! 203: (void) strcat(dua_config_dir, "duaconfig/"); ! 204: (void) strcat(dua_help_dir, "podHelpdir/"); ! 205: ! 206: if ((opt = ps_alloc (std_open)) == NULLPS) ! 207: fatal (-1,"ps_alloc failed"); ! 208: if (std_setup (opt,stdout) == NOTOK) ! 209: fatal (-1,"std_setup failed"); ! 210: ! 211: namestr[0] = '\0'; ! 212: *passwd = '\0'; ! 213: cache[0] = '\0'; ! 214: ! 215: (void) strcpy (Dish_Home, getenv ("HOME")); ! 216: (void) strcpy(read_Home, Dish_Home); ! 217: (void) strcpy(type_Home, Dish_Home); ! 218: (void) strcpy(friendly_Home, Dish_Home); ! 219: (void) strcpy(optionsHome, Dish_Home); ! 220: (void) strcpy(type_defaults_Home, Dish_Home); ! 221: ! 222: (void) strcat(Dish_Home, ptr); ! 223: (void) strcat(read_Home, config_dir); ! 224: (void) strcat(read_Home, read_File); ! 225: (void) strcat(type_Home, config_dir); ! 226: (void) strcat(type_Home, type_dir); ! 227: (void) strcat(friendly_Home, config_dir); ! 228: (void) strcat(friendly_Home, friendly_File); ! 229: (void) strcat(optionsHome, config_dir); ! 230: (void) strcat(optionsHome, options); ! 231: (void) strcat(type_defaults_Home, config_dir); ! 232: (void) strcat(type_defaults_Home, type_defaults); ! 233: ! 234: if (!(dir = opendir(type_Home))) { ! 235: (void) strcpy(type_Home, dua_config_dir); ! 236: (void) strcat(type_Home, type_dir); ! 237: if(!(dir = opendir(type_Home))) { ! 238: (void) strcpy(type_Home, "./Xd/duaconfig/"); ! 239: (void) strcat(type_Home, type_dir); ! 240: if (!(dir = opendir(type_Home))) { ! 241: (void) fprintf(stderr, "Can't find directory %s!\n", type_dir); ! 242: quit(1); ! 243: } ! 244: } ! 245: } ! 246: ! 247: rewinddir(dir); ! 248: filt_num = 0; ! 249: while(dir_ent = readdir(dir)) { ! 250: if (!(strncmp(dir_ent->d_name, "Type_", 5))) { ! 251: file_names[filt_num] = ! 252: (char *) malloc((unsigned int) ! 253: (strlen(dir_ent->d_name) + ! 254: strlen(type_Home) + 2)); ! 255: (void) strcpy(file_names[filt_num], type_Home); ! 256: (void) strcat(file_names[filt_num], dir_ent->d_name); ! 257: filt_num++; ! 258: } ! 259: } ! 260: (void) closedir(dir); ! 261: ! 262: if ((file = fopen (Dish_Home, "r")) == 0); ! 263: else { ! 264: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) { ! 265: p = SkipSpace (Read_in_Stuff); ! 266: if (( *p == '#') || (*p == '\0')) ! 267: continue; /* ignore comments and blanks */ ! 268: ! 269: part1 = p; ! 270: if ((part2 = index (p,':')) == NULLCP) ! 271: continue; /* ignore it */ ! 272: ! 273: *part2++ = '\0'; ! 274: part2 = TidyString(part2); ! 275: ! 276: if (strcmp (part1, "username") == 0) ! 277: (void) strcpy (namestr, part2); ! 278: else if (strcmp (part1, "password") == 0) ! 279: (void) strcpy (passwd, part2); ! 280: else if (strcmp(part1, "prefergreybook") == 0) ! 281: mailformat = greybook; ! 282: else if (lexequ (part1, "dsap") == 0) ! 283: (void) tai_string (part2); ! 284: else if (lexequ (part1, "isode") == 0) { ! 285: char * split; ! 286: if ((split = index (part2,' ')) != NULLCP) { ! 287: *split++ = 0; ! 288: (void) isodesetvar (part2,split,0); ! 289: } ! 290: } else if (strcmp (part1, "service") == 0) ! 291: new_service (part2); ! 292: } ! 293: isodexport (NULLCP); ! 294: (void) fclose(file); ! 295: } ! 296: ! 297: if ((file = fopen(optionsHome, "r")) == 0) { ! 298: (void) strcpy(optionsHome, dua_config_dir); ! 299: (void) strcat(optionsHome, options); ! 300: if ((file = fopen(optionsHome, "r")) == 0) { ! 301: (void) strcpy(optionsHome, "./Xd/duaconfig/"); ! 302: (void) strcat(optionsHome, options); ! 303: if ((file = fopen(optionsHome, "r")) == 0) { ! 304: (void) fprintf(stderr, "Can't find options file (%s)!\n", options); ! 305: } ! 306: } ! 307: } ! 308: ! 309: if (file) { ! 310: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) { ! 311: p = SkipSpace (Read_in_Stuff); ! 312: if (( *p == '#') || (*p == '\0')) ! 313: continue; /* ignore comments and blanks */ ! 314: ! 315: part1 = p; ! 316: if ((part2 = index (p,':')) == NULLCP) ! 317: continue; /* ignore it */ ! 318: ! 319: *part2++ = '\0'; ! 320: part2 = TidyString(part2); ! 321: ! 322: if (strcmp (part1, "listmode") == 0) ! 323: if (strcmp (part2, "one") == 0) ! 324: listmode = one; ! 325: else ! 326: listmode = many; ! 327: } ! 328: } ! 329: if (!(file = fopen(read_Home, "r"))) { ! 330: (void) strcpy(read_Home, dua_config_dir); ! 331: (void) strcat(read_Home, read_File); ! 332: if (!(file = fopen(read_Home, "r"))) { ! 333: (void) strcpy(read_Home, "./Xd/duaconfig/"); ! 334: (void) strcat(read_Home, read_File); ! 335: if (!(file = fopen(read_Home, "r"))) { ! 336: (void) fprintf(stderr, "Can't find read file (%s)!\n", read_Home); ! 337: quit(1); ! 338: } ! 339: } ! 340: } ! 341: ! 342: while(fgets(Read_in_Stuff, STRINGLEN, file) != 0) { ! 343: (void) strcpy(stroid_buf, get_strioid(Read_in_Stuff)); ! 344: if (*stroid_buf) { ! 345: if (!read_types) ! 346: read_types = as_comp_new(AttrT_new(stroid_buf), NULLAV, NULLACL_INFO); ! 347: else { ! 348: read_types2 = as_comp_new(AttrT_new(stroid_buf) ,NULLAV, NULLACL_INFO); ! 349: read_types = as_merge(read_types, read_types2); ! 350: } ! 351: } ! 352: } ! 353: (void) fclose(file); ! 354: ! 355: if (!(file = fopen(friendly_Home, "r"))) { ! 356: (void) strcpy(friendly_Home, dua_config_dir); ! 357: (void) strcat(friendly_Home, friendly_File); ! 358: if (!(file = fopen(friendly_Home, "r"))) { ! 359: (void) strcpy(friendly_Home, "./Xd/duaconfig/"); ! 360: (void) strcat(friendly_Home, friendly_File); ! 361: if (!(file = fopen(friendly_Home, "r"))) { ! 362: (void) fprintf(stderr, "Can't find read file (%s)!\n", friendly_Home); ! 363: quit(1); ! 364: } ! 365: } ! 366: } ! 367: ! 368: name_map[fname_num] = 0; ! 369: while(fgets(Read_in_Stuff, STRINGLEN, file) != 0) { ! 370: if (*Read_in_Stuff != '#') { ! 371: sptr = str = Read_in_Stuff; ! 372: while (*sptr != ':' && !isspace(*sptr) && sptr != '\0') { ! 373: while (!isalnum(*sptr)) sptr++; ! 374: str = sptr; ! 375: while (*str != ' ' && *str != ',' && *str != ':') str++; ! 376: save = *str; ! 377: *str = '\0'; ! 378: ! 379: if (!name_map[fname_num]) { ! 380: name_map[fname_num] = (fName) malloc(sizeof(struct friendlyName)); ! 381: name_map[fname_num]->names = 0; ! 382: } ! 383: ! 384: add_seq(&name_map[fname_num]->names, sptr); ! 385: *str = save; ! 386: sptr = str; ! 387: while (*sptr != ',' && *sptr != ':') sptr++; ! 388: } ! 389: ! 390: while (!isalpha(*sptr) && *sptr != '\0') sptr++; ! 391: ! 392: str = sptr; ! 393: while (*str != '\0' && *str != '\n') str++; ! 394: *str = '\0'; ! 395: ! 396: if (name_map[fname_num]) { ! 397: (void) strcpy(name_map[fname_num]->fname, sptr); ! 398: fname_num++; ! 399: name_map[fname_num] = 0; ! 400: } ! 401: } ! 402: } ! 403: ! 404: for (curr_filt = 0; curr_filt < filt_num; curr_filt++) { ! 405: if (!(file = fopen(file_names[curr_filt], "r"))) { ! 406: (void) fprintf(stderr, "Can't find file %s!\n", file_names[curr_filt]); ! 407: quit(1); ! 408: } ! 409: filtvalue[curr_filt] = (char *) malloc(STRINGLEN); ! 410: *filtvalue[curr_filt] = '\0'; ! 411: ! 412: (void) yyparse(); ! 413: (void) fclose(file); ! 414: } ! 415: filttype[curr_filt] = NULLCP; ! 416: for (count = 0; count < filt_num; count++) ! 417: free(file_names[count]); ! 418: ! 419: if (!(file = fopen(type_defaults_Home, "r"))) { ! 420: (void) strcpy(type_defaults_Home, dua_config_dir); ! 421: (void) strcat(type_defaults_Home, type_defaults); ! 422: if (!(file = fopen(type_defaults_Home, "r"))) { ! 423: (void) strcpy(type_defaults_Home, "./Xd/duaconfig/"); ! 424: (void) strcat(type_defaults_Home, type_defaults); ! 425: if (!(file = fopen(type_defaults_Home, "r"))) { ! 426: (void) fprintf(stderr, "Can't open typeDefaults file\n"); ! 427: quit(1); ! 428: } ! 429: } ! 430: } ! 431: ! 432: default_num = 0; ! 433: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) { ! 434: p = SkipSpace(Read_in_Stuff); ! 435: if (( *p == '#') || (*p == '\0')) ! 436: continue; ! 437: ! 438: part1 = p; ! 439: if ((part2 = index (p,':')) == NULLCP) ! 440: continue; ! 441: ! 442: end = part2 - 1; ! 443: while (isspace(*end)) end--; ! 444: *++end = '\0'; ! 445: ! 446: *part2++ = '\0'; ! 447: ! 448: while (isspace(*part2)) part2++; ! 449: end = part2; ! 450: ! 451: while (!isspace(*end) && *end != ',' && *end != ':') end++; ! 452: ! 453: count = 0; ! 454: while (*part2 != ':') { ! 455: n = 0; ! 456: while (n < filt_num && strncmp(filttype[n], part2, ! 457: (int) (end - part2))) n++; ! 458: ! 459: if (n == filt_num) { ! 460: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 461: quit(1); ! 462: } else { ! 463: tempints[count] = n; ! 464: count++; ! 465: part2 = end; ! 466: while (!isalpha(*part2) && *part2 != ':' && part2 != '\0') part2++; ! 467: ! 468: if (*part2 == '\0') { ! 469: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 470: quit(1); ! 471: } ! 472: ! 473: if (*part2 != ':') { ! 474: while (!isalpha(*part2)) part2++; ! 475: end = part2; ! 476: while (!isspace(*end) && *end != ',' && ! 477: *end != ':' && *end != '\0') end++; ! 478: if (*end == '\0') { ! 479: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 480: quit(1); ! 481: } ! 482: } else end = part2; ! 483: } ! 484: } ! 485: ! 486: if (*end == ':') { ! 487: while(isspace(*++end)); ! 488: p = end; ! 489: while(!isspace(*++end)); ! 490: *end = '\0'; ! 491: ! 492: n = 0; ! 493: while (n < filt_num && strcmp(filttype[n], p)) n++; ! 494: ! 495: if (n == filt_num) { ! 496: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 497: quit(1); ! 498: } else { ! 499: num = 0; ! 500: while (num < count && n != tempints[num]) num++; ! 501: if (num == count) { ! 502: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 503: quit(1); ! 504: } ! 505: } ! 506: ! 507: defaults[default_num] = n; ! 508: ! 509: levels[default_num] = malloc((unsigned int) (strlen(part1) + 1)); ! 510: (void) strcpy(levels[default_num], part1); ! 511: available_types[default_num] = ! 512: (int *) malloc((unsigned int) (sizeof(int) * (count+1))); ! 513: ! 514: for (n = 0; n < count; n++) ! 515: available_types[default_num][n] = tempints[n]; ! 516: ! 517: available_types[default_num][n] = -1; ! 518: default_num++; ! 519: } ! 520: } ! 521: } ! 522: ! 523: cnnct_bind() ! 524: { ! 525: struct ds_bind_arg bindarg; ! 526: struct ds_bind_arg bindresult; ! 527: struct ds_bind_error binderr; ! 528: extern char * dsa_address, ! 529: * myname; ! 530: extern char * tailfile; ! 531: FILE * fp; ! 532: char buf [BUFSIZ]; ! 533: ! 534: if (*passwd != 0) ! 535: (void) strcpy(bindpass,"******"); ! 536: else ! 537: bindpass[0] = '\0'; ! 538: /* set dsa_address */ ! 539: dsa_address = NULLCP; ! 540: /* read tailor file to get address */ ! 541: if( (fp = fopen(isodefile(tailfile,0), "r")) == (FILE *) NULL) { ! 542: (void) fprintf(stderr, ! 543: "Cannot open tailor file %s\n", isodefile(tailfile,0)); ! 544: return; ! 545: } ! 546: while(fgets(buf, sizeof(buf), fp) != NULLCP) ! 547: if ( (*buf != '#') && (*buf != '\n') ) ! 548: (void) tai_string (buf); ! 549: ! 550: (void) fclose(fp); ! 551: ! 552: if (dsa_address == NULLCP) ! 553: dsa_address = myname; ! 554: ! 555: /* set password */ ! 556: if (bindpass[0] != 0) { ! 557: if (strcmp (bindpass,"******") != 0) ! 558: (void) strcpy (passwd,bindpass); ! 559: } else ! 560: passwd[0] = 0; ! 561: ! 562: /* now bind */ ! 563: bindarg.dba_version = DBA_VERSION_V1988; ! 564: if (passwd[0] == 0) { ! 565: bindarg.dba_passwd_len = 0; ! 566: bindarg.dba_passwd [0] = '\0'; ! 567: } else { ! 568: bindarg.dba_passwd_len = strlen (passwd); ! 569: (void) strcpy (bindarg.dba_passwd,passwd); ! 570: } ! 571: ! 572: bindarg.dba_dn = (*namestr == 0? NULLDN: str2dn(namestr)); ! 573: ! 574: if (ds_bind (&bindarg,&binderr,&bindresult) != DS_OK) { ! 575: (void) fprintf(stderr, binderr.dbe_type == DBE_TYPE_SECURITY? ! 576: "Security error - Check name and pasword.\n": ! 577: "Service error - Can't connect to directory!\n"); ! 578: quit(1); ! 579: } else { ! 580: user_name = bindarg.dba_dn; ! 581: (void) strcpy (buf, "TERM"); ! 582: ! 583: if(local_dit && *local_dit) ! 584: (void) strcpy(base_path, local_dit); ! 585: ! 586: #ifndef NO_STATS ! 587: LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address)); ! 588: #endif ! 589: #ifndef NO_STATS ! 590: LLOG (log_stat,LLOG_NOTICE,("pod bound to directory")); ! 591: #endif ! 592: ! 593: make_friendly(friendly_base_path, base_path); ! 594: ! 595: set_default_type(); ! 596: oclass = as_comp_new(AttrT_new("2.5.4.0"), NULLAV, NULLACL_INFO); ! 597: } ! 598: dn_number = 0; ! 599: back_buf_num = 0; ! 600: backseq = dnseq = NULLDS; ! 601: } ! 602: ! 603: dsEnqError ! 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: hold_text(); ! 612: cleartext(); ! 613: ! 614: if (*base_path == '\0') { ! 615: xprint("The World - Big and Round\n"); ! 616: restart_text(); ! 617: return Okay; ! 618: } ! 619: ! 620: if (get_default_service (&read_arg.rda_common) != 0) { ! 621: return nothingfound; ! 622: } ! 623: ! 624: refresh(); ! 625: ! 626: read_arg.rda_common.ca_servicecontrol.svc_options = 1; ! 627: read_arg.rda_eis.eis_allattributes = FALSE; ! 628: read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 629: read_arg.rda_eis.eis_select = read_types; ! 630: ! 631: read_arg.rda_object = (*friendly_base_path != 'T'? str2dn(base_path): NULLDN); ! 632: if ((read_entry = ! 633: local_find_entry (read_arg.rda_object, FALSE)) != NULLENTRY) { ! 634: cleartext(); ! 635: xprint("Information on:\n"); ! 636: xprint(friendly_base_path); ! 637: read_entry->e_attributes = sort_attrs(read_entry->e_attributes); ! 638: read_print (as_print, (caddr_t) read_entry->e_attributes); ! 639: restart_text(); ! 640: return Okay; ! 641: } ! 642: ! 643: #ifndef NO_STATS ! 644: LLOG (log_stat,LLOG_NOTICE,("read +%s",base_path)); ! 645: #endif ! 646: ! 647: if (ds_read (&read_arg,&error,&result) != DS_OK) { ! 648: /* deal with error */ ! 649: restart_text(); ! 650: return localdsaerror; ! 651: } else { ! 652: /* use data */ ! 653: if (result.rdr_entry.ent_attr == NULLATTR) { ! 654: cleartext(); ! 655: dn_number = 0; ! 656: restart_text(); ! 657: return nothingfound; ! 658: } ! 659: if (result.rdr_common.cr_aliasdereferenced) ! 660: xprint("Alias dereferenced)\n"); ! 661: ! 662: result.rdr_entry.ent_attr = sort_attrs(result.rdr_entry.ent_attr); ! 663: cache_entry(&(result.rdr_entry), TRUE, TRUE); ! 664: cleartext(); ! 665: xprint("Information on:\n"); ! 666: xprint(friendly_base_path); ! 667: read_print(as_print, (caddr_t) result.rdr_entry.ent_attr); ! 668: } ! 669: restart_text(); ! 670: return Okay; ! 671: } ! 672: ! 673: set_default_type() ! 674: { ! 675: int count; ! 676: DN base_name; ! 677: ! 678: if (*base_path != '\0') { ! 679: base_name = str2dn(base_path); ! 680: while (base_name->dn_parent) base_name = base_name->dn_parent; ! 681: for (count = 0; count < default_num && ! 682: strcmp(levels[count] ,base_name->dn_rdn->rdn_at-> ! 683: oa_ot.ot_stroid); ! 684: count++); ! 685: ! 686: if (count < default_num) { ! 687: av_typeindx = available_types[count]; ! 688: typeindx = defaults[count]; ! 689: } else { ! 690: av_typeindx = available_types[0]; ! 691: typeindx = defaults[0]; ! 692: } ! 693: } else { ! 694: for(count = 0; count < default_num && strcmp(levels[count], "@"); count++); ! 695: if (count < default_num) { ! 696: av_typeindx = available_types[count]; ! 697: typeindx = defaults[count]; ! 698: } else { ! 699: av_typeindx = available_types[0]; ! 700: typeindx = defaults[0]; ! 701: } ! 702: } ! 703: typetoggled = 0; ! 704: } ! 705: ! 706: /* These are the functions called by the list level widgets */ ! 707: ! 708: dsEnqError ! 709: list_start() ! 710: { ! 711: struct ds_search_arg search_arg; ! 712: struct ds_search_result result; ! 713: struct DSError error; ! 714: dsEnqError return_error; ! 715: ! 716: return_error = Okay; ! 717: ! 718: if (get_default_service (&search_arg.sra_common) != 0) { ! 719: return localdsaerror; ! 720: } ! 721: ! 722: refresh(); ! 723: ! 724: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit; ! 725: search_arg.sra_common.ca_servicecontrol.svc_options = 1; ! 726: search_arg.sra_baseobject = (*base_path != 'T'? ! 727: str2dn (base_path): ! 728: NULLDN); ! 729: search_arg.sra_eis.eis_allattributes = FALSE; ! 730: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 731: search_arg.sra_eis.eis_select = read_types; ! 732: search_arg.sra_subset = SRA_ONELEVEL; ! 733: ! 734: search_arg.sra_filter = filter_alloc(); ! 735: search_arg.sra_filter->flt_type = FILTER_NOT; ! 736: search_arg.sra_filter->flt_next = NULLFILTER; ! 737: search_arg.sra_filter->flt_un.flt_un_filter = filter_alloc(); ! 738: search_arg.sra_filter->flt_un.flt_un_filter->flt_type = FILTER_ITEM; ! 739: search_arg.sra_filter->flt_un.flt_un_filter->flt_next = NULLFILTER; ! 740: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_type ! 741: = FILTERITEM_EQUALITY; ! 742: ! 743: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. ! 744: fi_un_ava.ava_type = AttrT_new("2.5.4.0"); ! 745: ! 746: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. ! 747: fi_un_ava.ava_value = ! 748: str2AttrV("dsa", search_arg.sra_filter->flt_un.flt_un_filter-> ! 749: flt_un.flt_un_item.fi_un.fi_un_ava.ava_type-> ! 750: oa_syntax); ! 751: ! 752: #ifndef NO_STATS ! 753: LLOG (log_stat,LLOG_NOTICE,("search +%s,extent %d, val objectClass != dsa",base_path,search_arg.sra_subset)); ! 754: #endif ! 755: ! 756: if (search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item. ! 757: fi_un.fi_un_ava.ava_value == NULLAttrV) { ! 758: return_error = localdsaerror; ! 759: } else if (ds_search (&search_arg,&error,&result) != DS_OK) { ! 760: free_seq(dnseq); ! 761: dnseq = NULLDS; ! 762: dn_number = 0; ! 763: switch (error.dse_type) { ! 764: case DSE_LOCALERROR: ! 765: return_error = duaerror; ! 766: break; ! 767: case DSE_REMOTEERROR: ! 768: return_error = localdsaerror; ! 769: break; ! 770: case DSE_ATTRIBUTEERROR: ! 771: return_error = attributerror; ! 772: break; ! 773: case DSE_REFERRAL: ! 774: case DSE_DSAREFERRAL: ! 775: return_error = remotedsaerror; ! 776: break; ! 777: case DSE_SECURITYERROR: ! 778: return_error = security; ! 779: break; ! 780: case DSE_NAMEERROR: ! 781: return_error = namerror; ! 782: break; ! 783: default: ! 784: return_error = localdsaerror; ! 785: break; ! 786: } ! 787: } else { ! 788: correlate_search_results (&result); ! 789: if (result.CSR_entries != NULLENTRYINFO) { ! 790: register EntryInfo *ptr; ! 791: ! 792: if (result.CSR_common.cr_aliasdereferenced) { ! 793: /*quipu_print (dn_print, (caddr_t) result.CSR_object);*/ ! 794: dn_free (result.CSR_object); ! 795: } ! 796: ! 797: free_seq(dnseq); ! 798: dnseq = NULLDS; ! 799: dn_number = 0; ! 800: ! 801: for (ptr = result.CSR_entries; ptr != NULLENTRYINFO; ! 802: ptr = ptr->ent_next) { ! 803: dn_number++; ! 804: dn2str ((caddr_t)ptr->ent_dn, goto_path); ! 805: add_seq (&dnseq, goto_path); ! 806: cache_entry (ptr,TRUE,TRUE); ! 807: } ! 808: if (!dn_number) return_error = nothingfound; ! 809: } else if (result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) { ! 810: free_seq(dnseq); ! 811: dnseq = NULLDS; ! 812: dn_number = 0; ! 813: } ! 814: ! 815: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) { ! 816: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) { ! 817: free_seq(dnseq); ! 818: dnseq = NULLDS; ! 819: dn_number = 0; ! 820: return_error = timelimit; ! 821: } else return_error = listsizelimit; ! 822: } ! 823: entryinfo_free(result.CSR_entries, 0); ! 824: } ! 825: ! 826: entry_number = dn_number; ! 827: filter_free(search_arg.sra_filter); ! 828: return return_error; ! 829: } ! 830: ! 831: rdn2str(ptr,cptr) ! 832: caddr_t ptr; ! 833: char * cptr; ! 834: { ! 835: PS ps; ! 836: char buffer [RESBUF]; ! 837: ! 838: if ((ps = ps_alloc(str_open)) == NULLPS) { ! 839: return ; ! 840: } ! 841: if (str_setup(ps, buffer, RESBUF, 1) == NOTOK) { ! 842: return ; ! 843: } ! 844: rdn_print(ps, (RDN) ptr, READOUT); ! 845: ! 846: ps_free(ps); ! 847: *ps->ps_ptr = 0; ! 848: ! 849: (void) strcpy(cptr, buffer); ! 850: } ! 851: ! 852: ! 853: /* search ... */ ! 854: ! 855: dsEnqError ! 856: srch_start() ! 857: { ! 858: struct ds_search_arg search_arg; ! 859: struct ds_search_result result; ! 860: struct DSError error; ! 861: dsEnqError return_error; ! 862: char *str = base_path; ! 863: ! 864: if (*mvalue == '\0') { ! 865: return list_start(); ! 866: } ! 867: ! 868: if (get_default_service (&search_arg.sra_common) != 0) { ! 869: return nothingfound; ! 870: } ! 871: ! 872: refresh(); ! 873: ! 874: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit; ! 875: search_arg.sra_common.ca_servicecontrol.svc_options = 1; ! 876: search_arg.sra_baseobject = (*base_path != 'T'? ! 877: str2dn (base_path): ! 878: NULLDN); ! 879: search_arg.sra_eis.eis_allattributes = FALSE; ! 880: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 881: search_arg.sra_eis.eis_select = read_types; ! 882: ! 883: while (*str != '\0' && *str != '@') str++; ! 884: ! 885: search_arg.sra_subset = ((*base_path != 'T' && *str == '@')? ! 886: SRA_WHOLESUBTREE: ! 887: SRA_ONELEVEL); ! 888: search_arg.sra_filter = ! 889: make_filter(filt_arr[typeindx]); ! 890: ! 891: #ifndef NO_STATS ! 892: LLOG (log_stat,LLOG_NOTICE,("search +%s, extent %d, val %s",base_path,search_arg.sra_subset,mvalue)); ! 893: #endif ! 894: ! 895: if(ds_search (&search_arg,&error,&result) != DS_OK) { ! 896: /* deal with error */ ! 897: free_seq(dnseq); ! 898: dnseq = NULLDS; ! 899: dn_number = 0; ! 900: switch (error.dse_type) { ! 901: case DSE_LOCALERROR: ! 902: return_error = duaerror; ! 903: break; ! 904: case DSE_REMOTEERROR: ! 905: return_error = localdsaerror; ! 906: break; ! 907: case DSE_ATTRIBUTEERROR: ! 908: return_error = attributerror; ! 909: break; ! 910: case DSE_REFERRAL: ! 911: case DSE_DSAREFERRAL: ! 912: return_error = remotedsaerror; ! 913: break; ! 914: case DSE_SECURITYERROR: ! 915: return_error = security; ! 916: break; ! 917: case DSE_NAMEERROR: ! 918: return_error = namerror; ! 919: break; ! 920: default: ! 921: return_error = localdsaerror; ! 922: break; ! 923: } ! 924: } else { ! 925: correlate_search_results (&result); ! 926: ! 927: if (result.CSR_entries != NULLENTRYINFO) { ! 928: register EntryInfo *ptr; ! 929: ! 930: if (result.CSR_common.cr_aliasdereferenced) { ! 931: quipu_print (dn_print, (caddr_t) result.CSR_object); ! 932: dn_free (result.CSR_object); ! 933: } ! 934: return_error = Okay; ! 935: free_seq(dnseq); ! 936: dnseq = NULLDS; ! 937: dn_number = 0; ! 938: for (ptr = result.CSR_entries; ! 939: ptr != NULLENTRYINFO; ptr = ptr->ent_next){ ! 940: dn_number++; ! 941: dn2str ((caddr_t) ptr->ent_dn, goto_path); ! 942: add_seq (&dnseq, goto_path); ! 943: cache_entry (ptr,TRUE,TRUE); ! 944: } ! 945: if (!dn_number) return_error = nothingfound; ! 946: } else if(result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) { ! 947: free_seq(dnseq); ! 948: dnseq = NULLDS; ! 949: dn_number = 0; ! 950: return_error = nothingfound; ! 951: } ! 952: ! 953: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) ! 954: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) { ! 955: free_seq(dnseq); ! 956: dnseq = NULLDS; ! 957: dn_number = 0; ! 958: return_error = timelimit; ! 959: } else return_error = listsizelimit; ! 960: entryinfo_free(result.CSR_entries, 0); ! 961: } ! 962: entry_number = dn_number; ! 963: filter_free(search_arg.sra_filter); ! 964: return return_error; ! 965: } ! 966: ! 967: static dn2str (ptr,cptr) ! 968: caddr_t ptr; ! 969: char * cptr; ! 970: { ! 971: PS ps; ! 972: char buffer [RESBUF]; ! 973: ! 974: if((ps = ps_alloc(str_open)) == NULLPS) return ; ! 975: ! 976: if(str_setup(ps, buffer, RESBUF, 1) == NOTOK) return ; ! 977: ! 978: dn_print(ps, (DN) ptr, EDBOUT); ! 979: *ps->ps_ptr = 0; ! 980: ! 981: ps_free (ps); ! 982: ! 983: (void) strcpy(cptr, buffer); ! 984: } ! 985: ! 986: ! 987: read_print(func,ptr) ! 988: int (*func) (); ! 989: caddr_t ptr; ! 990: { ! 991: PS ps; ! 992: char buffer [RESBUF]; ! 993: char save; ! 994: int i, size; ! 995: register char *str, *sptr; ! 996: ! 997: if ((ps = ps_alloc (str_open)) == NULLPS) return ; ! 998: ! 999: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ; ! 1000: ! 1001: (*func) (ps, ptr, READOUT); ! 1002: *ps->ps_ptr = 0; ! 1003: ! 1004: ps_free(ps); ! 1005: str = buffer ; ! 1006: sptr = str; ! 1007: size = strlen(buffer); ! 1008: ! 1009: xprint("\n"); ! 1010: for (i = 0; i <= size; i++, sptr++) ! 1011: if (*sptr == '\n' || *sptr == '\0') { ! 1012: save = *sptr ; ! 1013: *sptr = '\0'; ! 1014: ! 1015: if (mailformat == greybook && indexstring(str, "rfc822") >= 0) ! 1016: (void) rfc2jnt(str); ! 1017: ! 1018: *sptr = '\n'; ! 1019: str = sptr+1; ! 1020: *sptr = save; ! 1021: } ! 1022: ! 1023: xprint(buffer); ! 1024: } ! 1025: ! 1026: /*ARGSUSED*/ ! 1027: podphoto(ps, picture, format) ! 1028: PS ps; ! 1029: PE picture; ! 1030: int format; ! 1031: { ! 1032: PS sps; ! 1033: ! 1034: if ((sps = ps_alloc (str_open)) == NULLPS) ! 1035: return; ! 1036: if (str_setup (sps,NULLCP,LINESIZE,0) == NOTOK) { ! 1037: ps_free (sps); ! 1038: return; ! 1039: } ! 1040: ! 1041: two_passes = 0; ! 1042: ! 1043: (void) pe2ps (sps,picture); ! 1044: decode_t4 (sps->ps_base, "photo", 0); ! 1045: decode_t4 (sps->ps_base, "photo", 0); ! 1046: ! 1047: ps_print (ps,"(see below)"); ! 1048: ps_free (sps); ! 1049: } ! 1050: ! 1051: quipu_print (func,ptr) ! 1052: int (*func) (); /* assumes func (PS ,dataptr,(int) format); */ ! 1053: caddr_t ptr; ! 1054: { ! 1055: /* log info to pstream */ ! 1056: PS ps; ! 1057: char buffer [RESBUF]; ! 1058: register char *str, *sptr; ! 1059: char save; ! 1060: ! 1061: if ((ps = ps_alloc (str_open)) == NULLPS) return ; ! 1062: ! 1063: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ; ! 1064: ! 1065: (*func) (ps,ptr,READOUT); ! 1066: *ps->ps_ptr = 0; ! 1067: ! 1068: ps_free (ps); ! 1069: ! 1070: str = buffer; ! 1071: do { ! 1072: for (sptr = str; *sptr != '\0'; sptr++); ! 1073: save = *sptr; ! 1074: *sptr = 0; ! 1075: xprint (str); ! 1076: *sptr = save; ! 1077: str = sptr; ! 1078: } while (*sptr != '\0'); ! 1079: } ! 1080: ! 1081: quipu_error (err) ! 1082: struct DSError * err; ! 1083: { ! 1084: PS ps; ! 1085: char buffer [RESBUF]; ! 1086: ! 1087: if ((ps = ps_alloc(str_open)) == NULLPS) return ; ! 1088: ! 1089: if (str_setup (ps, buffer, RESBUF, 1) == NOTOK) return ; ! 1090: ds_error(ps, err); ! 1091: ! 1092: *ps->ps_ptr = 0; ! 1093: xprint(buffer); ! 1094: } ! 1095: ! 1096: make_friendly(fstr, str) ! 1097: char *fstr; ! 1098: register char *str; ! 1099: { ! 1100: register char *end_ptr; ! 1101: char *string; ! 1102: char save; ! 1103: int count, seqnum = 0, mapped; ! 1104: ! 1105: *fstr = '\0'; ! 1106: if (*str == '\0') { ! 1107: *fstr = '\0'; ! 1108: return; ! 1109: } ! 1110: ! 1111: while (*str != '\0') { ! 1112: end_ptr = str; ! 1113: while (*end_ptr != '=') end_ptr++; ! 1114: while (!isalpha(*end_ptr)) end_ptr--; ! 1115: end_ptr++; ! 1116: save = *end_ptr; ! 1117: *end_ptr = '\0'; ! 1118: ! 1119: mapped = FALSE; ! 1120: for (count = 0; count < fname_num; count++) { ! 1121: seqnum = 0; ! 1122: while (!mapped && ! 1123: (string = get_from_seq(seqnum++, name_map[count]->names))) ! 1124: if (!strcmp(string, str)) { ! 1125: (void) strcat(fstr, name_map[count]->fname); ! 1126: count = fname_num; ! 1127: mapped = TRUE; ! 1128: } ! 1129: } ! 1130: ! 1131: if (!mapped) ! 1132: (void) strcat(fstr, str); ! 1133: ! 1134: (void) strcat(fstr, " = "); ! 1135: ! 1136: *end_ptr++ = save; ! 1137: str = end_ptr; ! 1138: while (!(isalpha(*str))) str++; ! 1139: ! 1140: end_ptr = str; ! 1141: while (*end_ptr != '@' && *end_ptr != '\0') end_ptr++; ! 1142: ! 1143: save = *end_ptr; ! 1144: *end_ptr = '\0'; ! 1145: (void) strcat(fstr, str); ! 1146: *end_ptr = save; ! 1147: ! 1148: str = end_ptr; ! 1149: if (*str != '\0') { ! 1150: (void) strcat(fstr, ", "); ! 1151: str++; ! 1152: } ! 1153: } ! 1154: } ! 1155: ! 1156: make_friendly_rdn(friendly, object, base) ! 1157: char *friendly; ! 1158: char *object, *base; ! 1159: { ! 1160: register char *front; ! 1161: int count; ! 1162: ! 1163: *friendly = '\0'; ! 1164: ! 1165: front = base; ! 1166: count = 0; ! 1167: ! 1168: if (showseq != backseq) { ! 1169: while (*front != '\0') ! 1170: if (*front != '=') front++; ! 1171: else {count++; front++;} ! 1172: } else ! 1173: count = 0; ! 1174: ! 1175: front = object; ! 1176: ! 1177: while (count && *front != '\0') ! 1178: if (*front != '=') front++; ! 1179: else {count--; front++;} ! 1180: ! 1181: while (front != object && *front != '@') front++; ! 1182: while (!isalpha(*front)) front++; ! 1183: ! 1184: make_friendly(friendly, front); ! 1185: } ! 1186: ! 1187: goto_addr() ! 1188: { ! 1189: register char *str; ! 1190: int count = 0; ! 1191: ! 1192: set_default_type(); ! 1193: ! 1194: make_friendly(friendly_base_path, base_path); ! 1195: ! 1196: str = get_from_seq(count+1, backseq); ! 1197: while (count < back_buf_num && strcmp(str, base_path)){ ! 1198: count++; ! 1199: str = get_from_seq(count+1, backseq); ! 1200: } ! 1201: ! 1202: if (count == back_buf_num) { ! 1203: add_seq(&backseq, base_path); ! 1204: back_buf_num++; ! 1205: add_to_history(friendly_base_path, back_buf_num); ! 1206: } ! 1207: } ! 1208: ! 1209: clear_dnseq() ! 1210: { ! 1211: free_seq(dnseq); ! 1212: dnseq = NULLDS; ! 1213: dn_number = 0; ! 1214: } ! 1215: ! 1216: ! 1217: int ! 1218: isleaf(name) ! 1219: char *name; ! 1220: { ! 1221: struct ds_list_arg list_arg; ! 1222: struct ds_list_result list_result; ! 1223: ! 1224: struct ds_read_arg read_arg; ! 1225: struct ds_read_result read_result; ! 1226: ! 1227: struct DSError list_error, read_error; ! 1228: ! 1229: char entry_str[1024]; ! 1230: ! 1231: if (get_default_service (&read_arg.rda_common) != 0) return(1); ! 1232: ! 1233: read_arg.rda_common.ca_servicecontrol.svc_options = 1; ! 1234: read_arg.rda_eis.eis_allattributes = FALSE; ! 1235: read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 1236: read_arg.rda_eis.eis_select = oclass; ! 1237: ! 1238: read_arg.rda_object = (*name? str2dn(name): NULLDN); ! 1239: if (ds_read (&read_arg,&read_error,&read_result) == DS_OK) { ! 1240: if (read_result.rdr_entry.ent_attr == NULLATTR) return(0); ! 1241: entry2str((caddr_t) read_result.rdr_entry.ent_attr, entry_str, 1024); ! 1242: if (issubstr(entry_str, "NonLeaf")) return(0); ! 1243: } ! 1244: ! 1245: if (get_default_service (&list_arg.lsa_common) != 0) return(1); ! 1246: list_arg.lsa_common.ca_servicecontrol.svc_sizelimit = 1; ! 1247: list_arg.lsa_common.ca_servicecontrol.svc_options = 1; ! 1248: list_arg.lsa_object = (*name? str2dn(name): NULLDN); ! 1249: if (ds_list (&list_arg, &list_error, &list_result) == DS_OK) { ! 1250: if (list_result.lsr_subordinates) return(0); ! 1251: else return(1); ! 1252: } else ! 1253: return (1); ! 1254: } ! 1255: ! 1256: entry2str(ptr, cptr, size) ! 1257: caddr_t ptr; ! 1258: char *cptr; ! 1259: int size; ! 1260: { ! 1261: PS ps; ! 1262: ! 1263: if ((ps = ps_alloc (str_open)) == NULLPS) return ; ! 1264: if (str_setup (ps, cptr, size, 1) == NOTOK) return ; ! 1265: ! 1266: as_print(ps, ptr, READOUT); ! 1267: *ps->ps_ptr = 0; ! 1268: ! 1269: ps_free(ps); ! 1270: } ! 1271: ! 1272: int issubstr(str, substr) ! 1273: char *str; ! 1274: char *substr; ! 1275: { ! 1276: register char *sptr; ! 1277: char c; ! 1278: int substrlen = strlen(substr); ! 1279: int count; ! 1280: ! 1281: if (*substr == '\0' || *str == '\0') return(0); ! 1282: ! 1283: sptr = str; ! 1284: c = *substr; ! 1285: ! 1286: while (1) { ! 1287: while (*sptr != '\0' && *sptr != c) sptr++; ! 1288: if (*sptr == '\0') return(0); ! 1289: for (count = 0; count >= 0 && count < substrlen; count++) { ! 1290: if (sptr[count] == '\0') return(0); ! 1291: else if (substr[count] != sptr[count]) count = -2; ! 1292: } ! 1293: if (count == substrlen) return(1); ! 1294: } ! 1295: } ! 1296: ! 1297: int indexstring(string, substring) ! 1298: char *string, ! 1299: *substring; ! 1300: { ! 1301: register char *sub, *str; ! 1302: char c, s; ! 1303: int indx = 0; ! 1304: ! 1305: while (1) { ! 1306: str = string + indx;; ! 1307: if (*str == '\0') return(-1); ! 1308: sub = substring; ! 1309: ! 1310: if (*str == *sub) { ! 1311: s = *str; ! 1312: c = *sub; ! 1313: while(c == s && c != '\0') { ! 1314: c = *++sub; ! 1315: s = *++str; ! 1316: } ! 1317: ! 1318: if (c == '\0') return((int) indx); ! 1319: else if(s == '\0') return(-1); ! 1320: } ! 1321: indx++; ! 1322: } ! 1323: } ! 1324: ! 1325: rfc2jnt(string) ! 1326: char *string; ! 1327: { ! 1328: char reversed[STRINGLEN], front[STRINGLEN]; ! 1329: register char *part; ! 1330: ! 1331: reversed[0] = '\0'; ! 1332: part = string + strlen(string); ! 1333: ! 1334: if (*part != '\0') return; ! 1335: ! 1336: while(1) { ! 1337: while (*part != '.' && *part != '@') --part; ! 1338: ! 1339: if (*part == '.') { ! 1340: if (reversed[0] != '\0') (void) strcat(reversed, "."); ! 1341: part++; ! 1342: (void) strcat(reversed, part); ! 1343: *--part = '\0'; ! 1344: --part; ! 1345: } else { ! 1346: part++; ! 1347: (void) strcat(reversed, "."); ! 1348: (void) strcat(reversed, part); ! 1349: *part-- = '\0'; ! 1350: while (!isspace(*part)) --part; ! 1351: ++part; ! 1352: (void) strcpy(front, part); ! 1353: (void) strcpy(string, "mailbox - "); ! 1354: (void) strcat(string, front); ! 1355: (void) strcat(string, reversed); ! 1356: return; ! 1357: } ! 1358: } ! 1359: } ! 1360: ! 1361: struct attrcomp * ! 1362: sort_attrs(entry_attrs) ! 1363: struct attrcomp *entry_attrs; ! 1364: { ! 1365: struct attrcomp *last, *next, *curr, *first, *firstn; ! 1366: ! 1367: first = curr = entry_attrs; ! 1368: firstn = last = next = 0; ! 1369: ! 1370: while (curr) ! 1371: if (!strcmp("2.5.4.3", curr->attr_type->oa_ot.ot_stroid) || ! 1372: !strcmp("2.5.4.4", curr->attr_type->oa_ot.ot_stroid) || ! 1373: !strcmp("0.9.2342.19200300.100.1.3", ! 1374: curr->attr_type->oa_ot.ot_stroid) || ! 1375: !strcmp("0.9.2342.19200300.100.1.2", ! 1376: curr->attr_type->oa_ot.ot_stroid) || ! 1377: !strcmp("2.5.4.20", curr->attr_type->oa_ot.ot_stroid)) { ! 1378: ! 1379: if (first == curr) first = curr->attr_link; ! 1380: ! 1381: if (next) ! 1382: next->attr_link = curr; ! 1383: else ! 1384: firstn = curr; ! 1385: ! 1386: next = curr; ! 1387: ! 1388: if (last) ! 1389: last->attr_link = curr->attr_link; ! 1390: ! 1391: curr = curr->attr_link; ! 1392: next->attr_link = 0; ! 1393: } else { ! 1394: last = curr; ! 1395: curr = curr->attr_link; ! 1396: } ! 1397: ! 1398: if (next) { ! 1399: next->attr_link = first; ! 1400: return firstn; ! 1401: } else ! 1402: return first; ! 1403: } ! 1404:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.