[alt.sources] STDWIN 0.9.5, Part 15/19

guido@cwi.nl (Guido van Rossum) (03/04/91)

Archive-name: stdwin/part15

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 15 (of 19)."
# Contents:  Appls/dpv/figtest Doc/man/dpv.man H/tools.h
#   Packs/textedit/text.h Ports/alfa/alfa.h Ports/alfa/keymap.c
#   Ports/mac/cursor.c Ports/mac/menu.c Ports/mac_mpw/set_open_hook.c
#   Ports/msdos/dir.c Ports/x11/amtimer.c Ports/x11/font.c
#   Ports/x11/x11.h
# Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:33 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Appls/dpv/figtest' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Appls/dpv/figtest'\"
else
echo shar: Extracting \"'Appls/dpv/figtest'\" \(3144 characters\)
sed "s/^X//" >'Appls/dpv/figtest' <<'END_OF_FILE'
X.lf 1 fstree.fig
X.\"	fstree.fig	1.4	88/03/25
X... -2 -2.375 1.75 0.125
X... 0.000i 2.500i 3.750i 0.000i
X.nr 00 \n(.u
X.nf
X.PS 2.500i 3.750i 
X.lf 28
X\h'2.375i'\v'0.125i'\v'.2m'\h'-\w'/'u/2u'/\h'-\w'/'u/2u'
X.sp -1
X\h'2.000i'\v'0.125i'\D'e0.750i 0.250i'
X.sp -1
X\h'3.375i'\v'0.875i'\v'.2m'\h'-\w'vmunix'u/2u'vmunix\h'-\w'vmunix'u/2u'
X.sp -1
X\h'3.000i'\v'1.000i'\D'l0.000i -0.250i'
X.sp -1
X\h'3.000i'\v'0.750i'\D'l0.750i 0.000i'
X.sp -1
X\h'3.750i'\v'0.750i'\D'l0.000i 0.250i'
X.sp -1
X\h'3.750i'\v'1.000i'\D'l-0.750i 0.000i'
X.sp -1
X\h'2.640i'\v'0.213i'\D'l0.734i 0.536i'
X.sp -1
X\h'3.279i'\v'0.711i'\D'l0.095i 0.038i'
X.sp -1
X\h'3.309i'\v'0.670i'\D'l0.066i 0.079i'
X.sp -1
X\h'1.375i'\v'0.875i'\v'.2m'\h'-\w'usr'u/2u'usr\h'-\w'usr'u/2u'
X.sp -1
X\h'1.000i'\v'0.875i'\D'e0.750i 0.250i'
X.sp -1
X\h'2.109i'\v'0.213i'\D'l-0.734i 0.536i'
X.sp -1
X\h'1.441i'\v'0.670i'\D'l-0.066i 0.079i'
X.sp -1
X\h'1.470i'\v'0.711i'\D'l-0.095i 0.038i'
X.sp -1
X\h'0.375i'\v'1.625i'\v'.2m'\h'-\w'foo'u/2u'foo\h'-\w'foo'u/2u'
X.sp -1
X\v'1.750i'\D'l0.000i -0.250i'
X.sp -1
X\v'1.500i'\D'l0.750i 0.000i'
X.sp -1
X\h'0.750i'\v'1.500i'\D'l0.000i 0.250i'
X.sp -1
X\h'0.750i'\v'1.750i'\D'l-0.750i 0.000i'
X.sp -1
X\h'1.109i'\v'0.963i'\D'l-0.734i 0.536i'
X.sp -1
X\h'0.441i'\v'1.420i'\D'l-0.066i 0.079i'
X.sp -1
X\h'0.470i'\v'1.461i'\D'l-0.095i 0.038i'
X.sp -1
X\h'1.375i'\v'1.625i'\v'.2m'\h'-\w'bin'u/2u'bin\h'-\w'bin'u/2u'
X.sp -1
X\h'1.000i'\v'1.625i'\D'e0.750i 0.250i'
X.sp -1
X\h'1.375i'\v'1.000i'\D'l0.000i 0.500i'
X.sp -1
X\h'1.350i'\v'1.400i'\D'l0.025i 0.100i'
X.sp -1
X\h'1.400i'\v'1.400i'\D'l-0.025i 0.100i'
X.sp -1
X\h'0.375i'\v'2.375i'\v'.2m'\h'-\w'ls'u/2u'ls\h'-\w'ls'u/2u'
X.sp -1
X\v'2.500i'\D'l0.000i -0.250i'
X.sp -1
X\v'2.250i'\D'l0.750i 0.000i'
X.sp -1
X\h'0.750i'\v'2.250i'\D'l0.000i 0.250i'
X.sp -1
X\h'0.750i'\v'2.500i'\D'l-0.750i 0.000i'
X.sp -1
X\h'1.109i'\v'1.713i'\D'l-0.734i 0.536i'
X.sp -1
X\h'0.441i'\v'2.170i'\D'l-0.066i 0.079i'
X.sp -1
X\h'0.470i'\v'2.211i'\D'l-0.095i 0.038i'
X.sp -1
X\h'1.375i'\v'2.375i'\v'.2m'\h'-\w'vi'u/2u'vi\h'-\w'vi'u/2u'
X.sp -1
X\h'1.000i'\v'2.500i'\D'l0.000i -0.250i'
X.sp -1
X\h'1.000i'\v'2.250i'\D'l0.750i 0.000i'
X.sp -1
X\h'1.750i'\v'2.250i'\D'l0.000i 0.250i'
X.sp -1
X\h'1.750i'\v'2.500i'\D'l-0.750i 0.000i'
X.sp -1
X\h'1.375i'\v'1.750i'\D'l0.000i 0.500i'
X.sp -1
X\h'1.350i'\v'2.150i'\D'l0.025i 0.100i'
X.sp -1
X\h'1.400i'\v'2.150i'\D'l-0.025i 0.100i'
X.sp -1
X\h'2.375i'\v'1.625i'\v'.2m'\h'-\w'staff'u/2u'staff\h'-\w'staff'u/2u'
X.sp -1
X\h'2.000i'\v'1.625i'\D'e0.750i 0.250i'
X.sp -1
X\h'1.640i'\v'0.963i'\D'l0.734i 0.536i'
X.sp -1
X\h'2.279i'\v'1.461i'\D'l0.095i 0.038i'
X.sp -1
X\h'2.309i'\v'1.420i'\D'l0.066i 0.079i'
X.sp -1
X\h'2.375i'\v'2.375i'\v'.2m'\h'-\w'mckusick'u/2u'mckusick\h'-\w'mckusick'u/2u'
X.sp -1
X\h'2.000i'\v'2.375i'\D'e0.750i 0.250i'
X.sp -1
X\h'2.375i'\v'1.750i'\D'l0.000i 0.500i'
X.sp -1
X\h'2.350i'\v'2.150i'\D'l0.025i 0.100i'
X.sp -1
X\h'2.400i'\v'2.150i'\D'l-0.025i 0.100i'
X.sp -1
X\h'3.375i'\v'2.375i'\v'.2m'\h'-\w'karels'u/2u'karels\h'-\w'karels'u/2u'
X.sp -1
X\h'3.000i'\v'2.375i'\D'e0.750i 0.250i'
X.sp -1
X\h'2.640i'\v'1.713i'\D'l0.734i 0.536i'
X.sp -1
X\h'3.279i'\v'2.211i'\D'l0.095i 0.038i'
X.sp -1
X\h'3.309i'\v'2.170i'\D'l0.066i 0.079i'
X.sp -1
X.sp 1+2.500i
X.PE
X.if \n(00 .fi
X.lf 28
END_OF_FILE
if test 3144 -ne `wc -c <'Appls/dpv/figtest'`; then
    echo shar: \"'Appls/dpv/figtest'\" unpacked with wrong size!
fi
# end of 'Appls/dpv/figtest'
fi
if test -f 'Doc/man/dpv.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Doc/man/dpv.man'\"
else
echo shar: Extracting \"'Doc/man/dpv.man'\" \(3458 characters\)
sed "s/^X//" >'Doc/man/dpv.man' <<'END_OF_FILE'
X.TH DPV 1
X.SH NAME
Xdpv \- ditroff output previewer
X.SH SYNOPSIS
X.B dpv
X[
X.B \-d
X]
X[
X.BI + page
X]
X.I file
X.SH DESCRIPTION
X.I Dpv
Xis a previewer for
X.IR ditroff (1)
Xoutput.
XThere must be exactly one file argument, specifying a file produced by
Xditroff.
XThe
X.B \-d
Xoption turns some debugging output on (if compiled in).
XThe
X.BI + page
Xoption selects the initial page to display (default 1).
X.SH MENUS
XThere are two menus.
XThe
X.B Control
Xmenu contains commands to move around in the file, and a Quit command to
Xleave the program.
XThe
X.B Print
Xmenu contains commands to spool the file to various printers queues.
XSome checks are made that the file is compatible with the printer.
X.SH KEYBOARD CONTROL
XThe following characters typed at the keyboard are interpreted as commands.
XA number
X.I N
Xfollowed by a Carriage Return moves to page
X.I N.
XCarriage Return without preceding number moves one page forward.
X`.' with preceding number is equivalent to Carriage Return;
Xwithout preceding number it redraws the current page.
X`N' moves to the next page, `P' moves to the previous page.
XA number
X.I N
Xfollowed by `N' or `P' moves
X.I N
Xpages forward or backward.
XUp arrow and backspace are equivalent to `P';
X`+', down arrow and space are equivalent to `N'.
X`-' is a toggle: it jumps to the previous page that was shown.
X`^' or `F' moves to the first page; `$' or `L' to the last.
X`G' without preceding number also moves to the last page;
Xwith a preceding number
X.I N
Xit moves to page
X.I N.
X`Q' quits from the program.
XLower case letters are equivalent to their upper case counterparts.
X.SH DIAGNOSTICS
XComplaints about missing files, unknown fonts and what have you are
Xwritten to stderr.
X.SH FILES
Xfunnytab, /usr/local/lib/funnytab, /userfs3/amoeba/lib/funnytab
X\- funny character translation table search path
X.SH SEE ALSO
Xditroff(1)
X.SH AUTHOR
XGuido van Rossum
X.SH BUGS
XMay crash on malformed input (not generated by ditroff).
X.br
XArcs and splines are replaced by straight lines (because I don't have
Xthe necessary mathematics at hand), so output from
X.IR pic (1)
Xor other graphics preprocessors may be unrecognizable.
X.br
XDoesn't know all funny characters.
XUnknown characters are silently suppressed.
X.br
XDoesn't know all fonts, or all sizes.
XUnknown fonts and sizes are replaced by known ones.
X.br
XThe current X11 version uses Adobe bitmap fonts which don't match very
Xwell with the width tables for the Harris.
X.br
XCharacter and line spacing are scaled, but it believes that it should
Xuse characters in the point sizes specified in the input.
XThis may cause the output to look a bit cramped.
X.br
XIt assumes page numbers always start at 1; it doesn't know about the
Xtrue page numbers (even though these are present in the ditroff output).
X.br
XThere should be an argument to specify an alternate funny character
Xtranslation table file.
X.br
XThe font translation table should be read from a file as well.
X.br
XIf it can't find the funny character translation table file, it should
Xfall back on a reasonable default.
X.br
XThe Print menu is very CWI-specific; it, too should be customizable
Xinstead of being wired in.
X.br
XErrors in the input are handled ungracefully.
X.br
XSTDWIN prints a warning to stderr for every font change if a font in the
Xtranslation table doesn't exist (e.g., if you are using the X11 Release
X3 version of dpv with a Release 2 server, or vice versa; or if you have
Xbotched your font directory or font path).  needless to say this can be
Xannoying.
END_OF_FILE
if test 3458 -ne `wc -c <'Doc/man/dpv.man'`; then
    echo shar: \"'Doc/man/dpv.man'\" unpacked with wrong size!
fi
# end of 'Doc/man/dpv.man'
fi
if test -f 'H/tools.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'H/tools.h'\"
else
echo shar: Extracting \"'H/tools.h'\" \(3277 characters\)
sed "s/^X//" >'H/tools.h' <<'END_OF_FILE'
X/* Useful includes, definitions etc. */
X
X#include "stdwconf.h"	/* Figure out on which system we are */
X#include "_ARGS.h"	/* Define _ARGS() macro appropriately */
X
X
X/****************************/
X/* Auto-configuration tests */
X/****************************/
X
X#ifdef __STDC__
X#define VOID_PTR
X#define HAVE_STDLIB
X#endif
X
X#ifdef THINK_C
X#ifdef THINK_C_3_0
X#define NO_STRING_H
X#else
X#define HAVE_STDLIB
X#endif
X#endif
X
X#ifdef THINK_C
X#define VOID_PTR
X#endif
X
X#ifdef SYSV
X#define VOID_PTR
X#endif
X
X
X/*********************/
X/* Universal pointer */
X/*********************/
X
X#ifdef VOID_PTR
X#define UNIVPTR void *
X#else
X#define UNIVPTR char *
X#endif
X
X
X/*************/
X/* C library */
X/*************/
X
X#include <stdio.h>
X#include <ctype.h>
X#include <errno.h>
X
X#ifdef NO_STRING_H
X/* Systems that don't have <string.h> should at least have <strings.h> */
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X
X#ifdef NO_STRCHR
X/* Systems that don't have str(r)chr should at least have (r)index */
X#define strchr index
X#define strrchr rindex
X#endif
X
X#ifdef NO_MEMCPY
X/* Systems that don't have memcpy/memcmp should at least have bcopy/bcmp */
X#define memcpy(dest, src, n)	bcopy(src, dest, n)
X#define memcmp(a, b, cnt)	bcmp(a, b, cnt)
X#endif
X
X#ifdef THINK_C
X#ifdef THINK_C_3_0
X#include <proto.h>
X#endif
X#endif
X
X
X#ifdef HAVE_STDLIB
X
X#include <stdlib.h>
X
X#else
X
XUNIVPTR malloc _ARGS((size_t));
XUNIVPTR calloc _ARGS((size_t, size_t));
XUNIVPTR realloc _ARGS((UNIVPTR, size_t));
X
X#ifndef NO_VOID_FREE
Xvoid free _ARGS((UNIVPTR));
X#endif
X
X#ifndef NO_VOID_EXIT
Xvoid exit _ARGS((int));
X#endif
X
Xchar *getenv _ARGS((char *));
X
X#endif /* !HAVE_STDLIB */
X
X/* According to the C Standard, errno may be a macro on systems with
X   multiple threads.  But on older systems, it may not be declared at
X   all in <errno.h>.  So we declare it here, except if it is a macro. */
X
X#ifndef errno
Xextern int errno;
X#endif
X
X
X/*************************************/
X/* Miscellaneous useful declarations */
X/*************************************/
X
X/* Interface to getopt(): */
Xextern int optind;
Xextern char *optarg;
Xint getopt _ARGS((int, char **, char *));
X
X/* Boolean data type: */
X#define bool int	/* For single variable, argument or return value */
X#define tbool char	/* Tiny bool, used in structs or arrays */
X#define FALSE 0
X#define TRUE 1
X
X/* Character shorthands: */
X#define EOS '\0'
X#define EOL '\n'
X
X/* Copy string to malloc'ed memory: */
Xchar *strdup _ARGS((const char *));
X
X/* Other useful macros: */
X
X#define CNTRL(x) ((x) & 0x1f) /* Usage: CNTRL('X') */
X
X#define ABS(x) ((x) < 0 ? -(x) : (x))
X
X#ifndef MIN
X#define MIN(a, b) ((a) < (b) ? (a) : (b))
X#endif
X#ifndef MAX
X#define MAX(a, b) ((a) > (b) ? (a) : (b))
X#endif
X
X#define CLIPMIN(var, min) if ((var) >= (min)) ; else (var)= (min)
X#define CLIPMAX(var, max) if ((var) <= (max)) ; else (var)= (max)
X
X/* Memory allocation macros: */
X
X#define ALLOC(type) ((type*) malloc(sizeof(type)))
X#define FREE(p) if ((p) != 0) { free((UNIVPTR)p); p = 0; } else /*empty*/
X
X/* Array (re)allocation macros.
X   RESIZE yields nonzero if the realloc succeeded. */
X
X#define NALLOC(type, n) ((type*) malloc((unsigned)(n) * sizeof(type)))
X#define RESIZE(var, type, n) \
X	(var= (type *) realloc((UNIVPTR)var, (n) * sizeof(type)))
X
X/* Dynamic array macros: */
X
X#include "lists.h"
END_OF_FILE
if test 3277 -ne `wc -c <'H/tools.h'`; then
    echo shar: \"'H/tools.h'\" unpacked with wrong size!
fi
# end of 'H/tools.h'
fi
if test -f 'Packs/textedit/text.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Packs/textedit/text.h'\"
else
echo shar: Extracting \"'Packs/textedit/text.h'\" \(4138 characters\)
sed "s/^X//" >'Packs/textedit/text.h' <<'END_OF_FILE'
X/* Text Edit, definitions */
X
X/* Include header files */
X#include "stdwin.h"	/* Window interface */
X#include "tools.h"	/* Lots of useful goodies */
X
X#ifndef LSC
X#define NDEBUG		/* Turn off all debugging code */
X#endif
X
X#define RESERVE 256	/* Increment for gap growth */
X#define STARTINCR 20	/* Increment for start array growth; must be >= 1 */
X
X/* Typedefs (for documentation only) */
Xtypedef int focpos;	/* Logical offset (not affected by gap) */
Xtypedef int bufpos;	/* Buffer offset (taking gap into account) */
Xtypedef int lineno;	/* Index into start array */
Xtypedef int coord;	/* Used to declare pairs of coordinates */
Xtypedef coord hcoord;	/* Hor. coordinate */
Xtypedef coord vcoord;	/* Ver. coordinate */
X
Xstruct _textedit {
X	/* Drawing environment */
X	WINDOW *win;
X	coord left, top, right, bottom;
X	hcoord width;	/* == right-left */
X	TEXTATTR attr;	/* Text attributes */
X	vcoord vspace;	/* Vertical spacing (line height) */
X	hcoord tabsize;	/* Spacing of horizontal tabs */
X	
X	/* Text and focus representation */
X	char *buf;	/* Text buffer */
X	bufpos buflen;	/* Size of buffer */
X	bufpos gap;	/* Start of gap */
X	int gaplen;	/* Gap length */
X	focpos foc;	/* Text selection focus start */
X	int foclen;	/* Focus length */
X	bufpos *start;	/* Array of screen line starts */
X	lineno nlines;	/* Number of lines */
X	lineno nstart;	/* Number of elements of start (must be > nlines) */
X	hcoord aim;	/* Where vertical arrows should (try to) go */
X	focpos anchor;	/* Anchor position of focus drag */
X	focpos anchor2;	/* Other end of anchor */
X	tbool focprev;	/* Set if foc between lines belongs to prev line */
X	tbool hilite;	/* Set if focus area shown inverted */
X	tbool mdown;	/* Set if mouse down */
X	tbool dclick;	/* Set if mouse down in double click */
X	tbool drawing;	/* FALSE if no window operations */
X	tbool active;	/* FALSE to inhibit highlighting and caret */
X	
X	/* To optimize single char inserts */
X	tbool opt_valid;	/* Set if following data is valid */
X	tbool opt_in_first_word;/* Focus is in first word of line */
X	lineno opt_i;		/* Line where focus is */
X	coord opt_h, opt_v;	/* Caret position in window */
X	hcoord opt_avail;	/* White pixels at end of line */
X	hcoord opt_end;		/* End of line or next tab stop */
X	
X	/* NB: aim, opt_h, opt_v are in window coordinates,
X	       i.e., tp->left or tp->top has already been added */
X};
X
X/* Constants */
X#define UNDEF		(-1)	/* Undefined value, e.g., for aim */
X
X/* NB: All macros below use a variable 'tp' pointing to the textedit struct */
X
X/* Shorthands */
X#define zfocend		(tp->foc+tp->foclen)
X#define zgapend		(tp->gap+tp->gaplen)
X
X/* Transformations between focpos and bufpos values */
X#define zaddgap(f)	((f) < tp->gap ? (f) : (f)+tp->gaplen)
X#define zsubgap(pos)	((pos) <= tp->gap ? (pos) : \
X			 (pos) <= zgapend ? tp->gap : (pos)-tp->gaplen)
X
X/* ++ and -- operators for bufpos variables */
X#define zincr(p)	(++*(p) == tp->gap ? (*(p) += tp->gaplen) : *(p))
X#define zdecr(p)	(*(p) == zgapend ? (*(p) = tp->gap - 1) : --*(p))
X
X/* +1 and -1 operators for same */
X#define znext(p)	((p) == tp->gap-1 ? zgapend : (p)+1)
X#define zprev(p)	((p) == zgapend ? (tp->gap-1) : (p)-1)
X
X/* Access characters at/before positions */
X#define zcharat(p)	(tp->buf[p])
X#define zcharbefore(p)	(tp->buf[zprev(p)])
X
X/* Tab stop calculation */
X#define znexttab(w) ((((w)+tp->tabsize) / tp->tabsize) * tp->tabsize)
X
X/* Functions that don't return int */
XTEXTEDIT *tesetup();
Xchar *zmalloc();
Xchar *zrealloc();
X
X/* Debugging help */
X
X#ifndef NDEBUG
X
X#ifndef __LINE__
X#define __LINE__ 0
X#endif
X
X/* General assertion (NB: type command-period to dprintf to halt) */
X#define zassert(n) ((n) || dprintf("line %d: zassert(n) failed", __LINE__))
X
X/* Check the validity of a buffer offset */
X#define zcheckpos(p) \
X	((p)>=0 && (p)<=tp->buflen && ((p)<tp->gap || (p)>=zgapend) || \
X		dprintf("line %d: zcheckpos(p=%d) buf[%d] gap=%d+%d", \
X			__LINE__, p, tp->buflen, tp->gap, tp->gaplen))
X
X/* Sanity checking routine for entire state */
X#define zcheck() techeck(tp, __LINE__)
X
X#else /* NDEBUG */
X
X#define zassert(n)	/*empty*/
X#define zcheckpos(pos)	/*empty*/
X#define zcheck()	/*empty*/
X
X#endif /* NDEBUG */
END_OF_FILE
if test 4138 -ne `wc -c <'Packs/textedit/text.h'`; then
    echo shar: \"'Packs/textedit/text.h'\" unpacked with wrong size!
fi
# end of 'Packs/textedit/text.h'
fi
if test -f 'Ports/alfa/alfa.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/alfa/alfa.h'\"
else
echo shar: Extracting \"'Ports/alfa/alfa.h'\" \(3643 characters\)
sed "s/^X//" >'Ports/alfa/alfa.h' <<'END_OF_FILE'
X/* TERMCAP STDWIN -- INTERNAL HEADER FILE */
X
X/* BEWARE: CONFUSED COORDINATE CONVENTIONS.
X   The VTRM package, used here for terminal output,
X   puts the y coordinate first.
X   The stdwin package itself puts the x coordinate first
X   (but instead of (x, y), it uses (h, v)).
X   Also, when VTRM specifies a range of lines, the second number
X   is the last line included.  In stdwin, the second number is
X   the first position NOT included. */
X
X#include "tools.h"
X#include "stdwin.h"
X#include "menu.h"
X#include "vtrm.h"
X
Xstruct _window {
X	short tag;		/* Window tag, usable as document id */
X	short open;		/* Set if this struct window is in use */
X	char *title;		/* Title string */
X	void (*drawproc)();	/* Draw procedure */
X	short top;		/* Top line on screen */
X	short bottom;		/* Bottom line on screen + 1 */
X	int offset;		/* Diff. between doc. and screen line no's */
X	int curh, curv;		/* Text cursor position (doc. coord.) */
X	TEXTATTR attr;		/* Text attributes */
X	struct menubar mbar;	/* Collection of local menus */
X	long timer;		/* Absolute timer value (see timer.c) */
X	short resized;		/* Nonzero when resize event pending */
X};
X
X/* Note on the meaning of the 'offset' field:
X   to convert from screen coordinates to document coordinates: add offset;
X   from document coordinates to screen coordinates: subtract offset. */
X
X/* Data structures describing windows. */
X
X#define MAXWINDOWS	20
X#define MAXLINES	120
X
Xextern WINDOW winlist[MAXWINDOWS];
Xextern char uptodate[MAXLINES];
Xextern WINDOW *wasfront, *front, *syswin;
Xextern int lines, columns;
Xextern TEXTATTR wattr;
X
X/* KEY MAPPING. */
X
X/* The primary key map is a 256-entry array indexed by the first
X   character received.  Secondary key maps are lists terminated with a
X   type field containing SENTINEL.
X   The maps use the same data structure so they can be processed
X   by the same routine. */
X
Xstruct keymap {
X	unsigned char key;	/* Character for which this entry holds */
X	unsigned char type;	/* Entry type */
X	unsigned char id;	/* Id and item of menu shortcut */
X	unsigned char item;	/* Also parameter for other types */
X};
X
X/* Entry types: */
X#define ORDINARY	0	/* Report char as itself */
X#define SECONDARY	1	/* Proceed to secondary keymap [id] */
X#define SHORTCUT	2	/* Menu shortcut */
X#define SENTINEL	127	/* End of secondary key map */
X
Xextern struct keymap _wprimap[256];
Xextern struct keymap **_wsecmap;
X
X#define SECMAPSIZE 128
X
X/* The system menu (menu id 0) has a few entries for window manipulation,
X   followed by entries corresponding to WE_COMMAND subcodes.
X   WC_CLOSE happens to be the first of those, and corresponds
X   with CLOSE_WIN. */
X
X/* Item numbers in system menu: */
X#define PREV_WIN	0
X#define NEXT_WIN	1
X#define CLOSE_WIN	2
X
X/* Offsets between WE_COMMAND subcodes and item numbers in system menu: */
X#define FIRST_CMD	(CLOSE_WIN - WC_CLOSE)
X#define LAST_CMD	99
X
X/* There are also some codes that have a shortcut and a special interpretation
X   but no entry in the system menu: */
X#define SUSPEND_PROC	100
X#define REDRAW_SCREEN	101
X#define MOUSE_DOWN	102
X#define MOUSE_UP	104
X#define LITERAL_NEXT	105
X
X#define MENU_CALL	127	/* Start interactive menu selection */
X
Xvoid wsyscommand();
Xbool wsysevent();
Xvoid wmenuselect();
Xvoid wdrawtitle();
Xvoid wnewshortcuts();
Xvoid wgoto();
Xvoid _wselnext();
Xvoid _wselprev();
Xvoid _wredraw();
Xvoid _wsuspend();
Xvoid getbindings();
Xvoid initsyswin();
Xvoid drawmenubar();
Xvoid drawlocalmenubar();
Xvoid _wreshuffle();
Xvoid _wnewtitle();
Xvoid wsysdraw();
Xvoid killmenubar();
Xvoid initmenubar();
Xvoid gettckeydefs();
Xvoid getttykeydefs();
Xvoid wsetmetakey();
Xvoid menubarchanged();
Xvoid menuselect();
Xvoid _wlitnext();
END_OF_FILE
if test 3643 -ne `wc -c <'Ports/alfa/alfa.h'`; then
    echo shar: \"'Ports/alfa/alfa.h'\" unpacked with wrong size!
fi
# end of 'Ports/alfa/alfa.h'
fi
if test -f 'Ports/alfa/keymap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/alfa/keymap.c'\"
else
echo shar: Extracting \"'Ports/alfa/keymap.c'\" \(3076 characters\)
sed "s/^X//" >'Ports/alfa/keymap.c' <<'END_OF_FILE'
X/* STDWIN -- KEY MAPPING TABLES. */
X
X#include "alfa.h"
X
X#define CTLX_MAP	1
X#define ESC_MAP		2
X#define PC_MAP		3
X
X/* The key map is set up to provide shortcuts for the system menu. */
X
Xstruct keymap _wprimap[256]= {
X#ifdef MSDOS
X	/* ^@ */ { 0, SECONDARY, PC_MAP, 0},	/* ^@ map */
X#else /* !MSDOS */
X	/* ^@ */ { 0, ORDINARY, 0, 0},
X#endif
X	/* ^A */ { 1, ORDINARY, 0, 0},
X	/* ^B */ { 2, SHORTCUT, 0, FIRST_CMD+WC_LEFT},
X	/* ^C */ { 3, SHORTCUT, 0, FIRST_CMD+WC_CANCEL},
X	/* ^D */ { 4, ORDINARY, 0, 0},
X	/* ^E */ { 5, ORDINARY, 0, 0},
X	/* ^F */ { 6, SHORTCUT, 0, FIRST_CMD+WC_RIGHT},
X	/* ^G */ { 7, SHORTCUT, 0, MOUSE_DOWN},
X	/* ^H */ { 8, SHORTCUT, 0, FIRST_CMD+WC_BACKSPACE},
X	/* ^I */ { 9, SHORTCUT, 0, FIRST_CMD+WC_TAB},
X	/* ^J */ {10, SHORTCUT, 0, FIRST_CMD+WC_RETURN},
X	/* ^K */ {11, ORDINARY, 0, 0},
X	/* ^L */ {12, SHORTCUT, 0, REDRAW_SCREEN},
X	/* ^M */ {13, SHORTCUT, 0, FIRST_CMD+WC_RETURN},
X	/* ^N */ {14, SHORTCUT, 0, FIRST_CMD+WC_DOWN},
X	/* ^O */ {15, ORDINARY, 0, 0},
X	/* ^P */ {16, SHORTCUT, 0, FIRST_CMD+WC_UP},
X	/* ^Q */ {17, ORDINARY, 0, 0},
X	/* ^R */ {18, SHORTCUT, 0, REDRAW_SCREEN},
X	/* ^S */ {19, ORDINARY, 0, 0},
X	/* ^T */ {20, ORDINARY, 0, 0},
X	/* ^U */ {21, ORDINARY, 0, 0},
X	/* ^V */ {22, SHORTCUT, 0, LITERAL_NEXT},
X	/* ^W */ {23, ORDINARY, 0, 0},
X	/* ^X */ {24, SECONDARY, CTLX_MAP, 0},	/* ^X map */
X	/* ^Y */ {25, ORDINARY, 0, 0},
X	/* ^Z */ {26, SHORTCUT, 0, SUSPEND_PROC},
X	/* ^[ */ {27, SECONDARY, ESC_MAP, 0},	/* ESC map */
X	/* ^\ */ {28, ORDINARY, 0, 0},
X	/* ^] */ {29, ORDINARY, 0, 0},
X	/* ^^ */ {30, ORDINARY, 0, 0},
X	/* ^_ */ {31, ORDINARY, 0, 0},
X	
X	/* Followed by 224 entries with type == ORDINARY. */
X	
X	/* NB: DEL (0177) should be mapped to BS_KEY. */
X};
X
Xstatic struct keymap dummy_map[]= {
X	{0, SENTINEL, 0, 0}
X};
X
Xstatic struct keymap ctlx_map[]= {
X	{'N', SHORTCUT, 0, NEXT_WIN},
X	{'P', SHORTCUT, 0, PREV_WIN},
X	{'D', SHORTCUT, 0, CLOSE_WIN},
X	{'\003', SHORTCUT, 0, CLOSE_WIN},	/* ^X-^C */
X	{0, SENTINEL, 0, 0}
X};
X
Xstatic struct keymap esc_map[]= {
X	{'\033', SHORTCUT, 0, MENU_CALL},	/* ESC-ESC */
X	{'\007', SHORTCUT, 0, MOUSE_UP},	/* ESC-^G */
X	{0, SENTINEL, 0, 0}
X};
X
X#ifdef MSDOS
Xstatic struct keymap pc_map[]= {
X	/* {0003, ORDINARY, 0, 0}, */ /* ^@ should map to true ^@ */
X	{0107, SHORTCUT, 0, FIRST_CMD+WC_HOME},
X	{0110, SHORTCUT, 0, FIRST_CMD+WC_UP},
X	{0113, SHORTCUT, 0, FIRST_CMD+WC_LEFT},
X	{0115, SHORTCUT, 0, FIRST_CMD+WC_RIGHT},
X	{0120, SHORTCUT, 0, FIRST_CMD+WC_DOWN},
X	{0111, SHORTCUT, 0, FIRST_CMD+WC_PAGE_UP},
X	{0117, SHORTCUT, 0, FIRST_CMD+WC_END},
X	{0121, SHORTCUT, 0, FIRST_CMD+WC_PAGE_DOWN},
X	{0123, SHORTCUT, 0, FIRST_CMD+WC_CLEAR},
X	{0163, SHORTCUT, 0, FIRST_CMD+WC_META_LEFT},
X	{0164, SHORTCUT, 0, FIRST_CMD+WC_META_RIGHT},
X	{0165, SHORTCUT, 0, FIRST_CMD+WC_META_END},
X	{0166, SHORTCUT, 0, FIRST_CMD+WC_META_PAGE_DOWN},
X	{0167, SHORTCUT, 0, FIRST_CMD+WC_META_HOME},
X	{0204, SHORTCUT, 0, FIRST_CMD+WC_META_PAGE_UP},
X	{0, SENTINEL, 0, 0}
X};
X#endif /* MSDOS */
X
Xstatic struct keymap *sec_map_list[SECMAPSIZE]= {
X	dummy_map,
X	ctlx_map,
X	esc_map,
X#ifdef MSDOS
X	pc_map,
X#endif
X};
X
Xstruct keymap **_wsecmap= sec_map_list;
END_OF_FILE
if test 3076 -ne `wc -c <'Ports/alfa/keymap.c'`; then
    echo shar: \"'Ports/alfa/keymap.c'\" unpacked with wrong size!
fi
# end of 'Ports/alfa/keymap.c'
fi
if test -f 'Ports/mac/cursor.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/mac/cursor.c'\"
else
echo shar: Extracting \"'Ports/mac/cursor.c'\" \(3231 characters\)
sed "s/^X//" >'Ports/mac/cursor.c' <<'END_OF_FILE'
X/* MAC STDWIN -- MOUSE CURSORS. */
X
X/* XXX Shouldn't named resources override the defaults? */
X
X#include "macwin.h"
X#ifdef MPW
X#include <ToolUtils.h>
X#endif
X#ifdef THINK_C
X#include <ToolboxUtil.h>
X#endif
X
Xextern CursPtr handcursorptr;
X
X/* Fetch a cursor by name.  This really returns a resource handle,
X   cast to the mythical type CURSOR *.
X   If no resource by that name exists, some standard cursors may
X   be returned. */
X
XCURSOR *
Xwfetchcursor(name)
X	char *name;
X{
X	CursHandle h = (CursHandle) GetNamedResource('CURS', name);
X	if (h == NULL) {
X		if (strcmp(name, "ibeam") == 0)
X			h = GetCursor(iBeamCursor);
X		else if (strcmp(name, "cross") == 0)
X			h = GetCursor(crossCursor);
X		else if (strcmp(name, "plus") == 0)
X			h = GetCursor(plusCursor);
X		else if (strcmp(name, "watch") == 0)
X			h = GetCursor(watchCursor);
X		else if (strcmp(name, "arrow") == 0) {
X			/* The arrow is not a resource but a quickdraw global.
X			   Fake a handle with a static variable. */
X			static CursPtr arrowptr;
X			arrowptr = &QD(arrow);
X			h = &arrowptr;
X		}
X		else if (strcmp(name, "hand") == 0) {
X			/* The hand is hardcoded below */
X			h = &handcursorptr;
X		}
X	}
X	return (CURSOR *)h;
X}
X
Xvoid
Xwsetwincursor(win, cursor)
X	WINDOW *win;
X	CURSOR *cursor;
X{
X	win->cursor = cursor;
X	if (win == active)
X		set_applcursor();
X}
X
X/* Set the mouse cursor shape to the standard arrow.
X   This shape is used when the program is ready for input without
X   having the active window. */
X
Xvoid
Xset_arrow()
X{
X/*XXX	SetCursor(&QD(arrow)); */
X	InitCursor();
X}
X
X/* Set the mouse cursor shape to the standard watch.
X   This shape is used when a long task is being performed.
X   In practice always between two calls to wgetevent()
X   except when the mouse is down.
X   Note: this call is ignored when the application has
X   specified a cursor for the window; in this case it
X   is up to the application to set an arrow when it goes
X   away for a long time. */
X
Xvoid
Xset_watch()
X{
X	if (active == NULL || active->cursor == NULL)
X		SetCursor(*GetCursor(watchCursor));
X}
X
X/* Set the cursor to the standard cursor for the active window.
X   If there is no active window, use an arrow.
X   If a cursor is specified for the active window, use that,
X   otherwise use a default.
X   The default is normally a crosshair but can be changed by
X   setting the global variable _w_cursor to a cursor ID. */
X
Xint _w_cursor= crossCursor;
X
Xvoid
Xset_applcursor()
X{
X	if (active == NULL)
X		set_arrow();
X	else if (active->cursor == NULL)
X		SetCursor(*GetCursor(_w_cursor));
X	else {
X		CursHandle h = (CursHandle) active->cursor;
X		if (*h == NULL)
X			LoadResource((Handle)h);
X		SetCursor(*h);
X	}
X}
X
X/* Set the mouse cursor shape to a little hand icon.
X   This shape is used when scroll-dragging the document. */
X
Xstatic Cursor handcursor= {
X	{	/* Data: */
X		0x0180, 0x1a70, 0x2648, 0x264a, 
X		0x124d, 0x1249, 0x6809, 0x9801, 
X		0x8802, 0x4002, 0x2002, 0x2004, 
X		0x1004, 0x0808, 0x0408, 0x0408,
X	},
X	{	/* Mask: */
X		0x0180, 0x1bf0, 0x3ff8, 0x3ffa, 
X		0x1fff, 0x1fff, 0x7fff, 0xffff, 
X		0xfffe, 0x7ffe, 0x3ffe, 0x3ffc, 
X		0x1ffc, 0x0ff8, 0x07f8, 0x07f8,
X	},
X	{8, 8}	/* Hotspot */
X};
X
Xstatic CursPtr handcursorptr = &handcursor; /* For wfetchcursor */
X
Xvoid
Xset_hand()
X{
X	SetCursor(&handcursor);
X}
END_OF_FILE
if test 3231 -ne `wc -c <'Ports/mac/cursor.c'`; then
    echo shar: \"'Ports/mac/cursor.c'\" unpacked with wrong size!
fi
# end of 'Ports/mac/cursor.c'
fi
if test -f 'Ports/mac/menu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/mac/menu.c'\"
else
echo shar: Extracting \"'Ports/mac/menu.c'\" \(4227 characters\)
sed "s/^X//" >'Ports/mac/menu.c' <<'END_OF_FILE'
X/* MAC STDWIN -- MENUS. */
X
X/* XXX Ought to find a way to allow the THINK C console menus
X   to work when the console is active */
X
X#include "macwin.h"
X#ifdef MPW
X#include <Fonts.h>
X#include <Menus.h>
X#include <ToolUtils.h>
X#endif
X#ifdef THINK_C
X#include <MenuMgr.h>
X#endif
X
X#define MENUID(mp) ((*((MenuHandle)(mp)))->menuID)
X
Xbool _wmenuhilite;		/* Set if HiliteMenu(0) needed */
X
Xstatic bool deflocal= FALSE;	/* Default menu state */
X
Xstatic int firstlocal;		/* First local menu in menu bar */
X
X/* Function prototypes */
X
XSTATIC void addtobar _ARGS((struct menubar *mbp, MENU *mp));
XSTATIC void delfrombar _ARGS((struct menubar *mbp, MENU *mp));
X
Xstatic void
Xaddtobar(mbp, mp)
X	struct menubar *mbp;
X	MENU *mp;
X{
X	int i;
X	
X	for (i= 0; i < mbp->nmenus; ++i) {
X		if (mp == mbp->menulist[i])
X			return; /* Already attached */
X	}
X	L_APPEND(mbp->nmenus, mbp->menulist, MENU *, mp);
X}
X
Xstatic void
Xdelfrombar(mbp, mp)
X	struct menubar *mbp;
X	MENU *mp;
X{
X	int i;
X	
X	for (i= 0; i < mbp->nmenus; ++i) {
X		if (mp == mbp->menulist[i]) {
X			L_REMOVE(mbp->nmenus, mbp->menulist, MENU *, i);
X			break;
X		}
X	}
X}
X
XMENU *
Xwmenucreate(id, title)
X	int id;
X	char *title;
X{
X	MENU *mp= (MENU *)NewMenu(id, PSTRING(title));
X	
X	if (!deflocal) {
X		InsertMenu(mp, firstlocal);
X		DrawMenuBar();
X	}
X	return mp;
X}
X
Xvoid
Xwmenudelete(mp)
X	MENU *mp;
X{
X	WindowPtr w;
X	
X	for (w= FrontWindow(); w != NULL;
X		w= (WindowPtr)((WindowPeek)w)->nextWindow) {
X		WINDOW *win= whichwin(w);
X		if (win != NULL)
X			delfrombar(&win->mbar, mp);
X	}
X	DeleteMenu(MENUID(mp));
X	DrawMenuBar();
X	DisposeMenu(mp);
X}
X
Xint
Xwmenuadditem(mp, text, shortcut)
X	MENU *mp;
X	char *text;
X	int shortcut;
X{
X	char buf[256];
X	int item;
X	
X	if (text == NULL || *text == EOS)
X		strcpy(buf, "(-");
X	else
X		strcpy(buf, "x");
X	if (shortcut >= 0) {
X		char *p= buf + strlen(buf);
X		*p++= '/';
X		*p++= shortcut;
X		*p= EOS;
X	}
X	AppendMenu(mp, PSTRING(buf));
X	item= CountMItems(mp);
X	if (text != NULL && *text != EOS)
X		SetItem(mp, item, PSTRING(text));
X	return item-1;
X}
X
Xvoid
Xwmenusetitem(mp, item, text)
X	MENU *mp;
X	int item;
X	char *text;
X{
X	++item;
X	if (text == NULL || *text == EOS)
X		DisableItem(mp, item);
X	else {
X		EnableItem(mp, item);
X		SetItem(mp, item, PSTRING(text));
X	}
X}
X
Xvoid
Xwmenuenable(mp, item, flag)
X	MENU *mp;
X	int item;
X	int flag;
X{
X	++item;
X	if (flag)
X		EnableItem(mp, item);
X	else
X		DisableItem(mp, item);
X}
Xvoid
Xwmenucheck(mp, item, flag)
X	MENU *mp;
X	int item;
X	int flag;
X{
X	++item;
X	CheckItem(mp, item, flag);
X}
X
Xvoid
Xwmenuattach(win, mp)
X	WINDOW *win;
X	MENU *mp;
X{
X	addtobar(&win->mbar, mp);
X	if (win == active) {
X		InsertMenu(mp, 0);
X		DrawMenuBar();
X	}
X}
X
Xvoid
Xwmenudetach(win, mp)
X	WINDOW *win;
X	MENU *mp;
X{
X	delfrombar(&win->mbar, mp);
X	if (win == active) {
X		DeleteMenu(MENUID(mp));
X		DrawMenuBar();
X	}
X}
X
Xvoid
Xwmenusetdeflocal(local)
X	bool local;
X{
X	deflocal= local;
X}
X
X/* Interface routines for the rest of the library. */
X
Xvoid
Xinitmbar(mb)
X	struct menubar *mb;
X{
X	L_INIT(mb->nmenus, mb->menulist);
X}
X
Xvoid
Xkillmbar(mb)
X	struct menubar *mb;
X{
X	L_DEALLOC(mb->nmenus, mb->menulist);
X}
X
Xvoid
Xaddlocalmenus(win)
X	WINDOW *win;
X{
X	int i;
X	
X	firstlocal= 0;
X	for (i= 0; i < win->mbar.nmenus; ++i) {
X		if (firstlocal == 0)
X			firstlocal= MENUID(win->mbar.menulist[i]);
X		InsertMenu(win->mbar.menulist[i], 0);
X	}
X	if (i > 0)
X		DrawMenuBar();
X}
X
Xvoid
Xrmlocalmenus(win)
X	WINDOW *win;
X{
X	int i;
X	
X	firstlocal= 0;
X	for (i= 0; i < win->mbar.nmenus; ++i)
X		DeleteMenu(MENUID(win->mbar.menulist[i]));
X	if (i > 0)
X		DrawMenuBar();
X}
X
Xvoid
X_wdo_menu(ep, menu_item)
X	EVENT *ep;
X	long menu_item;
X{
X	int id= HiWord(menu_item);
X	int item= LoWord(menu_item);
X	
X	if (id == 0)
X		return;
X	if (id == APPLE_MENU) {
X		if (item == 1)
X			do_about();
X		else {
X			char name[256];
X			GetItem(GetMHandle(id), item, name);
X			(void) OpenDeskAcc(name);
X		}
X		HiliteMenu(0);
X	}
X	else {
X		ep->type= WE_MENU;
X		ep->u.m.id= id;
X		ep->u.m.item= item-1;
X		_wmenuhilite= TRUE;
X	}
X}
X
X/* Call this routine exactly once to initialize the Apple menu. */
X
Xchar *about_item= "About STDWIN...";
X
Xvoid
Xsetup_menus()
X{
X	static char applename[2]= {appleMark, EOS};
X	MenuHandle m;
X	
X	m= (MenuHandle)wmenucreate(APPLE_MENU, applename);
X	AppendMenu(m, PSTRING(about_item));
X	AppendMenu(m, PSTRING("(-"));
X	AddResMenu(m, 'DRVR');
X}
END_OF_FILE
if test 4227 -ne `wc -c <'Ports/mac/menu.c'`; then
    echo shar: \"'Ports/mac/menu.c'\" unpacked with wrong size!
