[comp.sources.x] v04i040: Xgen - An X-window based applications generator, Part02/03

argv@island.uu.net (Dan Heller) (06/30/89)

Submitted-by: Jim Westervelt <westerve@osiris.cso.uiuc.edu>
Posting-number: Volume 4, Issue 40
Archive-name: xgen/part02



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of shell archive."
# Contents:  Dynamicshell.c Helpcommand.c create_cmdboard.c
#   create_msgboard.c create_scrollbar.c create_shell.c
#   expand_string.c get_button_args.c get_env.c get_label_args.c
#   get_message_args.c get_pixel.c get_shell_args.c get_string.c
# Wrapped by argv@island on Thu Jun 29 19:27:25 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Dynamicshell.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Dynamicshell.c'\"
else
echo shar: Extracting \"'Dynamicshell.c'\" \(1551 characters\)
sed "s/^X//" >'Dynamicshell.c' <<'END_OF_FILE'
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xos.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/CoreP.h>
X
X#include "DynamicshellP.h"
X#include "Dynamicshell.h"
X
X#define Offset(x)       (XtOffset(DynamicshellWidget, x))
X#define XtInheritRedisplay ((void (*)())_XtInherit)
X
X
Xstatic XtResource dynamicShellResources[]=
X{
X	{XtNupdateFrom, XtCLabel, XtRString, sizeof(String),
X	Offset(dynamic.update_from), XtRString, (caddr_t)NULL
X	},
X};
X
Xstatic void Initialize();
Xstatic void Destroy();
X
XDynamicshellClassRec dynamicshellClassRec = {
X	{
X	(WidgetClass) &transientShellClassRec,
X	"Dynamicshell",
X	sizeof(DynamicshellRec),
X	NULL,
X	NULL,
X	FALSE,
X	Initialize,
X	NULL,
X	XtInheritRealize,
X	NULL,
X	0,
X	dynamicShellResources,
X	XtNumber(dynamicShellResources),
X	NULLQUARK,
X	FALSE,
X	TRUE,
X	FALSE,
X	FALSE,
X	Destroy,
X	XtInheritResize,
X	XtInheritRedisplay,
X	NULL,
X	NULL,
X	XtInheritSetValuesAlmost,
X	NULL,
X	NULL,
X	XtVersion,
X	NULL,
X	NULL,
X	},
X	{
X	XtInheritGeometryManager,
X	XtInheritChangeManaged,
X	XtInheritInsertChild,
X	XtInheritDeleteChild,
X	NULL
X	},
X};
X
XWidgetClass dynamicshellWidgetClass = (WidgetClass)
X&dynamicshellClassRec;
X
Xstatic void Initialize(request, new)
XWidget request, new;
X{
X	DynamicshellWidget dsw = (DynamicshellWidget)new;
X	if(dsw->dynamic.update_from != NULL)
X		dsw->dynamic.update_from = strcpy( XtMalloc(strlen(
X		    dsw->dynamic.update_from) + 1), dsw->dynamic.update_from);
X
X
X}
X
Xstatic void Destroy(w)
XWidget w;
X{
X	DynamicshellWidget dsw = (DynamicshellWidget)w;
X	free(dsw->dynamic.update_from);
X}
END_OF_FILE
if test 1551 -ne `wc -c <'Dynamicshell.c'`; then
    echo shar: \"'Dynamicshell.c'\" unpacked with wrong size!
fi
# end of 'Dynamicshell.c'
fi
if test -f 'Helpcommand.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Helpcommand.c'\"
else
echo shar: Extracting \"'Helpcommand.c'\" \(2274 characters\)
sed "s/^X//" >'Helpcommand.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/Xos.h>
X#include <ctype.h>
X#include <X11/StringDefs.h>
X#include <X11/IntrinsicP.h>
X#include <X11/CommandP.h>
X#include "Helpcommand.h"
X#include "HelpcommandP.h"
X
X#define offset(field) XtOffset(HelpcommandWidget, field)
X
X#define XtInheritRedisplay ((void (*)())_XtInherit)
X
X
Xvoid Initialize();
Xvoid Destroy();
Xstatic void  Nothing();
Xstatic void Unset();
Xstatic void Help();
X
Xtypedef void (*XtRedisplayProc)();
X
Xstatic XtResource resources[] = {
X	{XtNhelp, XtCLabel, XtRString, sizeof(caddr_t),
X	offset(helpcommand.help_string), XtRString, (caddr_t)NULL},
X	{XtNhelpCallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X	offset(helpcommand.help_callbacks), XtRCallback, (caddr_t)NULL},
X	{XtNfreePointer1, XtCFreePointer, XtRFreePointer, sizeof(caddr_t),
X	offset(helpcommand.freepointer1), XtRFreePointer, (caddr_t)NULL},};
X
Xstatic char helpDefaultTranslations[] =
X"Shift<Btn1Down>:          nothing()\n\
X      Shift<Btn1Up>:            help()";
X
XXtTranslations helpdefaulttranslations;
X
Xstatic XtActionsRec actionslist[] =
X{
X	{"help", Help},
X	{"nothing", Nothing},
X};
X
XHelpcommandClassRec helpcommandClassRec = {
X	{
X	(WidgetClass) &commandClassRec,
X	"Helpcommand",
X	sizeof(HelpcommandRec),
X	NULL,
X	NULL,
X	FALSE,
X	Initialize,
X	NULL,
X	XtInheritRealize,
X	actionslist,
X	XtNumber(actionslist),
X	resources,
X	XtNumber(resources),
X	NULLQUARK, 
X	FALSE,
X	TRUE,
X	TRUE,
X	FALSE,
X	Destroy,
X	XtInheritResize,
X	XtInheritRedisplay,
X	NULL,
X	NULL,
X	XtInheritSetValuesAlmost, 
X	NULL,                 
X	NULL,               
X	XtVersion,       
X	NULL,       
X	XtInheritTranslations,
X	NULL,
X	},
X	{ 
X	0,
X	},
X	{
X	0,
X	},
X	{
X	0,
X	},
X};
X
XWidgetClass helpcommandWidgetClass = (WidgetClass)
X&helpcommandClassRec;
X
X
X
Xstatic void Initialize(request, new)
XWidget request, new;
X{
X	XtAddActions(actionslist, 2);
X	helpdefaulttranslations = XtParseTranslationTable(
X	    helpDefaultTranslations );
X	XtOverrideTranslations( new, helpdefaulttranslations);
X}
X
X
X
Xstatic void  Nothing(w)
XWidget w;
X{
X	return;
X}
X
Xstatic void Destroy(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X}
Xstatic void Help(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X	XtCallCallbacks(w, XtNhelpCallback, NULL);
X}
X
X
END_OF_FILE
if test 2274 -ne `wc -c <'Helpcommand.c'`; then
    echo shar: \"'Helpcommand.c'\" unpacked with wrong size!
fi
# end of 'Helpcommand.c'
fi
if test -f 'create_cmdboard.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create_cmdboard.c'\"
else
echo shar: Extracting \"'create_cmdboard.c'\" \(22209 characters\)
sed "s/^X//" >'create_cmdboard.c' <<'END_OF_FILE'
X#define MAX_NUM_ARGS 20
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/CompositeP.h>
X#include <X11/CommandP.h>
X#include <X11/LabelP.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Form.h>
X#include <X11/Core.h>
X#include <X11/Viewport.h>
X#include <X11/VPaned.h>
X#include <X11/Text.h>
X#include <X11/AsciiText.h>
X#include "Helpcommand.h"
X
X#include "application.h"
X
Xextern Widget top_level;
Xextern XtTranslations input_text_translations;
Xvoid check();
Xvoid swap();
Xvoid check_tree();
Xvoid swap_grouped();
Xvoid initialize_cmdboard();
Xvoid reset_cmdboard();
Xvoid popup_error();
X
Xstatic int status = 0;
X
XWidget create_cmdboard(app_shell)
Xstruct shell *app_shell;
X{
X	Widget shell,
X	    form,
X	    button,
X	    scrolltextspace,
X	    vpane,
X	    label,
X	    input_text;
X	Widget prev_widget = NULL;
X	Widget create_spreadsheet();
X	Widget  create_textspace();
X	struct widget *child;
X
X	Arg args[ MAX_NUM_ARGS ];
X	int num_args = 0;
X
X	char name[STR_LEN];
X	char *shell_name;
X	int flag;
X	int borderwidth = 5;
X	char cmd_line_buf[1024];
X	static XtCallbackRec callback[2];
X
X	struct _cmd_line_arg *cmd_arg_header,
X		**pres_cmd_arg,
X		*fix_tree_order();
X
X
X	/* initialize command line buffer */
X	*cmd_line_buf = '\0';
X
X	/* initialize the data structure that will contain the *
X	 * various  data of the cmdboard                       */
X	pres_cmd_arg = &cmd_arg_header;
X
X	/* build the arglist of the enclosing shell*/
X	(void)get_shell_args( top_level, app_shell->resources,
X	    args, &num_args,  &shell_name);
X
X	XtSetArg( args[ num_args ], XtNallowShellResize, TRUE );
X	num_args++;
X
X	/*create the enclosing shell*/
X	shell = XtCreateApplicationShell("",
X	    topLevelShellWidgetClass, args, num_args);
X
X	/*enter the address in the shell address table*/
X	enter_shell_address( shell, app_shell->name);
X
X	/*create a vpane to tile the subsequent widgets vertically*/
X	XtSetArg( args[0], XtNborderWidth, 10);
X	XtSetArg( args[1], XtNgripIndent, -30);
X	vpane = XtCreateManagedWidget("", vPanedWidgetClass,
X	    shell, args, 2);
X
X
X	child = app_shell->child;
X
X	/*first child must be a label*/
X	if( !strcmp(child->type, "label" ))
X	{
X		get_label_args( vpane, child->resources, args, 
X		    &num_args, app_shell->name);
X
X		label = XtCreateManagedWidget("", labelWidgetClass,
X		    vpane, args, num_args );
X		child = child->next_widget;
X	}
X
X	/* this form will contain all textspaces and *
X     * scrolltextspaces                          */
X	form = XtCreateManagedWidget("", formWidgetClass,
X	    vpane, NULL, 0);
X
X
X	/*loop until the end of the linked list or a button is *
X     *declared                                             */
X	while( child != NULL )
X	{
X		if( !strcmp(child->type, "button"))
X			break;
X
X		/*if this object is a textspace create it*/
X		if ( !strcmp( child->type, "textspace"))
X		{
X			prev_widget = create_textspace( child->resources,
X			    form, prev_widget,
X			    pres_cmd_arg, 
X			    app_shell->name );
X
X			pres_cmd_arg = &((*pres_cmd_arg)->next);
X		}
X
X		/*if this object is a scrolltextspace create it*/
X		if( !strcmp( child->type, "scrolltextspace"))
X
X		{
X			prev_widget = create_spreadsheet( 
X			    child->resources , form,
X			    prev_widget,
X			    pres_cmd_arg );
X			pres_cmd_arg = &((*pres_cmd_arg)->next);
X		}
X		child = child->next_widget;
X	}
X
X	(*pres_cmd_arg) = NULL;
X
X	/* create buttons */
X	while( child != NULL )
X	{
X		if(strcmp( child->type, "button" )) break;
X
X		get_button_args(top_level, child->resources, args,
X		    &num_args, app_shell->name, cmd_line_buf);
X
X/* fprintf(stderr,"Got cmd_line_buf: %s\n", cmd_line_buf) ; */
X		/* use commandarg to reshuffle the cmdboard data *
X         * and put it in the right order                 */
X		if( *cmd_line_buf != '\0')
X		{
X			cmd_arg_header = fix_tree_order(cmd_line_buf,
X			    cmd_arg_header,
X			    app_shell->name);
X			XtAddCallback(shell, "popupCallback", 
X			    initialize_cmdboard, 
X			    cmd_arg_header);
X
X			*cmd_line_buf = '\0';
X		}
X
X		/*store a pointer to the head of the strings that will*
X         *contain the cmdboard data                           */
X		XtSetArg( args[num_args], XtNfreePointer1,
X		    cmd_arg_header);
X		num_args++;
X
X		XtCreateManagedWidget( "", helpcommandWidgetClass,
X		    vpane, args, num_args);
X
X		child = child->next_widget;
X	}
X	return(shell);
X}
X
X
XWidget
Xcreate_textspace(resources, outer_form, prev_widget, pres_cmd_arg, shell_name)
X	struct resource *resources;
X	Widget outer_form;
X	Widget prev_widget;
X	struct _cmd_line_arg **pres_cmd_arg;
X	char *shell_name;
X{
X	Arg label_args[MAX_NUM_ARGS];
X	Arg text_args[MAX_NUM_ARGS];
X	Arg form_args[MAX_NUM_ARGS];
X	Arg args[2];
X	XtArgVal ptr;
X	int num_label_args = 0,
X	num_text_args = 0,
X	num_form_args = 0;
X
X	int text_length = 15;
X	int pixel;
X
X	struct resource *pres_resource;
X	XFontStruct *font;
X	XFontStruct *textfont = NULL;
X	char *help_msg = NULL;
X
X	Widget form,
X	    label,
X	    text;
X
X	char *textspace_label;
X	int textlength = 30;
X	int text_width;
X
X	/*this is the data structure that will contain an argument*
X     *to the command line                                     */
X	 *pres_cmd_arg = (struct _cmd_line_arg *)(
X	    malloc(sizeof(struct _cmd_line_arg)));
X
X	/*this is flag to indicate that this is a textspace*/
X	(*pres_cmd_arg)->grouped_arg = NULL;
X
X	pres_resource = resources;
X
X	/*transfer the textspace options into widget argument list*/
X	while( pres_resource != NULL )
X	{
X		if( !strcmp( pres_resource->name, "labelbackground") )
X		{
X			pixel = get_pixel( pres_resource->value );
X			XtSetArg( label_args[num_label_args], XtNbackground,
X			    pixel );
X			num_label_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "labelforeground") )
X		{
X			pixel = get_pixel( pres_resource->value );
X			XtSetArg( label_args[num_label_args], XtNforeground,
X			    pixel );
X			num_label_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "labelfont" ) )
X		{
X			font = XLoadQueryFont( XtDisplay(top_level), 
X			    pres_resource->value );
X			XtSetArg( label_args[num_label_args], XtNfont,
X			    font);
X			num_label_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "label" ))
X		{
X			textspace_label = pres_resource->value;
X			XtSetArg( label_args[num_label_args], XtNlabel,
X			    pres_resource->value );
X			num_label_args++;
X			(*pres_cmd_arg)->name_quark = XrmStringToQuark(
X			    pres_resource->value);
X			goto next;
X		}
X
X		if(!strcmp( pres_resource->name, "labelborderwidth"))
X		{
X			XtSetArg( label_args[num_label_args], 
X			    XtNborderWidth, atoi( pres_resource->value));
X			num_label_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "textbackground") )
X		{
X			pixel = get_pixel( pres_resource->value );
X			XtSetArg( text_args[num_text_args], XtNbackground,
X			    pixel );
X			num_text_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "textforeground") )
X		{
X			pixel = get_pixel( pres_resource->value );
X			XtSetArg( text_args[num_text_args], XtNforeground,
X			    pixel );
X			num_text_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "textfont" ) )
X		{
X			textfont = XLoadQueryFont( XtDisplay(top_level), 
X			    pres_resource->value );
X			XtSetArg( text_args[num_text_args], XtNfont,
X			    textfont);
X			num_text_args++;
X			goto next;
X		}
X
X		if(!strcmp( pres_resource->name, "textborderwidth"))
X		{
X			XtSetArg( text_args[num_text_args], 
X			    XtNborderWidth, atoi( pres_resource->value));
X			num_text_args++;
X			goto next;
X		}
X
X		if(!strcmp( pres_resource->name, "textlength"))
X		{
X			text_length = atoi(pres_resource->value);
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "horizdistance"))
X		{
X			XtSetArg(form_args[num_form_args], 
X			    XtNhorizDistance, 
X			    atoi(pres_resource->value));
X			num_form_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "vertdistance"))
X		{
X			XtSetArg(form_args[num_form_args], 
X			    XtNvertDistance,
X			    atoi(pres_resource->value));
X			num_form_args++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "help"))
X		{
X			help_msg = pres_resource->value;
X			goto next;
X		}
X
X
X		fprintf(stderr,"In shell %s textspace %s: %s. No such option for textspaces. Ignored.\n", shell_name, textspace_label,
X		    pres_resource->name);
X
Xnext:
X		pres_resource = pres_resource->next;
X	}
X
X	/*set the length of the  text string*/
X	(*pres_cmd_arg)->value = (char *)malloc(
X	    text_length);
X	*((*pres_cmd_arg)->value) = '\0';
X
X	/*set the width of the text according to the length of the *
X     *string                                                  */
X	/*  if( textfont == NULL)
X   textfont = XLoadQueryFont(XtDisplay(top_level), 
X			      XtDefaultFont);
X
X  text_width = (textfont->max_bounds.width) * text_length;*/
X
X	/*create the form that will contain the label and text*
X     *widgets                                             */
X	XtSetArg(form_args[num_form_args], XtNborderWidth, 0);
X	num_form_args++;
X	XtSetArg(form_args[num_form_args], XtNfromVert, prev_widget);
X	num_form_args++;
X	form = XtCreateManagedWidget("", formWidgetClass,
X	    outer_form, form_args, num_form_args);
X
X	/*create the textspace label*/
X	label = XtCreateManagedWidget("", labelWidgetClass,
X	    form, label_args, num_label_args);
X
X	/*create the textspace text*/
X	XtSetArg( text_args[num_text_args], XtNfromHoriz, label);
X	num_text_args++;
X	XtSetArg( text_args[num_text_args], XtNstring, 
X	    (*pres_cmd_arg)->value);
X	num_text_args++;
X	XtSetArg( text_args[num_text_args], XtNeditType, XttextEdit);
X	num_text_args++;
X	XtSetArg( text_args[num_text_args], XtNlength, textlength );
X	num_text_args++;
X	XtSetArg( text_args[num_text_args], XtNtextOptions, 
X	    editable );
X	num_text_args++;
X	/*  XtSetArg( text_args[num_text_args], XtNwidth, text_width);
X        num_text_args++; */
X
X	(*pres_cmd_arg)->text_widget = XtCreateManagedWidget("", 
X	    asciiStringWidgetClass,
X	    form, text_args, num_text_args);
X
X	enter_hash_help( (*pres_cmd_arg)->text_widget, help_msg );
X
X	/*transform the text widget into a one line text editor*/
X	XtOverrideTranslations( (*pres_cmd_arg)->text_widget,
X	    input_text_translations);
X
X	return(form);
X}
X
Xvoid
Xcheck( w,closure, call_data)
X	Widget w;
X	caddr_t closure,
X	call_data;
X{
X	char cmd_line[1024];
X	char *cmd_arg;
X	XtArgVal ptr1;
X	Arg args[2];
X	FILE *fp,
X	    *popen();
X	char message[1024];
X	int temp = 0;
X
X	XtSetArg( args[0], XtNfreePointer1, &ptr1);
X
X	XtGetValues( w, args, 1);
X
X	cmd_arg = (char *)((long)cmd_line + strlen(closure));
X
X	strcpy(cmd_line , closure);
X
X	build_cmd_line(ptr1 , cmd_arg);
X	expand_string(cmd_line, 1024) ;
X
X	fp = popen(cmd_line, "r");
X
X	fgets(message, 1000, fp);
X
X	status = pclose(fp);
X
X	if(status != 0 )
X	{
X		XBell(XtDisplay(top_level), 100);
X		popup_error(message);
X	}
X}
X
Xvoid
Xrunback(w, closure, call_data)
X	Widget w;
X	caddr_t closure,
X	call_data;
X{
X
X	char cmd_line[1024];
X	char *cmd_arg;
X	XtArgVal ptr1;
X	Arg args[2];
X
X	if (status != 0)
X		return;
X
X	XtSetArg( args[0], XtNfreePointer1, &ptr1);
X
X	XtGetValues( w, args, 1);
X
X	cmd_arg = (char *)((long)cmd_line +strlen(closure));
X
X	strcpy(cmd_line, closure);
X
X	build_cmd_line(ptr1, cmd_arg);
X	expand_string(cmd_line, 1024) ;
X
X/* fprintf(stderr,"Background: %s\n", cmd_line) ; */
X	if (fork() == 0)
X	{
X		/*
X		XCloseDisplay(XtDisplay(top_level));
X		*/
X		setpgrp(0, getpid());
X		execlp("/bin/sh", "sh", "-c", cmd_line, 0);
X		_exit(127);
X	}
X}
X
Xvoid
Xrunfore(w, closure, call_data)
X	Widget w;
X	caddr_t closure,
X	call_data;
X{
X	Arg args[2];
X	FILE *fp, *popen();
X	XtArgVal ptr1;
X	char *cmd_arg;
X	char *p ;
X	char cmd_line[1024];
X	char message[1024];
X	int pro_status;
X
X	XtSetArg( args[0], XtNfreePointer1, &ptr1);
X
X	XtGetValues( w, args, 1);
X
X	cmd_arg = (char *)((long)cmd_line +strlen(closure));
X
X	strcpy(cmd_line, closure);
X
X	build_cmd_line(ptr1, cmd_arg);
X	expand_string(cmd_line, 1024) ;
X/*	strcat(cmd_line, " > /tmp/out") ; */
X/* fprintf(stderr,"Foreground: %s\n", cmd_line) ; */
X
X	if (NULL == (fp = popen(cmd_line, "r")))
X	{
X		sprintf(message, "Error. Can't run: <%s>", cmd_line) ;
X		XBell(XtDisplay(top_level), 100);
X		popup_error(message);
X	}
X	else
X	{
X		fgets(message, 1024, fp) ;
X		message[strlen(message)-1] = NULL ;
X		while(EOF != getc(fp))
X			;
X		pro_status =  pclose(fp);
X
X		if(pro_status != 0 )
X		{
X			XBell(XtDisplay(top_level), 100);
X			popup_error(message);
X		}
X	}
X/* fprintf(stderr,"Ran foreground") ; */
X}
X
Xvoid
Xcheck_tree( cmd_arg_header)
X	struct _cmd_line_arg *cmd_arg_header;
X{
X	struct _cmd_line_arg *pres_cmd_arg;
X	struct _grouped_arg *pres_grouped_arg;
X
X	pres_cmd_arg = cmd_arg_header;
X
X	/* skip leading spaces and command */
X
X	while(pres_cmd_arg != NULL)
X	{
X		if(pres_cmd_arg->grouped_arg == NULL)
X		{
X			pres_cmd_arg = pres_cmd_arg->next;
X		}
X		else
X		{
X			pres_grouped_arg = pres_cmd_arg->grouped_arg;
X
X			while( pres_grouped_arg != NULL)
X			{
X				pres_grouped_arg = pres_grouped_arg->next;
X
X
X			}
X			pres_cmd_arg = pres_cmd_arg->next;
X		}
X	}
X}
X
Xstruct _cmd_line_arg
X*fix_tree_order(ptr, cmdboard_data, shell_name)
X	char *ptr;
X	struct _cmd_line_arg *cmdboard_data;
X	char *shell_name;
X{
X	int str_length;
X	int new_position=0;
X	struct  _cmd_line_arg **pres_cmdboard_arg,
X	**moved_cmdboard_arg,
X	**old_position_ptr,
X	**old_branch_position_ptr,
X	**new_branch_position_ptr;
X	struct _grouped_arg **pres_grouped_arg,
X	**moved_grouped_arg,
X	**old_grouped_position_ptr;
X	char temp_string[1024];
X	char *temp ;
X	XrmQuark quark;
X	int  position;
X	int current_position = 0;
X	char *old_ptr;
X	char *tag_string;
X	long length;
X	char *default_string;
X
X	while( *ptr != '\0' )
X	{
X		str_length = 0;
X		current_position++;
X		temp = temp_string;
X
X		pres_cmdboard_arg = &cmdboard_data;
X
X		old_ptr = ptr;
X
X		while( *ptr != '[' )
X			ptr++;
X
X		length = (long)ptr - (long)old_ptr;
X
X		tag_string = 
X		    (char *)malloc((length+1)
X		    *sizeof(char));
X
X
X		strncpy(tag_string,
X		    old_ptr, length);
X
X		*((char *)((long)tag_string + length)) = '\0';
X
X		ptr++;
X
X		while( *ptr != ']' && *ptr != '(')
X			*temp++ = *ptr++;
X
X		*temp = '\0';
X
X		quark = XrmStringToQuark(temp_string);
X
X
X		if( *ptr == '(' )
X		{
X			ptr++;
X			temp = temp_string;
X			while ( *ptr != ')' )
X				*temp++ = *ptr++ ;
X			length = (long)temp - (long)temp_string;
X			default_string = (char *)malloc((length +1)
X			    *sizeof(char));
X			strncpy( default_string, temp_string, length + 1);
X			*((char *)((long)default_string + length)) = '\0';
X
X			ptr++;
X		}
X
X		else
X		{
X			default_string = (char *)malloc(1*sizeof(char));
X			*default_string = '\0';
X		}
X
X
X		/* find current position of quark in tree */
X		while( *pres_cmdboard_arg != NULL)
X		{
X			while( (*pres_cmdboard_arg)->grouped_arg == NULL )
X			{
X/* core dump here if option string is not identically matched by a
X * textstring entry */
X				if( quark == (*pres_cmdboard_arg)->name_quark)
X				{
X					(*pres_cmdboard_arg)->tag_string =
X					    tag_string;
X					(*pres_cmdboard_arg)->default_string =
X					    default_string;
X					old_position_ptr = pres_cmdboard_arg;
X					goto find_new_position;
X				}
X				else
X					pres_cmdboard_arg = &((*pres_cmdboard_arg)->next);
X			}
X			pres_grouped_arg = &((*pres_cmdboard_arg)->
X			    grouped_arg);
X
X			while( *pres_grouped_arg != NULL )
X			{
X
X				if( quark == (*pres_grouped_arg)->name_quark)
X				{
X					(*pres_grouped_arg)->tag_string = 
X					    tag_string;
X					(*pres_grouped_arg)->default_string =
X					    default_string;
X					old_grouped_position_ptr =
X					    pres_grouped_arg;
X					old_branch_position_ptr = 
X					    pres_cmdboard_arg;
X					goto find_new_position;
X				}
X				else
X					pres_grouped_arg = &((*pres_grouped_arg)->
X					    next);
X			}
X			pres_cmdboard_arg = &((*pres_cmdboard_arg)->next);
X
X		}
X		/* error argument not found */
X		fprintf(stderr, "Tag \"%s\" used in cmdboard \"%s\" do not match any tag in commandarg\n", 
X		    XrmQuarkToString(quark), 
X		    shell_name);
X		exit();
X
Xfind_new_position:
X
X		position = 1;
X		moved_cmdboard_arg = &cmdboard_data;
X
X		while(*moved_cmdboard_arg != NULL )
X		{
X			if((*moved_cmdboard_arg)->grouped_arg == NULL )
X			{
X
X				if( position == current_position)
X				{
X					swap(pres_cmdboard_arg, moved_cmdboard_arg );
X					goto loop;
X				}
X				position++;
X				moved_cmdboard_arg = &((*moved_cmdboard_arg)->
X				    next);
X			}
X
X			else
X			{
X				new_branch_position_ptr = pres_cmdboard_arg;
X
X				moved_grouped_arg = &((*moved_cmdboard_arg)->
X				    grouped_arg);
X				while(*moved_grouped_arg != NULL)
X				{
X					if( position == current_position)
X					{
X
X						swap(pres_cmdboard_arg,
X						    moved_cmdboard_arg);
X						swap_grouped(pres_grouped_arg, 
X						    moved_grouped_arg);
X						goto loop;
X					}
X					position++;
X					moved_grouped_arg = &((*moved_grouped_arg)
X					    ->next);
X				}
X				moved_cmdboard_arg = &((*moved_cmdboard_arg)
X				    ->next);
X			}
X		}
X
Xloop: /* loop again*/
X		ptr++;
X
X	}
X	check_tree( cmdboard_data);
X	return( cmdboard_data );
X}
X
X
X
Xvoid
Xswap(pres_ptr, moved_ptr)
X	struct _cmd_line_arg **pres_ptr;
X	struct _cmd_line_arg **moved_ptr;
X{
X
X	struct _cmd_line_arg *old_moved;
X	struct _cmd_line_arg *old_pres_next;
X	struct _cmd_line_arg *old_pres;
X	struct _cmd_line_arg *old_moved_next;
X
X
X	if( *pres_ptr == *moved_ptr)
X		return;
X
X	old_moved = *moved_ptr;
X	old_pres_next = (*pres_ptr)->next;
X
X	if((*moved_ptr)->next == *pres_ptr)
X	{
X
X		*moved_ptr = *pres_ptr;
X		(*moved_ptr)->next = old_moved;
X		((*moved_ptr)->next)->next = old_pres_next;
X		return;
X	}
X
X	old_pres = *pres_ptr;
X	old_moved_next = (*moved_ptr)->next;
X
X	if(old_pres_next == *moved_ptr)
X	{
X
X		*pres_ptr = *moved_ptr;
X		(*pres_ptr)->next = old_pres;
X		((*pres_ptr)->next)->next = old_moved_next;
X		return;
X	}
X
X	*pres_ptr = *moved_ptr;
X	(*pres_ptr)->next = old_pres_next;
X	*moved_ptr = old_pres;
X	(*moved_ptr)->next = old_moved_next;
X
X}
X
X
X
Xvoid
Xswap_grouped(pres_ptr, moved_ptr)
X	struct _grouped_arg **pres_ptr;
X	struct _grouped_arg **moved_ptr;
X{
X	struct _grouped_arg *old_moved;
X	struct _grouped_arg *old_pres_next;
X	struct _grouped_arg *old_pres;
X	struct _grouped_arg *old_moved_next;
X
X	if( *pres_ptr == *moved_ptr)
X		return;
X
X	old_moved = *moved_ptr;
X	old_pres_next = (*pres_ptr)->next;
X
X	if((*moved_ptr)->next == *pres_ptr)
X	{
X
X		*moved_ptr = *pres_ptr;
X		(*moved_ptr)->next = old_moved;
X
X		((*moved_ptr)->next)->next = old_pres_next;
X		return;
X	}
X
X	old_pres = *pres_ptr;
X	old_moved_next = (*moved_ptr)->next;
X
X	if(old_pres_next == *moved_ptr)
X	{
X
X		*pres_ptr = *moved_ptr;
X		(*pres_ptr)->next = old_pres;
X		((*pres_ptr)->next)->next = old_moved_next;
X		return;
X	}
X
X	*pres_ptr = *moved_ptr;
X	(*pres_ptr)->next = old_pres_next;
X	*moved_ptr = old_pres;
X	(*moved_ptr)->next = old_moved_next;
X
X}
X
Xbuild_cmd_line(cmdboard_data, cmd_ptr)
X	struct _cmd_line_arg *cmdboard_data;
X	char *cmd_ptr;
X{
X	int i,
X	lines;
X	struct _cmd_line_arg *pres_cmd_arg;
X	struct _rec_cmd_line_arg *pres_rec_cmd_arg;
X	struct _grouped_arg *pres_grouped_arg;
X	char *pres_ptr;
X
X	pres_cmd_arg = cmdboard_data;
X
X	*cmd_ptr++ = ' ';
X
X	while(pres_cmd_arg != NULL)
X	{
X		if( pres_cmd_arg->grouped_arg == NULL )
X		{
X			strcpy(cmd_ptr, pres_cmd_arg->tag_string);
X			cmd_ptr += strlen(pres_cmd_arg->tag_string);
X
X			strcpy(cmd_ptr, pres_cmd_arg->value);
X			cmd_ptr += strlen(pres_cmd_arg->value);
X			pres_cmd_arg = pres_cmd_arg->next;
X		}
X		else
X		{
X			pres_rec_cmd_arg = (struct _rec_cmd_line_arg *)
X			    pres_cmd_arg;
X			i=0;
X			lines = (strlen(pres_rec_cmd_arg->grouped_arg->
X			    value) -1) /
X			    pres_rec_cmd_arg->
X			    scrolltext_width + 1 ;
X			while(i < lines )
X			{
X				pres_grouped_arg = pres_rec_cmd_arg->
X				    grouped_arg;
X				while( pres_grouped_arg != NULL )
X				{
X
X
X					pres_ptr = (char *)
X					    ((long)(pres_grouped_arg->value)
X					    + i*(pres_rec_cmd_arg->
X					    scrolltext_width));
X
X					strcpy(cmd_ptr, pres_grouped_arg->
X					    tag_string);
X					cmd_ptr += strlen(pres_grouped_arg->
X					    tag_string);
X					while( *pres_ptr != ' ' && 
X					    *pres_ptr != '\0')
X						*cmd_ptr++ = *pres_ptr++;
X					if(*pres_ptr == '\0')
X						goto next_arg;
X
X
X					pres_grouped_arg = pres_grouped_arg->next;
X				}
X				i++;
X			}
Xnext_arg:
X			pres_cmd_arg = pres_rec_cmd_arg->next;
X		}
X
X
X
X	}
X	*cmd_ptr = '\0';
X}
X
Xvoid
Xinitialize_cmdboard(w, pres_cmd_arg)
X	Widget w;
Xcaddr_t pres_cmd_arg;
X{
X	static Boolean i = 0;
X	if( i == 1 )
X		return;
X	reset_cmdboard(pres_cmd_arg);
X
X	i = 1;
X}
X
Xvoid
Xclear_cmdboard(w)
X	Widget w;
X{
X	Arg args[2];
X	XtArgVal ptr1;
X
X	XtSetArg( args[0], XtNfreePointer1, &ptr1);
X	XtGetValues( w, args, 1);
X
X	(void)reset_cmdboard( ptr1 );
X}
X
Xvoid
Xreset_cmdboard( pres_cmd_arg)
X	struct _cmd_line_arg *pres_cmd_arg;
X{
X
X	struct _grouped_arg *pres_grouped_arg;
X	struct _rec_cmd_line_arg *pres_rec_cmd_arg;
X	XtTextBlock text;
X	char temp0[1024];
X	char *temp1,
X	*temp;
X	int num;
X	Arg args[2];
X	XtArgVal ptr;
X
X	while(pres_cmd_arg != NULL )
X	{
X		if(pres_cmd_arg->grouped_arg  == NULL)
X		{
X			text.firstPos = 0;
X			text.ptr = pres_cmd_arg->default_string;
X			text.length = strlen(pres_cmd_arg->default_string);
X
X			XtTextReplace ( pres_cmd_arg->text_widget,
X			    0,  strlen(pres_cmd_arg->value),
X			    &text);
X		}
X		else
X		{
X			pres_rec_cmd_arg = (struct _rec_cmd_line_arg *)
X			    pres_cmd_arg;
X			pres_grouped_arg = pres_cmd_arg->grouped_arg;
X
X			if(*(pres_grouped_arg->default_string) != '\0')
X			{
X				/* Make a blank line */
X
X				temp1 = temp0;
X
X				for( num=0; num<pres_rec_cmd_arg->
X				    scrolltext_width -1; num++)
X					*temp1++ = ' ';
X
X				*temp1 = '\n';
X				temp1++;
X				*temp1 = '\0';
X
X				while(pres_grouped_arg != NULL)
X				{
X					temp1 = (char *)((long)temp0 + 
X					    (long)(pres_grouped_arg->value)
X					    -(long)(pres_rec_cmd_arg->scroll_string));
X					temp = pres_grouped_arg->default_string;
X					while( *temp != '\0' )
X						*temp1++ = *temp++;
X					pres_grouped_arg = pres_grouped_arg->
X					    next;
X				}
X
X
X				text.firstPos = 0;
X				text.ptr = temp0;
X				text.length = pres_rec_cmd_arg->
X				    scrolltext_width;
X			}
X			else
X				text.length = 0;
X
X
X			XtTextReplace( pres_cmd_arg->text_widget,
X			    0, strlen(pres_rec_cmd_arg->
X			    scroll_string),
X			    &text);
X			XtTextSetInsertionPoint(pres_cmd_arg->text_widget,
X			    0);
X			XtSetArg(args[0], XtNstring, &ptr);
X			XtGetValues( pres_rec_cmd_arg->input_text_widget, 
X			    args, 1);
X
X			text.firstPos = 0;
X			text.ptr = NULL;
X			text.length = 0;
X
X			XtTextReplace( pres_rec_cmd_arg->input_text_widget,
X			    0, strlen(ptr),
X			    &text);
X		}
X
X		pres_cmd_arg = pres_cmd_arg->next;
X	}
X
X}
END_OF_FILE
if test 22209 -ne `wc -c <'create_cmdboard.c'`; then
    echo shar: \"'create_cmdboard.c'\" unpacked with wrong size!
