home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D3.DMS / in.adf / Interfaces / ARP.mod < prev    next >
Encoding:
Text File  |  1992-11-02  |  56.3 KB  |  1,155 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                                                                         *)
  3. (*  Amiga Oberon Library Module: ARP                  Date: 02-Nov-92      *)
  4. (*                                                                         *)
  5. (*   © 1992 by Fridtjof Siebert                                            *)
  6. (*                                                                         *)
  7. (*-------------------------------------------------------------------------*)
  8. (*
  9.  ************************************************************************
  10.  *                                                                      *
  11.  * 21/2/90      Arp.mod         ported to Oberon by Fridtjof Siebert    *
  12.  *                                                                      *
  13.  * 5/3/89       ARPbase.h       by MKSoft from ARPbase.i by SDB         *
  14.  *                                                                      *
  15.  ************************************************************************
  16.  *                                                                      *
  17.  *      AmigaDOS Resource Project -- Library Module File                *
  18.  *                                   for the AMOK Oberon Compiler       *
  19.  *                                                                      *
  20.  ************************************************************************
  21.  *                                                                      *
  22.  *      Copyright (c) 1987/1988/1989 by Scott Ballantyne                *
  23.  *                                                                      *
  24.  *      The arp.library, and related code and files may be freely used  *
  25.  *      by supporters of ARP.  Modules in the arp.library may not be    *
  26.  *      extracted for use in independent code, but you are welcome to   *
  27.  *      provide the arp.library with your work and call on it freely.   *
  28.  *                                                                      *
  29.  *      You are equally welcome to add new functions, improve the ones  *
  30.  *      within, or suggest additions.                                   *
  31.  *                                                                      *
  32.  *      BCPL programs are not welcome to call on the arp.library.       *
  33.  *      The welcome mat is out to all others.                           *
  34.  *                                                                      *
  35.  ************************************************************************
  36.  *)
  37.  
  38. MODULE ARP;
  39.  
  40. (*
  41.  ************************************************************************
  42.  *      First we need to import the Amiga Interface Modules             *
  43.  ************************************************************************
  44.  *)
  45.  
  46. IMPORT e := Exec,
  47.        d := Dos,
  48.        I := Intuition,
  49.        g := Graphics,
  50.        s := SYSTEM;
  51.  
  52. (*
  53.  ************************************************************************
  54.  *      Standard definitions for arp library information                *
  55.  ************************************************************************
  56.  *)
  57.  
  58. CONST
  59.  arpName     * =   "arp.library";   (* Name of library... *)
  60.  arpVersion  * =   39;              (* Current version... *)
  61.  
  62.  
  63. (*
  64.  ************************************************************************
  65.  *      Forward declaration of some Pointers:                           *
  66.  ************************************************************************
  67.  *)
  68.  
  69. TYPE
  70.   ArpBasePtr * = UNTRACED POINTER TO ArpBase;
  71.   EnvBasePtr * = UNTRACED POINTER TO EnvBase;
  72.   FileRequesterPtr * = UNTRACED POINTER TO FileRequester;
  73.   AChainPtr * = UNTRACED POINTER TO AChain;
  74.   DirectoryEntryPtr * = UNTRACED POINTER TO DirectoryEntry;
  75.   TrackedResourcePtr * = UNTRACED POINTER TO TrackedResource;
  76.   DefaultTrackerPtr * = UNTRACED POINTER TO DefaultTracker;
  77.   ResListPtr * = UNTRACED POINTER TO ResList;
  78.   ZombieMsgPtr * = UNTRACED POINTER TO ZombieMsg;
  79.   ResidentProgramNodePtr * = UNTRACED POINTER TO ResidentProgramNode;
  80.   ProcessControlBlockPtr * = UNTRACED POINTER TO ProcessControlBlock;
  81.   AnchorPathPtr * = UNTRACED POINTER TO AnchorPath;
  82.  
  83. (*
  84.  ************************************************************************
  85.  *      The current ARP library node...                                 *
  86.  ************************************************************************
  87.     stamp* : d.Date;         (* DOS Datestamp                        *)
  88.     format* : s.BYTE;        (* controls appearance ot dat_StrDate   *)
  89.     flags* : SET;            (* See BITDEF's below                   *)
  90.     strDay* : e.ADDRESS;     (* day of the week string               *)
  91.     strData* : e.ADDRESS;    (* date string                          *)
  92.     strTime* : e.ADDRESS;    (* time string                          *)
  93.   END;
  94.  *)
  95.  
  96. TYPE
  97.   ArpBase * = STRUCT
  98.     libNode* :         e.Library;          (* Standard library node    *)
  99.     dosRootNode* :     d.RootNodePtr;      (* Copy of dl_Root          *)
  100.     flags* :           SHORTSET;           (* See bitdefs below        *)
  101.     escChar* :         CHAR;               (* Character for escaping   *)
  102.     arpReserved1* :    LONGINT;            (* ArpLib's use only!!      *)
  103.     envBase* :         e.LibraryPtr;       (* Dummy library for MANX   *)
  104.     dosBase* :         d.DosLibraryPtr;    (* Cached DosBase           *)
  105.     gfxBase* :         g.GfxBasePtr;       (* Cached GfxBase           *)
  106.     intuiBase* :       I.IntuitionBasePtr; (* Cached IntuitionBase     *)
  107.     resLists* :        e.MinList;          (* Resource trackers        *)
  108.     residentPrgList* : ResidentProgramNodePtr; (* Resident Programs.   *)
  109.     resPrgProtection* :e.SignalSemaphore;  (* protection for above     *)
  110.     segList* :         e.BPTR;             (* Ptr to loaded lib (BPTR) *)
  111.   END;
  112.  
  113.  
  114. (*
  115.  ************************************************************************
  116.  *      The following is here *ONLY* for information and for            *
  117.  *      compatibility with MANX.  DO NOT use in new code!               *
  118.  ************************************************************************
  119.  *)
  120.  
  121.   EnvBase * = STRUCT
  122.     libNode* : e.Library;      (* Standard library node for linkage    *)
  123.     envSpace* : e.ADDRESS;     (* Access only when Forbidden!          *)
  124.     envSize* : LONGINT;        (* Total allocated mem for EnvSpace     *)
  125.     arpbase* : ArpBasePtr;     (* Added in V32 for Resource Tracking   *)
  126.   END;
  127.  
  128. (*
  129.  ************************************************************************
  130.  *      These are used in release 33.4 but not by the library code.     *
  131.  *      Instead, individual programs check for these flags.             *
  132.  ************************************************************************
  133.  *)
  134.  
  135. CONST  (* ArpBase.flags: *)
  136.  
  137.   arpWildWorld * = 0; (* Mixed BCPL/Normal wildcards. *)
  138.   arpWildBCPL  * = 1; (* Pure BCPL wildcards.         *)
  139.  
  140. (*
  141.  ************************************************************************
  142.  * The alert object is what you use if you really must return an alert  *
  143.  * to the user. You would normally OR this with another alert number    *
  144.  * from the alerts.h file. Generally, should be NON deadend alerts.     *
  145.  *                                                                      *
  146.  * For example, if you can't open ArpLibrary:                           *
  147.  *      Alert( (AG_OpenLib|AO_ArpLib), 0L);                             *
  148.  ************************************************************************
  149.  *)
  150.  
  151.   aoArpLib     * = 00008036H;           (* Alert object *)
  152.  
  153. (*
  154.  ************************************************************************
  155.  *      Alerts that arp.library may return...                           *
  156.  ************************************************************************
  157.  *)
  158.  
  159.   deadEnd * = MIN(LONGINT);
  160.  
  161.   anArpLib       * =           03600000H; (* Alert number              *)
  162.   anArpNoMem     * =           03610000H; (* No more memory            *)
  163.   anArpInputMem  * =           03610002H; (* No memory for input buffer*)
  164.   anArpNoMakeEnv * = deadEnd + 03610003H; (* No memory to make EnvLib  *)
  165.  
  166.   anArpNoDOS     * = deadEnd + 03630001H; (* Can't open dos.library    *)
  167.   anArpNoGfx     * = deadEnd + 03630002H; (* Can't open gfx.library    *)
  168.   anArpNoIntuit  * = deadEnd + 03630003H; (* Can't open intuition      *)
  169.   anBadPackBlues * = deadEnd + 03640000H; (* Bad packet to SendPacket()*)
  170.   anZombie       * = deadEnd + 03600003H; (* Zombie roaming around sys.*)
  171.  
  172.   anArpScattered * = deadEnd + 03600002H; (* Scatter load not allowed  *)
  173.  
  174. (*
  175.  ************************************************************************
  176.  *      Return codes you can get from calling ARP Assign()...           *
  177.  ************************************************************************
  178.  *)
  179.  
  180. CONST
  181.   assignOK      * = 0;      (* Everything is cool and groovey          *)
  182.   assignNODEV   * = 1;      (* "Physical" is not valid for assignment  *)
  183.   assignFATAL   * = 2;      (* Something really icky happened          *)
  184.   assignCANCEL  * = 3;      (* Tried to cancel something but it didn't *)
  185.  
  186. (*
  187.  ************************************************************************
  188.  *      Size of buffer you need if you are going to call ReadLine()     *
  189.  ************************************************************************
  190.  *)
  191.  
  192.   maxInputBuf   * = 256;
  193.  
  194. (*
  195.  ************************************************************************
  196.  *      The ARP file requester data structure...                        *
  197.  ************************************************************************
  198.  *)
  199.  
  200. TYPE
  201.   FileRequester * = STRUCT
  202.     hail* :   e.ADDRESS;              (* Hailing text                 *)
  203.     file* :    e.ADDRESS;             (* Filename array (FCHARS + 1)  *)
  204.     dir* :    e.ADDRESS;              (* Directory array (DSIZE + 1)  *)
  205.     window* : I.WindowPtr;            (* Window requesting or NULL    *)
  206.     funcFlags* : SHORTSET;            (* Set bitdef's below           *)
  207.     flags2* : SHORTSET;               (* New flags...                 *)
  208.     function* : PROCEDURE();          (* Your function, see bitdef's  *)
  209.     leftEdge* : INTEGER;              (* To be used later...          *)
  210.     topEdge* : INTEGER;
  211.   END;
  212.  
  213.  
  214.  
  215. (*
  216.  ************************************************************************
  217.  * The following are the defines for fr_FuncFlags.  These bits tell     *
  218.  * FileRequest() what your fr_UserFunc is expecting, and what           *
  219.  * FileRequest() should call it for.                                    *
  220.  *                                                                      *
  221.  * You are called like so:                                              *
  222.  * fr_Function(Mask, Object)                                            *
  223.  * ULONG        Mask;                                                   *
  224.  * CPTR         *Object;                                                *
  225.  *                                                                      *
  226.  * The Mask is a copy of the flag value that caused FileRequest() to    *
  227.  * call your function. You can use this to determine what action you    *
  228.  * need to perform, and exactly what Object is, so you know what to do  *
  229.  * and what to return.                                                  *
  230.  ************************************************************************
  231.  *)
  232.  
  233. CONST
  234.  
  235.   doWildFunc  * = 7; (* Call me with a FIB and a name, 0 return accepts*)
  236.   doMsgFunc   * = 6; (* You get all IDCMP messages not for FileRequest *)
  237.   doColor     * = 5; (* Set this bit for that new and different look   *)
  238.   newIDCMP    * = 4; (* Force a new IDCMP (only if fr_Window != NULL)  *)
  239.   newWindFunc * = 3; (* You get to modify the newwindow structure.     *)
  240.   addGadFunc  * = 2; (* You get to add gadgets.                        *)
  241.   gEventFunc  * = 1; (* Function to call if one of your gadg is selectd*)
  242.   listFunc    * = 0; (* Not implemented yet.                           *)
  243.  
  244. (*
  245.  ************************************************************************
  246.  * The FR2B_ bits are for fr_Flags2 in the file requester structure     *
  247.  ************************************************************************
  248.  *)
  249.  
  250.   longPath * = 0; (* Specify the fr_Dir buffer is 256 bytes long *)
  251.  
  252. (*
  253.  ************************************************************************
  254.  *      The sizes of the different buffers...                           *
  255.  ************************************************************************
  256.  *)
  257.  
  258.   fChars     * =     32; (* Filename size                              *)
  259.   dSize      * =     33; (* Directory name size if not FR2B_LongPath   *)
  260.  
  261.   longDSize  * =    254; (* If FR2B_LongPath is set, use LONG_DSIZE    *)
  262.   longFSize  * =    126; (* For compatibility with ARPbase.i           *)
  263.  
  264.   firstGadget * = 7680H; (* User gadgetID's must be < this value       *)
  265.  
  266. (*
  267.  ************************************************************************
  268.  * Structure expected by FindFirst()/FindNext()                         *
  269.  *                                                                      *
  270.  * You need to allocate this structure and initialize it as follows:    *
  271.  *                                                                      *
  272.  * Set ap_BreakBits to the signal bits (CDEF) that you want to take a   *
  273.  * break on, or NULL, if you don't want to convenience the user.        *
  274.  *                                                                      *
  275.  * if you want to have the FULL PATH NAME of the files you found,       *
  276.  * allocate a buffer at the END of this structure, and put the size of  *
  277.  * it into ap_StrLen.  If you don't want the full path name, make sure  *
  278.  * you set ap_StrLen to zero.  In this case, the name of the file, and  *
  279.  * stats are available in the ap_Info, as per usual.                    *
  280.  *                                                                      *
  281.  * Then call FindFirst() and then afterwards, FindNext() with this      *
  282.  * structure.  You should check the return value each time (see below)  *
  283.  * and take the appropriate action, ultimately calling                  *
  284.  * FreeAnchorChain() when there are no more files and you are done.     *
  285.  * You can tell when you are done by checking for the normal AmigaDOS   *
  286.  * return code ERROR_NO_MORE_ENTRIES.                                   *
  287.  *                                                                      *
  288.  * You will also have to check the DirEntryType variable in the ap_Info *
  289.  * structure to determine what exactly you have received.               *
  290.  ************************************************************************
  291.  *)
  292.  
  293. TYPE
  294.   AnchorPath * = STRUCT
  295.     base* : AChainPtr;       (* Pointer to first anchor                *)
  296.     last* : AChainPtr;       (* Pointer to last anchor                 *)
  297.     breakBits* : LONGSET;    (* Bits to break on                       *)
  298.     foundBreak* : LONGSET;   (* Bits we broke on. returns ERROR_BREAK  *)
  299.     flags* : SHORTSET;       (* New use for the extra word...          *)
  300.     reserved* : s.BYTE;      (* To fill it out...                      *)
  301.     strLen* : INTEGER;       (* This is what used to be ap_Length      *)
  302.     info* : d.FileInfoBlock;
  303. (*  buf* : ARRAY OF s.BYTE; *)(* Allocate a buffer here, if desired     *)
  304.   END;
  305.  
  306. (*
  307.  ************************************************************************
  308.  *      Bit definitions for the new ap_Flags...                         *
  309.  ************************************************************************
  310.  *)
  311.  
  312. CONST
  313.   doWild    * =  0;    (* User option ALL                              *)
  314.   itsWild   * =  1;    (* Set by FindFirst, used by FindNext           *)
  315.   doDir     * =  2;    (* Bit is SET if a DIR node should be entered   *)
  316.                        (* Application can RESET this bit to AVOID      *)
  317.                        (* entering a dir.                              *)
  318.   didDir    * =  3;    (* Bit is set for an "expired" dir node         *)
  319.   noMemErr  * =  4;    (* Set if there was not enough memory           *)
  320.   doDot     * =  5;    (* If set, '.' (DOT) will convert to CurrentDir *)
  321.  
  322. (*
  323.  ************************************************************************
  324.  * Structure used by the pattern matching functions, no need to obtain, *
  325.  * diddle or allocate this yourself.                                    *
  326.  *                                                                      *
  327.  * Note:  If you did, you will now break as it has changed...           *
  328.  ************************************************************************
  329.  *)
  330.  
  331. TYPE
  332.   AChain * = STRUCT
  333.              child* : AChainPtr;
  334.              paren* : AChainPtr;
  335.              lock* :  d.FileLockPtr;
  336.              info* :  d.FileInfoBlockPtr;
  337.              flags* : SHORTSET;
  338.              string* :ARRAY 1 OF CHAR;   (* Just as is .i file   *)
  339.            END;                          (* ???  Don't use this! *)
  340.  
  341. CONST
  342.  
  343.   patternBit  * = 0;
  344.   examinedBit * = 1;
  345.   completed   * = 2;
  346.   allBit      * = 3;
  347.  
  348. (*
  349.  ************************************************************************
  350.  * Constants used by wildcard routines                                  *
  351.  *                                                                      *
  352.  * These are the pre-parsed tokens referred to by pattern match.  It    *
  353.  * is not necessary for you to do anything about these, FindFirst()     *
  354.  * FindNext() handle all these for you.                                 *
  355.  ************************************************************************
  356.  *)
  357.  
  358. CONST
  359.   any      * =  80X;   (* Token for '*' | '#?' *)
  360.   single   * =  81X;   (* Token for '?'        *)
  361.  
  362. (*
  363.  ************************************************************************
  364.  * No need to muck with these as they may change...                     *
  365.  ************************************************************************
  366.  *)
  367.  
  368. CONST
  369.  
  370.   orStart    * =  82X;  (* Token for '('        *)
  371.   orNext     * =  83X;  (* Token for '|'        *)
  372.   OrEnd      * =  84X;  (* Token for ')'        *)
  373.   not        * =  85X;  (* Token for '~'        *)
  374.   notClass   * =  87X;  (* Token for '^'        *)
  375.   class      * =  88X;  (* Token for '[]'       *)
  376.   repBeg     * =  89X;  (* Token for '['        *)
  377.   repEnd     * =  8AX;  (* Token for ']'        *)
  378.  
  379. (*
  380.  ************************************************************************
  381.  * Structure used by AddDANode(), AddDADevs(), FreeDAList().            *
  382.  *                                                                      *
  383.  * This structure is used to create lists of names, which normally      *
  384.  * are devices, assigns, volumes, files, or directories.                *
  385.  ************************************************************************
  386.  *)
  387.  
  388. TYPE
  389.   DirectoryEntry * = STRUCT
  390.     next* : DirectoryEntryPtr;  (* Next in list                       *)
  391.     type* : SHORTINT;           (* DLX_mumble                         *)
  392.     flags* : SHORTSET;          (* For future expansion, DO NOT USE!  *)
  393.     name* : ARRAY 256 OF CHAR;  (* The name of the thing found        *)
  394.   END;
  395.  
  396. (*
  397.  ************************************************************************
  398.  * Defines you use to get a list of the devices you want to look at.    *
  399.  * For example, to get a list of all directories and volumes, do:       *
  400.  *                                                                      *
  401.  *      AddDADevs( mydalist, (DLF_DIRS | DLF_VOLUMES) )                 *
  402.  *                                                                      *
  403.  * After this, you can examine the de_type field of the elements added  *
  404.  * to your list (if any) to discover specifics about the objects added. *
  405.  *                                                                      *
  406.  * Note that if you want only devices which are also disks, you must    *
  407.  * (DLF_DEVICES | DLF_DISKONLY).                                        *
  408.  ************************************************************************
  409.  *)
  410.  
  411. CONST
  412.   devices   * =  0;  (* Return devices                               *)
  413.   diskOnly  * =  1;  (* Modifier for above: Return disk devices only *)
  414.   volumes   * =  2;  (* Return volumes only                          *)
  415.   dirs      * =  3;  (* Return assigned devices only                 *)
  416.  
  417. (*
  418.  ************************************************************************
  419.  * Legal de_Type values, check for these after a call to AddDADevs(),   *
  420.  * or use on your own as the ID values in AddDANode().                  *
  421.  ************************************************************************
  422.  *)
  423.  
  424.   file      * = 0H;     (* AddDADevs() can't determine this     *)
  425.   dir       * = 8H;     (* AddDADevs() can't determine this     *)
  426.   device    * = 16H;    (* It's a resident device               *)
  427.  
  428.   volume    * = 24H;    (* Device is a volume                   *)
  429.   ummounted * = 32H;    (* Device is not resident               *)
  430.  
  431.   assign    * = 40H;    (* Device is a logical assignment       *)
  432.  
  433. (*
  434.  ************************************************************************
  435.  *      Resource Tracking stuff...                                      *
  436.  ************************************************************************
  437.  *                                                                      *
  438.  * There are a few things in arp.library that are only directly         *
  439.  * acessable from assembler.  The glue routines provided by us for      *
  440.  * all 'C' compilers use the following conventions to make these        *
  441.  * available to C programs.  The glue for other language's should use   *
  442.  * as similar a mechanism as possible, so that no matter what language  *
  443.  * or compiler we speak, when talk about arp, we will know what the     *
  444.  * other guy is saying.                                                 *
  445.  *                                                                      *
  446.  * Here are the cases:                                                  *
  447.  *                                                                      *
  448.  * Tracker calls...                                                     *
  449.  *              These calls return the Tracker pointer as a secondary   *
  450.  *              result in the register A1.  For C, there is no clean    *
  451.  *              way to return more than one result so the tracker       *
  452.  *              pointer is returned in IoErr().  For ease of use,       *
  453.  *              there is a define that typecasts IoErr() to the correct *
  454.  *              pointer type.  This is called LastTracker and should    *
  455.  *              be source compatible with the earlier method of storing *
  456.  *              the secondary result.                                   *
  457.  *                                                                      *
  458.  * GetTracker() -                                                       *
  459.  *              Syntax is a bit different for C than the assembly call  *
  460.  *              The C syntax is GetTracker(ID).  The binding routines   *
  461.  *              will store the ID into the tracker on return.  Also,    *
  462.  *              in an effort to remain consistant, the tracker will     *
  463.  *              also be stored in LastTracker.                          *
  464.  *                                                                      *
  465.  * In cases where you have allocated a tracker before you have obtained *
  466.  * a resource (usually the most efficient method), and the resource has *
  467.  * not been obtained, you will need to clear the tracker id.  The macro *
  468.  * CLEAR_ID() has been provided for that purpose.  It expects a pointer *
  469.  * to a DefaultTracker sort of struct.                                  *
  470.  ************************************************************************
  471.  
  472. #define CLEAR_ID(t)     ((SHORT * ) t)[-1]* =NULL
  473.  
  474.  ************************************************************************
  475.  * You MUST prototype IoErr() to prevent the possible error in defining *
  476.  * IoErr() and thus causing LastTracker to give you trash...            *
  477.  *                                                                      *
  478.  * N O T E !  You MUST! have IoErr() defined as LONG to use LastTracker *
  479.  *            If your compiler has other defines for this, you may wish *
  480.  *            to remove the prototype for IoErr().                      *
  481.  ************************************************************************
  482.  
  483. #define LastTracker     ((struct DefaultTracker * )IoErr())
  484.  
  485.  ************************************************************************
  486.  * The rl_FirstItem list (ResList) is a list of TrackedResource (below) *
  487.  * It is very important that nothing in this list depend on the task    *
  488.  * existing at resource freeing time (i.e., RemTask(0L) type stuff,     *
  489.  * DeletePort() and the rest).                                          *
  490.  *                                                                      *
  491.  * The tracking functions return a struct Tracker *Tracker to you, this *
  492.  * is a pointer to whatever follows the tr_ID variable.                 *
  493.  * The default case is reflected below, and you get it if you call      *
  494.  * GetTracker() ( see DefaultTracker below).                            *
  495.  *                                                                      *
  496.  * NOTE: The two user variables mentioned in an earlier version don't   *
  497.  * exist, and never did. Sorry about that (SDB).                        *
  498.  *                                                                      *
  499.  * However, you can still use ArpAlloc() to allocate your own tracking  *
  500.  * nodes and they can be any size or shape you like, as long as the     *
  501.  * base structure is preserved. They will be freed automagically just   *
  502.  * like the default trackers.                                           *
  503.  ************************************************************************
  504.  *)
  505.  
  506. TYPE TrackedResource * = STRUCT
  507.        node* : e.MinNode;   (* Double linked pointer                *)
  508.        flags* : SHORTSET;   (* Don't touch                          *)
  509.        lock* : s.BYTE;      (* Don't touch, for Get/FreeAccess()    *)
  510.        id* : INTEGER;       (* Item's ID                            *)
  511. (*
  512.  ************************************************************************
  513.  * The struct DefaultTracker *Tracker portion of the structure.         *
  514.  * The stuff below this point can conceivably vary, depending           *
  515.  * on user needs, etc.  This reflects the default.                      *
  516.  ************************************************************************
  517.  *)
  518.  
  519.        object* : e.ADDRESS; (* The thing being tracked              *)
  520.        extra* :  e.ADDRESS; (* Only needed sometimes                *)
  521.      END;
  522.  
  523.  
  524. (*
  525.  ************************************************************************
  526.  * You get a pointer to a struct of the following type when you call    *
  527.  * GetTracker().  You can change this, and use ArpAlloc() instead of    *
  528.  * GetTracker() to do tracking. Of course, you have to take a wee bit   *
  529.  * more responsibility if you do, as well as if you use TRAK_GENERIC    *
  530.  * stuff.                                                               *
  531.  *                                                                      *
  532.  * TRAK_GENERIC folks need to set up a task function to be called when  *
  533.  * an item is freed.  Some care is required to set this up properly.    *
  534.  *                                                                      *
  535.  * Some special cases are indicated by the unions below, for            *
  536.  * TRAK_WINDOW, if you have more than one window opened, and don't      *
  537.  * want the IDCMP closed particularly, you need to set a ptr to the     *
  538.  * other window in dt_Window2.  See CloseWindowSafely() for more info.  *
  539.  * If only one window, set this to NULL.                                *
  540.  ************************************************************************
  541.  *)
  542.  
  543. TYPE DefaultTracker * = STRUCT;
  544.        object* : e.ADDRESS;     (* The object being tracked  *)
  545.        extra* :  e.ADDRESS;
  546.      END;
  547.  
  548. (*
  549.  ************************************************************************
  550.  *      Items the tracker knows what to do about                        *
  551.  ************************************************************************
  552.  *)
  553.  
  554. CONST
  555.   aAMem    * =  0;      (* Default (ArpAlloc) element           *)
  556.   lock     * =  1;      (* File lock                            *)
  557.   trFile   * =  2;      (* Opened file                          *)
  558.   window   * =  3;      (* Window -- see docs                   *)
  559.   screen   * =  4;      (* Screen                               *)
  560.   library  * =  5;      (* Opened library                       *)
  561.   dAMem    * =  6;      (* Pointer to DosAllocMem block         *)
  562.   memNode  * =  7;      (* AllocEntry() node                    *)
  563.   segList  * =  8;      (* Program segment                      *)
  564.   resList  * =  9;      (* ARP (nested) ResList                 *)
  565.   mem      * =  10;     (* Memory ptr/length                    *)
  566.   generic  * =  11;     (* Generic Element, your choice         *)
  567.   dAList   * =  12;     (* DAlist ( aka file request )          *)
  568.   anchor   * =  13;     (* Anchor chain (pattern matching)      *)
  569.   fReq     * =  14;     (* FileRequest struct                   *)
  570.   font     * =  15;     (* GfxBase CloseFont()                  *)
  571.   max      * =  15;     (* Poof, anything higher is tossed      *)
  572.  
  573.   unlink   * =   7;     (* Free node bit                        *)
  574.   reloc    * =   6;     (* This may be relocated (not used yet) *)
  575.   moved    * =   5;     (* Item moved                           *)
  576.  
  577. (*
  578.  ************************************************************************
  579.  * Note: ResList MUST be a DosAllocMem'ed list!, this is done for       *
  580.  * you when you call CreateTaskResList(), typically, you won't need     *
  581.  * to access/allocate this structure.                                   *
  582.  ************************************************************************
  583.  *)
  584.  
  585. TYPE
  586.   ResList * = STRUCT
  587.     node* : e.MinNode;        (* Used by arplib to link reslists      *)
  588.     taskid* : e.TaskPtr;      (* Owner of this list                   *)
  589.     firstItem* : e.MinList;   (* List of Tracked Resources            *)
  590.     link* : ResListPtr;       (* SyncRun's use - hide list here       *)
  591.   END;
  592.  
  593. (*
  594.  ************************************************************************
  595.  *      Returns from CompareLock()                                      *
  596.  ************************************************************************
  597.  *)
  598.  
  599. CONST
  600.  
  601.   equal    * = 0;  (* The two locks refer to the same object       *)
  602.   clVolume * = 1;  (* Locks are on the same volume                 *)
  603.   difVol1  * = 2;  (* Locks are on different volumes               *)
  604.   difVol2  * = 3;  (* Locks are on different volumes               *)
  605.  
  606. (*
  607.  ************************************************************************
  608.  *      ASyncRun() stuff...                                             *
  609.  ************************************************************************
  610.  * Message sent back on your request by an exiting process.             *
  611.  * You request this by putting the address of your message in           *
  612.  * pcb_LastGasp, and initializing the ReplyPort variable of your        *
  613.  * ZombieMsg to the port you wish the message posted to.                *
  614.  ************************************************************************
  615.  *)
  616.  
  617. TYPE
  618.   ZombieMsg * = STRUCT
  619.     execMessage* : e.Message;
  620.     taskNum* :     LONGINT;     (* Task ID                      *)
  621.     returnCode* :  LONGINT;     (* Process's return code        *)
  622.     result2* :     LONGINT;     (* System return code           *)
  623.     exitTime* :    d.Date;      (* Date stamp at time of exit   *)
  624.     userInfo* :    LONGINT;     (* For whatever you wish        *)
  625.   END;
  626.  
  627. (*
  628.  ************************************************************************
  629.  * Structure required by ASyncRun() -- see docs for more info.          *
  630.  ************************************************************************
  631.  *)
  632.  
  633.   ProcessControlBlock * = STRUCT
  634.     stackSize* : LONGINT;     (* Stacksize for new process             *)
  635.     pri* : SHORTINT;          (* Priority of new task                  *)
  636.     control* : SHORTSET;      (* Control bits, see defines below       *)
  637.     trapCode* : e.ADDRESS;    (* Optional Trap Code                    *)
  638.     input* : e.BPTR;
  639.     output* : e.BPTR;         (* Optional stdin, stdout                *)
  640.     console* : LONGINT;
  641.     loadedCode* : e.ADDRESS;  (* If not null, will not load/unload code*)
  642.     lastGasp* : ZombieMsgPtr; (* ReplyMsg() to be filled in by exit    *)
  643.     wbProcess* : e.MsgPort;   (* Valid only when PRB_NOCLI             *)
  644.   END;
  645.  
  646. (*
  647.  ************************************************************************
  648.  * Formerly needed to pass NULLCMD to a child.  No longer needed.       *
  649.  * It is being kept here for compatibility only...                      *
  650.  ************************************************************************
  651.  *)
  652.  
  653. CONST
  654.   NoCmd * = "\n";
  655.  
  656. (*
  657.  ************************************************************************
  658.  * The following control bits determine what ASyncRun() does on         *
  659.  * Abnormal Exits and on background process termination.                *
  660.  ************************************************************************
  661.  *)
  662.  
  663.   saveio      * = 0;      (* Don't free/check file handles on exit     *)
  664.   closeSplat  * = 1;      (* Close Splat file, must request explicitly *)
  665.   noCLI       * = 2;      (* Don't create a CLI process                *)
  666. (*interactive * = 3;       This is now obsolete...                     *)
  667.   code        * = 4;      (* Dangerous yet enticing                    *)
  668.   stdio       * = 5;      (* Do the stdio thing, splat * = CON:Filename*)
  669.  
  670. (*
  671.  ************************************************************************
  672.  *      Error returns from SyncRun() and ASyncRun()                     *
  673.  ************************************************************************
  674.  *)
  675.  
  676.   noFile    * =  -1;     (* Could not LoadSeg() the file        *)
  677.   noMem     * =  -2;     (* No memory for something             *)
  678. (*noCLI     * =  -3;        This is now obsolete                *)
  679.   noSlot    * =  -4;     (* No room in TaskArray                *)
  680.   noInput   * =  -5;     (* Could not open input file           *)
  681.   noOutPut  * =  -6;     (* Could not get output file           *)
  682. (*noClock   * =  -7;        This is now obsolete                *)
  683. (*argErr    * =  -8;        This is now obsolete                *)
  684. (*noBCPL    * =  -9;        This is now obsolete                *)
  685. (*badLib    * =  -10;       This is now obsolete                *)
  686.   noStdio   * =  -11;    (* Couldn't get stdio handles          *)
  687.  
  688. (*
  689.  ************************************************************************
  690.  *      Added V35 of arp.library                                        *
  691.  ************************************************************************
  692.  *)
  693.  
  694.   wantSMessage * = -12; (* Child wants you to report IoErr() to user   *)
  695.                         (* for SyncRun() only...                       *)
  696.   noShellProc  * = -13; (* Can't create a shell/cli process            *)
  697.   noExec       * = -14; (* 'E' bit is clear                            *)
  698.   script       * = -15; (* S and E are set, IoErr() contains directory *)
  699.  
  700. (*
  701.  ************************************************************************
  702.  * Version 35 ASyncRun() allows you to create an independent            *
  703.  * interactive or background Shell/CLI. You need this variant of the    *
  704.  * pcb structure to do it, and you also have new values for nsh_Control,*
  705.  * see below.                                                           *
  706.  *                                                                      *
  707.  * Syntax for Interactive shell is:                                     *
  708.  *                                                                      *
  709.  * rc=ASyncRun("Optional Window Name","Optional From File",&NewShell);  *
  710.  *                                                                      *
  711.  * Syntax for a background shell is:                                    *
  712.  *                                                                      *
  713.  * rc=ASyncRun("Command line",0L,&NewShell);                            *
  714.  *                                                                      *
  715.  * Same syntax for an Execute style call, but you have to be on drugs   *
  716.  * if you want to do that.                                              *
  717.  ************************************************************************
  718.  *)
  719.  
  720. TYPE
  721.   NewShell * = STRUCT
  722.     stackSize* : LONGINT; (* Stacksize shell will use for children     *)
  723.     pri* : SHORTINT;      (* ignored by interactive shells             *)
  724.     control* : SHORTSET;  (* bits/values* : see above                  *)
  725.     logMsg* : e.ADDRESS;  (* Optional login message, if 0, use default *)
  726.     input* : e.BPTR;      (* ignored by interactive shells, but        *)
  727.     output* : e.BPTR;     (* used by background and execute options.   *)
  728.     reserved* : ARRAY 5 OF LONGINT;
  729.   END;
  730.  
  731. (*
  732.  ************************************************************************
  733.  * Bit Values for nsh_Control, you should use them as shown below, or   *
  734.  * just use the actual values indicated.                                *
  735.  ************************************************************************
  736.  *)
  737.  
  738. CONST
  739.   cli         * = 0;      (* Do a CLI, not a shell        *)
  740.   backGround  * = 1;      (* Background shell             *)
  741.   execute     * = 2;      (* Do as EXECUTE...             *)
  742.   interactive * = 3;      (* Run an interactive shell     *)
  743.   fb          * = 7;      (* Alt function bit...          *)
  744.  
  745. (*
  746.  ************************************************************************
  747.  *      Common values for sh_Control which allow you to do usefull      *
  748.  *      and somewhat "standard" things...                               *
  749.  ************************************************************************
  750.  *)
  751.  
  752. TYPE SS = SHORTSET;
  753.  
  754. CONST
  755.   interactiveShell*=SS{fb,interactive};       (* Gimme a newshell!     *)
  756.   interactiveCli  *=SS{fb,interactive,cli};   (* Gimme that ol newcli! *)
  757.   backGroundShell *=SS{fb,backGround};        (* gimme a backgrnd shell*)
  758.   executeMe       *=SS{fb,backGround,execute};(* aptly named           *)
  759.  
  760. (*
  761.  ************************************************************************
  762.  *      Additional IoErr() returns added by ARP...                      *
  763.  ************************************************************************
  764.  *)
  765.   errorBufferOverflow  * = 303; (* User or internal buffer overflow  *)
  766.   errorBreak           * = 304; (* A break character was received    *)
  767.   errorNotExecuteable  * = 305; (* A file has E bit cleared          *)
  768.   errorNotCLI          * = 400; (* Program/function neeeds to be cli *)
  769.  
  770. (*
  771.  ************************************************************************
  772.  *      Resident Program Support                                        *
  773.  ************************************************************************
  774.  * This is the kind of node allocated for you when you AddResidentPrg() *
  775.  * a code segment.  They are stored as a single linked list with the    *
  776.  * root in ArpBase.  If you absolutely *must* wander through this list  *
  777.  * instead of using the supplied functions, then you must first obtain  *
  778.  * the semaphore which protects this list, and then release it          *
  779.  * afterwards.  Do not use Forbid() and Permit() to gain exclusive      *
  780.  * access!  Note that the supplied functions handle this locking        *
  781.  * protocol for you.                                                    *
  782.  ************************************************************************
  783.  *)
  784.  
  785. TYPE
  786.   ResidentProgramNode * = STRUCT
  787.     next* : ResidentProgramNodePtr;  (* next or NULL                 *)
  788.     usage* : LONGINT;                (* Number of current users      *)
  789.     accessCnt* : INTEGER;            (* Total times used...          *)
  790.     checkSum* : LONGINT;             (* Checksum of code             *)
  791.     segment* : e.BPTR;               (* Actual segment               *)
  792.     flags* : SET;                    (* See definitions below...     *)
  793.  (* name* : ARRAY OF CHAR;              Allocated as needed          *)
  794.   END;
  795.  
  796. (*
  797.  ************************************************************************
  798.  *      Bit definitions for rpn_Flags....                               *
  799.  ************************************************************************
  800.  *)
  801.  
  802. CONST
  803.   noCheck  * =  0;      (* Set in rpn_Flags for no checksumming...   *)
  804.   cache    * =  1;      (* Private usage in v1.3...                  *)
  805.  
  806. (*
  807.  ************************************************************************
  808.  * If your program starts with this structure, ASyncRun() and SyncRun() *
  809.  * will override a users stack request with the value in rpt_StackSize. *
  810.  * Furthermore, if you are actually attached to the resident list, a    *
  811.  * memory block of size rpt_DataSize will be allocated for you, and     *
  812.  * a pointer to this data passed to you in register A4.  You may use    *
  813.  * this block to clone the data segment of programs, thus resulting in  *
  814.  * one copy of text, but multiple copies of data/bss for each process   *
  815.  * invocation.  If you are resident, your program will start at         *
  816.  * rpt_Instruction, otherwise, it will be launched from the initial     *
  817.  * branch.                                                              *
  818.  ************************************************************************
  819.  *)
  820. TYPE ResidentProgramTag * = STRUCT
  821.        nextSeg* : e.BPTR;     (* Provided by DOS at LoadSeg time      *)
  822. (*
  823.  ************************************************************************
  824.  * The initial branch destination and rpt_Instruction do not have to be *
  825.  * the same.  This allows different actions to be taken if you are      *
  826.  * diskloaded or resident.  DataSize memory will be allocated only if   *
  827.  * you are resident, but StackSize will override all user stack         *
  828.  * requests.                                                            *
  829.  ************************************************************************
  830.  *)
  831.        bra* : INTEGER;        (* Short branch to executable           *)
  832.        magic* : INTEGER;      (* Resident majik value                 *)
  833.        stacksize* : LONGINT;  (* min stack for this process           *)
  834.        dataSie* : LONGINT;    (* Data size to allocate if resident    *)
  835.     (* instruction;            Start here if resident          *)
  836.      END;
  837.  
  838. (*
  839.  ************************************************************************
  840.  * The form of the ARP allocated node in your tasks memlist when        *
  841.  * launched as a resident program. Note that the data portion of the    *
  842.  * node will only exist if you have specified a nonzero value for       *
  843.  * rpt_DataSize. Note also that this structure is READ ONLY, modify     *
  844.  * values in this at your own risk.  The stack stuff is for tracking,   *
  845.  * if you need actual addresses or stack size, check the normal places  *
  846.  * for it in your process/task struct.                                  *
  847.  ************************************************************************
  848.  *)
  849.  
  850.   ProcessMemory * = STRUCT
  851.     node* : e.Node;
  852.     num* : INTEGER;       (* This is 1 if no data, two if data    *)
  853.     stack* : e.ADDRESS;
  854.     stackSize* : LONGINT;
  855.     data* : e.ADDRESS;    (* Only here if pm_Num * =* = 2         *)
  856.     dataSize* : LONGINT;
  857.   END;
  858.  
  859. (*
  860.  ************************************************************************
  861.  * To find the above on your memlist, search for the following name.    *
  862.  * We guarantee this will be the only arp.library allocated node on     *
  863.  * your memlist with this name.                                         *
  864.  * i.e. FindName(task->tcb_MemEntry, PMEM_NAME);                        *
  865.  ************************************************************************
  866.  *)
  867.  
  868. CONST
  869.   pMemName * = "ARP_MEM";
  870.  
  871.   residentMagic * = 4AFCH;    (* same as RTC_MATCHWORD (trapf) *)
  872.  
  873. (*
  874.  ************************************************************************
  875.  *      Date String/Data structures                                     *
  876.  ************************************************************************
  877.  *)
  878.  
  879. TYPE
  880.   DateTime * = STRUCT
  881.     stamp* : d.Date;         (* DOS Datestamp                        *)
  882.     format* : s.BYTE;        (* controls appearance ot dat_StrDate   *)
  883.     flags* : SET;            (* See BITDEF's below                   *)
  884.     strDay* : e.ADDRESS;     (* day of the week string               *)
  885.     strData* : e.ADDRESS;    (* date string                          *)
  886.     strTime* : e.ADDRESS;    (* time string                          *)
  887.   END;
  888.  
  889. (*
  890.  ************************************************************************
  891.  *      Size of buffer you need for each DateTime strings:              *
  892.  ************************************************************************
  893.  *)
  894.  
  895. CONST
  896.   lenDatString * = 10;
  897.  
  898. (*
  899.  ************************************************************************
  900.  *      For dat_Flags                                                   *
  901.  ************************************************************************
  902.  *)
  903.  
  904.   subSt  * = 0;  (* Substitute "Today" "Tomorrow" where appropriate  *)
  905.   future * = 1;  (* Day of the week is in future                     *)
  906.  
  907. (*
  908.  ************************************************************************
  909.  *      For dat_Format                                                  *
  910.  ************************************************************************
  911.  *)
  912.  
  913.   formatDos * = 0;        (* dd-mmm-yy AmigaDOS's own, unique style  *)
  914.   formatInt * = 1;        (* yy-mm-dd International format           *)
  915.   formatUSA * = 2;        (* mm-dd-yy The good'ol'USA.               *)
  916.   formatCDN * = 3;        (* dd-mm-yy Our friends to the north       *)
  917.   formatMAX * = formatCDN;(* Larger than this? Defaults to AmigaDOS  *)
  918.  
  919.  
  920. (*
  921.  ************************************************************************
  922.  *  ARP Library Base                                                    *
  923.  ************************************************************************
  924.  *)
  925.  
  926. VAR
  927.   arp *, base * : ArpBasePtr;  (* synonyms *)
  928.  
  929. (*
  930.  ************************************************************************
  931.  *      These duplicate the calls in dos.library                        *
  932.  *      Only include if you can use arp.library without dos.library     *
  933.  ************************************************************************
  934.  *)
  935.  
  936. TYPE PROC * = PROCEDURE();
  937.  
  938. PROCEDURE Close* {arp,- 36}(file{1}:  d.FileHandlePtr);
  939. PROCEDURE CreateDir* {arp,-120}(name{1}: ARRAY OF CHAR): d.FileLockPtr;
  940. PROCEDURE CreateProc* {arp,-138}(name{1}: ARRAY OF CHAR;
  941.                                  pri{2}: LONGINT;
  942.                                  segment{3}: e.BPTR;
  943.                                  stackSize{4}: LONGINT): d.ProcessId;
  944. PROCEDURE CurrentDir* {arp,-126}(lock{1}: d.FileLockPtr): d.FileLockPtr;
  945. PROCEDURE DateStamp* {arp,-192}(VAR v{1}: d.Date);
  946. PROCEDURE Delay* {arp,-198}(ticks{1}: LONGINT);
  947. PROCEDURE DeleteFile* {arp,- 72}(name{1}: ARRAY OF CHAR): BOOLEAN;
  948. PROCEDURE DeviceProc* {arp,-174}(name{1}: ARRAY OF CHAR): d.ProcessId;
  949. PROCEDURE DupLock* {arp,- 96}(lock{1}: d.FileLockPtr): d.FileLockPtr;
  950. PROCEDURE Examine* {arp,-102}(lock{1}: d.FileLockPtr;
  951.            infoBlock{2}: d.FileInfoBlockPtr): BOOLEAN;
  952. PROCEDURE Execute* {arp,-222}(commandString{1}: ARRAY OF CHAR;
  953.            input{2}: d.FileHandlePtr;
  954.            output{3}: d.FileHandlePtr): LONGINT;
  955. PROCEDURE Exit* {arp,-144}(returnCode{1}: LONGINT);
  956. PROCEDURE ExNext* {arp,-108}(lock{1}: d.FileLockPtr;
  957.            infoBlock{2}: d.FileInfoBlockPtr): BOOLEAN;
  958. PROCEDURE GetPacket* {arp,-162}(wait{1}: LONGINT): d.DosPacketPtr;
  959. PROCEDURE Info* {arp,-114}(lock{1}: d.FileLockPtr;
  960.            parameterBlock{2}: d.InfoDataPtr): BOOLEAN;
  961. PROCEDURE Input* {arp,- 54}(): d.FileHandlePtr;
  962. PROCEDURE IoErr* {arp,-132}(): LONGINT;
  963. PROCEDURE IsInteractive* {arp,-216}(file{1}: d.FileHandlePtr): BOOLEAN;
  964. PROCEDURE LoadSeg* {arp,-150}(name{1}: ARRAY OF CHAR): e.BPTR;
  965. PROCEDURE Lock* {arp,- 84}(name{1}: ARRAY OF CHAR;
  966.                accessMode{2}: LONGINT): d.FileLockPtr;
  967. PROCEDURE Open* {arp,- 30}(name{1}: ARRAY OF CHAR;
  968.            accessMode{2}: LONGINT): d.FileHandlePtr;
  969. PROCEDURE Output* {arp,- 60}(): d.FileHandlePtr;
  970. PROCEDURE ParentDir* {arp,-210}(lock{1}: d.FileLockPtr): d.FileLockPtr;
  971. PROCEDURE QueuePacket* {arp,-168}(packet{1}: d.DosPacketPtr): LONGINT;
  972. PROCEDURE Read* {arp,- 42}(file{1}: d.FileHandlePtr;
  973.                buffer{2}: ARRAY OF s.BYTE;
  974.                length{3}: LONGINT): LONGINT;
  975. PROCEDURE Rename* {arp,- 78}(oldName{1},newName{2}: ARRAY OF CHAR): BOOLEAN;
  976. PROCEDURE Seek* {arp,- 66}(file{1}: d.FileHandlePtr;
  977.                position{2}: LONGINT;
  978.                mode{3}: LONGINT): LONGINT;
  979. PROCEDURE SetComment* {arp,-180}(name{1},comment{2}: ARRAY OF CHAR): BOOLEAN;
  980. PROCEDURE SetProtection* {arp,-186}(name{1}: ARRAY OF CHAR;
  981.                                     mask{2}: LONGSET (* ProtectionFlags *)
  982.                                     ): BOOLEAN;
  983. PROCEDURE UnLoadSeg* {arp,-156}(segment{1}: e.BPTR);
  984. PROCEDURE UnLock* {arp,- 90}(lock{1}: d.FileLockPtr);
  985. PROCEDURE WaitForChar* {arp,-204}(file{1}: d.FileHandlePtr;
  986.                                   timeout{2}: LONGINT): BOOLEAN;
  987. PROCEDURE Write* {arp,- 48}(file{1}: d.FileHandlePtr;
  988.                             buffer{2}: ARRAY OF s.BYTE;
  989.                             length{3}: LONGINT): LONGINT;
  990.  
  991.  
  992. (*
  993.  ************************************************************************
  994.  *      Now for the stuff that only exists in arp.library...            *
  995.  ************************************************************************
  996.  *)
  997.  
  998. PROCEDURE AddDADevs* {arp,-516}(dalist{8}: DirectoryEntryPtr;
  999.                     select{0}: LONGSET (* DirEntryType *)): LONGINT;
  1000. PROCEDURE AddDANode* {arp,-510}(data{8}: e.ADDRESS;
  1001.                     dalist{9}: DirectoryEntryPtr;
  1002.                     length{0}: LONGINT;
  1003.                     id{1}: LONGSET (* DirEntryType *)): DirectoryEntryPtr;
  1004. PROCEDURE AddResidentPrg* {arp,-582}(segment{1}: e.BPTR;
  1005.                          name{8}: ARRAY OF CHAR): ResidentProgramNodePtr;
  1006. PROCEDURE ArpAlloc* {arp,-384}(size{0}: LONGINT): e.ADDRESS;
  1007. PROCEDURE ArpAllocMem* {arp,-390}(size{0}: LONGINT;
  1008.                       reqs{1}: LONGSET (* e.MemReqs *)): e.ADDRESS;
  1009. PROCEDURE ArpDupLock* {arp,-402}(lock{1}: d.FileLockPtr): d.FileLockPtr;
  1010. PROCEDURE ArpExit* {arp,-378}(returncode{0}: LONGINT;
  1011.                   fault{2}: LONGINT);
  1012. PROCEDURE ArpLock* {arp,-408}(name{1}: ARRAY OF CHAR;
  1013.                   accessMode{2}: LONGINT): d.FileLockPtr;
  1014. PROCEDURE ArpOpen* {arp,-396}(name{1}: ARRAY OF CHAR;
  1015.                   accessmode{2}: LONGINT): d.FileHandlePtr;
  1016. PROCEDURE Assign* {arp,-336}(name{8}: ARRAY OF CHAR;
  1017.                  phys{9}: ARRAY OF CHAR): LONGINT;
  1018. PROCEDURE ASyncRun* {arp,-546}(command{8}: ARRAY OF CHAR;
  1019.                    args{9}: ARRAY OF CHAR;
  1020.                    pcb{10}: ProcessControlBlockPtr): LONGINT;
  1021. PROCEDURE Atol* {arp,-258}(string{8}: ARRAY OF CHAR): LONGINT;
  1022. PROCEDURE BaseName* {arp,-630}(pathname{8}: ARRAY OF CHAR): e.ADDRESS;
  1023. PROCEDURE BtoCStr* {arp,-354}(cstring{8}: ARRAY OF CHAR;
  1024.                   bstr{0}: d.BSTR;
  1025.                   maxlength{1}: LONGINT): LONGINT;
  1026. PROCEDURE CheckAbort* {arp,-270}(func{9}: PROC): LONGSET;
  1027. PROCEDURE CheckBreak* {arp,-276}(mask{1}: LONGSET;
  1028.                      func{9}: PROC): LONGSET;
  1029. PROCEDURE CheckSumPrg* {arp,-618}(
  1030.                   node{1}: ResidentProgramNodePtr): LONGINT;
  1031. PROCEDURE CloseWindowSafely* {arp,-300}(window{8}: I.WindowPtr;
  1032.                             morewindows{9}: BOOLEAN);
  1033. PROCEDURE CompareLock* {arp,-456}(
  1034.                   lock1{0},lock2{1}: d.FileLockPtr): LONGINT;
  1035. PROCEDURE CreatePort* {arp,-306}(name{8}: e.ADDRESS;
  1036.                      priority{0}: SHORTINT): e.MsgPortPtr;
  1037. PROCEDURE CreateTaskResList* {arp,-468}(): ResListPtr;
  1038. PROCEDURE CtoBStr* {arp,-360}(cstring{8}: ARRAY OF CHAR;
  1039.                   bstr{0}: d.BSTR;
  1040.                   maxlength{1}: LONGINT): LONGINT;
  1041. PROCEDURE DeletePort* {arp,-312}(port{9}: e.MsgPortPtr);
  1042. PROCEDURE DosAllocMem* {arp,-342}(size{0}: LONGINT): e.ADDRESS;
  1043. PROCEDURE DosFreeMem* {arp,-348}(memBlk{9}: e.ADDRESS);
  1044. PROCEDURE EscapeString* {arp,-264}(string{8}: ARRAY OF CHAR): LONGINT;
  1045. PROCEDURE FileRequest* {arp,-294}(
  1046.                   filereq{8}: FileRequesterPtr): e.ADDRESS;
  1047. PROCEDURE FindCLI* {arp,-420}(tasknum{0}: LONGINT): d.ProcessPtr;
  1048. PROCEDURE FindFirst* {arp,-438}(pat{0}: ARRAY OF CHAR;
  1049.                     chain{8}: AnchorPathPtr): LONGINT;
  1050. PROCEDURE FindNext* {arp,-444}(chain{8}: AnchorPathPtr): LONGINT;
  1051. PROCEDURE FindTaskResList* {arp,-462}(): ResListPtr;
  1052. PROCEDURE VFPrintf* {arp,-234}(file{0}: d.FileHandlePtr;
  1053.                   string{8}: ARRAY OF CHAR;
  1054.                   argarray{9}: ARRAY OF e.APTR): LONGINT;
  1055. PROCEDURE FPrintf* {arp,-234}(file{0}: d.FileHandlePtr;
  1056.                   string{8}: ARRAY OF CHAR;
  1057.                   args{9}..: e.APTR): LONGINT;
  1058. PROCEDURE FreeAccess* {arp,-498}(tracker{9}: DefaultTrackerPtr);
  1059. PROCEDURE FreeAnchorChain* {arp,-450}(chain{8}: AnchorPathPtr);
  1060. PROCEDURE FreeDAList* {arp,-504}(dalist{9}: e.ADDRESS);
  1061. PROCEDURE FreeResList* {arp,-474}(freelist{9}: e.ADDRESS);
  1062. PROCEDURE FreeTaskResList* {arp,-372}(): BOOLEAN;
  1063. PROCEDURE FreeTrackedItem* {arp,-480}(item{9}: DefaultTrackerPtr);
  1064. PROCEDURE GADS* {arp,-252}(cmdLine{8}: ARRAY OF CHAR;
  1065.                cmdLen{0}: LONGINT;
  1066.                help{9}: ARRAY OF CHAR;
  1067.                argarray{10}: e.ADDRESS;
  1068.                tplate{11}: ARRAY OF CHAR): LONGINT;
  1069. PROCEDURE GetAccess* {arp,-492}(
  1070.                tracker{9}: DefaultTrackerPtr): DefaultTrackerPtr;
  1071. PROCEDURE GetDevInfo* {arp,-366}(
  1072.                devinfo{10}: d.DeviceListPtr): d.DeviceListPtr;
  1073. PROCEDURE GetEnv* {arp,-282}(string{8}: ARRAY OF CHAR;
  1074.                  buffer{9}: ARRAY OF CHAR;
  1075.                  size{0}: LONGINT): e.ADDRESS;
  1076. PROCEDURE GetTracker* {arp,-486}(id{9}: LONGINT): DefaultTrackerPtr;
  1077. PROCEDURE InitStdPacket* {arp,-324}(action{0}: LONGINT;
  1078.                         args{8}: e.ADDRESS;
  1079.                         packet{9}: e.ADDRESS;
  1080.                         replyport{10}: e.MsgPortPtr);
  1081. PROCEDURE LDiv* {arp,-606}(dividend{0},divisor{1}: LONGINT): LONGINT;
  1082. PROCEDURE LMod* {arp,-612}(dividend{0},divisor{1}: LONGINT): LONGINT;
  1083. PROCEDURE LMult* {arp,-600}(num1{0},num2{1}: LONGINT): LONGINT;
  1084. PROCEDURE LoadPrg* {arp,-552}(name{1}: ARRAY OF CHAR): e.BPTR;
  1085. PROCEDURE ObtainResidentPrg* {arp,-576}(
  1086.                    name{8}: ARRAY OF CHAR): ResidentProgramNodePtr;
  1087. PROCEDURE PathName* {arp,-330}(lock{0}: d.FileLockPtr;
  1088.                    VAR dest{8}: ARRAY OF CHAR;
  1089.                    numberNames{1}: LONGINT): LONGINT;
  1090. PROCEDURE PatternMatch* {arp,-432}(pat{8}: ARRAY OF CHAR;
  1091.                        str{9}: ARRAY OF CHAR): BOOLEAN;
  1092. PROCEDURE PreParse* {arp,-558}(source{8}: ARRAY OF CHAR;
  1093.                    dest{9}: ARRAY OF CHAR): BOOLEAN;
  1094. PROCEDURE VPrintf* {arp,-228}(string{8}: ARRAY OF CHAR;
  1095.                  argarray{9}: ARRAY OF e.ADDRESS): LONGINT;
  1096. PROCEDURE Printf* {arp,-228}(string{8}: ARRAY OF CHAR;
  1097.                  args{9}..: e.APTR): LONGINT;
  1098. PROCEDURE Puts* {arp,-240}(string{9}: ARRAY OF CHAR): LONGINT;
  1099. PROCEDURE QSort* {arp,-426}(baseptr{8}: e.ADDRESS;
  1100.                 regionsize{0}: LONGINT;
  1101.                 bytesize{1}: LONGINT;
  1102.                 userfunction{9}: PROC): BOOLEAN;
  1103. PROCEDURE ReadLine* {arp,-246}(buffer{8}: ARRAY OF s.BYTE): LONGINT;
  1104. PROCEDURE ReleaseResidentPrg* {arp,-636}(segment{1}: e.BPTR):
  1105.                                       ResidentProgramNodePtr;
  1106. PROCEDURE RemResidentPrg* {arp,-588}(name{8}: ARRAY OF CHAR): LONGINT;
  1107. PROCEDURE RListAlloc* {arp,-414}(reslist{8}: ResListPtr;
  1108.                      size{0}: LONGINT): e.ADDRESS;
  1109. PROCEDURE SendPacket* {arp,-318}(action{0}: LONGINT;
  1110.                      args{8}: e.ADDRESS;
  1111.                      handler{9}: e.MsgPortPtr): LONGINT;
  1112. PROCEDURE SetEnv* {arp,-288}(string{8}: ARRAY OF CHAR;
  1113.                  buffer{9}: ARRAY OF CHAR): BOOLEAN;
  1114. PROCEDURE StampToStr* {arp,-564}(datetime{8}: d.DatePtr): BOOLEAN;
  1115. PROCEDURE Strcmp* {arp,-522}(s1{8},s2{9}: ARRAY OF CHAR): LONGINT;
  1116. PROCEDURE Strncmp* {arp,-528}(st{8},s2{9}: ARRAY OF CHAR;
  1117.                   n{0}: LONGINT): LONGINT;
  1118. PROCEDURE StrToStamp* {arp,-570}(datetime{8}: d.DatePtr): BOOLEAN;
  1119. PROCEDURE SyncRun* {arp,-540}(filename{8}: ARRAY OF CHAR;
  1120.                   args{9}: ARRAY OF CHAR;
  1121.                   input{0}: d.FileHandlePtr;
  1122.                   output{1}: d.FileHandlePtr): LONGINT;
  1123. PROCEDURE TackOn* {arp,-624}(pathname{8},filename{9}: ARRAY OF CHAR);
  1124. PROCEDURE ToUpper* {arp,-534}(old{0}: CHAR): CHAR;
  1125. PROCEDURE UnLoadPrg* {arp,-594}(segment{1}: e.BPTR);
  1126.  
  1127. PROCEDURE SPrintf* {arp,-642}(file{0}: e.ADDRESS;
  1128.                             str{8}: ARRAY OF CHAR;
  1129.                             stream{9}: e.ADDRESS): LONGINT;
  1130. PROCEDURE GetKeywordIndex* {arp,-648}(
  1131.                   str1{8},str2{9}: ARRAY OF CHAR): LONGINT;
  1132. PROCEDURE ArpOpenLibrary* {arp,-654}(name{9}: ARRAY OF CHAR;
  1133.                                    vers{0}: LONGINT): e.LibraryPtr;
  1134. PROCEDURE ArpAllocFreq* {arp,-660}(): FileRequesterPtr;
  1135.  
  1136.  
  1137. (* $OvflChk- $RangeChk- $StackChk- $NilChk- $ReturnChk- $CaseChk- *)
  1138.  
  1139. BEGIN
  1140.  
  1141.  arp :=  s.VAL(ArpBasePtr,e.OpenLibrary(arpName,arpVersion));
  1142.  IF arp = NIL THEN
  1143.    s.SETREG(0,I.DisplayAlert(0,
  1144.      "\x00\x64\x14missing arp.library V39\o\o",50));
  1145.    HALT(0)
  1146.  END;
  1147.  base := arp;
  1148.  
  1149. CLOSE
  1150.  
  1151.  IF arp#NIL THEN e.CloseLibrary(s.VAL(e.LibraryPtr,arp)) END;
  1152.  
  1153. END ARP.
  1154.  
  1155.