#! /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 shell archive."
# Contents:  wdiag.README wdiag.c wdiag.h
# Wrapped by matt@rapier on Tue Apr  7 20:54:23 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'wdiag.README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wdiag.README'\"
else
echo shar: Extracting \"'wdiag.README'\" \(373 characters\)
sed "s/^X//" >'wdiag.README' <<'END_OF_FILE'
XThe routines in these files (wdiag.h, wdiag.c) are useful for debugging 
XXt Widgets.  
X
XThey were originally written by Oliver Jones for a talk on developing 
XX11 applications presented in 1991.  He has kindly given permission 
Xfor them to be placed in the contrib area on export.lcs.mit.edu.
X
XThese routines are, of course, provided as-is and with no warantee
Xwhatsoever.
END_OF_FILE
if test 373 -ne `wc -c <'wdiag.README'`; then
    echo shar: \"'wdiag.README'\" unpacked with wrong size!
fi
# end of 'wdiag.README'
fi
if test -f 'wdiag.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wdiag.c'\"
else
echo shar: Extracting \"'wdiag.c'\" \(3002 characters\)
sed "s/^X//" >'wdiag.c' <<'END_OF_FILE'
X/*
X *  wdiag  --  widget hierarchy diagnostics.
X */
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/Intrinsic.h>
X#include <X11/IntrinsicP.h>
X#include <X11/CoreP.h>
X#include <X11/ObjectP.h>
X#include <X11/CompositeP.h>
X#include <X11/StringDefs.h>
X#include <ctype.h>
X
Xchar * nameof (widget)
X     Widget widget;
X{
X  static char fulname[1024];
X  Widget ancestry[256];
X  Widget w;
X  int nancs;
X  int i;
X
X  nancs = 0;
X  /* trace widget's ancestry */
X  for (w=widget; w; w=w->core.parent) {
X    ancestry[nancs++] = w;
X  }
X  /* run backwards through ancestry elucidating name string*/
X  fulname[0]='\0';
X  for (i = nancs; i; ) {
X    --i;
X    w = ancestry[i];
X    strcat (fulname,w->core.name);
X    if (i) {
X      strcat (fulname, ".");
X    }
X  }
X  return fulname;
X}
X  
Xchar * classof (widget)
X     Widget widget;
X{
X  static char fulclas[1024];
X  Widget ancestry[256];
X  Widget w;
X  int nancs;
X  int i;
X
X  nancs = 0;
X  /* trace widget's ancestry */
X  for (w=widget; w; w=w->core.parent) {
X    ancestry[nancs++] = w;
X  }
X  /* run backwards through ancestry elucidating strings */
X  fulclas[0]='\0';
X  for (i = nancs; i; ) {
X    --i;
X    w = ancestry[i];
X    strcat (fulclas,w->core.widget_class->core_class.class_name);
X    if (i) {
X      strcat (fulclas, ".");
X    }
X  }
X  return fulclas;
X}
X  
XWidget rootof (widget)
X     Widget widget;
X{
X  Widget w;
X  Widget result;
X
X  /* trace widget's ancestry */
X  for (w=widget; w; w=w->core.parent) {
X    result = w;
X  }
X  return result;
X}
X  
Xvoid treeof (widget)
X     Widget widget;
X{
X  Widget * wp;
X  int wc;
X  int i;
X
X  printf ("%-40s %s\n",nameof(widget),classof(widget));
X  if (XtIsComposite(widget)) {
X    CompositeRec * compw = (CompositeRec *) widget;
X    wp = compw->composite.children;
X    wc = compw->composite.num_children;
X    for (i = 0; i < wc ; i++) {
X      treeof (wp[i]);
X    }
X  }
X}
X  
Xchar * valueof (widget, value)
X     Widget widget;
X     char * value;
X{
X  char name[1024];
X  char clas[1024];
X  static char val [1024];
X  char str [1024];
X  XrmValue rmvalue;
X  char * str_type;
X  Display * dpy = XtDisplay(widget);
X  XrmDatabase database = dpy->db;
X  Boolean found;
X
X  strcpy (name, nameof(widget));
X  strcat (name, ".");
X  strcat (name, value);
X
X  strcpy (val, value);
X  if (islower(val[0])) val[0]=toupper(val[0]);
X  strcpy (clas, classof(widget));
X  strcat (clas, ".");
X  strcat (clas, val);
X  val[0] = '\0';
X
X  found = XrmGetResource (database, name, clas,
X			  &str_type, &rmvalue);
X  if (found) {
X    
X    if (0==strcmp ("String", str_type)) {
X      sprintf (val, "rm: (%s)", str_type);
X      strncpy (str, rmvalue.addr, rmvalue.size);
X      str[rmvalue.size] = '\0';
X      strcat (val," ");
X      strcat (val,str);
X    }
X    else if (   0==strcmp(str_type, "Dimension") 
X	     || 0==strcmp(str_type, "Int")
X	     || 0==strcmp(str_type, "Position")) {
X      sprintf (val, "rm: (%s) %d", str_type, *rmvalue.addr);
X    }
X    else {
X      sprintf (val, "rm: (%s) (length = %d)", str_type, rmvalue.size);
X    }      
X  }
X  return val;
X}
END_OF_FILE
if test 3002 -ne `wc -c <'wdiag.c'`; then
    echo shar: \"'wdiag.c'\" unpacked with wrong size!