fi
# end of 'create_cmdboard.c'
fi
if test -f 'create_msgboard.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create_msgboard.c'\"
else
echo shar: Extracting \"'create_msgboard.c'\" \(4248 characters\)
sed "s/^X//" >'create_msgboard.c' <<'END_OF_FILE'
X#define MAX_NUM_ARGS 25
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/CompositeP.h>
X#include <X11/CommandP.h>
X#include <X11/LabelP.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Form.h>
X#include <X11/Core.h>
X#include <X11/VPaned.h>
X#include <X11/Text.h>
X#include <X11/AsciiText.h>
X#include "Helpcommand.h"
X
X#include "application.h"
X
X
Xextern Widget top_level;
X
X
XWidget label;
XWidget help_msg_widget;
XWidget error_msg_widget;
XWidget label_help_widget;
XWidget label_error_widget;
X
Xextern void get_shell_args();
X
XWidget create_msgboard(app_shell)
Xstruct shell *app_shell;
X{
X	Widget shell,
X	    message,
X	    form,
X	    vpane,
X	    button = NULL;
X	static Arg vpane_args[3] = {
X		{XtNborderWidth, (XtArgVal)0},
X		{XtNgripIndent, (XtArgVal) -30},
X	};
X	int  button_entered = 0;
X	Widget prev_widget = NULL;
X
X	Arg args[MAX_NUM_ARGS];
X	int num_args = 0;
X	struct widget *child;
X	int flag;
X	char name[STR_LEN];
X	int borderwidth = 10;
X
X	/* build arglist for enclosing shell */
X	(void)get_shell_args(top_level, app_shell->resources,
X	    args, &num_args );
X
X	XtSetArg( args[num_args], XtNallowShellResize, TRUE); 
X	num_args++;
X
X	shell = XtCreateApplicationShell("", 
X	    topLevelShellWidgetClass, args, num_args);
X
X	enter_shell_address( shell, app_shell->name);
X
X	XtSetArg(args[0], XtNresizable, TRUE);
X
X	/* Create a geometry manager widget that will tile *
X   * the children in a vertical manner                 */
X	if( strcmp( app_shell->name , "help") == 0 ||
X	    strcmp( app_shell->name , "error") == 0 )
X		vpane = XtCreateManagedWidget("", formWidgetClass,
X		    shell, NULL, 0);
X	else
X		vpane = XtCreateManagedWidget("", vPanedWidgetClass,
X		    shell, vpane_args, 3);
X	child = app_shell->child;
X
X	/*loop over all the wdigets declared*/
X	while(child !=NULL)
X	{
X		/* if object declared is a label build arglist and *
X		 * create it                                       */
X		if(!strcmp(child->type, "label"))
X		{
X			get_label_args(shell, child->resources,
X			    args, &num_args, app_shell->name);
X
X			label = XtCreateManagedWidget("", 
X			    labelWidgetClass,
X			    vpane, args, num_args);
X			if( !strcmp( app_shell->name, "help"))
X				label_help_widget = label;
X			if( !strcmp( app_shell->name, "error"))
X				label_error_widget = label;
X
X			prev_widget = label;
X		}
X
X		/* if object declared is a message create it */
X		if(strcmp(child->type, "message") ==  0)
X		{
X
X			get_message_args(top_level, child->resources,
X			    args, &num_args, app_shell->name);
X
X			XtSetArg(args[num_args], XtNallowResize, 
X			    True);
X			num_args++;
X			XtSetArg(args[num_args], XtNeditType, XttextEdit);
X			num_args++;
X			XtSetArg(args[num_args], XtNtextOptions, editable|wordBreak);
X			num_args++;
X			XtSetArg(args[num_args], XtNlength, 1000);
X			num_args++;
X			XtSetArg(args[num_args], XtNresizable, TRUE);
X			num_args++;
X			XtSetArg(args[num_args], XtNsensitive, FALSE);
X			num_args++;
X			XtSetArg(args[num_args], XtNfromVert, prev_widget);
X			num_args++;
X			message = XtCreateManagedWidget("", 
X			    asciiStringWidgetClass,
X			    vpane, args, num_args);
X
X			/* if the msgboard is a help msgboard store the *
X			 * message address for later use                */
X			if( !strcmp( app_shell->name, "help"))
X				help_msg_widget = message;
X
X			if( !strcmp( app_shell->name, "error"))
X				error_msg_widget = message;
X
X			prev_widget = message;
X
X		}
X
X		if(!strcmp(child->type, "button"))
X		{
X			/* if this is the first button create a form to *
X	   * contain it with  all the declared buttons    */
X			if(button_entered == 0)
X			{
X				XtSetArg(args[0], XtNborderWidth, 0);
X				XtSetArg(args[1], XtNfromVert, prev_widget);
X				form = XtCreateManagedWidget("", formWidgetClass,
X				    vpane, args, 2);
X				prev_widget = form;
X				button_entered = 1;
X			}
X			get_button_args(shell, child->resources,
X			    args, &num_args, app_shell->name, NULL);
X
X			XtSetArg( args[num_args], XtNleft, XtChainLeft);
X			num_args++;
X			XtSetArg( args[num_args], XtNright, XtChainLeft);
X			num_args++;
X			XtSetArg( args[num_args], XtNfromHoriz,
X			    button);
X			num_args++;
X
X			button = XtCreateManagedWidget("", helpcommandWidgetClass,
X			    form, args, num_args);
X
X
X		}
X
X		child = child->next_widget;
X	}
X	return(shell);
X}
X
END_OF_FILE
if test 4248 -ne `wc -c <'create_msgboard.c'`; then
    echo shar: \"'create_msgboard.c'\" unpacked with wrong size!
