pod.c

来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 2,398 行 · 第 1/5 页

C
2,398
字号
#ifndef lintstatic char *rcsid = "$Header: /xtel/isode/isode/others/quipu/uips/pod/RCS/pod.c,v 9.0 1992/06/16 12:44:54 isode Rel $";#endif/* * $Header: /xtel/isode/isode/others/quipu/uips/pod/RCS/pod.c,v 9.0 1992/06/16 12:44:54 isode Rel $ */#include "bitmap"#include "pod.h"#include "defs.h"#include "dir_entry.h"dsEnqError srch_start(), read_config_types(), list_start(), read_all();dsErrorStruct modify_entry();void make_friendly(), make_friendly_rdn(), make_template();void quit();void rfc2greybook();extern mailtype mailformat;extern bool read_all_flag;extern char base_path[];extern char friendly_base_path[];extern char mvalue[];extern char dir_error_message[];extern unsigned int filt_num, typeindx;extern int *av_typeindx;extern char *filtvalue[];extern char *filttype[];extern char dua_help_dir[];extern int NUMLINES;extern int px, py, maxx;extern Pixmap photo_pixmap;extern bool photo_on;Widget PhotoWindow;Pixmap icon_pixmap;extern int sizelimit, histlimit;char curr_help[STRINGLEN];char curr_selection[STRINGLEN];char help_string[RESBUF];static Widget standby = 0, error_popup = 0,              curr_read_popup = 0, curr_list_popup = 0,               curr_modify_popup = 0, version_popup = 0;static Display *dpy;static Screen *screen;static int scr;extern str_seq showseq, dnseq, backseq;extern int entry_number, dn_number, back_buf_num;int element_number = 0;int rdn_number = 0;int help_up = 0;static void ShowVersion(), HideVersion();static void CreateCurrPosWindow(), CreateSearchWindow(), CreateMessagePopup();static void CreateErrorPopup(), CreateHelpPopup(), CreateHistoryPopup();static void CreateCommandForm(), CreateVersionPopup();static dirEntry createModifyTemplate();static Widget createModifyPopup(), createReadPopup();static Widget createTypeMenu();static void Quit(), QuitFromHelp(), InsertHelp();static void List(), ListDestroy();static void AddNewList(), ListSelect(), destroyList(), keepList();static void Move(), DnMoveRead(), DnMove();static void SetType(), Read(), Help(), ReadAll();static void TSearch(), ClearSearchArea(), StartSearch();static void createList();static void createHistoryPopup(), popupHistory(), popdownHistory();static void displayReadPopup(), readDestroy(), keepRead();static void submitModif(), closeModify(), modifyEntry(), addValField();static void UndoValChanges(), UndoAttrChanges(), modUpdate(), keepModify();static void cannotModify();static void killError(), doError();static void ChangeHelp();static void buttonPress();static void freeEntry(), freeSpace(), CutString();static void ListSelectList(), DnList();static void ListSelectMove();static bool ConvSel();static int GetTextWidth(), GetTextHeight();static void PopupMessage();static void entry_print();static void kill_error();void kill_message(), message();static void CreateBackgroundPixmap(), FreeWidgetPixmap();void displayError();void print_photo(), kill_photo(), make_photo_widget();Widget toplevel, outer;static XtActionsRec verActionsTable[] = {  {"HideVersion", (XtActionProc) HideVersion},};static XtActionsRec buttonActionsTable[] = {  {"ChangeHelp", (XtActionProc) ChangeHelp},  {"buttonPress", (XtActionProc) buttonPress},};static XtActionsRec listActionsTable[] = {  {"ListSelectList", (XtActionProc) ListSelectList},  {"ListSelectMove", (XtActionProc) ListSelectMove},};static XtActionsRec currPosActionsTable[] = {  {"DnList", (XtActionProc) DnList},  {"DnMove", (XtActionProc) DnMove},};void CreateWidgets(){  int count;  Arg args[MAXARGS];  count = 0;  outer = XtCreateManagedWidget("outer", formWidgetClass, toplevel,				args, count);  dpy = XtDisplay(toplevel);  scr = DefaultScreen(dpy);  screen = XtScreen(toplevel);  XtAddActions(buttonActionsTable, XtNumber(buttonActionsTable));  XtAddActions(listActionsTable, XtNumber(listActionsTable));  XtAddActions(currPosActionsTable, XtNumber(currPosActionsTable));  XtAddActions(verActionsTable, XtNumber(verActionsTable));  curr_help[0] = '\0';  CreateCurrPosWindow(outer);  CreateSearchWindow(outer);  CreateCommandForm(outer);  CreateHistoryPopup(backseq, "");  CreateHelpPopup();  CreateMessagePopup();  CreateErrorPopup();  CreateVersionPopup();}void PodLoop(){  Widget PosWindow;  XSizeHints   hints;  XWMHints wm_hints;  XClassHint class_hint;  XTextProperty window, icon;  String window_name = "Directory",  	 icon_name = "Directory";    XtRealizeWidget(toplevel);  icon_pixmap = XCreatePixmapFromBitmapData(dpy, XtWindow(toplevel),					    icon_bits, icon_width, icon_height,					    BlackPixelOfScreen(screen),					    WhitePixelOfScreen(screen),					    DefaultDepthOfScreen(screen));  hints.flags = 0;  wm_hints.input = TRUE;  wm_hints.icon_pixmap = icon_pixmap;  wm_hints.initial_state = NormalState;  wm_hints.flags = InputHint | IconPixmapHint | StateHint;  class_hint.res_name ="pod";  class_hint.res_class = "Pod";  XStringListToTextProperty(&window_name, 1, &window);  XStringListToTextProperty(&icon_name, 1, &icon);  XSetWMProperties(dpy, XtWindow(toplevel),		   &window, &icon,		   (char **) 0, (int) 0,		   &hints, &wm_hints, &class_hint);  PosWindow = XtNameToWidget(outer, 		       "PosForm.PosScrolledWindow.PosWindow");  print_search_area(PosWindow);  if (DefaultDepthOfScreen(screen) == 1) {    CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm"),			   gray_bits, gray_width, gray_height);    CreateBackgroundPixmap(outer, gray_bits, gray_width, gray_height);    CreateBackgroundPixmap(XtNameToWidget(outer, "TypeForm"), 			   gray_bits, gray_width, gray_height);  }  CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm.searchButton"),                         Search_bits, Search_width, Search_height);  CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm.listButton"),                         List_bits, List_width, List_height);  CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm.historyButton"),                         History_bits, History_width, History_height);  CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm.quitButton"),                         Quit_bits, Quit_width, Quit_height);  CreateBackgroundPixmap(XtNameToWidget(outer, "MainButtonForm.helpButton"),                         Help_bits, Help_width, Help_height);  goto_addr();  SetType((Widget) 0, (XtPointer) typeindx, (XtPointer) 0);  XtMainLoop();}void make_photo_widget(){  int count;  Arg args[MAXARGS];  Widget TextForm, TextWindow;  TextForm = XtNameToWidget(curr_read_popup,			    "ReadForm.TextScrolledWindow.TextForm");  TextWindow = XtNameToWidget(curr_read_popup,			    "ReadForm.TextScrolledWindow.TextForm.AttrWindow");    count = 0;  XtSetArg(args[count], XtNresizable, TRUE); count++;  XtSetArg(args[count], XtNforeground, WhitePixelOfScreen(screen)); count++;  XtSetArg(args[count], XtNbackground, BlackPixelOfScreen(screen)); count++;  XtSetArg(args[count], XtNwidth, (Dimension) maxx); count++;  XtSetArg(args[count], XtNheight, (Dimension) py); count++;  XtSetArg(args[count], XtNlabel, ""); count++;  XtSetArg(args[count], XtNfromVert, TextWindow); count++;  PhotoWindow = XtCreateManagedWidget("PhotoWindow",				       labelWidgetClass,				       TextForm, args, count);}void kill_photo(){  if (PhotoWindow != NULL) {    XtUnmanageChild(PhotoWindow);    XtDestroyWidget(PhotoWindow);    PhotoWindow = (Widget) 0;  }}void print_photo(){  int count;  Arg args[MAXARGS];  count = 0;  if (photo_pixmap) {    XtSetArg(args[count], XtNbackgroundPixmap, photo_pixmap); count++;  }  XtSetArg(args[count], XtNresizable, FALSE); count++;  XtSetValues(PhotoWindow, args, count);  XtAddCallback(PhotoWindow, XtNdestroyCallback, FreeWidgetPixmap, 		(XtPointer) photo_pixmap);    photo_pixmap = (Pixmap) 0;}/*ARGSUSED*/static void FreeWidgetPixmap(w, closure, calldata)     Widget w;     XtPointer closure, calldata;{  XFreePixmap(dpy, (Pixmap) closure);}static void createList(list_seq, top_mess, lower_mess)     str_seq list_seq;     char *top_mess, *lower_mess;{  int count = 0;  Widget shell, swindow, ListForm, ListWindow,          closeButton, keepButton, ListTitleView;  Arg args[MAXARGS];  if (curr_list_popup) {    if (!XtIsManaged(curr_list_popup)) XtManageChild(curr_list_popup);    shell = curr_list_popup;    ListForm = XtNameToWidget(shell, "ListForm");    swindow = XtNameToWidget(shell,			     "ListForm.ListScrolledWindow");    ListWindow = XtNameToWidget(shell,				"ListForm.ListScrolledWindow.ListWindow");        XawFormDoLayout(ListForm, FALSE);    XtUnmanageChild(ListWindow);    XtDestroyWidget(ListWindow);        count = 0;    ListWindow = XtCreateWidget("ListWindow", formWidgetClass,				       swindow, args, count);    AddNewList(ListWindow, list_seq,  (unsigned) entry_number);    XtRealizeWidget(ListWindow);    XtManageChild(ListWindow);    XawFormDoLayout(ListForm, TRUE);        count = 0;    XtSetArg(args[count], XtNlabel, top_mess); count++;    XtSetValues(XtNameToWidget(shell, "ListForm.ListTitleView.listTitle"),		args, count);        count = 0;    XtSetArg(args[count], XtNlabel, lower_mess); count++;    XtSetValues(XtNameToWidget(shell, "ListForm.ListMessage"),		args, count);        XRaiseWindow(dpy, XtWindow(shell));    return;  }  count = 0;  shell = XtCreatePopupShell("ListOutput", topLevelShellWidgetClass,                             toplevel, args, 0);  count = 0;  ListForm = XtCreateManagedWidget("ListForm", formWidgetClass,				       shell, args, count);  count = 0;  XtSetArg(args[count], XtNheight, Close_height); count++;  XtSetArg(args[count], XtNwidth, Close_width); count++;  closeButton = XtCreateManagedWidget("closeButton",				     commandWidgetClass,                                     ListForm, args, count);    XtAddCallback(closeButton, XtNcallback,                (XtCallbackProc) destroyList, (XtPointer) shell);  count = 0;  XtSetArg(args[count], XtNheight, Keep_height); count++;  XtSetArg(args[count], XtNwidth, Keep_width); count++;  keepButton = XtCreateManagedWidget("keepButton",                                     commandWidgetClass,				     ListForm, args, count);  XtAddCallback(keepButton, XtNcallback,		(XtCallbackProc) keepList, (XtPointer) shell);  count = 0;  XtSetArg(args[count], XtNforceBars, FALSE); count++;  XtSetArg(args[count], XtNallowVert, FALSE); count++;  XtSetArg(args[count], XtNallowHoriz, TRUE); count++;  ListTitleView = XtCreateManagedWidget("ListTitleView", viewportWidgetClass,					ListForm, args, count);  count = 0;  XtSetArg(args[count], XtNlabel, top_mess); count++;  (void) XtCreateManagedWidget("listTitle", labelWidgetClass, 				ListTitleView, args, count);  count = 0;  swindow = XtCreateManagedWidget("ListScrolledWindow", viewportWidgetClass,				  ListForm, args, count);  count = 0;  ListWindow = XtCreateManagedWidget("ListWindow", formWidgetClass,                                     swindow, args, count);  count = 0;  XtSetArg(args[count], XtNlabel, lower_mess); count++;  (void) XtCreateManagedWidget("ListMessage", labelWidgetClass,                                ListForm, args, count);    XtAddCallback(ListWindow, XtNdestroyCallback, 		ListDestroy, (XtPointer) list_seq);  AddNewList(ListWindow, list_seq,  (unsigned) entry_number);  XtRealizeWidget(shell);  XtPopup(shell, XtGrabNone);  curr_list_popup = shell;  CreateBackgroundPixmap(closeButton, Close_bits, Close_width, Close_height);  CreateBackgroundPixmap(keepButton, Keep_bits, Keep_width, Keep_height);  if (DefaultDepthOfScreen(screen) == 1)    CreateBackgroundPixmap(ListForm, gray_bits, gray_width, gray_height);}static void CreateCurrPosWindow(parent)     Widget parent;{  int count;  Widget PosForm, swindow, title;  Arg args[MAXARGS];  count = 0;  PosForm = XtCreateManagedWidget("PosForm", formWidgetClass,				       parent, args, count);  count = 0;  title = XtCreateManagedWidget("PosTitle", commandWidgetClass, PosForm,				args, count);  XtAddCallback(title, XtNcallback, CutString, (XtPointer) base_path);  count = 0;  swindow = XtCreateManagedWidget("PosScrolledWindow", viewportWidgetClass,				  PosForm, args, count);  count = 0;  (void) XtCreateManagedWidget("PosWindow", formWidgetClass,				    swindow, args, count);}static XtActionsRec actionsTable[] = {  {"TSearch", (XtActionProc) TSearch},  {"ClearSearchArea", (XtActionProc) ClearSearchArea},};static char defaultTranslations[] =    "<Key>Return: TSearch() \n\   Ctrl<Key>M:  TSearch() \n\   Ctrl<Key>O:  TSearch() \n\   Ctrl<Key>J:  TSearch() \n\   Ctrl<Key>U:  ClearSearchArea()";static void CreateSearchWindow(parent)     Widget parent;{  int count;  Arg args[MAXARGS];  Widget TypeForm, SearchVal;  XtTranslations trans_table;  XFontStruct *font;  Dimension height;  count = 0;  TypeForm = XtCreateManagedWidget("TypeForm", formWidgetClass,				   parent, args, count);  count = 0;  XtSetArg(args[count], XtNlabel, "Searching For"); count++;  (void) XtCreateManagedWidget("SearchValLabel", labelWidgetClass,				TypeForm, args, count);    count = 0;  XtSetArg(args[count], XtNeditType, XawtextEdit); count++;  SearchVal = XtCreateManagedWidget("SearchVal", asciiTextWidgetClass,				    TypeForm, args, count);  count = 0;  XtSetArg(args[count], XtNfont, &font); count++;  XtGetValues(SearchVal, args, count);  height = FONTHEIGHT(font);  height += 15;    count = 0;  XtSetArg(args[count], XtNheight, height); count++;  XtSetValues(SearchVal, args, count);  count = 0;  XtSetArg(args[count], XtNlabel, XtNresizable); count++;  (void) XtCreateManagedWidget("TypeButton", menuButtonWidgetClass,				TypeForm, args, count);  XtSetKeyboardFocus(parent, SearchVal);  XtAddActions(actionsTable, XtNumber(actionsTable));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?