[comp.sources.x] v07i016: AWL -- layout language for widget hierarchies, Part02/17

vixie@wrl.dec.com (Paul Vixie) (05/03/90)

Submitted-by: vixie@wrl.dec.com (Paul Vixie)
Posting-number: Volume 7, Issue 16
Archive-name: awl/part02

#! /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 2 (of 17)."
# Contents:  Awl.h TODO awl.1 awl_driver.c examples/hackpict.awl
#   examples/porsche.awl examples/set2.awl layout.c ltypes.h
#   mathrtns.c resw.gperf
# Wrapped by vixie@jove.pa.dec.com on Mon Apr 30 01:25:20 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Awl.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Awl.h'\"
else
echo shar: Extracting \"'Awl.h'\" \(3700 characters\)
sed "s/^X//" >'Awl.h' <<'END_OF_FILE'
X#ifndef _Awl_h
X#define _Awl_h
X
X/* $Header: /usr/src/local/awl/RCS/Awl.h,v 2.1 90/04/19 20:04:03 jkh Exp $ */
X
X/*
X *
X *                     Copyright 1989
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X * This file is part of AWL.
X *
X * AWL is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X * AWL is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with AWL; see the file COPYING.  If not, write to
X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *
X */
X
X/*
X * Resources:
X *
X * Name			Class		RepType		Default Value
X * ----			-----		-------		-------------
X * cppArg		CppArg		String		NULL
X * cppCommand		CppCommand	String		NULL
X * debug             	Debug 	  	Boolean		False
X * externList		ExternList	AwlExtList	NULL
X * file			File		String		NULL
X * line			Line		Boolean		False
X * mainArgv		MainArgv	String *	NULL
X * noWarn		NoWarn		Boolean		False
X * show			Show		Boolean		False
X * start		Start		String		"main"
X * trace		Trace		Boolean		False
X * version		Version		Boolean		False
X *
X */
X
X/*
X * This is the public declarations file for the awl widget.
X * Documentation is in awl.texinfo.
X *
X * $Log:	Awl.h,v $
X * Revision 2.1  90/04/19  20:04:03  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:42:06  jkh
X * pre-beta check-in
X *
X */
X
X
X/* resource types */
X#define XgNcppArg		"cppArg"
X#define XgNcppCommand		"cppCommand"
X#define XgNdebug		"debug"
X#define XgNexternList		"externList"
X#define XgNfile			"file"
X#define XgNline			"line"
X#define XgNmainArgv		"mainArgv"
X#define XgNnoWarn		"noWarn"
X#define XgNshow			"show"
X#define XgNstart		"start"
X#define XgNtrace		"trace"
X#define XgNversion		"version"
X
X/* class types */
X#define XgCCppArg		"CppArg"
X#define XgCCppCommand		"CppCommand"
X#define XgCDebug		"Debug"
X#define XgCExternList		"ExternList"
X#define XgCFile			"File"
X#define XgCLine			"Line"
X#define XgCMainArgv		"MainArgv"
X#define XgCNoWarn		"NoWarn"
X#define XgCShow			"Show"
X#define XgCStart		"Start"
X#define XgCTrace		"Trace"
X#define XgCVersion		"Version"
X
X/*
X * How to invoke cpp on your system with line control information. If your
X * cpp doesn't generate such information, error messages will be less
X * meaningful.
X */
X#define XgDefaultCppCommand	"/lib/cpp"
X
X/* declare specific AwlWidget class and instance datatypes */
typedef struct _AwlClassRec*		AwlWidgetClass;
typedef struct _AwlRec*			AwlWidget;
X
X/* Types for the type field of AwlExtern */
X#define _TYPE_START	1
X#define TYPE_CHAR	(_TYPE_START + 1)
X#define TYPE_INT	(_TYPE_START + 2)
X#define TYPE_FLOAT	(_TYPE_START + 3)
X#define TYPE_STRING	(_TYPE_START + 4)
X#define TYPE_LIST	(_TYPE_START + 5)
X#define TYPE_ANY	(_TYPE_START + 6)
X#define TYPE_FUNCTION	(_TYPE_START + 7)
X#define TYPE_C_FUNCTION	(_TYPE_START + 8)
X#define TYPE_A_FUNCTION	(_TYPE_START + 9)
X#define TYPE_WCLASS	(_TYPE_START + 10)
X
typedef struct _awlextern {
X     String name;
X     int type;
X     caddr_t ptr;
X     caddr_t client_data;
X} AwlExtern, *AwlExternList;
X
typedef void (*AwlExtProc)();
X
X/* declare the class constant */
extern WidgetClass awlWidgetClass;
X
X/* contact routines */
extern caddr_t awl_call();
extern void awl_break_set(), awl_break_delete(),
X     awl_break_enable(), awl_break_disable();
X#endif /* _Awl_h */
END_OF_FILE
if test 3700 -ne `wc -c <'Awl.h'`; then
    echo shar: \"'Awl.h'\" unpacked with wrong size!
fi
# end of 'Awl.h'
fi
if test -f 'TODO' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'TODO'\"
else
echo shar: Extracting \"'TODO'\" \(4835 characters\)
sed "s/^X//" >'TODO' <<'END_OF_FILE'
X#
X# $Header: /usr/src/local/awl/RCS/TODO,v 2.1 90/04/19 20:04:11 jkh Exp $
X#
X# $Log:	TODO,v $
X# Revision 2.1  90/04/19  20:04:11  jkh
X# Alpha checkin.
X# 
X# Revision 2.0  90/03/26  01:42:15  jkh
X# pre-beta check-in
X# 
X#
X
X[Subsequent] line numbers will be wrong in the presence of multiple line
string constants. I don't quite know what to do about this.
X
XXt{Set,Get}MultiClickTime()? Do we need this?
X
XXtInstallAccelerators/XtInstallAllAccelerators().
X
XXtCallActionProc() would be useful, but I don't know what to do about
the XEvent structure. Foo. 
X
Add code for getting $PC information on functions and/or line numbers.
Make disassemble available from the application. Otherwise, breakpoints
are pretty useless.
X
Add builtin functions load and destroy (destroy is grammer builtin).
X* load is done.
X
put "option" back in for setting internal resource options on-the-fly.
X
There are potential leaks that can occur from internal calls to coerce()
X(and indirectly from calls to get_arg()) that cause storage to be allocated
for a coersion but never free'd afterwards. A rough cut at fixing this
by a) bumping up the ref counts on all coerce'd allocated values and then
b) calling do_free() on the coerced results when finished. This would
then merely decrement the ref count for values that were pre-ref'd but
free values that had been created only for the coersion. This failed due
to the sheer number of callers to coerce and the number of intermediate
steps performed on coerced values. A final solution may be to better
anticipate these situations (that scheme should work, it just needs
a very thorough approach) or to keep a separate list of intermediate
coerced values for later garbage collection.
X
Add an option to tell awl to retain the separator character when doing
splits. I.E. If awl is splitting a string at newlines, allow the user to keep
the newline or when reading a string with get(), retain the terminator.
X
Do we need mkdir/rmdir/{sym}link/rename/creat/flock/{get,set}priority/
X{set,get}pgrp,time(),umask() and unlink()?
We support some system calls now, but now many is "reasonable" and how
many is "overkill?". All of the above could be added easily, I'm just not
sure if it's necessary. They would make awl more compatable with PERL.
Some things I can never add since they return complicated structures
and awl is not PERL in that regard.
X
Do Xw map.
X
XFind out how to use menu objects in athena. * heh..
X
XFigure out which text type to make generic. (sort of done.)
X
XFigure out generic dialog.
X
Make Athena "main" widget. A number of other Motif/Xw composite widgets
can probably be emulated too. Figure out which ones these are and add them
to the Generic set.
X
Make callback functions somehow get layout they were called from. (Hard).
Perhaps this can be done by walking up the widget tree.
X
XFigure out what the interface to awl's internal variables and functions
is going to be like. If we let them stick breakpoints around, we should
also give them a way to see which functions reside where and what the
registers are set to.
X
Go through the Xw, Xt and Motif widgets sets and find all areas of
commonality. This means:
X
X	1. All widgets which have a counterpart in each of the three.
X	2. All resource names which can be mapped with a reasonable degree
X	of functional equivalancy for each widget in this set.
X	3. All ancillary work functions who's work can be generalized
X	across all three widget sets.
X
Make the AwlExtern stuff work! While you're at it, make the SetValues
and Destroy functions Do The Right Thing for the awl widget.
X
Make sure single widgets can be created (or all that work making create_widget
and friends work for them will be wasted). Add functions for frobbing the
generic text widget/generic pane widget/etc. *half done. Need the frobbing
functions.
X
Add awl_register_widget_class for registering weird widgets (like the Tty
widget in xgdb) from C. Or add this as part of the AwlExtern mechanism.
Half done.
X
XXtAddcallback and friends? Should we do anything about them? What about
callbacks in general?
X
Add awl_line_info and awl_func_info functions to find out beginning and
ending insns for awl lines and functions, respectively. Don't forget that
awl_line_info will have to include both a filename and line number if it
is to be general. It will also not work when line information is
omitted (will print warning [unless nowarn] and return 0,0). Perhaps
this could be generalized into awl_get_symbol() (functions are symbols too).
X
Signal handling vector. Each signal can have an associated symbol that will
be called as a function when and if that signal arrives. * Not possible
since we can't figure out which signal invoked a generic signal handler. Oh
well. Hmmmm. This actually is possible, but we'd need a front-end function
for every possible signal. This bites the big one.
X
END_OF_FILE
if test 4835 -ne `wc -c <'TODO'`; then
    echo shar: \"'TODO'\" unpacked with wrong size!