fi
# end of 'Ports/mac/menu.c'
fi
if test -f 'Ports/mac_mpw/set_open_hook.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/mac_mpw/set_open_hook.c'\"
else
echo shar: Extracting \"'Ports/mac_mpw/set_open_hook.c'\" \(3316 characters\)
sed "s/^X//" >'Ports/mac_mpw/set_open_hook.c' <<'END_OF_FILE'
X/* A procedure to install a hook in the MPW C 'open' library function.
X   This is useful because you may want to create files automatically
X   with type 'TEXT' without having to change all the 'open' or 'fopen'
X   calls in a large C program you are trying to port.  A standard hook
X   procedure for this purpose is also provided.   
X
X   Call:
X   	set_open_hook(proc);
X   This installs the hook proc, or restores the default situation if
X   proc is NULL.
X   The hook procedure will be called immediately *after* a successful
X   open call, with the following parameters:
X   	proc(filename, oflag, fd)
X		char *filename;		The file name
X		int oflag;		Mode passed to open
X		int fd;			Return value from open
X
X   Note: this only works when the program is linked as an application
X   (type APPL); for tools (type MPST) the device switch is located
X   in the Shell's memory.
X   
X   Careful! this information was gathered by disassembling parts
X   of the library.
X   There are no guarantees that the same code will work in future
X   versions of MPW.  It has been tested with version 1.0B2. */
X
X#include <fcntl.h>
X
X#include <Types.h>
X#include <Files.h>
X
X#include "intercept.h"
X
X#define ERRFLAG 0x40000000
X
Xstatic ProcPtr open_hook;
X
X/* The hook for faccess, installed in the device switch.
X   This will be called with cmd == F_OPEN from 'open',
X   but also from 'faccess', with other values for cmd.
X   The open_hook is only called if cmd == F_OPEN.
X   It is not necessary to check whether open_hook is NULL,
X   since we are only installed after open_hook is set non-NULL. */
X
Xstatic long
Xmy_faccess(file, cmd, arg)
X	char *file;
X	int cmd;
X	short *arg;
X{
X	long res= _fsFAccess(file, cmd, arg);
X	
X	if (cmd == F_OPEN && !(res&ERRFLAG)) {
X		(void) (*open_hook)(file, *arg, (int)res);
X	}
X	return res;
X}
X
X/* Standard open hook, to set type and creator of created files.
X   It will not change existing non-zero type or creator fields.
X   It returns an error code even though this is ignored by the
X   calling routine; you might want to call it yourself in a more
X   fancyful hook, and test the error code.
X   This routine can be customized by changing 'std_type' or
X   'std_creator'. */
X
XOSType std_type=	'TEXT';
XOSType std_creator=	'MPS ';
X
Xint
Xstd_open_hook(file, mode, fd)
X	char *file;
X	int mode;
X	int fd;
X{
X	FInfo info;
X	int err= noErr;
X	
X	switch (mode & 03) {
X	
X	case O_RDWR:
X	case O_WRONLY:
X		err= GetFInfo(file, 0, &info);
X		if (err != noErr)
X			return err;
X		if (info.fdType == 0) {
X			info.fdType= std_type;
X			++err; /* Use 'err' as a flag to call SetFInfo */
X		}
X		if (info.fdCreator == 0) {
X			info.fdCreator= std_creator;
X			++err;
X		}
X		if (err != noErr)
X			err= SetFInfo(file, 0, &info);
X	
X	}
X	return err;
X}
X
X/* The procedure to install the hook.
X   Note: this assumes nobody else is also installing hooks
X   for faccess, otherwise we would have to save and restore
X   the old function, instead of blindly assuming _fsFAccess. */
X
Xset_open_hook(hook)
X	ProcPtr hook;
X{
X	if (hook == NULL)
X		_StdDevs[DEV_FSYS].dev_faccess= _fsFAccess;
X	else {
X		open_hook= hook;
X		_StdDevs[DEV_FSYS].dev_faccess= my_faccess;
X	}
X}
X
X/* A trivial test program will be included if you #define MAIN: */
X
X#ifdef MAIN
X
X#include <stdio.h>
X
Xextern int std_open_hook();
X
Xmain()
X{
X	set_open_hook(std_open_hook);
X	fclose(fopen("ABC", "a"));
X}
X
X#endif
END_OF_FILE
if test 3316 -ne `wc -c <'Ports/mac_mpw/set_open_hook.c'`; then
    echo shar: \"'Ports/mac_mpw/set_open_hook.c'\" unpacked with wrong size!
fi
# end of 'Ports/mac_mpw/set_open_hook.c'
fi
if test -f 'Ports/msdos/dir.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/msdos/dir.c'\"
else
echo shar: Extracting \"'Ports/msdos/dir.c'\" \(3239 characters\)
sed "s/^X//" >'Ports/msdos/dir.c' <<'END_OF_FILE'
X/*
X * MS-DOS version of UNIX directory access package.
X * (opendir, readdir, closedir).
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <errno.h>
X#include <dos.h>
Xextern int errno;
X#define MAXPATH 64
X
X#include "dir.h"
Xstatic char *firstf();
Xstatic char *nextf();
X
Xtypedef int bool;
X#define TRUE 1
X#define FALSE 0
X#define EOS '\0'
X#define NULL 0
X
Xstatic char dirpath[MAXPATH+1]= "";
Xstatic bool busy= FALSE;
X
X/*
X * Open a directory.
X * This MS-DOS version allows only one directory to be open at a time.
X * The path must exist and be a directory.
X * Then it only saves the file name and returns a pointer to it.
X */
X
Xchar *
Xopendir(path)
X	char *path;
X{
X	struct stat buffer;
X
X	if (dirpath[0] != EOS) {
X		 errno= EMFILE;
X		 return NULL; /* Only one directory can be open at a time */
X	}
X	if (stat(path, &buffer) == -1)
X		return NULL; /* Directory doesn't exist */
X	if ((buffer.st_mode & S_IFMT) != S_IFDIR) {
X		errno= ENOENT;
X		return NULL; /* Not a directory */
X	}
X	strcpy(dirpath, path);
X	path= dirpath + strlen(dirpath);
X	if (path > dirpath && path[-1] != ':' && path[-1] != '/' &&
X			path[-1] != '\\')
X		*path++ = '\\';
X	strcpy(path, "*.*");
X	busy= FALSE; /* Tell readdir this is the first time */
X	return dirpath;
X}
X
X/*
X * Close a directory.
X * We must clear the first char of dirpath to signal opendir that
X * no directory is open.
X */
X
Xclosedir(dirp)
X	char *dirp;
X{
X	dirp[0]= EOS;
X}
X
X/*
X * Read the next directory entry.
X */
X
Xstruct direct *
Xreaddir(dp)
X	char *dp;
X{
X	static struct direct buffer;
X	char *p;
X
X	if (!busy)
X		p= firstf(dp);
X	else
X		p= nextf();
X	busy= (p != NULL);
X	if (!busy)
X		return NULL;
X	strcpy(buffer.d_name, p);
X	buffer.d_namlen= strlen(p);
X	return &buffer;
X}
X
X
X/*
X * Low-level implementation -- access to DOS system calls FIRST and NEXT.
X */
X
Xstatic char dta[64]; /* Device Transfer Area */
X
X/* File attributes */
X#define READONLY	0x01
X#define HIDDEN		0x02
X#define SYSTEM		0x04
X#define VOLUMEID	0x08
X#define DIRECTORY	0x10
X#define ARCHIVE		0x20
X
X#define MATCHATTR	(HIDDEN|SYSTEM|DIRECTORY)
X
Xstatic char *
Xfirstf(pat)
X    char *pat;
X{
X    int flags;
X    union REGS regs;
X    struct SREGS segregs;
X
X    setdta(dta);
X
X    segread(&segregs);
X    regs.h.ah = 0x4e;
X    regs.x.cx = MATCHATTR;
X#ifdef M_I86LM /* Large Model -- far pointers */
X    regs.x.dx = FP_OFF(pat);
X    segregs.ds = FP_SEG(pat);
X#else
X    regs.x.dx = (int) pat;
X#endif
X    flags= intdosx(&regs, &regs, &segregs);
X    if (regs.x.cflag)
X	return NULL;
X    fixfile();
X    return dta + 30;
X}
X
Xstatic char *
Xnextf()
X{
X    int flags;
X    union REGS regs;
X
X    setdta(dta);
X
X    regs.h.ah = 0x4f;
X    flags= intdos(&regs, &regs);
X    if (regs.x.cflag)
X	return NULL;
X    fixfile();
X    return dta + 30;
X}
X
X/*
X * Convert the file name in the Device Transfer Area to lower case.
X */
X
Xstatic
Xfixfile()
X{
X	char *cp;
X
X	for (cp= dta+30; *cp != EOS; ++cp)
X		*cp= tolower(*cp);
X}
X
X/*
X * Tell MS-DOS where the Device Transfer Area is.
X */
X
Xstatic
Xsetdta(dta)
X    char *dta;
X{
X    union REGS regs;
X    struct SREGS segregs;
X
X    segread(&segregs);
X    regs.h.ah = 0x1a;
X#ifdef M_I86LM /* Large Model -- far pointers */
X    regs.x.dx = FP_OFF(dta);
X    segregs.ds = FP_SEG(dta);
X#else
X    regs.x.dx = (int) dta;
X#endif
X    intdosx(&regs, &regs, &segregs);
X}
END_OF_FILE
if test 3239 -ne `wc -c <'Ports/msdos/dir.c'`; then
    echo shar: \"'Ports/msdos/dir.c'\" unpacked with wrong size!
