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

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

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

#! /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 4 (of 17)."
# Contents:  ATHENA.gperf MOTIF.gperf builtins.c etc/xaw.h stat.c
#   symbols.c
# Wrapped by vixie@jove.pa.dec.com on Mon Apr 30 01:25:21 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ATHENA.gperf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ATHENA.gperf'\"
else
echo shar: Extracting \"'ATHENA.gperf'\" \(8116 characters\)
sed "s/^X//" >'ATHENA.gperf' <<'END_OF_FILE'
X%{
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/ATHENA.gperf,v 2.1 90/04/19 20:03:54 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 using the Athena implementation
X * of the awl generic widget set.
X *
X * $Log:	ATHENA.gperf,v $
X * Revision 2.1  90/04/19  20:03:54  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:41:58  jkh
X * pre-beta check-in
X * 
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
X#include	<X11/Xaw/AsciiText.h>
X#include	<X11/Xaw/Box.h>
X#include	<X11/Xaw/Clock.h>
X#include	<X11/Xaw/Command.h>
X#include	<X11/Xaw/Dialog.h>
X#include	<X11/Xaw/Form.h>
X#include	<X11/Xaw/Grip.h>
X#include	<X11/Xaw/Label.h>
X#include	<X11/Xaw/List.h>
X#include	<X11/Xaw/Logo.h>
X#include	<X11/Xaw/Mailbox.h>
X#include	<X11/Xaw/MenuButton.h>
X#include	<X11/Xaw/Paned.h>
X#include	<X11/Xaw/Scrollbar.h>
X#include	<X11/Xaw/SimpleMenu.h>
X#include	<X11/Xaw/Sme.h>
X#include	<X11/Xaw/SmeBSB.h>
X#include	<X11/Xaw/SmeLine.h>
X#include	<X11/Xaw/StripChart.h>
X#include	<X11/Xaw/Text.h>
X#include	<X11/Xaw/Toggle.h>
X#include	<X11/Xaw/Viewport.h>
X
DEFRMAP(mapBoxSpacing)
X{
X     XtSetArg(args[*idx], XtNhSpace, value_int(res_value(res))); (*idx)++;
X     XtSetArg(args[*idx], XtNvSpace, value_int(res_value(res))); (*idx)++;
X}
X
XExport RMap ResMap[] = {
X     { "XgAccelerators",	XtNaccelerators		},
X     { "XgAllowResize",		XtNallowResize		},
X     { "XgAllowShellResize",	XtNallowShellResize	},
X     { "XgAncestorSensitive",	XtNancestorSensitive	},
X     { "XgBitmap",		XtNbitmap		},
X     { "XgBackground",		XtNbackground		},
X     { "XgBackgroundPixmap",	XtNbackgroundPixmap	},
X     { "XgBorderColor",		XtNborderColor		},
X     { "XgBorderPixmap",	XtNborderPixmap		},
X     { "XgBorderWidth",		XtNborderWidth		},
X     { "XgBoxSpacing",		"mapBoxSpacing"		},
X     { "XgCallback",		XtNcallback		},
X     { "XgColormap",		XtNcolormap		},
X     { "XgCursor",		XtNcursor		},
X     { "XgDepth",		XtNdepth		},
X     { "XgDestroyCallback",	XtNdestroyCallback	},
X     { "XgFont",		XtNfont			},
X     { "XgForeground",		XtNforeground		},
X     { "XgFormBottom",		XtNbottom		},
X     { "XgFormHorizDist",	XtNhorizDistance	},
X     { "XgFormHorizWidget",	XtNfromHoriz		},
X     { "XgFormLeft",		XtNleft			},
X     { "XgFormResizable",	XtNresizable		},
X     { "XgFormRight",		XtNright		},
X     { "XgFormTop",		XtNtop			},
X     { "XgFormVertDist",	XtNvertDistance		},
X     { "XgFormVertWidget",	XtNfromVert		},
X     { "XgHighlightThickness",	XtNhighlightThickness	},
X     { "XgHeight",		XtNheight		},
X     { "XgIconic",		XtNiconic		},
X     { "XgLabel",		XtNlabel		},
X     { "XgListItems",		XtNlist			},
X     { "XgListNitems",		XtNnumberStrings	},
X     { "XgMappedWhenManaged",	XtNmappedWhenManaged	},
X     { "XgMarginHeight",	XtNinternalHeight	},
X     { "XgMarginWidth",		XtNinternalWidth	},
X     { "XgPaneAllowResize",	XtNallowResize		},
X     { "XgPaneMaxHeight",	XtNmax			},
X     { "XgPaneMinHeight",	XtNmin			},
X     { "XgPaneSkipAdjust",	XtNskipAdjust		},
X     { "XgSaveUnder",		XtNsaveUnder		},
X     { "XgScreen",		XtNscreen		},
X     { "XgSensitive",		XtNsensitive		},
X     { "XgTextInsertPosition",	XtNinsertPosition	},
X     { "XgTextJustify",		XtNjustify		},
X     { "XgTextString",		XtNstring		},
X     { "XgTranslations",	XtNtranslations		},
X     { "XgViewportScrollHoriz",	XtNallowHoriz		},
X     { "XgViewportScrollVert",	XtNallowVert		},
X     { "XgWidth",		XtNwidth		},
X     { "XgX",			XtNx			},
X     { "XgY",			XtNy			},
X     { NULL,			NULL			},
X};
X
X%}
struct WMap { char *name; WidgetClass *type; long flags; };
X%%
AppShell,	&applicationShellWidgetClass,	W_MANAGER | W_POPUP
AsciiText,	&asciiTextWidgetClass,		W_EXTENDED
Box,		&boxWidgetClass,		W_MANAGER
Command,	&commandWidgetClass,		W_EXTENDED
Button,		&commandWidgetClass,		W_NONE
Clock,		&clockWidgetClass,		W_EXTENDED
Dialog,		&dialogWidgetClass,		W_NONE
XForm,		&formWidgetClass,		W_MANAGER
Grip,		&gripWidgetClass,		W_NONE
Label,		&labelWidgetClass,		W_NONE
List,		&listWidgetClass,		W_NONE
Logo,		&logoWidgetClass,		W_EXTENDED
Mailbox,	&mailboxWidgetClass,		W_EXTENDED
MenuButton,	&menuButtonWidgetClass,		W_NONE
OverrideShell,	&overrideShellWidgetClass,	W_POPUP | W_MANAGER
Pane,		&panedWidgetClass,		W_MANAGER
Popup,		&transientShellWidgetClass,	W_POPUP | W_MANAGER
Scrollbar,	&scrollbarWidgetClass,		W_NONE
Simple,		&simpleWidgetClass,		W_EXTENDED
SimpleMenu,	&simpleMenuWidgetClass,		W_NONE
StripChart,	&stripChartWidgetClass,		W_EXTENDED
Text,		&textWidgetClass,		W_NONE
Toggle,		&toggleWidgetClass,		W_NONE
Shell,		&topLevelShellWidgetClass,	W_MANAGER | W_POPUP
ToplevelShell,	&topLevelShellWidgetClass,	W_MANAGER | W_POPUP
TransientShell,	&transientShellWidgetClass,	W_MANAGER | W_POPUP
Viewport,	&viewportWidgetClass,		W_EXTENDED | W_MANAGER
mapBoxSpacing,	MAP(mapBoxSpacing),		W_RESPROC
X%%
X
X/*
X * Given a widget name, return its class.
X */
XExport WidgetClass map_wname_to_wclass(name)
String name;
X{
X     struct WMap *wm;
X
X     if ((wm = is_generic(name, strlen(name))) != NULL
X	 && !(wm->flags & W_RESPROC))
X	  return(*(wm->type));
X     else
X	  return((WidgetClass)0);
X}
X
X/*
X * Given a resource name, see if it maps to something else
X */
XExport String map_rname(name, flags)
String name;
int *flags;
X{
X     struct WMap *wm;
X     String ret = NULL;
X
X     if ((wm = is_generic(name, strlen(name))) != NULL
X	 && (wm->flags & W_RESPROC)) {
X	  if (flags)
X	       *flags = wm->flags;
X	  ret = (String)wm->type;
X     }
X     return(ret);
X}
X
X/*
X * These next two actually grub around in the wordlist array directly and
X * that's kludge. I wish there was a way I could make gperf generate multiple
X * hash tables for different members of the same struct, but that would
X * probably be kludge too. I don't think gperf does hash tables for
X * non-string values anyway. In any case, we don't lose a whole lot
X * doing linear searches on the class member since it's not done very
X * often. We're in trouble if gperf ever changes the name of the wordlist
X * array, but given the existence of gperf's -G flag), I doubt that this will
X * ever happen.
X */
X 
X/*
X * Given a widget class, return its name.
X */
XExport String map_wclass_to_wname(type)
WidgetClass type;
X{
X     register int i, limit = (sizeof(wordlist) / sizeof(struct WMap));
X
X     for (i = 0; i < limit; i++)
X	  if (!(wordlist[i].flags & W_RESPROC) && wordlist[i].type
X	      && *(wordlist[i].type) == type)
X	       return(wordlist[i].name);
X     return((String)0);
X}
X
X/*
X * Given a widget class, return its mask.
X */
XExport long map_wclass_to_flags(type)
WidgetClass type;
X{
X     register int i, limit = (sizeof(wordlist) / sizeof(struct WMap));
X
X     for (i = 0; i < limit; i++)
X	  if (!(wordlist[i].flags & W_RESPROC) && wordlist[i].type
X	      && *(wordlist[i].type) == type)
X	       return(wordlist[i].flags);
X     return((long)0);
X}
X
X
X/*******************************************************
X * Here lie the generic widget manipulation functions. *
X *******************************************************/
X
XExport void XgListSelectItem(list, item)
Widget list;
int item;
X{
X     XawListHighlight(list, item);
X}
X
XExport void XgListUnselectItem(list, item)
Widget list;
int item;
X{
X     XawListUnhighlight(list, item);
X}
X
XExport void XgListChange(list, data)
Widget list;
String *data;
X{
X     XawListChange(list, data, 0, 0, TRUE);
X}
END_OF_FILE
if test 8116 -ne `wc -c <'ATHENA.gperf'`; then
    echo shar: \"'ATHENA.gperf'\" unpacked with wrong size!
