ssdken@watson.claremont.edu (Ken Nelson) (08/28/90)
Submitted-by: Ken Nelson <ssdken@watson.claremont.edu> Posting-number: Volume 8, Issue 103 Archive-name: xpeg/part01 Xpeg is a X simulation of the pegboard you see in many offices. It allows many people across an entire X-Windowed and NFS'ed network to keep track of the comings and goings of each other. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 2)." # Contents: xpeg1.0 xpeg1.0/COPYRIGHT xpeg1.0/Makefile xpeg1.0/README # xpeg1.0/Todo xpeg1.0/Xpeg.ad xpeg1.0/dynobj xpeg1.0/dynobj # xpeg1.0/dynobj/Makefile xpeg1.0/dynobj/README xpeg1.0/dynobj/dyn.h # xpeg1.0/dynobj/dyn.man xpeg1.0/dynobj/dynP.h # xpeg1.0/dynobj/dyn_append.c xpeg1.0/dynobj/dyn_create.c # xpeg1.0/dynobj/dyn_debug.c xpeg1.0/dynobj/dyn_delete.c # xpeg1.0/dynobj/dyn_header.c xpeg1.0/dynobj/dyn_insert.c # xpeg1.0/dynobj/dyn_paranoid.c xpeg1.0/dynobj/dyn_put.c # xpeg1.0/dynobj/dyn_realloc.c xpeg1.0/dynobj/dyn_size.c # xpeg1.0/dynobj/test.c xpeg1.0/pegbd.h xpeg1.0/pegbg.h # xpeg1.0/sample_pegfile xpeg1.0/strdup.c xpeg1.0/strtrim.c # xpeg1.0/xpeg.c xpeg1.0/xpeg.icon xpeg1.0/xui.h # Wrapped by ssdken@watson on Fri Aug 24 10:13:36 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test ! -d 'xpeg1.0' ; then echo shar: Creating directory \"'xpeg1.0'\" mkdir 'xpeg1.0' fi if test -f 'xpeg1.0/COPYRIGHT' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/COPYRIGHT'\" else echo shar: Extracting \"'xpeg1.0/COPYRIGHT'\" \(723 characters\) sed "s/^X//" >'xpeg1.0/COPYRIGHT' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X END_OF_FILE if test 723 -ne `wc -c <'xpeg1.0/COPYRIGHT'`; then echo shar: \"'xpeg1.0/COPYRIGHT'\" unpacked with wrong size! fi # end of 'xpeg1.0/COPYRIGHT' fi if test -f 'xpeg1.0/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/Makefile'\" else echo shar: Extracting \"'xpeg1.0/Makefile'\" \(845 characters\) sed "s/^X//" >'xpeg1.0/Makefile' <<'END_OF_FILE' X XXLIBS = -lXaw -lXmu -lXt -lXext -lX11 X XOBJECTS = pegbd.o xui.o xpeg.o strdup.o strtrim.o X XDEBUG = -g X XCFLAGS = $(DEBUG) -Idynobj X Xdefault : X @echo " make xpeg - makes xpeg" X @echo " make dist - makes an xpeg distribution" X @echo " make clean - cleans up xpeg objects etc..." X @echo " make allclean - cleans up xpeg and dynobj..." X @echo "" X @echo "To test after making: xpeg sample_pegfile" X @echo "" X Xxpeg : $(OBJECTS) dynobj/libdyn.a X cc $(CFLAGS) -o xpeg $(OBJECTS) dynobj/libdyn.a $(XLIBS) X Xdynobj/libdyn.a : X (cd dynobj; make) X X Xdist : X cp *.c ../xpeg/ X cp *.h ../xpeg/ X cp Makefile ../xpeg/ X cp Xpeg.ad ../xpeg/ X cp README ../xpeg/ X cp COPYRIGHT ../xpeg/ X cp sample_pegfile ../xpeg/ X cp xpeg.icon ../xpeg/ X cp Todo ../xpeg/ X cp -r dynobj ../xpeg/ X X Xclean : X -rm *.o xpeg X Xallclean : clean X (cd dynobj; make clean) END_OF_FILE if test 845 -ne `wc -c <'xpeg1.0/Makefile'`; then echo shar: \"'xpeg1.0/Makefile'\" unpacked with wrong size! fi # end of 'xpeg1.0/Makefile' fi if test -f 'xpeg1.0/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/README'\" else echo shar: Extracting \"'xpeg1.0/README'\" \(3353 characters\) sed "s/^X//" >'xpeg1.0/README' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copywrite 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X X XCurrent Release: 1.0, 24 Aug 90. XAuthor : Ken Nelson, ssdken@jarthur.claremont.edu XRequires : X11R4, Athena Widgets (-lXaw) , X Extensions (-lXext) X X X X X XAbout Xpeg X X Xpeg is a X simulation of the pegboard you see in many offices. It allows X many people across an entire X-Windowed and NFS'ed network to keep track of X the comings and goings of each other. X X X Xpeg accepts all standard X toolkit command line parameters. You must X specify an Xpeg file, which Xpeg uses to track locations of people. You X may optionally specify your name. If your name matches one in the Xpeg X file, then you may edit your location on the pegboard. The Xpeg file and X your name may be set using the environment variables XPEG_FILE and XPEG_USER. X X X XMaking Xpeg X X No imakefile yet. Just type: X make xpeg X X To test after the make type: X X xpeg sample_pegfile "Ken Nelson" X X X X XStarting an Xpeg File. X X When you start an Xpeg file, Xpeg will only have its name and command buttons X showing. Press the NEW button to add users. Once you have added all the X users, press the SAVE button to update the pegfile. X X NOTE: In XPEG 1.0 adding a new users does not automatically resize the X window. You have do do this by hand. When Xpeg starts up with X the new Xpeg next time the window will be the correct size. X X XWhat it all means. X X X The buttons: X X about - Pops up a little "About" box about Xpeg. X X quit - quits Xpeg X X update - rescans the Xpeg file to see if anybody else using X it has changed there location. An update before a X save will erase any changes you have made. X X save - saves any changes you have made to the Pegfile. X X new - adds a new person to the pegboard. X X group - Changes the name of the group this pegboard tracks. X (The 3rd pane in the window) X X X Your Username: - Your name. If it is Unkown then you won't be X allowed to edit any locations. You can't edit X any locations but yours. X X X X The pegboard has 3 fields: X X Name - who it is. X Date Updated - the date the location what last updated. X Location - where the user was when last updated. X X X X X X XBugs/Improvements X X If you use Xpeg, I would like to here from you. A simple e-mail saying X you are using would be great. If you have any bugs or improvements send them X along also. X X X Send them to: X X X ssdken@jarthur.claremont.edu X X Include xpeg or Xpeg in the subject line. X X X X X X X X Good luck, X X X X Ken Nelson X Principal Engineer X Software Systems Design X 3627 Padua Av. X Claremont, CA 91711 X (714) 624-3402 X X END_OF_FILE if test 3353 -ne `wc -c <'xpeg1.0/README'`; then echo shar: \"'xpeg1.0/README'\" unpacked with wrong size! fi # end of 'xpeg1.0/README' fi if test -f 'xpeg1.0/Todo' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/Todo'\" else echo shar: Extracting \"'xpeg1.0/Todo'\" \(1980 characters\) sed "s/^X//" >'xpeg1.0/Todo' <<'END_OF_FILE' X The TODO List - Xpeg X XNote: If you see something you would like to do here. Please e-mail me or call so X I can coordinate independent actions, and thus prevent duplication of effort. X X If you want to add a feature not mentioned here, the same applies. X X Patches are definitly welcome. Larry Wall's patch format preferred. Diffs accepted. X X If you add to this file, try to add in the same "awk"able format it is in now. X X Contact: X X Ken Nelson X ssdken@jarthur.claremont.edu X (714) 624-3402 X X X Problem : Make the stupid Athena Pane holding the people resize when you X add a new person. Or find an alternate Widget to hold them that X will resize. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Make person name a menubutton, that pops up a menu of common X locations to place into the location spot. Could make this X an action in the editor, I suppose but that has implications for X the readonly part of it. Could be another command button called X common. Menu defined by enviroment var, or resource file, or X command line. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Add a username button so the user can switch usernames inside X of xpeg. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Make updates automatic, or check for update needed every X x seconds. Kind of like xbiff. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Add -time "format" command to allow the user to format the date X stamping on location updates. Something ala dclock. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Allow the user to specify the pegfile and their pegboard name in the X defaults. X Suggested By: Ken Nelson X Assumed By: X X Problem : Add ability to switch between multiple pegboards. X Suggested By: Ken Nelson X Assumed By: X X X Problem : Use ndbm, dbm type file for pegfile instead of ascii file. (Perhaps) X Suggested By: Ken Nelson X Assumed By: X END_OF_FILE if test 1980 -ne `wc -c <'xpeg1.0/Todo'`; then echo shar: \"'xpeg1.0/Todo'\" unpacked with wrong size! fi # end of 'xpeg1.0/Todo' fi if test -f 'xpeg1.0/Xpeg.ad' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/Xpeg.ad'\" else echo shar: Extracting \"'xpeg1.0/Xpeg.ad'\" \(20 characters\) sed "s/^X//" >'xpeg1.0/Xpeg.ad' <<'END_OF_FILE' XXpeg.*showGrip: off END_OF_FILE if test 20 -ne `wc -c <'xpeg1.0/Xpeg.ad'`; then echo shar: \"'xpeg1.0/Xpeg.ad'\" unpacked with wrong size! fi # end of 'xpeg1.0/Xpeg.ad' fi if test ! -d 'xpeg1.0/dynobj' ; then echo shar: Creating directory \"'xpeg1.0/dynobj'\" mkdir 'xpeg1.0/dynobj' fi if test ! -d 'xpeg1.0/dynobj' ; then echo shar: Creating directory \"'xpeg1.0/dynobj'\" mkdir 'xpeg1.0/dynobj' fi if test -f 'xpeg1.0/dynobj/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/Makefile'\" else echo shar: Extracting \"'xpeg1.0/dynobj/Makefile'\" \(1305 characters\) sed "s/^X//" >'xpeg1.0/dynobj/Makefile' <<'END_OF_FILE' X# This file is part of libdyn.a, the C Dynamic Object library. It X# contains the Makefile. X# X# There are no restrictions on this code; however, if you make any X# changes, I request that you document them so that I do not get X# credit or blame for your modifications. X# X# Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X# and MIT-Project Athena, 1989. X XDESTDIR = /afs/.athena.mit.edu/contrib/sipb/$(MACHINE)lib XCC = cc XCFLAGS = -g XDEST = libdyn.a X XSRCS = dyn_create.c dyn_put.c dyn_debug.c dyn_delete.c dyn_size.c \ X dyn_append.c dyn_realloc.c dyn_paranoid.c dyn_insert.c XOBJS = dyn_create.o dyn_put.o dyn_debug.o dyn_delete.o dyn_size.o \ X dyn_append.o dyn_realloc.o dyn_paranoid.o dyn_insert.o XHDRS = dyn.h dynP.h X X$(DEST): $(OBJS) X rm -f $(DEST) X ar rc $(DEST) $(OBJS) X ranlib $(DEST) X Xinstall: X make $(INSTFLAGS) DEST="libdyn.a" CFLAGS="-g" clean libdyn.a X cp libdyn.a $(DESTDIR) X ranlib $(DESTDIR)/libdyn.a X make $(INSTFLAGS) DEST="libdyn_p.a" CFLAGS="-g -pg" clean libdyn_p.a X cp libdyn_p.a $(DESTDIR) X ranlib $(DESTDIR)/libdyn_p.a X Xall: $(DEST) test X Xtest: $(DEST) test.o X $(CC) -o test test.o $(DEST) X Xsaber: X #load $(SRCS) X Xclean: X rm -f $(OBJS) $(DEST) test *~ X Xdepend: X makedepend -- $(CLFAGS) -- $(HDRS) $(SRCS) X X# DO NOT DELETE THIS LINE -- make depend depends on it. END_OF_FILE if test 1305 -ne `wc -c <'xpeg1.0/dynobj/Makefile'`; then echo shar: \"'xpeg1.0/dynobj/Makefile'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/Makefile' fi if test -f 'xpeg1.0/dynobj/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/README'\" else echo shar: Extracting \"'xpeg1.0/dynobj/README'\" \(1503 characters\) sed "s/^X//" >'xpeg1.0/dynobj/README' <<'END_OF_FILE' Xlibdyn.a -- Release 1.0 X XA C Dynamic Object is an array that takes care of resizing itself as Xelements are added and deleted from it. It can be of any type for Xwhich sizeof is defined and for which an address of a variable of that Xtype can be passed to a function. X XTo build libdyn.a, simply type "make depend all" (if you don't have Xthe program makedepend, of course, leave out the "depend" part). If Xyour system's bcopy() cannot handle overlapping regions, you'll need Xto write one that can. (Left as an excercise for the reader..) X XThe library should compile and work without modification on a vast Xnumber of systems. It only uses 5 external functions: malloc, Xrealloc, free, bcopy, and fprintf (to stderr). Of these, only bcopy Xshould need to be changed for other systems (such as MS-DOS) and it Xcould probably be done with a -D flag to the compiler. X XThe test/demo program is built by "make all". This program produces Xthe library's debugging output (to stderr) as well as some of its own Xoutput (to stdout). X XThe library has been tested (with test.c) on a VAX VSII, VAXstation X3100, DECstation 3100, and IBM RT all running BSD4.3 (except for the XDECstation, which was running Ultrix V2.1). X XAn earlier version of this library was posted to alt.sources. This Xversion contains one new function (DynInsert) and slightly cleaner Xcode, but no bugfixes (no bugs were found). X XAuthor: Barr3y Jaspan, Student Information Processing Board (SIPB) and XMIT-Project Athena, bjaspan@athena.mit.edu, 1990 END_OF_FILE if test 1503 -ne `wc -c <'xpeg1.0/dynobj/README'`; then echo shar: \"'xpeg1.0/dynobj/README'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/README' fi if test -f 'xpeg1.0/dynobj/dyn.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn.h'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn.h'\" \(1087 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn.h' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the public header file. X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X X/* X * dyn.h -- header file to be included by programs linking against X * libdyn.a. X */ X X#ifndef _Dyn_h X#define _Dyn_h X X#ifdef notdef Xtypedef void *DynPtr; X#else Xtypedef char *DynPtr; X#endif X Xtypedef struct _DynObject DynObjectRec, *DynObject; X X/* Function macros */ X#define DynHigh(obj) (DynSize(obj) - 1) X#define DynLow(obj) (0) X X/* Return status codes */ X#define DYN_OK -1000 X#define DYN_NOMEM -1001 X#define DYN_BADINDEX -1002 X#define DYN_BADVALUE -1003 X X/* Function declarations */ XDynObject DynCreate(); Xint DynAdd(), DynDelete(), DynDestroy(), DynDebug(); Xint DynInsert(), DynParanoid(); XDynPtr DynGet(); X X#endif /* _Dyn_h */ X/* DO NOT ADD ANYTHING AFTER THIS #endif */ END_OF_FILE if test 1087 -ne `wc -c <'xpeg1.0/dynobj/dyn.h'`; then echo shar: \"'xpeg1.0/dynobj/dyn.h'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn.h' fi if test -f 'xpeg1.0/dynobj/dyn.man' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn.man'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn.man'\" \(4993 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn.man' <<'END_OF_FILE' X.TH DYN 3M "15 March 1990" X X.SH NAME Xdyn \- the C Dynamic Object library X X.SH DESCRIPTION X XA C Dynamic Object is an array that takes care of resizing Xitself as you add and delete elements from it. It can be of any type Xfor which sizeof is defined and for which an address of a variable of Xthat type can be passed to a function. The library containing the Xfunctions described below is called X.IR libdyn.a , Xand the necessary declarations to use them are in X.RI < dyn.h >. X.PP XA DynObject is actually a structure that contains an array and a Xcouple of integers to maintain necessary state information. When a XDyn function is said to operate on "the object" or "the array", it is Xoperating on the array stored in the structure while at the same time Xupdating internal state information. X X.SH LIST OF FUNCTIONS X.nf XDynObject DynCreate(size, increment) X int size, increment; X.fi X.PP X.IR Requires : X.I size Xand X.I increment Xare greater than zero. X.PP X.IR Effects : XCreates a new DynObject that will store elements of size X.I size Xand will allocate memory in blocks large enough to hold exactly X.I increment Xelements. For example, if you are storing 8-byte double Xprecision numbers and X.I increment Xis 5, each 5th element you add to the object will cause it to request X40 more bytes (8 * 5) from the operating system. If X.I increment Xis zero, a default value is used (currently 100). This is the only Xtime the programmer deals with a dynamic object's memory allocation. X.PP X.IR Returns : X.B DynCreate Xreturns the new DynObject, or NULL if there is insufficient memory. X.PP X.nf Xint DynDestroy(obj) X DynObject obj; X.fi X.PP X.IR Modifies : Xobj X.PP X.IR Effects : XFrees all memory associated with X.IR obj . XThe results of calling any Dyn function on a destroyed object are Xundefined (except for DynCreate, which resets the object). X.PP X.IR Returns : X.B DynDestroy Xreturns DYN_OK. X.PP X.nf Xint DynAdd(obj, el) X DynObject obj; X DynPtr el; X.fi X.PP X.IR Modifies : Xobj X.PP X.IR Effects : XAdds the element pointed to by X.I el Xto the object X.IR obj , Xresizing the object if necessary. XThe new element becomes the last element in obj's array. X.PP X.IR Returns : X.B DynAdd Xreturns DYN_OK on success or DYN_NOMEM if there is insufficient Xmemory. X.PP X.nf Xint DynInsert(obj, index, els, num) X DynObject obj; X DynPtr els; X int index, num; X.fi X.PP X.IR Modifies : Xobj X.PP X.IR Effects : XInserts the array of X.I num Xelements, pointed to by X.IR els, Xinto the object X.I obj Xstarting at the array location X.IR index , Xresizing the object if necessary. Order is preserved; if you have the Xarray "1 2 3 4 5" and insert "10 11 12" at the third position, you Xwill have the array "1 2 10 11 12 3 4 5". X.PP X.IR Returns : X.B DynInsert Xreturns DYN_BADINDEX if X.I index Xis not between 0 and X.BR DynSize ( obj ) ; XDYN_BADVALUE if X.I num Xis less than 1; DYN_NOMEM if there is insufficient memory. X.PP X.nf Xint DynGet(obj, index) X DynObject obj; X int index; X.fi X.PP X.IR Effects : XReturns the address of the element X.I index Xin the array of X.IR obj . XThis pointer can be treated as a normal array of the type specified to X.BR DynCreate . XThe order of elements in this array is the order in which they were Xadded to the object. The returned pointer is guaranteed to be valid Xonly until obj is modified. X.PP X.IR Returns : X.B DynGet Xreturns NULL if X.I index Xis larger than the number of elements in the array of less than zero. X.PP X.nf Xint DynDelete(obj, index) X DynObject obj; X int index; X.fi X.PP X.IR Modifies : Xobj X.PP X.IR Effects : XThe element X.I index Xis deleted from the object X.IR obj . XNote that the element is actually removed permanently from the array. XIf you have the array "1 2 3 4 5" and delete the third element, you Xwill have the array "1 2 4 5". The order of elements in not affected. X.PP X.IR Returns : X.B DynDelete Xwill return DYN_OK on success or DYN_BADINDEX if the element X.I index Xdoes not exist in the array or is less than zero. X.PP X.nf Xint DynSize(obj) X DynObject obj; X.fi X.PP X.IR Effects : XReturns the number of elements in the object X.IR obj . X.PP X.nf Xint DynHigh(obj) X DynObject obj; X.fi X.PP X.IR Effects : XReturns the index of the highest element in the object X.IR obj . XIn this version, X.B DynHigh Xis macro that expands to X.B DynSize X- 1. X.PP X.nf Xint DynLow(obj) X DynObject obj; X.fi X.PP X.IR Effects : XReturns the index of the lowest element in the object X.IR obj . XIn this version, X.B DynLow Xis macro that expands to 0. X.PP X.nf Xint DynDebug(obj, state) X DynObject obj; X int state; X.fi X.PP X.IR Modifies : Xobj X.PP X.IR Effects : XSets the debugging state of X.I obj Xto X.I state Xand prints a message on stderr saying what state debugging was set to. XAny non-zero value for X.I state Xturns debugging ``on''. When debugging is on, all Dyn functions will Xproduce (hopefully useful) output describing what is going on on Xstderr. X.PP X.IR Returns : X.B DynDebug Xreturns DYN_OK. X.SH AUTHOR XBarr3y Jaspan, Student Information Processing Board (SIPB) and XMIT-Project Athena, bjaspan@athena.mit.edu END_OF_FILE if test 4993 -ne `wc -c <'xpeg1.0/dynobj/dyn.man'`; then echo shar: \"'xpeg1.0/dynobj/dyn.man'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn.man' fi if test -f 'xpeg1.0/dynobj/dynP.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dynP.h'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dynP.h'\" \(1344 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dynP.h' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the private header file. X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X X/* X * dynP.h -- private header file included by source files for libdyn.a. X */ X X#ifndef _DynP_h X#define _DynP_h X X#include "dyn.h" X X/* X * Rep invariant: X * 1) el_size is the number of bytes per element in the object X * 2) num_el is the number of elements currently in the object. It is X * one higher than the highest index at which an element lives. X * 3) size is the number of elements the object can hold without X * resizing. num_el <= index. X * 4) inc is a multiple of the number of elements the object grows by X * each time it is reallocated. X */ X Xtypedef struct _DynObject { X DynPtr array; X int el_size, num_el, size, inc; X char debug, paranoid; X} DynObjectRecP, *DynObjectP; X X/* Internal functions */ Xint _DynRealloc(); X X#define _DynResize(obj, req) \ X ((obj)->size > (req) ? DYN_OK : \ X (_DynRealloc((obj), (((req) - (obj)->size) / (obj)->inc) + 1))) X X#endif /* _DynP_h */ X/* DON'T ADD STUFF AFTER THIS #endif */ END_OF_FILE if test 1344 -ne `wc -c <'xpeg1.0/dynobj/dynP.h'`; then echo shar: \"'xpeg1.0/dynobj/dynP.h'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dynP.h' fi if test -f 'xpeg1.0/dynobj/dyn_append.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_append.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_append.c'\" \(1100 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_append.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynAppend(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xint DynAppend(obj, els, num) X DynObjectP obj; X DynPtr els; X int num; X{ X if (obj->debug) X fprintf(stderr, "dyn: append: Writing %d bytes from %d to %d + %d\n", X obj->el_size*num, els, obj->array, obj->num_el*obj->el_size); X X if (obj->size < obj->num_el + num) { X int num_incs, ret; X X num_incs = ((obj->num_el + num - obj->size) / obj->inc) + 1; X if ((ret = _DynRealloc(obj, num_incs)) != DYN_OK) X return ret; X } X X bcopy(els, obj->array + obj->num_el*obj->el_size, obj->el_size*num); X X obj->num_el += num; X X if (obj->debug) X fprintf(stderr, "dyn: append: done.\n"); X X return DYN_OK; X} X END_OF_FILE if test 1100 -ne `wc -c <'xpeg1.0/dynobj/dyn_append.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_append.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_append.c' fi if test -f 'xpeg1.0/dynobj/dyn_create.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_create.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_create.c'\" \(1067 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_create.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the functions DynCreate() and X * DynDestroy(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X X#ifndef DEFAULT_INC X#define DEFAULT_INC 100 X#endif X Xstatic int default_increment = DEFAULT_INC; X XDynObjectP DynCreate(el_size, inc) X int el_size, inc; X{ X DynObjectP obj; X X obj = (DynObjectP) malloc(sizeof(DynObjectRecP)); X if (obj == NULL) X return NULL; X X obj->array = (DynPtr) malloc(0); X obj->el_size = el_size; X obj->num_el = obj->size = 0; X obj->debug = obj->paranoid = 0; X obj->inc = (!! inc) ? inc : default_increment; X X return obj; X} X Xint DynDestroy(obj) X DynObjectP obj; X{ X free(obj->array); X free(obj); X return DYN_OK; X} END_OF_FILE if test 1067 -ne `wc -c <'xpeg1.0/dynobj/dyn_create.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_create.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_create.c' fi if test -f 'xpeg1.0/dynobj/dyn_debug.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_debug.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_debug.c'\" \(639 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_debug.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynDebug(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xint DynDebug(obj, state) X DynObjectP obj; X char state; X{ X obj->debug = state; X X fprintf(stderr, "dyn: debug: Debug state set to %d.\n", state); X return DYN_OK; X} END_OF_FILE if test 639 -ne `wc -c <'xpeg1.0/dynobj/dyn_debug.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_debug.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_debug.c' fi if test -f 'xpeg1.0/dynobj/dyn_delete.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_delete.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_delete.c'\" \(1929 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_delete.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynDelete(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xint DynDelete(obj, index) X DynObjectP obj; X int index; X{ X if (index < 0) { X if (obj->debug) X fprintf(stderr, "dyn: delete: bad index %d\n", index); X return DYN_BADINDEX; X } X X if (index >= obj->num_el) { X if (obj->debug) X fprintf(stderr, "dyn: delete: Highest index is %d.\n", X obj->num_el); X return DYN_BADINDEX; X } X X if (index == obj->num_el-1) { X if (obj->paranoid) { X if (obj->debug) X fprintf(stderr, "dyn: delete: last element, zeroing.\n"); X bzero(obj->array + index*obj->el_size, obj->el_size); X } X else { X if (obj->debug) X fprintf(stderr, "dyn: delete: last element, punting.\n"); X } X } X else { X if (obj->debug) X fprintf(stderr, X "dyn: delete: copying %d bytes from %d + %d to + %d.\n", X obj->el_size*(obj->num_el - index), obj->array, X (index+1)*obj->el_size, index*obj->el_size); X X bcopy(obj->array + (index+1)*obj->el_size, X obj->array + index*obj->el_size, X obj->el_size*(obj->num_el - index)); X X if (obj->paranoid) { X if (obj->debug) X fprintf(stderr, X "dyn: delete: zeroing %d bytes from %d + %d\n", X obj->el_size, obj->array, X obj->el_size*(obj->num_el - 1)); X bzero(obj->array + obj->el_size*(obj->num_el - 1), X obj->el_size); X } X } X X --obj->num_el; X X if (obj->debug) X fprintf(stderr, "dyn: delete: done.\n"); X X return DYN_OK; X} END_OF_FILE if test 1929 -ne `wc -c <'xpeg1.0/dynobj/dyn_delete.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_delete.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_delete.c' fi if test -f 'xpeg1.0/dynobj/dyn_header.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_header.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_header.c'\" \(414 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_header.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function xxx. X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ END_OF_FILE if test 414 -ne `wc -c <'xpeg1.0/dynobj/dyn_header.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_header.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_header.c' fi if test -f 'xpeg1.0/dynobj/dyn_insert.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_insert.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_insert.c'\" \(1633 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_insert.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynInsert(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X#include "dynP.h" X Xint DynInsert(obj, index, els, num) X DynObjectP obj; X DynPtr els; X int index, num; X{ X int ret; X X if (index < 0 || index > obj->num_el) { X if (obj->debug) X fprintf(stderr, "dyn: insert: index %d is not in [0,%d]\n", X index, obj->num_el); X return DYN_BADINDEX; X } X X if (num < 1) { X if (obj->debug) X fprintf(stderr, "dyn: insert: cannot insert %d elements\n", X num); X return DYN_BADVALUE; X } X X if (obj->debug) X fprintf(stderr,"dyn: insert: Moving %d bytes from %d + %d to + %d\n", X (obj->num_el-index)*obj->el_size, obj->array, X obj->el_size*index, obj->el_size*(index+num)); X X if ((ret = _DynResize(obj, obj->num_el + num)) != DYN_OK) X return ret; X X bcopy(obj->array + index, obj->array + (index + num), X (obj->num_el-index)*obj->el_size); X X if (obj->debug) X fprintf(stderr, "dyn: insert: Copying %d bytes from %d to %d + %d\n", X obj->el_size*num, els, obj->array, obj->el_size*index); X X bcopy(els, obj->array + obj->el_size*index, obj->el_size*num); X X obj->num_el += num; X X if (obj->debug) X fprintf(stderr, "dyn: insert: done.\n"); X X return DYN_OK; X} END_OF_FILE if test 1633 -ne `wc -c <'xpeg1.0/dynobj/dyn_insert.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_insert.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_insert.c' fi if test -f 'xpeg1.0/dynobj/dyn_paranoid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_paranoid.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_paranoid.c'\" \(664 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_paranoid.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynDebug(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xint DynParanoid(obj, state) X DynObjectP obj; X char state; X{ X obj->paranoid = state; X X if (obj->debug) X fprintf(stderr, "dyn: paranoid: Paranoia set to %d.\n", state); X return DYN_OK; X} END_OF_FILE if test 664 -ne `wc -c <'xpeg1.0/dynobj/dyn_paranoid.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_paranoid.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_paranoid.c' fi if test -f 'xpeg1.0/dynobj/dyn_put.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_put.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_put.c'\" \(1850 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_put.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the functions DynGet() and DynAdd(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xstatic int DynPut(); X XDynPtr DynGet(obj, num) X DynObjectP obj; X int num; X{ X if (num < 0) { X if (obj->debug) X fprintf(stderr, "dyn: get: bad index %d\n", num); X return NULL; X } X X if (num >= obj->num_el) { X if (obj->debug) X fprintf(stderr, "dyn: get: highest element is %d.\n", X obj->num_el); X return NULL; X } X X if (obj->debug) X fprintf(stderr, "dyn: get: Returning address %d + %d.\n", X obj->array, obj->el_size*num); X X return (DynPtr) obj->array + obj->el_size*num; X} X Xint DynAdd(obj, el) X DynObjectP obj; X DynPtr el; X{ X int ret; X X ret = DynPut(obj, el, obj->num_el); X if (ret != DYN_OK) X return ret; X X ++obj->num_el; X return ret; X} X X/* X * This function is not exported because if index is large enough to X * cause two or more increments to be allocated the rep invariant X * is not preserved. X */ Xstatic int DynPut(obj, el, index) X DynObjectP obj; X DynPtr el; X int index; X{ X int ret; X X if (obj->debug) X fprintf(stderr, "dyn: put: Writing %d bytes from %d to %d + %d\n", X obj->el_size, el, obj->array, index*obj->el_size); X X if ((ret = _DynResize(obj, index)) != DYN_OK) X return ret; X X bcopy(el, obj->array + index*obj->el_size, obj->el_size); X X if (obj->debug) X fprintf(stderr, "dyn: put: done.\n"); X X return DYN_OK; X} END_OF_FILE if test 1850 -ne `wc -c <'xpeg1.0/dynobj/dyn_put.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_put.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_put.c' fi if test -f 'xpeg1.0/dynobj/dyn_realloc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_realloc.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_realloc.c'\" \(1300 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_realloc.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the internal function _DynRealloc(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X X/* X * Ideally, this function should not be called from outside the X * library. However, nothing will break if it is. X */ Xint _DynRealloc(obj, num_incs) X DynObjectP obj; X int num_incs; X{ X DynPtr temp; X int new_size_in_bytes; X X new_size_in_bytes = obj->el_size*(obj->size + obj->inc*num_incs); X X if (obj->debug) X fprintf(stderr, X "dyn: alloc: Increasing object by %d bytes (%d incs).\n", X obj->el_size*obj->inc*num_incs, num_incs); X X temp = (DynPtr) realloc(obj->array, new_size_in_bytes); X if (temp == NULL) { X if (obj->debug) X fprintf(stderr, "dyn: alloc: Out of memory.\n"); X return DYN_NOMEM; X } X else { X obj->array = temp; X obj->size += obj->inc*num_incs; X } X X if (obj->debug) X fprintf(stderr, "dyn: alloc: done.\n"); X X return DYN_OK; X} END_OF_FILE if test 1300 -ne `wc -c <'xpeg1.0/dynobj/dyn_realloc.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_realloc.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_realloc.c' fi if test -f 'xpeg1.0/dynobj/dyn_size.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/dyn_size.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/dyn_size.c'\" \(615 characters\) sed "s/^X//" >'xpeg1.0/dynobj/dyn_size.c' <<'END_OF_FILE' X/* X * This file is part of libdyn.a, the C Dynamic Object library. It X * contains the source code for the function DynSize(). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dynP.h" X Xint DynSize(obj) X DynObjectP obj; X{ X if (obj->debug) X fprintf(stderr, "dyn: size: returning size %d.\n", obj->num_el); X X return obj->num_el; X} END_OF_FILE if test 615 -ne `wc -c <'xpeg1.0/dynobj/dyn_size.c'`; then echo shar: \"'xpeg1.0/dynobj/dyn_size.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/dyn_size.c' fi if test -f 'xpeg1.0/dynobj/test.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/dynobj/test.c'\" else echo shar: Extracting \"'xpeg1.0/dynobj/test.c'\" \(3603 characters\) sed "s/^X//" >'xpeg1.0/dynobj/test.c' <<'END_OF_FILE' X/* X * This file is a (rather silly) demonstration of the use of the X * C Dynamic Object library. It is a also reasonably thorough test X * of the library (except that it only tests it with one data size). X * X * There are no restrictions on this code; however, if you make any X * changes, I request that you document them so that I do not get X * credit or blame for your modifications. X * X * Written by Barr3y Jaspan, Student Information Processing Board (SIPB) X * and MIT-Project Athena, 1989. X */ X X#include <stdio.h> X X#include "dyn.h" X Xstatic char random_string[] = "This is a random string."; Xstatic char insert1[] = "This will be put at the beginning."; Xstatic char insert2[] = "(parenthetical remark!) "; Xstatic char insert3[] = " This follows the random string."; X Xmain(argc, argv) X int argc; X char **argv; X{ X DynObject obj; X int i, s; X char d, *data; X X obj = DynCreate(sizeof(char), 8); X if (! obj) { X fprintf(stderr, "test: create failed.\n"); X exit(1); X } X X DynDebug(obj, 1); X DynParanoid(obj, 1); X X if (DynGet(obj, -5) || DynGet(obj, 0) || DynGet(obj, 1000)) { X fprintf(stderr, "test: Get did not fail when it should have.\n"); X exit(1); X } X X if (DynDelete(obj, -1) != DYN_BADINDEX || X DynDelete(obj, 0) != DYN_BADINDEX || X DynDelete(obj, 100) != DYN_BADINDEX) { X fprintf(stderr, "test: Delete did not fail when it should have.\n"); X exit(1); X } X X printf("Size of empty object: %d\n", DynSize(obj)); X X for (i=0; i<14; i++) { X d = (char) i; X if (DynAdd(obj, &d) != DYN_OK) { X fprintf(stderr, "test: Adding %d failed.\n", i); X exit(1); X } X } X X if (DynAppend(obj, random_string, strlen(random_string)+1) != DYN_OK) { X fprintf(stderr, "test: appending array failed.\n"); X exit(1); X } X X if (DynDelete(obj, DynHigh(obj) / 2) != DYN_OK) { X fprintf(stderr, "test: deleting element failed.\n"); X exit(1); X } X X if (DynDelete(obj, DynHigh(obj) * 2) == DYN_OK) { X fprintf(stderr, "test: delete should have failed here.\n"); X exit(1); X } X X d = 200; X if (DynAdd(obj, &d) != DYN_OK) { X fprintf(stderr, "test: Adding %d failed.\n", i); X exit(1); X } X X data = (char *) DynGet(obj, 0); X s = DynSize(obj); X for (i=0; i < s; i++) X printf("Element %d is %d.\n", i, (unsigned char) data[i]); X X data = (char *) DynGet(obj, 13); X printf("Element 13 is %d.\n", (unsigned char) *data); X X data = (char *) DynGet(obj, DynSize(obj)); X if (data) { X fprintf(stderr, "DynGet did not return NULL when it should have.\n"); X exit(1); X } X X printf("This should be the random string: \"%s\"\n", DynGet(obj, 14)); X X if (DynInsert(obj, -1, "foo", 4) != DYN_BADINDEX || X DynInsert(obj, DynSize(obj) + 1, "foo", 4) != DYN_BADINDEX || X DynInsert(obj, 0, "foo", -1) != DYN_BADVALUE) { X fprintf(stderr, "DynInsert did not fail when it should have.\n"); X exit(1); X } X X if (DynInsert(obj, DynSize(obj) - 2, insert3, strlen(insert3) + X 1) != DYN_OK) { X fprintf(stderr, "DynInsert to end failed.\n"); X exit(1); X } X X if (DynInsert(obj, 19, insert2, strlen(insert2)) != DYN_OK) { X fprintf(stderr, "DynInsert to middle failed.\n"); X exit(1); X } X X if (DynInsert(obj, 0, insert1, strlen(insert1)+1) != DYN_OK) { X fprintf(stderr, "DynInsert to start failed.\n"); X exit(1); X } X X printf("A new random string: \"%s\"\n", DynGet(obj, 14 + X strlen(insert1) + 1)); X printf("This was put at the beginning: \"%s\"\n", DynGet(obj, 0)); X X DynDestroy(obj); X X return 0; X} END_OF_FILE if test 3603 -ne `wc -c <'xpeg1.0/dynobj/test.c'`; then echo shar: \"'xpeg1.0/dynobj/test.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/dynobj/test.c' fi if test -f 'xpeg1.0/pegbd.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/pegbd.h'\" else echo shar: Extracting \"'xpeg1.0/pegbd.h'\" \(2499 characters\) sed "s/^X//" >'xpeg1.0/pegbd.h' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X/* X * pegbd.h - provides definition of a person and external definitions of global X * routines for the pegboard. X * X */ X X X#ifndef PEGBOARD_DEFINED X X# define PEGBOARD_DEFINED X X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X X X X/* X * A person on the pegboard is really two label wigdets and a X * text widget that you can edit. The char * fields are updated X * when the pegboard file is read, the widgets are then created using X * that information. When an update is done the text from the location X * widget is used because it may have been edited. X * The okay_to_edit field tells if the person running the xpeg application X * has authorization to edit location information for this person. X * X */ X X Xtypedef struct person X{ X Widget wname; X char *name; X Widget wdate; X char *date; X Widget wlocation; X char *location; X int okay_to_edit; X} Person; X X X/* X * person routines X * X */ X Xextern char *personName(); Xextern char *personDate(); Xextern char *personLocation(); Xextern Widget personNameWidget(); Xextern Widget personDateWidget(); Xextern Widget personLocationWidget(); X Xextern int personEditable(); X Xextern void setPersonName(); Xextern void setPersonDate(); Xextern void setPersonLocation(); Xextern void setPersonNameWidget(); Xextern void setPersonDateWidget(); Xextern void setPersonLocationWidget(); X Xextern int firstPerson(); Xextern int lastPerson(); Xextern int numPeople(); Xextern int nextPerson(); X X Xextern void addPerson(); X X X/* X * pegboard routines. X * X */ X Xextern void setPegfileName(); Xextern char *pegfileName(); X Xextern void setGroupName(); Xextern char *groupName(); X Xextern char *dateString(); X Xextern void buildXpegBoard(); Xextern void saveXpegBoard(); Xextern void updateXpegBoard(); X X X X X#endif PEGBOARD_DEFINED END_OF_FILE if test 2499 -ne `wc -c <'xpeg1.0/pegbd.h'`; then echo shar: \"'xpeg1.0/pegbd.h'\" unpacked with wrong size! fi # end of 'xpeg1.0/pegbd.h' fi if test -f 'xpeg1.0/pegbg.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/pegbg.h'\" else echo shar: Extracting \"'xpeg1.0/pegbg.h'\" \(914 characters\) sed "s/^X//" >'xpeg1.0/pegbg.h' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X/* X * pegbd.h - include files for externals and definitions needed to X * update the pegboard. X * X*/ X X Xextern void setGroup(); Xextern char *groupName(); Xextern void addPerson(); X END_OF_FILE if test 914 -ne `wc -c <'xpeg1.0/pegbg.h'`; then echo shar: \"'xpeg1.0/pegbg.h'\" unpacked with wrong size! fi # end of 'xpeg1.0/pegbg.h' fi if test -f 'xpeg1.0/sample_pegfile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/sample_pegfile'\" else echo shar: Extracting \"'xpeg1.0/sample_pegfile'\" \(497 characters\) sed "s/^X//" >'xpeg1.0/sample_pegfile' <<'END_OF_FILE' XXPEG_FILE XThe Engineers Of Software Systems Design, Inc. XKen Nelson XFri Aug 24 08:48:09 1990 XI wrote Xpeg, ssdken@jarthur.claremont.edu XLee Jensen XThu Aug 23 18:25:19 1990 XNot in yet XDoug Pollard XThu Aug 23 18:25:45 1990 XHere but not "in" yet XBruce Crabtree XThu Aug 23 18:26:19 1990 XPorting to HP, phone (555)-555 XGeorge Marschalk XThu Aug 23 18:28:47 1990 XAt desk, phone 555-2322 XTom Radi XFri Aug 24 08:50:28 1990 XAt Coporate Headquarters XTippy XFri Aug 24 10:03:13 1990 XIn the corporate doghouse. END_OF_FILE if test 497 -ne `wc -c <'xpeg1.0/sample_pegfile'`; then echo shar: \"'xpeg1.0/sample_pegfile'\" unpacked with wrong size! fi # end of 'xpeg1.0/sample_pegfile' fi if test -f 'xpeg1.0/strdup.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/strdup.c'\" else echo shar: Extracting \"'xpeg1.0/strdup.c'\" \(923 characters\) sed "s/^X//" >'xpeg1.0/strdup.c' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X X#include <malloc.h> X X Xchar *strdup(old_str) X{ X char *new_str; X X new_str = (char *) malloc(strlen(old_str)+1*sizeof(char)); X strcpy(new_str,old_str); X return new_str; X} X END_OF_FILE if test 923 -ne `wc -c <'xpeg1.0/strdup.c'`; then echo shar: \"'xpeg1.0/strdup.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/strdup.c' fi if test -f 'xpeg1.0/strtrim.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/strtrim.c'\" else echo shar: Extracting \"'xpeg1.0/strtrim.c'\" \(2555 characters\) sed "s/^X//" >'xpeg1.0/strtrim.c' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X/* X * NAME X * strtrim - trim specified characters from a string. X * X * SYNOPSIS X * char *strtrim(s1,s2) X * char *s1, *s2; X * X * DESCRIPTION X * strtrim returns string s1 after deleting the leading and trailing X * occurrances of any characters in string s2. X * X * AUTHOR X * Bruce Crabtree X * Software Systems Design, Inc. X */ X X#include <stdio.h> X#include <ctype.h> X#include <string.h> X Xchar * Xstrtrim(s1,s2) /* strtrim: removes leading and trailing occurrances of */ X char *s1; /* any character in string s2 from s1. */ X char *s2; X{ X char *r, *tmp, *p, *calloc(); X X if (s1 == NULL) X return(NULL); X X p = calloc(strlen(s1)+1,sizeof(char)); X (void) strcpy(p,s1); X X if (s2 != NULL) { X for ( ; (*s1 != '\0') && (strchr(s2,*s1) != NULL); s1++) X ; /* remove leading characters */ X X /* copy remaining portion of string */ X for (tmp=p ; *s1 != '\0'; s1++, tmp++) X *tmp = *s1; X *tmp = '\0'; X X r = p + strlen(p) - 1; X for (; strchr(s2,*r) != NULL; r--) /* remove trailing characters */ X ; X *(++r) = '\0'; X } X return(p); X} X X X#ifdef TEST X Xchar *text1 = { " * This is a sample." }; Xchar *text2 = { "This is a sample also. " }; Xchar *text3 = { " This is another sample. 11111" }; Xchar *text4 = { "This is the last sample." }; X Xmain() X{ X char *strtrim(); X X printf("[%s] = [%s]\n",text1,strtrim(text1,"* \t\n")); X printf("[%s] = [%s]\n",text2,strtrim(text2," \t\n")); X printf("[%s] = [%s]\n",text3,strtrim(text3," \t\n1")); X printf("[%s] = [%s]\n",text4,strtrim(text4," \t\n")); X printf("[%s] = [%s]\n",text1,strtrim(text1,NULL)); X printf("[%s] = [%s]\n",NULL,strtrim(NULL," \t\n")); X} X#endif X X END_OF_FILE if test 2555 -ne `wc -c <'xpeg1.0/strtrim.c'`; then echo shar: \"'xpeg1.0/strtrim.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/strtrim.c' fi if test -f 'xpeg1.0/xpeg.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/xpeg.c'\" else echo shar: Extracting \"'xpeg1.0/xpeg.c'\" \(2437 characters\) sed "s/^X//" >'xpeg1.0/xpeg.c' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X /* X * xpeg.c - contains main and startup code. X * X */ X X#include "xui.h" X X Xchar *xpeg_version() X{ X return "Xpeg 1.0"; X} X X Xvoid Usage() X{ X printf("usage: xpeg [-toolkit_options] pegfile [username]\n\n"); X printf(" pegfile - a valid Xpeg file, xpeg will quit if it is not.\n\n"); X printf(" username - an optional string that should match your name\n"); X printf(" on the Xpeg board. If it does not match you will\n"); X printf(" not be able to edit your location\n\n"); X printf(" These enviroment variables can be used instead of the command line options:\n\n"); X printf(" XPEG_FILE\n"); X printf(" XPEG_USER\n\n"); X printf(" The command line interface will override the environment variables.\n"); X exit(1); X} X X X Xmain(argc, argv) X int argc; X char **argv; X X { X X /* X * Let X do the parsing of it's stuff, and then we do ours! X * X */ X X initXpegInterface(&argc,argv); X X X if (argc < 2) X { X /* X * No arguments, so check enviroment variables, if they are not set holler! X * X */ X X setPegfileName(getenv("XPEG_FILE")); X setUserName(getenv("XPEG_USER")); X if (pegfileName() == NULL) X { X Usage(); X } X } X else X { X if (argc > 2) X { X setPegfileName(strdup(argv[argc-2])); X setUserName(strdup(argv[argc-1])); X } X else X { X setPegfileName(strdup(argv[argc-1])); X } X } X X /* X * Build up the storage for the pegboard X * X */ X X buildXpegBoard(pegfileName()); X X X /* X * Build up the X interface. X * X */ X X buildXpegInterface(); X X runXpegInterface(); X X } X END_OF_FILE if test 2437 -ne `wc -c <'xpeg1.0/xpeg.c'`; then echo shar: \"'xpeg1.0/xpeg.c'\" unpacked with wrong size! fi # end of 'xpeg1.0/xpeg.c' fi if test -f 'xpeg1.0/xpeg.icon' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/xpeg.icon'\" else echo shar: Extracting \"'xpeg1.0/xpeg.icon'\" \(2264 characters\) sed "s/^X//" >'xpeg1.0/xpeg.icon' <<'END_OF_FILE' X#define xpeg_width 50 X#define xpeg_height 50 Xstatic char xpeg_bits[] = { X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0xf0, 0x01, 0xf3, 0xf9, 0xe1, 0x00, 0x00, 0xe0, 0x81, 0x11, X 0x09, 0x10, 0x01, 0x00, 0xc0, 0xc3, 0x10, 0x0a, 0x08, 0x00, 0x00, 0x80, X 0x67, 0x10, 0x0a, 0x08, 0x00, 0x00, 0x00, 0x2f, 0x10, 0x0a, 0x08, 0x00, X 0x00, 0x00, 0x1e, 0x10, 0x09, 0x08, 0x00, 0x00, 0x00, 0x1e, 0xf0, 0x79, X 0x88, 0x03, 0x00, 0x00, 0x3f, 0x10, 0x08, 0x08, 0x04, 0x00, 0x00, 0x39, X 0x10, 0x08, 0x08, 0x04, 0x00, 0x80, 0x71, 0x10, 0x08, 0x08, 0x04, 0x00, X 0xc0, 0xf0, 0x10, 0x08, 0x18, 0x02, 0x00, 0x60, 0xf0, 0x11, 0xf8, 0xf1, X 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, X 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, X 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, X 0x00, 0x80, 0x00, 0x44, 0x01, 0x00, 0x01, 0x40, 0x80, 0x00, 0xc4, 0x00, X 0x00, 0x01, 0x40, 0x80, 0x00, 0x44, 0xdd, 0x31, 0xa9, 0xdb, 0x81, 0x00, X 0x44, 0x4d, 0x01, 0xa9, 0x4a, 0x81, 0x00, 0x44, 0x5d, 0x01, 0xbf, 0x5a, X 0x81, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, X 0x00, 0x00, 0x80, 0x00, 0xc4, 0x54, 0x00, 0x00, 0x00, 0x80, 0x00, 0x44, X 0x51, 0x00, 0x00, 0xa0, 0x8a, 0x00, 0xc4, 0x55, 0x30, 0xf7, 0xa1, 0x8e, X 0x00, 0x44, 0x55, 0x00, 0x55, 0xa1, 0x88, 0x00, 0xc4, 0x54, 0x00, 0x51, X 0xa1, 0x88, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, X 0x00, 0x00, 0x00, 0x80, 0x00, 0xc4, 0x05, 0x00, 0x17, 0x02, 0x80, 0x00, X 0x84, 0x00, 0x00, 0x01, 0x02, 0x80, 0x00, 0x84, 0xf4, 0x31, 0xd3, 0x0e, X 0x80, 0x00, 0x84, 0x54, 0x01, 0x54, 0x06, 0x80, 0x00, 0x84, 0x54, 0x01, X 0xd7, 0x0a, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, X 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, X 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, X 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, X 0x00, 0x00, 0x00, 0x80, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00}; END_OF_FILE if test 2264 -ne `wc -c <'xpeg1.0/xpeg.icon'`; then echo shar: \"'xpeg1.0/xpeg.icon'\" unpacked with wrong size! fi # end of 'xpeg1.0/xpeg.icon' fi if test -f 'xpeg1.0/xui.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xpeg1.0/xui.h'\" else echo shar: Extracting \"'xpeg1.0/xui.h'\" \(982 characters\) sed "s/^X//" >'xpeg1.0/xui.h' <<'END_OF_FILE' X/*************************************************************************\ X* Xpeg 1.0 * X* * X* Copyright 1990, Kenneth C. Nelson * X* * X* Rights : I, Ken Nelson own Xpeg. I am donating the source * X* to the public domain with the restriction that nobody * X* sells it, or anything derived from it, for anything more * X* than media costs. Xpeg uses a dynamic object library * X* that I don't own. See the subdirectory dynobj for * X* restrictions on its use. * X* * X* Please feel free to modify Xpeg. See Todo for details. * X* * X\*************************************************************************/ X X X X X /* X * xui.h - provides externals to the users of the X User interface. X * X */ X X X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X X Xextern void buildXpegInterface(); Xextern void runXpegInterface(); Xextern void initXpegInterface(); END_OF_FILE if test 982 -ne `wc -c <'xpeg1.0/xui.h'`; then echo shar: \"'xpeg1.0/xui.h'\" unpacked with wrong size! fi # end of 'xpeg1.0/xui.h' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.