📄 calls.c
字号:
} else if (lexequ (part1, "dsap") == 0) (void) tai_string (part2); else if (lexequ (part1, "isode") == 0) { char *split; if ((split = index (part2,' ')) != NULLCP) { *split++ = 0; (void) isodesetvar (part2, split, 0); } } else if (lexequ(part1, "service") == 0) new_service (part2); else if (lexequ(part1, "history") == 0) { (void) sscanf(part2, "%d", &histlimit); if (histlimit < 1) histlimit = 1; } else if (lexequ(part1, "readnonleaf") == 0) { if (lexequ(part2, "TRUE") == 0) read_all_flag = TRUE; else read_all_flag = FALSE; } else { add_seq(&alias_seq, part1); if ((part3 = index (part2 ,':')) != NULLCP) { *part3++ = '\0'; part3 = TidyString(part3); add_seq(&password_seq, part3); } else { add_seq(&password_seq, ""); } add_seq(&aliased_dn_seq, part2); } } isodexport(myname); (void) fclose(config_file); }}char *cnnct_bind(){ struct ds_bind_arg bindarg; struct ds_bind_arg bindresult; struct ds_bind_error binderr; extern char *dsa_address, *myname; if (namestr[0] != '\0' && passwd[0] == '\0') { kill_message(); message((Widget) NULL, "Enter password at command line!"); (void) strcpy(passwd, getpassword("Enter user password: ")); kill_message(); message((Widget) NULL, "Connecting to Directory. Please wait."); } /* set dsa_address */ if (dsa_address == NULLCP) dsa_address = myname; if (dsa_address == NULLCP || *dsa_address == '\0') { return ("Cannot find name of DSA to bind to! Click on this window to exit."); } /* now bind */ bindarg.dba_version = DBA_VERSION_V1988; if (passwd[0] == 0) { bindarg.dba_passwd_len = 0; bindarg.dba_passwd [0] = '\0'; } else { bindarg.dba_passwd_len = strlen(passwd); (void) strcpy (bindarg.dba_passwd, passwd); } bindarg.dba_dn = (*namestr == 0? NULLDN: str2dn(namestr)); if (ds_bind (&bindarg, &binderr, &bindresult) != DS_OK) { return(binderr.dbe_type == DBE_TYPE_SECURITY? "Security error - Check name and pasword.\n\Click on this window to exit.": "Service error - Can't connect to directory!\n\Click on this window to exit."); } else { user_name = bindarg.dba_dn; if(local_dit && *local_dit) (void) strcpy(base_path, local_dit);#ifndef NO_STATS LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address));#endif#ifndef NO_STATS LLOG (log_stat,LLOG_NOTICE,("pod bound to directory"));#endif make_friendly(friendly_base_path, base_path); set_default_type(); check_known_oids(); oclass = as_comp_new(AttrT_new("2.5.4.0"), NULLAV, NULLACL_INFO); } dn_number = 0; back_buf_num = 0; backseq = dnseq = NULLDS; return NULLCP;}void set_default_type(){ int count; register DN base_name; DN d_name; if (*base_path != '\0') { base_name = d_name = str2dn(base_path); while (base_name && base_name->dn_parent) base_name = base_name->dn_parent; for (count = 0 ; count < default_num && base_name && strcmp(levels[count], base_name->dn_rdn->rdn_at->oa_ot.ot_stroid) ; count++) ; dn_free(d_name); if (count < default_num) { av_typeindx = available_types[count]; typeindx = defaults[count]; } else { av_typeindx = available_types[0]; typeindx = defaults[0]; } } else { for(count = 0; count < default_num && strcmp(levels[count], "@"); count++); if (count < default_num) { av_typeindx = available_types[count]; typeindx = defaults[count]; } else { av_typeindx = available_types[0]; typeindx = defaults[0]; } } typetoggled = 0;}void dn2buf (ptr,cptr) caddr_t ptr; char * cptr;{ PS ps; char buffer [RESBUF]; if((ps = ps_alloc(str_open)) == NULLPS) return ; if(str_setup(ps, buffer, RESBUF, 1) == NOTOK) return ; dn_print(ps, (DN) ptr, EDBOUT); *ps->ps_ptr = 0; ps_free (ps); (void) strcpy(cptr, buffer);}void make_friendly(fstr, str) char *fstr, *str;{ char *end, *start; char save; char buffer[LINESIZE]; int count, rdn_count = 0; str_seq rdns = NULLDS; if (str == NULLCP || *str == '\0') { *fstr = '\0'; return; } end = str; while (*end != '\0') end++; start = end; while (start >= str) { if (*start == '@' || start == str) { save = *end; *end = '\0'; if (start != str) start++; add_seq(&rdns, start); *end = save; end = --start; rdn_count++; } --start; } *fstr = '\0'; for (count = 1; count <= rdn_count; count++) { start = get_from_seq(count, rdns); buffer[0] = '\0'; make_friendly_aux(buffer, start); if (*fstr == '\0') (void) strcpy(fstr, buffer); else { (void) strcat(fstr, ", "); (void) strcat(fstr, buffer); } } free_seq(rdns);}static void make_friendly_aux(fstr, rdn) char *fstr, *rdn;{ char *start, *end, *string; char save; short int mapped; int count, seqnum; extern char *SkipSpace(); /* First check the attribute type alias */ start = end = SkipSpace(rdn); while (!isspace(*end) && *end != '=') end++; save = *end; *end = '\0'; mapped = FALSE; for (count = 0; count < fname_num && !mapped; count++) { seqnum = 0; while (!mapped && (string = get_from_seq(seqnum++, name_map[count]->names))) if (!strcmp(string, start)) { (void) strcat(fstr, name_map[count]->fname); mapped = TRUE; } } if (!mapped) { (void) strcat(fstr, start); (void) strcat(fstr, " = "); } else { if (*name_map[--count]->fname != '\0') (void) strcat(fstr, " = "); } *end = save; /* Now get the attribute value*/ start = end; while (isspace(*start) || *start == '=') start++; end = start; while (*end != '@' && *end != '\0' && *end != '%') end++; save = *end; *end = '\0'; if (index(start, ',') == NULLCP) (void) strcat(fstr, start); else { (void) strcat(fstr, "\""); (void) strcat(fstr, start); (void) strcat(fstr, "\""); } *end = save; if (save == '\0' || save == '@') return; else if (save == '%') { (void) strcat(fstr, " ("); for (start = fstr; *start != '\0'; start++) ; make_friendly_aux(start, ++end); (void) strcat(fstr, ")"); }}void make_friendly_rdn(friendly, object, base) char *friendly; char *object, *base;{ register char *front; char save; int count; count = strlen(base); front = (char *) (object + count); save = *front; *front = '\0'; if (lexequ(object, base)) { *front = save; make_friendly(friendly, object); return; } *front = save; *friendly = '\0'; front = base; count = 0; if (showseq != backseq) { while (*front != '\0') if (*front++ == '@') count++; count++; } else count = 0; front = object; while (count && *front != '\0') if (*front++ == '@') count--; if (*front != '\0') { if (front != object) while (isspace(*front) && *front != '\0') front++; make_friendly(friendly, front); } else make_friendly(friendly, object);}goto_addr(){ char *str; int count = 0; void add_to_history(); set_default_type(); make_friendly(friendly_base_path, base_path); str = get_from_seq(count+1, backseq); while (count < back_buf_num && strcmp(str, base_path)){ count++; str = get_from_seq(count+1, backseq); } if (count == back_buf_num) { add_seq(&backseq, base_path); back_buf_num++; add_to_history(back_buf_num); }}clear_dnseq(){ free_seq(dnseq); dnseq = NULLDS; dn_number = 0;}int is_dit_leaf(name) char *name;{ struct ds_list_arg list_arg; struct ds_list_result list_result; struct list_cache *cached_list; struct ds_read_arg read_arg; struct ds_read_result read_result; Entry read_entry; Attr_Sequence object_class; struct DSError list_error, read_error; char entry_str[STRINGLEN]; if (get_default_service (&read_arg.rda_common) != 0) return(1); read_arg.rda_common.ca_servicecontrol.svc_options = SVC_OPT_PREFERCHAIN; read_arg.rda_eis.eis_allattributes = FALSE; read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; read_arg.rda_eis.eis_select = oclass; read_arg.rda_object = (*name? str2dn(name): NULLDN); if ((read_entry = local_find_entry(read_arg.rda_object, FALSE)) != NULLENTRY && read_entry->e_data != E_TYPE_CONSTRUCTOR) { object_class = get_sorted_attrs(read_entry->e_attributes, oclass); entry2str((caddr_t) object_class, entry_str, STRINGLEN); as_free(object_class); if (issubstr(entry_str, "NonLeaf")) return(0); } else if (ds_read(&read_arg, &read_error, &read_result) == DS_OK) { if (read_result.rdr_entry.ent_attr == NULLATTR) return(0); entry2str((caddr_t) read_result.rdr_entry.ent_attr, entry_str, STRINGLEN); entryinfo_comp_free(&read_result.rdr_entry, 0); if (issubstr(entry_str, "NonLeaf")) return(0); } else { dn_free(read_arg.rda_object); ds_error_free(&read_error); } if (get_default_service (&list_arg.lsa_common) != 0) return(1); list_arg.lsa_common.ca_servicecontrol.svc_sizelimit = 1; list_arg.lsa_common.ca_servicecontrol.svc_options = SVC_OPT_PREFERCHAIN; list_arg.lsa_object = (*name? str2dn(name): NULLDN); if ((cached_list = find_list_cache(list_arg.lsa_object, 1)) != NULL) { if (cached_list->list_sub_top) return(0); else return(1); } else if (ds_list (&list_arg, &list_error, &list_result) == DS_OK) { cache_list(list_result.lsr_subordinates, 0, list_arg.lsa_object, 1); dn_free(list_arg.lsa_object); if (list_result.lsr_subordinates) return(0); else return(1); } else { dn_free(list_arg.lsa_object); ds_error_free(&list_error); return (1); }}char *GetSurname(name) register char *name;{ while (*name != '\0') name++; while (*name != ' ' && *name != '=') name--; return ++name;}char *GetWholeRelName(name) register char *name;{ while (*name!= '\0') name++; while (*name != '=') name--; while (!isalpha(*name)) name++; return name;}str_seq SortList(list) str_seq list;{ register str_seq currEntry, lastSortedEntry , currSortedEntry; str_seq sortedList; char *sortedName, *currName; register DN curr_dn; DN dn; if (!list) return 0; currEntry = list; sortedList = 0; while (currEntry) { dn = curr_dn = str2dn(currEntry->dname); while (curr_dn && curr_dn->dn_parent != NULLDN) curr_dn = curr_dn->dn_parent; if (!strcmp(curr_dn->dn_rdn->rdn_at->oa_ot.ot_stroid, "2.5.4.3")) currName = GetSurname(currEntry->dname); else currName = GetWholeRelName(currEntry->dname); dn_free(dn); if (!sortedList) { sortedList = currEntry; currEntry = currEntry->next; sortedList->next = 0; } else { lastSortedEntry = 0; currSortedEntry = sortedList; while (currSortedEntry != 0) { dn = curr_dn = str2dn(currSortedEntry->dname); while (curr_dn && curr_dn->dn_parent != NULLDN) curr_dn = curr_dn->dn_parent; if (!strcmp(curr_dn->dn_rdn->rdn_at->oa_ot.ot_stroid, "2.5.4.3")) sortedName = GetSurname(currSortedEntry->dname); else sortedName = GetWholeRelName(currSortedEntry->dname); dn_free(dn); if (strcmp(currName, sortedName) <= 0) { if (lastSortedEntry) { lastSortedEntry->next = currEntry; currEntry = currEntry->next; lastSortedEntry->next->next = currSortedEntry; } else { sortedList = currEntry; currEntry = currEntry->next; sortedList->next = currSortedEntry; } currSortedEntry = 0; } else { lastSortedEntry = currSortedEntry; currSortedEntry = currSortedEntry->next; if (!currSortedEntry) { lastSortedEntry->next = currEntry; currEntry = currEntry->next; lastSortedEntry->next->next = 0; currSortedEntry = 0; } } } } } return sortedList;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -