man.h revision 6d36ef34
11abf7346Smrg/* 21abf7346Smrg 31abf7346SmrgCopyright (c) 1987, 1988 X Consortium 41abf7346Smrg 51abf7346SmrgPermission is hereby granted, free of charge, to any person obtaining 61abf7346Smrga copy of this software and associated documentation files (the 71abf7346Smrg"Software"), to deal in the Software without restriction, including 81abf7346Smrgwithout limitation the rights to use, copy, modify, merge, publish, 91abf7346Smrgdistribute, sublicense, and/or sell copies of the Software, and to 101abf7346Smrgpermit persons to whom the Software is furnished to do so, subject to 111abf7346Smrgthe following conditions: 121abf7346Smrg 131abf7346SmrgThe above copyright notice and this permission notice shall be included 141abf7346Smrgin all copies or substantial portions of the Software. 151abf7346Smrg 161abf7346SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 171abf7346SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 181abf7346SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 191abf7346SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 201abf7346SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 211abf7346SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 221abf7346SmrgOTHER DEALINGS IN THE SOFTWARE. 231abf7346Smrg 241abf7346SmrgExcept as contained in this notice, the name of the X Consortium shall 251abf7346Smrgnot be used in advertising or otherwise to promote the sale, use or 261abf7346Smrgother dealings in this Software without prior written authorization 271abf7346Smrgfrom the X Consortium. 281abf7346Smrg 291abf7346Smrg*/ 301abf7346Smrg 316d36ef34Smrg#ifdef HAVE_CONFIG_H 326d36ef34Smrg# include "config.h" 336d36ef34Smrg#endif 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 "defs.h" 741abf7346Smrg 751abf7346Smrg#define Error(x) { printf x ; exit(EXIT_FAILURE); } 761abf7346Smrg#define Assertion(expr, msg) { if (!(expr)) { Error msg } } 771abf7346Smrg#ifdef DEBUG 781abf7346Smrg# define Log(x) { if(True) printf x; } 791abf7346Smrg#else 801abf7346Smrg# define Log(x) { if(False) printf x; } 811abf7346Smrg#endif /* DEBUG */ 821abf7346Smrg 836d36ef34Smrg/* 841abf7346Smrg * Assigning values here allows the user of Bitwise Or. 851abf7346Smrg */ 861abf7346Smrg 871abf7346Smrgtypedef struct _XmanFonts { 886d36ef34Smrg XFontStruct *directory; /* The font for the directory. */ 891abf7346Smrg} XmanFonts; 901abf7346Smrg 911abf7346Smrgtypedef struct _XmanCursors { 926d36ef34Smrg Cursor top, /* The top Cursor, default for xman. */ 936d36ef34Smrg help, /* The top cursor for the help menu. */ 946d36ef34Smrg manpage, /* The cursor for the Manpage. */ 956d36ef34Smrg search_entry; /* The cursor for the text widget in the 966d36ef34Smrg search box. */ 976d36ef34Smrg Pixel fg_color; /* foreground color of cursors. */ 986d36ef34Smrg Pixel bg_color; /* background color of cursors. */ 991abf7346Smrg} XmanCursors; 1001abf7346Smrg 1011abf7346Smrgtypedef struct _ManPageWidgets { 1026d36ef34Smrg Widget manpage, /* The manual page window (scrolled) */ 1036d36ef34Smrg directory, /* The widget in which all directories will 1046d36ef34Smrg appear. */ 1056d36ef34Smrg *box; /* The boxes containing the sections. */ 1061abf7346Smrg} ManPageWidgets; 1071abf7346Smrg 1081abf7346Smrgtypedef struct _MenuStruct { 1096d36ef34Smrg caddr_t data; 1106d36ef34Smrg int number; 1116d36ef34Smrg XrmQuark quark; 1121abf7346Smrg} MenuStruct; 1131abf7346Smrg 1141abf7346Smrg/* 1151abf7346Smrg * The manual sections and entries 1161abf7346Smrg */ 1171abf7346Smrg 1181abf7346Smrgtypedef struct tManual { 1196d36ef34Smrg char *blabel; /* The button label. */ 1206d36ef34Smrg char **entries; /* The individual man page file names. */ 1216d36ef34Smrg char **entries_less_paths; /* Entry names only */ 1226d36ef34Smrg int nentries; /* how many (TOTAL) */ 1236d36ef34Smrg int nalloc; /* how much space allocated */ 1246d36ef34Smrg int flags; /* suffix, fold */ 1251abf7346Smrg} Manual; 1266d36ef34Smrg 1276d36ef34Smrg/* pseudo Globals that are specific to each manpage created. */ 1286d36ef34Smrg 1296d36ef34Smrgtypedef struct _ManpageGlobals { 1306d36ef34Smrg int current_directory; /* The directory currently being shown 1316d36ef34Smrg on this manpage. */ 1326d36ef34Smrg Boolean dir_shown, /* True if the directory is then current 1336d36ef34Smrg visible screen */ 1346d36ef34Smrg both_shown; /* If true then both the manpage and 1356d36ef34Smrg the directory are to be shown. */ 1366d36ef34Smrg Widget label, /* The label widget at the top of the page. */ 1376d36ef34Smrg standby, /* The please standby widget. */ 1386d36ef34Smrg save, /* The "would you like to save?" widget. */ 1396d36ef34Smrg search_widget, /* The search widget popup. */ 1406d36ef34Smrg help_button, /* The help button. */ 1416d36ef34Smrg option_menu, /* The option menu. */ 1426d36ef34Smrg text_widget; /* text widget containing search string. */ 1436d36ef34Smrg 1446d36ef34Smrg /* Widgets (Objects really) for the command menu entries. */ 1456d36ef34Smrg 1466d36ef34Smrg Widget dir_entry, manpage_entry, help_entry, 1476d36ef34Smrg search_entry, both_screens_entry, remove_entry, 1486d36ef34Smrg open_entry, print_entry, version_entry, quit_entry; 1496d36ef34Smrg 1501abf7346Smrg#ifdef INCLUDE_XPRINT_SUPPORT 1516d36ef34Smrg /* Print objects and data */ 1526d36ef34Smrg Widget printdialog_shell; /* Shell for the print dialog */ 1536d36ef34Smrg Widget printdialog; /* Print dialog */ 1546d36ef34Smrg#endif /*INCLUDE_XPRINT_SUPPORT */ 1556d36ef34Smrg /* Misc. */ 1561abf7346Smrg 1576d36ef34Smrg char manpage_title[80]; /* The label to use for the current manpage. */ 1581abf7346Smrg 1596d36ef34Smrg char save_file[80]; /* the name of the file to save formatted 1606d36ef34Smrg page into. */ 1616d36ef34Smrg char tempfile[80]; /* the name of the file to copy the formatted 1626d36ef34Smrg page from. */ 1636d36ef34Smrg Boolean compress; /* Compress file on save? */ 1646d36ef34Smrg Boolean gzip; /* Gzip file on save? */ 1656d36ef34Smrg Boolean bzip2; /* Bzip2 file on save? */ 1666d36ef34Smrg Boolean lzma; 1676d36ef34Smrg Boolean deletetempfile; /* Need to delete tempfile when done? */ 1686d36ef34Smrg char **section_name; /* The name of each of the sections */ 1691abf7346Smrg 1706d36ef34Smrg ManPageWidgets manpagewidgets; /* The manpage widgets. */ 1711abf7346Smrg 1726d36ef34Smrg /* Things to remember when cleaning up when killing manpage. */ 1731abf7346Smrg 1746d36ef34Smrg Widget This_Manpage; /* a pointer to the root of 1756d36ef34Smrg this manpage. */ 1761abf7346Smrg 1776d36ef34Smrg FILE *curr_file; /* Current file shown in manpage widget */ 1781abf7346Smrg} ManpageGlobals; 1791abf7346Smrg 1801abf7346Smrg 1811abf7346Smrg/* Resource manager sets these. */ 1821abf7346Smrg 1831abf7346Smrgtypedef struct _Xman_Resources { 1846d36ef34Smrg XmanFonts fonts; /* The fonts used for the man pages. */ 1856d36ef34Smrg XmanCursors cursors; /* The cursors for xman. */ 1866d36ef34Smrg Boolean show_help_syntax; /* True if syntax message should be dumped to 1876d36ef34Smrg stdout. */ 1886d36ef34Smrg Boolean both_shown_initial; /* The initial state of the manual pages 1896d36ef34Smrg show two screens or only one. */ 1906d36ef34Smrg Boolean top_box_active; /* Put up the Top Box. */ 1916d36ef34Smrg Boolean clear_search_string; /* clear the search string each time it 1926d36ef34Smrg is popped down? */ 1936d36ef34Smrg int directory_height; /* The default height of directory in 1946d36ef34Smrg both_shown mode. */ 1956d36ef34Smrg char *help_file; /* The name of the help file. */ 1966d36ef34Smrg char *title; /* The title for topBox */ 1976d36ef34Smrg Boolean iconic; /* Should topBox come up in an iconic state */ 1981abf7346Smrg} Xman_Resources; 1991abf7346Smrg 2001abf7346Smrg/************************************************************ 2011abf7346Smrg * 2026d36ef34Smrg * Function Definitions 2036d36ef34Smrg * 2041abf7346Smrg ************************************************************/ 2051abf7346Smrg 2061abf7346Smrg/* Standard library function definitions. */ 2071abf7346Smrg#include <stdlib.h> 2081abf7346Smrg 2091abf7346Smrg/* buttons.c */ 2101abf7346Smrg 2116d36ef34SmrgManpageGlobals *InitPsuedoGlobals(void); 2121abf7346SmrgWidget CreateManpage(FILE * file); 2136d36ef34Smrgvoid CreateManpageWidget(ManpageGlobals * man_globals, char *name, 2146d36ef34Smrg Boolean full_instance); 2156d36ef34Smrgvoid FormUpWidgets(Widget parent, 2166d36ef34Smrg const char **full_size, const char **half_size); 2176d36ef34Smrgvoid MakeDirectoryBox(ManpageGlobals * man_globals, Widget parent, 2186d36ef34Smrg Widget * dir_disp, int section); 2196d36ef34Smrgvoid MakeSaveWidgets(ManpageGlobals * man_globals, Widget parent); 2201abf7346Smrgvoid MakeTopBox(void); 2211abf7346Smrg 2221abf7346Smrg/* handler.c */ 2231abf7346Smrg 2241abf7346Smrgvoid DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk); 2251abf7346Smrgvoid DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val); 2261abf7346Smrgvoid OptionCallback(Widget w, XtPointer pointer, XtPointer junk); 2271abf7346Smrgvoid Popup(Widget w, XtGrabKind grab_kind); 2281abf7346Smrg 2291abf7346Smrg/* Action Routines. */ 2301abf7346Smrg 2316d36ef34Smrgvoid CreateNewManpage(Widget w, XEvent * event, String * params, 2326d36ef34Smrg Cardinal * num_params); 2331abf7346Smrgvoid GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params); 2346d36ef34Smrgvoid PopupHelp(Widget w, XEvent * event, String * params, 2356d36ef34Smrg Cardinal * num_params); 2366d36ef34Smrgvoid PopupSearch(Widget w, XEvent * event, String * params, 2376d36ef34Smrg Cardinal * num_params); 2381abf7346Smrgvoid Quit(Widget w, XEvent * event, String * params, Cardinal * num_params); 2396d36ef34Smrgvoid RemoveThisManpage(Widget w, XEvent * event, String * params, 2406d36ef34Smrg Cardinal * num_params); 2416d36ef34Smrgvoid SaveFormattedPage(Widget w, XEvent * event, String * params, 2426d36ef34Smrg Cardinal * num_params); 2431abf7346Smrgvoid Search(Widget w, XEvent * event, String * params, Cardinal * num_params); 2446d36ef34Smrg 2451abf7346Smrg#ifdef INCLUDE_XPRINT_SUPPORT 2466d36ef34Smrgvoid PrintThisManpage(Widget w, XEvent * event, String * params, 2476d36ef34Smrg Cardinal * num_params); 2481abf7346Smrg#endif /* INCLUDE_XPRINT_SUPPORT */ 2496d36ef34Smrgvoid ShowVersion(Widget w, XEvent * event, String * params, 2506d36ef34Smrg Cardinal * num_params); 2511abf7346Smrg 2521abf7346Smrg/* help.c */ 2531abf7346Smrg 2541abf7346SmrgBoolean MakeHelpWidget(void); 2551abf7346SmrgBoolean OpenHelpfile(ManpageGlobals * man_globals); 2561abf7346Smrg 2571abf7346Smrg/* man.c */ 2581abf7346SmrgBool ReadManConfig(char manpath[]); 2591abf7346Smrgint Man(void); 2601abf7346Smrg 2611abf7346Smrg/* misc.c */ 2626d36ef34Smrg#ifndef HAVE_MKSTEMP 2636d36ef34Smrg_X_HIDDEN int Xmkstemp (char *template); 2646d36ef34Smrg# define mkstemp Xmkstemp 2656d36ef34Smrg#endif 2666d36ef34Smrg 2676d36ef34SmrgFILE *FindManualFile(ManpageGlobals * man_globals, int section_num, 2686d36ef34Smrg int entry_num); 2696d36ef34SmrgManpageGlobals *GetGlobals(Widget w); 2706d36ef34Smrg 2711abf7346Smrgvoid AddCursor(Widget w, Cursor cursor); 2726d36ef34Smrgvoid ChangeLabel(Widget w, const char *str); 2731abf7346Smrgvoid OpenFile(ManpageGlobals * man_globals, FILE * file); 2746d36ef34Smrgvoid PopupWarning(ManpageGlobals * man_globals, const char *string); 2756d36ef34Smrgvoid PositionCenter(Widget widget, int x, int y, int above, int left, 2766d36ef34Smrg int v_space, int h_space); 2776d36ef34Smrgvoid PrintError(const char *string) _X_NORETURN; 2781abf7346Smrgvoid RemoveGlobals(Widget w); 2791abf7346Smrgvoid SaveGlobals(Widget w, ManpageGlobals * globals); 2806d36ef34Smrgvoid ParseEntry(const char *entry, char *path, char *sect, char *page); 2816d36ef34SmrgFILE *Format(ManpageGlobals * man_globals, const char *entry); 2821abf7346Smrg 2831abf7346Smrg/* search */ 2846d36ef34SmrgFILE *DoSearch(ManpageGlobals * man_globals, int type); 2851abf7346Smrgvoid MakeSearchWidget(ManpageGlobals * man_globals, Widget parent); 2861abf7346Smrg 2871abf7346Smrg/* tkfunctions.c */ 2881abf7346Smrg 2891abf7346Smrgint Width(Widget); 2901abf7346Smrgint Height(Widget); 2911abf7346Smrgint BorderWidth(Widget); 2926d36ef34Smrgchar *Name(Widget); 293