fi
# end of 'ATHENA.gperf'
fi
if test -f 'MOTIF.gperf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MOTIF.gperf'\"
else
echo shar: Extracting \"'MOTIF.gperf'\" \(9038 characters\)
sed "s/^X//" >'MOTIF.gperf' <<'END_OF_FILE'
X%{
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/MOTIF.gperf,v 2.1 90/04/19 20:04:08 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 is the gperf hash table for using the Motif implementation
X * of the awl generic widget set.
X *
X * $Log:	MOTIF.gperf,v $
X * Revision 2.1  90/04/19  20:04:08  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:42:11  jkh
X * pre-beta check-in
X *
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
X#include <Xm/Xm.h>
X#include <Xm/Command.h>
X#include <Xm/CutPaste.h>
X#include <Xm/DialogS.h>
X#include <Xm/Form.h>
X#include <Xm/Frame.h>
X#include <Xm/Label.h>
X#include <Xm/LabelG.h>
X#include <Xm/List.h>
X#include <Xm/MessageB.h>
X#include <Xm/MenuShell.h>
X#include <Xm/MainW.h>
X#include <Xm/PanedW.h>
X#include <Xm/PushB.h>
X#include <Xm/PushBG.h>
X#include <Xm/RowColumn.h>
X#include <Xm/Scale.h>
X#include <Xm/ScrollBar.h>
X#include <Xm/ScrolledW.h>
X#include <Xm/SelectioB.h>
X#include <Xm/SeparatoG.h>
X#include <Xm/Separator.h>
X#include <Xm/Text.h>
X#include <Xm/ToggleB.h>
X#include <Xm/ToggleBG.h>
X
X/* Deal with inter-form positioning resources */
DEFRMAP(mapFormPos)
X{
X     if (!strcmp(res_name(res), "FormFromVertW")) {
X	  XtSetArg(args[*idx], XmNtopAttachment, XmATTACH_WIDGET); ++(*idx);
X	  wset_arg_by_value(args, idx, "XmNtopWidget", res_value(res));
X     }
X     else if (!strcmp(res_name(res), "FormFromHorizW")) {
X	  XtSetArg(args[*idx], XmNleftAttachment, XmATTACH_WIDGET); ++(*idx);
X	  wset_arg_by_value(args, idx, "XmNleftWidget", res_value(res));
X     }
X     else
X	  exec_warn(aw, "MOTIF: Can't map form resource '%s'", res_name(res));
X}
X
X/* Enable scrolling on viewport */
DEFRMAP(mapViewportScroll)
X{
X     if (value_type(res_value(res)) == INT && value_int(res_value(res)))
X	  XtSetArg(args[*idx], XmNscrollingPolicy, XmAUTOMATIC); ++(*idx);
X     else
X	  exec_warn(aw, "MOTIF: Bogus attempt to change viewport scrolling policy; ignored");
X}
X
DEFRMAP(mapIgnore)
X{
X     return;
X}
X
XExport RMap ResMap[] = {
X     { "XgAccelerators",	XmNaccelerators		},
X     { "XgAllowResize",		XmNallowResize		},
X     { "XgAllowShellResize",	XmNallowShellResize	},
X     { "XgAncestorSensitive",	XmNancestorSensitive	},
X     { "XgBitmap",		XmNlabelPixmap		},
X     { "XgBackground",		XmNbackground		},
X     { "XgBackgroundPixmap",	XmNbackgroundPixmap	},
X     { "XgBorderColor",		XmNborderColor		},
X     { "XgBorderPixmap",	XmNborderPixmap		},
X     { "XgBorderWidth",		XmNborderWidth		},
X     { "XgBoxSpacing",		XmNspacing		},
X     { "XgCallback",		XmNactivateCallback	},
X     { "XgColormap",		XmNcolormap		},
X     { "XgCursor",		"mapIgnore"		},
X     { "XgDepth",		XmNdepth		},
X     { "XgDestroyCallback",	XmNdestroyCallback	},
X     { "XgFont",		XmNfont			},
X     { "XgForeground",		XmNforeground		},
X     { "XgFormBottom",		XmNbottomAttachment	},
X     { "XgFormHorizDist",	XmNleftOffset		},
X     { "XgFormHorizWidget",	"mapFormPos"		},
X     { "XgFormLeft",		XmNleftAttachment	},
X     { "XgFormResizable",	XmNresizable		},
X     { "XgFormRight",		XmNrightAttachment	},
X     { "XgFormTop",		XmNtopAttachment	},
X     { "XgFormVertDist",	XmNtopOffset		},
X     { "XgFormVertWidget",	"mapFormPos"		},
X     { "XgHeight",		XmNheight		},
X     { "XgHighlightThickness",	XmNhighlightThickness	},
X     { "XgIconic",		XmNiconic		},
X     { "XgIconMask",		XmNiconMask		},
X     { "XgIconPixmap",		XmNiconPixmap		},
X     { "XgIconWindow",		XmNiconWindow		},
X     { "XgIconX",		XmNiconX		},
X     { "XgIconY",		XmNiconY		},
X     { "XgInitialState",	XmNinitialState		},
X     { "XgInput",		XmNinput		},
X     { "XgLabel",		XmNlabelString		},
X     { "XgMappedWhenManaged",	XmNmappedWhenManaged	},
X     { "XgMarginHeight",	XmNmarginHeight		},
X     { "XgMarginWidth",		XmNmarginWidth		},
X     { "XgPaneAllowResize",	XmNallowResize		},
X     { "XgPaneMaxHeight",	XmNmaximum		},
X     { "XgPaneMinHeight",	XmNminimum		},
X     { "XgPaneSkipAdjust",	XmNskipAdjust		},
X     { "XgSaveUnder",		XmNsaveUnder		},
X     { "XgScreen",		XmNscreen		},
X     { "XgSensitive",		XmNsensitive		},
X     { "XgTextInsertPosition",	XmNinsertPosition	}, /* fake */
X     { "XgTextJustify",		XmNjustify		},
X     { "XgTextString",		XmNstring		}, /* map string? */
X     { "XgTranslations",	XmNtranslations		},
X     { "XgViewportScrollHoriz",	"mapViewScroll"		},
X     { "XgViewportScrollVert",	"mapViewScroll"		},
X     { "XgWidth",		XmNwidth		},
X     { "XgX",			XmNx			},
X     { "XgY",			XmNy			},
X     { NULL,			NULL			},
X};
X
X%}
struct WMap { char *name; WidgetClass *type; long flags; };
X%%
AppShell,	&applicationShellWidgetClass,	W_MANAGER | W_POPUP
ArrowButton,	&xmArrowButtonWidgetClass,	W_EXTENDED
Box,		&xmRowColumnWidgetClass,	W_MANAGER
BulletinBoard,	&xmBulletinBoardWidgetClass,	W_EXTENDED | W_MANAGER
Button,		&xmPushButtonWidgetClass,	W_NONE
CascadeButton,	&xmCascadeButtonWidgetClass,	W_EXTENDED
Dialog,		&xmMessageBoxWidgetClass,	W_NONE
XForm,		&xmFormWidgetClass,		W_MANAGER
Grip,		&xmSeparatorWidgetClass,	W_NONE
Label,		&xmLabelWidgetClass,		W_NONE
List,		&xmListWidgetClass,		W_NONE
OverrideShell,	&overrideShellWidgetClass,	W_POPUP | W_MANAGER
Pane,		&xmPanedWindowWidgetClass,	W_MANAGER
Popup,		&xmMenuShellWidgetClass,	W_MANAGER | W_POPUP
Scrollbar,	&xmScrollBarWidgetClass,	W_NONE
Shell,		&topLevelShellWidgetClass,	W_MANAGER | W_POPUP
Text,		&xmTextWidgetClass,		W_NONE
Toggle,		&xmToggleButtonWidgetClass,	W_NONE
ToplevelShell,	&topLevelShellWidgetClass,	W_MANAGER | W_POPUP
TransientShell,	&transientShellWidgetClass,	W_MANAGER | W_POPUP
Viewport,	&xmScrolledWindowWidgetClass,	W_MANAGER
mapIgnore,	MAP(mapIgnore),			W_RESPROC
mapFormPos,	MAP(mapFormPos),		W_RESPROC
mapViewScroll,	MAP(mapViewportScroll),		W_RESPROC
X%%
X
X/*
X * Given a widget name, return its class.
X */
XExport WidgetClass map_wname_to_wclass(name)
String name;
X{
X     struct WMap *wm;
X
X     if ((wm = is_generic(name, strlen(name))) != NULL
X	 && !(wm->flags & W_RESPROC))
X	  return(*(wm->type));
X     else
X	  return((WidgetClass)0);
X}
X
X/*
X * Given a resource name, see if it maps to something else
X */
XExport Generic map_rname(name, flags)
String name;
int *flags;
X{
X     struct WMap *wm;
X
X     if ((wm = is_generic(name, strlen(name))) != NULL
X	 && (wm->flags & W_RESPROC)) {
X	  if (flags)
X	       *flags = wm->flags;
X	  return((Generic)wm->type);
X     }
X     else
X	  return((Generic)NULL);
X}
X
X/*
X * These next two actually grub around in the wordlist array directly and
X * that's kludge. I wish there was a way I could make gperf generate multiple
X * hash tables for different members of the same struct, but that would
X * probably be kludge too. I don't think gperf does hash tables for
X * non-string values anyway. In any case, we don't lose a whole lot
X * doing linear searches on the class member since it's not done very
X * often. We're in trouble if gperf ever changes the name of the wordlist
X * array, but given the existence of gperf's -G flag), I doubt that this will
X * ever happen.
X */
X 
X/*
X * Given a widget class, return its name.
X */
XExport String map_wclass_to_wname(type)
WidgetClass type;
X{
X     int i, limit;
X
X     limit = (sizeof(wordlist) / sizeof(struct WMap));
X
X     for (i = 0; i < limit; i++)
X	  if (!(wordlist[i].flags & W_RESPROC) && wordlist[i].type
X	      && *(wordlist[i].type) == type)
X	       return(wordlist[i].name);
X     return((String)0);
X}
X
X/*
X * Given a widget class, return its mask.
X */
XExport long map_wclass_to_flags(type)
WidgetClass type;
X{
X     int i, limit;
X
X     limit = (sizeof(wordlist) / sizeof(struct WMap));
X
X     for (i = 0; i < limit; i++)
X	  if (!(wordlist[i].flags & W_RESPROC) && wordlist[i].type
X	      && *(wordlist[i].type) == type)
X	       return(wordlist[i].flags);
X     return((long)0);
X}
X
X
X/*******************************************************
X * Here lie the generic widget manipulation functions. *
X *******************************************************/
X
XExport void XgListSelectItem(list, item)
Widget list;
int item;
X{
X     XmListDeselectAllItems(list);
X     XmListSelectItem(list, item);
X}
X
XExport void XgListUnselectItem(list, item)
Widget list;
int item;
X{
X     XmListDeselectItem(list, item);
X}
X
XExport void XgListChange(list, data)
Widget list;
String *data;
X{
X     /* don't know how to create XmStringTable from list yet */
X}
END_OF_FILE
if test 9038 -ne `wc -c <'MOTIF.gperf'`; then
    echo shar: \"'MOTIF.gperf'\" unpacked with wrong size!