fi
# end of 'Ports/msdos/dir.c'
fi
if test -f 'Ports/x11/amtimer.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/x11/amtimer.c'\"
else
echo shar: Extracting \"'Ports/x11/amtimer.c'\" \(3675 characters\)
sed "s/^X//" >'Ports/x11/amtimer.c' <<'END_OF_FILE'
X/* Amoeba-specific timer code. */
X
X#include "x11.h"
X
X#include <amoeba.h>
X#include <semaphore.h>
X
Xinterval sys_milli();
X
X/* Although win->timer and the second parameter of wsettimer() are in
X   deciseconds, *all* other values are in milliseconds. */
X
Xstatic interval nexttimer;
X
X/* Compute a new value for nexttimer.
X   This is the system time (in msec.) when the first event should go
X   off, or 0 if there are no scheduled timer events.
X   Return the relevant window as a convenience. */
X
Xstatic WINDOW *
Xsetnexttimer()
X{
X	WINDOW *win = _wnexttimer();
X	
X	if (win == NULL)
X		nexttimer = 0;
X	else
X		nexttimer = win->timer * 100;
X	_wdebug(4, "setnexttimer: nexttimer at %d for %x", nexttimer, win);
X	return win;
X}
X
X/* Set the timer for a given window at now + deciseconds;
X   or discard the timer if deciseconds is zero. */
X
Xvoid
Xwsettimer(win, deciseconds)
X	WINDOW *win;
X	int deciseconds;
X{
X	_wdebug(3, "wsettimer: deciseconds=%d", deciseconds);
X	win->timer = 0;
X	if (deciseconds > 0)
X		win->timer = deciseconds + sys_milli() / 100;
X	_wdebug(3, "wsettimer(%d): timer set to %d", deciseconds, win->timer);
X	(void) setnexttimer();
X}
X
X/* Return an interval until the next timer, or -1 if no timers.
X   This is suitable to pass directly to mu_trylock() etc. */
X
Xinterval
Xnextdelay()
X{
X	interval now;
X	
X	if (nexttimer == 0)
X		return -1; /* No timer events */
X	now = sys_milli();
X	if (nexttimer <= now)
X		return 0; /* Immediate timer event */
X	return nexttimer - now; /* Milliseconds until timer event */
X}
X
X/* Check if a timer has gone off, and if so, generate an appropriate event.
X   This can be called at any time, but for efficiency reasons it should
X   only be called when an alarm has actually gone off.
X   If an alarm has gone off, it will always be found by this function. */
X
Xstatic bool
Xdotimer(ep)
X	EVENT *ep;
X{
X	WINDOW *win;
X	interval next;
X	
X	win = setnexttimer();
X	if (win == NULL) {
X		_wdebug(1, "dotimer: no event found (spurious call)");
X		return FALSE;
X	}
X	next = nextdelay();
X	if (next < 0) {
X		/* Shouldn't happen -- setnexttimer should have been NULL */
X		_wdebug(0, "dotimer: nextdelay() < 0 ???");
X		return FALSE;
X	}
X	if (next == 0) {
X		_wdebug(3, "dotimer: reporting timer event");
X		ep->type = WE_TIMER;
X		ep->window = win;
X		win->timer = 0;
X		(void) setnexttimer();
X		return TRUE;
X	}
X	else {
X		_wdebug(1, "dotimer: it is not yet time");
X		return FALSE;
X	}
X}
X
X/* Check for timer events, return TRUE if one found.
X   If a timer event is due now, return it immediately.
X   Otherwise, if mayblock is FALSE, return FALSE immediately.
X   Otherwise, block until either an X event is available or the next
X   timer event happens (in which case it is returned).
X*/
X
Xbool
X_w_checktimer(ep, mayblock)
X	EVENT *ep;
X	bool mayblock;
X{
X	for (;;) {
X		interval delay;
X		int status;
X		
X		delay = nextdelay();
X		if (delay == 0) {
X			if (dotimer(ep))
X				return TRUE;
X		}
X		if (!mayblock)
X			return FALSE;
X		/* Block until next X event or next timer event */
X		status = XamBlock(_wd, delay);
X		_wdebug(4, "_w_checktimer: status %d", status);
X		if (status > 0) {
X			_wdebug(3, "_w_checktimer: external event, status %d",
X								status);
X			ep->type = WE_EXTERN;
X			ep->window = NULL;
X			ep->u.command = status;
X			return TRUE;
X		}
X		if (status == 0) {
X			_wdebug(3, "_w_checktimer: X event");
X			return FALSE;
X		}
X		_wdebug(3, "_w_checktimer: timer went off");
X		/* Negative return means timer went off
X		   (or interrupted system call) */
X	}
X}
X
Xsemaphore *_wsema; /* Global, used by winit() */
X
X/* Interface to specify the semaphore used by XamBlock().
X   *** This must be called before calling winit[new]() !!! ***
X   */
X
Xvoid
Xwsetsema(ps)
X	semaphore *ps;
X{
X	_wsema = ps;
X}
END_OF_FILE
if test 3675 -ne `wc -c <'Ports/x11/amtimer.c'`; then
    echo shar: \"'Ports/x11/amtimer.c'\" unpacked with wrong size!
