"Fossies" - the Fresh Open Source Software Archive

Member "ghostview-1.5/main.c" (24 Jul 1993, 38255 Bytes) of package /linux/misc/old/ghost/gnu/ghostview/ghostview-1.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * main.c -- Main routine for ghostview.
    3  * Copyright (C) 1992  Timothy O. Theisen
    4  *
    5  * This program is free software; you can redistribute it and/or modify
    6  * it under the terms of the GNU General Public License as published by
    7  * the Free Software Foundation; either version 2 of the License, or
    8  * (at your option) any later version.
    9  *
   10  * This program is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  * GNU General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU General Public License
   16  * along with this program; if not, write to the Free Software
   17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18  *
   19  *   Author: Tim Theisen           Systems Programmer
   20  * Internet: tim@cs.wisc.edu       Department of Computer Sciences
   21  *     UUCP: uwvax!tim             University of Wisconsin-Madison
   22  *    Phone: (608)262-0438         1210 West Dayton Street
   23  *      FAX: (608)262-9777         Madison, WI   53706
   24  */
   25 
   26 #include <X11/Intrinsic.h>
   27 #include <X11/cursorfont.h>
   28 #include <X11/StringDefs.h>
   29 #include <X11/Shell.h>
   30 #ifdef VMS
   31 #include <X11/bitmaps/dot.>
   32 #include <X11/bitmaps/menu16.>
   33 #include <X11/bitmaps/tie_fighter.>
   34 #else
   35 #include <X11/bitmaps/dot>
   36 #include <X11/bitmaps/menu16>
   37 #include <X11/bitmaps/tie_fighter>
   38 #endif
   39 
   40 #include <X11/Xaw/Cardinals.h>
   41 #include <X11/Xaw/Form.h>
   42 #include <X11/Xaw/Viewport.h>
   43 #include <X11/Xaw/Box.h>
   44 #include <X11/Xaw/MenuButton.h>
   45 #include <X11/Xaw/SimpleMenu.h>
   46 #include <X11/Xaw/SmeBSB.h>
   47 #include <X11/Xaw/SmeLine.h>
   48 #include <X11/Xaw/Label.h>
   49 #include <X11/Xaw/AsciiText.h>
   50 #include <X11/Xaw/Command.h>
   51 
   52 #include "Ghostview.h"
   53 #include "gv.h"
   54 #include "ps.h"
   55 
   56 extern char *getenv();
   57 
   58 static String version = "Ghostview, version 1.5";
   59 
   60 static XtResource resources[] = {
   61     {"showTitle", "Labels", XtRBoolean, sizeof(Boolean),
   62      XtOffsetOf(AppResources, show_title), XtRImmediate, (XtPointer)True},
   63     {"showDate", "Labels", XtRBoolean, sizeof(Boolean),
   64      XtOffsetOf(AppResources, show_date), XtRImmediate, (XtPointer)True},
   65     {"showLocator", "Labels", XtRBoolean, sizeof(Boolean),
   66      XtOffsetOf(AppResources, show_locator), XtRImmediate, (XtPointer)True},
   67     {"autoCenter", "AutoCenter", XtRBoolean, sizeof(Boolean),
   68      XtOffsetOf(AppResources, auto_center), XtRImmediate, (XtPointer)True},
   69     {"horizontalMargin", "Margin", XtRInt, sizeof(int),
   70      XtOffsetOf(AppResources, wm_horiz_margin), XtRImmediate, (XtPointer)20},
   71     {"verticalMargin", "Margin", XtRInt, sizeof(int),
   72      XtOffsetOf(AppResources, wm_vert_margin), XtRImmediate, (XtPointer)44},
   73     {"minimumMagstep", "Magstep", XtRInt, sizeof(int),
   74      XtOffsetOf(AppResources, minimum_magstep), XtRImmediate, (XtPointer)-5},
   75     {"maximumMagstep", "Magstep", XtRInt, sizeof(int),
   76      XtOffsetOf(AppResources, maximum_magstep), XtRImmediate, (XtPointer)5},
   77     {"magstep", "Magstep", XtRInt, sizeof(int),
   78      XtOffsetOf(AppResources, magstep), XtRImmediate, (XtPointer)0},
   79     {"orientation", "Orientation", XtRPageOrientation,
   80      sizeof(XtPageOrientation), XtOffsetOf(AppResources, orientation),
   81      XtRImmediate, (XtPointer) XtPageOrientationPortrait},
   82     {"page", "Page", XtRString, sizeof(String),
   83      XtOffsetOf(AppResources, page), XtRImmediate, NULL},
   84     {"pageMedia", "PageMedia", XtRString, sizeof(String),
   85      XtOffsetOf(AppResources, pagemedia), XtRImmediate, "Letter"},
   86     {"forceOrientation", "Force", XtRBoolean, sizeof(Boolean),
   87      XtOffsetOf(AppResources, force_orientation), XtRImmediate,
   88      (XtPointer)False},
   89     {"forcePageMedia", "Force", XtRBoolean, sizeof(Boolean),
   90      XtOffsetOf(AppResources, force_pagemedia), XtRImmediate, (XtPointer)False},
   91     {"swapLandscape", "SwapLandscape", XtRBoolean, sizeof(Boolean),
   92      XtOffsetOf(AppResources, swap_landscape), XtRImmediate, (XtPointer)False},
   93 #ifndef VMS
   94 #if defined(SVR4) || defined(SYSV) || defined(USG)
   95     {"printCommand", "PrintCommand", XtRString, sizeof(String),
   96      XtOffsetOf(AppResources, print_command), XtRImmediate, "lp"},
   97     {"printerVariable", "PrinterVariable", XtRString, sizeof(String),
   98      XtOffsetOf(AppResources, printer_variable), XtRImmediate, "LPDEST"},
   99 #else
  100     {"printCommand", "PrintCommand", XtRString, sizeof(String),
  101      XtOffsetOf(AppResources, print_command), XtRImmediate, "lpr"},
  102     {"printerVariable", "PrinterVariable", XtRString, sizeof(String),
  103      XtOffsetOf(AppResources, printer_variable), XtRImmediate, "PRINTER"},
  104 #endif
  105     {"printPrompt", "PrintPrompt", XtRString, sizeof(String),
  106      XtOffsetOf(AppResources, print_prompt), XtRImmediate, "Printer Name:"},
  107 #else /* VMS */
  108     {"printCommand", "PrintCommand", XtRString, sizeof(String),
  109      XtOffsetOf(AppResources, print_command), XtRImmediate, "Print_dcl/Delete"},
  110     {"printerVariable", "PrinterVariable", XtRString, sizeof(String),
  111      XtOffsetOf(AppResources, printer_variable), XtRImmediate, "GV_PRINT_QUAL"},
  112     {"printPrompt", "PrintPrompt", XtRString, sizeof(String),
  113      XtOffsetOf(AppResources, print_prompt), XtRImmediate, "Print Qualifiers:"},
  114 #endif /* VMS */
  115     {"defaultPrinter", "DefaultPrinter", XtRString, sizeof(String),
  116      XtOffsetOf(AppResources, default_printer), XtRImmediate, NULL},
  117     {"printFail", "printFail", XtRString, sizeof(String),
  118      XtOffsetOf(AppResources, print_fail), XtRImmediate,
  119      "\"%s\" command failed."},
  120     {"openPrompt", "OpenPrompt", XtRString, sizeof(String),
  121      XtOffsetOf(AppResources, open_prompt), XtRImmediate, "Open File:"},
  122     {"openFail", "OpenFail", XtRString, sizeof(String),
  123      XtOffsetOf(AppResources, open_fail), XtRImmediate, "Cannot open file: "},
  124     {"savePrompt", "SavePrompt", XtRString, sizeof(String),
  125      XtOffsetOf(AppResources, save_prompt), XtRImmediate, "Save File:"},
  126     {"saveFail", "SaveFail", XtRString, sizeof(String),
  127      XtOffsetOf(AppResources, save_fail), XtRImmediate, "Cannot save file: "},
  128     {"openWindows", "OpenWindows", XtRBoolean, sizeof(Boolean),
  129      XtOffsetOf(AppResources, openwindows), XtRImmediate, (XtPointer)False},
  130     {"ncdwm", "Ncdwm", XtRBoolean, sizeof(Boolean),
  131      XtOffsetOf(AppResources, ncdwm), XtRImmediate, (XtPointer)False},
  132 };
  133 
  134 static XrmOptionDescRec options[] = {
  135     {"-monochrome", "*Ghostview.palette", XrmoptionNoArg, "Monochrome"},
  136     {"-grayscale", "*Ghostview.palette", XrmoptionNoArg, "Grayscale"},
  137     {"-color", "*Ghostview.palette", XrmoptionNoArg, "Color"},
  138     {"-page", ".page", XrmoptionSepArg, NULL},
  139     {"-title", ".showTitle", XrmoptionNoArg, "True"},
  140     {"-notitle", ".showTitle", XrmoptionNoArg, "False"},
  141     {"-date", ".showDate", XrmoptionNoArg, "True"},
  142     {"-nodate", ".showDate", XrmoptionNoArg, "False"},
  143     {"-locator", ".showLocator", XrmoptionNoArg, "True"},
  144     {"-nolocator", ".showLocator", XrmoptionNoArg, "False"},
  145     {"-center", ".autoCenter", XrmoptionNoArg, "True"},
  146     {"-nocenter", ".autoCenter", XrmoptionNoArg, "False"},
  147     {"-labels", ".Labels", XrmoptionNoArg, "True"},
  148     {"-nolabels", ".Labels", XrmoptionNoArg, "False"},
  149     {"-quiet", "*Ghostview.quiet", XrmoptionNoArg, "True"},
  150     {"-noquiet", "*Ghostview.quiet", XrmoptionNoArg, "False"},
  151     {"-safer", "*Ghostview.safer", XrmoptionNoArg, "True"},
  152     {"-nosafer", "*Ghostview.safer", XrmoptionNoArg, "False"},
  153     {"-arguments", "*Ghostview.arguments", XrmoptionSepArg, NULL},
  154     {"-xdpi", "*Ghostview.xdpi", XrmoptionSepArg, NULL},
  155     {"-ydpi", "*Ghostview.ydpi", XrmoptionSepArg, NULL},
  156     {"-dpi", "*Ghostview.Resolution", XrmoptionSepArg, NULL},
  157     {"-resolution", "*Ghostview.Resolution", XrmoptionSepArg, NULL},
  158     {"-magstep", ".magstep", XrmoptionSepArg, NULL},
  159     {"-portrait", ".orientation", XrmoptionNoArg, "Portrait"},
  160     {"-landscape", ".orientation", XrmoptionNoArg, "Landscape"},
  161     {"-upsidedown", ".orientation", XrmoptionNoArg, "Upside-down"},
  162     {"-seascape", ".orientation", XrmoptionNoArg, "Seascape"},
  163     {"-forceorientation", ".forceOrientation", XrmoptionNoArg, "True"},
  164     {"-letter", ".pageMedia", XrmoptionNoArg, "Letter"},
  165     {"-tabloid", ".pageMedia", XrmoptionNoArg, "Tabloid"},
  166     {"-ledger", ".pageMedia", XrmoptionNoArg, "Ledger"},
  167     {"-legal", ".pageMedia", XrmoptionNoArg, "Legal"},
  168     {"-statement", ".pageMedia", XrmoptionNoArg, "Statement"},
  169     {"-executive", ".pageMedia", XrmoptionNoArg, "Executive"},
  170     {"-a3", ".pageMedia", XrmoptionNoArg, "A3"},
  171     {"-a4", ".pageMedia", XrmoptionNoArg, "A4"},
  172     {"-a5", ".pageMedia", XrmoptionNoArg, "A5"},
  173     {"-b4", ".pageMedia", XrmoptionNoArg, "B4"},
  174     {"-b5", ".pageMedia", XrmoptionNoArg, "B5"},
  175     {"-folio", ".pageMedia", XrmoptionNoArg, "Folio"},
  176     {"-quarto", ".pageMedia", XrmoptionNoArg, "Quarto"},
  177     {"-10x14", ".pageMedia", XrmoptionNoArg, "10x14"},
  178     {"-forcemedia", ".forcePageMedia", XrmoptionNoArg, "True"},
  179     {"-force", ".Force", XrmoptionNoArg, "True"},
  180     {"-swap", ".swapLandscape", XrmoptionNoArg, "True"},
  181     {"-noswap", ".swapLandscape", XrmoptionNoArg, "False"},
  182     {"-openwindows", ".openWindows", XrmoptionNoArg, "True"},
  183     {"-noopenwindows", ".openWindows", XrmoptionNoArg, "False"},
  184     {"-ncdwm", ".ncdwm", XrmoptionNoArg, "True"},
  185     {"-noncdwm", ".ncdwm", XrmoptionNoArg, "False"},
  186 };
  187 
  188 static XtActionsRec actions[] = {
  189     {"GhostviewCopyright",  gv_copyright},
  190     {"GhostviewQuit",       gv_quit},
  191     {"GhostviewOpen",       gv_open},
  192     {"GhostviewReopen",     gv_reopen},
  193     {"GhostviewSave",       gv_save},
  194     {"GhostviewPrintWhole", gv_print_whole},
  195     {"GhostviewPrintMarked",    gv_print_marked},
  196     {"GhostviewPrevious",   gv_prev},
  197     {"GhostviewShow",       gv_show},
  198     {"GhostviewNext",       gv_next},
  199     {"GhostviewCenter",     gv_center},
  200     {"GhostviewMark",       gv_mark},
  201     {"GhostviewUnmark",     gv_unmark},
  202     {"GhostviewSetMagstep", gv_set_magstep},
  203     {"GhostviewIncreaseMagstep",gv_increase_magstep},
  204     {"GhostviewDecreaseMagstep",gv_decrease_magstep},
  205     {"GhostviewSetOrientation", gv_set_orientation},
  206     {"GhostviewSwapLandscape",  gv_swap_landscape},
  207     {"GhostviewSetPageMedia",   gv_set_pagemedia},
  208     {"GhostviewDefault",    gv_default},
  209     {"GhostviewForce",      gv_force},
  210     {"GhostviewDeleteWindow",   gv_delete_window},
  211     {"GhostviewDeleteZoom", gv_delete_zoom},
  212     {"GhostviewDismiss",    gv_dismiss},
  213     {"GhostviewScrollUp",   gv_scroll_up},
  214     {"GhostviewScrollDown", gv_scroll_down},
  215     {"GhostviewScrollLeft", gv_scroll_left},
  216     {"GhostviewScrollRight",    gv_scroll_right},
  217     {"GhostviewEraseLocator",   gv_erase_locator},
  218     {"GhostviewCheckFile",  gv_check_file},
  219 };
  220 
  221 String fallback_resources[] = {
  222 #   include "app-defaults.h"
  223     NULL
  224 };
  225 
  226 #define ROWS 22
  227 #define COLS 68
  228 static String copyright = "\
  229 Ghostview -- An X11 user interface for ghostscript.\n\
  230 Copyright (C) 1992  Timothy O. Theisen\n\
  231 \n\
  232 This program is free software; you can redistribute it and/or modify\n\
  233 it under the terms of the GNU General Public License as published by\n\
  234 the Free Software Foundation; either version 2 of the License, or\n\
  235 (at your option) any later version.\n\
  236 \n\
  237 This program is distributed in the hope that it will be useful,\n\
  238 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
  239 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\
  240 GNU General Public License for more details.\n\
  241 \n\
  242 You should have received a copy of the GNU General Public License\n\
  243 along with this program; if not, write to the Free Software\n\
  244 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\
  245 \n\
  246   Author: Tim Theisen           Systems Programmer\n\
  247 Internet: tim@cs.wisc.edu       Department of Computer Sciences\n\
  248     UUCP: uwvax!tim             University of Wisconsin-Madison\n\
  249    Phone: (608)262-0438         1210 West Dayton Street\n\
  250      FAX: (608)262-9777         Madison, WI   53706";
  251 
  252 static void Syntax();
  253 
  254 float   default_xdpi;   /* default xdpi from ghostview widget */
  255 float   default_ydpi;   /* default ydpi from ghostview widget */
  256 
  257 int num_ghosts; /* number of ghostview widgets active */
  258 FILE    *psfile;    /* file to display */
  259 String  filename;   /* its filename */
  260 String  oldfilename;    /* previous filename */
  261 int current_page;   /* current page being displayed */
  262 int current_magstep;/* current magnification */
  263 XtPageOrientation   current_orientation; /* current orientation */
  264 int default_pagemedia;  /* index into document media or papersizes */
  265 int current_pagemedia;  /* index into document media or papersizes */
  266 Boolean force_document_media;   /* Whether to force a document media */
  267 int document_media;     /* document media being forced */
  268 int current_llx;        /* current bounding box */
  269 int current_lly;
  270 int current_urx;
  271 int current_ury;
  272 int base_papersize;     /* tells where papersizes begins */
  273 Boolean info_up;        /* tells if information window is up */
  274 int force_setting;      /* tells if new setting override %%comments */
  275 Pixmap  dot_bitmap;     /* bitmap used to mark default setting */
  276 Pixmap  menu16_bitmap;      /* bitmap used to mark document setting */
  277 Pixmap  tie_fighter_bitmap; /* bitmap used to mark forced setting */
  278 String  toc_text;   /* page labels (Table of Contents) */
  279 int toc_length; /* length of page label text */
  280 int toc_entry_length; /* length of one entry */
  281 int info_length;    /* number of bytes in infotext window */
  282 int mode;   /* tells what type of popup */
  283 time_t  mtime;      /* last modified time of input file */
  284 struct document *doc;   /* document structure */
  285 struct document *olddoc;    /* document structure */
  286 Atom    wm_delete_window;   /* Atom sent to destroy a window */
  287 XErrorHandler   old_Xerror; /* standard error handler */
  288 Boolean dying;      /* whether an X error caused our exit */
  289 XErrorEvent bomb;   /* what the error was */
  290 
  291 XtAppContext app_con;
  292 AppResources app_res;
  293 
  294 /* Widgets used.  Indentation indicates hierarchy */
  295         Widget toplevel;
  296         Widget     form;
  297         Widget         titlebutton;
  298         Widget             titlemenu;
  299         Widget         datebutton;
  300         Widget             datemenu;
  301         Widget         locator;
  302         Widget         box;
  303         Widget             filebutton;
  304         Widget                 filemenu;
  305         Widget                     openbutton;
  306         Widget                     reopenbutton;
  307         Widget                     printwholebutton;
  308         Widget                     printmarkedbutton;
  309         Widget                     savebutton;
  310         Widget                     copyrightbutton;
  311         Widget                     quitbutton;
  312         Widget             pagebutton;
  313         Widget                 pagemenu;
  314         Widget                     nextbutton;
  315         Widget                     showbutton;
  316         Widget                     prevbutton;
  317         Widget                     centerbutton;
  318         Widget                     markbutton;
  319         Widget                     unmarkbutton;
  320         Widget             magstepbutton;
  321         Widget                 magstepmenu;
  322         Widget                     *magstepentry;
  323         Widget             orientationbutton;
  324         Widget                 orientationmenu;
  325         Widget                     portraitbutton;
  326         Widget                     landscapebutton;
  327         Widget                     upsidedownbutton;
  328         Widget                     seascapebutton;
  329         Widget                     swapbutton;
  330         Widget             pagemediabutton;
  331         Widget                 pagemediamenu;
  332         Widget                     *pagemediaentry;
  333         Widget         toc;
  334         Widget         pageview;
  335         Widget             page;
  336 
  337 /* Popup children */
  338         Widget infopopup;
  339         Widget     infoform;
  340         Widget         infotext;
  341         Widget         infodismiss;
  342         Widget copyrightpopup;
  343         Widget     copyrightform;
  344         Widget         copyrighttext;
  345         Widget         copyrightdismiss;
  346         Widget dialogpopup;
  347         Widget     dialog;
  348 
  349 int
  350 main(argc, argv)
  351 int argc;
  352 char *argv[];
  353 {
  354     struct stat sbuf;
  355     Display *dpy;
  356     Screen *scr;
  357     Arg args[20];
  358     Cardinal num_args;
  359     Widget above_toc;
  360     Widget left_of_page;
  361     Widget line;
  362     int i;
  363     Boolean set_vert_dist;
  364     String s1, s2;
  365     XFontStruct *font;
  366     XTextProperty nameprop;
  367     Dimension bottomMargin, leftMargin, rightMargin, topMargin;
  368     Dimension width, height;
  369     Dimension button_width;
  370     static String nothing = "";
  371     static XawTextSelectType sarry[] =
  372         {XawselectLine, XawselectAll, XawselectNull};
  373 
  374     XtToolkitInitialize();
  375     XtSetTypeConverter(XtRString, XtRPageOrientation,
  376                XmuCvtStringToPageOrientation, NULL, 0,
  377                XtCacheAll, NULL);
  378     app_con = XtCreateApplicationContext();
  379     XtAppAddActions(app_con, actions, XtNumber(actions));
  380     XtAppSetFallbackResources(app_con, fallback_resources);
  381     dpy = XtOpenDisplay(app_con, NULL, NULL, "Ghostview",
  382             options, XtNumber(options), &argc, argv);
  383     if (dpy == NULL) {
  384     fprintf(stderr, "%s: cannot open DISPLAY.\n", argv[0]);
  385     exit(1);
  386     }
  387     if (argc > 2) Syntax(argv[0]);
  388     if (argc == 2) {
  389     filename = XtNewString(argv[1]);
  390     if (strcmp(filename, "-")) {
  391 #ifdef VMS
  392         if ((psfile = fopen(argv[1], "r", "mbc=100")) == NULL) {
  393 #else
  394         if ((psfile = fopen(argv[1], "r")) == NULL) {
  395 #endif
  396         fprintf(stderr, "Cannot open ");
  397         perror(argv[1]);
  398         exit(1);
  399         }
  400         stat(filename, &sbuf);
  401         mtime = sbuf.st_mtime;
  402     }
  403     }
  404 
  405     old_Xerror = XSetErrorHandler(catch_Xerror);
  406     scr = DefaultScreenOfDisplay(dpy);
  407     wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
  408 
  409     toplevel = XtAppCreateShell(NULL, "Ghostview", applicationShellWidgetClass,
  410                 dpy, NULL, ZERO);
  411 
  412     XtGetApplicationResources(toplevel, (XtPointer) &app_res,
  413                   resources, XtNumber(resources), NULL, ZERO);
  414     if (s1 = getenv(app_res.printer_variable)) app_res.default_printer = s1;
  415 
  416     /* Open Windows sometimes hands me a bad bitmap */
  417     if (app_res.openwindows) {
  418     dot_bitmap = menu16_bitmap = tie_fighter_bitmap = None;
  419     } else {
  420     dot_bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr),
  421                        dot_bits, dot_width, dot_height);
  422     menu16_bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr),
  423                           menu16_bits, menu16_width,
  424                           menu16_height);
  425     tie_fighter_bitmap = XCreateBitmapFromData(dpy, RootWindowOfScreen(scr),
  426                            tie_fighter_bits,
  427                            tie_fighter_width,
  428                            tie_fighter_height);
  429     }
  430     
  431     /* Instantiate Popup children */
  432     infopopup = XtCreatePopupShell("information", topLevelShellWidgetClass,
  433                    toplevel, NULL, ZERO);
  434 
  435     infoform = XtCreateManagedWidget("form", formWidgetClass,
  436                      infopopup, NULL, ZERO);
  437 
  438                             num_args = 0;
  439     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  440     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  441     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  442     XtSetArg(args[num_args], XtNright, XtChainRight);   num_args++;
  443     XtSetArg(args[num_args], XtNscrollHorizontal, XawtextScrollWhenNeeded);
  444                             num_args++;
  445     XtSetArg(args[num_args], XtNscrollVertical, XawtextScrollWhenNeeded);
  446                             num_args++;
  447     XtSetArg(args[num_args], XtNdisplayCaret, False);   num_args++;
  448     infotext = XtCreateManagedWidget("text", asciiTextWidgetClass,
  449                      infoform, args, num_args);
  450 
  451                             num_args = 0;
  452     XtSetArg(args[num_args], XtNfromVert, infotext);    num_args++;
  453     XtSetArg(args[num_args], XtNtop, XtChainBottom);    num_args++;
  454     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  455     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  456     XtSetArg(args[num_args], XtNright, XtChainRight);   num_args++;
  457     infodismiss = XtCreateManagedWidget("dismiss", commandWidgetClass,
  458                        infoform, args, num_args);
  459     XtAddCallback(infodismiss, XtNcallback, dismiss, (XtPointer)infopopup);
  460 
  461                             num_args = 0;
  462     XtSetArg(args[num_args], XtNfont, &font);       num_args++;
  463     XtSetArg(args[num_args], XtNbottomMargin, &bottomMargin);num_args++;
  464     XtSetArg(args[num_args], XtNleftMargin, &leftMargin);num_args++;
  465     XtSetArg(args[num_args], XtNrightMargin, &rightMargin);num_args++;
  466     XtSetArg(args[num_args], XtNtopMargin, &topMargin); num_args++;
  467     XtGetValues(infotext, args, num_args);
  468 
  469     width = font->max_bounds.width * 80 + leftMargin + rightMargin;
  470     height = (font->ascent + font->descent) * ROWS + topMargin + bottomMargin;
  471 
  472     XtSetArg(args[0], XtNwidth, width);
  473     XtSetArg(args[1], XtNheight, height);
  474     XtSetValues(infotext, args, TWO);
  475     XtSetValues(infodismiss, args, ONE);
  476     XtRealizeWidget(infopopup);
  477     XSetWMProtocols(dpy, XtWindow(infopopup), &wm_delete_window, 1);
  478 
  479     copyrightpopup = XtCreatePopupShell("copyright", topLevelShellWidgetClass,
  480                     toplevel, NULL, ZERO);
  481 
  482     copyrightform = XtCreateManagedWidget("form", formWidgetClass,
  483                       copyrightpopup, NULL, ZERO);
  484 
  485                             num_args = 0;
  486     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  487     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  488     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  489     XtSetArg(args[num_args], XtNright, XtChainRight);   num_args++;
  490     XtSetArg(args[num_args], XtNscrollHorizontal, XawtextScrollWhenNeeded);
  491                             num_args++;
  492     XtSetArg(args[num_args], XtNscrollVertical, XawtextScrollWhenNeeded);
  493                             num_args++;
  494     XtSetArg(args[num_args], XtNdisplayCaret, False);   num_args++;
  495     XtSetArg(args[num_args], XtNuseStringInPlace, True);num_args++;
  496     XtSetArg(args[num_args], XtNlength, strlen(copyright));num_args++;
  497     XtSetArg(args[num_args], XtNstring, copyright); num_args++;
  498     copyrighttext = XtCreateManagedWidget("text", asciiTextWidgetClass,
  499                       copyrightform, args, num_args);
  500 
  501                             num_args = 0;
  502     XtSetArg(args[num_args], XtNfromVert, copyrighttext);
  503                             num_args++;
  504     XtSetArg(args[num_args], XtNtop, XtChainBottom);    num_args++;
  505     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  506     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  507     XtSetArg(args[num_args], XtNright, XtChainRight);   num_args++;
  508     copyrightdismiss = XtCreateManagedWidget("dismiss", commandWidgetClass,
  509                          copyrightform, args, num_args);
  510     XtAddCallback(copyrightdismiss, XtNcallback, dismiss,
  511           (XtPointer)copyrightpopup);
  512 
  513                             num_args = 0;
  514     XtSetArg(args[num_args], XtNfont, &font);       num_args++;
  515     XtSetArg(args[num_args], XtNbottomMargin, &bottomMargin);num_args++;
  516     XtSetArg(args[num_args], XtNleftMargin, &leftMargin);num_args++;
  517     XtSetArg(args[num_args], XtNrightMargin, &rightMargin);num_args++;
  518     XtSetArg(args[num_args], XtNtopMargin, &topMargin); num_args++;
  519     XtGetValues(copyrighttext, args, num_args);
  520 
  521     width = font->max_bounds.width * COLS + leftMargin + rightMargin;
  522     height = (font->ascent + font->descent) * ROWS + topMargin + bottomMargin;
  523 
  524     XtSetArg(args[0], XtNwidth, width);
  525     XtSetArg(args[1], XtNheight, height);
  526     XtSetValues(copyrighttext, args, TWO);
  527     XtSetValues(copyrightdismiss, args, ONE);
  528     XtRealizeWidget(copyrightpopup);
  529     XSetWMProtocols(dpy, XtWindow(copyrightpopup), &wm_delete_window, 1);
  530 
  531     dialogpopup = XtCreatePopupShell("popup", transientShellWidgetClass,
  532                      toplevel, NULL, ZERO);
  533 
  534     dialog = CreateDialog(dialogpopup, "dialog", okay, dismiss);
  535     XtRealizeWidget(dialogpopup);
  536     XSetWMProtocols(dpy, XtWindow(dialogpopup), &wm_delete_window, 1);
  537 
  538 
  539     /* Instantiate Widgets */
  540 
  541     form = XtCreateManagedWidget("form", formWidgetClass,
  542                  toplevel, NULL, ZERO);
  543 
  544     above_toc = NULL;
  545     left_of_page = NULL;
  546     set_vert_dist = False;
  547     if (app_res.show_title) {
  548                             num_args = 0;
  549     XtSetArg(args[num_args], XtNfromVert, above_toc);num_args++;
  550     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  551     XtSetArg(args[num_args], XtNbottom, XtChainTop);num_args++;
  552     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  553     XtSetArg(args[num_args], XtNright, XtChainLeft);num_args++;
  554     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  555     XtSetArg(args[num_args], XtNborderWidth, 0);    num_args++;
  556     XtSetArg(args[num_args], XtNresize, False); num_args++;
  557     XtSetArg(args[num_args], XtNlabel, " ");    num_args++;
  558     titlebutton = XtCreateManagedWidget("titleButton",
  559                         menuButtonWidgetClass,
  560                             form, args, num_args);
  561     above_toc = titlebutton;
  562     if (!left_of_page) left_of_page = titlebutton;
  563     set_vert_dist = True;
  564     }
  565 
  566     if (app_res.show_date) {
  567                             num_args = 0;
  568     XtSetArg(args[num_args], XtNfromVert, above_toc);num_args++;
  569     if (set_vert_dist) {
  570         XtSetArg(args[num_args], XtNvertDistance, 0);num_args++;
  571     }
  572     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  573     XtSetArg(args[num_args], XtNbottom, XtChainTop);num_args++;
  574     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  575     XtSetArg(args[num_args], XtNright, XtChainLeft);num_args++;
  576     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  577     XtSetArg(args[num_args], XtNborderWidth, 0);    num_args++;
  578     XtSetArg(args[num_args], XtNresize, False); num_args++;
  579     XtSetArg(args[num_args], XtNlabel, " ");    num_args++;
  580     datebutton = XtCreateManagedWidget("dateButton", menuButtonWidgetClass,
  581                        form, args, num_args);
  582     above_toc = datebutton;
  583     if (!left_of_page) left_of_page = datebutton;
  584     set_vert_dist = True;
  585     }
  586 
  587     if (app_res.show_locator) {
  588                             num_args = 0;
  589     XtSetArg(args[num_args], XtNfromVert, above_toc);num_args++;
  590     if (set_vert_dist) {
  591         XtSetArg(args[num_args], XtNvertDistance, 0);num_args++;
  592     }
  593     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  594     XtSetArg(args[num_args], XtNbottom, XtChainTop);num_args++;
  595     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  596     XtSetArg(args[num_args], XtNright, XtChainLeft);num_args++;
  597     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  598     XtSetArg(args[num_args], XtNborderWidth, 0);    num_args++;
  599     XtSetArg(args[num_args], XtNresize, False); num_args++;
  600     XtSetArg(args[num_args], XtNlabel, " ");    num_args++;
  601     locator = XtCreateManagedWidget("locator", labelWidgetClass,
  602                     form, args, num_args);
  603     above_toc = locator;
  604     if (!left_of_page) left_of_page = locator;
  605     }
  606 
  607                             num_args = 0;
  608     XtSetArg(args[num_args], XtNfromVert, above_toc);   num_args++;
  609     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  610     XtSetArg(args[num_args], XtNbottom, XtChainTop);    num_args++;
  611     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  612     XtSetArg(args[num_args], XtNright, XtChainLeft);    num_args++;
  613     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  614     XtSetArg(args[num_args], XtNallowVert, True);   num_args++;
  615     box = XtCreateManagedWidget("box", boxWidgetClass, form, args, num_args);
  616 
  617     XtSetArg(args[0], XtNresize, False);
  618     filebutton = XtCreateManagedWidget("fileButton", menuButtonWidgetClass,
  619                        box, args, ONE);
  620 
  621     filemenu = XtCreatePopupShell("menu", simpleMenuWidgetClass,
  622                   filebutton, NULL, ZERO);
  623 
  624     openbutton = XtCreateManagedWidget("open", smeBSBObjectClass,
  625                        filemenu, NULL, ZERO);
  626     XtAddCallback(openbutton, XtNcallback, popup_dialog, (XtPointer)OPEN);
  627 
  628     reopenbutton = XtCreateManagedWidget("reopen", smeBSBObjectClass,
  629                          filemenu, NULL, ZERO);
  630     XtAddCallback(reopenbutton, XtNcallback, reopen_file, (XtPointer)NULL);
  631 
  632     printwholebutton = XtCreateManagedWidget("printwhole", smeBSBObjectClass,
  633                              filemenu, NULL, ZERO);
  634     XtAddCallback(printwholebutton, XtNcallback, popup_dialog,
  635           (XtPointer)PRINT_WHOLE);
  636 
  637     printmarkedbutton = XtCreateManagedWidget("printmarked", smeBSBObjectClass,
  638                               filemenu, NULL, ZERO);
  639     XtAddCallback(printmarkedbutton, XtNcallback, popup_dialog,
  640           (XtPointer)PRINT_MARKED);
  641 
  642     savebutton = XtCreateManagedWidget("save", smeBSBObjectClass,
  643                        filemenu, NULL, ZERO);
  644     XtAddCallback(savebutton, XtNcallback, popup_dialog, (XtPointer)SAVE);
  645 
  646     line = XtCreateManagedWidget("line", smeLineObjectClass,
  647                  filemenu, NULL, ZERO);
  648 
  649     copyrightbutton = XtCreateManagedWidget("copyright", smeBSBObjectClass,
  650                         filemenu, NULL, ZERO);
  651     XtAddCallback(copyrightbutton, XtNcallback, popup,
  652           (XtPointer)copyrightpopup);
  653 
  654     quitbutton = XtCreateManagedWidget("quit", smeBSBObjectClass,
  655                        filemenu, NULL, ZERO);
  656     XtAddCallback(quitbutton, XtNcallback, quit_ghostview, (XtPointer)0);
  657 
  658     XtSetArg(args[0], XtNresize, False);
  659     pagebutton = XtCreateManagedWidget("pageButton", menuButtonWidgetClass,
  660                        box, args, 1);
  661 
  662     pagemenu = XtCreatePopupShell("menu", simpleMenuWidgetClass,
  663                   pagebutton, NULL, ZERO);
  664 
  665     nextbutton = XtCreateManagedWidget("next", smeBSBObjectClass,
  666                        pagemenu, NULL, ZERO);
  667     XtAddCallback(nextbutton, XtNcallback, next_page, (XtPointer)0);
  668 
  669     showbutton = XtCreateManagedWidget("show", smeBSBObjectClass,
  670                        pagemenu, NULL, ZERO);
  671     XtAddCallback(showbutton, XtNcallback, this_page, (XtPointer)0);
  672 
  673     prevbutton = XtCreateManagedWidget("prev", smeBSBObjectClass,
  674                        pagemenu, NULL, ZERO);
  675     XtAddCallback(prevbutton, XtNcallback, prev_page, (XtPointer)0);
  676 
  677     line = XtCreateManagedWidget("line", smeLineObjectClass,
  678                  pagemenu, NULL, ZERO);
  679 
  680     centerbutton = XtCreateManagedWidget("center", smeBSBObjectClass,
  681                        pagemenu, NULL, ZERO);
  682     XtAddCallback(centerbutton, XtNcallback, center_page, (XtPointer)0);
  683 
  684     line = XtCreateManagedWidget("line", smeLineObjectClass,
  685                  pagemenu, NULL, ZERO);
  686 
  687     markbutton = XtCreateManagedWidget("mark", smeBSBObjectClass,
  688                        pagemenu, NULL, ZERO);
  689     XtAddCallback(markbutton, XtNcallback, mark_page, (XtPointer)0);
  690 
  691     unmarkbutton = XtCreateManagedWidget("unmark", smeBSBObjectClass,
  692                          pagemenu, NULL, ZERO);
  693     XtAddCallback(unmarkbutton, XtNcallback, unmark_page, (XtPointer)0);
  694 
  695     XtSetArg(args[0], XtNresize, False);
  696     magstepbutton = XtCreateManagedWidget("magstepButton",
  697                       menuButtonWidgetClass,
  698                       box, args, ONE);
  699 
  700     magstepmenu = XtCreatePopupShell("menu", simpleMenuWidgetClass,
  701                      magstepbutton, NULL, ZERO);
  702 
  703     magstepentry = (Widget *) XtMalloc(
  704         (app_res.maximum_magstep - app_res.minimum_magstep + 1) *
  705         sizeof(Widget));
  706     XtSetArg(args[0], XtNleftMargin, 20);
  707     for (i = app_res.minimum_magstep; i <= app_res.maximum_magstep; i++) {
  708     char buf[16];
  709     sprintf(buf, "%d", i);
  710     magstepentry[i-app_res.minimum_magstep] =
  711         XtCreateManagedWidget(buf, smeBSBObjectClass,
  712                       magstepmenu, args, 1);
  713     XtAddCallback(magstepentry[i-app_res.minimum_magstep], XtNcallback,
  714               set_magstep, (XtPointer)i);
  715     }
  716 
  717     XtSetArg(args[0], XtNresize, False);
  718     orientationbutton = XtCreateManagedWidget("orientationButton",
  719                           menuButtonWidgetClass,
  720                           box, args, ONE);
  721 
  722     orientationmenu = XtCreatePopupShell("menu", simpleMenuWidgetClass,
  723                          orientationbutton, NULL, ZERO);
  724 
  725     XtSetArg(args[0], XtNleftMargin, 20);
  726     portraitbutton = XtCreateManagedWidget("portrait", smeBSBObjectClass,
  727                            orientationmenu, args, ONE);
  728     XtAddCallback(portraitbutton, XtNcallback,
  729           set_orientation, (XtPointer)XtPageOrientationPortrait);
  730 
  731     landscapebutton = XtCreateManagedWidget("landscape", smeBSBObjectClass,
  732                             orientationmenu, args, ONE);
  733     XtAddCallback(landscapebutton, XtNcallback,
  734           set_orientation, (XtPointer)XtPageOrientationLandscape);
  735 
  736     upsidedownbutton = XtCreateManagedWidget("upsidedown", smeBSBObjectClass,
  737                              orientationmenu, args, ONE);
  738     XtAddCallback(upsidedownbutton, XtNcallback,
  739           set_orientation, (XtPointer)XtPageOrientationUpsideDown);
  740 
  741     seascapebutton = XtCreateManagedWidget("seascape", smeBSBObjectClass,
  742                              orientationmenu, args, ONE);
  743     XtAddCallback(seascapebutton, XtNcallback,
  744           set_orientation, (XtPointer)XtPageOrientationSeascape);
  745 
  746     line = XtCreateManagedWidget("line", smeLineObjectClass,
  747                  orientationmenu, NULL, ZERO);
  748 
  749     swapbutton = XtCreateManagedWidget("swap", smeBSBObjectClass,
  750                        orientationmenu, args, ONE);
  751     XtAddCallback(swapbutton, XtNcallback, swap_landscape, (XtPointer)0);
  752 
  753     if (app_res.swap_landscape) {
  754     XtSetArg(args[0], XtNlabel, &s1);
  755     XtGetValues(landscapebutton, args, ONE);
  756     s1 = XtNewString(s1);
  757     XtSetArg(args[0], XtNlabel, &s2);
  758     XtGetValues(seascapebutton, args, ONE);
  759     s2 = XtNewString(s2);
  760     XtSetArg(args[0], XtNlabel, s2);
  761     XtSetValues(landscapebutton, args, ONE);
  762     XtSetArg(args[0], XtNlabel, s1);
  763     XtSetValues(seascapebutton, args, ONE);
  764     XtFree(s1);
  765     XtFree(s2);
  766     }
  767 
  768     XtSetArg(args[0], XtNresize, False);
  769     pagemediabutton = XtCreateManagedWidget("pagemediaButton",
  770                         menuButtonWidgetClass,
  771                         box, args, ONE);
  772 
  773     default_pagemedia = 0;
  774     for (i = 0; papersizes[i].name; i++) {
  775         if (!strcmp(app_res.pagemedia, papersizes[i].name)) {
  776         default_pagemedia = i;
  777             break;
  778         }
  779     }
  780 
  781 #ifndef max
  782 #define max(a,b) ((a)>(b)?(a):(b))
  783 #endif
  784 
  785     /* Line up all the menu buttons */
  786     XtSetArg(args[0], XtNwidth, &width);
  787     XtGetValues(filebutton, args, ONE);
  788     button_width = width;
  789     XtGetValues(pagebutton, args, ONE);
  790     button_width = max(button_width, width);
  791     XtGetValues(magstepbutton, args, ONE);
  792     button_width = max(button_width, width);
  793     XtGetValues(orientationbutton, args, ONE);
  794     button_width = max(button_width, width);
  795     XtGetValues(pagemediabutton, args, ONE);
  796     button_width = max(button_width, width);
  797 
  798     XtSetArg(args[0], XtNwidth, button_width);
  799     XtSetValues(filebutton, args, ONE);
  800     XtSetValues(pagebutton, args, ONE);
  801     XtSetValues(magstepbutton, args, ONE);
  802     XtSetValues(orientationbutton, args, ONE);
  803     XtSetValues(pagemediabutton, args, ONE);
  804 
  805                             num_args = 0;
  806     XtSetArg(args[num_args], XtNfromVert, above_toc);   num_args++;
  807     XtSetArg(args[num_args], XtNfromHoriz, box);    num_args++;
  808     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  809     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  810     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  811     XtSetArg(args[num_args], XtNright, XtChainLeft);    num_args++;
  812     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  813     XtSetArg(args[num_args], XtNdisplayCaret, False);   num_args++;
  814     XtSetArg(args[num_args], XtNuseStringInPlace, True);num_args++;
  815     XtSetArg(args[num_args], XtNlength, 0);     num_args++;
  816     XtSetArg(args[num_args], XtNstring, nothing);   num_args++;
  817     XtSetArg(args[num_args], XtNselectTypes, sarry);    num_args++;
  818     XtSetArg(args[num_args], XtNscrollVertical, XawtextScrollAlways);num_args++;
  819     toc = XtCreateManagedWidget("toc", asciiTextWidgetClass,
  820                 form, args, num_args);
  821     if (!left_of_page) left_of_page = toc;
  822 
  823                             num_args = 0;
  824     XtSetArg(args[num_args], XtNfromHoriz, left_of_page);num_args++;
  825     XtSetArg(args[num_args], XtNtop, XtChainTop);   num_args++;
  826     XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++;
  827     XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++;
  828     XtSetArg(args[num_args], XtNright, XtChainRight);   num_args++;
  829     XtSetArg(args[num_args], XtNresizable, True);   num_args++;
  830     XtSetArg(args[num_args], XtNallowHoriz, True);  num_args++;
  831     XtSetArg(args[num_args], XtNallowVert, True);   num_args++;
  832     pageview = XtCreateManagedWidget("pageview", viewportWidgetClass,
  833                      form, args, num_args);
  834 
  835     page = XtCreateManagedWidget("page", ghostviewWidgetClass,
  836                  pageview, NULL, ZERO);
  837     num_ghosts++;
  838     XtAddCallback(page, XtNcallback, track_and_zoom, (XtPointer)0);
  839     XtAddCallback(page, XtNdestroyCallback, destroy_ghost, (XtPointer)page);
  840     XtAddCallback(page, XtNmessageCallback, message, (XtPointer)page);
  841     XtAddCallback(page, XtNoutputCallback, output, (XtPointer)0);
  842                             num_args = 0;
  843     XtSetArg(args[num_args], XtNxdpi, &default_xdpi);   num_args++;
  844     XtSetArg(args[num_args], XtNydpi, &default_ydpi);   num_args++;
  845     XtGetValues(page, args, num_args);
  846 
  847     /* This sets most of the window sizes.  This keeps X server traffic
  848      * down during realization.
  849      */
  850     GhostviewDisableInterpreter(page);
  851     setup_ghostview();
  852     i = find_page(app_res.page);
  853 
  854     /* Coerce page number to fall in range */
  855     if (toc_text) {
  856     if (i >= doc->numpages) i = doc->numpages - 1;
  857     if (i < 0) i = 0;
  858     }
  859     /* Coerce magstep to fall in range */
  860     if (app_res.magstep < app_res.minimum_magstep)
  861     app_res.magstep = app_res.minimum_magstep;
  862     if (app_res.magstep > app_res.maximum_magstep)
  863     app_res.magstep = app_res.maximum_magstep;
  864     set_new_magstep();
  865     set_new_orientation(i);
  866     set_new_pagemedia(i);
  867     layout_ghostview();
  868 
  869     XtSetMappedWhenManaged(toplevel, False);
  870     XtRealizeWidget(toplevel);
  871     XtSetArg(args[0], XtNtransientFor, toplevel);
  872     XtSetValues(dialogpopup, args, ONE);
  873     XSetWMProtocols(dpy, XtWindow(toplevel), &wm_delete_window, 1);
  874     if (XStringListToTextProperty(&version, 1, &nameprop)) {
  875     XSetWMName(dpy, XtWindow(toplevel), &nameprop);
  876     }
  877 
  878     /* This sets the sizes on widget that were created during the realize. */
  879     layout_ghostview();
  880     XtMapWidget(toplevel);
  881 
  882     show_page(i);
  883     XtAppMainLoop(app_con);
  884 
  885     /* should never get here */
  886     return 1;
  887 }
  888 
  889 static void
  890 Syntax(call)
  891 char *call;
  892 {
  893     XtDestroyApplicationContext(app_con);
  894     fprintf(stderr, "Usage: %s\n", call);
  895     fprintf(stderr,
  896         "    [-monochrome] [-grayscale] [-color]\n");
  897     fprintf(stderr,
  898         "    [-[no]title] [-[no]date] [-[no]locator] [-[no]labels]\n");
  899     fprintf(stderr,
  900         "    [-resolution <dpi>] [-dpi <dpi>]\n");
  901     fprintf(stderr,
  902         "    [-xdpi <dpi>] [-ydpi <dpi>] [-magstep <n>]\n");
  903     fprintf(stderr,
  904         "    [-[no]safer] [-[no]quiet] [-arguments <arguments>]\n");
  905     fprintf(stderr,
  906         "    [-[no]center]\n");
  907     fprintf(stderr,
  908         "    [-portrait] [-landscape] [-upsidedown] [-seascape] [-[no]swap]\n");
  909     fprintf(stderr,
  910         "    [-letter] [-tabloid] [-ledger] [-legal] [-statement]\n");
  911     fprintf(stderr,
  912         "    [-executive] [-a3] [-a4] [-a5] [-b4] [-b5]\n");
  913     fprintf(stderr,
  914         "    [-folio] [-quarto] [-10x14]\n");
  915     fprintf(stderr,
  916         "    [-force] [-forceorientation] [-forcemedia]\n");
  917     fprintf(stderr,
  918         "    [-[no]openwindows] [-[no]ncdwm]\n");
  919     fprintf(stderr,
  920         "    [-page <label>] [toolkitoption]\n");
  921     fprintf(stderr,
  922         "    [filename]\n");
  923     exit(1);
  924 }