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

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

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

#! /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 6 (of 17)."
# Contents:  Awl.c COPYING regex.h xtkrtns.c
# Wrapped by vixie@jove.pa.dec.com on Mon Apr 30 01:25:22 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Awl.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Awl.c'\"
else
echo shar: Extracting \"'Awl.c'\" \(13050 characters\)
sed "s/^X//" >'Awl.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/Awl.c,v 2.1 90/04/19 20:04:01 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 * AWL itself is spread over many files, however all internal data and
X * awl public functions are declared here.
X *
X * $Log:	Awl.c,v $
X * Revision 2.1  90/04/19  20:04:01  jkh
X * Alpha checkin.
X * 
X * Revision 2.0  90/03/26  01:42:04  jkh
X * pre-beta check-in
X * 
X */
X
X/* #include <X11/AwlP.h> */
X#include "AwlP.h"
X#include "y.tab.h"
X
X#define offset(name)    XtOffset(AwlWidget, awl.res.name)
X
Local XtResource awlResources[] = {
X     {XgNcppArg,  XgCCppArg,		XtRString,	sizeof(String),
X	   offset(cpp_args),		XtRString,	" "},
X     {XgNcppCommand,	XgCCppCommand,	XtRString,	sizeof(String),
X	   offset(cpp_command),		XtRString,	XgDefaultCppCommand},
X     {XgNdebug,		XgCDebug,	XtRBoolean,	sizeof(Boolean),
X           offset(debug),		XtRImmediate,	(caddr_t)False},
X     {XgNexternList,	XgCExternList,	XtRPointer,	sizeof(AwlExternList),
X	   offset(externlist),		XtRPointer,	NULL},
X     {XgNfile,		XgCFile,	XtRString,	sizeof(String),
X	   offset(file),		XtRString,	NULL},
X     {XgNline,		XgCLine,	XtRBoolean,	sizeof(Boolean),
X	   offset(lineinfo),		XtRImmediate,	(caddr_t)False},
X     {XgNmainArgv,	XgCMainArgv,	XtRStringArray,	sizeof(String *),
X	   offset(argv),		XtRImmediate,	NULL},
X     {XgNnoWarn,	XgCNoWarn,	XtRBoolean,	sizeof(Boolean),
X	   offset(nowarn),		XtRImmediate,	(caddr_t)False},
X     {XgNshow,		XgCShow,	XtRBoolean,	sizeof(Boolean),
X	   offset(showasm),		XtRImmediate,	(caddr_t)False},
X     {XgNstart,		XgCStart,	XtRString,	sizeof(String),
X	   offset(startfunc),		XtRString,	"main"},
X     {XgNtrace,		XgCTrace,	XtRBoolean,	sizeof(Boolean),
X	   offset(trace),		XtRImmediate,	(caddr_t)False},
X     {XgNversion,	XgCVersion,	XtRBoolean,	sizeof(Boolean),
X	   offset(version),		XtRImmediate,	(caddr_t)False},
X};
X
X#undef offset
X
Local void Initialize(), Destroy(), clean_house();
Local Boolean SetValues();
X
XExport AwlClassRec awlClassRec = {
X  { /* core fields */
X    /* superclass		*/	(WidgetClass) &topLevelShellClassRec,
X    /* class_name		*/	"Awl",
X    /* widget_size		*/	sizeof(AwlRec),
X    /* class_initialize		*/	NULL,
X    /* class_part_initialize	*/	NULL,
X    /* class_inited		*/	False,
X    /* initialize		*/	Initialize,
X    /* initialize_hook		*/	NULL,
X    /* realize			*/	XtInheritRealize,
X    /* actions			*/	NULL,
X    /* num_actions		*/	0,
X    /* resources		*/	awlResources,
X    /* num_resources		*/	XtNumber(awlResources),
X    /* xrm_class		*/	NULLQUARK,
X    /* compress_motion		*/	True,
X    /* compress_exposure	*/	True,
X    /* compress_enterleave	*/	True,
X    /* visible_interest		*/	False,
X    /* destroy			*/	Destroy,
X    /* resize			*/	XtInheritResize,
X    /* expose			*/	XtInheritExpose,
X    /* set_values		*/	SetValues,
X    /* set_values_hook		*/	NULL,
X    /* set_values_almost	*/	XtInheritSetValuesAlmost,
X    /* get_values_hook		*/	NULL,
X    /* accept_focus		*/	XtInheritAcceptFocus,
X    /* version			*/	XtVersion,
X    /* callback_private		*/	NULL,
X    /* tm_table			*/	NULL,
X    /* query_geometry		*/	XtInheritQueryGeometry,
X    /* display_accelerator	*/	XtInheritDisplayAccelerator,
X    /* extension		*/	NULL
X  },
X  { /* composite fields */
X    /* geometry_manager */	XtInheritGeometryManager,
X    /* change_managed	*/	XtInheritChangeManaged,
X    /* insert_child	*/	XtInheritInsertChild,
X    /* delete_child	*/	XtInheritDeleteChild,
X    /* extension	*/	NULL
X  },
X  { /* shell fields	*/
X    /* extension	*/	NULL
X  },
X  { /* wmshell fields	*/
X    /* extension	*/	NULL
X  },
X  { /* vendorshell fields */
X    /* extension	*/	NULL
X  },
X  { /* toplevelshell fields */
X    /* extension	*/	NULL
X  },
X  { /* awl fields	*/
X    /* empty		*/	0
X  }
X};
X
XExport WidgetClass awlWidgetClass = (WidgetClass)&awlClassRec;
X
X/* VARARGS */
XExport caddr_t awl_call(va_alist)
va_dcl
X{
X     va_list ap;
X     AwlWidget aw;
X     String func;
X     Value val;
X     Symbol f;
X     char *lpar, *rpar, *tmp;
X     int type = ANY, uns = FALSE;
X
X     va_start(ap);
X     aw = va_arg(ap, AwlWidget);
X     tmp = va_arg(ap, String);
X     func = tmp = XtNewString(tmp);
X
X     debug(aw, "awl_call: Invoking '%s' as start func", tmp);
X     do_link(aw);
X     lpar = index(func, '(');
X     rpar = rindex(func, ')');
X     if (lpar && rpar) {
X	  int state = 0;
X
X	  *lpar = '\0';
X	  while (++lpar < rpar) {
X	       switch (*lpar) {
X	       case '%':
X		    state = 1;
X		    break;
X
X	       case 'a':
X		    if (state) {
X			 debug(aw, "awl_call: pushing a generic parameter");
X			 value_set(val, DATA, ANY, any, va_arg(ap, Generic));
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%CHAR' in format");
X		    break;
X
X	       case 'c':
X		    if (state) {
X			 debug(aw, "awl_call: pushing a char parameter");
X			 value_set(val, DATA, CHAR, char, va_arg(ap, char));
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%CHAR' in format");
X		    break;
X
X	       case 'h':
X		    state = 2;
X		    break;
X
X	       case 'l':
X		    state = 4;
X		    break;
X
X	       case 'd': case 'i': case 'o': case 'O':
X	       case 'u': case 'x': case 'X':
X		    if (state) {
X			 int tmp;
X
X			 if (*lpar == 'u')
X			      uns = TRUE;
X			 else
X			      uns = FALSE;
X			 if (state == 1) {
X			      if (!uns)
X				   tmp = va_arg(ap, int);
X			      else
X				   tmp = va_arg(ap, unsigned int);
X			 }
X			 else if (state == 2) {
X			      if (!uns)
X				   tmp = (int)va_arg(ap, short);
X			      else
X				   tmp = (int)va_arg(ap, unsigned short);
X			 }
X			 else {
X			      if (!uns)
X				   tmp = (int)va_arg(ap, long);
X			      else
X				   tmp = (int)va_arg(ap, unsigned long);
X			 }
X			 debug(aw, "awl_call: pushing an int/%d parameter",
X			       state);
X			 value_set(val, DATA, INT, int, tmp);
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%INT' in format");
X		    break;
X
X	       case 'e': case 'E': case 'f': case 'g': case 'G':
X		    if (state) {
X			 debug(aw, "awl_call: pushing a float parameter");
X			 value_set(val, DATA, FLOAT, float, va_arg(ap, float));
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%FLOAT' in format");
X		    break;
X
X	       case 's':
X		    if (state) {
X			 debug(aw, "awl_call: pushing a string parameter");
X			 value_set(val, STATIC, STRING, aobj,
X				   new_aobj(va_arg(ap, String)));
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%STRING' in format");
X		    break;
X
X	       case 'L':
X		    if (state) {
X			 debug(aw, "awl_call: pushing a list parameter");
X			 value_set(val, STATIC, LIST, aobj,
X				   new_aobj(va_arg(ap, String *)));
X			 push(aw, val);
X			 state = 0;
X		    }
X		    else
X			 exec_warn(aw, "awl_call: Bad '%LIST' in format");
X		    break;
X
X	       case '0': case '1': case '2': case '3': case '4':
X	       case '5': case '6': case '7': case '8': case '9':
X		    /* simply ignore numbers unless they're bogus */
X		    if (!state)
X			 exec_warn(aw, "awl_call: Bad number in format");
X		    break;
X
X		    /* same for decimal points */
X	       case '.':
X		    if (!state)
X			 exec_warn(aw,
X				   "awl_call: Bogus decimal point in format");
X		    break;
X
X	       case ',':
X	       case ' ':
X		    break;
X
X	       default:
X		    exec_warn(aw, "awl_call: Bad char '%c' in format", *lpar);
X		    break;
X	       }
X	  }
X     }
X     /* skip any leading spaces */
X     func = skip_whitespace(func);
X     if (*func == '%') {
X	  switch (*(++func)) {
X	  case 'c':
X	       type = CHAR;
X	       break;
X
X	  case 'd': case 'i': case 'o': case 'O':
X	  case 'u': case 'x': case 'X':
X	       type = INT;
X	       break;
X
X	  case 'e': case 'E': case 'f': case 'g': case 'G':
X	       type = FLOAT;
X	       break;
X
X	  case 's':
X	       type = FLOAT;
X	       break;
X	  }
X	  /* skip any trailing spaces */
X	  func = skip_whitespace(func);
X	  debug(aw, "awl_call: return value type set to %s", type_name(type));
X     }
X     if ((f = symbol_find(aw, func)) != NULL) {
X	  if (symbol_is_function(f))
X	       val = coerce(aw, Eval(f), type);
X	  else
X	       exec_error(aw, "startfunc '%s' is type '%s', not function!",
X			  func, type_name(symbol_type(f)));
X     }
X     else
X	  exec_error(aw, "Can't find startfunc named '%s'", func);
X     va_end(ap);
X     XtFree(tmp);
X
X     switch (type) {
X     case CHAR:
X	  return((caddr_t)value_char(val));
X     case INT:
X	  return((caddr_t)value_int(val));
X     case FLOAT:
X	  {
X	       static float ftemp;
X
X	       ftemp = value_float(val);
X	       return((caddr_t)&ftemp);
X	  }
X     AOBJCASE:
X	  return((caddr_t)aobj_ptr(value_aobj(val)));
X     default:
X	  return((caddr_t)value_any(val));
X     }
X}
X
Local void Initialize(request, new)
Widget request;
Widget new;
X{
X     AwlWidget aw = (AwlWidget)new;
X     Import int setjmp();
X
X     /* Initialize the AWL universe */
X     do_init(aw);
X
X     /* deal with any special resources */
X     if (awl_externlist(aw))
X	  do_externs(aw, awl_externlist(aw));
X
X     /* give us a place to bomb out to */
X     if (setjmp(awl_bomb(aw))) {
X	  clean_house(aw);
X	  return;
X     }
X      /* if a start function exists, call it */
X     if (!parseFile(aw, awl_file(aw))) {
X	  if (awl_startfunc(aw)) {
X	       if (!awl_mainargv(aw))
X		    awl_call(aw, awl_startfunc(aw));
X	       else {
X		    char cmd[512];
X
X		    strcpy(cmd, awl_startfunc(aw));
X		    strcat(cmd, "(%d %L)");
X		    awl_call(aw, cmd, list_len(awl_mainargv(aw)),
X			     awl_mainargv(aw));
X	       }
X	  }
X     }
X}
X
Local void Destroy(w)
Widget w;
X{
X     AwlWidget aw = (AwlWidget)w;
X
X     debug(aw, "Destroying awl widget '%x'", aw);
X     clean_house(aw);
X}
X
Local Boolean SetValues(current, request, new)
Widget current, request, new;
X{
X     AwlWidget cw = (AwlWidget)current;
X     AwlWidget nw = (AwlWidget)new;
X
X     if (awl_file(cw) != awl_file(nw) ||
X	  strcomp(awl_file(cw), awl_file(nw)))
X	  parseFile(nw, awl_file(nw));
X     if (awl_externlist(cw) != awl_externlist(nw))
X	  do_externs(nw, awl_externlist(nw));
X     return(FALSE);
X}
X
X/*
X * Awl public functions.
X */
X
X/*
X * Set a breakpoint.
X */
XExport void awl_break_set(aw, addr, func)
AwlWidget aw;
int addr;
int (*func)();
X{
X     Breakpoint tmp;
X
X     if (awl_bkpts(aw) == NULL)
X	  awl_bkpts(aw) = tmp = new_bkpt();
X     else {
X	  tmp = new_bkpt();
X	  bkpt_next(tmp) = awl_bkpts(aw);
X	  awl_bkpts(aw) = tmp;
X     }
X     bkpt_addr(tmp) = addr;
X     bkpt_func(tmp) = func;
X     bkpt_enable(tmp) = TRUE;
X     debug(aw, "awl_break_set: breakpoint set at %d to function %x",
X	   addr, func);
X}
X
XExport void awl_break_delete(aw, addr)
AwlWidget aw;
int addr;
X{
X     Breakpoint tmp, tmp2;
X
X     if ((tmp = awl_bkpts(aw)) == NULL)
X	  XtWarning("awl_break_delete: No breakpoints set");
X     else if (bkpt_addr(tmp) == addr) {
X	  XtFree(awl_bkpts(aw));
X	  awl_bkpts(aw) = NULL;
X     }
X     else {
X	  while (tmp) {
X	       if (bkpt_addr(tmp) == addr) {
X		    bkpt_next(tmp2) = bkpt_next(tmp);
X		    XtFree(tmp);
X		    return;
X	       }
X	       tmp2 = tmp;
X	       tmp = bkpt_next(tmp);
X	  }
X	  fprintf(stderr, "awl_break_delete: No breakpoint at addr %d\n",
X		  addr);
X     }
X}
X
Local void set_enable_state(aw, addr, state)
AwlWidget aw;
int addr;
Boolean state;
X{
X     Breakpoint tmp;
X
X     tmp = awl_bkpts(aw);
X     while (tmp) {
X	  if (bkpt_addr(tmp) == addr) {
X	       bkpt_enable(tmp) = state;
X	       return;
X	  }
X	  tmp = bkpt_next(tmp);
X     }
X     fprintf(stderr, "%s: No breakpoint at addr %d\n",
X	     state ? "awl_break_enable" : "awl_break_disable", addr);
X}
X
XExport void awl_break_enable(aw, addr)
AwlWidget aw;
int addr;
X{
X     set_enable_state(aw, addr, TRUE);
X}
X
XExport void awl_break_disable(aw, addr)
AwlWidget aw;
int addr;
X{
X     set_enable_state(aw, addr, FALSE);
X}
X
X/*
X * This is sort of like a soft reset. First we buzz through the symbol
X * table and remove everything in sight, then we free up the stack and
X * data segments and reset all our pointers. Active layouts are
X * destroyed, any open files are closed and executing subprocesses
X * are delicately killed with a sledgehammer.
X */
X
X/* This is far from finished.. It's more of a place-holder at the moment */
Local void clean_house(aw)
AwlWidget aw;
X{
X     awl_lastpc(aw) = awl_fp(aw) = awl_sp(aw) = awl_pc(aw) = 0;
X}
X  
END_OF_FILE
if test 13050 -ne `wc -c <'Awl.c'`; then
    echo shar: \"'Awl.c'\" unpacked with wrong size!
fi
# end of 'Awl.c'
fi
if test -f 'COPYING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'COPYING'\"
else
echo shar: Extracting \"'COPYING'\" \(12488 characters\)
sed "s/^X//" >'COPYING' <<'END_OF_FILE'
X
X		    GNU GENERAL PUBLIC LICENSE
X		     Version 1, February 1989
X
X Copyright (C) 1989 Free Software Foundation, Inc.
X                    675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X			    Preamble
X
X  The license agreements of most software companies try to keep users
at the mercy of those companies.  By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
X
X  When we speak of free software, we are referring to freedom, not
price.  Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
X
X  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
X
X  For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must tell them their rights.
X
X  We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
X
X  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
X
X  The precise terms and conditions for copying, distribution and
modification follow.
X
X		    GNU GENERAL PUBLIC LICENSE
X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X  0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License.  The
X"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications.  Each
licensee is addressed as "you".
X
X  1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program.  You may charge a fee for the physical act of
transferring a copy.
X
X  2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
X1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating that
X    you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish, that
X    in whole or in part contains the Program or any part thereof, either
X    with or without modifications, to be licensed at no charge to all
X    third parties under the terms of this General Public License (except
X    that you may choose to grant warranty protection to some or all
X    third parties, at your option).
X
X    c) If the modified program normally reads commands interactively when
X    run, you must cause it, when started running for such interactive use
X    in the simplest and most usual way, to print or display an
X    announcement including an appropriate copyright notice and a notice
X    that there is no warranty (or else, saying that you provide a
X    warranty) and that users may redistribute the program under these
X    conditions, and telling the user how to view a copy of this General
X    Public License.
X
X    d) You may charge a fee for the physical act of transferring a
X    copy, and you may at your option offer warranty protection in
X    exchange for a fee.
X
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
X
X  3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal charge
X    for the cost of distribution) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
Source code for a work means the preferred form of the work for making
modifications to it.  For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
X
X  4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License.  However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
X
X  5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
X
X  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions.  You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
X
X  7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
X
XEach version is given a distinguishing version number.  If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
XFoundation.
X
X  8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
X
X			    NO WARRANTY
X
X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
X
X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
X
X		     END OF TERMS AND CONDITIONS
X
X	Appendix: How to Apply These Terms to Your New Programs
X
X  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
X
X  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X    <one line to give the program's name and a brief idea of what it does.>
X    Copyright (C) 19yy  <name of author>
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
Also add information on how to contact you by electronic and paper mail.
X
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
X
X    Gnomovision version 69, Copyright (C) 19xx name of author
X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
X    This is free software, and you are welcome to redistribute it
X    under certain conditions; type `show c' for details.
X
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
X
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here a sample; alter the names:
X
X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
X  program `Gnomovision' (a program to direct compilers to make passes
X  at assemblers) written by James Hacker.
X
X  <signature of Ty Coon>, 1 April 1989
X  Ty Coon, President of Vice
X
That's all there is to it!
END_OF_FILE
if test 12488 -ne `wc -c <'COPYING'`; then
    echo shar: \"'COPYING'\" unpacked with wrong size!
fi
# end of 'COPYING'
fi
if test -f 'regex.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'regex.h'\"
else
echo shar: Extracting \"'regex.h'\" \(12869 characters\)
sed "s/^X//" >'regex.h' <<'END_OF_FILE'
X#ifndef REGEX_H_INCLUDE
X#define REGEX_H_INCLUDE
X
X/* $Header: /usr/src/local/awl/RCS/regex.h,v 2.0 90/03/26 01:44:37 jkh Exp $ */
X
X/* Definitions for data structures callers pass the regex library.
X   Copyright (C) 1985 Free Software Foundation, Inc.
X
X		       NO WARRANTY
X
X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
X
X		GENERAL PUBLIC LICENSE TO COPY
X
X  1. You may copy and distribute verbatim copies of this source file
as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy a valid copyright notice "Copyright
X(C) 1985 Free Software Foundation, Inc."; and include following the
copyright notice a verbatim copy of the above disclaimer of warranty
and of this License.  You may charge a distribution fee for the
physical act of transferring a copy.
X
X  2. You may modify your copy or copies of this source file or
any portion of it, and copy and distribute such modifications under
the terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of this
X    program or any part thereof, to be licensed at no charge to all
X    third parties on terms identical to those contained in this
X    License Agreement (except that you may choose to grant more extensive
X    warranty protection to some or all third parties, at your option).
X
X    c) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
Mere aggregation of another unrelated program with this program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other program under the scope of these terms.
X
X  3. You may copy and distribute this program (or a portion or derivative
of it, under Paragraph 2) in object code or executable form under the terms
of Paragraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal
X    shipping charge) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XFor an executable file, complete source code means all the source code for
all modules it contains; but, as a special exception, it need not include
source code for modules which are standard libraries that accompany the
operating system on which the executable file runs.
X
X  4. You may not copy, sublicense, distribute or transfer this program
except as expressly provided under this License Agreement.  Any attempt
otherwise to copy, sublicense, distribute or transfer this program is void and
your rights to use the program under this License agreement shall be
automatically terminated.  However, parties who have received computer
software programs from you with this License Agreement will not have
their licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of this program into other free
programs whose distribution conditions are different, write to the Free
Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
worked out a simple rule that can be stated here, but we will often permit
this.  We will be guided by the two goals of preserving the free status of
all derivatives of our free software and of promoting the sharing and reuse of
software.
X
X
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them.   Help stamp out software-hoarding!  */
X
X/* Define number of parens for which we record the beginnings and ends.
X   This affects how much space the `struct re_registers' type takes up.  */
X#ifndef RE_NREGS
X#define RE_NREGS 10
X#endif
X
X#ifndef BYTEWIDTH
X#define BYTEWIDTH	8
X#endif
X
X/* These bits are used in the obscure_syntax variable to choose among
X   alternative regexp syntaxes.  */
X
X/* 1 means plain parentheses serve as grouping, and backslash
X     parentheses are needed for literal searching.
X   0 means backslash-parentheses are grouping, and plain parentheses
X     are for literal searching.  */
X#define RE_NO_BK_PARENS 1
X
X/* 1 means plain | serves as the "or"-operator, and \| is a literal.
X   0 means \| serves as the "or"-operator, and | is a literal.  */
X#define RE_NO_BK_VBAR 2
X
X/* 0 means plain + or ? serves as an operator, and \+, \? are literals.
X   1 means \+, \? are operators and plain +, ? are literals.  */
X#define RE_BK_PLUS_QM 4
X
X/* 1 means | binds tighter than ^ or $.
X   0 means the contrary.  */
X#define RE_TIGHT_VBAR 8
X
X/* 1 means treat \n as an _OR operator
X   0 means treat it as a normal character */
X#define RE_NEWLINE_OR 16
X
X/* 0 means that a special characters (such as *, ^, and $) always have
X     their special meaning regardless of the surrounding context.
X   1 means that special characters may act as normal characters in some
X     contexts.  Specifically, this applies to:
X	^ - only special at the beginning, or after ( or |
X	$ - only special at the end, or before ) or |
X	*, +, ? - only special when not after the beginning, (, or | */
X#define RE_CONTEXT_INDEP_OPS 32
X
X/* Now define combinations of bits for the standard possibilities.  */
X#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
X#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
X#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
X#define RE_SYNTAX_EMACS 0
X
X/* This data structure is used to represent a compiled pattern. */
X
struct re_pattern_buffer
X{
X    char *buffer;	/* Space holding the compiled pattern commands. */
X    int allocated;	/* Size of space that  buffer points to */
X    int used;		/* Length of portion of buffer actually occupied */
X    char *fastmap;	/* Pointer to fastmap, if any, or zero if none.
X			 * re_search uses the fastmap, if there is one,
X			 * to skip quickly over totally implausible
X 			 * characters.
X			 */
X    char *translate;	/* Translate table to apply to all characters before
X 			 * comparing, or zero for no translation.
X			 * The translation is applied to a pattern when it
X 			 * is compiled and to data when it is matched.
X 			 */
X    char fastmap_accurate;
X			/* Set to zero when a new pattern is stored,
X			 * set to one when the fastmap is updated from it.
X			 */
X    char can_be_null;   /* Set to one by compiling fastmap
X			 * if this pattern might match the null string.
X			 * It does not necessarily match the null string
X			 * in that case, but if this is zero, it cannot.
X			 * 2 as value means can match null string
X			 * but at end of range or before a character
X			 * listed in the fastmap.
X			 */
X};
X
X/* Structure to store "register" contents data in.
X
X   Pass the address of such a structure as an argument to re_match, etc.,
X   if you want this information back.
X
X   start[i] and end[i] record the string matched by \( ... \) grouping i,
X   for i from 1 to RE_NREGS - 1.
X   start[0] and end[0] record the entire string matched. */
X
struct re_registers
X{
X    int start[RE_NREGS];
X    int end[RE_NREGS];
X};
X
X/* These are the command codes that appear in compiled regular expressions, one per byte.
X  Some command codes are followed by argument bytes.
X  A command code can specify any interpretation whatever for its arguments.
X  Zero-bytes may appear in the compiled regular expression. */
X
enum regexpcode
X{
X    unused,
X    exactn,    /* followed by one byte giving n, and then by n literal bytes */
X    begline,   /* fails unless at beginning of line */
X    endline,   /* fails unless at end of line */
X    jump,      /* followed by two bytes giving relative address to jump to */
X    on_failure_jump,	 /* followed by two bytes giving relative address
X			  * of place to resume at in case of failure.
X			  */
X    finalize_jump,	 /* Throw away latest failure point and then jump
X			  * to address.
X			  */
X    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
X			  * This is used to jump back to the beginning
X			  * of a repeat.  If the command that follows
X			  * this jump is clearly incompatible with the
X			  * one at the beginning of the repeat, such that
X			  * we can be sure that there is no use backtracking
X			  * out of repetitions already completed,
X			  * then we finalize.
X			  */
X    dummy_failure_jump,  /* jump, and push a dummy failure point.
X			  * This failure point will be thrown away
X			  * if an attempt is made to use it for a failure.
X			  * A + construct makes this before the first repeat.
X			  */
X    anychar,	 /* matches any one character */
X    charset,     /* matches any one char belonging to specified set.
X		  * First following byte is # bitmap bytes.
X		  * Then come bytes for a bit-map saying which chars are in.
X		  * Bits in each byte are ordered low-bit-first.
X		  * A character is in the set if its bit is 1.
X		  * A character too large to have a bit in the map
X		  * is automatically not in the set
X		  */
X    charset_not, /* similar but match any character that is NOT one of those
X		  * specified
X		  */
X    start_memory,/* starts remembering the text that is matched
X		  * and stores it in a memory register.
X		  * followed by one byte containing the register number.
X		  * Register numbers must be in the range 0 through NREGS.
X		  */
X    stop_memory, /* stops remembering the text that is matched
X		  * and stores it in a memory register.
X		  * followed by one byte containing the register number.
X		  * Register numbers must be in the range 0 through NREGS.
X		  */
X    duplicate,   /* match a duplicate of something remembered.
X		  * Followed by one byte containing the index of the memory
X		  * register.
X		  */
X    before_dot,	 /* Succeeds if before dot */
X    at_dot,	 /* Succeeds if at dot */
X    after_dot,	 /* Succeeds if after dot */
X    begbuf,      /* Succeeds if at beginning of buffer */
X    endbuf,      /* Succeeds if at end of buffer */
X    wordchar,    /* Matches any word-constituent character */
X    notwordchar, /* Matches any char that is not a word-constituent */
X    wordbeg,	 /* Succeeds if at word beginning */
X    wordend,	 /* Succeeds if at word end */
X    wordbound,   /* Succeeds if at a word boundary */
X    notwordbound,/* Succeeds if not at a word boundary */
X    syntaxspec,  /* Matches any character whose syntax is specified.
X		  * followed by a byte which contains a syntax code, Sword
X		  * or such like
X		  */
X    notsyntaxspec/* Matches any character whose syntax differs from the
X		  * specified.
X		  */
X};
X
X
extern char *re_compile_pattern ();
X/* Is this really advertised? */
extern void re_compile_fastmap ();
extern int re_search (), re_search_2 ();
extern int re_match (), re_match_2 ();
extern int match(), matchExp(), check_registers();
extern int re_init_comp();
X
X/* 4.2 bsd compatibility (yuck) */
extern char *re_comp ();
extern int re_exec ();
X
X#ifdef SYNTAX_TABLE
extern char *re_syntax_table;
X#endif
X
X#endif /* REGEX_H_INCLUDE */
END_OF_FILE
if test 12869 -ne `wc -c <'regex.h'`; then
    echo shar: \"'regex.h'\" unpacked with wrong size!
fi
# end of 'regex.h'
fi
if test -f 'xtkrtns.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xtkrtns.c'\"
else
echo shar: Extracting \"'xtkrtns.c'\" \(12805 characters\)
sed "s/^X//" >'xtkrtns.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid = "$Header: /usr/src/local/awl/RCS/xtkrtns.c,v 2.7 90/04/19 20:06:27 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 * All widget-specific built-in functions. This file is included from
X * builtins.c.
X *
X * $Log:	xtkrtns.c,v $
X * Revision 2.7  90/04/19  20:06:27  jkh
X *  Alpha checkin.
X * 
X * Revision 2.6  90/03/29  18:29:27  jkh
X * Even more bug fixes to XgInstallColorTable
X * 
X * Revision 2.5  90/03/27  09:05:09  jkh
X * Fixed typo.
X * 
X * Revision 2.4  90/03/27  08:35:08  jkh
X * Added Yet Another Sanity Check to XgInstallColorTable().
X * 
X * Revision 2.3  90/03/27  08:31:24  jkh
X * Added sanity check to XgInstallColorTable() for color indices of
X * bad length. Removed insane sanity check for rectangular list (what was
X * I thinking?).
X * 
X * Revision 2.2  90/03/27  08:15:31  jkh
X * Switched back from XtColormap (too gross) to DefaultColormapOfScreen(),
X * which is marginally less gross.
X * 
X * Revision 2.1  90/03/27  08:02:30  jkh
X * Switched over to XtColormap macro in XgInstallColorTable().
X * 
X * Revision 2.0  90/03/26  01:43:59  jkh
X * pre-beta check-in
X * 
X */
X
X#include "AwlP.h"
X#include "y.tab.h"
X
Local Value arg, arg2;
X
X/* Various local helper macros. Don't look. */
X
X#define GET_WIDGET_OR_LAYOUT(name) \
X     Widget tmp; \
X     arg = get_arg(aw, 1, ANY, FALSE); \
X     if (value_type(arg) == LAYOUT) \
X	  tmp = layout_id(aw, value_any(arg)); \
X     else if (value_type(arg) == WIDGET) \
X	  tmp = value_widget(arg); \
X     else \
X	  exec_error(aw, "%s: Expected widget or layout, got '%s'", \
X		     name, type_name(value_type(arg)))
X
X#if defined(__STDC__) && !defined(UNIXCPP)	/* ANSI */
X
X#define DEFUN_XT_VAL_FUNC(xtcall, valtype, valmember) \
DEFUN(xtcall) { GET_WIDGET_OR_LAYOUT(#xtcall); value_type(arg) = valtype; \
X		value_##valmember(arg) = xtcall(tmp); return(arg); }
X
X#define DEFUN_XT_OP(name, xtcall) \
DEFUN(name) { GET_WIDGET_OR_LAYOUT(#name); xtcall(tmp); return(arg); }
X
X#define DEFUN_XT_2OP(xtcall, arg2_type, valmember) \
DEFUN(xtcall) { GET_WIDGET_OR_LAYOUT(#xtcall); \
X		arg2 = get_arg(aw, 2, arg2_type, TRUE); \
X		xtcall(tmp, value_##valmember(arg2)); return(arg); }
X
X#else /* !ANSI */
X
X#define DEFUN_XT_VAL_FUNC(xtcall, valtype, valmember) \
DEFUN(xtcall) { GET_WIDGET_OR_LAYOUT("xtcall"); value_type(arg) = valtype; \
X		value_/**/valmember(arg) = xtcall(tmp); return(arg); }
X
X#define DEFUN_XT_OP(name, xtcall) \
DEFUN(name) { GET_WIDGET_OR_LAYOUT("name"); xtcall(tmp); return(arg); }
X
X#define DEFUN_XT_2OP(xtcall, arg2_type, valmember) \
DEFUN(xtcall) { GET_WIDGET_OR_LAYOUT("xtcall"); \
X		arg2 = get_arg(aw, 2, arg2_type, TRUE); \
X		xtcall(tmp, value_/**/valmember(arg2)); return(arg); }
X#endif
X
Import void XgListSelectItem(), XgListUnselectItem(), XgListChange();
X
X/* The generic functions */
DEFUN_XT_2OP(XgListSelectItem, INT, int)
DEFUN_XT_2OP(XgListUnselectItem, INT, int)
DEFUN_XT_2OP(XgListChange, LIST, list)
X
DEFUN(XgInstallColorTable)
X{
X     arg = get_arg(aw, 1, LIST, TRUE);
X     if (value_type(arg)) {
X	  register CTable ct;
X	  register String *l;
X	  register int i, j, p = 0;
X	  XColor close, exact;
X	  Display *dpy = XtDisplay(aw);
X
X	  l = value_list(arg);
X	  i = list_len(l);
X	  if (!i || i % 2)
X    	       exec_warn(aw, "Got odd-size or NULL list as color table");
X	  else {
X	       if (ct = awl_ctable(aw)) {
X		    hash_purge(ctab_hash(ct), NULL);
X		    XFreeColors(XtDisplay(aw),
X				DefaultColormapOfScreen(XtScreen(aw)),
X				ctab_colors(ct), ctab_ncolors(ct), AllPlanes);
X		    XtFree(ctab_colors(ct));
X	       }
X	       else {
X		    ct = awl_ctable(aw) = (CTable)XtMalloc(ctab_size);
X		    ctab_hash(ct) = hash_create(ALIST_HASH_SIZE);
X	       }
X	       if ((ctab_nchars(ct) = strlen(l[0])) >= 31) {
X		    exec_warn(aw, "Insane index length for first table entry");
X		    return(arg);
X	       }
X	       ctab_ncolors(ct) = i / 2;
X	       ctab_colors(ct) = (Pixel *)XtMalloc(sizeof(Pixel) * (i / 2));
X	       for (j = 0; j < i; j += 2) {
X		    if (strlen(l[j]) != ctab_nchars(ct)) {
X			 exec_warn(aw, "Color tag '%s' is not of length %d",
X				   l[j], ctab_nchars(ct));
X			 l[j][ctab_nchars(ct)] = '\0';
X		    }
X		    XAllocNamedColor(XtDisplay(aw),
X				     DefaultColormapOfScreen(XtScreen(aw)),
X				     l[j + 1], &close, &exact);
X		    ctab_colors(ct)[p] = close.pixel;
X		    hash_search(ctab_hash(ct), l[j], p++, NULL);
X	       }
X	       value_set(arg, DATA, INT, int, ctab_ncolors(ct));
X	  }
X     }
X     return(arg);
X}
X
DEFUN(XtGetSelectionTimeout)
X{
X     value_set(arg, DATA, INT, int,
X	       XtAppGetSelectionTimeout(XtWidgetToApplicationContext(aw)));
X     return(arg);
X}
X
DEFUN_XT_VAL_FUNC(XtClass, WCLASS, wclass)
DEFUN_XT_VAL_FUNC(XtIsManaged, INT, int)
DEFUN_XT_VAL_FUNC(XtIsRealized, INT, int)
DEFUN_XT_VAL_FUNC(XtIsSensitive, INT, int)
DEFUN_XT_VAL_FUNC(XtParent, WIDGET, widget)
DEFUN_XT_VAL_FUNC(XtSuperclass, WCLASS, wclass)
X
DEFUN_XT_OP(XtRealize, XtRealizeWidget)
DEFUN_XT_OP(XtManage, XtManageChild)
DEFUN_XT_OP(XtUnmanage, XtUnmanageChild)
DEFUN_XT_OP(XtMap, XtMapWidget)
DEFUN_XT_OP(XtUnmap, XtUnmapWidget)
DEFUN_XT_OP(XtDestroy, XtDestroyWidget)
DEFUN_XT_OP(XtPopdown, XtPopdown)
DEFUN_XT_OP(XtUninstallTranslations, XtUninstallTranslations)
X
DEFUN_XT_2OP(XtAugmentTranslations, ANY, any)
DEFUN_XT_2OP(XtOverrideTranslations, ANY, any)
DEFUN_XT_2OP(XtPopup, INT, int)
DEFUN_XT_2OP(XtSetMappedWhenManaged, INT, int)
DEFUN_XT_2OP(XtSetSensitive, INT, int)
X
DEFUN(XtMove)
X{
X     GET_WIDGET_OR_LAYOUT("XtMove");
X     arg2 = get_arg(aw, 2, INT, TRUE);
X     if (value_type(arg2)) {
X	  int x = value_int(arg2);
X
X	  arg2 = get_arg(aw, 3, INT, TRUE);
X	  if (value_type(arg2))
X	       XtMoveWidget(tmp, x, value_int(arg2));
X     }
X     return(arg);
X}
X
DEFUN(XtName)
X{
X     String str;
X
X     GET_WIDGET_OR_LAYOUT("XtName");
X     if ((str = XtName(tmp)) != NULL)
X	  value_set(arg, STATIC, STRING, aobj, new_aobj(str));
X     else
X	  value_clear(arg);
X     return(arg);
X}
X
DEFUN(XtNameToWidget)
X{
X     Widget xret = (Widget)NULL;
X
X     GET_WIDGET_OR_LAYOUT("XtNameToWidget");
X     arg2 = get_arg(aw, 2, STRING, TRUE);
X     if (value_type(arg2))
X	  xret = XtNameToWidget(tmp, value_string(arg2));
X     value_set(arg, DATA, WIDGET, widget, xret);
X     return(arg);
X}
X
DEFUN(XtResize)
X{
X     GET_WIDGET_OR_LAYOUT("XtResize");
X     arg2 = get_arg(aw, 2, INT, TRUE);
X     if (value_type(arg2)) {
X	  int width = value_int(arg2);
X
X	  arg2 = get_arg(aw, 3, INT, TRUE);
X	  if (value_type(arg2)) {
X	       int height = value_int(arg2);
X
X	       arg2 = get_arg(aw, 4, INT, TRUE);
X	       if (value_type(arg2))
X		    XtResizeWidget(tmp, width, height, value_int(arg2));
X	  }
X     }
X     return(arg);
X}
X
DEFUN(XtSetSelectionTimeout)
X{
X     arg = get_arg(aw, 1, INT, FALSE);
X     XtAppSetSelectionTimeout(XtWidgetToApplicationContext(aw),
X			      value_int(arg));
X     return(arg);
X}
X
DEFUN(XtAddTimeOut)
X{
X     arg = get_arg(aw, 1, INT, FALSE);
X     arg2 = get_arg(aw, 2, ANY, FALSE);
X     if (value_type(arg2) != SYMBOL ||
X	 symbol_class(value_symbol(arg2)) != FUNCTION)
X	  exec_warn(aw, "Non-function passed to XtAddTimeOut");
X     else {
X	  Symbol sym;
X	  Function f;
X
X	  sym = value_symbol(arg2);
X	  f = symbol_function(sym);
X	  value_type(arg) = ANY;
X	  switch(symbol_type(sym)) {
X	  case FUNC_USER:
X	       value_any(arg) =
X		    (Generic)XtAppAddTimeOut(XtWidgetToApplicationContext(aw),
X					     value_int(arg),
X					     do_timer_user,
X					     sym);
X	       break;
X
X	  case FUNC_BUILTIN:
X	  case FUNC_EXTERN:
X	       value_any(arg) =
X		    (Generic)XtAppAddTimeOut(XtWidgetToApplicationContext(aw),
X					     value_int(arg),
X					     function_faddr(f),
X					     function_data(f));
X	       break;
X	       
X	  default:
X	       exec_warn(aw, "Illegal function type for XtAddTimeOut");
X	       break;
X	  }
X     }
X     return(arg);
X}
X
DEFUN(XtRemoveTimeOut)
X{
X     arg = get_arg(aw, 1, ANY, FALSE);
X     XtRemoveTimeOut((XtIntervalId)value_any(arg));
X     return(arg);
X}
X
DEFUN(XtAddWorkProc)
X{
X     arg = get_arg(aw, 1, INT, FALSE);
X     arg2 = get_arg(aw, 2, ANY, FALSE);
X     if (value_type(arg2) != SYMBOL ||
X	 symbol_class(value_symbol(arg2)) != FUNCTION)
X	  exec_warn(aw, "Non-function passed to XtAddTimeOut");
X     else {
X	  Symbol sym;
X	  Function f;
X
X	  sym = value_symbol(arg2);
X	  f = symbol_function(sym);
X	  value_type(arg) = ANY;
X	  switch(symbol_type(sym)) {
X	  case FUNC_USER:
X	       value_any(arg) =
X		    (Generic)XtAppAddWorkProc(XtWidgetToApplicationContext(aw),
X					      do_workproc_user,
X					      sym);
X	       break;
X
X	  case FUNC_BUILTIN:
X	  case FUNC_EXTERN:
X	       value_any(arg) =
X		    (Generic)XtAppAddWorkProc(XtWidgetToApplicationContext(aw),
X					      function_faddr(f),
X					      function_data(f));
X	       break;
X	       
X	  default:
X	       exec_warn(aw, "Illegal function type for XtAddWorkProc");
X	       break;
X	  }
X     }
X     return(arg);
X}
X
DEFUN(XtRemoveWorkProc)
X{
X     arg = get_arg(aw, 1, ANY, FALSE);
X     XtRemoveTimeOut((XtWorkProcId)value_any(arg));
X     return(arg);
X}
X
DEFUN(XtIsSubclass)
X{
X     GET_WIDGET_OR_LAYOUT("XtIsSubclass");
X     arg = get_arg(aw, 2, ANY, FALSE);
X     if (value_type(arg) == LAYOUT) {
X	  value_type(arg) = INT;
X	  value_int(arg) = XtIsSubclass(tmp,
X					layout_wclass(aw, value_any(arg)));
X     }
X     else if (value_type(arg) == WCLASS) {
X	  value_type(arg) = INT;
X	  value_int(arg) = XtIsSubclass(tmp, value_wclass(arg));
X     }
X     else
X	  exec_error(aw, "%s: Expected widget class or layout, got '%s'",
X		     "XtIsSubclass", type_name(value_type(arg)));
X     return(arg);
X}
X	  
Local Value wcreate(aw, manage)
AwlWidget aw;
Boolean manage;
X{
X     int i, nargs = awl_nparms(aw);
X     String name, nm;
X     Widget parent;
X     WidgetClass class;
X     int a;
X     Arg args[50];
X
X     if (manage)
X	  nm = "XtCreateManaged";
X     else
X	  nm = "XtCreate";
X
X     /* if argcnt = 1, it's a layout w/default parent */
X     if (nargs == 1) {
X	  arg = get_arg(aw, 1, LAYOUT, TRUE);
X	  if (value_type(arg))
X	       layout_create(aw, aw, value_any(arg), manage);
X     }
X     /* if argcnt == 2, it's a layout with the parent specified */
X     else if (nargs == 2) {
X	  arg = get_arg(aw, 1, WIDGET, TRUE);
X	  arg2 = get_arg(aw, 2, LAYOUT, TRUE);
X	  if (value_type(arg) && value_type(arg2))
X	       layout_create(aw, value_widget(arg), value_any(arg2), manage);
X     }
X     /* otherwise it's a direct widget declaration */
X     else {
X	  if (nargs < 3)
X	       exec_error(aw, "%s: Minimum of 3 args to create widget", nm);
X	  else if (!(nargs % 2))
X	       exec_error(aw, "%s: Incomplete argument pair for widget", nm);
X	  else {
X	       arg = get_arg(aw, 1, STRING, FALSE);
X	       if (value_type(arg))
X		    name = value_string(arg);
X	       else
X		    exec_error(aw, "%s: Missing or invalid widget name", nm);
X	       arg = get_arg(aw, 2, WCLASS, TRUE);
X	       class = value_wclass(arg);
X	       if (!map_wclass_to_wname(class))
X		    exec_error(aw, "%s: Invalid widget class specified", nm);
X	       arg = get_arg(aw, 3, ANY, FALSE);
X	       if (value_type(arg) == WIDGET)
X		    parent = value_widget(arg);
X	       else if (value_type(arg) == LAYOUT)
X		    parent = layout_id(aw, value_any(arg));
X	       else
X		    exec_error(aw, "%s: Invalid parent specified", nm);
X	       if (!parent)
X		    exec_error(aw, "%s: parent widget is NULL", nm);
X	       a = 0;
X	       for (i = 4; i < nargs; i += 2) {
X		    String rname;
X
X		    arg = get_arg(aw, i, STRING, TRUE);
X		    rname = value_string(arg);
X		    wset_arg_by_value(args, &a, rname,
X				      get_arg(aw, i + 1, ANY, FALSE));
X	       }
X	       value_set(arg, DATA, WIDGET, widget, 
X			 ((*wcreate_rtn)(class, manage))(name, class,
X							 parent, args, a));
X	  }
X     }
X     return(arg);
X}
X
X/* Create a managed widget */
DEFUN(XtCreateManaged)
X{
X     return(wcreate(aw, TRUE));
X}
X
X/* Create an unmanaged widget */
DEFUN(XtCreate)
X{
X     return(wcreate(aw, FALSE));
X}
X
X/* Toot the horn */
DEFUN(XBell)
X{
X     arg = get_arg(aw, 1, INT, FALSE);
X     XBell(XtDisplay(aw), value_int(arg));
X     return(arg);
X}
END_OF_FILE
if test 12805 -ne `wc -c <'xtkrtns.c'`; then
    echo shar: \"'xtkrtns.c'\" unpacked with wrong size!
fi
# end of 'xtkrtns.c'
fi
echo shar: End of archive 6 \(of 17\).
cp /dev/null ark6isdone
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.