man.h revision 1abf7346
11abf7346Smrg/* $XConsortium: man.h,v 1.31 94/12/16 21:36:53 gildea Exp $ */ 21abf7346Smrg/* $XdotOrg: xc/programs/xman/man.h,v 1.6 2004/07/29 00:40:35 gisburn Exp $ */ 31abf7346Smrg/* 41abf7346Smrg 51abf7346SmrgCopyright (c) 1987, 1988 X Consortium 61abf7346Smrg 71abf7346SmrgPermission is hereby granted, free of charge, to any person obtaining 81abf7346Smrga copy of this software and associated documentation files (the 91abf7346Smrg"Software"), to deal in the Software without restriction, including 101abf7346Smrgwithout limitation the rights to use, copy, modify, merge, publish, 111abf7346Smrgdistribute, sublicense, and/or sell copies of the Software, and to 121abf7346Smrgpermit persons to whom the Software is furnished to do so, subject to 131abf7346Smrgthe following conditions: 141abf7346Smrg 151abf7346SmrgThe above copyright notice and this permission notice shall be included 161abf7346Smrgin all copies or substantial portions of the Software. 171abf7346Smrg 181abf7346SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 191abf7346SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 201abf7346SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 211abf7346SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 221abf7346SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 231abf7346SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 241abf7346SmrgOTHER DEALINGS IN THE SOFTWARE. 251abf7346Smrg 261abf7346SmrgExcept as contained in this notice, the name of the X Consortium shall 271abf7346Smrgnot be used in advertising or otherwise to promote the sale, use or 281abf7346Smrgother dealings in this Software without prior written authorization 291abf7346Smrgfrom the X Consortium. 301abf7346Smrg 311abf7346Smrg*/ 321abf7346Smrg/* $XFree86: xc/programs/xman/man.h,v 1.4 2001/07/25 15:05:27 dawes Exp $ */ 331abf7346Smrg 341abf7346Smrg 351abf7346Smrg/* X toolkit header files */ 361abf7346Smrg 371abf7346Smrg#include <X11/Intrinsic.h> 381abf7346Smrg#include <X11/StringDefs.h> 391abf7346Smrg#include <X11/Shell.h> 401abf7346Smrg 411abf7346Smrg#include <X11/Xaw/Cardinals.h> 421abf7346Smrg 431abf7346Smrg/* Std system and C header files */ 441abf7346Smrg 451abf7346Smrg#include <stdio.h> 461abf7346Smrg#include <limits.h> 471abf7346Smrg 481abf7346Smrg#include <X11/Xfuncs.h> 491abf7346Smrg#include <X11/Xos.h> 501abf7346Smrg 511abf7346Smrg/* X include files */ 521abf7346Smrg 531abf7346Smrg#include <X11/Xatom.h> 541abf7346Smrg 551abf7346Smrg/* Widget header files. */ 561abf7346Smrg 571abf7346Smrg#include <X11/Xaw/AsciiText.h> 581abf7346Smrg#include <X11/Xaw/SmeBSB.h> 591abf7346Smrg#include <X11/Xaw/Box.h> 601abf7346Smrg#include <X11/Xaw/Command.h> 611abf7346Smrg#include <X11/Xaw/Dialog.h> 621abf7346Smrg#include <X11/Xaw/Label.h> 631abf7346Smrg#include <X11/Xaw/List.h> 641abf7346Smrg#include <X11/Xaw/MenuButton.h> 651abf7346Smrg#include <X11/Xaw/SimpleMenu.h> 661abf7346Smrg#include <X11/Xaw/Paned.h> 671abf7346Smrg#include <X11/Xaw/Viewport.h> 681abf7346Smrg 691abf7346Smrg/* program specific header files. */ 701abf7346Smrg 711abf7346Smrg#include "ScrollByL.h" 721abf7346Smrg 731abf7346Smrg#include "version.h" 741abf7346Smrg#include "defs.h" 751abf7346Smrg 761abf7346Smrg/* Turn a NULL pointer string into an empty string */ 771abf7346Smrg#define NULLSTR(x) (((x)!=NULL)?(x):("")) 781abf7346Smrg 791abf7346Smrg#define Error(x) { printf x ; exit(EXIT_FAILURE); } 801abf7346Smrg#define Assertion(expr, msg) { if (!(expr)) { Error msg } } 811abf7346Smrg#ifdef DEBUG 821abf7346Smrg# define Log(x) { if(True) printf x; } 831abf7346Smrg#else 841abf7346Smrg# define Log(x) { if(False) printf x; } 851abf7346Smrg#endif /* DEBUG */ 861abf7346Smrg 871abf7346Smrg/* 881abf7346Smrg * Assigning values here allows the user of Bitwise Or. 891abf7346Smrg */ 901abf7346Smrg 911abf7346Smrgtypedef struct _XmanFonts { 921abf7346Smrg XFontStruct * directory; /* The font for the directory. */ 931abf7346Smrg} XmanFonts; 941abf7346Smrg 951abf7346Smrgtypedef struct _XmanCursors { 961abf7346Smrg Cursor top, /* The top Cursor, default for xman. */ 971abf7346Smrg help, /* The top cursor for the help menu. */ 981abf7346Smrg manpage, /* The cursor for the Manpage. */ 991abf7346Smrg search_entry; /* The cursor for the text widget in the 1001abf7346Smrg search box.*/ 1011abf7346Smrg Pixel fg_color; /* foreground color of cursors. */ 1021abf7346Smrg Pixel bg_color; /* background color of cursors. */ 1031abf7346Smrg} XmanCursors; 1041abf7346Smrg 1051abf7346Smrgtypedef struct _ManPageWidgets { 1061abf7346Smrg Widget manpage, /* The manual page window (scrolled) */ 1071abf7346Smrg directory, /* The widget in which all directories will 1081abf7346Smrg appear. */ 1091abf7346Smrg *box; /* The boxes containing the sections. */ 1101abf7346Smrg} ManPageWidgets; 1111abf7346Smrg 1121abf7346Smrgtypedef struct _MenuStruct { 1131abf7346Smrg caddr_t data; 1141abf7346Smrg int number; 1151abf7346Smrg XrmQuark quark; 1161abf7346Smrg} MenuStruct; 1171abf7346Smrg 1181abf7346Smrg/* 1191abf7346Smrg * The manual sections and entries 1201abf7346Smrg */ 1211abf7346Smrg 1221abf7346Smrgtypedef struct tManual { 1231abf7346Smrg char * blabel; /* The button label. */ 1241abf7346Smrg char ** entries; /* The individual man page file names. */ 1251abf7346Smrg char ** entries_less_paths; /* Entry names only */ 1261abf7346Smrg int nentries; /* how many (TOTAL)*/ 1271abf7346Smrg int nalloc; /* how much space allocated */ 1281abf7346Smrg int flags; /* suffix, fold */ 1291abf7346Smrg} Manual; 1301abf7346Smrg 1311abf7346Smrg/* psuedo Globals that are specific to each manpage created. */ 1321abf7346Smrg 1331abf7346Smrgtypedef struct _ManpageGlobals{ 1341abf7346Smrg int current_directory; /* The directory currently being shown 1351abf7346Smrg on this manpage. */ 1361abf7346Smrg Boolean dir_shown, /* True if the directory is then current 1371abf7346Smrg visable screen */ 1381abf7346Smrg both_shown; /* If true then both the manpage and 1391abf7346Smrg the directory are to be shown.*/ 1401abf7346Smrg Widget label, /* The label widget at the top of the page. */ 1411abf7346Smrg standby, /* The please standby widget. */ 1421abf7346Smrg save, /* The "would you like to save?" widget. */ 1431abf7346Smrg search_widget, /* The search widget popup. */ 1441abf7346Smrg help_button, /* The help button. */ 1451abf7346Smrg option_menu, /* The option menu. */ 1461abf7346Smrg text_widget; /* text widget containing search string. */ 1471abf7346Smrg 1481abf7346Smrg /* Widgets (Objects really) for the command menu entries. */ 1491abf7346Smrg 1501abf7346Smrg Widget dir_entry, manpage_entry, help_entry, 1511abf7346Smrg search_entry, both_screens_entry, remove_entry, 1521abf7346Smrg open_entry, print_entry, version_entry, quit_entry; 1531abf7346Smrg 1541abf7346Smrg#ifdef INCLUDE_XPRINT_SUPPORT 1551abf7346Smrg /* Print objects and data */ 1561abf7346Smrg Widget printdialog_shell; /* Shell for the print dialog */ 1571abf7346Smrg Widget printdialog; /* Print dialog */ 1581abf7346Smrg#endif /*INCLUDE_XPRINT_SUPPORT */ 1591abf7346Smrg /* Misc. */ 1601abf7346Smrg 1611abf7346Smrg char manpage_title[80]; /* The label to use for the current manpage. */ 1621abf7346Smrg 1631abf7346Smrg char save_file[80]; /* the name of the file to save fomatted 1641abf7346Smrg page into. */ 1651abf7346Smrg char tempfile[80]; /* the name of the file to copy the formatted 1661abf7346Smrg page from. */ 1671abf7346Smrg Boolean compress; /* Compress file on save? */ 1681abf7346Smrg Boolean gzip; /* Gzip file on save? */ 1691abf7346Smrg Boolean deletetempfile; /* Need to delete tempfile when done? */ 1701abf7346Smrg char ** section_name; /* The name of each of the sections */ 1711abf7346Smrg 1721abf7346Smrg ManPageWidgets manpagewidgets; /* The manpage widgets. */ 1731abf7346Smrg 1741abf7346Smrg /* Things to remember when cleaning up when killing manpage. */ 1751abf7346Smrg 1761abf7346Smrg Widget This_Manpage; /* a pointer to the root of 1771abf7346Smrg this manpage. */ 1781abf7346Smrg 1791abf7346Smrg FILE *curr_file; /* Current file shown in manpage widget */ 1801abf7346Smrg} ManpageGlobals; 1811abf7346Smrg 1821abf7346Smrg 1831abf7346Smrg/* Resource manager sets these. */ 1841abf7346Smrg 1851abf7346Smrgtypedef struct _Xman_Resources { 1861abf7346Smrg XmanFonts fonts; /* The fonts used for the man pages. */ 1871abf7346Smrg XmanCursors cursors; /* The cursors for xman. */ 1881abf7346Smrg Boolean show_help_syntax; /* True if syntax message should be dumped to 1891abf7346Smrg stdout. */ 1901abf7346Smrg Boolean both_shown_initial; /* The initial state of the manual pages 1911abf7346Smrg show two screens or only one. */ 1921abf7346Smrg Boolean top_box_active; /* Put up the Top Box. */ 1931abf7346Smrg Boolean clear_search_string; /* clear the search string each time it 1941abf7346Smrg is popped down? */ 1951abf7346Smrg int directory_height; /* The default height of directory in 1961abf7346Smrg both_shown mode. */ 1971abf7346Smrg char * help_file; /* The name of the help file. */ 1981abf7346Smrg char * title; /* The title for topBox */ 1991abf7346Smrg Boolean iconic; /* Should topBox come up in an iconic state */ 2001abf7346Smrg} Xman_Resources; 2011abf7346Smrg 2021abf7346Smrg/************************************************************ 2031abf7346Smrg * 2041abf7346Smrg * Function Defintions 2051abf7346Smrg * 2061abf7346Smrg ************************************************************/ 2071abf7346Smrg 2081abf7346Smrg/* 2091abf7346Smrg * This is easier than trying to find all calls to StrAlloc(). 2101abf7346Smrg */ 2111abf7346Smrg 2121abf7346Smrg#define StrAlloc(ptr) XtNewString(ptr) 2131abf7346Smrg 2141abf7346Smrg/* Standard library function definitions. */ 2151abf7346Smrg#include <stdlib.h> 2161abf7346Smrg 2171abf7346Smrg/* buttons.c */ 2181abf7346Smrg 2191abf7346SmrgManpageGlobals * InitPsuedoGlobals(void); 2201abf7346SmrgWidget CreateManpage(FILE * file); 2211abf7346Smrgvoid CreateManpageWidget(ManpageGlobals * man_globals, char * name, Boolean full_instance); 2221abf7346Smrgvoid FormUpWidgets(Widget parent, char ** full_size, char ** half_size); 2231abf7346Smrgvoid MakeDirectoryBox(ManpageGlobals *man_globals, Widget parent, Widget *dir_disp, int section); 2241abf7346Smrgvoid MakeSaveWidgets(ManpageGlobals *man_globals, Widget parent); 2251abf7346Smrgvoid MakeTopBox(void); 2261abf7346Smrg 2271abf7346Smrg/* handler.c */ 2281abf7346Smrg 2291abf7346Smrgvoid DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk); 2301abf7346Smrgvoid DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val); 2311abf7346Smrgvoid OptionCallback(Widget w, XtPointer pointer, XtPointer junk); 2321abf7346Smrgvoid Popup(Widget w, XtGrabKind grab_kind); 2331abf7346Smrg 2341abf7346Smrg/* Action Routines. */ 2351abf7346Smrg 2361abf7346Smrgvoid CreateNewManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2371abf7346Smrgvoid GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2381abf7346Smrgvoid PopupHelp(Widget w, XEvent * event, String * params, Cardinal * num_params); 2391abf7346Smrgvoid PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params); 2401abf7346Smrgvoid Quit(Widget w, XEvent * event, String * params, Cardinal * num_params); 2411abf7346Smrgvoid RemoveThisManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2421abf7346Smrgvoid SaveFormattedPage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2431abf7346Smrgvoid Search(Widget w, XEvent * event, String * params, Cardinal * num_params); 2441abf7346Smrg#ifdef INCLUDE_XPRINT_SUPPORT 2451abf7346Smrgvoid PrintThisManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2461abf7346Smrg#endif /* INCLUDE_XPRINT_SUPPORT */ 2471abf7346Smrgvoid ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params); 2481abf7346Smrg 2491abf7346Smrg/* help.c */ 2501abf7346Smrg 2511abf7346SmrgBoolean MakeHelpWidget(void); 2521abf7346SmrgBoolean OpenHelpfile(ManpageGlobals * man_globals); 2531abf7346Smrg 2541abf7346Smrg/* man.c */ 2551abf7346SmrgBool ReadManConfig(char manpath[]); 2561abf7346Smrgint Man(void); 2571abf7346Smrg 2581abf7346Smrg/* misc.c */ 2591abf7346SmrgFILE * FindManualFile(ManpageGlobals * man_globals, int section_num, int entry_num); 2601abf7346SmrgManpageGlobals * GetGlobals(Widget w); 2611abf7346Smrgvoid AddCursor(Widget w, Cursor cursor); 2621abf7346Smrgvoid ChangeLabel(Widget w, char * str); 2631abf7346Smrgvoid OpenFile(ManpageGlobals * man_globals, FILE * file); 2641abf7346Smrgvoid PopupWarning(ManpageGlobals * man_globals, char * string); 2651abf7346Smrgvoid PositionCenter(Widget widget, int x, int y, int above, int left, int v_space, int h_space); 2661abf7346Smrgvoid PrintError(char * string); 2671abf7346Smrgvoid RemoveGlobals(Widget w); 2681abf7346Smrgvoid SaveGlobals(Widget w, ManpageGlobals * globals); 2691abf7346Smrgvoid ParseEntry(char *entry, char *path, char *sect, char *page); 2701abf7346SmrgFILE * Format(ManpageGlobals * man_globals, char * entry); 2711abf7346Smrg 2721abf7346Smrg/* search */ 2731abf7346SmrgFILE * DoSearch(ManpageGlobals * man_globals, int type); 2741abf7346Smrgvoid MakeSearchWidget(ManpageGlobals * man_globals, Widget parent); 2751abf7346Smrg 2761abf7346Smrg/* tkfunctions.c */ 2771abf7346Smrg 2781abf7346Smrgint Width(Widget); 2791abf7346Smrgint Height(Widget); 2801abf7346Smrgint BorderWidth(Widget); 2811abf7346Smrgchar * Name(Widget); 282