fi
# end of 'TODO'
fi
if test -f 'awl.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'awl.1'\"
else
echo shar: Extracting \"'awl.1'\" \(4143 characters\)
sed "s/^X//" >'awl.1' <<'END_OF_FILE'
X.\"
X.\" $Header: /usr/src/local/awl/RCS/awl.1,v 1.1 90/04/19 20:04:13 jkh Exp $
X.\"
X.\"
X.\" $Log:	awl.1,v $
Revision 1.1  90/04/19  20:04:13  jkh
Initial revision
X
X.\"
X.TH AWL 1
X.SH NAME
awl \- Simple \fIawl widget\fR client
X.SH SYNOPSIS
X.B awl
X[
X\fBfile\fR
X]
X[
X\fB\-cpp\fR \fIcpp command\fR
X]
X[
X\fB\-cpparg\fR \fIcpp arguments\fR
X]
X[
X\fB\-debug\fR
X]
X[
X\fB\-file\fR \fIfile name\fR
X]
X[
X\fB\-line\fR
X]
X[
X\fB\-nowarn\fR
X]
X[
X\fB\-show\fR
X]
X[
X\fB\-start\fR \fIfunction\fR
X]
X[
X\fB\-trace\fR
X]
X[
X\fB\-v\fR
X]
X[
X\fBtoolkit options\fR
X]
X[
X\fBarguments to CPP\fR
X]
X.SH DESCRIPTION
X.B Awl
Is a simple client of the \fIAwl Widget\fR that allows you to run \fBawl\fR
programs stand-alone without having to write a wrapper. It also facilitates
debugging by allowing you to set many different toolkit, cpp and \fBawl\fR
internal tracing options before execution. You can also request that execution
begin at some arbitrary function rather than 'main'.
X.SH OPTIONS
X.TP
X.B file
Specifies the file to execute as an \fBawl\fR program. This argument
is generally taken to be the first non -'d argument after all toolkit
arguments have been parsed.
X.B \-cpp \fIcpp command\FR
Specifies the name of a program to run instead of CPP for pre-processing
the \fBawl\fR program.
X.TP
X.B \-cpparg \fIcpp arguments\fR
Specifies arguments to pass to the CPP program. This should be used
when the implicit rules for passing arguments to CPP are insufficient.
X.TP
X.B \-debug
Turn on very verbose debugging output.
X.TP
X.B \-file \fIfile name\fR
Specifies the file to execute as an \fBawl\fR program. Use this option
when the default rule for finding the filename is insufficient.
X.TP
X.B \-line
Retain line-to-$PC translation information. This is useful for debugging.
X.TP
X.B \-nowarn
Do not output warning messages.
X.TP
X.B \-show
Show the intermediate "assembly" stage generated by \fBawl\fR.
X.TP
X.B \-start \fIfunction name\fR
Specifies an alternate function with which to begin execution.
X.TP
X.B \-trace
Display an execution trace as code is executed.
X.TP
X.B \-v
Display the current \fBawl\fR version number and default widget set.
X.TP
X.B X toolkit options
All standard toolkit options.
X.TP
X.B arguments to CPP
Any arguments not used by \fBawl\fR or the X toolkit are assumed to be
for the pre-processor program.
X.PP
X.SH EXAMPLES
X.PP
XExecute \fBawl\fP code from file \fIfoo.awl\fR on display \fIfrobozz:0.0\fR
adding the directory \fI\"/usr/lusers/joe/awl\"\fR to the include path.
X.nf
X	\fBawl\fR foo.awl -I/usr/lusers/joe/awl -display frobozz:0.0
X.fi
X.sp
XExecute code from \fIbar.awl\fR with tracing, debugging and a starting
point of \"debug_rtn\".
X.nf
X	\fBawl\fR bar.awl -trace -debug -startfunc debug_rtn
X.fi
X.SH AUTHOR
Jordan K. Hubbard
X.br
PCS Computer Systeme, GmbH
X.br
jkh@meepmeep.pcs.com
X.sp
March 1st, 1990.
X.SH ACKNOWLEDGEMENTS
Thanks to Paul A. Vixie, Kurt J. Pires and an anonymous individual at the
XExperimental Computing Facility (XCF), U.C. Berkeley for answering many of my
YACC questions and acting as a sounding board for some of my weird ideas
X(Paul Vixie also provided some AVL tree code which was used during testing and
proof-of-concept).
X.sp
Thanks also to Chris Torek and Fred Blonder for their printf() code which was
used in modified form for my own [s]printf() routines. IBM users will find
the roman numeral notation especially useful for deciphering the original
release dates on their system software.
X
XFinally, great thanks go to Terry Copernicus Jones who provided the strsed
and hashing code, made gratuitous insults about my coding style (even having
the nerve to re-write some of my code more efficiently behind my back) and
motivated me to finish this with his "clear staff of striking".
X.SH SEE ALSO
X.I X(1), awk(1).
X.SH BUGS
There are several places where memory (though not in large amounts) can
leak from implicit string/list conversions. I'm looking at various solutions
to this (and welcome suggestions) right now. Error handling in the grammer
could probably be a whole lot better. I need to understand a bit more about
yacc before I can make this more robust.
X
Others are sure to be lurking somewhere, especially in Terry's code.
END_OF_FILE
if test 4143 -ne `wc -c <'awl.1'`; then
    echo shar: \"'awl.1'\" unpacked with wrong size!
