[comp.sources.amiga] v90i211: icontools - tools for managing icons under workbench, Part02/02

Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (07/16/90)

Submitted-by: rich@californium.cchem.berkeley.ed (Rich Mazzarisi)
Posting-number: Volume 90, Issue 211
Archive-name: util/icontools/part02

#!/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 2 (of 2)."
# Contents:  arp/ArpBase.j.aa
# Wrapped by tadguy@xanth on Sun Jul 15 18:36:27 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'arp/ArpBase.j.aa' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'arp/ArpBase.j.aa'\"
else
echo shar: Extracting \"'arp/ArpBase.j.aa'\" \(41051 characters\)
sed "s/^X//" >'arp/ArpBase.j.aa' <<'END_OF_FILE'
X\ ArpBase.j
X\ AMIGA JForth Include file.
X\
X\ converted 11/24/89 by R. Mazzarisi using the H2J program by Phil Burke from
X\	the JForth Goodies #1 package
X\ lines which were unconvertable by the program, which I attempted to
X\	convert are marked "correct below? -RM"
X\
X\ 11/24/89 the only parts tested are the data structures for opening the
X\		library and for the functions ArpAllocFreq and FileRequest
X\
Xinclude? :struct ju:c_struct
Xdecimal
XEXISTS? LIBRARIES_ARPBASE_H NOT .IF
X1   constant LIBRARIES_ARPBASE_H
X.THEN	\ %? Forced .THEN to prevent nesting!!!
X
X( )
X(  ************************************************************************)
X(  *                                                                    *)
X(  * 5/3/89     ARPbase.h       by MKSoft from ARPbase.i by SDB         *)
X(  *                                                                    *)
X(  ************************************************************************)
X(  *                                                                    *)
X(  *    AmigaDOS Resource Project -- Library Include File               *)
X(  *                                 for Lattice C 5.x or Manx C 3.6    *)
X(  *                                                                    *)
X(  ************************************************************************)
X(  *                                                                    *)
X(  *    Copyright [c] 1987/1988/1989 by Scott Ballantyne                *)
X(  *                                                                    *)
X(  *    The arp.library, and related code and files may be freely used  *)
X(  *    by supporters of ARP.  Modules in the arp.library may not be    *)
X(  *    extracted for use in independent code, but you are welcome to   *)
X(  *    provide the arp.library with your work and call on it freely.   *)
X(  *                                                                    *)
X(  *    You are equally welcome to add new functions, improve the ones  *)
X(  *    within, or suggest additions.                                   *)
X(  *                                                                    *)
X(  *    BCPL programs are not welcome to call on the arp.library.       *)
X(  *    The welcome mat is out to all others.                           *)
X(  *                                                                    *)
X(  ************************************************************************)
X(  *                                                                    *)
X(  * N O T E !  You MUST! have IoErr[] defined as LONG to use LastTracker *)
X(  *          If your compiler has other defines for this, you may wish *)
X(  *          to remove the prototype for IoErr[] from this file.       *)
X(  *                                                                    *)
X(  ************************************************************************)
X(  )
X
X( )
X(  ************************************************************************)
X(  *    First we need to include the Amiga Standard Include files...    *)
X(  ************************************************************************)
X(  )
X
XEXISTS? EXEC_TYPES_H NOT .IF
Xinclude ji:EXEC/Types.j
X.THEN
X
XEXISTS? EXEC_LISTS_H NOT .IF
Xinclude ji:EXEC/Lists.j
X.THEN
X
XEXISTS? EXEC_ALERTS_H NOT .IF
Xinclude ji:EXEC/Alerts.j
X.THEN
X
XEXISTS? EXEC_LIBRARIES_H NOT .IF
Xinclude ji:EXEC/Libraries.j
X.THEN
X
XEXISTS? EXEC_SEMAPHORES_H NOT .IF
Xinclude ji:EXEC/Semaphores.j
X.THEN
X
XEXISTS? LIBRARIES_DOS_H NOT .IF
Xinclude ji:Libraries/DOS.j
X.THEN
X
X( )
X(  ************************************************************************)
X(  *    Standard definitions for arp library information                *)
X(  ************************************************************************)
X(  )
X0" arp.library"  0string ArpName  ( Name of library... )
X39   constant ArpVersion (  Current version... )
X
X( )
X(  ************************************************************************)
X(  *    The current ARP library node...                                 *)
X(  ************************************************************************)
X(  )
X
X:STRUCT ArpBase
X	  STRUCT Library	ab_LibNode	 (  Standard library node               )
X		  APTR ab_DosRootNode	 (  Copy of dl_Root                     )
X		  UBYTE ab_Flags		 (  See bitdefs below                   )
X		  UBYTE ab_ESCChar	 (  Character to be used for escaping   )
X		  LONG ab_ArpReserved1	 (  ArpLib's use only!!                 )
X	  APTR ab_EnvBase	 (  Dummy library for MANX compatibility)
X	  APTR ab_DosBase	 (  Cached DosBase                      )
X	  APTR ab_GfxBase	 (  Cached GfxBase                      )
X	  APTR ab_IntuiBase	 (  Cached IntuitionBase                )
X	  STRUCT MinList	ab_ResLists	 (  Resource trackers                   )
X	  APTR ab_ResidentPrgList	 (  Resident Programs.                  )
X	  STRUCT SignalSemaphore	ab_ResPrgProtection (  protection for above              )
X		  LONG ab_SegList	 (  Pointer to loaded libcode [a BPTR]. )
X		;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  *    The following is here *ONLY* for information and for            *)
X(  *    compatibility with MANX.  DO NOT use in new code!               *)
X(  ************************************************************************)
X(  )
XEXISTS? ARP_PRIVATE .IF
X
X:STRUCT EnvBase
X	  STRUCT Library	eb_LibNode	(  Standard library node for linkage    )
X		  APTR eb_EnvSpace	(  Access only when Forbidden!          )
X		  ULONG eb_EnvSize	(  Total allocated mem for EnvSpace     )
X	  APTR eb_ArpBase	(  Added in V32 for Resource Tracking   )
X		;STRUCT
X
X.THEN
X
X( )
X(  ************************************************************************)
X(  *    These are used in release 33.4 but not by the library code.     *)
X(  *    Instead, individual programs check for these flags.             *)
X(  ************************************************************************)
X(  )
X0   constant ARPB_WILD_WORLD	( Mixed BCPL/Normal wildcards. )
X1   constant ARPB_WILD_BCPL	( Pure BCPL wildcards. )
X
X1  ARPB_WILD_WORLD <<  constant ARPF_WILD_WORLD
X1  ARPB_WILD_BCPL <<  constant ARPF_WILD_BCPL
X
X( )
X(  ************************************************************************)
X(  * The alert object is what you use if you really must return an alert        *)
X(  * to the user. You would normally OR this with another alert number  *)
X(  * from the alerts.h file. Generally, should be NON deadend alerts.   *)
X(  *                                                                    *)
X(  * For example, if you can't open ArpLibrary:                         *)
X(  *    Alert[ [AG_OpenLib|AO_ArpLib], 0L];                             *)
X(  ************************************************************************)
X(  )
X$ 00008036   constant AO_ArpLib (  Alert object )
X
X( )
X(  ************************************************************************)
X(  *    Alerts that arp.library may return...                           *)
X(  ************************************************************************)
X(  )
X$ 03600000   constant AN_ArpLib (  Alert number                              )
X$ 03610000   constant AN_ArpNoMem (  No more memory                  )
X$ 03610002   constant AN_ArpInputMem (  No memory for input buffer           )
X$ 83610003   constant AN_ArpNoMakeEnv (  No memory to make EnvLib            )
X
X$ 83630001   constant AN_ArpNoDOS (  Can't open dos.library          )
X$ 83630002   constant AN_ArpNoGfx (  Can't open graphics.library             )
X$ 83630003   constant AN_ArpNoIntuit (  Can't open intuition                 )
X$ 83640000   constant AN_BadPackBlues (  Bad packet returned to SendPacket[] )
X$ 83600003   constant AN_Zombie (  Zombie roaming around system              )
X
X$ 83600002   constant AN_ArpScattered (  Scatter loading not allowed for arp )
X
X
X( )
X(  ************************************************************************)
X(  *    Return codes you can get from calling ARP Assign[]...           *)
X(  ************************************************************************)
X(  )
X0   constant ASSIGN_OK (  Everything is cool and groovey                     )
X1   constant ASSIGN_NODEV (  "Physical" is not valid for assignment          )
X2   constant ASSIGN_FATAL (  Something really icky happened                  )
X3   constant ASSIGN_CANCEL (  Tried to cancel something but it won't cancel  )
X
X( )
X(  ************************************************************************)
X(  *    Size of buffer you need if you are going to call ReadLine[]     *)
X(  ************************************************************************)
X(  )
X256   constant MaxInputBuf
X
X( )
X(  ************************************************************************)
X(  *    The ARP file requester data structure...                        *)
X(  ************************************************************************)
X(  )
X
X:STRUCT FileRequester
X			  APTR fr_Hail		     (  Hailing text                 )
X			  APTR fr_File		     (  Filename array [FCHARS + 1]  )
X			  APTR fr_Dir		     (  Directory array [DSIZE + 1]  )
X			  APTR fr_Window	     (  Window requesting or NULL    )
X			  UBYTE fr_FuncFlags	     (  Set bitdef's below           )
X			  UBYTE fr_Flags2	     (  New flags...                 )
X\ %? correct below? -RM   VOID	  (*fr_Function)();       /* Your function, see bitdef's  */
X			  APTR	fr_Function()        (  Your function, see bitdef's  )
X			  SHORT fr_LeftEdge	     (  To be used later...          )
X			  SHORT fr_TopEdge
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  * The following are the defines for fr_FuncFlags.  These bits tell   *)
X(  * FileRequest[] what your fr_UserFunc is expecting, and what         *)
X(  * FileRequest[] should call it for.                                  *)
X(  *                                                                    *)
X(  * You are called like so:                                            *)
X(  * fr_Function[Mask, Object]                                          *)
X(  * ULONG      Mask;                                                   *)
X(  * CPTR               *Object;                                                *)
X(  *                                                                    *)
X(  * The Mask is a copy of the flag value that caused FileRequest[] to  *)
X(  * call your function. You can use this to determine what action you  *)
X(  * need to perform, and exactly what Object is, so you know what to do        *)
X(  * and what to return.                                                        *)
X(  ************************************************************************)
X(  )
X7   constant FRB_DoWildFunc (  Call me with a FIB and a name, ZERO return accepts.   )
X6   constant FRB_DoMsgFunc (  You get all IDCMP messages not for FileRequest[]               )
X5   constant FRB_DoColor (  Set this bit for that new and different look             )
X4   constant FRB_NewIDCMP (  Force a new IDCMP [only if fr_Window != NULL]           )
X3   constant FRB_NewWindFunc (  You get to modify the newwindow structure.           )
X2   constant FRB_AddGadFunc (  You get to add gadgets.                                       )
X1   constant FRB_GEventFunc (  Function to call if one of your gadgets is selected.  )
X0   constant FRB_ListFunc (  Not implemented yet.                                    )
X
X1  FRB_DoWildFunc <<  constant FRF_DoWildFunc
X1  FRB_DoMsgFunc <<  constant FRF_DoMsgFunc
X1  FRB_DoColor <<  constant FRF_DoColor
X1  FRB_NewIDCMP <<  constant FRF_NewIDCMP
X1  FRB_NewWindFunc <<  constant FRF_NewWindFunc
X1  FRB_AddGadFunc <<  constant FRF_AddGadFunc
X1  FRB_GEventFunc <<  constant FRF_GEventFunc
X1  FRB_ListFunc <<  constant FRF_ListFunc
X
X( )
X(  ************************************************************************)
X(  * The FR2B_ bits are for fr_Flags2 in the file requester structure   *)
X(  ************************************************************************)
X(  )
X0   constant FR2B_LongPath (  Specify the fr_Dir buffer is 256 bytes long )
X
X1  FR2B_LongPath <<  constant FR2F_LongPath
X
X( )
X(  ************************************************************************)
X(  *    The sizes of the different buffers...                           *)
X(  ************************************************************************)
X(  )
X32   constant FCHARS (  Filename size                                )
X33   constant DSIZE (  Directory name size if not FR2B_LongPath      )
X
X254   constant LONG_DSIZE (  If FR2B_LongPath is set, use LONG_DSIZE )
X126   constant LONG_FSIZE (  For compatibility with ARPbase.i                )
X
X$ 7680	 constant FR_FIRST_GADGET (  User gadgetID's must be less than this value    )
X
X( )
X(  ************************************************************************)
X(  * Structure expected by FindFirst[]/FindNext[]                               *)
X(  *                                                                    *)
X(  * You need to allocate this structure and initialize it as follows:  *)
X(  *                                                                    *)
X(  * Set ap_BreakBits to the signal bits [CDEF] that you want to take a *)
X(  * break on, or NULL, if you don't want to convenience the user.      *)
X(  *                                                                    *)
X(  * if you want to have the FULL PATH NAME of the files you found,     *)
X(  * allocate a buffer at the END of this structure, and put the size of        *)
X(  * it into ap_StrLen.  If you don't want the full path name, make sure        *)
X(  * you set ap_StrLen to zero.  In this case, the name of the file, and        *)
X(  * stats are available in the ap_Info, as per usual.                  *)
X(  *                                                                    *)
X(  * Then call FindFirst[] and then afterwards, FindNext[] with this    *)
X(  * structure.  You should check the return value each time [see below]        *)
X(  * and take the appropriate action, ultimately calling                        *)
X(  * FreeAnchorChain[] when there are no more files and you are done.   *)
X(  * You can tell when you are done by checking for the normal AmigaDOS *)
X(  * return code ERROR_NO_MORE_ENTRIES.                                 *)
X(  *                                                                    *)
X(  * You will also have to check the DirEntryType variable in the ap_Info       *)
X(  * structure to determine what exactly you have received.             *)
X(  ************************************************************************)
X(  )
X
X:STRUCT AnchorPath
X		  APTR ap_Base	     (  Pointer to first anchor                      )
X		  APTR ap_Last	     (  Pointer to last anchor                       )
X			  LONG ap_BreakBits  (  Bits to break on                             )
X			  LONG ap_FoundBreak (  Bits we broke on. Also returns ERROR_BREAK   )
X			  BYTE ap_Flags      (  New use for the extra word...                )
X			  BYTE ap_Reserved   (  To fill it out...                            )
X			  SHORT ap_StrLen    (  This is what used to be ap_Length            )
X		  STRUCT FileInfoBlock	ap_Info
X			( %?)   1 BYTES ap_Buf       (  Allocate a buffer here, if desired           )
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  *    Bit definitions for the new ap_Flags...                         *)
X(  ************************************************************************)
X(  )
X0   constant APB_DoWild (  User option ALL                           )
X1   constant APB_ItsWild (  Set by FindFirst, used by FindNext               )
X2   constant APB_DoDir (  Bit is SET if a DIR node should be entered )
X				(  Application can RESET this bit to AVOID      )
X				(  entering a dir.                              )
X3   constant APB_DidDir (  Bit is set for an "expired" dir node              )
X4   constant APB_NoMemErr (  Set if there was not enough memory              )
X5   constant APB_DoDot (  If set, '.' [DOT] will convert to CurrentDir       )
X
X1  APB_DoWild <<  constant APF_DoWild
X1  APB_ItsWild <<  constant APF_ItsWild
X1  APB_DoDir <<  constant APF_DoDir
X1  APB_DidDir <<  constant APF_DidDir
X1  APB_NoMemErr <<  constant APF_NoMemErr
X1  APB_DoDot <<  constant APF_DoDot
X
X( )
X(  ************************************************************************)
X(  * Structure used by the pattern matching functions, no need to obtain,       *)
X(  * diddle or allocate this yourself.                                  *)
X(  *                                                                    *)
X(  * Note:  If you did, you will now break as it has changed...         *)
X(  ************************************************************************)
X(  )
XEXISTS? ARP_PRIVATE .IF
X
X:STRUCT AChain
X	  APTR an_Child
X	  APTR an_Parent
X	  APTR an_Lock
X	  APTR an_Info
X		  BYTE an_Flags
X		( %?)   1 BYTES an_String       (  Just as is .i file   )
X		;STRUCT
X				(  ???  Don't use this! )
X.THEN
X
X0   constant DDB_PatternBit
X1   constant DDB_ExaminedBit
X2   constant DDB_Completed
X3   constant DDB_AllBit
X
X1  DDB_PatternBit <<  constant DDF_PatternBit
X1  DDB_ExaminedBit <<  constant DDF_ExaminedBit
X1  DDB_Completed <<  constant DDF_Completed
X1  DDB_AllBit <<  constant DDF_AllBit
X
X( )
X(  ************************************************************************)
X(  * This structure takes a pointer, and returns FALSE if wildcard was  *)
X(  * not found by FindFirst[]                                           *)
X(  ************************************************************************)
X(  )
X\ %? #define	IsWild( ptr )           ( *((LONG *)(ptr)) ): IsWild ;
X
X( )
X(  ************************************************************************)
X(  * Constants used by wildcard routines                                        *)
X(  *                                                                    *)
X(  * These are the pre-parsed tokens referred to by pattern match.  It  *)
X(  * is not necessary for you to do anything about these, FindFirst[]   *)
X(  * FindNext[] handle all these for you.                                       *)
X(  ************************************************************************)
X(  )
X$ 80   constant P_ANY (  Token for '*' | '#?'        )
X$ 81   constant P_SINGLE (  Token for '?'    )
X
X( )
X(  ************************************************************************)
X(  * No need to muck with these as they may change...                   *)
X(  ************************************************************************)
X(  )
XEXISTS? ARP_PRIVATE .IF
X$ 82   constant P_ORSTART (  Token for '['   )
X$ 83   constant P_ORNEXT (  Token for '|'    )
X$ 84   constant P_OREND (  Token for ']'     )
X$ 85   constant P_NOT (  Token for '~'       )
X$ 87   constant P_NOTCLASS (  Token for '^'  )
X$ 88   constant P_CLASS (  Token for '[]'    )
X$ 89   constant P_REPBEG (  Token for '['    )
X$ 8A   constant P_REPEND (  Token for ']'    )
X.THEN
X
X( )
X(  ************************************************************************)
X(  * Structure used by AddDANode[], AddDADevs[], FreeDAList[].          *)
X(  *                                                                    *)
X(  * This structure is used to create lists of names, which normally    *)
X(  * are devices, assigns, volumes, files, or directories.              *)
X(  ************************************************************************)
X(  )
X
X:STRUCT DirectoryEntry
X		  APTR de_Next	(  Next in list                         )
X			  BYTE de_Type	(  DLX_mumble                           )
X			  BYTE de_Flags (  For future expansion, DO NOT USE!    )
X			( %?)   1 BYTES de_Name (  The name of the thing found          )
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  * Defines you use to get a list of the devices you want to look at.  *)
X(  * For example, to get a list of all directories and volumes, do:     *)
X(  *                                                                    *)
X(  *    AddDADevs[ mydalist, [DLF_DIRS | DLF_VOLUMES] ]                 *)
X(  *                                                                    *)
X(  * After this, you can examine the de_type field of the elements added        *)
X(  * to your list [if any] to discover specifics about the objects added.       *)
X(  *                                                                    *)
X(  * Note that if you want only devices which are also disks, you must  *)
X(  * [DLF_DEVICES | DLF_DISKONLY].                                      *)
X(  ************************************************************************)
X(  )
X0   constant DLB_DEVICES (  Return devices                           )
X1   constant DLB_DISKONLY (  Modifier for above: Return disk devices only    )
X2   constant DLB_VOLUMES (  Return volumes only                              )
X3   constant DLB_DIRS (  Return assigned devices only                        )
X
X1  DLB_DEVICES <<  constant DLF_DEVICES
X1  DLB_DISKONLY <<  constant DLF_DISKONLY
X1  DLB_VOLUMES <<  constant DLF_VOLUMES
X1  DLB_DIRS <<	constant DLF_DIRS
X
X( )
X(  ************************************************************************)
X(  * Legal de_Type values, check for these after a call to AddDADevs[], *)
X(  * or use on your own as the ID values in AddDANode[].                        *)
X(  ************************************************************************)
X(  )
X0   constant DLX_FILE (  AddDADevs[] can't determine this    )
X8   constant DLX_DIR (  AddDADevs[] can't determine this     )
X16   constant DLX_DEVICE (  It's a resident device           )
X
X24   constant DLX_VOLUME (  Device is a volume                       )
X32   constant DLX_UNMOUNTED (  Device is not resident                )
X
X40   constant DLX_ASSIGN (  Device is a logical assignment   )
X
X( )
X(  ************************************************************************)
X(  *    This macro is to check for an error return from the Atol[]      *)
X(  *    routine.  If Errno is ERRBADINT, then there was an error...     *)
X(  *    This was done to try to remain as close to source compatible    *)
X(  *    as possible with the older [rel 1.1] ARPbase.h                  *)
X(  ************************************************************************)
X(  )
X1   constant ERRBADINT
X\ %? #define Errno	     (IoErr() ? ERRBADINT : 0)
X
X( )
X(  ************************************************************************)
X(  *    Resource Tracking stuff...                                      *)
X(  ************************************************************************)
X(  *                                                                    *)
X(  * There are a few things in arp.library that are only directly               *)
X(  * acessable from assembler.  The glue routines provided by us for    *)
X(  * all 'C' compilers use the following conventions to make these      *)
X(  * available to C programs.  The glue for other language's should use *)
X(  * as similar a mechanism as possible, so that no matter what language        *)
X(  * or compiler we speak, when talk about arp, we will know what the   *)
X(  * other guy is saying.                                                       *)
X(  *                                                                    *)
X(  * Here are the cases:                                                        *)
X(  *                                                                    *)
X(  * Tracker calls...                                                   *)
X(  *            These calls return the Tracker pointer as a secondary   *)
X(  *            result in the register A1.  For C, there is no clean    *)
X(  *            way to return more than one result so the tracker       *)
X(  *            pointer is returned in IoErr[].  For ease of use,       *)
X(  *            there is a define that typecasts IoErr[] to the correct *)
X(  *            pointer type.  This is called LastTracker and should    *)
X(  *            be source compatible with the earlier method of storing *)
X(  *            the secondary result.                                   *)
X(  *                                                                    *)
X(  * GetTracker[] -                                                     *)
X(  *            Syntax is a bit different for C than the assembly call  *)
X(  *            The C syntax is GetTracker[ID].  The binding routines   *)
X(  *            will store the ID into the tracker on return.  Also,    *)
X(  *            in an effort to remain consistant, the tracker will     *)
X(  *            also be stored in LastTracker.                          *)
X(  *                                                                    *)
X(  * In cases where you have allocated a tracker before you have obtained       *)
X(  * a resource [usually the most efficient method], and the resource has       *)
X(  * not been obtained, you will need to clear the tracker id.  The macro       *)
X(  * CLEAR_ID[] has been provided for that purpose.  It expects a pointer       *)
X(  * to a DefaultTracker sort of struct.                                        *)
X(  ************************************************************************)
X(  )
X\ %? #define	CLEAR_ID(t)     ((SHORT *) t)[-1]=NULL: CLEAR_ID ;
X
X( )
X(  ************************************************************************)
X(  * You MUST prototype IoErr[] to prevent the possible error in defining       *)
X(  * IoErr[] and thus causing LastTracker to give you trash...          *)
X(  *                                                                    *)
X(  * N O T E !  You MUST! have IoErr[] defined as LONG to use LastTracker *)
X(  *          If your compiler has other defines for this, you may wish *)
X(  *          to remove the prototype for IoErr[].                      *)
X(  ************************************************************************)
X(  )
X\ %? #define LastTracker     ((struct DefaultTracker *)IoErr())
X
X( )
X(  ************************************************************************)
X(  * The rl_FirstItem list [ResList] is a list of TrackedResource [below]       *)
X(  * It is very important that nothing in this list depend on the task  *)
X(  * existing at resource freeing time [i.e., RemTask[0L] type stuff,   *)
X(  * DeletePort[] and the rest].                                                *)
X(  *                                                                    *)
X(  * The tracking functions return a struct Tracker *Tracker to you, this       *)
X(  * is a pointer to whatever follows the tr_ID variable.                       *)
X(  * The default case is reflected below, and you get it if you call    *)
X(  * GetTracker[] [ see DefaultTracker below].                          *)
X(  *                                                                    *)
X(  * NOTE: The two user variables mentioned in an earlier version don't *)
X(  * exist, and never did. Sorry about that [SDB].                      *)
X(  *                                                                    *)
X(  * However, you can still use ArpAlloc[] to allocate your own tracking        *)
X(  * nodes and they can be any size or shape you like, as long as the   *)
X(  * base structure is preserved. They will be freed automagically just *)
X(  * like the default trackers.                                         *)
X(  ************************************************************************)
X(  )
X
X:STRUCT TrackedResource
X		  STRUCT MinNode	tr_Node (  Double linked pointer                )
X			  BYTE tr_Flags (  Don't touch                          )
X			  BYTE tr_Lock	(  Don't touch, for Get/FreeAccess[]    )
X			  SHORT tr_ID		(  Item's ID                            )
X
X( )
X(  ************************************************************************)
X(  * The struct DefaultTracker *Tracker portion of the structure.               *)
X(  * The stuff below this point can conceivably vary, depending         *)
X(  * on user needs, etc.  This reflects the default.                    *)
X(  ************************************************************************)
X(  )
X			union{
X\ %? correct below? -RM 	CPTR	tr_Resource;	/* Whatever				*/
X				APTR	tr_Resource	(  Whatever                             )
X			}union{
X				  LONG tg_Verify	(  For use during TRAK_GENERIC          )
X				}union	\ tr_Object;	  /* The thing being tracked		  */
X			union{
X\ %? correct below? -RM 	VOID	(*tg_Function)();/* Function to call for TRAK_GENERIC   */
X				APTR	tg_Function()  ( Function to call for TRAK_GENERIC   )
X			}union{
X			  APTR tr_Window2	(  For TRAK_WINDOW                      )
X				}union	\ tr_Extra;	  /* Only needed sometimes		 */
X			;STRUCT
X
X
X\ %? #define tg_Value tg_Verify      /* Ancient compatibility only!  Do NOT use in new CODE!!! */
X
X( )
X(  ************************************************************************)
X(  * You get a pointer to a struct of the following type when you call  *)
X(  * GetTracker[].  You can change this, and use ArpAlloc[] instead of  *)
X(  * GetTracker[] to do tracking. Of course, you have to take a wee bit *)
X(  * more responsibility if you do, as well as if you use TRAK_GENERIC  *)
X(  * stuff.                                                             *)
X(  *                                                                    *)
X(  * TRAK_GENERIC folks need to set up a task function to be called when        *)
X(  * an item is freed.  Some care is required to set this up properly.  *)
X(  *                                                                    *)
X(  * Some special cases are indicated by the unions below, for          *)
X(  * TRAK_WINDOW, if you have more than one window opened, and don't    *)
X(  * want the IDCMP closed particularly, you need to set a ptr to the   *)
X(  * other window in dt_Window2.  See CloseWindowSafely[] for more info.        *)
X(  * If only one window, set this to NULL.                              *)
X(  ************************************************************************)
X(  )
X
X:STRUCT DefaultTracker
X			union{
X\ %? correct below? -RM 	CPTR	dt_Resource;	/* Whatever				*/
X				APTR	dt_Resource	(  Whatever                             )
X			}union{
X				  LONG tg_Verify	(  For use during TRAK_GENERIC          )
X				}union	\ dt_Object;	  /* The object being tracked		  */
X			union{
X\ %? correct below? -RM 	VOID	(*tg_Function)();/* Function to call for TRAK_GENERIC   */
X				APTR	tg_Function()  ( Function to call for TRAK_GENERIC    )
X			}union{
X			  APTR dt_Window2	(  For TRAK_WINDOW                      )
X				}union	\ dt_Extra;
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  *    Items the tracker knows what to do about                        *)
X(  ************************************************************************)
X(  )
X0   constant TRAK_AAMEM (  Default [ArpAlloc] element                )
X1   constant TRAK_LOCK (  File lock                          )
X2   constant TRAK_FILE (  Opened file                                )
X3   constant TRAK_WINDOW (  Window -- see docs                       )
X4   constant TRAK_SCREEN (  Screen                           )
X5   constant TRAK_LIBRARY (  Opened library                  )
X6   constant TRAK_DAMEM (  Pointer to DosAllocMem block              )
X7   constant TRAK_MEMNODE (  AllocEntry[] node                       )
X8   constant TRAK_SEGLIST (  Program segment                 )
X9   constant TRAK_RESLIST (  ARP [nested] ResList                    )
X10   constant TRAK_MEM (  Memory ptr/length                  )
X11   constant TRAK_GENERIC (  Generic Element, your choice           )
X12   constant TRAK_DALIST (  DAlist [ aka file request ]             )
X13   constant TRAK_ANCHOR (  Anchor chain [pattern matching] )
X14   constant TRAK_FREQ (  FileRequest struct                        )
X15   constant TRAK_FONT (  GfxBase CloseFont[]                       )
X15   constant TRAK_MAX (  Poof, anything higher is tossed    )
X
X7   constant TRB_UNLINK (  Free node bit                     )
X6   constant TRB_RELOC (  This may be relocated [not used yet]       )
X5   constant TRB_MOVED (  Item moved                         )
X
X1  TRB_UNLINK <<  constant TRF_UNLINK
X1  TRB_RELOC <<  constant TRF_RELOC
X1  TRB_MOVED <<  constant TRF_MOVED
X
X( )
X(  ************************************************************************)
X(  * Note: ResList MUST be a DosAllocMem'ed list!, this is done for     *)
X(  * you when you call CreateTaskResList[], typically, you won't need   *)
X(  * to access/allocate this structure.                                 *)
X(  ************************************************************************)
X(  )
X
X:STRUCT ResList
X	  STRUCT MinNode	rl_Node (  Used by arplib to link reslists      )
X	  APTR rl_TaskID	(  Owner of this list                   )
X	  STRUCT MinList	rl_FirstItem	(  List of Tracked Resources            )
X	  APTR rl_Link	(  SyncRun's use - hide list here       )
X		;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  *    Returns from CompareLock[]                                      *)
X(  ************************************************************************)
X(  )
X0   constant LCK_EQUAL (  The two locks refer to the same object     )
X1   constant LCK_VOLUME (  Locks are on the same volume                      )
X2   constant LCK_DIFVOL1 (  Locks are on different volumes           )
X3   constant LCK_DIFVOL2 (  Locks are on different volumes           )
X
X( )
X(  ************************************************************************)
X(  *    ASyncRun[] stuff...                                             *)
X(  ************************************************************************)
X(  * Message sent back on your request by an exiting process.           *)
X(  * You request this by putting the address of your message in         *)
X(  * pcb_LastGasp, and initializing the ReplyPort variable of your      *)
X(  * ZombieMsg to the port you wish the message posted to.              *)
X(  ************************************************************************)
X(  )
X
X:STRUCT ZombieMsg
X		  STRUCT Message	zm_ExecMessage
X			  ULONG zm_TaskNum	(  Task ID                      )
X			  LONG zm_ReturnCode	(  Process's return code        )
X			  ULONG zm_Result2	(  System return code           )
X		  STRUCT DateStamp	zm_ExitTime	(  Date stamp at time of exit   )
X			  ULONG zm_UserInfo	(  For whatever you wish        )
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  * Structure required by ASyncRun[] -- see docs for more info.                *)
X(  ************************************************************************)
X(  )
X
X:STRUCT ProcessControlBlock
X				  ULONG pcb_StackSize	(  Stacksize for new process                    )
X				  BYTE pcb_Pri	(  Priority of new task                         )
X				  UBYTE pcb_Control	(  Control bits, see defines below              )
X				  APTR pcb_TrapCode	(  Optional Trap Code                           )
X				  LONG pcb_Input
X				  LONG pcb_Output	(  Optional stdin, stdout                       )
X				union{
X					  LONG pcb_SplatFile	(  File to use for Open["*"]                    )
X				}union{
X					  APTR pcb_ConName	(  CON: filename                                )
X					}union	\ pcb_Console;
X\ %?				CPTR		pcb_LoadedCode; /* If not null, will not load/unload code	*/
X				APTR		pcb_LoadedCode	(  If not null, will not load/unload code       )
X			  APTR pcb_LastGasp	(  ReplyMsg[] to be filled in by exit           )
X			  APTR pcb_WBProcess	(  Valid only when PRB_NOCLI                    )
X				;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  * Formerly needed to pass NULLCMD to a child.  No longer needed.     *)
X(  * It is being kept here for compatibility only...                    *)
X(  ************************************************************************)
X(  )
X\ %? #define	NOCMD	"\n"
X
X( )
X(  ************************************************************************)
X(  * The following control bits determine what ASyncRun[] does on               *)
X(  * Abnormal Exits and on background process termination.              *)
X(  ************************************************************************)
X(  )
X0   constant PRB_SAVEIO (  Don't free/check file handles on exit     )
X1   constant PRB_CLOSESPLAT (  Close Splat file, must request explicitly     )
X2   constant PRB_NOCLI (  Don't create a CLI process                 )
X(       PRB_INTERACTIVE 3L         This is now obsolete...                      )
X4   constant PRB_CODE (  Dangerous yet enticing                      )
X5   constant PRB_STDIO (  Do the stdio thing, splat = CON:Filename   )
X
X1  PRB_SAVEIO <<  constant PRF_SAVEIO
X1  PRB_CLOSESPLAT <<  constant PRF_CLOSESPLAT
X1  PRB_NOCLI <<  constant PRF_NOCLI
X1  PRB_CODE <<	constant PRF_CODE
X1  PRB_STDIO <<  constant PRF_STDIO
X
X( )
X(  ************************************************************************)
X(  *    Error returns from SyncRun[] and ASyncRun[]                     *)
X(  ************************************************************************)
X(  )
X-1   constant PR_NOFILE (  Could not LoadSeg[] the file                      )
X-2   constant PR_NOMEM (  No memory for something                    )
X(       PR_NOCLI        -3L        This is now obsolete                         )
X-4   constant PR_NOSLOT (  No room in TaskArray                              )
X-5   constant PR_NOINPUT (  Could not open input file                        )
X-6   constant PR_NOOUTPUT (  Could not get output file                       )
X(       PR_NOLOCK       -7L        This is now obsolete                         )
X(       PR_ARGERR       -8L        This is now obsolete                         )
X(       PR_NOBCPL       -9L        This is now obsolete                         )
X(       PR_BADLIB       -10L       This is now obsolete                         )
X-11   constant PR_NOSTDIO (  Couldn't get stdio handles                      )
X
X( )
X(  ************************************************************************)
X(  *    Added V35 of arp.library                                        *)
X(  ************************************************************************)
X(  )
X-12   constant PR_WANTSMESSAGE (  Child wants you to report IoErr[] to user  )
X				(  for SyncRun[] only...                        )
X-13   constant PR_NOSHELLPROC (  Can't create a shell/cli process            )
X-14   constant PR_NOEXEC (  'E' bit is clear                         )
X-15   constant PR_SCRIPT (  S and E are set, IoErr[] contains directory      )
X
X( )
X(  ************************************************************************)
X(  * Version 35 ASyncRun[] allows you to create an independent          *)
X(  * interactive or background Shell/CLI. You need this variant of the  *)
X(  * pcb structure to do it, and you also have new values for nsh_Control,*)
X(  * see below.                                                         *)
X(  *                                                                    *)
X(  * Syntax for Interactive shell is:                                   *)
X(  *                                                                    *)
X(  * rc=ASyncRun["Optional Window Name","Optional From File",&NewShell];        *)
X(  *                                                                    *)
X(  * Syntax for a background shell is:                                  *)
X(  *                                                                    *)
X(  * rc=ASyncRun["Command line",0L,&NewShell];                          *)
X(  *                                                                    *)
X(  * Same syntax for an Execute style call, but you have to be on drugs *)
X(  * if you want to do that.                                            *)
X(  ************************************************************************)
X(  )
X
X:STRUCT NewShell
X			  ULONG nsh_StackSize	(  stacksize shell will use for children        )
X			  BYTE nsh_Pri	(  ignored by interactive shells                )
X			  UBYTE nsh_Control	(  bits/values: see above                       )
X\ %? correct below? -RM CPTR	nsh_LogMsg;	/* Optional login message, if null, use default */
X			  APTR nsh_LogMsg	(  Optional login message, if null, use default )
X			  LONG nsh_Input	(  ignored by interactive shells, but           )
X			  LONG nsh_Output	(  used by background and execute options.      )
X			( %?)   5 4 *  BYTES nsh_RESERVED
X			;STRUCT
X
X
X( )
X(  ************************************************************************)
X(  * Bit Values for nsh_Control, you should use them as shown below, or *)
X(  * just use the actual values indicated.                              *)
X(  ************************************************************************)
X(  )
X0   constant PRB_CLI (  Do a CLI, not a shell        )
X1   constant PRB_BACKGROUND (  Background shell              )
X2   constant PRB_EXECUTE (  Do as EXECUTE...         )
END_OF_FILE
if test 41051 -ne `wc -c <'arp/ArpBase.j.aa'`; then
    echo shar: \"'arp/ArpBase.j.aa'\" unpacked with wrong size!
fi
# end of 'arp/ArpBase.j.aa'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
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
-- 
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.