fi
# end of 'create_msgboard.c'
fi
if test -f 'create_scrollbar.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create_scrollbar.c'\"
else
echo shar: Extracting \"'create_scrollbar.c'\" \(6467 characters\)
sed "s/^X//" >'create_scrollbar.c' <<'END_OF_FILE'
X#define MAX_NUM_ARGS 15
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/CompositeP.h>
X#include <X11/CommandP.h>
X#include <X11/LabelP.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Viewport.h>
X#include <X11/Form.h>
X#include <X11/Core.h>
X#include <X11/VPaned.h>
X#include "Helpcommand.h"
X#include "Dynamicshell.h"
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X
X#include "application.h"
X#define UNKNOWN_STRING		0
X#define FILE_STRING			1
X#define DIRECTORY_STRING	2
X#define COMMAND_STRING		3
X
Xextern Widget top_level;
X
Xstatic Arg pane_args[3] = {
X	{XtNdefaultDistance, (XtArgVal)0},
X	{XtNborderWidth, (XtArgVal)0},
X	{XtNgripIndent, (XtArgVal) -30},
X};
XWidget shell;
X
Xvoid destroy_shell(widget, closure, call_data)
XWidget widget;
Xcaddr_t closure;
Xcaddr_t call_data;
X{
X	Widget shell,
X	    get_shell_address();
X
X	shell = get_shell_address( closure );
X
X	XtDestroyWidget(shell);
X
X	remove_shell_address(closure);
X}
X
XWidget create_scrollbar(app_shell)
Xstruct shell *app_shell;
X{
X	Widget 
X	    vpane,
X	    label,
X	    viewport,
X	    vpane2,
X	    button;
X	int status;
X	char buf[STR_LEN];
X	char name[STR_LEN];
X	int string_type ;
X	int num_args = 0;
X	int viewport_created = 0;
X	FILE *fp,
X	    *popen();
X	XtArgVal ptr;
X	static Arg args[MAX_NUM_ARGS];
X	struct widget *child;
X	char *tmp;
X	struct stat filestat ;
X	DIR *opendir() ;
X	DIR *dirp ;
X	struct direct *readdir() ;
X	struct direct *dp ;
X
X	/* build the argument list for the enclosing shell*/
X	get_shell_args(top_level, app_shell->resources,
X	    args, &num_args);
X
X
X	XtSetArg(args[num_args], XtNallowResize, TRUE);
X	num_args++;
X	XtSetArg(args[num_args], XtNtransient, False);
X	num_args++;
X
X	/* create enclosing shell */
X	shell = XtCreatePopupShell("", 
X	    dynamicshellWidgetClass,
X	    top_level, args, num_args);
X
X	/* If  the shell is dynamic it should be destroyed when it 
X	 * popped down
X	 */
X	XtSetArg( args[0], XtNupdateFrom, &ptr);
X	XtGetValues( shell, args, 1);
X
X
X	if ( ptr != NULL )
X		XtAddCallback(shell, "popdownCallback", destroy_shell, app_shell->name);
X
X	/* enter the created shell in the hash table */
X	enter_shell_address( shell, app_shell->name);
X
X	/* create the geometry management widget that will tile *
X	 * the label and buttons vertically                     */
X	vpane = XtCreateManagedWidget("", vPanedWidgetClass,
X	    shell, pane_args, 3);
X
X	child = app_shell->child;
X
X	/* loop over all the declared labels and buttons */
X	while(child != NULL)
X	{
X		/* if a label is declared create it */
X		if(!strcmp(child->type,"label"))
X		{
X			get_label_args(top_level, child->resources,
X			    args, &num_args, app_shell->name);
X
X			label = XtCreateManagedWidget("label", 
X			    labelWidgetClass,
X			    vpane, args, num_args);
X			goto next;
X		}
X
X		/*if a button  is declared create it */
X		if(!strcmp(child->type, "button"))
X		{
X			/*create one viewport for all buttons*/
X			if( viewport_created == 0 )
X			{
X				XtSetArg(args[0], XtNallowVert, True);
X
X				viewport = XtCreateManagedWidget("",
X				    viewportWidgetClass,
X				    vpane, args, 1);
X
X				vpane2 = XtCreateManagedWidget("",
X				    vPanedWidgetClass,
X				    viewport, pane_args, 3);
X				viewport_created = 1;
X			}
X
X			/*if the menu is dynamic search for button names*/
X			if( ptr != NULL )
X			{
X				char ptr_expanded[1024] ;
X				/*
X				char buf3[STR_LEN] ;
X				char *p1, *p2, *p3, *p4 ;
X				char *getenv() ;
X				int i ;
X
X				for(p1=(char *)ptr, p2=ptr_expanded; *p1 != NULL; )
X				{
X					if (*p1 == '$')
X					{
X						p3 = buf3 ;
X						p1++ ;
X						while(*p1 != ' ' && *p1 != '$' && *p1 != '/' & *p1 != NULL)
X							*p3++ = *p1++ ;
X						*p3 = NULL ;
X						p4 = getenv(buf3) ;
X						i = strlen(p4) ;
X						while(i--)
X							*p2++ = *p4++ ;
X					}
X					else
X					{
X						*p2++ = *p1++ ;
X					}
X					*p2 = NULL ;
X				}
X				*/
X				strcpy(ptr_expanded, (char *)ptr) ;
X				expand_string(ptr_expanded, 1024) ;
X
X				/* get file info */
X				string_type = UNKNOWN_STRING ;
X				if (*ptr_expanded == '!')
X					string_type = COMMAND_STRING ;
X				else if (!stat(ptr_expanded, &filestat))
X				{
X					/* test if the argument to updatefrom is a directory*/
X					if (filestat.st_mode & S_IFDIR)
X						string_type = DIRECTORY_STRING ;
X					else if (filestat.st_mode & S_IFREG)
X						string_type = FILE_STRING ;
X					else
X					{
X						fprintf(stderr,"Warning: <%s> not accessible\n",
X							(char *)ptr) ;
X					}
X				}
X				else
X				{
X					fprintf(stderr,"Warning: <%s> not found\n", (char *)ptr) ;
X				}
X
X				/*build arg list  for all the scrollbar buttons*/
X				get_button_args(top_level, child->resources,
X				    args, &num_args, app_shell->name, NULL);
X
X				/* make each line in the specified file or each *
X				 * file in the directory a button in the menu   */
X
X				if (string_type == COMMAND_STRING)
X				{
X/* fprintf(stderr,"updating from command\n") ; */
X					if (NULL == (fp = popen(ptr_expanded+1, "r")))
X						fprintf(stderr,"Error: Can't access <%s>\n", ptr_expanded) ;
X					else
X					{
X						while(fgets(buf, 40, fp))
X						{
X							sscanf(buf,"%[^\n]", name);
X
X							XtCreateManagedWidget(name, helpcommandWidgetClass,
X								vpane2, args, num_args);
X						}
X					}
X					pclose(fp);
X				}
X				else if (string_type == FILE_STRING)
X				{
X/* fprintf(stderr,"updating from file\n") ; */
X					if (NULL == (fp = fopen(ptr_expanded, "r")))
X						fprintf(stderr,"Error: Can't access <%s>\n", ptr_expanded) ;
X					else
X					{
X						while(fgets(buf, 40, fp))
X						{
X							sscanf(buf,"%[^\n]", name);
X
X							XtCreateManagedWidget(name, helpcommandWidgetClass,
X								vpane2, args, num_args);
X						}
X					}
X					pclose(fp);
X				}
X				else if (string_type == DIRECTORY_STRING)
X				{
X/* fprintf(stderr,"updating from directory\n") ; */
X					dirp = opendir(ptr_expanded) ;
X					for(dp=readdir(dirp); dp != NULL; dp = readdir(dirp))
X					{
X						if(*(dp->d_name) != '.')
X							XtCreateManagedWidget(dp->d_name, helpcommandWidgetClass,
X								vpane2, args, num_args);
X					}
X					closedir(dirp) ;
X				}
X			}
X			/* if the shell is static create each individual button */
X			else
X			{
X				get_button_args(top_level, child->resources,
X				    args, &num_args, NULL,  app_shell->name);
X				button = XtCreateManagedWidget("",
X				    helpcommandWidgetClass,
X				    vpane2, args, num_args );
X			}
X
X			goto next;
X		}
X		fprintf(stderr,"Error in menu %s. The object type %s is not supported in menus", app_shell->name,  child->type);
X
Xnext:
X		child = child->next_widget;
X	}
X
X	return( shell);
X}
END_OF_FILE
if test 6467 -ne `wc -c <'create_scrollbar.c'`; then
    echo shar: \"'create_scrollbar.c'\" unpacked with wrong size!