fi
chmod +x 'awl.1'
# end of 'awl.1'
fi
if test -f 'awl_driver.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'awl_driver.c'\"
else
echo shar: Extracting \"'awl_driver.c'\" \(3617 characters\)
sed "s/^X//" >'awl_driver.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/awl_driver.c,v 2.2 90/04/19 20:04:37 jkh Exp $";
X#endif
X
X/*
X *
X *                   Copyright 1989, 1990
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X *  All rights reserved.
X * 
X *  This is unsupported software and is subject to change without notice.
X *  the author makes no representations about the suitability of this software
X *  for any purpose. It is supplied "as is" without express or implied
X *  warranty.
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 the author not be used in
X *  advertising or publicity pertaining to distribution of the software
X *  without specific, written prior permission.
X *
X */
X
X/*
X * This file implements the awl driver.
X *
X * $Log:	awl_driver.c,v $
X * Revision 2.2  90/04/19  20:04:37  jkh
X * Alpha checkin.
X * 
X * Revision 2.1  90/04/02  01:50:45  jkh
X * Changed the name to protect the innocent.
X * 
X * Revision 2.0  90/03/26  01:42:55  jkh
X * pre-beta check-in
X *
X */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X/* #include <Awl.h> */
X#include "Awl.h"
X
static XrmOptionDescRec opts[] = {
X     {"-cpp",		"*cppCommand",	XrmoptionSepArg, XgDefaultCppCommand},
X     {"-cpparg",	"*cppArg",	XrmoptionSepArg, " "},
X     {"-debug",		"*debug",	XrmoptionNoArg, "on" },
X     {"-file",		"*file",	XrmoptionSepArg, NULL},
X     {"-line",		"*line",	XrmoptionNoArg, "on" },
X     {"-nowarn",	"*nowarn",	XrmoptionNoArg, "on" },
X     {"-show",		"*show",	XrmoptionNoArg, "on" },
X     {"-start",		"*start",	XrmoptionSepArg, "main"},
X     {"-trace",		"*trace",	XrmoptionNoArg, "on" },
X     {"-v",		"*version",	XrmoptionNoArg, "on" },
X};
X
int main(argc, argv)
int argc;
char **argv;
X{
X     char **margv;
X     Arg args[5];
X     Cardinal i, ac, margc;
X     Widget top;
X     char cpp_args[1024];
X     XtAppContext awl;
X     String file = NULL;
X     Display *dpy;
X
X     /* Init the toolkit */
X     XtToolkitInitialize();
X
X     /* Get a unique application context */
X     awl = XtCreateApplicationContext();
X
X     /* Open the display (of course) */
X     dpy = XtOpenDisplay(awl, NULL, "awl", "Awl", opts, XtNumber(opts),
X			 &argc, argv);
X
X     /* allocate margv for worst-case argument passing */
X     margv = (char **)XtMalloc(sizeof(char **) * argc);
X     margc = 1;
X
X
X     /*
X      * Assume that the first non -'d argument is the input file and any
X      * other options are for the pre-processor. This lets us get around
X      * having to use the klunky -file arg unconditionally. If we need to
X      * pass some strange non -'d pre-processor args, we can always use -file.
X      */
X     strcpy(cpp_args, " ");
X     for (ac = 1; ac < argc; ac++) {
X	  if (argv[ac][0] != '-') {
X	       if (!file)
X		    file = argv[ac];
X	       else
X		    margv[margc++] = argv[ac];
X	  }
X	  else
X	       strcat(cpp_args, argv[ac]);
X     }
X
X     i = 0;
X     if (file) {
X	  XtSetArg(args[i], XgNfile, file);		i++;
X	  margv[0] = file;
X     }
X     else
X	  margv[0] = "<stdin>";
X     margv[margc] = NULL;
X     if (margc > 1) {
X	  XtSetArg(args[i], XgNmainArgv, margv);		i++;
X     }
X     XtSetArg(args[i], XgNcppArg, cpp_args);		i++;
X     top = XtAppCreateShell("awl", "Awl", awlWidgetClass, dpy, args, i);
X     XtAppMainLoop(awl);
X     return(0);
X}
END_OF_FILE
if test 3617 -ne `wc -c <'awl_driver.c'`; then
    echo shar: \"'awl_driver.c'\" unpacked with wrong size!
fi
# end of 'awl_driver.c'
fi
if test -f 'examples/hackpict.awl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'examples/hackpict.awl'\"
else
echo shar: Extracting \"'examples/hackpict.awl'\" \(5412 characters\)
sed "s/^X//" >'examples/hackpict.awl' <<'END_OF_FILE'
X/* -*-Mode: C; -*- */
X
X/*
X * Another strange picture taken from the net. Don't click on it
X * unless you have nethack in your path. Just another test of
X * PIXMAP conversion, really, though B/W display users will find it more
X * interesting that porsche.awl
X */
X
X#include <xt.h>
X
global map = { "#", "white", "-", "black" };
X
global picture = {
X     "################################################################",
X     "#####-######-##################-######-#####-#######-----------#",
X     "#####-######-#-----------######-######-#####-#######--#-----#--#",
X     "#####-######-##----------######-######-#####-#######--##----#--#",
X     "#####-######-#####-------######-######-#####-#######--#-#---#--#",
X     "#####-######-##----------######-######-#####-#######--#--#--#--#",
X     "#####-######-#-----------######-######-#####-#######--#---#-#--#",
X     "#------------#-----------#----------------------------#----##--#",
X     "#######-######-----------#-######-#####-######-#####--#-----#--#",
X     "#######-######-------#---#-######-#####-######-#####-----------#",
X     "#######-######------###--#-######-#####-######-#####--#######--#",
X     "#######-######-----#-#-#-#-######-#####-######-#####--#-----#--#",
X     "#######-######-----#---#-#-######-#####-######-#####--#--------#",
X     "#######-######-----#---#-#-######-#####-######-#####--#--------#",
X     "#------------#------###--#----------------------------####-----#",
X     "######-########----------#-#####-######-#####-######--#--------#",
X     "######-###########-------#-#####-######-#####-######--#--------#",
X     "######-########----------#-#####-######-#####-######--#-----#--#",
X     "######-#######-----------#-#####-######-#####-######--#######--#",
X     "######-#######-----------#-#####-######-#####-######-----------#",
X     "######-###################-#####-######-#####-######--#######--#",
X     "#-----------------------------------------------------#--#--#--#",
X     "#####-######------###------------------#####-#######-----#-----#",
X     "#####-######-----#####-------------#---#####-#######-----#-----#",
X     "#####-######-----#-#-#-----------------#####-#######-----#-----#",
X     "#####-######-----#####------#----------#####-#######-----#-----#",
X     "#####-######-----##-##-----------------#####-#######-----#-----#",
X     "#####-######------###------------------#####-#######-----------#",
X     "#------------------#-------------------------------------------#",
X     "#######-#####----#####----------#-------######-#####--#-----#--#",
X     "#######-#####---#######------#--#--#--#-######-#####--#-----#--#",
X     "#######-#####--#########------#---#-----######-#####--#-----#--#",
X     "#######-#####--#-#####-#----------------######-#####--#######--#",
X     "#######-#####--#-#####-#----#########---######-#####--#-----#--#",
X     "#######-#####--#-#####-#-----#-----#----######-#####--#-----#--#",
X     "#--------------#-#####-#----##-----##-----------------#-----#--#",
X     "######-######----##-##------#-------#---#####-######--#-----#--#",
X     "######-######---###-###-----#-------#---#####-######-----------#",
X     "######-######---##---##-----#-------#---#####-######-----#-----#",
X     "######-######---##---##-----##-----##---#####-######----#-#----#",
X     "######-######--###---###-----#######----#####-######---#---#---#",
X     "######-######---------------------------#####-######--#######--#",
X     "#-----------------------------------------------------#-----#--#",
X     "#####-######-#####-######-#####-######-#####-#######--#-----#--#",
X     "#####-######-#####-######-#####-######-#####-#######--#-----#--#",
X     "#####-######-#####-######-#####-######-#####-#######-----------#",
X     "#####-######-#####-######-#####-######-#####-#######--#######--#",
X     "#####-######-#####-######-#####-######-#####-#######--#-----#--#",
X     "#####-######-#####-######-#####-######-#####-#######--#--------#",
X     "#-----------------------------------------------------#--------#",
X     "#######-#####-######-#####-######-#####-######-#####--#--------#",
X     "#######-#####-######-#####-######-#####-######-#####--#-----#--#",
X     "#######-#####-######-#####-######-#####-######-#####--#######--#",
X     "#######-#####-######-#####-######-#####-######-#####-----------#",
X     "#######-#####-######-#####-######-#####-######-#####--#----#---#",
X     "#######-#####-######-#####-######-#####-######-#####--#---#----#",
X     "#-----------------------------------------------------#--#-----#",
X     "######-######-#####-######-#####-######-#####-######--###------#",
X     "######-######-#####-######-#####-######-#####-######--###------#",
X     "######-######-#####-######-#####-######-#####-######--#--#-----#",
X     "######-######-#####-######-#####-######-#####-######--#---#----#",
X     "######-######-#####-######-#####-######-#####-######--#----#---#",
X     "######-######-#####-######-#####-######-#####-######-----------#",
X     "################################################################"
X};
X
play_hack()
X{
X     system("xterm -e nethack &");
X}
X
main()
X{
X     XgInstallColorTable(map);
X     foo = (PIXMAP)picture;
X     dude = Button "hack!" {
X	  XgWidth  length(picture[0]);
X	  XgHeight length(picture);
X	  XgBackgroundPixmap foo;
X	  XgCallback (CALLBACK)play_hack;
X	  XgTranslations (TRANSLATION)"#augment\n<Key>q: exit(0)";
X     };
X     XtCreateManaged(dude);
X     XtRealize(SELF);
X}
END_OF_FILE
if test 5412 -ne `wc -c <'examples/hackpict.awl'`; then
    echo shar: \"'examples/hackpict.awl'\" unpacked with wrong size!
