pod.c
来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 2,398 行 · 第 1/5 页
C
2,398 行
trans_table = XtParseTranslationTable(defaultTranslations); XtOverrideTranslations(SearchVal, trans_table);}void add_to_history(seqnum) int seqnum;{ int count; char curr_base[STRINGLEN]; Widget history_form, history_display, scrolwin; Arg args[MAXARGS]; str_seq first; history_form = XtNameToWidget(toplevel, "Session History.HistoryForm"); history_display = XtNameToWidget(history_form, "ListScrolledWindow.ListWindow"); scrolwin = XtParent(history_display); XawFormDoLayout(history_form, FALSE); XtUnmanageChild(history_display); XtDestroyWidget(history_display); count = 0; history_display = XtCreateWidget("ListWindow", formWidgetClass, scrolwin, args, count); if (seqnum > histlimit) { first = backseq; backseq = backseq->next; first->next = NULLDS; free_seq(first); back_buf_num--; } (void) strcpy(curr_base, base_path); base_path[0] = '\0'; AddNewList(history_display, backseq, (unsigned) back_buf_num); XtRealizeWidget(history_display); XtManageChild(history_display); (void) strcpy(base_path, curr_base); XawFormDoLayout(history_form, TRUE);}print_search_area(PosWindow) Widget PosWindow;{ char *str, *end, save, name_array[STRINGLEN]; char *trans_start_btn2 = "None <Btn2Up>: set() DnList(", *trans_start_btn3 = "None <Btn3Up>: set() DnMove(", translations[STRINGLEN], trans_buf[SMALLSTRING]; Dimension width; int count; Arg args[MAXARGS]; Widget rdn_window, last_rdn = 0; XtTranslations trans_table; count = 0; XtSetArg(args[count], XtNwidth, &width); count++; XtGetValues(PosWindow, args, count); width -= 24; count = 0; XtSetArg(args[count], XtNlabel, ("The World")); count++; XtSetArg(args[count], XtNborderWidth, 0); count++; XtSetArg(args[count], XtNborderColor, WhitePixelOfScreen(screen)); count++; XtSetArg(args[count], XtNhighlightThickness, 1); count++; XtSetArg(args[count], XtNjustify, XtJustifyLeft); count++; XtSetArg(args[count], XtNwidth, width); count++; rdn_window = XtCreateManagedWidget("x", commandWidgetClass, PosWindow, args, count); XtAddCallback(rdn_window, XtNcallback, DnMoveRead, (XtPointer) 0); (void) sprintf(trans_buf, "%d", 0); (void) strcpy(translations, trans_start_btn2); (void) strcat(translations, trans_buf); (void) strcat(translations, ") unset() \n "); (void) strcat(translations, trans_start_btn3); (void) strcat(translations, trans_buf); (void) strcat(translations, ") unset()"); trans_table = XtParseTranslationTable(translations); XtOverrideTranslations(rdn_window, trans_table); last_rdn = rdn_window; rdn_number = 1; (void) strcpy (name_array, "xx"); make_friendly(friendly_base_path, base_path); end = friendly_base_path; while (*end != '\0') end++; str = end; while (str > (char *) friendly_base_path) { while (*str != ',' && str > (char *) friendly_base_path) if (*str == '\"') { end = str--; while (*str != '\"' && str > (char *) friendly_base_path) str--; } else str--; while (!isalnum(*str)) str++; save = *end; *end = '\0'; count = 0; XtSetArg(args[count], XtNlabel, (*str? str: "ahem")); count++; XtSetArg(args[count], XtNborderWidth, 0); count++; XtSetArg(args[count], XtNborderColor, WhitePixelOfScreen(screen)); count++; XtSetArg(args[count], XtNhighlightThickness, 1); count++; XtSetArg(args[count], XtNjustify, XtJustifyLeft); count++; XtSetArg(args[count], XtNwidth, width); count++; XtSetArg(args[count], XtNfromVert, last_rdn); count++; rdn_window = XtCreateManagedWidget((String) name_array, commandWidgetClass, PosWindow, args, count); last_rdn = rdn_window; XtAddCallback(rdn_window, XtNcallback, DnMoveRead, (XtPointer) rdn_number); (void) sprintf(trans_buf, "%d", (strlen(name_array) - 1)); (void) strcpy(translations, trans_start_btn2); (void) strcat(translations, trans_buf); (void) strcat(translations, ") unset() \n "); (void) strcat(translations, trans_start_btn3); (void) strcat(translations, trans_buf); (void) strcat(translations, ") unset()"); trans_table = XtParseTranslationTable(translations); XtOverrideTranslations(rdn_window, trans_table); (void) strcat(name_array, "x"); rdn_number++; *end = save; if (str > (char *) friendly_base_path) { while (*str != ',' && str > (char *) friendly_base_path) str--; end = str; if (*str == ',') str--; } }} /*ARGSUSED*/static void StartSearch(w, closure, calldata) Widget w; XtPointer closure, calldata;{ Arg args[MAXARGS]; int count, indx; Widget text; char entry[STRINGLEN], string[STRINGLEN], mess[STRINGLEN]; char *value; dsEnqError status; Cursor time_cur = XCreateFontCursor(dpy, XC_watch); Cursor normal_cur = XCreateFontCursor(dpy, XC_left_ptr); text = XtNameToWidget(outer, "TypeForm.SearchVal"); count = 0; XtSetArg(args[count], XtNstring, &value); count++; XtGetValues(text, args, count); (void) strcpy(mvalue, value); if (mvalue[0] == '\0') { kill_message(); displayError(outer, "You have not specified a search value!\n\Click on this window to continue"); return; } if (index(mvalue, '=') == NULLCP) (void) sprintf(mess, "Searching for entry of type `%s'.\nPlease stand by....", filttype[typeindx]); else (void) sprintf(mess, "Searching with filter `%s'.\nPlease stand by....", mvalue); message(outer, mess); XDefineCursor(dpy, XtWindow(outer), time_cur); XFlush(dpy); status = srch_start(); XDefineCursor(dpy, XtWindow(outer), normal_cur); XFlush(dpy); kill_message(); switch(status) { case Okay: if (entry_number == 1) { (void) strcpy(entry, (get_from_seq(1, dnseq))); if (!is_dit_leaf(entry)) { (void) strcpy(base_path, entry); make_friendly(friendly_base_path, base_path); set_search_area(XtNameToWidget (outer, "PosForm.PosScrolledWindow.PosWindow")); goto_addr(); SetType((Widget) 0, (XtPointer) typeindx, (XtPointer) 0); XFlush(dpy); if (curr_read_popup == 0) curr_read_popup = createReadPopup(); status = read_config_types(); if (status == Okay) displayReadPopup(); else doError(status); } else { (void) strcpy(string, base_path); (void) strcpy(base_path, entry); make_friendly(friendly_base_path, base_path); XFlush(dpy); if (curr_read_popup == 0) curr_read_popup = createReadPopup(); status = read_config_types(); displayReadPopup(); if (status == Okay) { (void) strcpy(base_path, string); make_friendly(friendly_base_path, base_path); } else doError(status); } clear_dnseq(); entry_number = 0; } else if (entry_number > 0) { (void) strcpy(mess, "Results of search under "); if (strlen(base_path) > 3) { indx = 0; while (friendly_base_path[indx] != ',' && friendly_base_path[indx] != '\0') indx++; friendly_base_path[indx] = '\0'; (void) strcat(mess, (char *) (friendly_base_path)); } else { (void) strcat(mess, "The World"); indx = 0; } createList(dnseq, mess, ""); dnseq = 0; break; case listsizelimit: case adminlimit_w_partial: case timelimit_w_partial: (void) strcpy(mess, "Results of search under "); if (strlen(base_path) > 3) { indx = 0; while (friendly_base_path[indx] != ',' && friendly_base_path[indx] != '\0') indx++; friendly_base_path[indx] = '\0'; (void) strcat(mess, (char *) friendly_base_path); } else { (void) strcat(mess, "The World"); indx = 0; } switch (status) { case timelimit_w_partial: (void) sprintf(string, "%s. %s. %d %s.", "Time limit reached", "Partial results only", entry_number, "items displayed"); break; case adminlimit_w_partial: (void) sprintf(string, "%s. %s. %d %s.", "Administrative limit reached", "Partial results only", entry_number, "items displayed"); break; case listsizelimit: (void) sprintf(string, "List size limit exceeded. Only %d items displayed.", entry_number); break; } createList(dnseq, mess, string); dnseq = 0; break; default: doError(status); } } ClearSearchArea(XtNameToWidget(outer, "TypeForm.SearchVal"), (XEvent *) NULL, (String *) NULL, (Cardinal) 0);}static Widget createTypeMenu(parent) Widget parent;{ Widget menu_mgr, button; Arg args[MAXARGS]; int count = 0, n; menu_mgr = XtCreatePopupShell("menu", simpleMenuWidgetClass, parent, args, 0 ); n = 0; while (av_typeindx[n] != -1) { count = 0; XtSetArg(args[count], XtNlabel, (String) filttype[av_typeindx[n]]);count++; button = XtCreateManagedWidget((String) filttype[av_typeindx[n]], smeBSBObjectClass, menu_mgr, args, count); XtAddCallback(button, XtNcallback, SetType, (XtPointer) av_typeindx[n]); n++; } return menu_mgr;}/*ARGSUSED*/static void SetType(w, indx, calldata) Widget w; XtPointer indx, calldata;{ Widget menu, menuButton; int count = 0; Arg args[MAXARGS]; char label[1024]; menuButton = XtNameToWidget(outer, "TypeForm.TypeButton"); if ((int) indx < 0 || (int) indx >= (int) filt_num) return; if ((menu = XtNameToWidget(outer, "TypeForm.TypeButton.menu"))) XtDestroyWidget(menu); (void) createTypeMenu(menuButton); (void) strcpy(label, filttype[(int) indx]); count = 0; XtSetArg(args[count], XtNlabel, label); count++; XtSetValues(menuButton, args, count); typeindx = (int) indx;}static void CreateCommandForm(parent) Widget parent;{ Widget form, quitButton, helpButton, searchButton, listButton, historyButton; Arg args[MAXARGS]; int count; count = 0; form = XtCreateManagedWidget("MainButtonForm", formWidgetClass, parent, args, count); count = 0; XtSetArg(args[count], XtNheight, Quit_height); count++; XtSetArg(args[count], XtNwidth, Quit_width); count++; quitButton = XtCreateManagedWidget("quitButton", commandWidgetClass, form, args, count); XtAddCallback(quitButton, XtNcallback, (XtCallbackProc) Quit, (XtPointer) 0); count = 0; XtSetArg(args[count], XtNheight, Help_height); count++; XtSetArg(args[count], XtNwidth, Help_width); count++; helpButton = XtCreateManagedWidget("helpButton", commandWidgetClass, form, args, count); XtAddCallback(helpButton, XtNcallback, (XtCallbackProc) Help, (XtPointer) 0); count = 0; XtSetArg(args[count], XtNheight, Search_height); count++; XtSetArg(args[count], XtNwidth, Search_width); count++; searchButton = XtCreateManagedWidget("searchButton", commandWidgetClass, form, args, count); XtAddCallback(searchButton, XtNcallback, (XtCallbackProc) StartSearch, (XtPointer) 0); count = 0; XtSetArg(args[count], XtNheight, List_height); count++; XtSetArg(args[count], XtNwidth, List_width); count++; listButton = XtCreateManagedWidget("listButton", commandWidgetClass, form, args, count); XtAddCallback(listButton, XtNcallback, (XtCallbackProc) List, (XtPointer) 0); count = 0; XtSetArg(args[count], XtNheight, History_height); count++; XtSetArg(args[count], XtNwidth, History_width); count++; historyButton = XtCreateManagedWidget("historyButton", commandWidgetClass, form, args, count); XtAddCallback(historyButton, XtNcallback, (XtCallbackProc) popupHistory, (XtPointer) 0);}static void displayReadPopup(){ if (curr_read_popup) { XtPopup(curr_read_popup, XtGrabNone); XRaiseWindow(dpy, XtWindow(curr_read_popup)); }}void setReadEntryName(entry_name) char *entry_name;{ Widget title, modifyButton, showAllButton; int count = 0; Arg args[MAXARGS]; char *object, friendly_name[STRINGLEN]; make_friendly(friendly_name, entry_name); if (curr_read_popup) { object = strdup(entry_name); title = XtNameToWidget(curr_read_popup, "ReadForm.titleView.readTitle"); if (*friendly_name == '\0') { XtSetArg(args[count], XtNlabel, "The World"); count++; } else { XtSetArg(args[count], XtNlabel, friendly_name); count++; } XtSetValues(title, args, count); modifyButton = XtNameToWidget(curr_read_popup, "ReadForm.ReadButtonForm.modifyButton"); showAllButton = XtNameToWidget(curr_read_popup, "ReadForm.ReadButtonForm.showAllButton"); if (XtHasCallbacks(title, XtNcallback) == XtCallbackHasSome) XtRemoveAllCallbacks(title, XtNcallback); XtAddCallback(title, XtNcallback, CutString, (XtPointer) object); if (XtHasCallbacks(showAllButton, XtNcallback) == XtCallbackHasSome) XtRemoveAllCallbacks(showAllButton, XtNcallback); XtAddCallback(showAllButton, XtNcallback, ReadAll, (XtPointer) object); if (XtHasCallbacks(modifyButton, XtNcallback) == XtCallbackHasSome) XtRemoveAllCallbacks(modifyButton, XtNcallback); if (*object != '\0') XtAddCallback(modifyButton, XtNcallback, modifyEntry, (XtPointer) object);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?