fi
# end of 'MOTIF.gperf'
fi
if test -f 'builtins.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'builtins.c'\"
else
echo shar: Extracting \"'builtins.c'\" \(8086 characters\)
sed "s/^X//" >'builtins.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/builtins.c,v 2.1 90/04/19 20:04:39 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 includes and "declares" all awl builtin functions. If you want
X * to add new functions to awl, first decide which <xxx>rtns.c file it
X * goes in (or create a new one) and DEFUN it there. Next, add an F_DECLARE
X * line for it to the add_builtins() function below. I wish I could figure
X * out a nice way to have DEFUN'd functions automatically declared, but I
X * haven't yet. I know how gdb does it and I don't particularly care for
X * that approach (grubbing through the object's symbol table! Ack!).
X *
X * $Log:	builtins.c,v $
X * Revision 2.1  90/04/19  20:04:39  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:42:59  jkh
X * pre-beta check-in
X *
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
X/*
X * Declare any DEFUN'd builtins here. Syntax is: F_DECLARE(name, num_args);
X * If function takes a variable number of arguments, set num_args to -1.
X */
XExport void add_builtins(aw)
AwlWidget aw;
X{
X     Address addr;
X
X     /* awl specific functions */
X     F_DECLARE(aw, _argc, 0);
X     F_DECLARE(aw, _argv, 1);
X     F_DECLARE(aw, assign, 2);
X     F_DECLARE(aw, classid, 1);
X     F_DECLARE(aw, classof, 1);
X     F_DECLARE(aw, get, 1);
X     F_DECLARE(aw, input, 2);
X     F_DECLARE(aw, length, 1);
X     F_DECLARE(aw, load, 1);
X     F_DECLARE(aw, print, -1);
X     F_DECLARE(aw, println, -1);
X     F_DECLARE(aw, printname, 1);
X     F_DECLARE(aw, symbol, 1);
X     F_DECLARE(aw, typeid, 1);
X     F_DECLARE(aw, typeof, 1);
X
X     /* system functions */
X     F_DECLARE(aw, chdir, 1);
X     F_DECLARE(aw, chmod, 2);
X     F_DECLARE(aw, chown, 3);
X     F_DECLARE(aw, chroot, 1);
X     F_DECLARE(aw, close, 1);
X     F_DECLARE(aw, exec, 2);
X     F_DECLARE(aw, exit, 1);
X     F_DECLARE(aw, fork, 0);
X     F_DECLARE(aw, free, 1);
X     F_DECLARE(aw, fmt_time, 2);
X     F_DECLARE(aw, getenv, 1);
X     F_DECLARE(aw, getegid, 0);
X     F_DECLARE(aw, geteuid, 0);
X     F_DECLARE(aw, getgid, 0);
X     F_DECLARE(aw, getpid, 0);
X     F_DECLARE(aw, getuid, 0);
X     F_DECLARE(aw, getwd, 0);
X     F_DECLARE(aw, group, 1);
X     F_DECLARE(aw, kill, 2);
X     F_DECLARE(aw, malloc, 1);
X     F_DECLARE(aw, open, 2);
X     F_DECLARE(aw, perror, 1);
X     F_DECLARE(aw, printf, -1);
X     F_DECLARE(aw, read, 2);
X     F_DECLARE(aw, readdir, 1);
X     F_DECLARE(aw, setbuf, 2);
X     F_DECLARE(aw, setgid, 1);
X     F_DECLARE(aw, setuid, 1);
X     F_DECLARE(aw, signal, 2);
X     F_DECLARE(aw, sleep, 1);
X     F_DECLARE(aw, sprintf, -1);
X     F_DECLARE(aw, stat, 1);
X     F_DECLARE(aw, system, 1);
X     F_DECLARE(aw, time, 0);
X     F_DECLARE(aw, user, 1);
X     F_DECLARE(aw, write, 2);
X
X     /* math ops */
X     F_DECLARE(aw, acos, 1);
X     F_DECLARE(aw, asin, 1);
X     F_DECLARE(aw, atan, 1);
X     F_DECLARE(aw, atan2, 2);
X     F_DECLARE(aw, cos, 1);
X     F_DECLARE(aw, exp, 1);
X     F_DECLARE(aw, hypot, 2);
X     F_DECLARE(aw, log, 1);
X     F_DECLARE(aw, log10, 1);
X     F_DECLARE(aw, pow, 2);
X     F_DECLARE(aw, rand, 0);
X     F_DECLARE(aw, sin, 1);
X     F_DECLARE(aw, sqrt, 1);
X     F_DECLARE(aw, srand, 1);
X     F_DECLARE(aw, tan, 1);
X
X     /* string ops */
X     F_DECLARE(aw, strsed, -1);
X     F_DECLARE(aw, substr, 1);
X
X     /* toolkit ops */
X     F_DECLARE(aw, XBell, 1);
X
X     F_DECLARE(aw, XgInstallColorTable, 1);
X     F_DECLARE(aw, XgListSelectItem, 2);
X     F_DECLARE(aw, XgListUnselectItem, 2);
X     F_DECLARE(aw, XgListChange, 2);
X
X/*   F_DECLARE(aw, XtAddCallback, 3); */
X     F_DECLARE(aw, XtAddTimeOut, 2);
X     F_DECLARE(aw, XtAddWorkProc, 2);
X     F_DECLARE(aw, XtAugmentTranslations, 2);
X     F_DECLARE(aw, XtClass, 1);
X     F_DECLARE(aw, XtCreate, -1);
X     F_DECLARE(aw, XtCreateManaged, -1);
X     F_DECLARE(aw, XtDestroy, 1);
X     F_DECLARE(aw, XtGetSelectionTimeout, 0);
X     F_DECLARE(aw, XtIsManaged, 1);
X     F_DECLARE(aw, XtIsRealized, 1);
X     F_DECLARE(aw, XtIsSensitive, 1);
X     F_DECLARE(aw, XtIsSubclass, 2);
X     F_DECLARE(aw, XtManage, 1);
X     F_DECLARE(aw, XtMap, 1);
X     F_DECLARE(aw, XtMove, 3);
X     F_DECLARE(aw, XtName, 1);
X     F_DECLARE(aw, XtNameToWidget, 2);
X     F_DECLARE(aw, XtOverrideTranslations, 2);
X     F_DECLARE(aw, XtParent, 1);
X     F_DECLARE(aw, XtPopdown, 1);
X     F_DECLARE(aw, XtPopup, 2);
X     F_DECLARE(aw, XtRealize, 1);
X     F_DECLARE(aw, XtRemoveTimeOut, 1);
X     F_DECLARE(aw, XtRemoveWorkProc, 1);
X     F_DECLARE(aw, XtResize, 4);
X     F_DECLARE(aw, XtSetMappedWhenManaged, 2);
X     F_DECLARE(aw, XtSetSelectionTimeout, 1);
X     F_DECLARE(aw, XtSetSensitive, 2);
X     F_DECLARE(aw, XtSuperclass, 1);
X     F_DECLARE(aw, XtUninstallTranslations, 1);
X     F_DECLARE(aw, XtUnmanage, 1);
X     F_DECLARE(aw, XtUnmap, 1);
X}
X
X/*
X * Declare any builtin constants and variables.
X * Syntax is: C_DECLARE(aw, name, type, value).
X * If the type 0 is passed, it signifies that the name and string
X * value are the same (symbol becomes a string constant).
X * If you want to declare a variable (something that can be modified by
X * the user), use V_DECLARE(aw, name, type, address-of-value).
X * Try to follow the convention that all constants and variables are in
X * upper case and that all variables are preceeded by a dollar sign ($).
X * This will avoid confusion.
X */
XExport void add_predefined_symbols(aw)
AwlWidget aw;
X{
X     Datum t;
X
X#ifndef MAXINT
X/* Make an informed guess */
X#define MAXINT (~(1 << (8 * sizeof(int)) - 1))
X#endif
X
X     /* useful integer constants */
X     C_DECLARE(aw, TRUE, INT, TrueDatum);
X     C_DECLARE(aw, FALSE, INT, FalseDatum);
X     datum_int(t) = EOF;		C_DECLARE(aw, EOF, INT, t);
X     datum_int(t) = MAXINT;		C_DECLARE(aw, MAXINT, INT, t);
X     datum_int(t) = 0;			C_DECLARE(aw, NULL, INT, t);
X     datum_int(t) = MY_SIG_DFL;		C_DECLARE(aw, SIG_DFL, INT, t);
X     datum_int(t) = MY_SIG_IGN;		C_DECLARE(aw, SIG_IGN, INT, t);
X
X     /* user setable parameters */
X     V_DECLARE(aw, $RADIX, IADDR, &awl_radix(aw));
X     V_DECLARE(aw, $SEP, SADDR, &awl_sep(aw));
X
X     /* useful float constants from <math.h> */
X     datum_float(t) = M_E;		C_DECLARE(aw, M_E, FLOAT, t);
X     datum_float(t) = M_LOG2E;		C_DECLARE(aw, M_LOG2E, FLOAT, t);
X     datum_float(t) = M_LOG10E;		C_DECLARE(aw, M_LOG10E, FLOAT, t);
X     datum_float(t) = M_LN2;		C_DECLARE(aw, M_LN2, FLOAT, t);
X     datum_float(t) = M_LN10;		C_DECLARE(aw, M_LN10, FLOAT, t);
X     datum_float(t) = M_PI;		C_DECLARE(aw, M_PI, FLOAT, t);
X     datum_float(t) = M_PI_2;		C_DECLARE(aw, M_PI_2, FLOAT, t);
X     datum_float(t) = M_PI_4;		C_DECLARE(aw, M_PI_4, FLOAT, t);
X     datum_float(t) = M_1_PI;		C_DECLARE(aw, M_1_PI, FLOAT, t);
X     datum_float(t) = M_2_PI;		C_DECLARE(aw, M_2_PI, FLOAT, t);
X     datum_float(t) = M_2_SQRTPI;	C_DECLARE(aw, M_2_SQRTPI, FLOAT, t);
X     datum_float(t) = M_SQRT2;		C_DECLARE(aw, M_SQRT2 1, FLOAT, t);
X     datum_float(t) = M_SQRT1_2;	C_DECLARE(aw, M_SQRT1_2, FLOAT, t);
X     datum_float(t) = MAXFLOAT;		C_DECLARE(aw, MAXFLOAT, FLOAT, t);
X
X     /* misc interesting constants */
X     datum_widget(t) = (Widget)aw;	C_DECLARE(aw, SELF, WIDGET, t);
X     datum_file(t) = stdin;		C_DECLARE(aw, STDIN, FILEDESC, t);
X     datum_file(t) = stdout;		C_DECLARE(aw, STDOUT, FILEDESC, t);
X     datum_file(t) = stderr;		C_DECLARE(aw, STDERR, FILEDESC, t);
X}
END_OF_FILE
if test 8086 -ne `wc -c <'builtins.c'`; then
    echo shar: \"'builtins.c'\" unpacked with wrong size!
fi
# end of 'builtins.c'
fi
if test -f 'etc/xaw.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'etc/xaw.h'\"
else
echo shar: Extracting \"'etc/xaw.h'\" \(8195 characters\)
sed "s/^X//" >'etc/xaw.h' <<'END_OF_FILE'
X#define ASCII_TIME_BUFLEN 32
X#define BS 0
X#define CR 0
X#define DEFAULT_GRIP_SIZE 8
X#define DEL 0
X#define FOREGROUND 1
X#define HIGHLIGHT 1
X#define HighlightNone 0
X#define LF 0
X#define LayoutDone 2
X#define LayoutInProgress 1
X#define LayoutPending 0
X#define MAXCUT 30000
X#define NO_GCS 0
X#define Normal 0
X#define OKAY 0
X#define PANED_ASK_CHILD 0
X#define PANED_GRIP_SIZE 0
X#define SEG_BUFF_SIZE 128
X#define SP 0
X#define Selected 1
X#define TAB 0
X#define TMPSIZ 32
X#define XawAsciiFile 0
X#define XawAsciiString 1
X#define XawEditDone 0
X#define XawEditError 1
X#define XawPositionError 2
X#define XawactionAdjust 1
X#define XawactionEnd 2
X#define XawactionStart 0
X#define XawisOff 1
X#define XawisOn 0
X#define XawsdLeft 0
X#define XawsdRight 1
X#define XawselectAll 6
X#define XawselectChar 2
X#define XawselectLine 4
X#define XawselectNull 0
X#define XawselectParagraph 5
X#define XawselectPosition 1
X#define XawselectWord 3
X#define XawsmTextExtend 1
X#define XawsmTextSelect 0
X#define XawstAll 4
X#define XawstEOL 2
X#define XawstParagraph 3
X#define XawstPositions 0
X#define XawstWhiteSpace 1
X#define XawtextAppend 1
X#define XawtextEdit 2
X#define XawtextRead 0
X#define XawtextResizeBoth 3
X#define XawtextResizeHeight 2
X#define XawtextResizeNever 0
X#define XawtextResizeWidth 1
X#define XawtextScrollAlways 2
X#define XawtextScrollNever 0
X#define XawtextScrollWhenNeeded 1
X#define XawtextWrapLine 1
X#define XawtextWrapNever 0
X#define XawtextWrapWord 2
X#define XtCAutoFill "AutoFill"
X#define XtCBitmap "Bitmap"
X#define XtCCheckCommand "CheckCommand"
X#define XtCColumnWidth "ColumnWidth"
X#define XtCColumns "Columns"
X#define XtCCornerRoundPercent "CornerRoundPercent"
X#define XtCDataCompression "DataCompression"
X#define XtCEdge "Edge"
X#define XtCFlip "Flip"
X#define XtCGripIndent "GripIndent"
X#define XtCHorizontalMargins "HorizontalMargins"
X#define XtCIcon "Icon"
X#define XtCInsensitive "Insensitive"
X#define XtCJumpScroll "JumpScroll"
X#define XtCLabelClass "LabelClass"
X#define XtCLeftBitmap "LeftBitmap"
X#define XtCLineWidth "LineWidth"
X#define XtCList "List"
X#define XtCLongest "Longest"
X#define XtCMax "Max"
X#define XtCMenuName "MenuName"
X#define XtCMenuOnScreen "MenuOnScreen"
X#define XtCMin "Min"
X#define XtCMinimumThumb "MinimumThumb"
X#define XtCNumberStrings "NumberStrings"
X#define XtCOutput "Output"
X#define XtCPieceSize "PieceSize"
X#define XtCPixmapMask "PixmapMask"
X#define XtCPopupOnEntry "PopupOnEntry"
X#define XtCPreferredPaneSize "PreferredPaneSize"
X#define XtCRadioData "RadioData"
X#define XtCRadioGroup "RadioGroup"
X#define XtCResize "Resize"
X#define XtCRightBitmap "RightBitmap"
X#define XtCRowHeight "RowHeight"
X#define XtCScale "Scale"
X#define XtCScroll "Scroll"
X#define XtCSelectTypes "SelectTypes"
X#define XtCShapeStyle "ShapeStyle"
X#define XtCShapeWindow "ShapeWindow"
X#define XtCShowGrip "ShowGrip"
X#define XtCShown "Shown"
X#define XtCSpacing "Spacing"
X#define XtCState "State"
X#define XtCStipple "Stipple"
X#define XtCTemplateResource "TemplateResource"
X#define XtCTopOfThumb "TopOfThumb"
X#define XtCType "Type"
X#define XtCUseStringInPlace "UseStringInPlace"
X#define XtCVertSpace "VertSpace"
X#define XtCVerticalMargins "VerticalMargins"
X#define XtCVolume "Volume"
X#define XtCWidget "Widget"
X#define XtCWrap "Wrap"
X#define XtChainTop 0
X#define XtEfile "file"
X#define XtEstring "string"
X#define XtEtextResizeBoth "both"
X#define XtEtextResizeHeight "height"
X#define XtEtextResizeNever "never"
X#define XtEtextResizeWidth "width"
X#define XtEtextScrollAlways "always"
X#define XtEtextScrollNever "never"
X#define XtEtextScrollWhenNeeded "whenneeded"
X#define XtEtextWrapLine "line"
X#define XtEtextWrapNever "never"
X#define XtEtextWrapWord "word"
X#define XtNallowHoriz "allowHoriz"
X#define XtNallowResize "allowResize"
X#define XtNallowVert "allowVert"
X#define XtNanalog "analog"
X#define XtNautoFill "autoFill"
X#define XtNbetweenCursor "betweenCursor"
X#define XtNbitmap "bitmap"
X#define XtNbottom "bottom"
X#define XtNbottomMargin "bottomMargin"
X#define XtNcheckCommand "checkCommand"
X#define XtNchime "chime"
X#define XtNcolumnSpacing "columnSpacing"
X#define XtNcolumnWidth "columnWidth"
X#define XtNcornerRoundPercent "cornerRoundPercent"
X#define XtNcursor "cursor"
X#define XtNdataCompression "dataCompression"
X#define XtNdefaultColumns "defaultColumns"
X#define XtNdefaultDistance "defaultDistance"
X#define XtNdialogHOffset "dialogHOffset"
X#define XtNdialogVOffset "dialogVOffset"
X#define XtNdisplayCaret "displayCaret"
X#define XtNdisplayNonprinting "displayNonprinting"
X#define XtNdisplayPosition "displayPosition"
X#define XtNecho "echo"
X#define XtNemptyPixmap "emptyPixmap"
X#define XtNemptyPixmapMask "emptyPixmapMask"
X#define XtNflip "flip"
X#define XtNfont "font"
X#define XtNforceBars "forceBars"
X#define XtNforceColumns "forceColumns"
X#define XtNforeground "foreground"
X#define XtNfromHoriz "fromHoriz"
X#define XtNfromVert "fromVert"
X#define XtNfullPixmap "fullPixmap"
X#define XtNfullPixmapMask "fullPixmapMask"
X#define XtNgetValue "getValue"
X#define XtNgripCursor "gripCursor"
X#define XtNgripIndent "gripIndent"
X#define XtNgripTranslations "gripTranslations"
X#define XtNhSpace "hSpace"
X#define XtNhand "hands"
X#define XtNhighlight "highlight"
X#define XtNhighlightThickness "highlightThickness"
X#define XtNhorizDistance "horizDistance"
X#define XtNhorizontalBetweenCursor "horizontalBetweenCursor"
X#define XtNhorizontalGripCursor "horizontalGripCursor"
X#define XtNicon "icon"
X#define XtNinsensitiveBorder "insensitiveBorder"
X#define XtNinsertPosition "insertPosition"
X#define XtNinternalBorderColor "internalBorderColor"
X#define XtNinternalBorderWidth "internalBorderWidth"
X#define XtNinternalHeight "internalHeight"
X#define XtNinternalWidth "internalWidth"
X#define XtNjumpScroll "jumpScroll"
X#define XtNlabel "label"
X#define XtNlabelClass "labelClass"
X#define XtNleft "left"
X#define XtNleftBitmap "leftBitmap"
X#define XtNleftCursor "leftCursor"
X#define XtNleftMargin "leftMargin"
X#define XtNlineWidth "lineWidth"
X#define XtNlist "list"
X#define XtNlongest "longest"
X#define XtNlowerCursor "lowerCursor"
X#define XtNmax "max"
X#define XtNmenuName "menuName"
X#define XtNmenuOnScreen "menuOnScreen"
X#define XtNmin "min"
X#define XtNminScale "minScale"
X#define XtNminimumThumb "minimumThumb"
X#define XtNnumberStrings "numberStrings"
X#define XtNonceOnly "onceOnly"
X#define XtNpadding "padding"
X#define XtNpasteBuffer "pasteBuffer"
X#define XtNpieceSize "pieceSize"
X#define XtNpopupOnEntry "popupOnEntry"
X#define XtNposition "position"
X#define XtNpreferredPaneSize "preferredPaneSize"
X#define XtNradioData "radioData"
X#define XtNradioGroup "radioGroup"
X#define XtNrefigureMode "refigureMode"
X#define XtNresizable "resizable"
X#define XtNresize "resize"
X#define XtNresizeToPreferred "resizeToPreferred"
X#define XtNright "right"
X#define XtNrightBitmap "rightBitmap"
X#define XtNrightCursor "rightCursor"
X#define XtNrightMargin "rightMargin"
X#define XtNrowHeight "rowHeight"
X#define XtNrowSpacing "rowSpacing"
X#define XtNscale "scale"
X#define XtNscrollHorizontal "scrollHorizontal"
X#define XtNscrollVertical "scrollVertical"
X#define XtNselectTypes "selectTypes"
X#define XtNselection "selection"
X#define XtNshapeStyle "shapeStyle"
X#define XtNshapeWindow "shapeWindow"
X#define XtNshowGrip "showGrip"
X#define XtNskipAdjust "skipAdjust"
X#define XtNstate "state"
X#define XtNstipple "stipple"
X#define XtNtemplateResource "templateResource"
X#define XtNtop "top"
X#define XtNtopMargin "topMargin"
X#define XtNtopOfThumb "topOfThumb"
X#define XtNtype "type"
X#define XtNupdate "update"
X#define XtNupperCursor "upperCursor"
X#define XtNuseBottom "useBottom"
X#define XtNuseRight "useRight"
X#define XtNuseStringInPlace "useStringInPlace"
X#define XtNvSpace "vSpace"
X#define XtNvertDistance "vertDistance"
X#define XtNvertSpace "vertSpace"
X#define XtNverticalBetweenCursor "verticalBetweenCursor"
X#define XtNverticalGripCursor "verticalGripCursor"
X#define XtNverticalList "verticalList"
X#define XtNvmunix "vmunix"
X#define XtNvolume "volume"
X#define XtNwrap "wrap"
X#define XtRAsciiType "AsciiType"
X#define XtREdgeType "EdgeType"
X#define XtRResizeMode "ResizeMode"
X#define XtRScrollMode "ScrollMode"
X#define XtRShapeStyle "ShapeStyle"
X#define XtRTemplateResource "TemplateResource"
X#define XtRWidget "Widget"
X#define XtRWrapMode "WrapMode"
END_OF_FILE
if test 8195 -ne `wc -c <'etc/xaw.h'`; then
    echo shar: \"'etc/xaw.h'\" unpacked with wrong size!
fi
# end of 'etc/xaw.h'
fi
if test -f 'stat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stat.c'\"
else
echo shar: Extracting \"'stat.c'\" \(8201 characters\)
sed "s/^X//" >'stat.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr1/src/local/awl/RCS/stat.c,v 2.1 90/04/19 20:05:44 jkh Exp Locker: jkh $";
X#endif lint
X
X/*
X *
X *                     Copyright 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 * Return verbose description of stat struct. I'm not completely sure
X * that this Does The Right Thing for all cases under BSD and SYSV, but
X * I've done my best to handle the differences I know about. If you find
X * any holes, please tell me.
X *
X * $Log:	stat.c,v $
X * Revision 2.1  90/04/19  20:05:44  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:43:42  jkh
X * pre-beta check-in
X *
X */
X
X#include "AwlP.h"
X#include <pwd.h>
X#include <grp.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X/* Return a verbose description of mode */
Local String expand_mode(mode)
ushort mode;
X{
X     Local char modestr[12];
X     int i = 0;
X
X     /*
X      * On BSD systems, links are denoted with 'y', on SYSV they're 'l'.
X      * Also on BSD a setgid file without execute permission has an 'S'
X      * displayed. On SYSV, this means that mandatory locking is set and
X      * is indicated with an 'l'. If your system does something else,
X      * let me know.
X      */
X#ifdef BSD
X#define LINKCH	'l'
X#define NXGID	'S'
X#else
X#define LINKCH	'y'
X#define NXGID	'l'
X#endif
X     /*
X      * figure out the file type, taking various operating system
X      * conditionals into account.
X      */
X     if ((mode & S_IFMT) == S_IFDIR)
X	  modestr[0] = 'd';
X     else if ((mode & S_IFMT) == S_IFBLK)
X	  modestr[0] = 'b';
X     else if ((mode & S_IFMT) == S_IFCHR)
X	  modestr[0] = 'c';
X#ifdef S_IFLNK
X     else if ((mode & S_IFMT) == S_IFLNK)
X	  modestr[0] = LINKCH;
X#endif
X#ifdef S_IFIFO
X     else if ((mode & S_IFMT) == S_IFIFO)
X	  modestr[0] = 'p';
X#endif
X#ifdef S_IFSOCK
X     else if ((mode & S_IFMT) == S_IFSOCK)
X	  modestr[0] = 's';
X#endif
X     else
X	  modestr[0] = '-';
X     modestr[1] = (mode & (S_IREAD >> 0)) ? 'r' : '-';
X     modestr[2] = (mode & (S_IWRITE >> 0)) ? 'w' : '-';
X     modestr[3] = (mode & S_ISUID) ? (mode & (S_IEXEC >> 0)) ? 's' : 'S' :
X	  (mode & (S_IEXEC >> 0)) ? 'x' : '-';
X     modestr[4] = (mode & (S_IREAD >> 3)) ? 'r' : '-';
X     modestr[5] = (mode & (S_IWRITE >> 3)) ? 'w' : '-';
X     modestr[6] = (mode & S_ISGID) ? (mode & (S_IEXEC >> 3)) ? 's' : NXGID :
X	  (mode & (S_IEXEC >> 3)) ? 'x' : '-';
X     modestr[7] = (mode & (S_IREAD >> 6)) ? 'r' : '-';
X     modestr[8] = (mode & (S_IWRITE >> 6)) ? 'w' : '-';
X     modestr[9] = (mode & S_ISVTX) ? (mode & (S_IEXEC >> 3)) ? 't' : 'T' :
X	  (mode & (S_IEXEC >> 3)) ? 'x' : '-';
X     modestr[10] = '\0';
X     return(modestr);
X}
X
Local String file_part(s)
register String s;
X{
X     register String tmp;
X
X     if (s && *s) {
X	  tmp = s + strlen(s);
X	  while (tmp != s) {
X	       if (*tmp == '/')
X		    return(tmp + 1);
X	       else
X		    --tmp;
X	  }
X     }
X     else
X	  tmp = s;
X     return(tmp);
X}
X
X/*
X * Return an expanded representation of a stat buffer according to a
X * format string.
X */
XExport String stat_expand(aw, name, fmt, b)
AwlWidget aw;
String name, fmt;
struct stat *b;
X{
X     register char ch, op, datefmt[100];
X     String ret, tmp;
X     int i, max, aux;
X     struct group *gw;
X     struct passwd *pw;
X
X     ret = NULL;
X     i = max = 0;
X
X     if (!fmt)
X	  return NULL;
X
X     while (*fmt) {
X	  while ((ch = *(fmt++)) != '%') {
X	       append_string(&ret, &max, i++, ch);
X	       if (ch == '\0')
X		    return(ret);
X	  }
X	  op = (*fmt++);
X	  aux = 0;
X	  if (*fmt == '(') {
X	       ++fmt;
X	       while (*fmt && *fmt != ')')
X		    datefmt[aux++] = *(fmt++);
X	       datefmt[aux] = '\0';
X	       if (!*fmt) {
X		    exec_warn(aw, "Unterminated date format specifier.");
X		    return(NULL);
X	       }
X	       else
X		    ++fmt;	/* skip ')' */
X	  }
X	  switch (op) {
X	  case 'G':	/* group name */
X	       if ((gw = getgrgid(b->st_gid)) != NULL)
X		    i += sappend_string(&ret, &max, i, gw->gr_name);
X	       else
X		    i += sappend_string(&ret, &max, i,
X					numtoa(aw, b->st_gid, 0));
X	       break;
X
X	  case 'P':	/* verbose representation of protection bits */
X	       i += sappend_string(&ret, &max, i, expand_mode(b->st_mode));
X	       break;
X
X	  case 'U':	/* user name */
X	       if ((pw = getpwuid(b->st_uid)) != NULL)
X		    i += sappend_string(&ret, &max, i, pw->pw_name);
X	       else
X		    i += sappend_string(&ret, &max, i,
X					numtoa(aw, b->st_uid, 0));
X	       break;
X
X	  case 'a':	/* access time */
X	       if (aux) {
X		    if ((tmp = format_time(datefmt, b->st_atime)) != NULL) {
X			 i += sappend_string(&ret, &max, i, tmp);
X			 XtFree(tmp);
X		    }
X		    else
X			 i += sappend_string(&ret, &max, i, "<bad date fmt>");
X	       }
X	       else
X		    i += sappend_string(&ret, &max, i,
X					numtoa(aw, b->st_atime, 0));
X	       break;
X
X#if defined(BSD)
X	  case 'b':	/* file size in blocks */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_blocks, 0));
X	       break;
X#endif
X
X	  case 'c':	/* status change time */
X	       if (aux) {
X		    if ((tmp = format_time(datefmt, b->st_mtime)) != NULL) {
X			 i += sappend_string(&ret, &max, i, tmp);
X			 XtFree(tmp);
X		    }
X		    else
X			 i += sappend_string(&ret, &max, i, "<bad date fmt>");
X	       }
X	       else
X		    i += sappend_string(&ret, &max, i,
X					numtoa(aw, b->st_ctime, 0));
X	       break;
X
X	  case 'd':	/* device */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_dev, 0));
X	       break;
X
X	  case 'f':	/* file type */
X	       if ((b->st_mode & S_IFMT) == S_IFDIR)
X		    append_string(&ret, &max, i++, '/');
X#ifdef S_IFLNK
X	       else if ((b->st_mode & S_IFMT) == S_IFLNK)
X		    append_string(&ret, &max, i++, '@');
X#endif
X#ifdef S_IFSOCK
X	       else if ((b->st_mode & S_IFMT) == S_IFSOCK)
X		    append_string(&ret, &max, i++, '=');
X#endif
X	       else if (b->st_mode & (S_IEXEC|(S_IEXEC >> 3)|(S_IEXEC >> 6)))
X		    append_string(&ret, &max, i++, '*');
X	       break;
X
X	  case 'g':	/* group ID */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_gid, 0));
X	       break;
X
X	  case 'i':	/* inode */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_ino, 0));
X	       break;
X
X	  case 'l':	/* link count */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_nlink, 0));
X	       break;
X
X	  case 'm':	/* modify time */
X	       if (aux) {
X		    if ((tmp = format_time(datefmt, b->st_mtime)) != NULL) {
X			 i += sappend_string(&ret, &max, i, tmp);
X			 XtFree(tmp);
X		    }
X		    else
X			 i += sappend_string(&ret, &max, i, "<bad date fmt>");
X	       }
X	       else
X		    i += sappend_string(&ret, &max, i,
X					numtoa(aw, b->st_mtime, 0));
X	       break;
X
X	  case 'n':	/* file name */
X	       i += sappend_string(&ret, &max, i, file_part(name));
X	       break;
X
X	  case 'p':	/* protection mode */
X	       i += sappend_string(&ret, &max, i,
X				   numtoa(aw, b->st_mode, 0));
X	       break;
X
X	  case 'r':
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_rdev, 0));
X	       break;
X
X	  case 's':	/* file size in bytes */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_size, 0));
X	       break;
X
X	  case 't':	/* device type */
X	       break;
X
X	  case 'u':	/* user ID */
X	       i += sappend_string(&ret, &max, i, numtoa(aw, b->st_uid, 0));
X	       break;
X#if defined(BSD)
X	  case 'z':	/* block size of fs */
X	       i += sappend_string(&ret, &max, i,
X				   numtoa(aw, b->st_blksize, 0));
X	       break;
X#endif
X	  }
X     }
X     append_string(&ret, &max, i, '\0');
X     return(ret);
X}
END_OF_FILE
if test 8201 -ne `wc -c <'stat.c'`; then
    echo shar: \"'stat.c'\" unpacked with wrong size!