fi
# end of 'examples/hackpict.awl'
fi
if test -f 'examples/porsche.awl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'examples/porsche.awl'\"
else
echo shar: Extracting \"'examples/porsche.awl'\" \(5562 characters\)
sed "s/^X//" >'examples/porsche.awl' <<'END_OF_FILE'
X/* -*-Mode: C; -*- */
X
X/*
X * This shows how to use XgInstallColorTable() for PIXMAP conversion
X * using pixmap (and format) borrowed from the xloadimage(1) program.
X * The actual conversion code is, however, completely different.
X */
X
X#include <xt.h>
X
global cmap = { " ", "slate blue", ".", "yellow", "r", "red", "b", "black" };
X
global porche = {
X     "                                                                ",
X     "                                                                ",
X     "        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb............................................bb        ",
X     "        bb..bbbb..bbbb..bbbb..bbbb..bbbb..b..b..bbbb..bb        ",
X     "        bb..b..b..b..b..b..b..b..b..b..b..b..b..b.....bb        ",
X     "        bb..b..b..b..b..b..b..b.....b.....b..b..b.....bb        ",
X     "        bb..bbbb..b..b..bbb...bbbb..b.....bbbb..bbbb..bb        ",
X     "        bb..b.....b..b..b..b.....b..b.....b..b..b.....bb        ",
X     "        bb..b.....b..b..b..b..b..b..b..b..b..b..b.....bb        ",
X     "        bb..b.....bbbb..b..b..bbbb..bbbb..b..b..bbbb..bb        ",
X     "        bb............................................bb        ",
X     "        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb.....................bbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb......b...b...bb.....bbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb.....b...b...b....b..bbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb....bb..bb.bbbbbbb...bbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb...bbbbbbbb......bb..bbrrrrrrrrrrrrrrrrrrrrrbb        ",
X     "        bb..bbbb...............bbrrrrrrrrrrrrrrrrrrrrrbb        ",
X     "        bb.bbb.................bbrrrrrrrrrrrrrrrrrrrrrbb        ",
X     "        bb..........b..b.......bbrrrrrrrrrrrrrrrrrrrrrbb        ",
X     "        bb.....b...b..b........bbrrrrrrrrrrrrrrrrrrrrrbb        ",
X     "        bb....b...b..b..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb....b.bbbbbbbbb..............bbbbbbbbbbbbbbbbb        ",
X     "        bb...bbbb.......bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
X     "        bb..bbb.........b..............bbbbbbbbbbbbbbbbb        ",
X     "        bb.bbb..........b...bbb........bbbbbbbbbbbbbbbbb        ",
X     "        bb.........b..b.b..bbbbb.......bbbbbbbbbbbbbbbbb        ",
X     "        bb.....b..b..b..b..b.bbb.....b.brrrrrrrrrrrrrrbb        ",
X     "        bb....b..b..b..bb....bbb....bb.brrrrrrrrrrrrrrbb        ",
X     "        bb...bb.bbbbbbb.b....bbb....bb.brrrrrrrrrrrrrrbb        ",
X     "        bb..bbbbb......bb...bbbbb...b..brrrrrrrrrrrrrrbb        ",
X     "        bb.bbb..........b.bbbbbbbbbbb..brrrrrrrrrrrrrrbb        ",
X     "        bb..............b.b.bbbbbbbbb..brrrrrrrrrrrrrrbb        ",
X     "        bbbbbbbbbbbbbbbbb.b.b....bbbb..bbbbbbbbbbbbbbbbb        ",
X     "        bbbbbbbbbbbbbbbbb...b.....b.b..b..............bb        ",
X     "        bbbbbbbbbbbbbbbbb........bb.bb.b...b..b.......bb        ",
X     "         bbbbbbbbbbbbbbbb........b..b..b..b..b...b...bb         ",
X     "         bbbbbbbbbbbbbbbb.......b..b...b.b..b...b....bb         ",
X     "         bbbbbbbbbbbbbbbbb............b.bbbbbbbbbb...bb         ",
X     "          bbrrrrrrrrrrrrrrb..........bbbb........bb.bb          ",
X     "          bbrrrrrrrrrrrrrrrb........bbbb............bb          ",
X     "           bbrrrrrrrrrrrrrrrbbbbbbbb.......b..b....bb           ",
X     "           bbrrrrrrrrrrrrrrrrrrbb.....b...b..b..b..bb           ",
X     "            bbrrrrrrrrrrrrrrrrrbb....b...b..b..b..bb            ",
X     "            bbrrrrrrrrrrrrrrrrrbb...bb.bbbbbbbb...bb            ",
X     "             bbbbbbbbbbbbbbbbbbbb...bbbb......bb.bb             ",
X     "              bbbbbbbbbbbbbbbbbbb..bbb...........b              ",
X     "              bbbbbbbbbbbbbbbbbbb.bbb...........bb              ",
X     "               bbbbbbbbbbbbbbbbbb..............bb               ",
X     "                bbbbbbbbbbbbbbbbb...b.b.b.....bb                ",
X     "                 bbbbbbbbbbbbbbbb..b.b.b..b..bb                 ",
X     "                  bbrrrrrrrrrrrbb..bbbbbbb..bb                  ",
X     "                   bbrrrrrrrrrrbb.bbb....b.bb                   ",
X     "                    bbrrrrrrrrrbb.bb......bb                    ",
X     "                     bbbrrrrrrrbb.......bbb                     ",
X     "                      bbbbrrrrrbb.....bbbb                      ",
X     "                        bbbbrrrbb...bbbb                        ",
X     "                          bbbbrbb.bbbb                          ",
X     "                            bbbbbbbb                            ",
X     "                              bbbb                              ",
X     "                               bb                               ",
X     "                                                                "
X};
X
main()
X{
X     /* we can always assume same-sized rows */
X     porche_width = length(porche[0]);
X     porche_height = length(porche);
X
X     /* Set the internal color table to the colormap */
X     XgInstallColorTable(cmap);
X
X     /* create the pixmap */
X     picture = (PIXMAP)porche;
X
X     x = Shell "click" {
X	  Box $? {
X	       XgTranslations (TRANSLATION)"<Btn1Down>:exit(0)";
X	       XgWidth porche_width;
X	       XgHeight porche_height;
X	       XgBackgroundPixmap picture;
X	  }
X     };
X     XtPopup(XtCreateManaged(x), XtGrabNone);
X}
END_OF_FILE
if test 5562 -ne `wc -c <'examples/porsche.awl'`; then
    echo shar: \"'examples/porsche.awl'\" unpacked with wrong size!