fi
# end of 'create_scrollbar.c'
fi
if test -f 'create_shell.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create_shell.c'\"
else
echo shar: Extracting \"'create_shell.c'\" \(599 characters\)
sed "s/^X//" >'create_shell.c' <<'END_OF_FILE'
X#define MAX_NUM_SHELLS 50
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/Shell.h>
X#include "application.h"
X
XWidget create_shell( app_shell )
Xstruct shell *app_shell;
X{
X
X	Widget shell = NULL;
X	Widget create_scrollbar(),
X	    create_cmdboard(),
X	    create_msgboard();
X
X
X	if ( strcmp(app_shell->type,"menu" ) == 0)
X		shell =  create_scrollbar( app_shell );
X
X
X	if ( strcmp(app_shell->type, "msgboard" ) == 0)
X		shell = create_msgboard( app_shell) ;
X
X
X	if ( strcmp(app_shell->type, "cmdboard" ) == 0)
X		shell = create_cmdboard( app_shell );
X
X	return( shell );
X}
END_OF_FILE
if test 599 -ne `wc -c <'create_shell.c'`; then
    echo shar: \"'create_shell.c'\" unpacked with wrong size!
fi
# end of 'create_shell.c'
fi
if test -f 'expand_string.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'expand_string.c'\"
else
echo shar: Extracting \"'expand_string.c'\" \(948 characters\)
sed "s/^X//" >'expand_string.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <ctype.h>
X
Xexpand_string(string, max_len)
X	char *string ;
X	int max_len ;
X{
X	char old_string[1024] ;
X	char env[128] ;
X	char *o, *n, *e ;
X	char *getenv() ;
X	char *tmp ;
X	int atchar ;
X	int i ;
X	int status ;
X
X	strncpy(old_string, string, max_len) ;
X
X	o = old_string ;
X	n = string ;
X	atchar = 0 ;
X	status = 0 ;
X
X	while(*o != NULL)
X	{
X		if (atchar++ > max_len)
X			return(-1) ;
X		if (*o != '$')
X			*n++ = *o++ ;
X		else
X		{
X			e = env ;
X			o++ ;
X			while(isalpha(*o) || isdigit(*o) || (*o == '_'))
X				*e++ = *o++ ;
X			*e = NULL ;
X			tmp = getenv(env) ;
X			if(NULL == tmp)
X			{
X				fprintf(stderr,"Warning: <%s> is an undefined variable\n",env) ;
X				status = 1 ;
X			}
X			else
X				strcpy(env, tmp) ;
X
X			i = strlen(env) ;
X			atchar += i ;
X			if (atchar >= max_len)
X			{
X				fprintf(stderr,"Exceeded max string len\n") ;
X				return(-1) ;
X			}
X			e = env ;
X			while(i--)
X				*n++ = *e++ ;
X		}
X		*n = NULL ;
X	}
X	return(status) ;
X}
END_OF_FILE
if test 948 -ne `wc -c <'expand_string.c'`; then
    echo shar: \"'expand_string.c'\" unpacked with wrong size!