fi
# end of 'stat.c'
fi
if test -f 'symbols.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'symbols.c'\"
else
echo shar: Extracting \"'symbols.c'\" \(8228 characters\)
sed "s/^X//" >'symbols.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/symbols.c,v 2.4 90/04/19 20:05:51 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 functions for manipulating "symbols" in awl.
X * Each symbol can contain its own table of symbols (alists) with a special
X * purpose symbol alist (Symbol_top) being used to implement the global
X * symbol table.
X *
X * $Log:	symbols.c,v $
X * Revision 2.4  90/04/19  20:05:51  jkh
X * Alpha checkin.
X * 
X * Revision 2.3  90/03/31  06:20:35  jkh
X * Fixed Yet Another Typo.
X * 
X * Revision 2.2  90/03/31  05:51:56  jkh
X * Fixed typo.
X * 
X * Revision 2.1  90/03/31  05:49:45  jkh
X * Changed the way register symbols are printed.
X * 
X * Revision 2.0  90/03/26  01:43:50  jkh
X * pre-beta check-in
X *
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
Local Symbol LocalParmList;
X
Local int symbol_free_contents();
Local void symbol_free();
X
X/* Return a terse description of a symbol */
XExport String symbol_printname(sym)
Symbol sym;
X{
X     Local char prtname[256];
X
X     /* limit it to 200 just to be safe, however unlikely */
X     strncpy(prtname, symbol_name(sym), 200);
X     prtname[200] = '\0';
X     if (symbol_is_register(sym)) {
X	  strcat(prtname, ":");
X	  strcat(prtname, type_name(symbol_type(sym)));
X	  sprintf(prtname + strlen(prtname), "%+d", symbol_int(sym));
X     }
X     return(prtname);
X}
X
X/* Allocate space for symbol named "name" of type "type". */
XExport Inline Symbol symbol_new(aw, name, type)
AwlWidget aw;
String name;
int type;
X{
X     Symbol ret;
X
X     ret = (Symbol)XtMalloc(symbol_size);
X     bzero(ret, symbol_size);
X     symbol_name(ret) = XtNewString(name);
X     /* some reasonable defaults */
X     symbol_root(ret) = aw;
X     symbol_class(ret) = DATA;
X     symbol_type(ret) = type;
X     symbol_parent(ret) = awl_top(aw);
X     return(ret);
X}
X
X/*
X * Free just the storage for a symbol's contents, returning 1 if this
X * is possible, 0 if not.
X */
Local Inline int symbol_free_contents(sym)
Symbol sym;
X{
X     /*
X      * If it's an allocated type, then the contents were malloc'd
X      * and should be free'd, unless the symbol is precious.
X      */
X     if (is_allocated_type(symbol_type(sym)) && !symbol_is_precious(sym)) {
X	  do_free(&symbol_value(sym));
X	  /* If it has an alist, free it */
X	  if (symbol_alist(sym))
X	       hash_purge(symbol_alist(sym), symbol_free);
X	  return(1);
X     }
X     else
X	  return(0);
X}
X	  
X/* Free a symbol's storage. */
Local Inline void symbol_free(sym)
Symbol sym;
X{
X     if (symbol_free_contents(sym)) {
X	  debug(symbol_root(sym), "symbol_free: nuking %s\n",
X		symbol_name(sym));
X	  XtFree(symbol_name(sym));
X	  XtFree(sym);
X     }
X}
X     
X/* Add a symbol to a symbol table. */
XExport Inline void symbol_add(sym)
Symbol sym;
X{
X     debug(symbol_root(sym), "symbol_add: Adding %s to table %0#x",
X	   symbol_name(sym), symbol_parent(sym));
X     hash_search(symbol_parent(sym), symbol_name(sym), sym,
X		 symbol_free_contents);
X}
X
XExport Inline void symbol_set_locals(s)
Symbol s;
X{
X     Symbol tmp = LocalParmList;
X
X     if (s) {
X	  if (tmp) {
X	       while (symbol_next(tmp))
X		    tmp = symbol_next(tmp);
X	       symbol_next(tmp) = s;
X	  }
X	  else 
X	       LocalParmList = s;
X     }
X     else
X	  LocalParmList = NULL;
X}
X
X/* Remove a symbol from a symbol table and free it. */
XExport Inline void symbol_remove(aw, sym)
AwlWidget aw;
Symbol sym;
X{
X     debug(aw, "symbol_remove: Removing %s from table %0#x",
X	   symbol_name(sym), symbol_parent(sym));
X     hash_destroy(symbol_parent(sym), symbol_name(sym), symbol_free);
X}
X
X/* Find a symbol in the symbol table. */
XExport Symbol symbol_find(aw, name)
AwlWidget aw;
String name;
X{
X     Symbol ret;
X
X     if (!name)
X	  return(NULL);
X
X     if (LocalParmList) {	/* search these first */
X	  Symbol tmp = LocalParmList;
X	  
X	  while (tmp) {
X	       if (!strcmp(symbol_name(tmp), name))
X		    return(tmp);
X	       else
X		    tmp = symbol_next(tmp);
X	  }
X     }
X     ret = (Symbol)hash_search(awl_top(aw), name, NULL, NULL);
X     return(ret);
X}
X
X/* look to see if a given name is a special widget class */
XExport Inline WidgetClass lookup_client_wclass(aw, name)
AwlWidget aw;
String name;
X{
X     Symbol tmp;
X
X     tmp = symbol_find(aw, name);
X     if (tmp && symbol_class(tmp) == CONSTANT && symbol_type(tmp) == WCLASS)
X	  return(symbol_wclass(tmp));
X     else
X	  return((WidgetClass)NULL);
X}
X
X/* Find a value in another symbol's alist */
XExport Symbol symbol_alist_find(sym, val, addp)
Symbol sym;
Value val;
int addp;
X{
X     Symbol ret;
X     String name;
X     AwlWidget aw;
X
X     aw = symbol_root(sym);
X     name = value_string_value(aw, val);
X     if (!symbol_alist(sym)) {
X	  if ((symbol_alist(sym) = hash_create(ALIST_HASH_SIZE)) == NULL)
X	       exec_error(aw, "Couldn't create hash table for alist!");
X     }
X     /* look for it */
X
X     ret = (Symbol)hash_search(symbol_alist(sym), name, NULL, NULL);
X     debug(aw, "alist_find: Search for %s returns %d", name, ret);
X     if (addp && !ret) {
X	  ret = symbol_new(aw, name, STRING);
X	  value_set(symbol_value(ret), DATA, STRING, aobj,
X		    new_aobj(XtNewString(name)));
X	  symbol_parent(ret) = symbol_alist(sym);
X	  hash_search(symbol_alist(sym), name, ret, NULL);
X     }
X     return(ret);
X}
X
X/* Add a function to the symbol table, declaring it undefined. */
XExport Inline Symbol symbol_add_function(aw, n)
AwlWidget aw;
String n;
X{
X     Symbol tmp;
X
X     tmp = symbol_new(aw, n, FUNC_UNDEF);
X     symbol_class(tmp) = FUNCTION;
X     symbol_function(tmp) = (Function)XtMalloc(function_size);
X     function_uaddr(symbol_function(tmp)) = UNDEF_ADDR;
X     function_nparms(symbol_function(tmp)) =
X	  function_nlocals(symbol_function(tmp)) = 0;
X     symbol_add(tmp);
X     return(tmp);
X}
X
X/* Define function in the symbol table. */
XExport Symbol symbol_def_function(aw, n, type, nparms, fp, checkp)
AwlWidget aw;
String n;
int type, nparms;
Address fp;
Boolean checkp;
X{
X     Symbol tmp;
X     Function f;
X
X     /* See if it was already allocated through a forward ref */
X     if (checkp && (tmp = symbol_find(aw, n)) != NULL) {
X	  if (!symbol_is_function(tmp)) {
X	       exec_error(aw, "Attempt to redefine symbol '%s' as function.",
X			  symbol_name(tmp));
X	       return(NULL);
X	  }
X	  if (symbol_type(tmp) != FUNC_UNDEF) {
X	       exec_error(aw, "'%s' is already defined as a %s function.",
X			  symbol_type(tmp) == FUNC_BUILTIN ? "system" : "user",
X			  symbol_name(tmp));
X	       return(NULL);
X	  }
X     }
X     else
X	  tmp = symbol_add_function(aw, n);
X     symbol_type(tmp) = type;
X     f = symbol_function(tmp);
X     function_addr(f) = fp;
X     function_nparms(f) = nparms;
X     return(tmp);
X}
X
X/* define a constant in the symbol table */
XExport void symbol_def_constant(aw, n, type, val)
AwlWidget aw;
String n;
int type;
Datum val;
X{
X     Symbol tmp;
X
X     if (type) {
X	  tmp = symbol_new(aw, n, type);
X	  symbol_class(tmp) = CONSTANT;
X	  symbol_data(tmp) = val;
X     }
X     else {
X	  /* it's a string name constant */
X	  tmp = symbol_new(aw, n, STRING);
X	  symbol_class(tmp) = CONSTANT;
X	  symbol_aobj(tmp) = new_aobj(n);
X     }
X     symbol_add(tmp);
X}
X
X/* define a user-setable variable in the symbol table */
XExport void symbol_def_variable(aw, n, type, val)
AwlWidget aw;
String n;
int type;
Generic val;
X{
X     Symbol tmp;
X
X     tmp = symbol_new(aw, n, type);
X     symbol_class(tmp) = DATA;
X     symbol_any(tmp) = val;
X     symbol_add(tmp);
X}
END_OF_FILE
if test 8228 -ne `wc -c <'symbols.c'`; then
    echo shar: \"'symbols.c'\" unpacked with wrong size!
fi
# end of 'symbols.c'
fi
echo shar: End of archive 4 \(of 17\).
cp /dev/null ark4isdone
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.