fi
# end of 'Ports/x11/amtimer.c'
fi
if test -f 'Ports/x11/font.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/x11/font.c'\"
else
echo shar: Extracting \"'Ports/x11/font.c'\" \(3646 characters\)
sed "s/^X//" >'Ports/x11/font.c' <<'END_OF_FILE'
X/* X11 STDWIN -- font manipulation */
X
X#include "x11.h"
X
XTEXTATTR wattr;		/* Global text attributes */
X
X/* Setting text drawing parameters. */
X
Xvoid
Xwsetplain()
X{
X	wattr.style= PLAIN;
X}
X
Xvoid
Xwsethilite()
X{
X	wattr.style |= HILITE;
X}
X
Xvoid
Xwsetinverse()
X{
X	wattr.style |= INVERSE;
X}
X
Xvoid
Xwsetitalic()
X{
X	wattr.style |= ITALIC;
X}
X
Xvoid
Xwsetbold()
X{
X	wattr.style |= BOLD;
X}
X
Xvoid
Xwsetbolditalic()
X{
X	wattr.style |= BOLD|ITALIC;
X}
X
Xvoid
Xwsetunderline()
X{
X	wattr.style |= UNDERLINE;
X}
X
Xvoid
Xwsetfont(fontname)
X	char *fontname;
X{
X	wattr.font= fontnum(fontname);
X	_wfontswitch();
X}
X
Xvoid
Xwsetsize(pointsize)
X	int pointsize;
X{
X	/* Ignored for now; must be present for compatibility */
X}
X
Xvoid
Xwgettextattr(attr)
X	TEXTATTR *attr;
X{
X	*attr= wattr;
X}
X
Xvoid
Xwsettextattr(attr)
X	TEXTATTR *attr;
X{
X	wattr= *attr;
X	_wfontswitch();
X}
X
X/* Font administration */
X
Xstruct font {
X	char *name;		/* Font name, (lower case), NULL if unknown */
X	XFontStruct *info;	/* Text measuring info */
X};
X
Xstatic int nfonts;
Xstatic struct font *fontlist;
X
X/* Initialize the font stuff */
X
X_winitfonts()
X{
X	struct font stdfont, menufont;
X	
X	/* Get the user-specified or server default font */
X	
X	stdfont.name= _wgetdefault("font", "Font");
X	if (stdfont.name != NULL) {
X		stdfont.info= XLoadQueryFont(_wd, stdfont.name);
X		if (stdfont.info != NULL) {
X			stdfont.name= strdup(stdfont.name);
X		}
X		else {
X		    _wwarning(
X		      "_winitfonts: can't load font %s; using server default",
X		      stdfont.name);
X		    stdfont.name= NULL;
X		}
X	}
X	if (stdfont.name == NULL) {
X		stdfont.info= XQueryFont(_wd, DefaultGCOfScreen(_ws)->gid);
X		if (stdfont.info == NULL)
X			_wfatal("_winitfonts: no server default font");
X		stdfont.info->fid= 0;
X	}
X	L_APPEND(nfonts, fontlist, struct font, stdfont);
X	_wmf= _wf= stdfont.info;
X	
X	/* Get the user-specified default menu font.
X	   If no user-specified default, use the the standard font. */
X	
X	menufont.name= _wgetdefault("menuFont", "Font");
X	if (menufont.name != NULL) {
X		menufont.info= XLoadQueryFont(_wd, menufont.name);
X		if (menufont.info != NULL) {
X			menufont.name= strdup(menufont.name);
X			L_APPEND(nfonts, fontlist, struct font, menufont);
X			_wmf= menufont.info;
X		}
X		else {
X		    _wwarning(
X		      "_winitfonts: can't load font %s; using server default",
X		      menufont.name);
X		}
X	}
X}
X
X/* Start using the font from 'wattr' */
X
X_wfontswitch()
X{
X	if (wattr.font < 0 || wattr.font >= nfonts)
X		_werror("_wfontswitch: wattr.font out of range");
X	else {
X		_wf= fontlist[wattr.font].info;
X		_wgcfontswitch();
X	}
X}
X
X/* Return the font number for a given font name.
X   If not already in the font list, add it.
X   Return 0 (the number of the system font) if the font doesn't exist. */
X
Xstatic int
Xfontnum(name)
X	char *name;
X{
X	struct font newfont;
X	char lcname[256];
X	int i;
X	
X	if (name == NULL || name[0] == EOS)
X		return 0; /* Use standard font */
X	
X	makelower(lcname, name);
X	for (i= 0; i < nfonts; ++i) {
X		if (fontlist[i].name != NULL &&
X			strcmp(fontlist[i].name, lcname) == 0)
X			return i;
X	}
X	newfont.info= XLoadQueryFont(_wd, lcname);
X	if (newfont.info == NULL) {
X		static nwarn; /* Limit the number of warnings */
X		if (nwarn++ < 10)
X			_wwarning("fontnum: font %s not found; using default",
X				lcname);
X		return 0; /* Not found; use system font */
X	}
X	_wdebug(1, "fontnum: new font %s", lcname);
X	newfont.name= strdup(lcname);
X	L_APPEND(nfonts, fontlist, struct font, newfont);
X	return i;
X}
X
X/* Copy a string like strcpy, converting to lower case in the process */
X
Xstatic
Xmakelower(dest, src)
X	char *dest, *src;
X{
X	char c;
X	while ((c= *src++) != EOS) {
X		if (isupper(c))
X			c= tolower(c);
X		*dest++ = c;
X	}
X	*dest= EOS;
X}
END_OF_FILE
if test 3646 -ne `wc -c <'Ports/x11/font.c'`; then
    echo shar: \"'Ports/x11/font.c'\" unpacked with wrong size!
fi
# end of 'Ports/x11/font.c'
fi
if test -f 'Ports/x11/x11.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Ports/x11/x11.h'\"
else
echo shar: Extracting \"'Ports/x11/x11.h'\" \(4161 characters\)
sed "s/^X//" >'Ports/x11/x11.h' <<'END_OF_FILE'
X/* X11 STDWIN -- private definitions */
X
X/* Includes */
X#include "tools.h"
X#include "stdwin.h"
X#include "style.h"		/* For wattr */
X
X/* Includes from X11 */
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/Xresource.h>
X#include <X11/Xatom.h>
X#include <X11/cursorfont.h>
X
X/* Additional system includes */
X#include <sys/time.h>
X
X#define IBORDER		1	/* Border width of (most) internal windows */
X
X/* Menu item */
Xstruct item {
X	char *text;
X	char *sctext;
X	short shortcut;
X	tbool enabled;
X	tbool checked;
X};
X
X/* Menu definition */
Xstruct _menu {
X	int id;
X	char *title;
X	int nitems;
X	struct item *itemlist;
X}; /* == MENU from <stdwin.h> */
X
X/* Window or subwindow essential data */
Xstruct windata {
X	Window wid;		/* X Window id */
X				/* The parent is implicit in the use */
X	int x, y;		/* Origin w/ respect to parent */
X	int width, height;	/* Width and height */
X	short border;		/* Border width */
X	tbool dirty;		/* Set if update pending */
X				/* Some windows also have an update area */
X};
X
X#define NSUBS 7			/* Number of subwindows */
X
X/* Window struct */
Xstruct _window {
X	short tag;		/* Must be first member and must be short! */
X	void (*drawproc)();	/* Draw procedure */
X	struct {
X		int width, height;
X	} doc;			/* Document dimension */
X	int careth, caretv;	/* Caret position; (-1, -1) if no caret */
X	bool caretshown;	/* Is the caret currently on display? */
X	long timer;		/* Deciseconds till next alarm */
X	TEXTATTR attr;		/* Text attributes */
X	
X	struct windata subw[NSUBS];	/* Subwindows */
X	
X	unsigned long fgo, bgo; /* pixel values for all but WA */
X	unsigned long fga, bga;	/* pixel values for WA */
X	
X	GC gc;			/* Graphics Context for all but WA */
X	GC gca;			/* Graphics Context for WA */
X	
X	Region inval;		/* Invalid area in WA window */
X
X	int nmenus;		/* Number of menus */
X	MENU **menulist;	/* List of attached menus (incl. global) */
X	int curmenu;
X	int curitem;
X	
X	tbool resized;		/* True if WE_SIZE event pending */
X}; /* == WINDOW from <stdwin.h> */
X
X/* Shorthands for subwindow array access.
X   Order is important! --for wopen() */
X#define WO	0
X#define MBAR	1
X#define VBAR	2
X#define HBAR	3
X#define WI	4
X#define WA	5
X#define MWIN	6
X
X#define wo	subw[WO]	/* Outer window (direct child of root)  */
X#define mbar	subw[MBAR]	/* Menu bar (child of wo) */
X#define vbar	subw[VBAR]	/* Scroll bars (children of wo) */
X#define hbar	subw[HBAR]	/* " */
X#define wi	subw[WI]	/* Inner window (child of wo) */
X#define wa	subw[WA]	/* Application window (child of wi) */
X#define mwin	subw[MWIN]	/* Currently visible menu */
X
X/* Button state record */
Xstruct button_state {
X	bool down;		/* We think a button is down */
X	int button;		/* Which button */
X	int mask;		/* Buttons down (1|2|4) */
X	int clicks;		/* Click status */
X	long time;		/* Time stamp, milliseconds */
X	WINDOW *win;		/* The WINDOW where it applies */
X	Window w;		/* SubWindow id */
X	int isub;		/* Subwindow index */
X	int x, y;		/* Current position */
X	int xdown, ydown;	/* Position of initial press */
X};
X
X/* Private globals */
Xextern Display *_wd;		/* general.c */
Xextern Screen *_ws;		/* general.c */
Xextern XFontStruct *_wf;	/* general.c */
Xextern XFontStruct *_wmf;	/* general.c */
Xextern int _wpipe[2];		/* general.c */
Xextern char *_wprogname;	/* general.c */
Xextern int _wdebuglevel;	/* errors.c */
Xextern int _wtracelevel;	/* errors.c */
X
X/* Interned atoms */
Xextern Atom _wm_protocols;
Xextern Atom _wm_delete_window;
Xextern Atom _wm_take_focus;
X
X/* Externals used to communicate hints to wopen() */
Xextern char *_whostname;
Xextern char *_wm_command;
Xextern int _wm_command_len;
X
X/* Functions not returning int */
XWINDOW *_wsetup();		/* window.c */
XWINDOW *_whichwin();		/* window.c */
XWINDOW *_wnexttimer();		/* window.c */
XGC _wgcreate();			/* window.c */
Xunsigned long _wgetpixel();	/* window.c */
XWINDOW *_w_get_last_active();	/* event.c */
XWINDOW *_w_somewin();		/* window.c */
XPixmap _w_gray();		/* window.c */
Xchar *_wgetdefault();		/* general.c */
Xvoid _w_setgrayborder();	/* window.c */
Xvoid _wsetmasks();		/* window.c */
X
X/* Function _wcreate has an extra parameter now */
X#define _wcreate(wp, parent, cursor, map, fg, bg) \
X	_wcreate1(wp, parent, cursor, map, fg, bg, 0)
END_OF_FILE
if test 4161 -ne `wc -c <'Ports/x11/x11.h'`; then
    echo shar: \"'Ports/x11/x11.h'\" unpacked with wrong size!
fi
# end of 'Ports/x11/x11.h'
fi
echo shar: End of archive 15 \(of 19\).
cp /dev/null ark15isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 19 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0