Article View: vmsnet.sources
Article #23Ghostview for VMS 13/14
From: Terry Poot
Date: Thu, 29 Oct 1992 18:50
Date: Thu, 29 Oct 1992 18:50
1337 lines
49220 bytes
49220 bytes
Submitted-by: Terry Poot <tp@mccall.com>
Posting-number: Volume 3, Issue 231
Archive-name: ghostview/part13
-+-+-+-+-+-+-+-+ START OF PART 13 -+-+-+-+-+-+-+-+
XVMS POSIX is used to convert the application defaults file to a C include
Xfile for use as fallback resources. The include file is provided for the
Xshipped version of the application defaults file, but if you don't have
XPOSIX installed, you won't be able to automatically update the include file
Xto match changes you make to the application defaults file. Note that the
Xdata in the include file is used only if you do NOT install the application
Xdefaults file on your system (see the Installation section below).`20
X
X(If you have a unix system available, you can move files back and forth
Xmanually and run ad2c on that machine to create an updated app-defaults.h.)
X
XIf you have MMS:
X
XFirst, edit DESCRIP.MMS. Change the second line to show the proper location
Xon your system for the command procedure that defines the Athena logical
Xnames (this is the LOGICALS.COM procedure that came with George Carrette's
XAthena widget kit). Also, if you don't have VMS POSIX 1.0 installed on your
Xsystem, delete the line that starts:
X
Xsource:app-defaults.h : source:Ghostview.ad
X
Xand the following action lines, or just add a "!" before the POSIX/RUN
Xcommand.`20
X
XOnce you've made these changes, just type "MMS" and it should build.
X
XIf you don't have MMS:
X
XFirst, edit VMS_BUILD.COM. Change the first line to show the proper
Xlocation on your system for the command procedure that defines the Athena
Xlogical names (this is the LOGICALS.COM procedure that came with George
XCarrette's Athena widget kit). Also, if you don't have VMS POSIX 1.0
Xinstalled on your system, delete or comment out the line that contains the
Xcommand POSIX/RUN. Then simply type in "@VMS_BUILD".
X
XYou might notice that we don't use all the source files. The ones not part
Xof the VMS build procedure aren't needed for VMS. This includes setenv.c,
Xgetenv.c, and all source files for the select file widget. The file
Xvms_types.h is new, and is used to define VMS data structures in
Xghostview.c. This file was written by Jym Dyer in 1989, so I don't know if
Xthe email address in the file is still good. I added a definition to it
X(IOSB_GET_T). It was already Copyright'ed under the GPL, so there's no
Xconflict including it here.
X
XInstallation
X------------
X
XTo run Ghostview, you must define a foreign command for it. This can be
Xdone in a user's login.com, or in the system wide sylogin.com for
Xconvenience. The command to do this is:
X
X$ gv :==$dev:`5Bdir`5Dgv.exe
X
XFill in the device and directory for your site. Note the "$" after the
X":==". It's important that it be there.
X
XYou can call this something other than gv, but DON'T call it ghostview!!!
XRepeat: DON'T CALL IT GHOSTVIEW!!! If you do, Ghostscript will no longer
Xwork on your system, except (maybe) when called by Ghostview. The reason,
Xfor the curious, is that Ghostscript expects the environment variable
XGHOSTVIEW, if it exists, to be the window id of the window it should draw
Xon. That's how Ghostview gets Ghostscript to use a Ghostview window for
Xoutput. Symbols, including foreign command symbols, will be seen as
Xenvironment variables, so Ghostscript will try to use your command
Xdefinition as a window id, and choke and die.
X
XSpeaking of Ghostscript, the default resource setup expects it to be
Xdefined as a foreign command named gs. If you choose to call the
XGhostscript command something else, you'll need to change the interpreter
Xresource of Ghostview to the command needed to run Ghostscript (or supply
Xthe -interpreter command line option). It MUST be defined as a foreign
Xcommand so that Ghostview can set some command line options.
X
XThe application defaults file can be installed system-wide by copying it to
XDECW$SYSTEM_DEFAULTS:GHOSTVIEW.DAT (you have to have privileges to do
Xthat). Alternately, each Ghostview user can copy it to
XDECW$USER_DEFAULTS:GHOSTVIEW.DAT. (DECW$USER_DEFAULTS usually points to the
Xuser's login directory.) If that file is not found, the compiled in values
Xwill be used. Therefore, if you install the application defaults file, you
Xdon't really have to worry about keeping app-defaults.h up to date, as it
Xis only used if the app defaults file isn't found. You will especially want
Xto install the file if you don't have VMS POSIX available to maintain the
Xinclude file that is derived from it.
X
XNotes for application users
X---------------------------
X
XThere aren't too many differences to worry about.`20
X
XNo attempt has been made to port the select file widget. Any prompt for a
Xfile name will simply pop up a dialog box into which you type the file
Xname. I'd have tried to integrate the DECwindows file selection widget, but
Xthis is an Athena program, and I figured the hassle to get it all to work
Xtogether wouldn't be worth the trouble. Besides, in my application, I
Xdidn't need it. :-)
X
XAlso the print related resources have been changed a bit.`20
X
XThe printCommand resource must be a command that takes a filename argument.
XThe default for printCommand is "Print_dcl/Delete". The "_dcl" suffix is to
Xavoid any symbol redefinitions of the print command.
X
XThe printerVariable resource is the name of a logical name that may contain
Xqualifiers to the print command. The logical name has been changed from
XPRINTER to GV_PRINT_QUAL to make it a little bit safer to set system wide,
Xfor instance with a /QUEUE=xxx qualifier to point to the queue serving your
Xpostscript printer. The printPrompt resource has been changed to "Print
XQualifiers: " to reflect this usage.
X
XdefaultPrinter defaults to NULL, but it will be set the the equivalence
Xstring for GV_PRINT_QUAL at application startup if that logical is set (or
Xwhatever logical might be named in printerVariable if you change it). Thus
Xyou can default the print queue either with a logical name or by putting it
Xin Ghostview's application defaults file.
X
XAny print command can be used, but bear in mind that it must take one
Xargument, which is a temporary file name. The print command must delete
Xthis file or it will be left lying around. printerVariable may be used to
Xpass any qualifiers to the command. It can be used to select a print queue,
Xform, etc. This is the item that is prompted for when you tell it to print.
X(printPrompt has been changed from "Printer Name:" to "Print Qualifiers:").
XIf you define a logical name or symbol named GV_PRINT_QUAL (or some other
Xname if you change printerVariable) it will be used as the
Xdefault response for this prompt.
X
XThe command executed in any print request is the value of printComand,
Xfollowed by a space and then by the print qualifiers specified by the user
X(which default to defaultPrinter, see above) followed by another space and
Xthen the temp file name. You can fill in these 2 resources to suit
Xyour needs. Just remember the user can over-ride the second one at run
Xtime. (That's why the /DELETE is part of the print command as distributed,
Xrather than included as a default in defaultPrinter.)
X
XThis would make a bit more sense if I'd renamed the resources, but that
Xwould have created a lot of VMS specific code for little actual gain. If it
Xhelps you keep track of them, here's a brief summary table:
X
Xresource VMS Value What it is
X-------- --------- ----------
XprintCommand PRINT_DCL/DELETE The print command
XprinterVariable GV_PRINT_QUAL logical name to hold default qualifie
Vrs
XdefaultPrinter <empty> Default qualifiers, over-ridden by
X GV_PRINT_QUAL if set
XprintPrompt "Print Qualifiers:" Just a prompt string
X
XNotes for widget users
X----------------------
X
XSee the notes for application users for differences in resources.
X
XThe widget uses VMS Event Flag number 23. You can change the event flag
Xnumber by changing the define for XtEFN in ghostview.c. Ghostview can
Xtolerate other modules in the program setting the flag, as it always checks
Xfor actual I/O completion using IOSB's. However, if you clear the flag, Xt
Xmay miss an I/O completion and your program could hang. Best to simply
Xavoid it.
X
XI've made changes to the definitions of the widget data in ghostviewp.h.
XI've ifdef'ed out data items not used in the VMS version and added a few
Xthat I needed under VMS. I might have missed a few of the former kind, but
Xif so, they should just sit around unused and not bother anyone.
X--
XTerry Poot <tp@mccall.com> The McCall Pattern Company
X(uucp: ...!rutgers!depot!mccall!tp) 615 McCall Road
X(800)255-2762, in KS (913)776-4041 Manhattan, KS 66502, USA
$ CALL UNPACK README.VMS;1 2049403924
$ create 'f'
Xad2c ghostview.ad >app-defaults.h
$ CALL UNPACK RUN-AD2C.;1 1510163122
$ create 'f'
X/*
X * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted, provided
X * that the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of Software Research Associates not be u
Vsed
X * in advertising or publicity pertaining to distribution of the software
X * without specific, written prior permission. Software Research Associates
X * makes no representations about the suitability of this software for any
X * purpose. It is provided "as is" without express or implied warranty.
X *
X * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
V,
X * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FRO
VM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENC
VE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author: Erik M. van der Poel
X * Software Research Associates, Inc., Tokyo, Japan
X * erik@sra.co.jp
X */
X
X/*
X * Author's address:
X *
X * erik@sra.co.jp
X * OR
X * erik%sra.co.jp@uunet.uu.net
X * OR
X * erik%sra.co.jp@mcvax.uucp
X * OR
X * try junet instead of co.jp
X * OR
X * Erik M. van der Poel
X * Software Research Associates, Inc.
X * 1-1-1 Hirakawa-cho, Chiyoda-ku
X * Tokyo 102 Japan. TEL +81-3-234-2692
X */
X
X#include <stdio.h>
X#include <errno.h>
X/* BSD 4.3 errno.h does not declare errno */
Xextern int errno;
Xextern int sys_nerr;
Xextern char *sys_errlist`5B`5D;
X
X#include <sys/param.h>
X#include <X11/cursorfont.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Composite.h>
X#include <X11/Shell.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Scrollbar.h>
X#include <X11/Xaw/Label.h>
X
X#include "SFinternal.h"
X
X#ifndef MAXPATHLEN
X#define MAXPATHLEN 1024
X#endif /* ndef MAXPATHLEN */
X
X#if !defined(SVR4) && !defined(SYSV) && !defined(USG)
Xextern char *getwd();
X#endif /* !defined(SVR4) && !defined(SYSV) && !defined(USG) */
X
Xint SFstatus = SEL_FILE_NULL;
X
Xchar
X`09SFstartDir`5BMAXPATHLEN`5D,
X`09SFcurrentPath`5BMAXPATHLEN`5D,
X`09SFcurrentDir`5BMAXPATHLEN`5D;
X
XWidget
X`09selFile,
X`09selFileCancel,
X`09selFileField,
X`09selFileForm,
X`09selFileHScroll,
X`09selFileHScrolls`5B3`5D,
X`09selFileLists`5B3`5D,
X`09selFileOK,
X`09selFilePrompt,
X`09selFileVScrolls`5B3`5D;
X
XDisplay *SFdisplay;
X
XPixel SFfore, SFback;
X
XAtom`09SFwmDeleteWindow;
X
XXSegment SFsegs`5B2`5D, SFcompletionSegs`5B2`5D;
X
XXawTextPosition SFtextPos;
X
Xint SFupperX, SFlowerY, SFupperY;
X
Xint SFtextX, SFtextYoffset;
X
Xint SFentryWidth, SFentryHeight;
X
Xint SFlineToTextH = 3;
X
Xint SFlineToTextV = 3;
X
Xint SFbesideText = 3;
X
Xint SFaboveAndBelowText = 2;
X
Xint SFcharsPerEntry = 15;
X
Xint SFlistSize = 10;
X
Xint SFworkProcAdded = 0;
X
XXtAppContext SFapp;
X
Xint SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
X
Xchar SFtextBuffer`5BMAXPATHLEN`5D;
X
XXtIntervalId SFdirModTimerId;
X
Xint (*SFfunc)();
X
Xstatic char *oneLineTextEditTranslations = "\
X`09<Key>Return:`09redraw-display()\n\
X`09Ctrl<Key>M:`09redraw-display()\n\
X";
X
X/* ARGSUSED */
Xstatic void
XSFexposeList(w, n, event)
X`09Widget`09`09w;
X`09int`09`09n;
X`09XExposeEvent`09*event;
X`7B
X`09if ((event->type == NoExpose) `7C`7C event->count) `7B
X`09`09return;
X`09`7D
X
X`09SFdrawList(n, SF_DO_NOT_SCROLL);
X`7D
X
X/* ARGSUSED */
Xstatic void
XSFmodVerifyCallback(w, client_data, event)
X`09Widget`09`09`09w;
X`09XtPointer`09`09client_data;
X`09XKeyPressedEvent`09*event;
X`7B
X`09char`09buf`5B2`5D;
X
X`09if (
X`09`09(XLookupString(event, buf, 2, NULL, NULL) == 1) &&
X`09`09((*buf) == '\r')
X`09) `7B
X`09`09SFstatus = SEL_FILE_OK;
X`09`7D else `7B
X`09`09SFstatus = SEL_FILE_TEXT;
X`09`7D
X`7D
X
X/* ARGSUSED */
Xstatic void
XSFokCallback(w)
X`09Widget`09w;
X`7B
X`09SFstatus = SEL_FILE_OK;
X`7D
X
Xstatic XtCallbackRec SFokSelect`5B`5D = `7B
X`09`7B SFokCallback, (XtPointer) NULL `7D,
X`09`7B NULL, (XtPointer) NULL `7D,
X`7D;
X
X/* ARGSUSED */
Xstatic void
XSFcancelCallback(w)
X`09Widget`09w;
X`7B
X`09SFstatus = SEL_FILE_CANCEL;
X`7D
X
Xstatic XtCallbackRec SFcancelSelect`5B`5D = `7B
X`09`7B SFcancelCallback, (XtPointer) NULL `7D,
X`09`7B NULL, (XtPointer) NULL `7D,
X`7D;
X
X/* ARGSUSED */
Xstatic void
XSFdismissAction(w, event, params, num_params)
X`09Widget`09w;
X`09XEvent *event;
X`09String *params;
X`09Cardinal *num_params;
X`7B
X`09if (event->type == ClientMessage &&
X`09 event->xclient.data.l`5B0`5D != SFwmDeleteWindow) return;
X
X`09SFstatus = SEL_FILE_CANCEL;
X`7D
X
Xstatic char *wmDeleteWindowTranslation = "\
X`09<Message>WM_PROTOCOLS:`09SelFileDismiss()\n\
X";
X
Xstatic XtActionsRec actions`5B`5D = `7B
X`09`7B"SelFileDismiss",`09SFdismissAction`7D,
X`7D;
X
Xstatic void
XSFcreateWidgets(toplevel, prompt, ok, cancel)
X`09Widget`09toplevel;
X`09char`09*prompt;
X`09char`09*ok;
X`09char`09*cancel;
X`7B
X`09int`09`09i, n;
X`09int`09`09listWidth, listHeight;
X`09int`09`09listSpacing = 10;
X`09int`09`09scrollThickness = 15;
X`09int`09`09hScrollX, hScrollY;
X`09int`09`09vScrollX, vScrollY;
X`09Cursor
X`09`09`09xtermCursor,
X`09`09`09sbRightArrowCursor,
X`09`09`09dotCursor;
X`09Arg`09`09arglist`5B20`5D;
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNtransientFor, toplevel);`09`09i++;
X
X`09selFile = XtAppCreateShell("selFile", "SelFile",
X`09`09transientShellWidgetClass, SFdisplay, arglist, i);
X
X`09/* Add WM_DELETE_WINDOW protocol */
X`09XtAppAddActions(XtWidgetToApplicationContext(selFile),
X`09`09actions, XtNumber(actions));
X`09XtOverrideTranslations(selFile,
X`09`09XtParseTranslationTable(wmDeleteWindowTranslation));
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNdefaultDistance, 30);`09`09`09i++;
X`09selFileForm = XtCreateManagedWidget("selFileForm",
X`09`09formWidgetClass, selFile, arglist, i);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNlabel, prompt);`09`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNresizable, True);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderWidth, 0);`09`09`09i++;
X`09selFilePrompt = XtCreateManagedWidget("selFilePrompt",
X`09`09labelWidgetClass, selFileForm, arglist, i);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNforeground, &SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbackground, &SFback);`09`09`09i++;
X`09XtGetValues(selFilePrompt, arglist, i);
X
X`09SFinitFont();
X
X`09SFentryWidth = SFbesideText + SFcharsPerEntry * SFcharWidth +
X`09`09`09SFbesideText;
X`09SFentryHeight = SFaboveAndBelowText + SFcharHeight +
X`09`09`09SFaboveAndBelowText;
X
X`09listWidth = SFlineToTextH + SFentryWidth + SFlineToTextH + 1 +
X`09`09`09scrollThickness;
X`09listHeight = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
X`09`09`09SFlineToTextV + SFlistSize * SFentryHeight +
X`09`09`09SFlineToTextV + 1 + scrollThickness;
X
X`09SFpathScrollWidth = 3 * listWidth + 2 * listSpacing + 4;
X
X`09hScrollX = -1;
X`09hScrollY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
X`09`09`09SFlineToTextV + SFlistSize * SFentryHeight +
X`09`09`09SFlineToTextV;
X`09SFhScrollWidth = SFlineToTextH + SFentryWidth + SFlineToTextH;
X
X`09vScrollX = SFlineToTextH + SFentryWidth + SFlineToTextH;
X`09vScrollY = SFlineToTextV + SFentryHeight + SFlineToTextV;
X`09SFvScrollHeight = SFlineToTextV + SFlistSize * SFentryHeight +
X`09`09`09SFlineToTextV;
X
X`09SFupperX = SFlineToTextH + SFentryWidth + SFlineToTextH - 1;
X`09SFlowerY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
X`09`09`09SFlineToTextV;
X`09SFupperY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
X`09`09`09SFlineToTextV + SFlistSize * SFentryHeight - 1;
X
X`09SFtextX = SFlineToTextH + SFbesideText;
X`09SFtextYoffset = SFlowerY + SFaboveAndBelowText + SFcharAscent;
X
X`09SFsegs`5B0`5D.x1 = 0;
X`09SFsegs`5B0`5D.y1 = vScrollY;
X`09SFsegs`5B0`5D.x2 = vScrollX - 1;
X`09SFsegs`5B0`5D.y2 = vScrollY;
X`09SFsegs`5B1`5D.x1 = vScrollX;
X`09SFsegs`5B1`5D.y1 = 0;
X`09SFsegs`5B1`5D.x2 = vScrollX;
X`09SFsegs`5B1`5D.y2 = vScrollY - 1;
X
X`09SFcompletionSegs`5B0`5D.x1 = SFcompletionSegs`5B0`5D.x2 = SFlineToTextH;
X`09SFcompletionSegs`5B1`5D.x1 = SFcompletionSegs`5B1`5D.x2 =
X`09`09SFlineToTextH + SFentryWidth - 1;
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNwidth, 3 * listWidth + 2 * listSpacing + 4);
X`09`09`09`09`09`09`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFilePrompt);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 10);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNresizable, True);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNstring, SFtextBuffer);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNlength, MAXPATHLEN);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNeditType, XawtextEdit);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNwrap, XawtextWrapWord);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNresize, XawtextResizeHeight);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNuseStringInPlace, True);`09`09i++;
X`09selFileField = XtCreateManagedWidget("selFileField",
X`09`09asciiTextWidgetClass, selFileForm, arglist, i);
X
X`09XtOverrideTranslations(selFileField,
X`09`09XtParseTranslationTable(oneLineTextEditTranslations));
X`09XtSetKeyboardFocus(selFileForm, selFileField);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNorientation, XtorientHorizontal);`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNwidth, SFpathScrollWidth);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNheight, scrollThickness);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileField);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 30);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileHScroll = XtCreateManagedWidget("selFileHScroll",
X`09`09scrollbarWidgetClass, selFileForm, arglist, i);
X
X`09XtAddCallback(selFileHScroll, XtNjumpProc,
X`09`09SFpathSliderMovedCallback, (XtPointer) NULL);
X`09XtAddCallback(selFileHScroll, XtNscrollProc,
X`09`09SFpathAreaSelectedCallback, (XtPointer) NULL);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNwidth, listWidth);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNheight, listHeight);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileHScroll);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 10);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileLists`5B0`5D = XtCreateManagedWidget("selFileList1",
X`09`09compositeWidgetClass, selFileForm, arglist, i);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNwidth, listWidth);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNheight, listHeight);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromHoriz, selFileLists`5B0`5D);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileHScroll);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNhorizDistance, listSpacing);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 10);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileLists`5B1`5D = XtCreateManagedWidget("selFileList2",
X`09`09compositeWidgetClass, selFileForm, arglist, i);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNwidth, listWidth);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNheight, listHeight);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromHoriz, selFileLists`5B1`5D);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileHScroll);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNhorizDistance, listSpacing);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 10);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileLists`5B2`5D = XtCreateManagedWidget("selFileList3",
X`09`09compositeWidgetClass, selFileForm, arglist, i);
X
X`09for (n = 0; n < 3; n++) `7B
X
X`09`09i = 0;
X`09`09XtSetArg(arglist`5Bi`5D, XtNx, vScrollX);`09`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNy, vScrollY);`09`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNwidth, scrollThickness);`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNheight, SFvScrollHeight);`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09i++;
X`09`09selFileVScrolls`5Bn`5D = XtCreateManagedWidget("selFileVScroll",
X`09`09`09scrollbarWidgetClass, selFileLists`5Bn`5D, arglist, i);
X
X`09`09XtAddCallback(selFileVScrolls`5Bn`5D, XtNjumpProc,
X`09`09`09SFvFloatSliderMovedCallback, (XtPointer) n);
X`09`09XtAddCallback(selFileVScrolls`5Bn`5D, XtNscrollProc,
X`09`09`09SFvAreaSelectedCallback, (XtPointer) n);
X
X`09`09i = 0;
X
X`09`09XtSetArg(arglist`5Bi`5D, XtNorientation, XtorientHorizontal);
X`09`09`09`09`09`09`09`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNx, hScrollX);`09`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNy, hScrollY);`09`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNwidth, SFhScrollWidth);`09`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNheight, scrollThickness);`09i++;
X`09`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09i++;
X`09`09selFileHScrolls`5Bn`5D = XtCreateManagedWidget("selFileHScroll",
X`09`09`09scrollbarWidgetClass, selFileLists`5Bn`5D, arglist, i);
X
X`09`09XtAddCallback(selFileHScrolls`5Bn`5D, XtNjumpProc,
X`09`09`09SFhSliderMovedCallback, (XtPointer) n);
X`09`09XtAddCallback(selFileHScrolls`5Bn`5D, XtNscrollProc,
X`09`09`09SFhAreaSelectedCallback, (XtPointer) n);
X`09`7D
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNlabel, ok);`09`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNresizable, True);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNcallback, SFokSelect);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileLists`5B0`5D);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 30);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileOK = XtCreateManagedWidget("selFileOK", commandWidgetClass,
X`09`09selFileForm, arglist, i);
X
X`09i = 0;
X`09XtSetArg(arglist`5Bi`5D, XtNlabel, cancel);`09`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNresizable, True);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNcallback, SFcancelSelect);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNborderColor, SFfore);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromHoriz, selFileOK);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNfromVert, selFileLists`5B0`5D);`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNhorizDistance, 30);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNvertDistance, 30);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNtop, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNbottom, XtChainTop);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNleft, XtChainLeft);`09`09`09i++;
X`09XtSetArg(arglist`5Bi`5D, XtNright, XtChainLeft);`09`09`09i++;
X`09selFileCancel = XtCreateManagedWidget("selFileCancel",
X`09`09commandWidgetClass, selFileForm, arglist, i);
X
X`09XtSetMappedWhenManaged(selFile, False);
X`09XtRealizeWidget(selFile);
X
X`09/* Add WM_DELETE_WINDOW protocol */
X`09SFwmDeleteWindow = XInternAtom(SFdisplay, "WM_DELETE_WINDOW", False);
X`09XSetWMProtocols(SFdisplay, XtWindow(selFile), &SFwmDeleteWindow, 1);
X
X`09SFcreateGC();
X
X`09xtermCursor = XCreateFontCursor(SFdisplay, XC_xterm);
X
X`09sbRightArrowCursor = XCreateFontCursor(SFdisplay, XC_sb_right_arrow);
X`09dotCursor = XCreateFontCursor(SFdisplay, XC_dot);
X
X`09XDefineCursor(SFdisplay, XtWindow(selFileForm), xtermCursor);
X`09XDefineCursor(SFdisplay, XtWindow(selFileField), xtermCursor);
X
X`09for (n = 0; n < 3; n++) `7B
X`09`09XDefineCursor(SFdisplay, XtWindow(selFileLists`5Bn`5D),
X`09`09`09sbRightArrowCursor);
X`09`7D
X`09XDefineCursor(SFdisplay, XtWindow(selFileOK), dotCursor);
X`09XDefineCursor(SFdisplay, XtWindow(selFileCancel), dotCursor);
X
X`09for (n = 0; n < 3; n++) `7B
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, ExposureMask, True,
X`09`09`09SFexposeList, (XtPointer) n);
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, EnterWindowMask, False,
X`09`09`09SFenterList, (XtPointer) n);
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, LeaveWindowMask, False,
X`09`09`09SFleaveList, (XtPointer) n);
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, PointerMotionMask, False,
X`09`09`09SFmotionList, (XtPointer) n);
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, ButtonPressMask, False,
X`09`09`09SFbuttonPressList, (XtPointer) n);
X`09`09XtAddEventHandler(selFileLists`5Bn`5D, ButtonReleaseMask, False,
X`09`09`09SFbuttonReleaseList, (XtPointer) n);
X`09`7D
X
X`09XtAddEventHandler(selFileField, KeyPressMask, False,
X`09`09SFmodVerifyCallback, (XtPointer) NULL);
X
X`09SFapp = XtWidgetToApplicationContext(selFile);
X
X`7D
X
X/* position widget under the cursor */
Xvoid
XSFpositionWidget(w)
X Widget w;
X`7B
X Arg args`5B3`5D;
X Cardinal num_args;
X Dimension width, height, b_width;
X int x, y, max_x, max_y;
X Window root, child;
X int dummyx, dummyy;
X unsigned int dummymask;
X `20
X XQueryPointer(XtDisplay(w), XtWindow(w), &root, &child, &x, &y,
X`09`09 &dummyx, &dummyy, &dummymask);
X num_args = 0;
X XtSetArg(args`5Bnum_args`5D, XtNwidth, &width); num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNheight, &height); num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNborderWidth, &b_width); num_args++;
X XtGetValues(w, args, num_args);
X
X width += 2 * b_width;
X height += 2 * b_width;
X
X x -= ( (Position) width/2 );
X if (x < 0) x = 0;
X if ( x > (max_x = (Position) (XtScreen(w)->width - width)) ) x = max_x;
X
X y -= ( (Position) height/2 );
X if (y < 0) y = 0;
X if ( y > (max_y = (Position) (XtScreen(w)->height - height)) ) y = max_y
V;
X `20
X num_args = 0;
X XtSetArg(args`5Bnum_args`5D, XtNx, x); num_args++;
X XtSetArg(args`5Bnum_args`5D, XtNy, y); num_args++;
X XtSetValues(w, args, num_args);
X`7D
X
XFILE *
XSFopenFile(name, mode, prompt, failed)
X char *name;
X char *mode;
X char *prompt;
X char *failed;
X`7B
X Arg args`5B1`5D;
X FILE *fp;
X
X SFchdir(SFstartDir);
X if ((fp = fopen(name, mode)) == NULL) `7B
X`09char *buf;
X`09if (errno <= sys_nerr) `7B
X`09 buf = XtMalloc(strlen(failed) + strlen(sys_errlist`5Berrno`5D) +`20
X`09`09`09 strlen(prompt) + 2);
X`09 strcpy(buf, failed);
X`09 strcat(buf, sys_errlist`5Berrno`5D);
X`09 strcat(buf, "\n");
X`09 strcat(buf, prompt);
X`09`7D else `7B
X`09 buf = XtMalloc(strlen(failed) + strlen(prompt) + 2);
X`09 strcpy(buf, failed);
X`09 strcat(buf, "\n");
X`09 strcat(buf, prompt);
X`09`7D
X`09XtSetArg(args`5B0`5D, XtNlabel, buf);
X`09XtSetValues(selFilePrompt, args, 1);
X`09XtFree(buf);
X`09return NULL;
X `7D
X return fp;
X`7D
X
XSFtextChanged()
X`7B
X
X`09if ((SFtextBuffer`5B0`5D == '/') `7C`7C (SFtextBuffer`5B0`5D == '`7E')) `
V7B
X`09`09(void) strcpy(SFcurrentPath, SFtextBuffer);
X
X`09`09SFtextPos = XawTextGetInsertionPoint(selFileField);
X`09`7D else `7B
X`09`09(void) strcat(strcpy(SFcurrentPath, SFstartDir), SFtextBuffer);
X
X`09`09SFtextPos = XawTextGetInsertionPoint(selFileField) +
X`09`09`09strlen(SFstartDir);
X`09`7D
X
X`09if (!SFworkProcAdded) `7B
X`09`09(void) XtAppAddWorkProc(SFapp, SFworkProc, NULL);
X`09`09SFworkProcAdded = 1;
X`09`7D
X
X`09SFupdatePath();
X`7D
X
Xstatic char *
XSFgetText()
X`7B
X`09return strcpy(XtMalloc((unsigned) (strlen(SFtextBuffer) + 1)),
X`09`09SFtextBuffer);
X`7D
X
Xstatic
XSFprepareToReturn()
X`7B
X`09SFstatus = SEL_FILE_NULL;
X`09XtRemoveGrab(selFile);
X`09XtUnmapWidget(selFile);
X`09XtRemoveTimeOut(SFdirModTimerId);
X`09if (SFchdir(SFstartDir)) `7B
X`09`09XtAppError(
X`09`09`09SFapp,
X`09`09`09"XsraSelFile: can't return to current directory"
X`09`09);
X`09`7D
X`7D
X
XFILE *
XXsraSelFile(toplevel, prompt, ok, cancel, failed,
X`09 init_path, mode, show_entry, name_return)
X`09Widget`09`09toplevel;
X`09char`09`09*prompt;
X`09char`09`09*ok;
X`09char`09`09*cancel;
X`09char`09`09*failed;
X`09char`09`09*init_path;
X`09char`09`09*mode;
X`09int`09`09(*show_entry)();
X`09char`09`09**name_return;
X`7B
X`09static int`09firstTime = 1;
X`09int`09`09i;
X`09Arg`09`09arglist`5B20`5D;
X`09XEvent`09`09event;
X`09FILE`09`09*fp;
X
X`09if (!prompt) `7B
X`09`09prompt = "Pathname:";
X`09`7D
X
X`09if (!ok) `7B
X`09`09ok = "OK";
X`09`7D
X
X`09if (!cancel) `7B
X`09`09cancel = "Cancel";
X`09`7D
X
X`09if (firstTime) `7B
X`09`09firstTime = 0;
X`09`09SFdisplay = XtDisplay(toplevel);
X`09`09SFcreateWidgets(toplevel, prompt, ok, cancel);
X`09`7D else `7B
X`09`09i = 0;
X
X`09`09XtSetArg(arglist`5Bi`5D, XtNlabel, prompt);`09`09`09i++;
X`09`09XtSetValues(selFilePrompt, arglist, i);
X
X`09`09i = 0;
X`09`09XtSetArg(arglist`5Bi`5D, XtNlabel, ok);`09`09`09i++;
X`09`09XtSetValues(selFileOK, arglist, i);
X
X`09`09i = 0;
X`09`09XtSetArg(arglist`5Bi`5D, XtNlabel, cancel);`09`09`09i++;
X`09`09XtSetValues(selFileCancel, arglist, i);
X`09`7D
X
X`09SFpositionWidget(selFile);
X`09XtMapWidget(selFile);
X
X#if defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG)
X`09if (!getcwd(SFstartDir, MAXPATHLEN)) `7B
X#else /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X`09if (!getwd(SFstartDir)) `7B
X#endif /* defined(SVR4) `7C`7C defined(SYSV) `7C`7C defined(USG) */
X
X`09`09XtAppError(SFapp, "XsraSelFile: can't get current directory");
X`09`7D
X`09(void) strcat(SFstartDir, "/");
X`09(void) strcpy(SFcurrentDir, SFstartDir);
X
X`09if (init_path) `7B
X`09`09if (init_path`5B0`5D == '/') `7B
X`09`09`09(void) strcpy(SFcurrentPath, init_path);
X`09`09`09if (strncmp(
X`09`09`09`09SFcurrentPath,
X`09`09`09`09SFstartDir,
X`09`09`09`09strlen(SFstartDir)
X`09`09`09)) `7B
X`09`09`09`09SFsetText(SFcurrentPath);
X`09`09`09`7D else `7B
X`09`09`09`09SFsetText(&(SFcurrentPath`5Bstrlen(SFstartDir)`5D));
X`09`09`09`7D
X`09`09`7D else `7B
X`09`09`09(void) strcat(strcpy(SFcurrentPath, SFstartDir),
X`09`09`09`09init_path);
X`09`09`09SFsetText(&(SFcurrentPath`5Bstrlen(SFstartDir)`5D));
X`09`09`7D
X`09`7D else `7B
X`09`09(void) strcpy(SFcurrentPath, SFstartDir);
X`09`7D
X
X`09SFfunc = show_entry;
X
X`09SFtextChanged();
X
X`09XtAddGrab(selFile, True, True);
X
X`09SFdirModTimerId = XtAppAddTimeOut(SFapp, (unsigned long) 1000,
X`09`09SFdirModTimer, (XtPointer) NULL);
X
X`09while (1) `7B
X`09`09XtAppNextEvent(SFapp, &event);
X`09`09XtDispatchEvent(&event);
X`09`09switch (SFstatus) `7B
X`09`09case SEL_FILE_TEXT:
X`09`09`09SFstatus = SEL_FILE_NULL;
X`09`09`09SFtextChanged();
X`09`09`09break;
X`09`09case SEL_FILE_OK:
X`09`09`09*name_return = SFgetText();
X`09`09`09if (fp = SFopenFile(*name_return, mode,
X`09`09`09`09`09 prompt, failed)) `7B
X`09`09`09`09SFprepareToReturn();
X`09`09`09`09return fp;
X`09`09`09`7D
X`09`09`09SFstatus = SEL_FILE_NULL;
X`09`09`09break;
X`09`09case SEL_FILE_CANCEL:
X`09`09`09SFprepareToReturn();
X`09`09`09return NULL;
X`09`09case SEL_FILE_NULL:
X`09`09`09break;
X`09`09`7D
X`09`7D
X`7D
$ CALL UNPACK SELFILE.C;1 1516496284
$ create 'f'
X/*
X * Copyright (c) 1987 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that: (1) source distributions retain this entire copyright
X * notice and comment, and (2) distributions including binaries display
X * the following acknowledgement: `60`60This product includes software
X * developed by the University of California, Berkeley and its contributors'
V'
X * in the documentation or other materials provided with the distribution
X * and in all advertising materials mentioning features or use of this
X * software. Neither the name of the University nor the names of its
X * contributors may be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid`5B`5D = "@(#)setenv.c`095.4 (Berkeley) 6/1/90";
X#endif /* LIBC_SCCS and not lint */
X
X#include <stdio.h>
X#include <sys/types.h>
Xextern char *malloc();
X
X#ifdef BSD4_2
X#define memcpy(a,b,c) bcopy(b,a,c)
X#endif
X
X/*
X * setenv --
X *`09Set the value of the environmental variable "name" to be
X *`09"value". If rewrite is set, replace any current value.
X */
Xsetenv(name, value, rewrite)
X`09register char *name, *value;
X`09int rewrite;
X`7B
X`09extern char **environ;
X`09static int alloced;`09`09`09/* if allocated space before */
X`09register char *C;
X`09int l_value, offset;
X`09char *_findenv();
X
X`09if (*value == '=')`09`09`09/* no `60=' in value */
X`09`09++value;
X`09l_value = strlen(value);
X`09if ((C = _findenv(name, &offset))) `7B`09/* find if already exists */
X`09`09if (!rewrite)
X`09`09`09return(0);
X`09`09if (strlen(C) >= l_value) `7B`09/* old larger; copy over */
X`09`09`09while (*C++ = *value++);
X`09`09`09return(0);
X`09`09`7D
X`09`7D
X`09else `7B`09`09`09`09`09/* create new slot */
X`09`09register int`09cnt;
X`09`09register char`09**P;
X
X`09`09for (P = environ, cnt = 0; *P; ++P, ++cnt);
X`09`09if (alloced) `7B`09`09`09/* just increase size */
X`09`09`09environ = (char **)realloc((char *)environ,
X`09`09`09 (size_t)(sizeof(char *) * (cnt + 2)));
X`09`09`09if (!environ)
X`09`09`09`09return(-1);
X`09`09`7D
X`09`09else `7B`09`09`09`09/* get new space */
X`09`09`09alloced = 1;`09`09/* copy old entries into it */
X`09`09`09P = (char **)malloc((size_t)(sizeof(char *) *
X`09`09`09 (cnt + 2)));
X`09`09`09if (!P)
X`09`09`09`09return(-1);
X`09`09`09memcpy(P, environ, cnt * sizeof(char *));
X`09`09`09environ = P;
X`09`09`7D
X`09`09environ`5Bcnt + 1`5D = NULL;
X`09`09offset = cnt;
X`09`7D
X`09for (C = name; *C && *C != '='; ++C);`09/* no `60=' in name */
X`09if (!(environ`5Boffset`5D =`09`09`09/* name + `60=' + value */
X`09 malloc((size_t)((int)(C - name) + l_value + 2))))
X`09`09return(-1);
X`09for (C = environ`5Boffset`5D; (*C = *name++) && *C != '='; ++C);
X`09for (*C++ = '='; *C++ = *value++;);
X`09return(0);
X`7D
X
X/*
X * unsetenv(name) --
X *`09Delete environmental variable "name".
X */
Xvoid
Xunsetenv(name)
X`09char`09*name;
X`7B
X`09extern char **environ;
X`09register char **P;
X`09int offset;
X`09char *_findenv();
X
X`09while (_findenv(name, &offset))`09`09/* if set multiple times */
X`09`09for (P = &environ`5Boffset`5D;; ++P)
X`09`09`09if (!(*P = *(P + 1)))
X`09`09`09`09break;
X`7D
$ CALL UNPACK SETENV.C;1 1416193976
$ create 'f'
X/*
X * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted, provided
X * that the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of Software Research Associates not be u
Vsed
X * in advertising or publicity pertaining to distribution of the software
X * without specific, written prior permission. Software Research Associates
X * makes no representations about the suitability of this software for any
X * purpose. It is provided "as is" without express or implied warranty.
X *
X * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
V,
X * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FRO
VM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENC
VE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author: Erik M. van der Poel
X * Software Research Associates, Inc., Tokyo, Japan
X * erik@sra.co.jp
X */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xos.h>
X#include <X11/Xaw/Text.h>
X#include <X11/Xaw/AsciiText.h>
X
X#define SEL_FILE_CANCEL`09`09-1
X#define SEL_FILE_OK`09`090
X#define SEL_FILE_NULL`09`091
X#define SEL_FILE_TEXT`09`092
X
X#define SF_DO_SCROLL`09`091
X#define SF_DO_NOT_SCROLL`090
X
Xtypedef struct `7B
X`09int`09statDone;
X`09char`09*real;
X`09char`09*shown;
X`7D SFEntry;
X
Xtypedef struct `7B
X`09char`09*dir;
X`09char`09*path;
X`09SFEntry`09*entries;
X`09int`09nEntries;
X`09int`09vOrigin;
X`09int`09nChars;
X`09int`09hOrigin;
X`09int`09changed;
X`09int`09beginSelection;
X`09int`09endSelection;
X`09time_t`09mtime;
X`7D SFDir;
X
Xextern int SFstatus;
X
Xextern char SFcurrentPath`5B`5D, SFstartDir`5B`5D, SFcurrentDir`5B`5D;
X
Xextern Widget
X`09`09selFile,
X`09`09selFileCancel,
X`09`09selFileField,
X`09`09selFileForm,
X`09`09selFileHScroll,
X`09`09selFileHScrolls`5B`5D,
X`09`09selFileLists`5B`5D,
X`09`09selFileOK,
X`09`09selFilePrompt,
X`09`09selFileVScrolls`5B`5D;
X
Xextern Display *SFdisplay;
X
Xextern int SFcharWidth, SFcharHeight, SFcharAscent;
X
Xextern SFDir *SFdirs;
X
Xextern int SFdirEnd, SFdirPtr;
X
Xextern Pixel SFfore, SFback;
X
Xextern Atom SFwmDeleteWindow;
X
Xextern XSegment SFsegs`5B`5D, SFcompletionSegs`5B`5D;
X
Xextern XawTextPosition SFtextPos;
X
Xextern void
X`09SFenterList(),
X`09SFleaveList(),
X`09SFmotionList(),
X`09SFbuttonPressList(),
X`09SFbuttonReleaseList();
X
Xextern void
X`09SFvSliderMovedCallback(),
X`09SFvFloatSliderMovedCallback(),
X`09SFhSliderMovedCallback(),
X`09SFpathSliderMovedCallback(),
X`09SFvAreaSelectedCallback(),
X`09SFhAreaSelectedCallback(),
X`09SFpathAreaSelectedCallback();
X
Xextern int SFupperX, SFlowerY, SFupperY;
X
Xextern int SFtextX, SFtextYoffset;
X
Xextern int SFentryWidth, SFentryHeight;
X
Xextern int SFlineToTextH, SFlineToTextV;
X
Xextern int SFbesideText, SFaboveAndBelowText;
X
Xextern int SFcharsPerEntry;
X
Xextern int SFlistSize;
X
Xextern int SFcurrentInvert`5B`5D;
X
Xextern int SFworkProcAdded;
X
Xextern Boolean SFworkProc();
X
Xextern XtAppContext SFapp;
X
Xextern int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
X
Xextern char SFtextBuffer`5B`5D;
X
Xextern int SFbuttonPressed;
X
Xextern int SFcompareEntries();
X
Xextern void SFdirModTimer();
X
Xextern char SFstatChar();
X
Xextern XtIntervalId SFdirModTimerId;
X
Xextern int (*SFfunc)();
$ CALL UNPACK SFINTERNAL.H;1 2133735521
$ create 'f'
X/*
X * Copyright (c) 1988 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution is only permitted until one year after the first shipment
X * of 4.4BSD by the Regents. Otherwise, redistribution and use in source an
Vd
X * binary forms are permitted provided that: (1) source distributions retain
X * this entire copyright notice and comment, and (2) distributions including
X * binaries display the following acknowledgement: This product includes
X * software developed by the University of California, Berkeley and its
X * contributors'' in the documentation or other materials provided with the
X * distribution and in all advertising materials mentioning features or use
X * of this software. Neither the name of the University nor the names of
X * its contributors may be used to endorse or promote products derived from
X * this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X *`09@(#)stdc.h`097.3 (Berkeley) 6/28/90
X */
X
X/*
X * This file is designed to ease the porting from standard C to ANSI C.
X * It will eventually go away.
X * Questions to K. Bostic.
X */
X
X#if __STDC__ `7C`7C c_plusplus
X#define`09CONCAT(x,y)`09x ## y
X#define`09PROTOTYPE(p)`09p
X#define`09STRING(x)`09#x
X#else
X#define`09const
X#define`09volatile
X#define`09signed
X#define`09CONCAT(x,y)`09x/**/y
X#define`09PROTOTYPE(p)`09()
X#define`09STRING(x)`09"x"
X#endif
$ CALL UNPACK STDC.H;1 561017436
$ create 'f'
X/*
X * Copyright (c) 1987 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that: (1) source distributions retain this entire copyright
X * notice and comment, and (2) distributions including binaries display
X * the following acknowledgement: `60`60This product includes software
X * developed by the University of California, Berkeley and its contributors'
V'
X * in the documentation or other materials provided with the distribution
X * and in all advertising materials mentioning features or use of this
X * software. Neither the name of the University nor the names of its
X * contributors may be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#include "stdc.h"
X#include <sys/types.h>
X
X#ifdef VMS
X#include <stddef.h>
X#endif
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic const char sccsid`5B`5D = "@(#)strcasecmp.c`095.9 (Berkeley) 6/1/90";
X#endif /* LIBC_SCCS and not lint */
X
X/*
X * This array is designed for mapping upper and lower case letter
X * together for a case independent comparison. The mappings are
X * based upon ascii character sequences.
X */
Xstatic const unsigned char charmap`5B`5D = `7B
X`09'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
X`09'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
X`09'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
X`09'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
X`09'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
X`09'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
X`09'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
X`09'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
X`09'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
X`09'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
X`09'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
X`09'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
X`09'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
X`09'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
X`09'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
X`09'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
X`09'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
X`09'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
X`09'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
X`09'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
X`09'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
X`09'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
X`09'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
X`09'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
X`09'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
X`09'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
X`09'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
X`09'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
X`09'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
X`09'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
X`09'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
X`09'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
X`7D;
X
Xint
Xstrcasecmp(s1, s2)
X`09const char *s1, *s2;
X`7B
X`09register const unsigned char *cm = charmap,
X`09`09`09*us1 = (const unsigned char *)s1,
X`09`09`09*us2 = (const unsigned char *)s2;
X
X`09while (cm`5B*us1`5D == cm`5B*us2++`5D)
X`09`09if (*us1++ == '\0')
X`09`09`09return (0);
X`09return (cm`5B*us1`5D - cm`5B*--us2`5D);
X`7D
X
Xint
Xstrncasecmp(s1, s2, n)
X`09const char *s1, *s2;
X`09register size_t n;
X`7B
X`09if (n != 0) `7B
X`09`09register const unsigned char *cm = charmap,
X`09`09`09`09*us1 = (const unsigned char *)s1,
X`09`09`09`09*us2 = (const unsigned char *)s2;
X
X`09`09do `7B
X`09`09`09if (cm`5B*us1`5D != cm`5B*us2++`5D)
X`09`09`09`09return (cm`5B*us1`5D - cm`5B*--us2`5D);
X`09`09`09if (*us1++ == '\0')
X`09`09`09`09break;
+-+-+-+-+-+-+-+- END OF PART 13 +-+-+-+-+-+-+-+-
Technical Details
Message-ID:
<8881769@MVB.SAIC.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!hamblin.math.byu.edu!arizona.edu!mvb.saic.com!vmsnet-sourcesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!hamblin.math.byu.edu!arizona.edu!mvb.saic.com!vmsnet-sources Newsgroups: vmsnet.sources Subject: Ghostview for VMS 13/14 Message-ID: <8881769@MVB.SAIC.COM> From: Terry Poot <tp@mccall.com> Date: Thu, 29 Oct 1992 18:50:11 GMT Approved: Mark.Berryman@Mvb.Saic.Com Lines: 1337