fi
# end of 'examples/porsche.awl'
fi
if test -f 'examples/set2.awl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'examples/set2.awl'\"
else
echo shar: Extracting \"'examples/set2.awl'\" \(5795 characters\)
sed "s/^X//" >'examples/set2.awl' <<'END_OF_FILE'
X/* -*-Mode: C; -*- */
X
X/*
X * This is like set.wl except this time we actually use the array elements to 
X * store data. This has gotten progressively sillier and sillier for some
X * reason.
X */
X
X#define NUMBER	"^[0-9]*[\t ]*"
X#define ARTICLE "^an?[\t ][\t ]*"
X#define BUG_THRESHOLD 3000
X
init_grocery()
X{
X     /* first set arrays to INT type to prevent ambiguity with [] */
X     fruit = insects = 0;
X     Pests = Inv = 0;
X
X     /* set the random number generator */
X     srand(getpid());
X
X     /* what we have in stock */
X     fruit["apple"] = 10;
X     fruit["pear"] = 5;
X     fruit["orange"] = 6;
X     fruit["mango"] = 2;
X     fruit["banana"] = 3;
X     fruit["papaya"] = 20;
X     fruit["grape"] = 40;
X     fruit["lemon"] = 3;
X     fruit["lime"] = 5;
X     fruit["pineapple"] = 4;
X     fruit["strawberrie"] = 200; /* berries are deliberately misspelled */
X     fruit["cherrie"] = 100;	 /* to deal with plural problem */
X     fruit["blackberrie"] = 40;
X
X     /* deal with silly requests */
X     bunch["strawberry"] = bunch["cherry"] = bunch["blackberry"] = 
X	  bunch["grape"] = TRUE;
X
X     /* give the fruit stand some realism */
X     insects["hornet"] = 5;
X     insects["bee"] = 10;
X     insects["yellowjacket"] = 10;
X     insects["spider"] = 8;
X     insects["ant"] = 25;
X}
X
X/* randomize the number of insects hovering around the stand */
twiddle_insect_count()
X{
X     local crawlies;
X
X     if (!Pests)
X	  Plen = length(Pests = (LIST)insects);
X     highest = 0;
X     for (i = 0; i < Plen; i++) {
X	  bias = rand();
X	  if (rand() < 1.6)
X	       bias -= 1; /* make it occasionally < 1 */
X	  old = insects[Pests[i]];
X	  new = (INT)(bias * old);
X	  if (new <= 0)
X	       new = 1;
X	  insects[Pests[i]] = new;
X	  if (new > highest) {
X	       highest = new;
X	       crawlies = Pests[i];
X	  }
X     }
X     if (highest < BUG_THRESHOLD)
X	  crawlies = NULL;
X     return(crawlies);
X}
X
global helpstring = "
Hi! I'm your friendly (if somewhat stupid) local purveyor of fruit
products (that is to say, the detached reproductive organs of various
plant specie). Please indicate which items you wish to purchase by telling
me what you want and (optionally) in what quantity. If you say 'stock'
I'll tell you my current inventory. If you tell me something is rotten,
I'll throw it away.
Thank you for shopping at Terry's Free Fruit!\n";
X
X/* macro for conditionally pluralizing things */
X#define PLUR(str)	("s$" ?? str ? str : str + "s")
X
main()
X{
X     init_grocery();
X     do {
X	  quantity = 0;
X	  q = input("Your order, sir? ", STRING);
X	  /* shift to lower case and de-pluralize if necessary */
X	  q = strsed(q, "g/./{A-Z}{a-z}/") - "s$";
X
X	  /* if there's a numeric quantity, extract it */
X	  if (num = NUMBER ?? q) {
X	       quantity = (INT)num;
X	       /* remove it (and leading spaces) from the item */
X	       q -= NUMBER;
X	  }
X	  /* else if there's an article, assume 1 */
X	  else if (ARTICLE ?? q) {
X	       quantity = 1;
X	       /* remove the article */
X	       q -= ARTICLE;
X	  }
X	  if (!quantity)
X	       quantity = 1;
X
X	  if (q == "help")
X	       println(helpstring);
X	  else if (q == "stock") {
X	       println("Current stock:");
X	       /* construct inventory and insect swarm */
X	       if (!Inv)
X		    Ilen = length(Inv = (LIST)fruit);
X	       for (i = 0; i < Ilen; i++) {
X		    s = Inv[i];
X		    if (fruit[s])
X			 printf("%d\t%s\n", fruit[s], PLUR(s));
X	       }
X	       print("\nAlso buzzing (and crawling) around the stands are ");
X	       if (!Pests) {
X		    Plen = length(Pests = (LIST)insects);
X		    highest = 0;
X	       }
X	       for (i = 0; i < Plen; i++) {
X		    s = Pests[i];
X		    cnt = insects[s];
X		    n = cnt > 1 ? s + "s" : s;
X
X		    if (i == 0)
X			 printf("%d %s", cnt, n);
X		    else if (i == (Plen - 1))
X			 printf(" and %d %s\n", cnt, n);
X		    else
X			 printf(", %d %s", cnt, n);
X	       }
X	       println();
X	  }
X	  else if ("^rotten" ?? q) {
X	       /* remove expletive and/or plural, if present */
X	       q -= "[s|!]$";
X	       bad = q - "^rotten[ \t]*";
X	       if (bad ?? fruit) {
X		    printf("What? The %s are rotten you say? Oh my! ",
X			   PLUR(bad));
X		    println("I'll get rid of those..");
X		    /* Nuke the offending fruit */
X		    fruit[bad] = 0;
X	       }
X	       else if (bad == "service") {
X		    printf("I'm so ashamed. I'm going to kill myself.\n");
X		    kill(getpid(), 9);
X	       }
X	       else if (bad == "")
X		    println("What exactly is rotten, sir?");
X	       else
X		    printf("I don't understand.. I don't stock %s!\n",
X			   PLUR(bad));
X	  }
X	  else if (q ?? insects)
X	       println("The bugs you can have for free (take all you want)");
X	  else if (q ?? bunch && quantity == 1)
X	       println("C'mon, nobody buys just one ", q, '!');
X	  else if (q != "quit") {
X	       /* figure out the appropriate article to print it with */
X	       art = q[0] ?? "aeio" ? "an " : "a ";
X	       if (q ?? fruit) {
X		    if (fruit[q] >= quantity) {
X			 fruit[q] -= quantity;
X			 if (quantity == 1)
X			      printf("You purchased %s%s,", art, q);
X			 else
X			      printf("You purchased %d %ss,", quantity, q);
X			 printf(" %s %s left.\n",
X				fruit[q] ? fruit[q] : "none",
X				fruit[q] == 1 ? "is" : "are");
X		    }
X		    else if (!fruit[q])
X			 println("Sorry, we're out of ", q + "s");
X		    else {
X			 print("Sorry, we don't have that many in stock, ");
X			 println("I can let you have ", fruit[q],
X				 " if you'd like.");
X		    }
X	       }
X	       else
X		    println("Hmm. I don't know what a ",q," is. Type 'help'.");
X	  }
X	  particularly_numerous_insect = twiddle_insect_count();
X	  if (particularly_numerous_insect != NULL) {
X	       printf("Argh!! This place is infested with %ss! I'm getting the hell out of here!\nSorry, we're closed!\n",
X		      particularly_numerous_insect);
X	       q = "quit";
X	  }
X     } until (q == "quit");
X     exit(0);
X}
END_OF_FILE
if test 5795 -ne `wc -c <'examples/set2.awl'`; then
    echo shar: \"'examples/set2.awl'\" unpacked with wrong size!