fi
# end of 'expand_string.c'
fi
if test -f 'get_button_args.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_button_args.c'\"
else
echo shar: Extracting \"'get_button_args.c'\" \(8783 characters\)
sed "s/^X//" >'get_button_args.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <sys/file.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Form.h>
X#include <X11/Command.h>
X#include "Helpcommand.h"
X
X#include "application.h"
X
Xextern void popdown_shell();
Xextern void popup();
Xextern void get_env();
Xextern void popdown();
Xextern void check();
Xextern void button_help();
Xextern void destroy();
Xextern void clear_cmdboard();
Xextern void runback();
Xextern void runfore();
Xextern void popdown_env();
Xvoid exit_app();
X
Xextern Widget top_level;
X
Xvoid
Xsetenv(w, closure, call_data)
X	Widget w;
X	caddr_t closure;
X	caddr_t call_data;
X{
X	Arg args[2];
X	XtArgVal ptr;
X	char *tmp;
X	char *p1, *p2, *p3 ;
X	char var[1024];
X	char buf1[1024];
X	char buf2[1024];
X	char buf3[1024] ;
X	char *strcat() ;
X	char *getenv() ;
X	char *malloc() ;
X	int i ;
X
X	/* Check command */
X	p1 = closure ;
X	p2 = buf2 ;
X	*p2 = NULL ;
X	while(*p1 != NULL)
X	{
X		if (!strncmp(p1, "buttonname", 10))
X		{
X			XtSetArg(args[0], XtNlabel, &ptr);
X			XtGetValues( w, args, 1);
X			i = strlen(ptr) ;
X			p3 = (char *)ptr ;
X			while(i--)
X				*p2++ = *p3++ ;
X			p1 += 10 ;
X		}
X		else
X		{
X			*p2++ = *p1++ ;
X		}
X		*p2 = NULL ;
X	}
X	*p2 = NULL ;
X	expand_string(buf2, 1024) ; /* expand environment variables */
X	p3 = malloc(1 + strlen(buf2)) ;
X	if (p3 == NULL)
X	{
X		fprintf(stderr,"Error on allocation in setenv\n") ;
X		exit(-1) ;
X	}
X	strcpy(p3, buf2) ;
X	putenv(p3);
X	sscanf(buf2,"%[^=]",var) ;
X	tmp = getenv(var);
X}
X
Xvoid
Xget_button_args(w, resources, args, num_args, shell_name, free_ptr)
X	Widget w;
X	struct resource *resources;
X	Arg args[];
X	int *num_args;
X	char *shell_name ;
X	char *free_ptr ;
X{
X	char buff[1024] ;
X	int i=0;
X	static XFontStruct *font;
X	struct resource *pres_resource;
X	char *label;
X	int c=0;
X	int pixel;
X	static XtCallbackRec callback[8];
X	static XtCallbackRec helpcallback[2];
X	void store();
X	FILE *fp,
X	    *popen();
X
X	pres_resource = resources;
X
X	while( pres_resource != NULL)
X	{
X
X		if( !strcmp( pres_resource->name, "background") )
X		{
X			pixel = get_pixel(pres_resource->value, shell_name,
X			    label);
X			if( pixel < 0 )
X				goto next;
X			XtSetArg(args[i], XtNbackground, pixel);
X			i++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "bordercolor" ) )
X		{
X			pixel = get_pixel( pres_resource->value, shell_name,
X			    label);
X			if( pixel < 0 )
X				goto next;
X
X			XtSetArg(args[i], XtNborderColor, pixel);
X			i++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "borderwidth"))
X		{
X			XtSetArg(args[i], XtNborderWidth, 
X			    atoi(pres_resource->value) );
X			i++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "highlight") )
X		{
X			XtSetArg( args[i], XtNhighlightThickness,
X			    atoi( pres_resource->value) );
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "font"))
X		{
X			font = XLoadQueryFont(XtDisplay(w), pres_resource->
X			    value);
X			if( font == NULL)
X			{
X				fprintf(stderr, "In shell %s: button %s. Could not load font %s. Using internal default.\n",
X				    shell_name, 
X				    label, pres_resource->value);
X				goto next;
X			}
X			XtSetArg(args[i], XtNfont, font);
X			i++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "foreground"))
X		{
X
X			pixel = get_pixel( pres_resource->value, shell_name,
X			    label);
X			if( pixel < 0 )
X				goto next;
X			XtSetArg(args[i], XtNforeground, pixel);
X			i++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "height") )
X		{
X			XtSetArg(args[i], XtNheight,
X			    atoi( pres_resource->value));
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, 
X		    "internalheight"))
X		{
X			XtSetArg(args[i], XtNinternalHeight,
X			    atoi(pres_resource->value));
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "internalwidth"))
X		{
X			XtSetArg(args[i], XtNinternalWidth,
X			    atoi(pres_resource->value));
X			i++;
X			goto next;
X		}
X
X
X		if(!strcmp(pres_resource->name, "label") )
X		{
X			if( !strcmp(pres_resource->value,"null"))
X				goto next;
X			label = pres_resource->value;
X			XtSetArg(args[i], XtNlabel,
X			    pres_resource->value);
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "width"))
X		{
X			XtSetArg(args[i], XtNwidth,
X			    atoi(pres_resource->value)),   i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "vertdistance") == 0)
X		{
X			XtSetArg(args[i], XtNvertDistance,
X			    atoi( pres_resource->value));
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "horizdistance") == 0)
X		{
X			XtSetArg(args[i], XtNhorizDistance,
X			    atoi( pres_resource->value));
X			i++;
X			goto next;
X		}
X
X		if( strcmp(pres_resource->name, "help") == 0)
X		{
X			XtSetArg(args[i], XtNhelp, pres_resource->value);
X			i++;
X			helpcallback[0].callback = button_help;
X			helpcallback[0].closure = (caddr_t)pres_resource->value;
X			helpcallback[1].callback = NULL;
X			helpcallback[1].closure = NULL;
X
X			XtSetArg(args[i], XtNhelpCallback, 
X			    helpcallback);
X			i++;
X
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "popup") )
X		{
X			callback[c].callback = popup;
X			callback[c].closure = (caddr_t)pres_resource->value;
X			c++;
X
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "getenv") )
X		{
X			callback[c].callback = get_env;
X			callback[c].closure = (caddr_t)pres_resource->value;
X			c++;
X			/*	 callback[c].callback = popdown;
X				 callback[c].closure = (caddr_t)free_ptr;
X				 c++;
X			*/
X			goto next;
X		}
X
X
X		if( !strcmp(pres_resource->name, "store"))
X		{
X			callback[c].callback = store;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "destroy"))
X		{
X			callback[c].callback = destroy;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "popdown"))
X		{
X			callback[c].callback = popdown;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "clearcmdboard"))
X		{
X			callback[c].callback = clear_cmdboard;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp( pres_resource->name, "commandarg" ))
X		{
X/* fprintf(stderr,"Working: %s\n", pres_resource->value) ; */
X			strcpy(buff, pres_resource->value) ;
X			expand_string(buff, 1024) ;
X			strcpy(free_ptr, buff);
X/* fprintf(stderr,"         %s\n", buff) ; */
X			if (*buff == '!') 
X			{
X			/* Attempt to run command */
X/* fprintf(stderr,"Running: %s\n", pres_resource->value) ; */
X				if (NULL != (fp = popen(pres_resource->value + 1, "r")))
X				{
X					if (NULL != fgets(buff, 1024, fp))
X					{
X						buff[strlen(buff)-1] = NULL ; /* Remove new line */
X						strcpy(free_ptr, buff) ;
X					}
X					pclose(fp) ;
X				}
X			}
X			else if (*buff != '[' && !access(buff, R_OK))
X			{
X			/* Assume to read file */
X				if (NULL != (fp = fopen(pres_resource->value, "r")))
X				{
X					if (NULL != fgets(buff, 1024, fp))
X					{
X						buff[strlen(buff)-1] = NULL ; /* Remove new line */
X						strcpy(free_ptr, buff) ;
X					}
X					fclose(fp) ;
X				}
X			}
X/* fprintf(stderr,"Returning: <%s>\n", free_ptr) ; */
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "check"))
X		{
X			callback[c].callback = check;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "runbackground"))
X		{
X			callback[c].callback = runback;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "runforeground"))
X		{
X			callback[c].callback = runfore;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		if( !strncmp(pres_resource->name, "set", 3))
X		{
X			char buff1[STR_LEN] ;
X			char buff2[STR_LEN] ;
X			char *buff ;
X			char *malloc() ;
X
X			sscanf(pres_resource->name, "set%s", buff1) ;
X			sprintf(buff2,"%s=%s",buff1, pres_resource->value) ;
X			buff = malloc(strlen(buff2)+1) ;
X			strcpy(buff, buff2) ;
X			callback[c].callback = setenv;
X			callback[c].closure = buff ;
X			c++;
X			goto next;
X		}
X
X		if( !strcmp(pres_resource->name, "exit"))
X		{
X			callback[c].callback = exit_app;
X			callback[c].closure = pres_resource->value;
X			c++;
X			goto next;
X		}
X
X		fprintf(stderr, "In shell %s button %s: %s. No such option for buttons. Ignored.\n", shell_name, label, 
X		    pres_resource->name);
X
X
Xnext:
X		pres_resource = pres_resource->next;
X
X	}
X
X
X
X	if( c>0 )
X	{
X		callback[c].callback = NULL;
X		callback[c].closure = NULL;
X		XtSetArg( args[i], XtNcallback,
X		    callback);
X		i++;
X
X	}
X
X	*num_args = i;
X
X}
X
Xvoid store(w, closure)
XWidget w;
Xcaddr_t closure;
X{
X	XtArgVal label;
X	Arg args[2];
X
X	if( !strcmp(closure, "buttonname"))
X	{
X		XtSetArg( args[0], XtNlabel, &label);
X		XtGetValues( w, args, 1);
X		XStoreBuffer( XtDisplay(w), label, strlen(label), 0);
X		return;
X	}
X
X	XStoreBuffer(XtDisplay(w), closure, strlen(closure), 0);
X}
X
X
X
X
X
Xvoid exit_app(w, closure)
XWidget w;
Xcaddr_t closure;
X{
X	destroy_env();
X	XtDestroyApplicationContext(XtWidgetToApplicationContext(top_level));
X	exit();
X}
X
X
END_OF_FILE
if test 8783 -ne `wc -c <'get_button_args.c'`; then
    echo shar: \"'get_button_args.c'\" unpacked with wrong size!
