david@jpl-devvax.jpl.nasa.gov (David E. Smyth) (12/18/90)
Submitted-by: david@jpl-devvax.jpl.nasa.gov (David E. Smyth) Posting-number: Volume 10, Issue 60 Archive-name: wcl/part12 # to unbundle, "sh" this file -- DO NOT use csh # SHAR archive format. Archive created Fri Oct 19 09:33:36 PDT 1990 echo x - WcReg.c sed 's/^X//' > WcReg.c <<'+FUNKY+STUFF+' X/* X** Copyright (c) 1990 David E. Smyth X** X** This file was derived from work performed by Martin Brunecky at X** Auto-trol Technology Corporation, Denver, Colorado, under the X** following copyright: X** X******************************************************************************* X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado. X* X* All Rights Reserved X* X* Permission to use, copy, modify, and distribute this software and its X* documentation for any purpose and without fee is hereby granted, provided X* that the above copyright notice appears on all copies and that both the X* copyright and this permission notice appear in supporting documentation X* and that the name of Auto-trol not be used in advertising or publicity X* pertaining to distribution of the software without specific, prior written X* permission. X* X* Auto-trol disclaims all warranties with regard to this software, including X* all implied warranties of merchantability and fitness, in no event shall X* Auto-trol be liable for any special, indirect or consequential damages or X* any damages whatsoever resulting from loss of use, data or profits, whether X* in an action of contract, negligence or other tortious action, arising out X* of or in connection with the use or performance of this software. X******************************************************************************* X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/* X* SCCS_data: @(#)WcReg.c 1.0 ( 19 June 1990 ) X* X* Subsystem_group: X* X* Widget Creation Library X* X* Module_description: X* X* Since (for portability reasons) we can not assume runtime binding, X* all widget classes, creation routines (constructors), and callbacks X* must be "registered" by the application BEFORE widget tree creation. X* X* All four of the functions defined in this module load dynamically X* allocated and extended arrays of structures. The size increment X* of the arrays starts at a reasonably small size (INCR_REGISTRY, X* initially 32), and is doubled in size everytime a given registry is X* filled. This allows registries to be small, yet to not have to be X* realloc'd frequently when they grow large. X* X* The registries are arrays of structs. In all four cases, the X* structs are very similar: they contain a name string which holds the X* class, constructor, or callback name as it was registered; a quark X* which is based on an all lower case representation of the name, and X* class, constructor, or callback specific information. The name X* as registered should be as shown in reference documents and source X* code, as it is used for user error messages. X* X* The registries are intended to be used by string-to-whatever converters. X* X* All four registration functions currently check for duplicate X* entries, but do no fancy hashing scheme, nor any ties to the X* application context. Assumming a relatively small number of X* entries in these regestries, it is assumed that a sequential X* search using quarks will be adequate and simple. X X* Module_interface_summary: X* X* WcRegisterClassPtr( X* XtAppContext app, - application context X* String name, - class ptr name, as in ref manuals X* WidgetClass class ) - class record pointer X* X* WcRegisterClassName( X* XtAppContext app, - application context X* String name, - class name, as in ref manuals X* WidgetClass class ) - class record pointer X* X* WcRegisterConstructor( X* XtAppContext app, - application context X* String name, - constructor name, as in ref manuals X* (*Widget)() const ) - constructor function pointer X* X* WcRegisterCallback( X* XtAppContext app, - application context X* String name, - callback name, "nice" capitalization X* void (*func)() ) - pointer to callback function X* X* WcRegisterAction( X* XtAppContext app, - application context X* String name, - action name X* XtActionProc proc ) - action proc X X* WcAllowDuplicateRegistration ( int allowed ) X* WcAllowDuplicateClassPtrReg ( int allowed ) X* WcAllowDuplicateClassNameReg ( int allowed ) X* WcAllowDuplicateConstructorReg ( int allowed ) X* WcAllowDuplicateCallbackReg ( int allowed ) X* X* Module_history: X X* mm/dd/yy initials function action X* -------- -------- -------- --------------------------------------------- X* 16Jul90 D.Smyth Added WcAllowDuplicate*() X* 19Jun90 D.Smyth Version 1.0 Widget Creation Library X* 06/08/90 D.Smyth All Added "name" member for better user msgs. X* 02/26/90 MarBru All Created X* 02/16/90 MarBru Create.. Limited creation to composite widgets/objects X* X* Design_notes: X* X* For VMS, we could have used LIB$FIND_IMAGE_SYMBOL and use dynamic X* (runtime) binding. But since most UNIX systems lack such capability, X* we stick to the concept of "registration" routines. X* X******************************************************************************* X*/ X/* X******************************************************************************* X* Include_files. X******************************************************************************* X*/ X X/* -- Widget Creation Includes */ X#include "WcCreate.h" X#include "WcCreateP.h" X X/* X******************************************************************************* X* Private_data_definitions. X******************************************************************************* X The following cache/registry of known widget classes, contructors, X and callbacks are initially empty, and are loaded by the application X using "registration" routines. X*/ X Xstatic char msg[MAX_ERRMSG]; X Xstatic int allowDuplicateClassPtrReg = FALSE; Xstatic int allowDuplicateClassNameReg = FALSE; Xstatic int allowDuplicateConstructorReg = FALSE; Xstatic int allowDuplicateCallbackReg = FALSE; X X/* -- Named class pointer cache, intially empty */ X Xint classes_num = 0; Xint classes_max = 0; XClCacheRec *classes_ptr = NULL; X X/* -- Class name cache, intially empty */ X Xint cl_nm_num = 0; Xint cl_nm_max = 0; XClNameCacheRec* cl_nm_ptr = NULL; X X/* -- Named object constructor cache, intially empty */ X Xint constrs_num = 0; Xint constrs_max = 0; XConCacheRec *constrs_ptr = NULL; X X/* -- Named callback procedures cache, intially empty */ X Xint callbacks_num = 0; Xint callbacks_max = 0; XCBCacheRec *callbacks_ptr = NULL; X X/* X******************************************************************************* X* Private_function_declarations. X******************************************************************************* X*/ X X/* X******************************************************************************* X* Public_function_declarations. X******************************************************************************* X*/ X X/* X -- Allow or Disallow Duplicate Registrations X******************************************************************************* X By default, the Widget Creation Library does not allow a X string-to-callback, string-to-class, etc bindings to be re-defined. X Some applications, most noticably user interface builders, need to be X able to change these bindings in order to provide additional X flexibility. Therefore the following functions are provided. The X typical user interface builder will make this single call: X X WcAllowDuplicateRegistration( TRUE ); X X which allows class pointers, class names, constructors, and callbacks X to be changed during execution. X*/ X Xvoid WcAllowDuplicateRegistration( allowed ) X int allowed; X{ X allowDuplicateClassPtrReg = allowed; X allowDuplicateClassNameReg = allowed; X allowDuplicateConstructorReg = allowed; X allowDuplicateCallbackReg = allowed; X} Xvoid WcAllowDuplicateClassPtrReg( allowed ) X int allowed; X{ X allowDuplicateClassPtrReg = allowed; X} Xvoid WcAllowDuplicateClassNameReg( allowed ) X int allowed; X{ X allowDuplicateClassNameReg = allowed; X} Xvoid WcAllowDuplicateConstructorReg( allowed ) X int allowed; X{ X allowDuplicateConstructorReg = allowed; X} Xvoid WcAllowDuplicateCallbackReg( allowed ) X int allowed; X{ X allowDuplicateCallbackReg = allowed; X} X X/* X -- Register Class Pointer Name X******************************************************************************* X This procedure adds class pointer name to our list of registered X classes. Note that the class ptr name is effectively case insensitive X as it is being quarkified. However, one should register the class ptr X names using the "standard" capitalization (whatever is in the reference X manual for the widget set) as the name as registered is used for error X messages. X X The registry is primarily used by CvtStringToClassPtr(). X*/ X Xvoid WcRegisterClassPtr ( app, name, class ) X XtAppContext app; /* not used (yet), must be present */ X char* name; /* class ptr name, case insensitive */ X WidgetClass class; /* Xt object class pointer */ X{ X char *lowerCaseName; X XrmQuark quark; X ClCacheRec *rec; X int i; X X /* Might need to grow cache. Note that growth increment is exponential: X ** if lots of classes, don't need to keep realloc'ing so often. X */ X if (classes_num >= classes_max ) X { X classes_max += (classes_max ? classes_max : INCR_REGISTRY); X classes_ptr = (ClCacheRec*) XtRealloc((char*)classes_ptr, X sizeof(ClCacheRec) * classes_max); X } X X /* See if this object has been registered. Compare quarks. X */ X lowerCaseName = WcLowerCaseCopy( name ); X quark = XrmStringToQuark ( lowerCaseName ); X XtFree ( lowerCaseName ); X X for (i = 0 ; i < classes_num ; i++ ) X { X if (classes_ptr[i].quark == quark) X { X /* already registered this class */ X if ( allowDuplicateClassPtrReg ) X { X rec = &classes_ptr[i]; /* overwrite this ClCacheRec */ X goto found_rec; X } X sprintf(msg, X "WcRegisterClassPtr (%s) - Failed \n\ X Problem: Duplicate class registration ignored.", X name ); X XtWarning( msg ); X return; X } X } X X rec = &classes_ptr[classes_num++]; /* New ClCacheRec to be filled */ X Xfound_rec: X rec->quark = quark; X rec->class = class; X rec->name = XtMalloc( strlen(name) + 1 ); X strcpy ( rec->name, name ); X} X X/* X -- Register Class Name X******************************************************************************* X This procedure adds a class name to our list of registered X classes. Note that the class name is effectively case insensitive X as it is being quarkified. However, one should register the class X names using the "standard" capitalization (whatever is in the reference X manual for the widget set) as the name as registered is used for error X messages. X X The registry is primarily used by CvtStringToClassName(). X*/ X Xvoid WcRegisterClassName ( app, name, class ) X XtAppContext app; /* not used (yet), must be present */ X char* name; /* class name, case insensitive */ X WidgetClass class; /* Xt object class pointer */ X{ X char *lowerCaseName; X XrmQuark quark; X ClNameCacheRec *rec; X int i; X X /* Might need to grow cache. Note that growth increment is exponential: X ** if lots of classes, don't need to keep realloc'ing so often. X */ X if (cl_nm_num >= cl_nm_max ) X { X cl_nm_max += (cl_nm_max ? cl_nm_max : INCR_REGISTRY); X cl_nm_ptr = (ClNameCacheRec*) XtRealloc((char*)cl_nm_ptr, X sizeof(ClNameCacheRec) * cl_nm_max); X } X X /* See if this object has been registered. Compare quarks. X */ X lowerCaseName = WcLowerCaseCopy( name ); X quark = XrmStringToQuark ( lowerCaseName ); X XtFree ( lowerCaseName ); X X for (i = 0 ; i < cl_nm_num ; i++ ) X { X if (cl_nm_ptr[i].quark == quark) X { X /* already registered this class */ X if ( allowDuplicateClassNameReg ) X { X rec = &cl_nm_ptr[i]; /* overwrite this ClNameCacheRec */ X goto found_rec; X } X sprintf(msg, X "WcRegisterClassName (%s) - Failed \n\ X Problem: Duplicate class registration ignored.", X name ); X XtWarning( msg ); X return; X } X } X X rec = &cl_nm_ptr[cl_nm_num++]; /* New ClNameCacheRec to be filled */ X Xfound_rec: X rec->quark = quark; X rec->class = class; X rec->name = XtMalloc( strlen(name) + 1 ); X strcpy ( rec->name, name ); X} X X/* X -- Register constructor X******************************************************************************* X This procedure adds constructor procedure/name to our list of registered X constructors. Note that the name is effectively case insensitive X as it is being quarkified. However, one should register the X names using the "standard" capitalization (whatever is in the reference X manual for the widget set) as the name as registered is used for error X messages. X X Note the constructor is a "Motif Style" widget creation routine, X commonly called a "confusion function." X X The registry is primarily used by CvtStringToConstructor(). X*/ X Xvoid WcRegisterConstructor ( app, name, constructor ) X XtAppContext app; /* not used (yet), must be present */ X char* name; /* constructor name, case insensitive */ X Widget (*constructor) (); /* pointer to a widget creation routine */ X{ X char *lowerCaseName; X XrmQuark quark; X ConCacheRec *rec; X int i; X X /* Might need to grow cache. Note that growth increment is exponential: X ** if lots of constructors, don't need to keep realloc'ing so often. X */ X if (constrs_num >= constrs_max ) X { X constrs_max += (constrs_max ? constrs_max : INCR_REGISTRY); X constrs_ptr = (ConCacheRec*) XtRealloc((char*)constrs_ptr, X sizeof(ConCacheRec) * constrs_max); X } X X /* See if this object has been registered. Compare quarks. X */ X lowerCaseName = WcLowerCaseCopy( name ); X quark = XrmStringToQuark ( lowerCaseName ); X XtFree ( lowerCaseName ); X X for (i = 0 ; i < constrs_num ; i++ ) X { X if (constrs_ptr[i].quark == quark) X { X /* already registered this class */ X if ( allowDuplicateConstructorReg ) X { X rec = &constrs_ptr[i]; /* overwrite this ConCacheRec */ X goto found_rec; X } X sprintf(msg, X "WcRegisterConstructor (%s) - Failed \n\ X Problem: Duplicate constructor registration ignored.", X name ); X XtWarning( msg ); X return; X } X } X X rec = &constrs_ptr[constrs_num++]; /* New ClCacheRec to be filled */ X Xfound_rec: X rec->quark = quark; X rec->constructor = constructor; X rec->name = XtMalloc( strlen(name) + 1 ); X strcpy ( rec->name, name ); X} X X/* X -- Register Callbacks X******************************************************************************* X Register callback functions which can then be bound to widget X callback lists by the string-to-callback converter X CvtStringToCallback(). X*/ X Xvoid WcRegisterCallback ( app, name, callback, closure ) X XtAppContext app; /* not used (yet), must be present */ X String name; /* callback name, case insensitive */ X XtCallbackProc callback; /* callback function pointer */ X caddr_t closure; /* default client data */ X{ X char *lowerCaseName; X XrmQuark quark; X CBCacheRec *rec; X int i; X X /* Might need to grow cache. Note that growth increment is exponential: X ** if lots of constructors, don't need to keep realloc'ing so often. X */ X if (callbacks_num >= callbacks_max ) X { X callbacks_max += (callbacks_max ? callbacks_max : INCR_REGISTRY); X callbacks_ptr = (CBCacheRec*) XtRealloc((char*)callbacks_ptr, X sizeof(CBCacheRec) * callbacks_max); X } X X /* See if this callback has been registered. Compare quarks. X */ X lowerCaseName = WcLowerCaseCopy( name ); X quark = XrmStringToQuark ( lowerCaseName ); X XtFree ( lowerCaseName ); X X for (i = 0 ; i < callbacks_num ; i++ ) X { X if (callbacks_ptr[i].quark == quark) X { X /* already registered this callback */ X if ( allowDuplicateCallbackReg ) X { X rec = &callbacks_ptr[i]; /* overwrite this CBCacheRec */ X goto found_rec; X } X sprintf(msg, X "WcRegisterCallback (%s) - Failed \n\ X Problem: Duplicate callback registration ignored.", X name ); X XtWarning( msg ); X return; X } X } X X rec = &callbacks_ptr[callbacks_num++]; /* New ClCacheRec to be filled */ X Xfound_rec: X rec->quark = quark; X rec->callback = callback; X rec->closure = closure; X rec->name = XtMalloc( strlen(name) + 1 ); X strcpy ( rec->name, name ); X} X X/* X -- Register Actions X******************************************************************************* X A simple wrapper around XtAppAddActions(). X Register action procs which can then be bound to widget X actions using standard Xt mechanisms. X*/ X Xvoid WcRegisterAction(app, name, proc) X XtAppContext app; X String name; X XtActionProc proc; X{ X static XtActionsRec action_rec[] = { X { (String)NULL, (XtActionProc)NULL } X }; X X action_rec[0].string = name; X action_rec[0].proc = proc; X XtAppAddActions(app, action_rec, 1); X} +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 18444 Oct 8 08:32 WcReg.c (as sent)' chmod u=rw,g=r,o=r WcReg.c ls -l WcReg.c echo x - WcRegXt.c sed 's/^X//' > WcRegXt.c <<'+FUNKY+STUFF+' X/* X** Copyright (c) 1990 David E. Smyth X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/* X* SCCS_data: @(#)WcRegXt.c 1.03 ( 23 July 1990 ) X* X* Subsystem_group: X* X* Widget Creation Library - Intrinsic Resource Interpreter X* X* Module_description: X* X* This module contains registration routine for all Intrinsic X* widget constructors and classes. X* X* Module_interface_summary: X* X* void WcRegisterIntrinsic ( XtAppContext app ) X* X* Module_history: X* X* mm/dd/yy initials function action X* -------- -------- -------- --------------------------------------------- X* 07/23/90 D.Smyth cleaned up function return values. X* 06/19/90 R.Whitby all create. X* X* Design_notes: X* X******************************************************************************* X*/ X/* X******************************************************************************* X* Include_files. X******************************************************************************* X*/ X X#include <X11/Intrinsic.h> X X#include <X11/Object.h> X#include <X11/RectObj.h> X#include <X11/Shell.h> X#include <X11/Vendor.h> X X/* -- Widget constructor routines */ X XWidget WcCreateApplicationShell (); XWidget WcCreateOverrideShell (); XWidget WcCreateShell (); XWidget WcCreateTopLevelShell (); XWidget WcCreateTransientShell (); XWidget WcCreateVendorShell (); XWidget WcCreateWMShell (); X X Xvoid WcRegisterIntrinsic ( app ) X XtAppContext app; X{ X static int alreadyRegisteredXt = 0; X X if ( alreadyRegisteredXt++ ) X return; X X#define RCN( name, class ) WcRegisterClassName ( app, name, class ); X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); X#define RCR( name, func ) WcRegisterConstructor(app, name, func ); X X /* -- register all Intrinsic widget classes */ X X RCN("Object", objectClass ); X RCP("objectClass", objectClass ); X RCN("RectObj", rectObjClass ); X RCP("rectObjClass", rectObjClass ); X#if defined(MOTIF) && MOTIF > 1 || MOTIF_MINOR > 0 X RCN("Core", coreWidgetClass ); X RCP("coreWidgetClass", coreWidgetClass ); X#endif X RCN("Composite", compositeWidgetClass ); X RCP("compositeWidgetClass", compositeWidgetClass ); X RCN("Constraint", constraintWidgetClass ); X RCP("constraintWidgetClass", constraintWidgetClass ); X RCN("ApplicationShell", applicationShellWidgetClass ); X RCP("applicationShellWidgetClass", applicationShellWidgetClass ); X RCN("OverrideShell", overrideShellWidgetClass ); X RCP("overrideShellWidgetClass", overrideShellWidgetClass ); X RCN("Shell", shellWidgetClass ); X RCP("shellWidgetClass", shellWidgetClass ); X RCN("TopLevelShell", topLevelShellWidgetClass ); X RCP("topLevelShellWidgetClass", topLevelShellWidgetClass ); X RCN("TransientShell", transientShellWidgetClass ); X RCP("transientShellWidgetClass", transientShellWidgetClass ); X RCN("VendorShell", vendorShellWidgetClass ); X RCP("vendorShellWidgetClass", vendorShellWidgetClass ); X RCN("WmShell", wmShellWidgetClass ); X RCP("wmShellWidgetClass", wmShellWidgetClass ); X X /* -- register all Intrinsic constructors */ X X RCR("XtCreateApplicationShell", WcCreateApplicationShell); X RCR("XtCreateOverrideShell", WcCreateOverrideShell); X RCR("XtCreateShell", WcCreateShell); X RCR("XtCreateTopLevelShell", WcCreateTopLevelShell); X RCR("XtCreateTransientShell", WcCreateTransientShell); X RCR("XtCreateWMShell", WcCreateWMShell); X RCR("XtCreateVendorShell", WcCreateVendorShell); X X#undef RCN X#undef RCP X#undef RCR X} X X/* X -- Create Application Shell X******************************************************************************* X This function creates an application shell widget. X X*/ XWidget WcCreateApplicationShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X X return XtCreatePopupShell(name, applicationShellWidgetClass, pw, args, nargs); X} X X/* X -- Create Override Shell X******************************************************************************* X This function creates an override shell widget. X X*/ XWidget WcCreateOverrideShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, overrideShellWidgetClass, pw, args, nargs); X} X X/* X -- Create Shell X******************************************************************************* X This function creates a shell widget. X X*/ XWidget WcCreateShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, shellWidgetClass, pw, args, nargs); X} X X/* X -- Create TopLevel Shell X******************************************************************************* X This function creates a top level shell widget. X X*/ XWidget WcCreateTopLevelShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, topLevelShellWidgetClass, pw, args, nargs); X} X X/* X -- Create Transient Shell X******************************************************************************* X This function creates an transient shell widget. X X*/ XWidget WcCreateTransientShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, transientShellWidgetClass, pw, args, nargs); X} X X/* X -- Create Vendor Shell X******************************************************************************* X This function creates a vendor shell widget. X X*/ XWidget WcCreateVendorShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, vendorShellWidgetClass, pw, args, nargs); X} X X/* X -- Create WM Shell X******************************************************************************* X This function creates an WM shell widget. X X*/ XWidget WcCreateWMShell ( pw, name, args, nargs ) X Widget pw; /* children's parent */ X String name; /* widget name to create */ X Arg *args; /* args for widget */ X Cardinal nargs; /* args count */ X{ X return XtCreatePopupShell(name, wmShellWidgetClass, pw, args, nargs); X} +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 7651 Oct 12 10:27 WcRegXt.c (as sent)' chmod u=rw,g=r,o=r WcRegXt.c ls -l WcRegXt.c echo x - makefile sed 's/^X//' > makefile <<'+FUNKY+STUFF+' X# Assumes that your Imake site.cf defines -DHAVE_MOTIF if you have motif. X# Otherwise, you will have to add a line which says: X# #define HAVE_MOTIF X# X# Note how Motif version numbers are defined: Motif 1.1 or Motif 1.1.1 X# is defined: X# MOTIF_VER = -DMOTIF=1 -DMOTIF_MINOR=1 X# and when Motif 2.7 comes out, MOTIF_VER gets define as: X# MOTIF_VER = -DMOTIF=2 -DMOTIF_MINOR=7 X# X# If your C compiler does not know how to use prototypes, you may X# need to add -D_NO_PROTO to the MOTIF_VER macros. This may be X# needed because many sites do not put Motif specific defines X# in their site.cf files used by Imake. X# X# Some Table.c and Table_m.c both include Xmu.h. If you are using X# Motif 1.0 and you have installed the X11R4 Xmu libraries, then X# you musr provide the XT_VER macro as shown. In all other cases, X# I think that the XT_VER macro is not needed. X# X# Also, if you have Motif installed in a non-standard place, set MOTIFDIR to X# point to it. The value of MOTIFDIR gets pre-pended to /include and /lib. X# X# Motif 1.0 required a special Xt Intrinsics, commonly named libXtm. If X# you are building for 1.0, MOTIFLIB should be -lXtm X X# X# typical for Motif 1.0 X# X MOTIF_VER = -DMOTIF=1 -DMOTIF_MINOR=0 X XT_VER = -DXtSpecificationRelease=4 X MOTIFDIR = /usr X MOTIFXT = -lXtm X MOTIFXTLIB = $(MOTIFDIR)/lib/libXtm.a X X# X# typical for Motif 1.1: X# X# MOTIF_VER = -DMOTIF=1 -DMOTIF_MINOR=1 -D_NO_PROTO X# MOTIFDIR = /usr X# MOTIFXT = -lXt X# MOTIFXTLIB = $(MOTIFDIR)/lib/libXt.a X X# X# C compiler and ld definitions - pick and choose, but you CANNOT use X# prototypes with Motif 1.1!!! But you can with Motif 1.0. X# X CDEBUGFLAGS = -O X# CDEBUGFLAGS = -O4 X# CDEBUGFLAGS = -g -DDEBUG X# CDEBUGFLAGS = -g -Bstatic -DDEBUG X# X CC = cc X# CC = gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -fwritable-strings -traditional X# CC = gcc -DFUNCTION_PROTOTYPES -ansi X X# X# Imake related stuff. X# You might need to change the MACROFILE, and -DHAVE_MOTIF. X# X X MACROFILE = sun.cf X IRULESRC = /usr/lib/X11/config X IMAKE = imake X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) -DHAVE_MOTIF X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) X# X# These defines probably never have to change. What may change X# is the inclusion of -lXext in the XLIB define, and the place X# to look for include files (the `-I/usr/include' in CFLAGS). X# X CFLAGS = $(CDEBUGFLAGS) -I. -I/usr/include X SYSLIBS = -lm X INSTALLLIBDIR = /usr/lib X INSTALLINCDIR = /usr/include/Wc X XAWLIB = -lXaw X XMULIB = -lXmu X XTOOLLIB = -lXt X XLIB = -lXext -lX11 X# X# These are aliases for various system commands used by this makefile X# X AR = ar cq XINSTALL = install X MAKE = make X MV = mv X RANLIB = ranlib X RM = rm -f X# X# Permission flags used at installation time X# X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTINCFLAGS = -m 0444 X X WCLIB = -L. -lWc X DEPWCLIB = ./libWc.a X X WCMLIB = -L. -lWcm X DEPWCMLIB = ./libWcm.a X Xall:: libWc.a Ari App MDathena libWcm.a Mri MDmotif X X# X# Rules for Ari X# X X ARI_LIBS = $(WCLIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) X ARI_OBJS = Ari.o AriRegAll.o Table.o X XAri: $(ARI_OBJS) $(DEPWCLIB) X $(RM) $@ X $(CC) -o $@ $(CDEBUGFLAGS) $(ARI_OBJS) $(ARI_LIBS) $(SYSLIBS) X Xclean:: X $(RM) Ari X# X# Rules for App X# X X APP_OBJS = App.o AriRegAll.o X XApp: $(APP_OBJS) $(DEPWCLIB) X $(RM) $@ X $(CC) -o $@ $(CDEBUGFLAGS) $(APP_OBJS) $(ARI_LIBS) $(SYSLIBS) X Xclean:: X $(RM) App X X# X# Rules for MDathena X# X X MDA_OBJS = MDathena.o AriRegAll.o Table.o X XMDathena.o: MD.c X $(RM) $@ X $(CC) -c $(CFLAGS) MD.c -o MDathena.o X XMDathena: $(MDA_OBJS) $(DEPWCLIB) X $(RM) $@ X $(CC) -o $@ $(CDEBUGFLAGS) $(MDA_OBJS) $(ARI_LIBS) $(SYSLIBS) X Xclean:: X $(RM) MDathena X X# X# Rules for libWc.a X# X X LIBWC_INCS = WcCreate.h WcCreateP.h X LIBWC_OBJS = WcCreate.o WcCallb.o WcConvert.o WcName.o \ X WcReg.o WcActions.o WcRegXt.o X X.c.o: X $(RM) $@ X $(CC) -c $(CFLAGS) $*.c X XlibWc.a: $(LIBWC_OBJS) X $(RM) $@ X $(AR) $@ $(LIBWC_OBJS) X $(RANLIB) $@ X Xinstall:: libWc.a X $(INSTALL) -c $(INSTLIBFLAGS) libWc.a $(INSTALLLIBDIR) X $(RANLIB) $(INSTALLLIBDIR)/libWc.a X Xinstall:: $(LIBWC_INCS) X @case '${MFLAGS}' in *[i]*) set +e;; esac; \ X for i in $(LIBWC_INCS); do \ X (set -x; $(INSTALL) -c $(INSTINCFLAGS) $$i $(INSTALLINCDIR)); \ X done X Xclean:: X $(RM) libWc.a X X############################################################################### X# Rules to build Motif clients and Wcl on Motif's Xt X############################################################################### X# Note that Motif doesn't provide Xmu, so pick it up from R4 X# X# Rules for Mri X# X X MRI_LIBS = $(WCMLIB) $(MOTIFLIB) X MRI_DEPLIBS = $(DEPWCMLIB) $(DEPMOTIFLIB) X X MOTIFLIB = -L$(MOTIFDIR)/lib -lXm $(MOTIFXT) $(XLIB) X DEPMOTIFLIB = $(MOTIFDIR)/lib/libXm.a $(MOTIFXTLIB) X X MRI_OBJS = Mri.o MriRegAll.o Table_m.o X MRI_INCLUDES = -I$(MOTIFDIR)/include/Xm -I$(MOTIFDIR)/include X X MRI_DEFINES = $(MOTIF_VER) $(MRI_INCLUDES) X XTable_m.o: Table_m.c X $(RM) $@ X $(CC) -c $(XT_VER) $(MRI_DEFINES) $(CFLAGS) $*.c XMri.o: Mri.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) $*.c XMriRegAll.o: MriRegAll.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) $*.c X XMri: $(MRI_OBJS) $(MRI_DEPLIBS) X $(RM) $@ X $(CC) -o $@ $(CDEBUGFLAGS) $(MRI_OBJS) $(MRI_LIBS) $(SYSLIBS) X Xclean:: X $(RM) Mri X X X# X# Rules for MDmotif X# X XMDM_OBJS = MDmotif.o MriRegAll.o Table_m.o X XMDmotif.o: MD.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) MD.c -o MDmotif.o X XMDmotif: $(MDM_OBJS) $(MRI_DEPLIBS) X $(RM) $@ X $(CC) -o $@ $(CDEBUGFLAGS) $(MDM_OBJS) $(MRI_LIBS) $(SYSLIBS) X Xclean:: X $(RM) MDmotif X X# X# Rules for libWcm.a X# X X LIBWCM_OBJS = WcmCreate.o WcmCallb.o WcmConvert.o \ X WcmName.o WcmReg.o WcmActions.o WcmRegXt.o X XWcmCreate.o: WcCreate.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcCreate.c -o WcmCreate.o XWcmCallb.o: WcCallb.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcCallb.c -o WcmCallb.o XWcmConvert.o: WcConvert.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcConvert.c -o WcmConvert.o XWcmName.o: WcName.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcName.c -o WcmName.o XWcmReg.o: WcReg.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcReg.c -o WcmReg.o XWcmActions.o: WcActions.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcActions.c -o WcmActions.o XWcmRegXt.o: WcRegXt.c X $(RM) $@ X $(CC) -c $(MRI_DEFINES) $(CFLAGS) WcRegXt.c -o WcmRegXt.o X XlibWcm.a: $(LIBWCM_OBJS) X $(RM) $@ X $(AR) $@ $(LIBWCM_OBJS) X $(RANLIB) $@ X Xinstall:: libWcm.a X $(INSTALL) -c $(INSTLIBFLAGS) libWcm.a $(INSTALLLIBDIR) X $(RANLIB) $(INSTALLLIBDIR)/libWcm.a X Xclean:: X $(RM) libWcm.a X Xclean:: X $(RM) *.o core X XMakefile:: makefile_orig X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DCURDIR=. X Xmakefile_orig: makefile X $(MV) makefile makefile_orig +FUNKY+STUFF+ echo '-rw-rw-r-- 1 david 7134 Oct 18 16:36 makefile (as sent)' chmod u=rw,g=rw,o=r makefile ls -l makefile echo x - patchlevel.h sed 's/^X//' > patchlevel.h <<'+FUNKY+STUFF+' X#define PATCHLEVEL 4 +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 21 Aug 6 09:45 patchlevel.h (as sent)' chmod u=rw,g=r,o=r patchlevel.h ls -l patchlevel.h echo x - test sed 's/^X//' > test <<'+FUNKY+STUFF+' X# !/bin/csh X# X# Execute all of the programs in the Widget Creation Library X# delivery. X# X Xalias se setenv XENVIRONMENT X Xecho This script will execute the programs once at a time. X Xif (-e App) then X se App1.All X App Xendif X Xif (-e Ari) then X foreach example (A[0-9][0-9].*) X se $example X Ari X end Xendif X Xif (-e Mri) then X foreach example (M[1-9].*) X se $example X Mri X end Xendif X Xif (-e MDathena) then X se MD X MDathena Xendif X Xif (-e MDmotif) then X echo If you are using Xtm instead of X11R4 Xt, then X echo this will core dump when you close a display, X echo and then try to open another display. X se MD X MDmotif Xendif +FUNKY+STUFF+ echo '-rwxr-xr-x 1 david 656 Oct 9 20:48 test* (as sent)' chmod u=rwx,g=rx,o=rx test ls -l test exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only. -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.