fi
# end of 'examples/set2.awl'
fi
if test -f 'layout.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'layout.c'\"
else
echo shar: Extracting \"'layout.c'\" \(5102 characters\)
sed "s/^X//" >'layout.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/layout.c,v 2.1 90/04/19 20:05:12 jkh Exp $";
X#endif
X
X/*
X *
X *                   Copyright 1989, 1990
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X * This file is part of AWL.
X *
X * AWL is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X * AWL is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with AWL; see the file COPYING.  If not, write to
X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *
X */
X
X/*
X * This file contains the code for creating and inspecting widget
X * layouts and interfacing with the X toolkit's conversion routines.
X *
X * $Log:	layout.c,v $
X * Revision 2.1  90/04/19  20:05:12  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:44:33  jkh
X * pre-beta check-in
X * 
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
X/*
X * Given a value, figure out how to set a given "arg" element
X * to it.
X */
XExport void wset_arg_by_value(args, idx, name, val)
Arg *args;
int *idx;
String name;
Value val;
X{
X     switch (value_type(val)) {
X     case FLOAT:
X	  /* floats are passed by address for portability */
X	  XtSetArg(args[*idx], name, (XtArgVal)&value_float(val));
X	  ++(*idx);
X	  break;
X
X	  /* usually a widget ID that was pre-ref'd */
X     case WIDGET:
X	  if (value_class(val) == INDIRECT) {
X	       XtSetArg(args[*idx], name, *(Widget *)value_widget(val));
X	       ++(*idx);
X	  }
X	  else if (value_class(val) == DATA) {
X	       XtSetArg(args[*idx], name, (XtArgVal)value_widget(val));
X	       ++(*idx);
X	  }
X	  else
X	       exec_error("Illegal class for resource typed WIDGET");
X	  break;
X
X     case CHAR:
X	  XtSetArg(args[*idx], name, (XtArgVal)value_char(val));
X	  ++(*idx);
X	  break;
X
X     AOBJCASE:
X	  XtSetArg(args[*idx], name, (XtArgVal)aobj_ptr(value_aobj(val)));
X	  ++(*idx);
X	  break;
X	  
X	  /* All else can be passed in "any" */
X     default:
X	  XtSetArg(args[*idx], name, (XtArgVal)value_any(val));
X	  ++(*idx);
X	  break;
X     }
X}
X
X/*
X * Given a widget class and a "manage" flag, decide what toolkit function
X * should be called to create a given widget.
X */
XExport Widget (*wcreate_rtn(class, manage))()
WidgetClass class;
Boolean manage;
X{
X     int flags = map_wclass_to_flags(class);
X
X     if (flags & W_WIDPROC)
X	  return((Widget(*)())class);
X     else if (flags & W_POPUP)
X	  return(XtCreatePopupShell);
X     else if (manage)
X	  return(XtCreateManagedWidget);
X     else
X	  return(XtCreateWidget);
X}
X
X/* return the Widget ID for a layout, triggering an error if none */
XExport Inline Widget layout_id(aw, n)
AwlWidget aw;
Layout n;
X{
X     if (!n)
X	  exec_error(aw, "layout_id: Null layout passed");
X     else if (!wl_id(n))
X	  exec_error(aw, "layout_id: Layout %s has not yet been created",
X		     wl_name(n));
X     else
X	  return(wl_id(n));
X     /* Not reached, but keeps gcc happy */
X     return((Widget)0);
X}
X
X/* return the Widget class for a layout, triggering an error if none */
XExport Inline WidgetClass layout_wclass(aw, n)
AwlWidget aw;
Layout n;
X{
X     if (!n)
X	  exec_error(aw, "layout_wclass: Null layout passed");
X     else if (!wl_wclass(n))
X	  exec_error(aw, "layout_wclass: Layout %s has not yet been created",
X		     wl_name(n));
X     else
X	  return(wl_wclass(n));
X     /* Not reached, but keeps gcc happy */
X     return((WidgetClass)0);
X}
X
X/*
X * Create a widget for a layout.
X */
XExport void create_widget(aw, parent, n, manage)
AwlWidget aw;
Widget parent;
Layout n;
Boolean manage;
X{
X     int a, flags;
X     Arg args[50];
X     Resource r;
X     Generic map;
X
X     a = 0;
X     r = wl_resources(n);
X
X     while (r) {
X	  if ((map = map_rname(res_name(r), &flags)) != NULL) {
X	       if (flags & W_RESPROC)
X		    (*(void (*)())map)(aw, args, &a, r);
X	       else
X		    wset_arg_by_value(args, &a, (String)map, res_value(r));
X	  }
X	  else
X	       wset_arg_by_value(args, &a, res_name(r), res_value(r));
X	  r = res_next(r);
X     }
X
X     wl_id(n) = ((*wcreate_rtn)(wl_wclass(n), manage))(wl_name(n),
X						       wl_wclass(n),
X						       parent, args, a);
X     if (!wl_id(n)) {
X	  exec_error(aw, "Creating widget '%s'", wl_name(n));
X	  return;
X     }
X}
X
XExport void layout_create(aw, parent, w, manage)
AwlWidget aw;
Widget parent;
Layout w;
Boolean manage;
X{
X     while (w) {
X	  create_widget(aw, parent, w, manage);
X	  if (wl_head(w)) {
X	       if (map_wclass_to_flags(wl_wclass(w)) & W_MANAGER)
X		    layout_create(aw, wl_id(w), wl_head(w), manage);
X	       else
X		    exec_warn(aw,
X			      "%s: Widget '%s' Not MANAGER: Ignoring children",
X			      "xtcreate", wl_name(w),
X			      map_wclass_to_wname(wl_wclass(w)));
X	  }
X	  w = wl_next(w);
X     }
X}
END_OF_FILE
if test 5102 -ne `wc -c <'layout.c'`; then
    echo shar: \"'layout.c'\" unpacked with wrong size!