fi
# end of 'wdiag.c'
fi
if test -f 'wdiag.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wdiag.h'\"
else
echo shar: Extracting \"'wdiag.h'\" \(2583 characters\)
sed "s/^X//" >'wdiag.h' <<'END_OF_FILE'
X#ifndef _WDIAG_H_
X#define _WDIAG_H_
X/*
X * wdiag -- widget hierarchy diagnostics
X */
X
X#ifndef _XtIntrinsic_h
X#include <X11/Intrinsic.h>
X#endif
X
X#define XtSpecificationRelease 4
X
X#ifdef XTFUNCPROTO
X#undef NeedFunctionPrototypes
X#define NeedFunctionPrototypes 1
X#else
X#undef NeedFunctionPrototypes
X#define NeedFunctionPrototypes 0
X#undef NeedWidePrototypes
X#define NeedWidePrototypes 0
X#endif
X
X#ifndef NeedFunctionPrototypes
X#if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
X#define NeedFunctionPrototypes 1
X#else
X#define NeedFunctionPrototypes 0
X#endif /* __STDC__ */
X#endif /* NeedFunctionPrototypes */
X
X/* NeedVarargsPrototypes is temporary until function prototypes work everywhere */
X#ifndef NeedVarargsPrototypes
X#if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) || NeedFunctionPrototypes
X#define NeedVarargsPrototypes 1
X#else
X#define NeedVarargsPrototypes 0
X#endif /* __STDC__ */
X#endif /* NeedVarargsPrototypes */
X
X#if defined(__cplusplus) || defined(c_plusplus)
X#define CONST const
X/* make const String do the right thing */
X#define String char*
X#else
X#define CONST
X#endif /* __cplusplus */
X
X#ifndef NeedWidePrototypes
X#if defined(NARROWPROTO)
X#define NeedWidePrototypes 0
X#else
X#define NeedWidePrototypes 1		/* default to make interropt. easier */
X#endif
X#endif
X
X#ifndef NULL
X#define NULL 0
X#endif
X
X#ifdef VMS
X#define externalref globalref
X#define externaldef(psect) globaldef {"psect"} noshare
X#else
X#define externalref extern
X#define externaldef(psect)
X#endif /* VMS */
X
X#ifndef FALSE
X#define FALSE 0
X#define TRUE 1
X#endif
X
X/***************************************************************
X *
X * Exported Interfaces
X *
X ****************************************************************/
X
X#ifdef __cplusplus			/* do not leave open across includes */
Xextern "C" {				/* for C++ V2.0 */
X#endif
X
Xextern char * nameof (
X#if NeedFunctionPrototypes
X    Widget 		/* widget */
X#endif
X);
X
Xextern char * classof (
X#if NeedFunctionPrototypes
X    Widget 		/* widget */
X#endif
X);
X
Xextern Widget rootof (
X#if NeedFunctionPrototypes
X    Widget 		/* widget */
X#endif
X);
X
Xextern void treeof (
X#if NeedFunctionPrototypes
X    Widget 		/* widget */
X#endif
X);
X
Xextern char * valueof (
X#if NeedFunctionPrototypes
X    Widget 		/* widget */,
X    char *              /* resource name */
X#endif
X);
X
X
X#ifdef __cplusplus
X}						/* for C++ V2.0 */
X#endif
X
X#if NeedWidePrototypes
X#undef Boolean
X#undef Dimension
X#undef KeyCode
X#undef Position
X#undef XtEnum
X#endif /* NeedWidePrototypes */
X
X#undef String
X#undef CONST
X
X#endif
END_OF_FILE
if test 2583 -ne `wc -c <'wdiag.h'`; then
    echo shar: \"'wdiag.h'\" unpacked with wrong size!
fi
# end of 'wdiag.h'
fi
echo shar: End of shell archive.
exit 0
