🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: vmsnet.sources
Article #13

Ghostview for VMS 01/14

#13
From: Terry Poot
Date: Thu, 29 Oct 1992 18:49
1626 lines
49777 bytes
Submitted-by: Terry Poot <tp@mccall.com>
Posting-number: Volume 3, Issue 219
Archive-name: ghostview/part01

OK, here it finally is, for those of you without FTP access. This is the
full distribution of Ghostview 1.4, and should be identical to what you get
via FTP. One slight update to the readme.vms file is that it has now been
tested (however lightly) with Ghostscript 2.5.2.

Also not mentioned, because I didn't know it at the time, is that it ONLY
works properly with Postscript files that have DSC comments (they start
with "%!Adobe" and have the pages marked). This bug is specific to the VMS
version (some sort of problem with LIB$SPAWN that I haven't tracked down
yet). I'll try to take a look at it reasonably soon and come up with a fix,
but no promises.
--
Terry Poot <tp@mccall.com>                   The McCall Pattern Company
(uucp: ...!rutgers!depot!mccall!tp)          615 McCall Road
(800)255-2762, in KS (913)776-4041           Manhattan, KS 66502, USA

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 27-OCT-1992 16:42:54.60   By user TP 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 14 PARTS, TO KEEP EACH PART
$!  BELOW 98 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. ACTIONS.C;1
$!       2. AD2C.;1
$!       3. CALLBACKS.C;1
$!       4. COMMENTS.DOC;1
$!       5. COPYING.;1
$!       6. DESCRIP.MMS;1
$!       7. DIALOGS.C;1
$!       8. DIR.C;1
$!       9. DRAW.C;1
$!      10. GETENV.C;1
$!      11. GHOSTVIEW.AD;1
$!      12. GHOSTVIEW.C;1
$!      13. GHOSTVIEW.H;1
$!      14. GHOSTVIEW.MAN;1
$!      15. GHOSTVIEW.PS;1
$!      16. GHOSTVIEWP.H;1
$!      17. GS.INTERFACE;1
$!      18. GV.H;1
$!      19. HISTORY.;1
$!      20. IMAKEFILE.;1
$!      21. MAIN.C;1
$!      22. MAKEFILE.;1
$!      23. MISC.C;1
$!      24. PATH.C;1
$!      25. PS.C;1
$!      26. PS.H;1
$!      27. README.;1
$!      28. README.SELFILE;1
$!      29. README.VMS;1
$!      30. RUN-AD2C.;1
$!      31. SELFILE.C;1
$!      32. SETENV.C;1
$!      33. SFINTERNAL.H;1
$!      34. STDC.H;1
$!      35. STRCASECMP.C;1
$!      36. VMS_BUILD.COM;1
$!      37. VMS_TYPES.H;1
$!      38. XSTAT.H;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X/*
X * actions.c -- X11 actions for ghostview.
X * Copyright (C) 1992  Timothy O. Theisen
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *   Author: Tim Theisen           Systems Programmer
X * Internet: tim@cs.wisc.edu       Department of Computer Sciences
X *     UUCP: uwvax!tim             University of Wisconsin-Madison
X *    Phone: (608)262-0438         1210 West Dayton Street
X *      FAX: (608)262-9777         Madison, WI   53706
X */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Cardinals.h>
X#include <X11/Xaw/Scrollbar.h>
X#include "gv.h"
X#include "ps.h"
X
X/* Popup the copyright window */
Xvoid
Xgv_copyright(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    popup(w, (XtPointer)copyrightpopup, NULL);
X`7D
X
X/* Call the quit callback to stop ghostview */
Xvoid
Xgv_quit(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    quit_ghostview(w, NULL, NULL);
X`7D
X
X/* Popup the open file dialog box. */
Xvoid
Xgv_open(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    popup_dialog(w, (XtPointer)OPEN, NULL);
X`7D
X
X/* Popup the open file dialog box. */
Xvoid
Xgv_reopen(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(reopenbutton)) return;
X    reopen_file(w, NULL, NULL);
X`7D
X
X/* Popup the save file dialog box. */
Xvoid
Xgv_save(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(savebutton)) return;
X    popup_dialog(w, (XtPointer)SAVE, NULL);
X`7D
X
X/* Popup the print file dialog box. */
Xvoid
Xgv_print_whole(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(printwholebutton)) return;
X    popup_dialog(w, (XtPointer)PRINT_WHOLE, NULL);
X`7D
X
X/* Popup the print file dialog box. */
Xvoid
Xgv_print_marked(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(printmarkedbutton)) return;
X    popup_dialog(w, (XtPointer)PRINT_MARKED, NULL);
X`7D
X
X/* Call the prev_page callback */
Xvoid
Xgv_prev(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(prevbutton)) return;
X    prev_page(w, NULL, NULL);
X`7D
X
X/* Call the this_page callback */
Xvoid
Xgv_show(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(showbutton)) return;
X    this_page(w, NULL, NULL);
X`7D
X
X/* Call the next_page callback */
Xvoid
Xgv_next(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(nextbutton)) return;
X    next_page(w, NULL, NULL);
X`7D
X
X/* Call the center_page callback */
Xvoid
Xgv_center(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(centerbutton)) return;
X    center_page(w, NULL, NULL);
X`7D
X
X/* Call the mark_page callback */
Xvoid
Xgv_mark(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(markbutton)) return;
X    mark_page(w, NULL, NULL);
X`7D
X
X/* Call the unmark_page callback */
Xvoid
Xgv_unmark(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (!XtIsSensitive(unmarkbutton)) return;
X    unmark_page(w, NULL, NULL);
X`7D
X
X/* Get the magstep from the parameter string and
X * call the set_magstep callback with that magstep */
Xvoid
Xgv_set_magstep(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    int i;
X
X    if (*num_params < 1) return;
X    i = atoi(params`5B0`5D);
X    set_magstep(w, (XtPointer)i, NULL);
X`7D
X
X/* Increment the magstep and
X * call the set_magstep callback with that magstep */
Xvoid
Xgv_increase_magstep(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    int i;
X
X    i = app_res.magstep + 1;
X    if (i <= app_res.maximum_magstep)
X`09set_magstep(w, (XtPointer)i, NULL);
X`7D
X
X/* Decrement the magstep and
X * call the set_magstep callback with that magstep */
Xvoid
Xgv_decrease_magstep(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    int i;
X
X    i = app_res.magstep - 1;
X    if (i >= app_res.minimum_magstep)
X`09set_magstep(w, (XtPointer)i, NULL);
X`7D
X
X/* Set orientation action routine.  Converts text parameter
X * to XtPageOrientation and all set_orientation callback */
Xvoid
Xgv_set_orientation(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    XrmValue from, to;
X    XtPageOrientation orient;
X
X    if (*num_params < 1) return;
X    from.size = sizeof(String);
X    from.addr = params`5B0`5D;
X    to.size = 0;
X    to.addr = NULL;
X    if (XmuCvtStringToPageOrientation(XtDisplay(w), NULL, ZERO,
X`09`09`09`09      &from, &to, NULL)) `7B
X`09orient = *(XtPageOrientation *)(to.addr);
X`09set_orientation(w, (XtPointer)orient, NULL);
X    `7D
X`7D
X
X/* Call the swap_landscape callback */
Xvoid
Xgv_swap_landscape(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    swap_landscape(w, NULL, NULL);
X`7D
X
X/* Set pagemedia action routine.  Converts text parameter
X * to index into the pagemedia widgets and calls the set_pagemedia
X * callback. */
Xvoid
Xgv_set_pagemedia(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    int i;
X
X    if (*num_params < 1) return;
X
X    /* First check pagemedia defined within the document */
X    if (doc && doc->nummedia) `7B
X`09for (i = 0; i < doc->nummedia; i++) `7B
X`09    if (!strcmp(params`5B0`5D, doc->media`5Bi`5D.name)) `7B
X`09`09set_pagemedia(w, (XtPointer)i, NULL);
X`09`09break;
X`09    `7D
X`09`7D
X    `7D
X
X    /* Then check the standard ones */
X    for (i = 0; papersizes`5Bi`5D.name; i++) `7B
X`09if (!strcmp(params`5B0`5D, papersizes`5Bi`5D.name)) `7B
X    `09    set_pagemedia(w, (XtPointer)(base_papersize+i), NULL);
X`09    break;
X`09`7D
X    `7D
X`7D
X
X
X/* Reset the force flag.  */
X/* (force flag is checked when setting orientaion and pagemedia) */
Xvoid
Xgv_default(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    force_setting = False;
X`7D
X
X/* Set the force flag.  */
X/* (force flag is checked when setting orientaion and pagemedia) */
Xvoid
Xgv_force(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    force_setting = True;
X`7D
X
X/* Implement WM_DELETE_WINDOW protocol */
Xvoid
Xgv_delete_window(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    if (event->type == ClientMessage &&
X`09event->xclient.data.l`5B0`5D != wm_delete_window) return;
X    XtDestroyWidget(w);
X`7D
X
X
X/* Destroy popup zoom window */
Xvoid
Xgv_delete_zoom(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    XtDestroyWidget(XtParent(w));
X`7D
X
X/* dismiss a popup window */
Xvoid
Xgv_dismiss(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    XtPopdown(w);
X    if (w == infopopup) info_up = False;
X`7D
X
X/* scroll main viewport up */
Xvoid
Xgv_scroll_up(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    Arg args`5B2`5D;
X    Widget scroll;
X    float top, shown;
X
X    scroll = XtNameToWidget(pageview, "vertical");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = top - shown;
X`09if (top < 0.0) top = 0.0;
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X`7D
X
X/* scroll main viewport down */
Xvoid
Xgv_scroll_down(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    Arg args`5B2`5D;
X    Widget scroll;
X    float top, shown;
X
X    scroll = XtNameToWidget(pageview, "vertical");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = top + shown;
X`09if (top > (1.0 - shown)) top = (1.0 - shown);
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X`7D
X
X/* scroll main viewport left */
Xvoid
Xgv_scroll_left(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    Arg args`5B2`5D;
X    Widget scroll;
X    float top, shown;
X
X    scroll = XtNameToWidget(pageview, "horizontal");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = top - shown;
X`09if (top < 0.0) top = 0.0;
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X`7D
X
X/* scroll main viewport right */
Xvoid
Xgv_scroll_right(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    Arg args`5B2`5D;
X    Widget scroll;
X    float top, shown;
X
X    scroll = XtNameToWidget(pageview, "horizontal");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = top + shown;
X`09if (top > (1.0 - shown)) top = (1.0 - shown);
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X`7D
X
X/* Pop down locator window */
Xvoid
Xgv_erase_locator(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    Arg args`5B1`5D;
X
X    if (!app_res.show_locator) return;
X    XtSetArg(args`5B0`5D, XtNlabel, "");
X    XtSetValues(locator, args, ONE);
X`7D
X
X/* Check to see if file was updated */
Xvoid
Xgv_check_file(w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X`7B
X    struct stat sbuf;
X
X    if (psfile) `7B
X`09if (!stat(filename, &sbuf) && mtime != sbuf.st_mtime) `7B
X`09    show_page(current_page);
X`09`7D
X    `7D
X`7D
$ CALL UNPACK ACTIONS.C;1 741768195
$ create 'f'
X#!/bin/sh
X#
X#`09ad2c : Convert app-defaults file to C strings decls.
X#
X#`09George Ferguson, ferguson@cs.rcohester.edu, 12 Nov 1990.
X#`0919 Mar 1991 : gf
X#`09`09Made it self-contained.
X#`096 Jan 1992 : mycroft@gnu.ai.mit.edu (Charles Hannum)
X#`09`09Removed use of "-n" and ":read" label since Gnu and
X#`09`09IBM sed print pattern space on "n" command. Still works
X#`09`09with Sun sed, of course.
X#`097 Jan 1992: matthew@sunpix.East.Sun.COM (Matthew Stier)
X#`09`09Escape quotes after escaping backslashes.
X#
X
Xsed '
X/`5E!/d
X/`5E$/d
Xs/\\/\\\\/g
Xs/\\$//g
Xs/"/\\"/g
Xs/`5E/"/
X: test
X/\\$/b slash
Xs/$/",/
Xp
Xd
X: slash
Xn
X/`5E!/d
X/`5E$/d
Xs/"/\\"/g
Xs/\\\\/\\/g
Xs/\\n/\\\\n/g
Xs/\\t/\\\\t/g
Xs/\\f/\\\\f/g
Xs/\\b/\\\\b/g
Xb test' "$@"
$ CALL UNPACK AD2C.;1 1431710482
$ create 'f'
X/*
X * callbacks.c -- X11 callbacks for ghostview.
X * Copyright (C) 1992  Timothy O. Theisen
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 2 of the License, or
X * (at your option) any later version.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *   Author: Tim Theisen           Systems Programmer
X * Internet: tim@cs.wisc.edu       Department of Computer Sciences
X *     UUCP: uwvax!tim             University of Wisconsin-Madison
X *    Phone: (608)262-0438         1210 West Dayton Street
X *      FAX: (608)262-9777         Madison, WI   53706
X */
X
X#include <stdio.h>
X#ifndef BUFSIZ
X#define BUFSIZ 1024
X#endif
X
X#ifdef VMS
X#define getenv _getenv
X#endif
X
Xextern char *getenv();
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Xaw/Cardinals.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Scrollbar.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Command.h>
X
X#include "Ghostview.h"
X#include "gv.h"
X#include "ps.h"
X
X/* Start application folding up by Destroying the top level widget. */
X/* The application exits when the last interpreter is killed during */
X/* a destroy callback from ghostview widgets. */
Xvoid
Xquit_ghostview(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XtDestroyWidget(toplevel);
X`7D
X
X/* Popup a window. */
Xvoid
Xpopup(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    positionpopup((Widget)client_data);
X    XtPopup((Widget)client_data, XtGrabNone);
X    XRaiseWindow(XtDisplay((Widget)client_data), XtWindow((Widget)client_dat
Va));
X`7D
X
X/* Popup a dialog box. */
Xvoid
Xpopup_dialog(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X#ifdef SELFILE
X    Widget button;
X    String okay, cancel;
X    String name, init_path;
X    Arg args`5B1`5D;
X    FILE* fp;
X    struct stat sbuf;
X    extern FILE *XsraSelFile();
X
X    button = XtNameToWidget(dialog, "cancel");
X    if (button) `7B
X`09XtSetArg(args`5B0`5D, XtNlabel, &cancel);
X`09XtGetValues(button, args, ONE);
X    `7D
X    button = XtNameToWidget(dialog, "okay");
X    if (button) `7B
X`09XtSetArg(args`5B0`5D, XtNlabel, &okay);
X`09XtGetValues(button, args, ONE);
X    `7D
X#endif
X
X    mode = (int) client_data;
X    switch (mode) `7B
X    case PRINT_WHOLE:
X    case PRINT_MARKED:
X`09SetDialogPrompt(dialog, app_res.print_prompt);
X`09if (app_res.default_printer)
X`09    SetDialogResponse(dialog, app_res.default_printer);
X`09else
X`09    ClearDialogResponse(dialog);
X`09popup(w, (XtPointer)dialogpopup, call_data);
X`09break;
X    case OPEN:
X#ifdef SELFILE
X`09if (filename && strcmp(filename, "-")) init_path = filename;
X`09else init_path = NULL;
X`09fp = XsraSelFile(toplevel, app_res.open_prompt, okay, cancel,
X`09`09`09 app_res.open_fail, init_path, "r", NULL, &name);
X`09if (fp == NULL) break;
X`09if (oldfilename) XtFree(oldfilename);
X`09oldfilename = filename;
X`09filename = name;
X`09if (psfile) fclose(psfile);
X`09psfile = fp;
X`09stat(filename, &sbuf);
X`09mtime = sbuf.st_mtime;
X`09new_file(0);
X`09show_page(0);
X#else
X`09SetDialogPrompt(dialog, app_res.open_prompt);
X`09if (filename && strcmp(filename, "-"))
X`09    SetDialogResponse(dialog, filename);
X`09else
X`09    ClearDialogResponse(dialog);
X`09popup(w, dialogpopup, call_data);
X#endif
X`09break;
X    case SAVE:
X#ifdef SELFILE
X`09fp = XsraSelFile(toplevel, app_res.save_prompt, okay, cancel,
X`09`09`09 app_res.save_fail, "", "w", NULL, &name);
X`09if (fp == NULL) break;
X`09pscopydoc(fp);
X`09fclose(fp);
X`09XtFree(name);
X#else
X`09SetDialogPrompt(dialog, app_res.save_prompt);
X`09ClearDialogResponse(dialog);
X`09popup(w, dialogpopup, call_data);
X#endif
X`09break;
X    `7D
X`7D
X
X/* Explicitly reopen the file. */
Xvoid
Xreopen_file(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    struct stat sbuf;
X    int number = current_page;
X
X    fclose(psfile);
X    psfile = fopen(filename, "r");
X    mtime = sbuf.st_mtime;
X    if (oldfilename) XtFree(oldfilename);
X    oldfilename = XtNewString(filename);
X    new_file(number);
X    show_page(number);
X`7D
X
X/* Get the selection, if no selection, get the insertion point. */
X/* If the new_page is different from the current page show it.  */
X/* If not at the first page, show the previous page. */
Xvoid
Xprev_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XawTextPosition pos, end;
X    int new_page;
X
X    XawTextGetSelectionPos(toc, &pos, &end);
X    if (pos == end) `7B`09`09/* Nothing selected */
X`09pos = XawTextGetInsertionPoint(toc);
X    `7D
X    if ((new_page = pos/toc_entry_length) == current_page) `7B
X`09new_page = current_page - 1;
X    `7D
X    if (new_page < 0) return;
X    show_page(new_page);
X`7D
X
X/* Get the selection, if no selection, get the insertion point. */
X/* Show this page.  */
Xvoid
Xthis_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    if (toc_text) `7B
X`09XawTextPosition pos, end;
X`09int new_page;
X
X`09XawTextGetSelectionPos(toc, &pos, &end);
X`09if (pos == end) `7B`09`09/* Nothing selected */
X`09    pos = XawTextGetInsertionPoint(toc);
X`09`7D
X`09new_page = pos/toc_entry_length;
X`09show_page(new_page);
X    `7D else `7B
X`09GhostviewDisableInterpreter(page);
X`09show_page(0);
X    `7D
X`7D
X
X/* Get the selection, if no selection, get the insertion point. */
X/* If the new_page is different from the current page show it.  */
X/* If not at the last page, show the next page. */
Xvoid
Xnext_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XawTextPosition pos, end;
X    int new_page = 0;
X
X    if (toc_text) `7B
X`09XawTextGetSelectionPos(toc, &pos, &end);
X`09if (pos == end) `7B`09`09/* Nothing selected */
X`09    pos = XawTextGetInsertionPoint(toc);
X`09`7D
X`09if ((new_page = pos/toc_entry_length) == current_page) `7B
X`09    new_page = current_page + 1;
X`09`7D
X`09if (new_page >= doc->numpages) return;
X    `7D
X    show_page(new_page);
X`7D
X
X/* Center the viewport over the page */
Xvoid
Xcenter_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    Arg args`5B2`5D;
X    Widget scroll;
X    float top, shown;
X
X    scroll = XtNameToWidget(pageview, "vertical");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = (1.0 - shown) / 2.0;
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X
X    scroll = XtNameToWidget(pageview, "horizontal");
X    if (scroll) `7B
X`09XtSetArg(args`5B0`5D, XtNshown, &shown);
X`09XtSetArg(args`5B1`5D, XtNtopOfThumb, &top);
X`09XtGetValues(scroll, args, TWO);
X
X`09top = (1.0 - shown) / 2.0;
X`09XtCallCallbacks(scroll, XtNjumpProc, &top);
X    `7D
X`7D
X
X/* Get the selection, if no selection, get the insertion point. */
X/* Mark all pages in range, and cause toc to update. */
Xvoid
Xmark_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XawTextPosition begin, end;
X    int i;
X
X    XawTextGetSelectionPos(toc, &begin, &end);
X    if (begin == end) `7B`09`09/* Nothing selected */
X`09begin = end = XawTextGetInsertionPoint(toc);
X    `7D else `7B
X`09end--;`09`09`09/* Sometimes end spills onto next line */
X    `7D
X    for (i = begin/toc_entry_length; i <= end/toc_entry_length; i++) `7B
X`09toc_text`5Bi*toc_entry_length`5D = '*';
X`09XawTextInvalidate(toc, i*toc_entry_length, i*toc_entry_length+1);
X    `7D
X`7D
X
X/* Get the selection, if no selection, get the insertion point. */
X/* Unmark all pages in range, and cause toc to update. */
Xvoid
Xunmark_page(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XawTextPosition begin, end;
X    int i;
X
X    XawTextGetSelectionPos(toc, &begin, &end);
X    if (begin == end) `7B`09`09/* Nothing selected */
X`09begin = end = XawTextGetInsertionPoint(toc);
X    `7D else `7B
X`09end--;`09`09`09/* Sometimes end spills onto next line */
X    `7D
X    for (i = begin/toc_entry_length; i <= end/toc_entry_length; i++) `7B
X`09toc_text`5Bi*toc_entry_length`5D = ' ';
X`09XawTextInvalidate(toc, i*toc_entry_length, i*toc_entry_length+1);
X    `7D
X`7D
X
X/* Set new magstep.  Reshow the current page if magstep changed. */
Xvoid
Xset_magstep(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    app_res.magstep = (int)client_data;
X    if (set_new_magstep()) `7B
X`09layout_ghostview();
X`09show_page(current_page);
X    `7D
X`7D
X
X/* Set new orientation.  Reshow the current page if orientation changed. */
Xvoid
Xset_orientation(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    app_res.force_orientation = force_setting;
X    app_res.orientation = (XtPageOrientation) client_data;
X    if (set_new_orientation(current_page)) `7B
X`09layout_ghostview();
X`09show_page(current_page);
X    `7D
X`7D
X
X/* Swap the landscape labels and change the flag. */
Xvoid
Xswap_landscape(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    Arg args`5B1`5D;
X    String s1, s2;
X
X    app_res.swap_landscape = !app_res.swap_landscape;
X
X    XtSetArg(args`5B0`5D, XtNlabel, &s1);
X    XtGetValues(landscapebutton, args, ONE);
X    s1 = XtNewString(s1);
X    XtSetArg(args`5B0`5D, XtNlabel, &s2);
X    XtGetValues(seascapebutton, args, ONE);
X    s2 = XtNewString(s2);
X    XtSetArg(args`5B0`5D, XtNlabel, s2);
X    XtSetValues(landscapebutton, args, ONE);
X    XtSetArg(args`5B0`5D, XtNlabel, s1);
X    XtSetValues(seascapebutton, args, ONE);
X    XtFree(s1);
X    XtFree(s2);
X
X    if (set_new_orientation(current_page)) `7B
X`09layout_ghostview();
X`09show_page(current_page);
X    `7D
X`7D
X
X/* Set new page media.  If new page media is different, update app_resources
V */
X/* and redisplay page. */
Xvoid
Xset_pagemedia(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    int new_pagemedia = (int) client_data;
X    if (new_pagemedia >= base_papersize) `7B
X`09default_pagemedia = new_pagemedia;
X`09app_res.force_pagemedia = force_setting;
X    `7D else `7B
X`09document_media = new_pagemedia;
X`09force_document_media = force_setting;
X    `7D
X    if (set_new_pagemedia(current_page)) `7B
X`09layout_ghostview();
X`09show_page(current_page);
X    `7D
X`7D
X
X/* track mouse pointer and popup zoom window */
Xvoid
Xtrack_and_zoom(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    Arg args`5B20`5D;
X    Cardinal num_args;
X    Dimension width, height;
X    Widget zoom;
X    Widget zoomform;
X    Widget zoompage;
X    Widget zoomdismiss;
X    FILE *zoomfile;
X    struct stat sbuf;
X    GhostviewReturnStruct *p = (GhostviewReturnStruct *)call_data;
X    int llx;
X    int lly;
X    int urx;
X    int ury;
X    int bottom_margin;
X    int left_margin;
X    int right_margin;
X    int top_margin;
X    int i;
X
X    /* locator events have zero width and height */
X    if ((p->width == 0) `7C`7C (p->height == 0)) `7B
X`09char buf`5B32`5D;
X`09if (!app_res.show_locator) return;
X`09sprintf(buf, "(%d, %d)", p->psx, p->psy);
X`09XtSetArg(args`5B0`5D, XtNlabel, buf);
X`09XtSetValues(locator, args, ONE);
X`09return;
X    `7D
X
X    /* If no file, nothing to zoom. */
X    if (!psfile) return;
X
X    /* If the file changed, cannot zoom */
X    stat(filename, &sbuf);
X    if (mtime != sbuf.st_mtime) return;
X`09`09`09`09`09`09`09num_args = 0;
X    XtSetArg(args`5Bnum_args`5D, XtNcolormap, cmap);`09num_args++;
X    if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X    `7D
X    zoom = XtCreatePopupShell("zoom", topLevelShellWidgetClass,
X`09`09`09      toplevel, args, num_args);
X
X`09`09`09`09`09`09`09num_args = 0;
X    if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X    `7D
X    zoomform = XtCreateManagedWidget("form", formWidgetClass,
X`09`09`09`09     zoom, args, num_args);
X
X    llx = p->psx - p->width/2;
X    lly = p->psy - p->height/2;
X    urx = p->psx + p->width/2;
X    ury = p->psy + p->height/2;
X
X    /* Make sure zoom window doesn't go off the edge of the page */
X    if (llx < current_llx) `7B
X`09llx = current_llx;
X`09urx = llx + p->width;
X    `7D
X    if (lly < current_lly) `7B
X`09lly = current_lly;
X`09ury = lly + p->height;
X    `7D
X    if (urx > current_urx) `7B
X`09urx = current_urx;
X`09llx = urx - p->width;
X    `7D
X    if (ury > current_ury) `7B
X`09ury = current_ury;
X`09lly = ury - p->height;
X    `7D
X    if (llx < current_llx) `7B
X`09llx = current_llx;
X    `7D
X    if (lly < current_lly) `7B
X`09lly = current_lly;
X    `7D
X    bottom_margin = lly - current_lly;
X    left_margin = llx - current_llx;
X    right_margin = current_urx - urx;
X    top_margin = current_ury - ury;
X
X`09`09`09`09`09`09`09num_args = 0;
X    if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X    `7D
X    XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainTop);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainBottom);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNright, XtChainRight);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNorientation, current_orientation);
X`09`09`09`09`09`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNllx, llx);      `09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNlly, lly);      `09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNurx, urx);      `09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNury, ury);      `09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNbottomMargin, bottom_margin);
X`09`09`09`09`09`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNleftMargin, left_margin);
X`09`09`09`09`09`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNrightMargin, right_margin);
X`09`09`09`09`09`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNtopMargin, top_margin); num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNbottomMargin, bottom_margin);
X`09`09`09`09`09`09`09num_args++;
X    XtSetFloatArg(args`5Bnum_args`5D, XtNxdpi, p->xdpi);`09num_args++;
X    XtSetFloatArg(args`5Bnum_args`5D, XtNydpi, p->ydpi);`09num_args++;
X    if (!toc_text) `7B
X        XtSetArg(args`5Bnum_args`5D, XtNfilename, filename);`09num_args++;
X    `7D
X    zoompage = XtCreateManagedWidget("page", ghostviewWidgetClass,
X`09`09`09`09     zoomform, args, num_args);
X    num_ghosts++;
X    XtAddCallback(zoompage, XtNcallback, track_and_zoom, (XtPointer)0);
X    XtAddCallback(zoompage, XtNmessageCallback, message, (XtPointer)zoompage
V);
X    XtAddCallback(zoompage, XtNdestroyCallback, destroy_ghost,
X`09`09  (XtPointer)zoompage);
X
X`09`09`09`09`09`09`09num_args = 0;
X    if (special_cmap) `7B
X`09XtSetArg(args`5Bnum_args`5D, XtNforeground, black);`09num_args++;
X`09XtSetArg(args`5Bnum_args`5D, XtNbackground, white);`09num_args++;
X    `7D
X    XtSetArg(args`5Bnum_args`5D, XtNfromVert, zoompage);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNtop, XtChainBottom);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNbottom, XtChainBottom);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNleft, XtChainLeft);`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNright, XtChainRight);`09num_args++;
X    zoomdismiss = XtCreateManagedWidget("dismiss", commandWidgetClass,
X`09`09`09`09       zoomform, args, num_args);
X    XtAddCallback(zoomdismiss, XtNcallback, destroy, (XtPointer)zoom);
X
X    XtSetArg(args`5B0`5D, XtNwidth, &width);
X    XtGetValues(zoompage, args, ONE);
X    XtSetArg(args`5B0`5D, XtNwidth, width);
X    XtSetValues(zoomdismiss, args, ONE);
X
X    XtRealizeWidget(zoom);
X    positionpopup(zoom);
X
X`09`09`09`09`09`09`09num_args = 0;
X    XtSetArg(args`5Bnum_args`5D, XtNwidth, &width);`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNheight, &height);`09num_args++;
X    XtGetValues(zoom, args, num_args);
X
X`09`09`09`09`09`09`09      `09num_args = 0;
X    XtSetArg(args`5Bnum_args`5D, XtNminWidth, width);`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNminHeight, height);`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNmaxWidth, width);`09`09num_args++;
X    XtSetArg(args`5Bnum_args`5D, XtNmaxHeight, height);`09`09num_args++;
X    XtSetValues(zoom, args, num_args);
X    XSetWMProtocols(XtDisplay(zoom), XtWindow(zoom), &wm_delete_window, 1);
X    XtPopup(zoom, XtGrabNone);
X
X    if (toc_text) `7B
X`09zoomfile = fopen(filename, "r");
X`09if (zoomfile == NULL) return;
X`09GhostviewSendPS(zoompage, zoomfile, doc->beginprolog,
X`09`09`09doc->lenprolog, False);
X`09GhostviewSendPS(zoompage, zoomfile, doc->beginsetup,
X`09`09`09doc->lensetup, False);
X`09if (doc->pageorder == DESCEND)
X`09    i = (doc->numpages - 1) - current_page;
X`09else
X`09    i = current_page;
X`09GhostviewSendPS(zoompage, zoomfile, doc->pages`5Bi`5D.begin,
X`09`09`09doc->pages`5Bi`5D.len, True);
X    `7D
X`7D
X
X/* Process messages from ghostscript */
X/* Refresh occurs when window was resized unexpectedly */
Xvoid
Xmessage(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    int i;
X    char *error;
X
X    if (!strcmp((char *) call_data, "Failed")) `7B
X`09if ((Widget)client_data == page) `7B
X`09    error = "Error: PostScript interpreter failed in main window.\n\n";
X`09`7D else `7B
X`09    error = "Error: PostScript interpreter failed in zoom window.\n\n";
X`09`7D
X`09output(w, NULL, error);
X    `7D else if (!strcmp((char *) call_data, "BadAlloc")) `7B
X`09if ((Widget)client_data == page) `7B
X`09    error =`20
X`09       "Warning: Could not allocate backing pixmap in main window.\n\n";
X`09`7D else `7B
X`09    error =`20
X`09       "Warning: Could not allocate backing pixmap in zoom window.\n\n";
X`09`7D
X`09output(w, NULL, error);
X    `7D else if (!strcmp((char *) call_data, "Refresh")) `7B
X`09if (toc_text) `7B
X`09    GhostviewSendPS(w, psfile, doc->beginprolog,
X`09`09`09    doc->lenprolog, False);
X`09    GhostviewSendPS(w, psfile, doc->beginsetup,
X`09`09`09    doc->lensetup, False);
X`09    if (doc->pageorder == DESCEND)
X`09`09i = (doc->numpages - 1) - current_page;
X`09    else
X`09`09i = current_page;
X`09    GhostviewSendPS(w, psfile, doc->pages`5Bi`5D.begin,
X`09`09`09    doc->pages`5Bi`5D.len, False);
X`09`7D
X    `7D
X`7D
X
X/* Take output from ghostscript and display it in the infotext popup window
V */
Xvoid
Xoutput(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    Arg args`5B2`5D;
X    XawTextBlock message_block;
X
X    message_block.firstPos = 0;
X    message_block.length = strlen(call_data);
X    message_block.ptr = call_data;
X    message_block.format = FMT8BIT;
X
X    XawTextDisableRedisplay(infotext);
X
X    XtSetArg(args`5B0`5D, XtNeditType, XawtextAppend);
X    XtSetValues(infotext, args, ONE);
X    XawTextReplace(infotext, info_length, info_length, &message_block);
X    info_length = info_length + message_block.length;
X
X    XtSetArg(args`5B0`5D, XtNeditType, XawtextRead);
X    XtSetArg(args`5B1`5D, XtNinsertPosition, info_length);
X    XtSetValues(infotext, args, TWO);
X    XawTextEnableRedisplay(infotext);
X    if (!info_up) XtPopup(infopopup, XtGrabNone);
X    info_up = True;
X`7D
X
X/* Dismiss popup dialog */
Xvoid
Xokay(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    String name, error;
X    Widget dialog;
X
X    dialog = (Widget)client_data;
X    name = GetDialogResponse(dialog);
X    switch (mode) `7B
X    case PRINT_WHOLE:
X    case PRINT_MARKED:
X`09if (error = print_file(name, (mode == PRINT_WHOLE))) `7B
X`09    char *buf = XtMalloc(strlen(error) +
X`09`09`09`09 strlen(app_res.print_prompt) + 2);
X`09    sprintf(buf, "%s\n%s", error, app_res.print_prompt);
X`09    SetDialogPrompt(dialog, buf);
X`09    XtFree(error);
X`09    XtFree(buf);
X`09`7D else `7B
X`09    XtPopdown(XtParent(dialog));
X`09`7D
X`09break;
X    case OPEN:
X`09if (error = open_file(name)) `7B
X`09    char *buf = XtMalloc(strlen(error) +
X`09`09`09`09 strlen(app_res.open_prompt) + 2);
X`09    sprintf(buf, "%s\n%s", error, app_res.open_prompt);
X`09    SetDialogPrompt(dialog, buf);
X`09    XtFree(error);
X`09    XtFree(buf);
X`09`7D else `7B
X`09    XtPopdown(XtParent(dialog));
X`09`7D
X`09break;
X    case SAVE:
X`09if (error = save_file(name)) `7B
X`09    char *buf = XtMalloc(strlen(error) +
X`09`09`09`09 strlen(app_res.save_prompt) + 2);
X`09    sprintf(buf, "%s\n%s", error, app_res.save_prompt);
X`09    SetDialogPrompt(dialog, buf);
X`09    XtFree(error);
X`09    XtFree(buf);
X`09`7D else `7B
X`09    XtPopdown(XtParent(dialog));
X`09`7D
X`09break;
X    `7D
X    XtFree(name);
X`7D
X
X/* Dismiss popup window */
Xvoid
Xdismiss(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XtPopdown((Widget)client_data);
X    if ((Widget)client_data == infopopup) info_up = False;
X`7D
X
X/* Destroy popup window */
Xvoid
Xdestroy(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    XtDestroyWidget((Widget)client_data);
X`7D
X
X/* destroy callback for Ghostview widgets. */
X/* The disable interpreter call ensures that ghostscript is killed. */
X/* One the count goes to 0, we are sure that all forked processes have */
X/* been killed and that we can safely exit. */
Xvoid
Xdestroy_ghost(w, client_data, call_data)
X    Widget w;
X    XtPointer client_data, call_data;
X`7B
X    GhostviewDisableInterpreter((Widget) client_data);
X    num_ghosts--;
X    if (num_ghosts) return;
X    if (dying) old_Xerror(XtDisplay(w), &bomb);
X    XtDestroyApplicationContext(app_con);
X    exit(0);
X`7D
$ CALL UNPACK CALLBACKS.C;1 2064228442
$ create 'f'
XComments recognized by ghostview
X================================
X
X%!PS-Adobe-<real> `5BEPSF-<real>`5D
X%%BoundingBox: <int> <int> <int> <int>`7C(atend)
X%%CreationDate: <textline>
X%%Orientation: Portrait`7CLandscape`7C(atend)
X%%Pages: <uint>`7C(atend)
X%%PageOrder: Ascend`7CDescend`7CSpecial`7C(atend)
X%%Title: <textline>
X%%DocumentMedia: <text> <real> <real> <real> <text> <text>
X%%DocumentPageSizes: <text>
X%%EndComments
X
X%%BeginPreview
X%%EndPreview
X
X%%BeginDefaults
X%%PageBoundingBox: <int> <int> <int> <int>`7C(atend)
X%%PageOrientation: Portrait`7CLandscape
X%%PageMedia: <text>
X%%EndDefaults
X
X%%BeginProlog
X%%EndProlog
X
X%%BeginSetup
X%%PageBoundingBox: <int> <int> <int> <int>`7C(atend)
X%%PageOrientation: Portrait`7CLandscape
X%%PaperSize: <text>
X%%EndSetup
X
X%%Page: <text> <uint>
X%%PageBoundingBox: <int> <int> <int> <int>`7C(atend)
X%%PageOrientation: Portrait`7CLandscape
X%%PageMedia: <text>
X%%PaperSize: <text>
X
X%%Trailer
X%%EOF
X
X%%BeginDocument: <text> `5B<real>`5B<text>`5D`5D
X%%EndDocument
X
X%%BeginBinary: <uint>
X%%EndBinary
X
X%%BeginData: <uint> `5BHex`7CBinary`7CASCII`5BBytes`7CLines`5D`5D
X%%EndData
X
X
XPaper Keywords and paper size in points
X=======================================
X
XLetter`09`09 612x792
XLetterSmall`09 612x792
XTabloid`09`09 792x1224
XLedger`09`091224x792
XLegal`09`09 612x1008
XStatement`09 396x612
XExecutive`09 540x720
XA3`09`09 842x1190
XA4`09`09 595x842
XA4Small`09`09 595x842
XA5`09`09 420x595
XB4`09`09 729x1032
XB5`09`09 516x729
XEnvelope`09 ???x???
XFolio`09`09 612x936
XQuarto`09`09 610x780
X10x14`09`09 720x1008
$ CALL UNPACK COMMENTS.DOC;1 506932914
$ create 'f'
X`09`09    GNU GENERAL PUBLIC LICENSE
X`09`09       Version 2, June 1991
X
X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
X                          675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X`09`09`09    Preamble
X
X  The licenses for most software are designed to take away your
Xfreedom to share and change it.  By contrast, the GNU General Public
XLicense is intended to guarantee your freedom to share and change free
Xsoftware--to make sure the software is free for all its users.  This
XGeneral Public License applies to most of the Free Software
XFoundation's software and to any other program whose authors commit to
Xusing it.  (Some other Free Software Foundation software is covered by
Xthe GNU Library General Public License instead.)  You can apply it to
Xyour programs, too.
X
X  When we speak of free software, we are referring to freedom, not
Xprice.  Our General Public Licenses are designed to make sure that you
Xhave the freedom to distribute copies of free software (and charge for
Xthis service if you wish), that you receive source code or can get it
Xif you want it, that you can change the software or use pieces of it
Xin new free programs; and that you know you can do these things.
X
X  To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if you
Xdistribute copies of the software, or if you modify it.
X
X  For example, if you distribute copies of such a program, whether
Xgratis or for a fee, you must give the recipients all the rights that
Xyou have.  You must make sure that they, too, receive or can get the
Xsource code.  And you must show them these terms so they know their
Xrights.
X
X  We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
Xdistribute and/or modify the software.
X
X  Also, for each author's protection and ours, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xsoftware.  If the software is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original, so
Xthat any problems introduced by others will not reflect on the original
Xauthors' reputations.
X
X  Finally, any free program is threatened constantly by software
Xpatents.  We wish to avoid the danger that redistributors of a free
Xprogram will individually obtain patent licenses, in effect making the
Xprogram proprietary.  To prevent this, we have made it clear that any
Xpatent must be licensed for everyone's free use or not licensed at all.
X
X  The precise terms and conditions for copying, distribution and
Xmodification follow.
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X`09`09    GNU GENERAL PUBLIC LICENSE
X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X  0. This License applies to any program or other work which contains
Xa notice placed by the copyright holder saying it may be distributed
Xunder the terms of this General Public License.  The "Program", below,
Xrefers to any such program or work, and a "work based on the Program"
Xmeans either the Program or any derivative work under copyright law:
Xthat is to say, a work containing the Program or a portion of it,
Xeither verbatim or with modifications and/or translated into another
Xlanguage.  (Hereinafter, translation is included without limitation in
Xthe term "modification".)  Each licensee is addressed as "you".
X
XActivities other than copying, distribution and modification are not
Xcovered by this License; they are outside its scope.  The act of
Xrunning the Program is not restricted, and the output from the Program
Xis covered only if its contents constitute a work based on the
XProgram (independent of having been made by running the Program).
XWhether that is true depends on what the Program does.
X
X  1. You may copy and distribute verbatim copies of the Program's
Xsource code as you receive it, in any medium, provided that you
Xconspicuously and appropriately publish on each copy an appropriate
Xcopyright notice and disclaimer of warranty; keep intact all the
Xnotices that refer to this License and to the absence of any warranty;
Xand give any other recipients of the Program a copy of this License
Xalong with the Program.
X
XYou may charge a fee for the physical act of transferring a copy, and
Xyou may at your option offer warranty protection in exchange for a fee.
X
X  2. You may modify your copy or copies of the Program or any portion
Xof it, thus forming a work based on the Program, and copy and
Xdistribute such modifications or work under the terms of Section 1
Xabove, provided that you also meet all of these conditions:
X
X    a) You must cause the modified files to carry prominent notices
X    stating that you changed the files and the date of any change.
X
X    b) You must cause any work that you distribute or publish, that in
X    whole or in part contains or is derived from the Program or any
X    part thereof, to be licensed as a whole at no charge to all third
X    parties under the terms of this License.
X
X    c) If the modified program normally reads commands interactively
X    when run, you must cause it, when started running for such
X    interactive use in the most ordinary way, to print or display an
X    announcement including an appropriate copyright notice and a
X    notice that there is no warranty (or else, saying that you provide
X    a warranty) and that users may redistribute the program under
X    these conditions, and telling the user how to view a copy of this
X    License.  (Exception: if the Program itself is interactive but
X    does not normally print such an announcement, your work based on
X    the Program is not required to print an announcement.)
X
X
X
X
X
X
X
X
X
X
X
X
X
X
XThese requirements apply to the modified work as a whole.  If
Xidentifiable sections of that work are not derived from the Program,
Xand can be reasonably considered independent and separate works in
Xthemselves, then this License, and its terms, do not apply to those
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
Technical Details
Message-ID: <8881757@MVB.SAIC.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!usc!news.service.uci.edu!unogate!mvb.saic.com!vmsnet-sources
Newsgroups: vmsnet.sources
From: Terry Poot <tp@mccall.com>
Subject: Ghostview for VMS 01/14
Message-ID: <8881757@MVB.SAIC.COM>
Date: Thu, 29 Oct 1992 18:49:11 GMT
Lines: 1626
Approved: Mark.Berryman@Mvb.Saic.Com