fi
# end of 'layout.c'
fi
if test -f 'ltypes.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ltypes.h'\"
else
echo shar: Extracting \"'ltypes.h'\" \(4426 characters\)
sed "s/^X//" >'ltypes.h' <<'END_OF_FILE'
X#ifndef _LTYPES_H_INCLUDE
X#define _LTYPES_H_INCLUDE
X
X/* $Header: /usr/src/local/awl/RCS/ltypes.h,v 2.2 90/04/19 20:05:20 jkh Exp $ */
X
X/*
X *
X *                     Copyright 1989
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X * This file is part of AWL.
X *
X * AWL is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X * AWL is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with AWL; see the file COPYING.  If not, write to
X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *
X */
X
X/*
X * Here are all the awl internal / external types.
X *
X * $Log:	ltypes.h,v $
X * Revision 2.2  90/04/19  20:05:20  jkh
X * Alpha checkin.
X * 
X * Revision 2.1  90/03/31  06:38:28  jkh
X * Eliminated some dead typedefs.
X * 
X * Revision 2.0  90/03/26  01:43:19  jkh
X * pre-beta check-in
X *
X */
X
typedef hash_table *Table;	/* as defined by tsearch and friends */
X
typedef struct _insntab {	/* instruction table */
X     int insn;			/* insn # */
X     int nargs;			/* number of operands */
X     String name;		/* print name */
X} InsnTable;
X
typedef struct _ltabent {
X     String file;		/* file name */
X     int line;			/* line number */
X     int start;			/* PC of first insn for line */
X     int last;			/* PC of last insn for line */
X} LTabEnt;
X
typedef struct _breakpoint {
X     struct _breakpoint *next;	/* next breakpoint in chain */
X     int (*func)();		/* function to call on break */
X     int addr;			/* address of breakpoint */
X     Boolean enable;		/* enable state */
X} *Breakpoint;
X
typedef struct _ctable {
X     unsigned long *colors;	/* colors array */
X     Table htab;		/* color name hash table */
X     int nch;			/* # of chars per pixel */
X     int ncolors;		/* number of colors */
X} *CTable;
X
typedef struct _rmap {
X     String from;		/* map from -> to */
X     String to;
X} RMap;
X
typedef struct _process {
X     int pid;			/* process ID */
X     FILE *in, *out;		/* input/output fd's */
X} *Process;
X
typedef struct _allocobj {
X     int cnt;			/* ref count */
X     Generic ptr;		/* data */
X} *AllocObj;
X
typedef struct _sym {
X     AwlWidget aw;		/* which widget we belong to */
X     String name;		/* symbol name */
X     Table alist;		/* symbol's a-list (if any) */
X     Table parent;		/* symbol's parent table */
X     struct _sym *next;		/* for relating groups of symbols */
X     struct _val {		/* symbol's value */
X	  short class;		/* value's class */
X	  short type;		/* value's type */
X	  union _datum {	/* data */
X	       AllocObj o;	/* data is allocated object */
X	       FILE *z;		/* data is FILE */
X	       FTYPE f;		/* data is float */
X	       Widget w;	/* data is widget */
X	       WidgetClass c;	/* data is widget class */
X	       Generic a;	/* data is any (generic) */
X	       char b;		/* data is char */
X	       int i;		/* data is int */
X	       short r[2];	/* data is range */
X	       struct _sym *y;	/* data is symbol pointer */
X	  } v;
X     } v;
X} *Symbol;
X
typedef struct _val Value;
typedef union _datum Datum;
X
typedef Generic (*GenFunc)();
X
typedef struct _function {
X     int nparms;		/* number of function parameters */
X     int nlocals;		/* number of function locals */
X     int end;			/* ending PC address */
X     Generic calldata;		/* hook for function specific data */
X     union _addr {
X	  int u;		/* "text" addr of user function */
X	  Value (*s)();		/* function address of built-in function */
X	  GenFunc f;		/* function address of external function */
X     } addr;
X} *Function;
X
typedef union _addr Address;
X
typedef struct _layout {
X     Widget w_id;		/* the Widget ID */
X     String name;		/* widget's name */
X     WidgetClass class;		/* class */
X     struct _layout *parent;	/* daddy */
X     struct _layout *head, *tail;/* children */
X     struct _layout *next;	/* siblings */
X     struct _resource {
X	  String name;
X	  Value val;
X	  struct _layout *parent;
X	  struct _resource *next;
X     } *res;
X} *Layout;
X
typedef struct _resource *Resource;
X
X#endif /* _LTYPES_H_INCLUDE */
END_OF_FILE
if test 4426 -ne `wc -c <'ltypes.h'`; then
    echo shar: \"'ltypes.h'\" unpacked with wrong size!