fi
# end of 'get_button_args.c'
fi
if test -f 'get_env.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_env.c'\"
else
echo shar: Extracting \"'get_env.c'\" \(3354 characters\)
sed "s/^X//" >'get_env.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/ShellP.h>
X#include  "application.h"
X
Xstatic Widget popped_up_shells[128];
Xstatic int num_popped_shells = 0;
X
Xvoid popup();
Xvoid popdown_env();
X
Xextern Widget top_level;
X
X
Xvoid get_env(w, envmt)
XWidget w;
Xchar *envmt;
X{
X	struct env_shell *get_env_shells();
X
X	struct shell *app_shell;
X	struct env_shell * initial_shell;
X
X
X	/*get the initial shells of the new environment*/
X	initial_shell = get_env_shells( envmt );
X
X	if (initial_shell == NULL)
X	{
X		fprintf( stderr,"Error: environment %s  not specified\n", envmt);
X		return;
X	}
X
X	/*popdown all the currently popped up shells*/
X	popdown_env();
X
X	/*popup the initial shells*/
X	while ( initial_shell != NULL )
X	{
X		popup(w, initial_shell->name);
X		initial_shell = initial_shell->next;
X	}
X}
X
Xvoid popdown_shell( shell )
XWidget shell;
X{
X	int count;
X	/* find the shell to be popped down and remove it from
X   * the popped up list
X   */
X	for( count = 0 ; count<num_popped_shells; count++ )
X		if( shell == popped_up_shells[count] )
X		{
X			popped_up_shells[count] = 
X			    popped_up_shells[--num_popped_shells];
X			/* pop it down*/
X			XtPopdown( shell );
X		}
X}
X
Xvoid popdown(w, shell_name)
XWidget w;
Xchar * shell_name;
X{
X	Widget shell;
X	Widget get_shell_address();
X
X	/*find the shell adress of the shell called shell_name*/
X	shell = get_shell_address(shell_name);
X	if( shell == NULL )
X		fprintf( stderr,"Error: shell %s to popdown not specified\n", shell_name);
X
X	/*pop it down*/
X	popdown_shell(shell);
X
X}
X
X
Xvoid popdown_env()
X
X{
X	int count;
X
X	/* popdown all the shells that are currently popped up */
X	for ( count=0 ; count<num_popped_shells; count++ )
X		XtPopdown( popped_up_shells[count] );
X
X	num_popped_shells = 0;
X
X
X}
X
Xvoid destroy_env()
X{
X	int count;
X
X	/* popdown all the shells that are currently popped up */
X	for ( count=0 ; count<num_popped_shells; count++ )
X		XtDestroyWidget( popped_up_shells[count] );
X}
X
Xvoid popup(w, name)
XWidget w;
Xcaddr_t name;
X{
X	Widget  popup_shell;
X	Widget get_shell_address();
X	struct shell *shell_des;
X	struct shell *get_shell();
X	Widget create_shell();
X	ShellWidget  widgetshell;
X
X	/*get the address of the shell called name*/
X	popup_shell = get_shell_address( name );
X
X	/* if not already created create it*/
X	if ( popup_shell == NULL )
X	{
X		shell_des = get_shell( name );
X		if( shell_des == NULL )
X		{
X			fprintf( stderr,"Error: shell %s to popup not specified\n", name);
X			return;
X		}
X
X		popup_shell = create_shell( shell_des );
X
X	}
X
X	if( popup_shell == NULL )
X	{
X		fprintf(stderr,"Error: could not create shell %s shell type declaration error", name);
X		return;
X	}
X
X	widgetshell = (ShellWidget)popup_shell;
X
X	/*if not popped up pop it up*/
X	if( !widgetshell->shell.popped_up )
X	{
X		XtPopup( popup_shell, XtGrabNone );
X		popped_up_shells[num_popped_shells++] = popup_shell;
X	}
X}
X
X
Xvoid destroy(w, shell_name)
XWidget w;
Xchar *shell_name;
X{
X	Widget shell;
X	Widget get_shell_address();
X
X
X
X	shell = get_shell_address( shell_name );
X
X
X	if( shell == NULL )
X	{
X		fprintf(stderr,"Error: shell %s to be destroyed not created or already destroyed", shell_name);
X		return;
X	}
X
X	popdown(w, shell_name);
X
X	XtDestroyWidget(shell);
X
X	/* remove the destroyed shell from the shell address 
X   * hash table
X   */
X	remove_shell_address(shell_name);
X}
END_OF_FILE
if test 3354 -ne `wc -c <'get_env.c'`; then
    echo shar: \"'get_env.c'\" unpacked with wrong size!
fi
# end of 'get_env.c'
fi
if test -f 'get_label_args.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_label_args.c'\"
else
echo shar: Extracting \"'get_label_args.c'\" \(3206 characters\)
sed "s/^X//" >'get_label_args.c' <<'END_OF_FILE'
X#include <stdio.h> 
X#include <X11/IntrinsicP.h> 
X#include <X11/Intrinsic.h>
X#include <X11/LabelP.h>
X#include <X11/StringDefs.h>
X#include <X11/Xlib.h>
X#include <X11/Form.h>
X#include "application.h"
X
Xget_label_args(w, resources, args,
Xnum_args, shell_name)
XWidget w;
Xstruct resource *resources;
XArg args[];
Xint *num_args;
Xchar *shell_name;
X{
X	int pixel;
X	int i=0;
X	XFontStruct *font;
X	struct resource *pres_resource;
X	char *label;
X	int label_width = 0;
X	int string_width = 0;
X
X	pres_resource = resources;
X
X	while( pres_resource != NULL)
X	{
X
X
X		if( strcmp( pres_resource->name, "background") == 0)
X		{
X			pixel = get_pixel( pres_resource->value);
X			if ( pixel < 0 )
X				goto next;
X			XtSetArg(args[i], XtNbackground, pixel); 
X			i++;
X			goto next;
X		}
X
X		if( strcmp( pres_resource->name, "bordercolor") == 0)
X		{
X			pixel = get_pixel( pres_resource->value);
X			if ( pixel < 0 )
X				goto next;
X			XtSetArg(args[i], XtNborderColor, pixel);  
X			i++;
X			goto next;
X		}
X
X		if( strcmp( pres_resource->name, "borderwidth") ==0)
X		{
X			XtSetArg(args[i], XtNborderWidth, 
X			    atoi(pres_resource->value) );  
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "font") == 0)
X		{
X			font = XLoadQueryFont(XtDisplay(w),pres_resource->value);
X			if ( font == NULL)
X			{
X				fprintf(stderr, "In shell %s: button %s. Could not load font %s. Using internal default.\n",
X				    shell_name,
X				    label, pres_resource->value);
X				goto next;
X			}
X
X			XtSetArg(args[i], XtNfont, font);  
X			i++;
X			goto next;
X		}
X
X		if( strcmp(pres_resource->name, "foreground") == 0)
X		{
X
X			pixel = get_pixel( pres_resource->value);
X			if ( pixel < 0 )
X				goto next;
X			XtSetArg(args[i], XtNforeground, pixel);  
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "height") == 0)
X		{
X			XtSetArg(args[i], XtNheight,
X			    atoi( pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, 
X		    "internalheight") == 0)
X		{
X			XtSetArg(args[i], XtNinternalHeight,
X			    atoi(pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "internalwidth") == 0)
X		{
X			XtSetArg(args[i], XtNinternalWidth,
X			    atoi(pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "justify") == 0)
X		{
X			XtSetArg(args[i], XtNjustify,
X			    pres_resource->value);   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "label") == 0)
X		{
X			label = pres_resource->value;
X			XtSetArg(args[i], XtNlabel,
X			    pres_resource->value);   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "width") == 0)
X		{
X			label_width = atoi(pres_resource->value);
X			XtSetArg(args[i], XtNwidth,
X			    pres_resource->value),   i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "x") == 0)
X		{
X			XtSetArg(args[i], XtNx,
X			    atoi( pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "y") == 0)
X		{
X			XtSetArg(args[i], XtNy,
X			    atoi( pres_resource->value));  
X			i++;
X			goto next;
X		}
X		fprintf(stderr, "In shell %s label %s: %s. No such option for labels. Ignored.\n", shell_name, label, 
X		    pres_resource->name);
X
Xnext: 
X		pres_resource = pres_resource->next;
X
X	}
X
X	*num_args = i;
X
X}
X
END_OF_FILE
if test 3206 -ne `wc -c <'get_label_args.c'`; then
    echo shar: \"'get_label_args.c'\" unpacked with wrong size!
fi
# end of 'get_label_args.c'
fi
if test -f 'get_message_args.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_message_args.c'\"
else
echo shar: Extracting \"'get_message_args.c'\" \(4841 characters\)
sed "s/^X//" >'get_message_args.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/LabelP.h>
X#include <X11/StringDefs.h>
X#include <X11/Xlib.h>
X#include <X11/Form.h>
X#include <X11/Text.h>
X#include <X11/AsciiText.h>
X
X#include "application.h"
X
Xint max_help_msg_width ,
Xmax_help_msg_height;
X
Xint max_error_msg_width,
Xmax_error_msg_height;
X
XXFontStruct *help_msg_font;
XXFontStruct *error_msg_font;
X
Xget_message_args(w, resources, args,
Xnum_args, shell_name)
XWidget w;
Xstruct resource *resources;
XArg args[];
Xint *num_args;
Xchar *shell_name;
X{
X	int i=0;
X	struct resource *pres_resource;
X	char *label;
X	char *font_name;
X	int label_width,
X	width,
X	height,
X	char_height,
X	max_width,
X	max_height,
X	pixel;
X	XFontStruct *font = NULL;
X
X	pres_resource = resources;
X
X	while( pres_resource != NULL)
X	{
X		if( !strcmp( pres_resource->name, "label"))
X		{
X			label = pres_resource->value;
X			if( strcmp( label, "help") != 0 &&
X			    strcmp( label, "error") != 0)
X			{
X				XtSetArg(args[i], XtNstring, pres_resource->value);
X				i++;
X			}
X			goto next;
X		}
X
X		if( strcmp( pres_resource->name, "background") == 0)
X		{
X			pixel = get_pixel(pres_resource->value);
X			XtSetArg(args[i], XtNbackground, 
X			    pixel); 
X			i++;
X			goto next;
X		}
X
X		if( strcmp( pres_resource->name, "bordercolor") == 0)
X		{
X			pixel = get_pixel(pres_resource->value);
X			XtSetArg(args[i], XtNborderColor,
X			    pixel); 
X			i++;
X			goto next;
X		}
X
X		if( strcmp( pres_resource->name, "borderwidth") ==0)
X		{
X			XtSetArg(args[i], XtNborderWidth, 
X			    atoi(pres_resource->value) );  
X			i++;
X			goto next;
X		}
X
X		if(strcmp(pres_resource->name, "font") == 0)
X		{
X			font_name = pres_resource->value;
X			font = XLoadQueryFont(XtDisplay(w),font_name);
X			if ( font == NULL)
X			{
X				fprintf(stderr, "In shell %s: message %s. Could not load font %s. Using internal default.\n",
X				    shell_name, 
X				    label, pres_resource->value);
X				font = XLoadQueryFont(XtDisplay(w), XtDefaultFont);
X			}
X
X			XtSetArg(args[i], XtNfont, font);  
X			i++;
X			if( strcmp(label, "help"))
X				help_msg_font = font;
X
X			if( strcmp(label, "error"))
X				error_msg_font = font;
X
X			goto next;
X		}
X
X		if( strcmp(pres_resource->name, "foreground") == 0)
X		{
X			pixel = get_pixel(pres_resource->value);
X			XtSetArg(args[i], XtNforeground,
X			    pixel); 
X			i++;
X			goto next;
X		}
X
X		/*    if(strcmp(pres_resource->name, "height") == 0)
X      {
X        XtSetArg(args[i], XtNheight,
X                atoi( pres_resource->value));   i++;
X        goto next;
X      }
X             
X       
X      if(strcmp(pres_resource->name, "width") == 0)
X        {
X          label_width = atoi(pres_resource->value);
X          XtSetArg(args[i], XtNwidth,
X                   atoi(pres_resource->value)),   i++;
X          goto next;
X        }
X
X      if(strcmp(pres_resource->name, "vertdistance") == 0)
X        {
X          XtSetArg(args[i], XtNvertDistance,
X                  atoi( pres_resource->value));   i++;
X
X          goto next;
X        }
X       
X      if(strcmp(pres_resource->name, "horizdistance") == 0)
X        {
X          XtSetArg(args[i], XtNhorizDistance,
X                  atoi( pres_resource->value));  i++;
X
X          goto next;
X        }
X  
X/*      if(strcmp(pres_resource->name, "label") == 0)
X        {
X          XtSetArg(args[i], XtNstring, ""); i++;
X          strcpy(string ,  pres_resource->value);
X          goto next;
X        }
X*/
X		if(strcmp(pres_resource->name, "maxwidth") == 0)
X		{
X			if ( !strcmp( label,"help") )
X			{
X				max_help_msg_width = atoi(pres_resource->value);
X				goto next;
X			}
X
X			if ( !strcmp( label,"error") )
X			{
X				max_error_msg_width = atoi(pres_resource->value);
X				goto next;
X			}
X
X
X			max_width = atoi(pres_resource->value);
X			goto next;
X		}
X
X
X		if(strcmp(pres_resource->name, "maxheight") == 0)
X		{
X			if ( !strcmp(label,"help"))
X			{
X				max_help_msg_height = atoi(pres_resource->value);
X				goto next;
X			}
X
X
X			if ( !strcmp(label,"error"))
X			{
X				max_error_msg_height = atoi(pres_resource->value);
X				goto next;
X			}
X			max_height = atoi(pres_resource->value);
X			goto next;
X
X		}
X
X		fprintf(stderr, "In shell %s message %s: %s.\n   No such option for buttons. Ignored.\n", shell_name, label,
X		    pres_resource->name);
Xnext: 
X		pres_resource = pres_resource->next;
X	}
X
X
X
X
X	if( strcmp( label, "help") != 0 && strcmp( label, "error") != 0)
X	{
X		if( font == NULL)
X		{
X			font = XLoadQueryFont(XtDisplay(w), XtDefaultFont);
X		}
X
X		width = XTextWidth(font, label, strlen(label));
X
X		char_height = font->ascent + font->descent;
X
X		height = (width/max_width +2) * char_height;
X
X		if(width > max_width)
X		{
X			XtSetArg(args[i], XtNwidth, max_width); 
X			i++;
X			XtSetArg(args[i], XtNheight, height+2); 
X			i++;
X		}
X
X		else
X		{
X			XtSetArg( args[i], XtNwidth, width+2); 
X			i++;
X			XtSetArg( args[i], XtNheight, 2*char_height + 2); 
X			i++;
X		}
X	}
X
X	*num_args = i;
X}
X
X
END_OF_FILE
if test 4841 -ne `wc -c <'get_message_args.c'`; then
    echo shar: \"'get_message_args.c'\" unpacked with wrong size!
