|
|
1.1 ! root 1: /* $Header: /f/osi/others/quipu/uips/xd/RCS/calls.c,v 7.2 90/07/27 08:45:53 mrose Exp $ */ ! 2: #ifndef lint ! 3: static char *rcsid = "$Id: calls.c,v 7.2 90/07/27 08:45:53 mrose Exp $"; ! 4: #endif ! 5: /* ! 6: $Log: calls.c,v $ ! 7: * Revision 7.2 90/07/27 08:45:53 mrose ! 8: * update ! 9: * ! 10: * Revision 7.1 90/07/09 14:42:12 mrose ! 11: * sync ! 12: * ! 13: * Revision 7.0 90/06/12 13:10:48 mrose ! 14: * *** empty log message *** ! 15: * ! 16: * Revision 1.5 90/04/26 10:22:34 emsrssn ! 17: * Installation fixed ! 18: * ! 19: * ! 20: * Revision 1.4 90/04/25 17:28:04 emsrssn ! 21: * Lint tidy up ! 22: * ! 23: * ! 24: * Revision 1.3 90/04/19 13:54:04 emsrssn ! 25: * keyboard accelerator now activates button highlight. ! 26: * ! 27: * search types available is dependent on current position ! 28: * to prevent unreasonable searches. ! 29: * ! 30: * the help popup changes automatically depending on the ! 31: * position of the cursor ! 32: * ! 33: * buttons remain a fixed size when the application is ! 34: * resized ! 35: * ! 36: * command line options are now handled properly ! 37: * ! 38: * logging added ! 39: * ! 40: * "reads" are now sorted to show mail address at top etc. ! 41: * ! 42: * ! 43: * Revision 1.2 90/03/09 15:57:27 emsrssn ! 44: * First public distribution ! 45: * ! 46: * ! 47: * Revision 1.1 90/03/08 13:18:36 emsrssn ! 48: * Initial revision ! 49: * ! 50: * ! 51: */ ! 52: ! 53: #include "manifest.h" ! 54: #include "quipu/util.h" ! 55: #include "quipu/common.h" ! 56: #include "quipu/entry.h" ! 57: #include <malloc.h> ! 58: #include "usr.dirent.h" ! 59: #include "tailor.h" ! 60: #include "sequence.h" ! 61: #include "filt.h" ! 62: #include "y.tab.h" ! 63: #include "symtab.h" ! 64: ! 65: struct attrcomp * sort_attrs(); ! 66: static dn2str (); ! 67: ! 68: #define RESBUF 10000 ! 69: ! 70: PS opt; ! 71: Attr_Sequence read_types = 0, read_types2; ! 72: ! 73: table_entry symtab = 0; ! 74: int typetoggled = 0; ! 75: ! 76: int dn_print (), rdn_print(), as_print(), avs_comp_print(); ! 77: ! 78: char bound = FALSE; /* indication of whether bound */ ! 79: char * TidyString(); ! 80: ! 81: D_seq dnseq = NULLDS, backseq = NULLDS, showseq = NULLDS; ! 82: int entry_number, back_buf_num, element_num; ! 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: extern Filter make_filter(); ! 114: extern int Switch_On_Result_Update(); ! 115: extern int Switch_Off_Result_Update(); ! 116: extern void Clear_Results(); ! 117: extern void xprint(); ! 118: ! 119: extern char *local_dit; ! 120: ! 121: #ifndef NO_STATS ! 122: extern LLog *log_stat; ! 123: #endif ! 124: ! 125: ! 126: /* These are used as the data for the binding connection */ ! 127: char passwd[STRINGLEN]; ! 128: extern char * myname; ! 129: ! 130: extern int asizelimit; ! 131: DN user_name; ! 132: ! 133: char * addobj = NULLCP; ! 134: Filter search_filter; ! 135: FILE *file; ! 136: char *file_names[MAXTYPES]; ! 137: char dua_help_dir[256]; ! 138: ! 139: char *get_strioid(ptr) ! 140: register char *ptr; ! 141: { ! 142: register char *end_ptr; ! 143: ! 144: while(*ptr == '"') ptr++; ! 145: while(*ptr != '"') ptr++; ! 146: ! 147: while(*ptr > '9' || *ptr < '0') ptr++; ! 148: ! 149: end_ptr = ptr; ! 150: while(*end_ptr != '\n') end_ptr++; ! 151: ! 152: *end_ptr = '\0'; ! 153: return ptr; ! 154: } ! 155: ! 156: ! 157: user_tailor () ! 158: { ! 159: char *part1; ! 160: char *part2; ! 161: char *getenv (); ! 162: char *ptr = "/.quipurc"; ! 163: char *config_dir = "/.duaconfig/"; ! 164: char *isode_config_dir = "xd/duaconfig/"; ! 165: char *type_dir = "filterTypes/"; ! 166: char *read_File = "readTypes"; ! 167: char *type_defaults = "typeDefaults"; ! 168: ! 169: char Dish_Home[BUFSIZ]; ! 170: char read_Home[BUFSIZ]; ! 171: char type_Home[BUFSIZ]; ! 172: char type_defaults_Home[BUFSIZ]; ! 173: ! 174: char stroid_buf[BUFSIZ]; ! 175: ! 176: DIR *dir; ! 177: ! 178: struct dirent *dir_ent; ! 179: ! 180: char Read_in_Stuff[STRINGLEN]; ! 181: char *p, ! 182: *TidyString(), ! 183: *SkipSpace(), ! 184: *end; ! 185: ! 186: int count, n, num; ! 187: int tempints[MAXTYPES]; ! 188: ! 189: (void) strcpy(dua_help_dir, isodefile("xd/helpdir/", 0)); ! 190: ! 191: ! 192: if ((opt = ps_alloc (std_open)) == NULLPS) ! 193: fatal (-1,"ps_alloc failed"); ! 194: if (std_setup (opt,stdout) == NOTOK) ! 195: fatal (-1,"std_setup failed"); ! 196: ! 197: namestr[0] = '\0'; ! 198: *passwd = '\0'; ! 199: cache[0] = '\0'; ! 200: ! 201: (void) strcpy (Dish_Home, getenv ("HOME")); ! 202: (void) strcpy(read_Home, Dish_Home); ! 203: (void) strcpy(type_Home, Dish_Home); ! 204: ! 205: (void) strcat(Dish_Home, ptr); ! 206: (void) strcat(read_Home, config_dir); ! 207: (void) strcat(read_Home, read_File); ! 208: (void) strcat(type_Home, config_dir); ! 209: (void) strcat(type_Home, type_dir); ! 210: ! 211: if (!(dir = opendir(type_Home))) { ! 212: (void) strcpy(type_Home, isodefile(isode_config_dir,0)); ! 213: (void) strcat(type_Home, type_dir); ! 214: if(!(dir = opendir(type_Home))) { ! 215: (void) strcpy(type_Home, "./"); ! 216: (void) strcat(type_Home, isode_config_dir); ! 217: (void) strcat(type_Home, type_dir); ! 218: if(!(dir = opendir(type_Home))) { ! 219: (void) printf("Can't find directory %s!\n", type_dir); ! 220: quit(1); ! 221: } ! 222: } ! 223: } ! 224: ! 225: rewinddir(dir); ! 226: filt_num = 0; ! 227: while(dir_ent = readdir(dir)) { ! 228: if (!(strncmp(dir_ent->d_name, "Type_", 5))) { ! 229: file_names[filt_num] = ! 230: (char *) malloc((unsigned int) (strlen(dir_ent->d_name) + strlen(type_Home) + 2) ); ! 231: (void) strcpy(file_names[filt_num], type_Home); ! 232: (void) strcat(file_names[filt_num], dir_ent->d_name); ! 233: filt_num++; ! 234: } ! 235: } ! 236: (void) closedir(dir); ! 237: ! 238: if ((file = fopen (Dish_Home, "r")) == 0); ! 239: else { ! 240: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) { ! 241: p = SkipSpace (Read_in_Stuff); ! 242: if (( *p == '#') || (*p == '\0')) ! 243: continue; /* ignore comments and blanks */ ! 244: ! 245: part1 = p; ! 246: if ((part2 = index (p,':')) == NULLCP) ! 247: continue; /* ignore it */ ! 248: ! 249: *part2++ = '\0'; ! 250: part2 = TidyString(part2); ! 251: ! 252: if (strcmp (part1, "username") == 0) ! 253: (void) strcpy (namestr, part2); ! 254: else if (strcmp (part1, "password") == 0) ! 255: (void) strcpy (passwd, part2); ! 256: else if (lexequ (part1, "dsap") == 0) ! 257: (void) tai_string (part2); ! 258: else if (lexequ (part1, "isode") == 0) { ! 259: char * split; ! 260: if ((split = index (part2,' ')) != NULLCP) { ! 261: *split++ = 0; ! 262: (void) isodesetvar (part2,split,0); ! 263: } ! 264: } else if (strcmp (part1, "service") == 0) ! 265: new_service (part2); ! 266: } ! 267: isodexport (NULLCP); ! 268: (void) fclose(file); ! 269: } ! 270: ! 271: if (!(file = fopen(read_Home, "r"))) { ! 272: (void) strcpy(read_Home, isodefile(isode_config_dir,0)); ! 273: (void) strcat(read_Home, read_File); ! 274: if (!(file = fopen(read_Home, "r"))) { ! 275: (void) strcpy(read_Home, "./"); ! 276: (void) strcat(read_Home, isode_config_dir); ! 277: (void) strcat(read_Home, read_File); ! 278: if (!(file = fopen(read_Home, "r"))) { ! 279: (void) printf("Can't find read file (%s)!\n", read_Home); ! 280: quit(1); ! 281: } ! 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: (void) printf("Can't find file %s!\n", (char *) file_names[curr_filt]); ! 302: quit(1); ! 303: } ! 304: filtvalue[curr_filt] = (char *) malloc(STRINGLEN); ! 305: *filtvalue[curr_filt] = '\0'; ! 306: ! 307: yyparse(); ! 308: (void) fclose(file); ! 309: } ! 310: filttype[curr_filt] = NULLCP; ! 311: for (count = 0; count < filt_num; count++) ! 312: free(file_names[count]); ! 313: ! 314: if (!(file = fopen(type_defaults_Home, "r"))) { ! 315: (void) strcpy(type_defaults_Home, isodefile(isode_config_dir,0)); ! 316: (void) strcat(type_defaults_Home, type_defaults); ! 317: if (!(file = fopen(type_defaults_Home, "r"))) { ! 318: (void) strcpy(type_defaults_Home, "./Xd/duaconfig/"); ! 319: (void) strcat(type_defaults_Home, type_defaults); ! 320: if (!(file = fopen(type_defaults_Home, "r"))) { ! 321: (void) fprintf(stderr, "Can't open typeDefaults file\n"); ! 322: quit(1); ! 323: } ! 324: } ! 325: } ! 326: ! 327: default_num = 0; ! 328: while (fgets (Read_in_Stuff, STRINGLEN, file) != 0) { ! 329: p = SkipSpace(Read_in_Stuff); ! 330: if (( *p == '#') || (*p == '\0')) ! 331: continue; ! 332: ! 333: part1 = p; ! 334: if ((part2 = index (p,':')) == NULLCP) ! 335: continue; ! 336: ! 337: end = part2 - 1; ! 338: while (isspace(*end)) end--; ! 339: *++end = '\0'; ! 340: ! 341: *part2++ = '\0'; ! 342: ! 343: while (isspace(*part2)) part2++; ! 344: end = part2; ! 345: ! 346: while (!isspace(*end) && *end != ',' && *end != ':') end++; ! 347: ! 348: count = 0; ! 349: while (*part2 != ':') { ! 350: n = 0; ! 351: while (n < filt_num && strncmp(filttype[n], part2, ! 352: (int) (end - part2))) n++; ! 353: ! 354: if (n == filt_num) { ! 355: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 356: quit(1); ! 357: } else { ! 358: tempints[count] = n; ! 359: count++; ! 360: part2 = end; ! 361: while (!isalpha(*part2) && *part2 != ':' && part2 != '\0') part2++; ! 362: ! 363: if (*part2 == '\0') { ! 364: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 365: quit(1); ! 366: } ! 367: ! 368: if (*part2 != ':') { ! 369: while (!isalpha(*part2)) part2++; ! 370: end = part2; ! 371: while (!isspace(*end) && *end != ',' && ! 372: *end != ':' && *end != '\0') end++; ! 373: if (*end == '\0') { ! 374: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 375: quit(1); ! 376: } ! 377: } else end = part2; ! 378: } ! 379: } ! 380: ! 381: if (*end == ':') { ! 382: while(isspace(*++end)); ! 383: p = end; ! 384: while(!isspace(*++end)); ! 385: *end = '\0'; ! 386: ! 387: n = 0; ! 388: while (n < filt_num && strcmp(filttype[n], p)) n++; ! 389: ! 390: if (n == filt_num) { ! 391: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 392: quit(1); ! 393: } else { ! 394: num = 0; ! 395: while (num < count && n != tempints[num]) num++; ! 396: if (num == count) { ! 397: (void) fprintf(stderr, "Parsing error in typeDefaults file!"); ! 398: quit(1); ! 399: } ! 400: } ! 401: ! 402: defaults[default_num] = n; ! 403: ! 404: levels[default_num] = malloc((unsigned int) (strlen(part1) + 1) ); ! 405: (void) strcpy(levels[default_num], part1); ! 406: available_types[default_num] = ! 407: (int *) malloc((unsigned int) (sizeof(int) * (count+1)) ); ! 408: ! 409: for (n = 0; n < count; n++) ! 410: available_types[default_num][n] = tempints[n]; ! 411: ! 412: available_types[default_num][n] = -1; ! 413: default_num++; ! 414: } ! 415: } ! 416: av_typeindx = available_types[0]; ! 417: typeindx = defaults[0]; ! 418: } ! 419: ! 420: cnnct_bind() ! 421: { ! 422: struct ds_bind_arg bindarg; ! 423: struct ds_bind_arg bindresult; ! 424: struct ds_bind_error binderr; ! 425: extern char * dsa_address, ! 426: * myname; ! 427: extern char * tailfile; ! 428: FILE * fp; ! 429: char buf [BUFSIZ]; ! 430: ! 431: if (*passwd != 0) ! 432: (void) strcpy(bindpass,"******"); ! 433: else ! 434: bindpass[0] = '\0'; ! 435: /* set dsa_address */ ! 436: dsa_address = NULLCP; ! 437: /* read tailor file to get address */ ! 438: if( (fp = fopen(isodefile(tailfile,0), "r")) == (FILE *)NULL) { ! 439: (void) printf ("Cannot open tailor file %s\n",isodefile(tailfile,0)); ! 440: return; ! 441: } ! 442: while(fgets(buf, sizeof(buf), fp) != NULLCP) ! 443: if ( (*buf != '#') && (*buf != '\n') ) ! 444: (void) tai_string (buf); ! 445: ! 446: (void) fclose(fp); ! 447: ! 448: if (dsa_address == NULLCP) ! 449: dsa_address = myname; ! 450: ! 451: /* set password */ ! 452: if (bindpass[0] != 0) { ! 453: if (strcmp (bindpass,"******") != 0) ! 454: (void) strcpy (passwd,bindpass); ! 455: } else ! 456: passwd[0] = 0; ! 457: ! 458: /* now bind */ ! 459: bindarg.dba_version = DBA_VERSION_V1988; ! 460: if (passwd[0] == 0) { ! 461: bindarg.dba_passwd_len = 0; ! 462: bindarg.dba_passwd [0] = '\0'; ! 463: } else { ! 464: bindarg.dba_passwd_len = strlen (passwd); ! 465: (void) strcpy (bindarg.dba_passwd,passwd); ! 466: } ! 467: ! 468: bindarg.dba_dn = (*namestr == 0? NULLDN: str2dn(namestr)); ! 469: ! 470: if (ds_bind (&bindarg,&binderr,&bindresult) != DS_OK) { ! 471: (void) printf (binderr.dbe_type == DBE_TYPE_SECURITY? ! 472: "Bind security error - Check name and pasword.\n": ! 473: "Bind service error - Can't contact DSA!\n"); ! 474: quit(1); ! 475: } else { ! 476: user_name = bindarg.dba_dn; ! 477: (void) strcpy (buf, "TERM"); ! 478: if(local_dit && *local_dit) ! 479: (void) strcpy(base_path, local_dit); ! 480: ! 481: #ifndef NO_STATS ! 482: LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address)); ! 483: #endif ! 484: #ifndef NO_STATS ! 485: LLOG (log_stat,LLOG_NOTICE,("xd bound to directory")); ! 486: #endif ! 487: ! 488: make_friendly(friendly_base_path, base_path); ! 489: set_default_type(); ! 490: } ! 491: entry_number = 0; ! 492: back_buf_num = 0; ! 493: backseq = dnseq = NULLDS; ! 494: } ! 495: ! 496: rd_start() ! 497: { ! 498: struct ds_read_arg read_arg; ! 499: struct ds_read_result result; ! 500: struct DSError error; ! 501: Entry read_entry; ! 502: ! 503: if (*friendly_base_path == 'T') { ! 504: free_seq(dnseq); ! 505: dnseq = NULLDS; ! 506: entry_number = 0; ! 507: return; ! 508: } ! 509: ! 510: ! 511: if (get_default_service (&read_arg.rda_common) != 0) { ! 512: xprint ("Default service error -> check your .quipurc\n"); ! 513: return ; ! 514: } ! 515: ! 516: read_arg.rda_eis.eis_allattributes = FALSE; ! 517: read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 518: read_arg.rda_eis.eis_select = read_types; ! 519: ! 520: read_arg.rda_common.ca_servicecontrol.svc_options = 1; ! 521: read_arg.rda_object = (*friendly_base_path != 'T'? str2dn(base_path): NULLDN); ! 522: if ((read_entry = ! 523: local_find_entry (read_arg.rda_object, FALSE)) != NULLENTRY) { ! 524: read_entry->e_attributes = sort_attrs(read_entry->e_attributes); ! 525: read_print (as_print, (caddr_t) read_entry->e_attributes); ! 526: return; ! 527: } ! 528: ! 529: #ifndef NO_STATS ! 530: LLOG (log_stat,LLOG_NOTICE,("read +%s",base_path)); ! 531: #endif ! 532: ! 533: if (ds_read (&read_arg,&error,&result) != DS_OK) { ! 534: /* deal with error */ ! 535: Clear_Results(); ! 536: xprint("Read error due to:\n"); ! 537: quipu_error(&error); ! 538: } else { ! 539: /* use data */ ! 540: if (result.rdr_entry.ent_attr == NULLATTR) { ! 541: free_seq(dnseq); ! 542: dnseq = NULLDS; ! 543: entry_number = 0; ! 544: xprint("No attributes found! Sorry."); ! 545: return; ! 546: } ! 547: xprint("Result of look up ...\n"); ! 548: ! 549: if (result.rdr_common.cr_aliasdereferenced) ! 550: xprint("Alias dereferenced)\n"); ! 551: ! 552: result.rdr_entry.ent_attr = sort_attrs(result.rdr_entry.ent_attr); ! 553: cache_entry(&(result.rdr_entry), TRUE, TRUE); ! 554: read_print(as_print, (caddr_t) result.rdr_entry.ent_attr); ! 555: } ! 556: } ! 557: ! 558: back_start() ! 559: { ! 560: if (!back_buf_num) { ! 561: xprint("You haven't been anywhere yet!\n"); ! 562: return; ! 563: } ! 564: element_num = back_buf_num; ! 565: showseq = backseq; ! 566: } ! 567: ! 568: widen() ! 569: { ! 570: register char *str, *sptr; ! 571: int count = 0; ! 572: ! 573: str = get_from_seq(count+1, backseq); ! 574: while (count < back_buf_num && strcmp(str, base_path)){ ! 575: count++; ! 576: str = get_from_seq(count+1, backseq); ! 577: } ! 578: if (count == back_buf_num) { ! 579: add_seq(&backseq, base_path); ! 580: back_buf_num++; ! 581: } ! 582: ! 583: str = base_path; ! 584: if (*str != 'T') { ! 585: ! 586: for (sptr = str; *sptr != '\0'; sptr++) ! 587: if (*sptr == '@') str = sptr; ! 588: ! 589: sptr = str; ! 590: typetoggled = 0; ! 591: ! 592: if (str != base_path) { ! 593: if (*--sptr == ' ') ! 594: str = sptr; ! 595: *str = '\0'; ! 596: } else ! 597: (void) strcpy(base_path, "The World"); ! 598: ! 599: make_friendly(friendly_base_path, base_path); ! 600: rd_start(); ! 601: set_default_type(); ! 602: } ! 603: } ! 604: ! 605: set_default_type() ! 606: { ! 607: int count; ! 608: DN base_name; ! 609: ! 610: if (*base_path != 'T') { ! 611: base_name = str2dn(base_path); ! 612: while (base_name->dn_parent) base_name = base_name->dn_parent; ! 613: for (count = 0; count < default_num && ! 614: strcmp(levels[count] ,base_name->dn_rdn->rdn_at-> ! 615: oa_ot.ot_stroid); ! 616: count++); ! 617: ! 618: if (count < default_num) { ! 619: av_typeindx = available_types[count]; ! 620: typeindx = defaults[count]; ! 621: } else { ! 622: av_typeindx = available_types[0]; ! 623: typeindx = defaults[0]; ! 624: } ! 625: } else { ! 626: for(count = 0; count < default_num && strcmp(levels[count], "@"); count++); ! 627: if (count < default_num) { ! 628: av_typeindx = available_types[count]; ! 629: typeindx = defaults[count]; ! 630: } else { ! 631: av_typeindx = available_types[0]; ! 632: typeindx = defaults[0]; ! 633: } ! 634: } ! 635: ! 636: make_friendly(friendly_base_path, base_path); ! 637: typetoggled = 0; ! 638: Set_Search_Type(filttype[typeindx]); /* change string in widget */ ! 639: } ! 640: ! 641: /* These are the functions called by the list level widgets */ ! 642: ! 643: list_start() ! 644: { ! 645: struct ds_search_arg search_arg; ! 646: struct ds_search_result result; ! 647: struct DSError error; ! 648: ! 649: xprint("OK, listing."); ! 650: xprint("Chugging along....."); ! 651: ! 652: if (get_default_service (&search_arg.sra_common) != 0) { ! 653: xprint ("Default service error -> check your .quipurc\n"); ! 654: return ; ! 655: } ! 656: ! 657: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = asizelimit; ! 658: search_arg.sra_common.ca_servicecontrol.svc_options = 1; ! 659: search_arg.sra_baseobject = (*base_path != 'T'? ! 660: str2dn (base_path): ! 661: NULLDN); ! 662: search_arg.sra_eis.eis_allattributes = FALSE; ! 663: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 664: search_arg.sra_eis.eis_select = read_types; ! 665: search_arg.sra_subset = SRA_ONELEVEL; ! 666: ! 667: search_arg.sra_filter = filter_alloc(); ! 668: search_arg.sra_filter->flt_type = FILTER_NOT; ! 669: search_arg.sra_filter->flt_next = NULLFILTER; ! 670: search_arg.sra_filter->flt_un.flt_un_filter = filter_alloc(); ! 671: search_arg.sra_filter->flt_un.flt_un_filter->flt_type = FILTER_ITEM; ! 672: search_arg.sra_filter->flt_un.flt_un_filter->flt_next = NULLFILTER; ! 673: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_type ! 674: = FILTERITEM_EQUALITY; ! 675: ! 676: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. ! 677: fi_un_ava.ava_type = AttrT_new("2.5.4.0"); ! 678: ! 679: search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un. ! 680: fi_un_ava.ava_value = ! 681: str2AttrV("dsa", search_arg.sra_filter->flt_un.flt_un_filter-> ! 682: flt_un.flt_un_item.fi_un.fi_un_ava.ava_type-> ! 683: oa_syntax); ! 684: ! 685: #ifndef NO_STATS ! 686: LLOG (log_stat,LLOG_NOTICE,("search +%s,extent %d, val objectClass != dsa",base_path,search_arg.sra_subset)); ! 687: #endif ! 688: ! 689: ! 690: if (search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item. ! 691: fi_un.fi_un_ava.ava_value == NULLAttrV) { ! 692: xprint("No can do. Sorry!"); ! 693: } else if (ds_search (&search_arg,&error,&result) != DS_OK) { ! 694: /* deal with error */ ! 695: free_seq(dnseq); ! 696: dnseq = NULLDS; ! 697: entry_number = 0; ! 698: xprint("Search error due to:\n"); ! 699: quipu_error(&error); ! 700: } else { ! 701: correlate_search_results (&result); ! 702: if (result.CSR_entries != NULLENTRYINFO) { ! 703: register EntryInfo *ptr; ! 704: ! 705: xprint ("Result of search ...\n"); ! 706: if (result.CSR_common.cr_aliasdereferenced) { ! 707: xprint ("(Alias dereferenced - object is "); ! 708: quipu_print (dn_print, (caddr_t) result.CSR_object); ! 709: dn_free (result.CSR_object); ! 710: xprint (")\n"); ! 711: } ! 712: ! 713: free_seq(dnseq); ! 714: dnseq = NULLDS; ! 715: entry_number = 0; ! 716: ! 717: for (ptr = result.CSR_entries; ptr != NULLENTRYINFO; ! 718: ptr = ptr->ent_next) { ! 719: entry_number++; ! 720: dn2str ((caddr_t)ptr->ent_dn, goto_path); ! 721: add_seq (&dnseq, goto_path); ! 722: cache_entry (ptr,TRUE,TRUE); ! 723: } ! 724: ! 725: if (entry_number == 1) ! 726: get_listed_object(1); ! 727: ! 728: } else if (result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) { ! 729: free_seq(dnseq); ! 730: dnseq = NULLDS; ! 731: entry_number = 0; ! 732: xprint("Nothing found. Sorry!"); ! 733: } ! 734: ! 735: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) { ! 736: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) { ! 737: free_seq(dnseq); ! 738: dnseq = NULLDS; ! 739: entry_number = 0; ! 740: xprint("(Time limit exceeded)"); ! 741: } else ! 742: xprint("(Size limit exceeded)"); ! 743: } ! 744: entryinfo_free(result.CSR_entries, 0); ! 745: } ! 746: ! 747: filter_free(search_arg.sra_filter); ! 748: } ! 749: ! 750: rdn2str(ptr,cptr) ! 751: caddr_t ptr; ! 752: char * cptr; ! 753: { ! 754: PS ps; ! 755: char buffer [RESBUF]; ! 756: ! 757: if ((ps = ps_alloc(str_open)) == NULLPS) { ! 758: return ; ! 759: } ! 760: if (str_setup(ps, buffer, RESBUF, 1) == NOTOK) { ! 761: return ; ! 762: } ! 763: rdn_print(ps, (RDN) ptr, READOUT); ! 764: ! 765: ps_free(ps); ! 766: *ps->ps_ptr = 0; ! 767: ! 768: (void) strcpy(cptr, buffer); ! 769: } ! 770: ! 771: ! 772: /* search ... */ ! 773: ! 774: srch_start() ! 775: { ! 776: struct ds_search_arg search_arg; ! 777: struct ds_search_result result; ! 778: struct DSError error; ! 779: char *str = base_path; ! 780: ! 781: if (*mvalue == '\0') { ! 782: list_start(); ! 783: return; ! 784: } ! 785: ! 786: xprint("OK. Starting search.\n"); ! 787: ! 788: if (get_default_service (&search_arg.sra_common) != 0) { ! 789: xprint ("Default service error -> check your .quipurc\n"); ! 790: return ; ! 791: } ! 792: ! 793: search_arg.sra_common.ca_servicecontrol.svc_sizelimit = asizelimit; ! 794: search_arg.sra_common.ca_servicecontrol.svc_options = 1; ! 795: search_arg.sra_baseobject = (*base_path != 'T'? ! 796: str2dn (base_path): ! 797: NULLDN); ! 798: search_arg.sra_eis.eis_allattributes = FALSE; ! 799: search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; ! 800: search_arg.sra_eis.eis_select = read_types; ! 801: ! 802: while (*str != '\0' && *str != '@') str++; ! 803: ! 804: search_arg.sra_subset = ((*base_path != 'T' && *str == '@')? ! 805: SRA_WHOLESUBTREE: ! 806: SRA_ONELEVEL); ! 807: search_arg.sra_filter = ! 808: make_filter(filt_arr[typeindx]); ! 809: ! 810: #ifndef NO_STATS ! 811: LLOG (log_stat,LLOG_NOTICE,("search +%s, extent %d, val %s",base_path,search_arg.sra_subset,mvalue)); ! 812: #endif ! 813: ! 814: ! 815: if(ds_search (&search_arg,&error,&result) != DS_OK) { ! 816: /* deal with error */ ! 817: free_seq(dnseq); ! 818: dnseq = NULLDS; ! 819: entry_number = 0; ! 820: xprint(" Search error due to:\n "); ! 821: quipu_error(&error); ! 822: } else { ! 823: correlate_search_results (&result); ! 824: ! 825: if (result.CSR_entries != NULLENTRYINFO) { ! 826: register EntryInfo *ptr; ! 827: ! 828: if (result.CSR_common.cr_aliasdereferenced) { ! 829: xprint (" (Alias dereferenced - object is "); ! 830: quipu_print (dn_print, (caddr_t) result.CSR_object); ! 831: dn_free (result.CSR_object); ! 832: xprint (")\n"); ! 833: } ! 834: ! 835: free_seq(dnseq); ! 836: dnseq = NULLDS; ! 837: entry_number = 0; ! 838: for (ptr = result.CSR_entries; ! 839: ptr != NULLENTRYINFO; ptr = ptr->ent_next){ ! 840: entry_number++; ! 841: dn2str ((caddr_t) ptr->ent_dn, goto_path); ! 842: add_seq (&dnseq, goto_path); ! 843: cache_entry (ptr,TRUE,TRUE); ! 844: } ! 845: ! 846: if (entry_number == 1) ! 847: get_listed_object(1); ! 848: ! 849: } else if(result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) { ! 850: free_seq(dnseq); ! 851: dnseq = NULLDS; ! 852: entry_number = 0; ! 853: xprint("Nothing found using current search parameters. Sorry!\n"); ! 854: } ! 855: ! 856: if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) ! 857: if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) { ! 858: free_seq(dnseq); ! 859: dnseq = NULLDS; ! 860: entry_number = 0; ! 861: xprint("(Time limit exceeded)"); ! 862: } else ! 863: xprint("(Size limit exceeded)"); ! 864: ! 865: entryinfo_free(result.CSR_entries, 0); ! 866: } ! 867: filter_free(search_arg.sra_filter); ! 868: } ! 869: ! 870: static dn2str (ptr,cptr) ! 871: caddr_t ptr; ! 872: char * cptr; ! 873: { ! 874: PS ps; ! 875: char buffer [RESBUF]; ! 876: ! 877: if((ps = ps_alloc(str_open)) == NULLPS) return ; ! 878: ! 879: if(str_setup(ps, buffer, RESBUF, 1) == NOTOK) return ; ! 880: ! 881: dn_print(ps, (DN) ptr, EDBOUT); ! 882: *ps->ps_ptr = 0; ! 883: ! 884: ps_free (ps); ! 885: ! 886: (void) strcpy(cptr, buffer); ! 887: } ! 888: ! 889: ! 890: read_print(func,ptr) ! 891: int (*func) (); ! 892: caddr_t ptr; ! 893: { ! 894: PS ps; ! 895: char buffer [RESBUF]; ! 896: char save; ! 897: int i, size; ! 898: register char *str, *sptr; ! 899: ! 900: if ((ps = ps_alloc (str_open)) == NULLPS) return ; ! 901: ! 902: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ; ! 903: ! 904: (*func) (ps, ptr, READOUT); ! 905: *ps->ps_ptr = 0; ! 906: ! 907: ps_free(ps); ! 908: str = buffer ; ! 909: sptr = str; ! 910: size = strlen(buffer); ! 911: ! 912: free_seq(dnseq); ! 913: dnseq = NULLDS; ! 914: entry_number = 0; ! 915: ! 916: Switch_Off_Result_Update(); ! 917: ! 918: for (i = 0; i <= size; i++, sptr++) ! 919: if (*sptr == '\n' || *sptr == '\0') { ! 920: entry_number++; ! 921: save = *sptr ; ! 922: *sptr = '\0'; ! 923: xprint(str); ! 924: str = sptr+1; ! 925: *sptr = save; ! 926: } ! 927: ! 928: Switch_On_Result_Update(); ! 929: } ! 930: ! 931: quipu_print (func,ptr) ! 932: int (*func) (); /* assumes func (PS ,dataptr,(int) format); */ ! 933: caddr_t ptr; ! 934: { ! 935: /* log info to pstream */ ! 936: PS ps; ! 937: char buffer [RESBUF]; ! 938: register char *str, *sptr; ! 939: char save; ! 940: ! 941: if ((ps = ps_alloc (str_open)) == NULLPS) return ; ! 942: ! 943: if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ; ! 944: ! 945: (*func) (ps,ptr,READOUT); ! 946: *ps->ps_ptr = 0; ! 947: ! 948: ps_free (ps); ! 949: ! 950: /* print in blocks of 100 bytes-larger seems too much for curses*/ ! 951: str = buffer; ! 952: do { ! 953: for (sptr = str; *sptr != '\0'; sptr++); ! 954: save = *sptr; ! 955: *sptr = 0; ! 956: xprint (str); ! 957: *sptr = save; ! 958: str = sptr; ! 959: } while (*sptr != '\0'); ! 960: } ! 961: ! 962: quipu_error (err) ! 963: struct DSError * err; ! 964: { ! 965: PS ps; ! 966: char buffer [RESBUF]; ! 967: ! 968: if ((ps = ps_alloc(str_open)) == NULLPS) return ; ! 969: ! 970: if (str_setup (ps, buffer, RESBUF, 1) == NOTOK) return ; ! 971: ds_error(ps, err); ! 972: ! 973: *ps->ps_ptr = 0; ! 974: xprint(buffer); ! 975: } ! 976: ! 977: free_all() ! 978: { ! 979: int count; ! 980: ! 981: free_seq(dnseq); ! 982: free_seq(backseq); ! 983: free_table(symtab); ! 984: for (count = 0; count < filt_num; count++) { ! 985: free_filt(filt_arr[count]); ! 986: free(filtvalue[count]); ! 987: free(filttype[count]); ! 988: } ! 989: } ! 990: ! 991: get_listed_object(entrynum) ! 992: int entrynum; ! 993: { ! 994: int count = 0; ! 995: char *sptr, *str; ! 996: ! 997: if (entrynum > element_num) return; ! 998: ! 999: if (sptr = get_from_seq (entrynum, showseq)) { ! 1000: ! 1001: str = get_from_seq(count+1, backseq); ! 1002: while (count < back_buf_num && strcmp(str, base_path)){ ! 1003: count++; ! 1004: str = get_from_seq(count+1, backseq); ! 1005: } ! 1006: ! 1007: if (count == back_buf_num) { ! 1008: add_seq(&backseq, base_path); ! 1009: back_buf_num++; ! 1010: } ! 1011: ! 1012: (void) strcpy(base_path, sptr); ! 1013: make_friendly(friendly_base_path, base_path); ! 1014: rd_start(); ! 1015: typetoggled = 0; ! 1016: set_default_type(); ! 1017: } ! 1018: *srchvalue = '\0'; ! 1019: } ! 1020: ! 1021: make_friendly(fstr, str) ! 1022: char *fstr; ! 1023: register char *str; ! 1024: { ! 1025: register char *end_ptr; ! 1026: char save; ! 1027: ! 1028: *fstr = '\0'; ! 1029: if (!strcmp(str, "The World")) { ! 1030: (void) strcpy(fstr, str); ! 1031: return; ! 1032: } ! 1033: ! 1034: while (*str != '\0') { ! 1035: while (*str != '=') str++; ! 1036: while (*str == ' ') str++; ! 1037: ! 1038: end_ptr = ++str; ! 1039: while (*end_ptr != '@' && *end_ptr != '\0') end_ptr++; ! 1040: save = *end_ptr; ! 1041: *end_ptr = '\0'; ! 1042: if (*fstr == '\0') ! 1043: (void) strcpy(fstr, str); ! 1044: else ! 1045: (void) strcat(fstr, str); ! 1046: *end_ptr = save; ! 1047: str = end_ptr; ! 1048: if (*str != '\0') ! 1049: (void) strcat(fstr, ", "); ! 1050: } ! 1051: } ! 1052: ! 1053: ! 1054: ! 1055: goto_addr() ! 1056: { ! 1057: set_default_type(); ! 1058: rd_start(); ! 1059: } ! 1060: ! 1061: struct attrcomp * ! 1062: sort_attrs(entry_attrs) ! 1063: struct attrcomp *entry_attrs; ! 1064: { ! 1065: struct attrcomp *last, *next, *curr, *first, *firstn; ! 1066: ! 1067: first = curr = entry_attrs; ! 1068: firstn = last = next = 0; ! 1069: ! 1070: while (curr) ! 1071: if (!strcmp("2.5.4.3", curr->attr_type->oa_ot.ot_stroid) || ! 1072: !strcmp("2.5.4.4", curr->attr_type->oa_ot.ot_stroid) || ! 1073: !strcmp("0.9.2342.19200300.100.1.3", ! 1074: curr->attr_type->oa_ot.ot_stroid) || ! 1075: !strcmp("0.9.2342.19200300.100.1.2", ! 1076: curr->attr_type->oa_ot.ot_stroid) || ! 1077: !strcmp("2.5.4.20", curr->attr_type->oa_ot.ot_stroid)) { ! 1078: ! 1079: if (first == curr) first = curr->attr_link; ! 1080: ! 1081: if (next) ! 1082: next->attr_link = curr; ! 1083: else ! 1084: firstn = curr; ! 1085: ! 1086: next = curr; ! 1087: ! 1088: if (last) ! 1089: last->attr_link = curr->attr_link; ! 1090: ! 1091: curr = curr->attr_link; ! 1092: next->attr_link = 0; ! 1093: } else { ! 1094: last = curr; ! 1095: curr = curr->attr_link; ! 1096: } ! 1097: ! 1098: if (next) { ! 1099: next->attr_link = first; ! 1100: return firstn; ! 1101: } else ! 1102: return first; ! 1103: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.