fi
# end of 'ltypes.h'
fi
if test -f 'mathrtns.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mathrtns.c'\"
else
echo shar: Extracting \"'mathrtns.c'\" \(5236 characters\)
sed "s/^X//" >'mathrtns.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/mathrtns.c,v 2.1 90/04/19 20:05:24 jkh Exp $";
X#endif
X
X/*
X *
X *                     Copyright 1989
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X * This file is part of AWL.
X *
X * AWL is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X * AWL is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with AWL; see the file COPYING.  If not, write to
X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *
X */
X
X/*
X * This file contains all the math specific built-ins and system dependent
X * error handlers for under/overflow traps.
X *
X * $Log:	mathrtns.c,v $
X * Revision 2.1  90/04/19  20:05:24  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:43:29  jkh
X * pre-beta check-in
X * 
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
Local Value arg;
X
X#define DEFUN_SIMPLE_MATH_FUNC(func) \
DEFUN(func) \
X{ \
X     arg = get_arg(aw, 1, FLOAT, FALSE); \
X     value_float(arg) = func(value_float(arg)); \
X     return(arg); \
X}
X
X#if defined(__STDC__) && !defined(UNIXCPP)	/* ANSI */
X#define DEFUN_NONEG_MATH_FUNC(func) \
DEFUN(func) \
X{ \
X     arg = get_arg(aw, 1, FLOAT, FALSE); \
X     if (value_float(arg) < 0) \
X	  exec_warn(aw, "Attempt to compute %s of negative number.", #func); \
X     else \
X	  value_float(arg) = sqrt(value_int(arg)); \
X     return(arg); \
X}
X#else
DEFUN(func) \
X{ \
X     arg = get_arg(aw, 1, FLOAT, FALSE); \
X     if (value_float(arg) < 0) \
X	  exec_warn(aw, "Attempt to compute %s of negative number.", "func"); \
X     else \
X	  value_float(arg) = sqrt(value_int(arg)); \
X     return(arg); \
X}
X#endif
X
X/*
X * sqrt(X):
X * This gives you the positive square root of X.  It reports an
X * error if X is negative.
X */
DEFUN_NONEG_MATH_FUNC(sqrt)
X
X/*
X * log(X):
X * This gives you the natural logarithm of X. It reports an error
X * if X is negative.
X */
DEFUN_NONEG_MATH_FUNC(log)
X
X/*
X * log10(X):
X * This gives you the logarithm base 10 of X. It reports and error
X * if X is negative.
X */
DEFUN_NONEG_MATH_FUNC(log10)
X
X/*
X * exp(X):
X * This gives you the exponential of X, or reports an error if X is
X * out of range.  The range of values X can have depends on your
X * machine's floating point representation.
X */
DEFUN_SIMPLE_MATH_FUNC(exp)
X
X/*
X * sin(X):
X * This gives you the sine of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(sin)
X
X/*
X * cos(X):
X * This gives you the cosine of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(cos)
X
X/*
X * tan(x):
X * This gives you the tangent of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(tan)
X
X/*
X * asin(x):
X * This gives you the arcsine of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(asin)
X
X/*
X * acos(x):
X * This gives you the arccosine of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(acos)
X
X/*
X * atan(x):
X * This gives you the arctangent of X, with X in radians.
X */
DEFUN_SIMPLE_MATH_FUNC(atan)
X
X/*
X * atan2(Y, X):
X * This gives you the arctangent of Y/X, with both in radians.
X */
DEFUN(atan2)
X{
X     Value y, x;
X
X     y = get_arg(aw, 1, FLOAT, FALSE);
X     x = get_arg(aw, 2, FLOAT, FALSE);
X     value_float(arg) = atan2(value_float(y), value_float(x));
X     return(arg);
X}
X
X/*
X * hypot(X, Y):
X * Inplements the standard Euclidean distance function.
X */
DEFUN(hypot)
X{
X     Value x, y;
X
X     x = get_arg(aw, 1, FLOAT, FALSE);
X     y = get_arg(aw, 2, FLOAT, FALSE);
X     value_float(arg) = hypot(value_float(x), value_float(y));
X     return(arg);
X}
X
X/*
X * pow(X, Y):
X * Pow returns XY.  If X is zero, Y must be positive.  If X is
X * negative, Y must be an integer.
X */
DEFUN(pow)
X{
X     Value x, y;
X
X     x = get_arg(aw, 1, FLOAT, FALSE);
X     y = get_arg(aw, 2, ANY, FALSE);
X     value_set(arg, DATA, FLOAT, float, 0.0);
X     if (value_type(y) == FLOAT) {
X	  if (value_float(x) == 0.0 && value_float(y) < 0.0)
X	       exec_warn(aw, "pow: If X is 0.0, Y must be >= 0.0");
X	  else if (value_float(x) < 0.0)
X	       exec_warn(aw, "pow: If X is less than 0.0, Y must be INT");
X	  else
X	       value_set(arg, DATA, FLOAT, float, pow(value_float(x),
X						      value_float(y)));
X     }
X     else {
X	  y = coerce(aw, y, INT);
X	  if (value_float(x) == 0.0 && value_int(y) < 0)
X	       exec_warn(aw, "pow: If X is 0.0, Y must be >= 0");
X	  else
X	       value_set(arg, DATA, FLOAT, float, pow(value_float(x),
X						      (float)value_int(y)));
X     }
X     return(arg);
X}
X	  
X/*
X * rand():
X * This gives you a random number between 0 and 1.
X */
DEFUN(rand)
X{
X     Import float drand48();
X
X     value_type(arg) = FLOAT;
X     value_float(arg) = drand48();
X     return(arg);
X}
X
X/*
X * srand(X):
X * Sets the random number generator seed to X.
X */
DEFUN(srand)
X{
X     Import void srand48();
X
X     arg = get_arg(aw, 1, INT, FALSE);
X     srand48(value_int(arg));
X     return(arg);
X}
END_OF_FILE
if test 5236 -ne `wc -c <'mathrtns.c'`; then
    echo shar: \"'mathrtns.c'\" unpacked with wrong size!
fi
# end of 'mathrtns.c'
fi
if test -f 'resw.gperf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'resw.gperf'\"
else
echo shar: Extracting \"'resw.gperf'\" \(3579 characters\)
sed "s/^X//" >'resw.gperf' <<'END_OF_FILE'
X%{
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/resw.gperf,v 2.3 90/04/13 16:33:45 jkh Exp $";
X#endif
X
X/*
X *
X *                     Copyright 1989
X *                    Jordan K. Hubbard
X *
X *		  PCS Computer Systeme, GmbH.
X *	             Munich, West Germany
X *
X *
X * This file is part of AWL.
X *
X * AWL is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X * AWL is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with AWL; see the file COPYING.  If not, write to
X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X *
X */
X
X/*
X * This is the gperf hash table for all reserved words in awl.
X *
X * $Log:	resw.gperf,v $
X * Revision 2.3  90/04/13  16:33:45  jkh
X * Changed naming convention for FUNC_ types.
X * 
X * Revision 2.2  90/04/01  00:09:50  jkh
X * Added FUNC_EXTERN type.
X * 
X * Revision 2.1  90/03/29  18:28:53  jkh
X * Added switch/case/default keywords.
X * 
X * Revision 2.0  90/03/26  01:43:40  jkh
X * pre-beta check-in
X *
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
X%}
struct Reswords { char *name; int token; int type; };
X%%
if,		IF,		T_KEYWORD
do,		DO,		T_KEYWORD
for,		FOR,		T_KEYWORD
else,		ELSE,		T_KEYWORD
goto,		GOTO,		T_KEYWORD
while,		WHILE,		T_KEYWORD
until,		UNTIL,		T_KEYWORD
break,		BREAK,		T_KEYWORD
continue,	CONTINUE,	T_KEYWORD
return,		RETURN,		T_KEYWORD
switch,		SWITCH,		T_KEYWORD
case,		CASE,		T_KEYWORD
default,	DEFAULT,	T_KEYWORD
global,		GLOBAL,		T_KEYWORD
local,		LOCAL,		T_KEYWORD
XFUNC_ACTION,	FUNC_ACTION,	T_INTERN_TYPE
XFUNC_BUILTIN,	FUNC_BUILTIN,	T_INTERN_TYPE
XFUNC_CALLBACK,	FUNC_CALLBACK,	T_INTERN_TYPE
XFUNC_EXTERNAL,	FUNC_EXTERN,	T_INTERN_TYPE
XFUNC_LAYOUT,	FUNC_LAYOUT,	T_INTERN_TYPE
XFUNC_UNDEF,	FUNC_UNDEF,	T_INTERN_TYPE
XFUNC_USER,	FUNC_USER,	T_INTERN_TYPE
XFILEDESC,	FILEDESC,	T_INTERN_TYPE
XFILEPDESC,	FILEPDESC,	T_INTERN_TYPE
RESOURCE,	RESOURCE,	T_INTERN_TYPE
SYMBOL,		SYMBOL,		T_INTERN_TYPE
RANGE,		RANGE,		T_INTERN_TYPE
ANY,		ANY,		T_TYPE
CADDR,		CADDR,		T_TYPE
CALLBACK,	CALLBACK,	T_TYPE
CHAR,		CHAR,		T_TYPE
XFADDR,		FADDR,		T_TYPE
XFLOAT,		FLOAT,		T_TYPE
IADDR,		IADDR,		T_TYPE
INT,		INT,		T_TYPE
LAYOUT,		LAYOUT,		T_TYPE
LIST,		LIST,		T_TYPE
PIXMAP,		PIXMAP,		T_TYPE
SADDR,		SADDR,		T_TYPE
STRING,		STRING,		T_TYPE
TRANSLATION,	TRANSLATION,	T_TYPE
WCLASS,		WCLASS,		T_TYPE
WIDGET,		WIDGET,		T_TYPE
ALLOCATED,	ALLOCATED,	T_CLASS
CONSTANT,	CONSTANT,	T_CLASS
DATA,		DATA,		T_CLASS
XFUNCTION,	FUNCTION,	T_CLASS
INDIRECT,	INDIRECT,	T_CLASS
LABEL,		LABEL,		T_CLASS
STATIC,		STATIC,		T_CLASS
X%%
X
X/*
X * Look up a reserved word by name and token type.
X */
XExport int map_resword_to_token(name, type)
String name;
short type;
X{
X     struct Reswords *rw;
X
X     if ((rw = is_resword(name, strlen(name))) != NULL && rw->type & type)
X	  return(rw->token);
X     else
X	  return(0);
X}
X
X/*
X * Look up the name of a reserved word by token and type.
X */
XExport String map_token_to_resword(token, type)
register short token;
register short type;
X{
X     register int i, limit = (sizeof(wordlist) / sizeof(struct Reswords));
X
X     for (i = 0; i < limit; i++)
X	  if (wordlist[i].token == token && wordlist[i].type & type)
X	       return(wordlist[i].name);
X     return((String)0);
X}
END_OF_FILE
if test 3579 -ne `wc -c <'resw.gperf'`; then
    echo shar: \"'resw.gperf'\" unpacked with wrong size!
fi
# end of 'resw.gperf'
fi
echo shar: End of archive 2 \(of 17\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 17 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

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.