fi
# end of 'get_message_args.c'
fi
if test -f 'get_pixel.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_pixel.c'\"
else
echo shar: Extracting \"'get_pixel.c'\" \(1190 characters\)
sed "s/^X//" >'get_pixel.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/CompositeP.h>
X#include <X11/CommandP.h>
X#include <X11/LabelP.h>
X#include <X11/Box.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Viewport.h>
X#include <X11/Form.h>
X#include <X11/Core.h>
X#include  "application.h"
X
Xextern Widget top_level;
X
Xint get_pixel(string, shell_name, item_name)
Xchar *string;
Xchar *shell_name;
Xchar *item_name;
X
X{
X
X	Colormap cmap;
X	Colormap XDefaultColormap();
X
X	XColor color;
X	int status;
X
X
X	cmap = XDefaultColormap( XtDisplay( top_level), 
X	    DefaultScreen(XtDisplay( top_level)));
X	if ( cmap == NULL)
X	{
X		fprintf(stderr, " Default Colormap Not Installed\n");
X		exit();
X	}
X
X	status = XParseColor( XtDisplay( top_level), cmap, string, &color);
X
X	if ( status == 0 )
X	{
X		fprintf(stderr, 
X		    "In shell %s item %s: %s. No such color in the database. Using internal default.\n",  shell_name, item_name,
X
X		    string);
X		return (-1);
X	}
X
X
X	status = XAllocColor( XtDisplay( top_level), cmap, &color);
X	if ( status == 0 )
X		fprintf(stderr, "In shell %s item %s. Unable to allocate the color resource. Using internal default.\n");
X
X
X	return( color.pixel);
X
X}
X
END_OF_FILE
if test 1190 -ne `wc -c <'get_pixel.c'`; then
    echo shar: \"'get_pixel.c'\" unpacked with wrong size!
fi
# end of 'get_pixel.c'
fi
if test -f 'get_shell_args.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_shell_args.c'\"
else
echo shar: Extracting \"'get_shell_args.c'\" \(2174 characters\)
sed "s/^X//" >'get_shell_args.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include "Dynamicshell.h"
X#include "application.h"
X
Xvoid get_shell_args(w, resources, args,
Xnum_args, name )
XWidget w;
Xstruct resource *resources;
XArg args[];
Xint *num_args;
Xchar **name;
X{
X
X	struct resource *pres_resource;
X	int i=0;
X	int update_entered = 0;
X	char *shell_name;
X	pres_resource = resources;
X
X	while( pres_resource != NULL)
X
X	{
X		/*  printf (" shell res name %s \n", pres_resource->name);
X  printf (" shell res value %s \n", pres_resource->value);*/
X
X		if(!strcmp(pres_resource->name, "label"))
X		{
X			/*        strcpy( name, pres_resource->value ); */
X			shell_name = pres_resource->value;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "width"))
X		{
X			XtSetArg(args[i], XtNwidth,
X			    atoi(pres_resource->value)),   i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "height"))
X		{
X			XtSetArg(args[i], XtNheight,
X			    atoi( pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "maxheight"))
X		{
X			XtSetArg(args[i], XtNmaxHeight,
X			    atoi(pres_resource->value));    
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "maxwidth"))
X		{
X			XtSetArg(args[i], XtNmaxWidth,
X			    atoi(pres_resource->value));    
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "x"))
X		{
X			XtSetArg(args[i], XtNx,
X			    atoi( pres_resource->value));   
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "y"))
X		{
X			XtSetArg(args[i], XtNy,
X			    atoi( pres_resource->value));  
X			i++;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "updatefrom"))
X		{
X			XtSetArg( args[i], XtNupdateFrom,
X			    pres_resource->value);
X			i++;
X			update_entered = 1;
X			goto next;
X		}
X
X		if(!strcmp(pres_resource->name, "override"))
X		{
X			if(!strcmp(pres_resource->value,"on"))
X				XtSetArg( args[i], XtNoverrideRedirect, True); 
X			i++;
X			goto next;
X		}
X
X		fprintf(stderr, "In shell %s:%s. No such option for shells. Ignored.\n", shell_name, pres_resource->name);
X
Xnext: 
X		pres_resource = pres_resource->next;
X
X	}
X	if( update_entered == 0 )
X	{
X		XtSetArg( args[i], XtNupdateFrom, NULL );
X		i++;
X	}
X
X	*num_args = i;
X}
X
X
END_OF_FILE
if test 2174 -ne `wc -c <'get_shell_args.c'`; then
    echo shar: \"'get_shell_args.c'\" unpacked with wrong size!
fi
# end of 'get_shell_args.c'
fi
if test -f 'get_string.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_string.c'\"
else
echo shar: Extracting \"'get_string.c'\" \(2034 characters\)
sed "s/^X//" >'get_string.c' <<'END_OF_FILE'
X/* Removes leading white space, then retrieves a string terminated by 
X * white space, or a string bounded by double quotes.
X */
X
X#include <stdio.h>
X#include <ctype.h>
Xget_string(fp, string, stopchar, max)
X	FILE *fp ;
X	char *string ;
X	int stopchar ;
X	int max ;
X{
X	char *s ;
X	int m ;
X	int C ;
X
X	m = 0 ;
X	s = string ;
X
X/* Skip white spaces */
X	while(isspace(C = get_a_char(fp)))
X		;
X	if (EOF == C)
X		eof_error() ;
X
X/* Read strings enclosed by "" */
X	if (C == '"')
X	{
X		do
X		{
X			if (EOF == (C = get_a_char(fp)))
X				eof_error() ;
X			if (C == '\\')
X			{
X				while(isspace(C = get_a_char(fp)))
X					;
X				if (EOF == C)
X					eof_error() ;
X			}
X			if (++m >= max)
X			{
X				*s = NULL ;
X				fprintf(stderr,"Error: Ran out of space <%d chars max> reading:\n<%s>\n",
X					max, string) ;
X				exit(-1) ;
X			}
X			else
X				*s = toascii(C) ;
X		}	while(*s++ != '"') ;
X		s-- ;
X	}
X/* Read strings terminated by white space "" */
X	else
X	{
X		*s = (char)C ;
X		do
X		{
X			s++ ;
X			if (EOF == (C = get_a_char(fp)))
X				eof_error ;
X			if (C == '\\')
X			{
X				while(isspace(C = get_a_char(fp)))
X					;
X				if (EOF == C)
X					eof_error() ;
X			}
X			if (++m >= max)
X			{
X				*s = NULL ;
X				fprintf(stderr,"Error: Ran out of space reading <%s>\n",
X					string) ;
X				exit(-1) ;
X			}
X			else
X				*s = toascii(C) ;
X		} while((! isspace(C)) && (C != stopchar)) ;
X		ungetc( C, fp);
X	}
X	*s = NULL ;
X	return(0) ;
X}
X
Xget_symbol(fp, c)
X	FILE *fp ;
X	int *c ;
X{
X	int C ;
X	while(isspace(C = get_a_char(fp)))
X		;
X	if (EOF == C)
X		eof_error() ;
X	*c = toascii(C) ;
X}
X
Xcheck_eof(fp)
X	FILE *fp ;
X{
X	int C ;
X	while(isspace(C = get_a_char(fp)))
X		;
X	if (EOF == C)
X		return(1) ;
X
X	ungetc( C, fp);
X	return(0) ;
X}
X
Xstatic
Xeof_error()
X{
X	fprintf(stderr, "Error: unexpected end of file\n") ;
X	exit(-1) ;
X}
X
X/* This subroutine discards any lines beginning with the # symbol */
Xstatic
Xget_a_char(fp)
X	FILE *fp ;
X{
X	static int lastc = '\n' ;
X	int c ;
X
X	c = getc(fp) ;
X
X	if(lastc == '\n')
X		while (c == '#')
X		{
X			while(getc(fp) != '\n')
X				;
X			c = getc(fp) ;
X		}
X	return(lastc = c) ;
X}
END_OF_FILE
if test 2034 -ne `wc -c <'get_string.c'`; then
    echo shar: \"'get_string.c'\" unpacked with wrong size!
fi
# end of 'get_string.c'
fi
echo shar: End of shell archive.
exit 0