home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 073.lha / Arp / documentation / Arp31.docs < prev    next >
Encoding:
Text File  |  1986-11-20  |  59.9 KB  |  1,980 lines

  1.  
  2.  
  3. TABLE OF CONTENTS (not in order)
  4.  
  5. arp.doc/Printf
  6. arp.doc/FPrintf
  7. arp.doc/Puts
  8. arp.doc/ReadLine
  9. arp.doc/GADS
  10. arp.doc/Atol
  11. arp.doc/EscapeString
  12. arp.doc/CheckAbort
  13. arp.doc/CheckBreak
  14. arp.doc/Getenv
  15. arp.doc/Setenv
  16. arp.doc/FileRequest
  17. arp.doc/CloseWindowSafely
  18. arp.doc/CreatePort
  19. arp.doc/DeletePort
  20. arp.doc/SendPacket
  21. arp.doc/InitStdPacket
  22. arp.doc/PathName
  23. arp.doc/Assign
  24. arp.doc/DosAllocMem
  25. arp.doc/DosFreeMem
  26. arp.doc/BtoCStr
  27. arp.doc/CtoBStr
  28. arp.doc/GetDevInfo
  29. arp.doc/FreeTaskResources
  30. arp.doc/ArpExit
  31. arp.doc/ArpAlloc
  32. arp.doc/ArpAllocMem
  33. arp.doc/ArpOpen
  34. arp.doc/ArpDupLock
  35. arp.doc/ArpLock
  36. arp.doc/FindProcess
  37. arp.doc/GetDataSegment
  38. arp.doc/PatternMatch
  39. arp.doc/FindFirst
  40. arp.doc/FindNext
  41. arp.doc/FreeAnchorChain
  42.  
  43. arp.doc/DosAllocMem (V31)
  44.  
  45.      NAME        DosAllocMem -- AmigaDOS compatible memory allocator
  46.  
  47.     SYNOPSIS
  48.         memBlock = DosAllocMem( size_in_bytes )
  49.             d0                      d0
  50.  
  51.     FUNCTION
  52.         This function returns a memory block of the size requested, or
  53.         NULL if the allocation failed.  The memory will satisfy the
  54.         requirements of MEMF_PUBLIC | MEMF_CLEAR.
  55.  
  56.         As expected by AmigaDOS, the total size of the memory block is
  57.         stored at (memblock - 4), so the actual memory allocated will
  58.         always be four bytes larger than size_in_bytes.
  59.  
  60.     INPUTS
  61.         size_in_bytes - the size of the desired block in bytes.
  62.  
  63.     RESULT
  64.         memBlock - a pointer to the allocated free block.  This block
  65.                    will be longword aligned, and the total size of the
  66.                    block is stored at (memblock - 4).  If the allocation
  67.                    failed, memBlock will return zero.
  68.  
  69.     ADDITIONAL CONSIDERATIONS
  70.         The value returned by DosAllocMem is a real pointer.  If you
  71.         need a BPTR, you must convert this value yourself.
  72.  
  73.     BUGS
  74.         None known.
  75.  
  76.     SEE ALSO
  77.         DosFreeMem()
  78.  
  79.     AUTHOR: SDB
  80.     REVISED:
  81. arp.doc/DosFreeMem (V31)
  82.  
  83.     NAME
  84.         DosFreeMem -- AmigaDOS compatible memory freer.
  85.  
  86.     SYNOPSIS
  87.         DosFreeMem( memBlock )
  88.                         A1
  89.  
  90.     FUNCTION
  91.         This function frees a memory block which was allocated using
  92.         DosAllocMem or was allocated by AmigaDOS.
  93.  
  94.     INPUTS
  95.         memBlock -- the pointer to the memblock returned by DosAllocMem.
  96.                     This pointer may also be NULL, in which case no
  97.                     memory will be freed.
  98.  
  99.     ADDITIONAL CONSIDERATIONS
  100.         memBlock is not a BPTR - if you are passing a value obtained
  101.         from AmigaDOS, make sure you convert it from a BPTR to a real
  102.         pointer first!
  103.  
  104.     RESULT
  105.         None.
  106.  
  107.     BUGS
  108.         None known.
  109.  
  110.     SEE ALSO
  111.         DosAllocMem()
  112.  
  113.         AUTHOR: SDB
  114.         REVISED:
  115. arp.doc/Printf (V31)
  116.  
  117.     NAME
  118.         Printf -- print formatted data on current output.
  119.  
  120.     SYNOPSIS
  121.         count = Printf("String", *args)
  122.           d0              A0      A1
  123.  
  124.     FUNCTION
  125.         Print formatted data on current output stream.  This function
  126.         is implemented as FPrintf( Output(), "String", *args), please
  127.         see that page for more information.
  128.  
  129.     INPUTS
  130.         See FPrintf entry for "String" *args.
  131.  
  132.     RESULT
  133.         See FPrintf entry.
  134.  
  135.     BUGS
  136.         None known.
  137.  
  138.     SEE ALSO
  139.         FPrintf, Puts.
  140.  
  141.         AUTHOR: SDB
  142.         REVISED:
  143. arp.doc/FPrinff (V31)
  144.  
  145.     NAME
  146.         FPrintf -- print formatted data on file.
  147.  
  148.     SYNOPSIS
  149.         count = FPrintf(File, "String", *args)
  150.               D0      A0       A1
  151.     FUNCTION
  152.         This function performs 'standard' C-style formatting of data on
  153.         the specified output file. It uses the exec function
  154.         RawDoFmt() to do the actual formatting of the data.  The %
  155.         types supported by this function are quite standard, see any C
  156.         reference for details.
  157.  
  158.     INPUTS
  159.         File - A valid AmigaDOS output file handle, such as returned
  160.                by Open() or Output().
  161.  
  162.         "String" - pointer to a C-style format string.
  163.  
  164.         *args - Pointer to start of argument stream.
  165.  
  166.     RESULT
  167.         count - if all goes well, the total count of characters
  168.                 actually written will be returned.  If an error occured,
  169.                 this function will return -1.  If this function is
  170.                 passed a NULL output filehandle, this function will
  171.                 return zero.
  172.  
  173.     ADDITIONAL CONSIDERATIONS
  174.         If your compiler uses a default int size of 32 bits (i.e., Lattice),
  175.         you *must* specify %lx or %ld, for example, instead of %d
  176.         or %x, since the compilers will promote all ints to longs
  177.         before passing them to this function.
  178.  
  179.         Note also that this function very likely has a different idea
  180.         of stdout then the support libraries for your compiler.
  181.  
  182.     BUGS
  183.         None known.
  184.  
  185.     SEE ALSO
  186.         Printf, Puts, exec.library/RawDoFmt, C language reference on printf.
  187.  
  188.     AUTHOR: SDB
  189.     REVISED: cdh 26-sep-87 Use ArpBase not DosBase for call
  190. arp.doc/CreatePort (V31)
  191.  
  192.     NAME
  193.         CreatePort -- Create a message port.
  194.  
  195.     SYNOPSIS
  196.         msgport = CreatePort("Name", priority)
  197.           d0                    A0,     D0 (0:8)
  198.  
  199.     FUNCTION
  200.         Creates a message port with the given name and priority.  This
  201.         function is equivalent to that in amiga.lib, but is reentrant, and
  202.         may be called by assembly code.
  203.  
  204.      INPUTS
  205.         Name - pointer to a null terminated character string, or NULL.  If NULL,
  206.                this function will not attach the port to the system msgport
  207.                list (it will be private to the caller).
  208.  
  209.         priority -- the priority of this msgport (-128..127).
  210.  
  211.     RESULT
  212.         Pointer to an initialized message port, or NULL, if port could not
  213.         be allocated.  If Name was non-null, then the port will have been
  214.         added to the system's msgport list.
  215.  
  216.     BUGS
  217.         None known.
  218.  
  219.     SEE ALSO
  220.         DeletePort
  221.  
  222.     AUTHOR: SDB
  223.     REVISED:
  224.  
  225. arp.doc/DeletePort (V31)
  226.  
  227.     NAME
  228.         DeletePort -- Deletes a message port.
  229.  
  230.     SYNOPSIS
  231.         DeletePort(port)
  232.                     A1
  233.  
  234.     FUNCTION
  235.         Removes a message port.
  236.  
  237.     INPUTS
  238.         port - pointer to a message port - may be private or public.
  239.                port may also be NULL, in which case this function does nothing.
  240.  
  241.     RESULT
  242.         None.
  243.  
  244.     ADDITIONAL CONSIDERATIONS
  245.         Functionally equivalent to amiga.libs DeletePort, although the Amiga
  246.         version does some extra stuff which is not done here, largely
  247.         because it does not appear needed.
  248.  
  249.     BUGS
  250.         None known.
  251.  
  252.     SEE ALSO
  253.         CreatePort
  254.  
  255.     AUTHOR: SDB
  256.     REVISED:
  257. arp.doc/InitStdPacket (V31)
  258.  
  259.     NAME
  260.         InitStdPacket -- Initialize a standard packet structure.
  261.  
  262.     SYNOPSIS
  263.         InitStdPacket(Action, Args, Packet, replyport)
  264.                         D0      A0     A1       A2
  265.  
  266.     FUNCTION
  267.         This function performs the initialization required for a packet
  268.         before it is posted to AmigaDOS.
  269.  
  270.     INPUTS
  271.         PacketType -- The type (action) of packet you need.
  272.         Packet -- Address of the start of the standard packet you wish
  273.                   initialized. NOTE! - this is the start of the message
  274.                   portion of the packet, NOT the actual packet itself.
  275.  
  276.         ReplyPort -- The replyport for this packet.
  277.  
  278.         Args -- pointer to an array of 7 longwords representing the
  279.                 argument values you wish to send to AmigaDOS.  If this
  280.                 is NULL, the packet arguments will be cleared.
  281.  
  282.     RESULT
  283.         The StdPacket is initialized according to your requests.
  284.  
  285.     ADDITIONAL CONSIDERATIONS
  286.         Note that AmigaDOS destroys the value of the replyport in the
  287.         packet structure each time it is posted, therefore, you must
  288.         preserve a local copy of this pointer, and reinitialize it each time.
  289.  
  290.     BUGS
  291.         None known.
  292.  
  293.     SEE ALSO
  294.         SendPacket
  295.  
  296.     AUTHOR: SDB (Version 8)
  297.     REVISED:
  298. arp.doc/SendPacket (V31)
  299.  
  300.     NAME
  301.         SendPacket -- Send a packet to DOS.
  302.  
  303.     SYNOPSIS                         xxxxxx
  304.         Result1 = SendPacket( Action, Args, Handler, Result)
  305.            d0                    d0    a0      a1       a2
  306.                               xxxxxx
  307.     FUNCTION
  308.         Sends an AmigaDOS packet to a handler.  This function will Wait(),
  309.         if necessary, until the Handler returns the packet.  It cannot
  310.         therefore be used for asynchronous I/O.  This function uses the
  311.      processes message port, and it will call the pr_PktWait function
  312.      if this is installed.
  313.  
  314.     INPUTS
  315.         Action -- the action you wish this packet to cause.
  316.  
  317.         Args -- Pointer to an array of seven long words which specify the
  318.                 arguments to send with the packet.  This may be NULL, in which
  319.                 case the arguments will be set to zero.
  320.  
  321.         Handler -- The address of the msgport of the handler you wish to
  322.                    receive this packet.
  323.  
  324.         Result -- Pointer to an array of two long words in which the
  325.                   result1 and result2 of the returned packet will be
  326.                   placed.  This may be NULL.
  327.  
  328.  
  329.     RESULT
  330.      This function returns the result1 field of the returned packet.
  331.  
  332.     ADDITIONAL CONSIDERATIONS
  333.      Providing a higher level language environment for a user installed
  334.      PktWait function is an exercise left to those who require it.
  335.  
  336.      For use in assembly language, d0 will hold the result1 field,
  337.      and d1 will hold the result2 field.
  338.  
  339.     DIAGNOSTICS
  340.      See the return values for the packets which you post.  Note that
  341.      other processes (dos handler processes) are also using the process
  342.      message port.  If this function gets a packet other than the one it
  343.      posted, it will GURU out.
  344.  
  345.     BUGS
  346.         None known.
  347.  
  348.     SEE ALSO
  349.         InitStdPacket
  350.  
  351.     Author: SDB
  352.     Revised: V15.5 -- Uses process message port, which is vastly superior
  353.           to the way we were doing this originally.  In particular, this
  354.           allows us to return res1 and res2 instead of the former returns.
  355.           Many thanks to whawes for this suggestion. (SDB)
  356.     Revised: Result array arg removed
  357. arp.doc/EscapeString (V31)
  358.  
  359.     NAME
  360.         EscapeString -- convert escape characters in string.
  361.  
  362.     SYNOPSIS
  363.         NewLength = EscapeString( "String" )
  364.             D0                       A0
  365.  
  366.     FUNCTION
  367.         This function scans the string, replacing all escaped characters
  368.         with the correct byte value.  This function uses the value for ESCAPE
  369.         set in ESCChar in ArpBase, which is maintained elsewhere; this value
  370.      defaults to the BCPL '*' (RSN), or may be the normal '\'.
  371.  
  372.         This function currently recognizes the following special characters:
  373.  
  374.             N   - newline
  375.             T   - horizontal tab
  376.             V   - vertical tab
  377.             B   - backspace
  378.             R   - return
  379.             F   - formfeed
  380.             E   - escape (ascii 27 decimal)
  381.             Xnn - character representd by hex value nn.
  382.  
  383.         The above may be either upper or lower case.  If this function
  384.         finds an escaped character which is not one of the above, it will
  385.         return the character value (i.e. '\A' will be replaced by the single
  386.         character 'A'. The sequence '\\' is replaced by the single
  387.         character '\', and so on.)
  388.  
  389.         For sending hexcodes, the \x argument may be followed by either one
  390.         or two hex digits, in either upper or lower case.
  391.  
  392.     INPUTS
  393.         string - pointer to a null terminated ASCII string.
  394.  
  395.     RESULT
  396.         A new string, starting at the same memory location, but with the
  397.         escaped characters (if any) changed to their actual byte values.
  398.         This string will be null terminated.
  399.  
  400.         NewCount -- The new length of the string.
  401.  
  402.     ADDITIONAL NOTES:
  403.         For easy use in assembly language parsers, this function will
  404.         return with the A0 register unchanged.
  405.  
  406.     BUGS
  407.         Routine uses the region of memory pointed to by A0 as a work area,
  408.         so if you wish to retain a pristine copy of the string, copy it first.
  409.  
  410.  
  411.     SEE ALSO
  412.         GADS
  413.  
  414.     AUTHOR: SDB
  415.     REVISED: cdh 16-sep-87    Use ESCchar in ArpBase, rather than wild flags
  416. arp.doc/PathName (V31)
  417.  
  418.     NAME
  419.         PathName - Find complete pathname of file/directory.
  420.  
  421.     SYNOPSIS
  422.         Length = PathName(Lock, Destination, NumberNames)
  423.           D0               D0       A0          D1
  424.  
  425.     FUNCTION
  426.         This function builds a path name which completely describes the
  427.         path from the root of the filing system to the file on which the
  428.         Lock has been obtained.
  429.  
  430.         The name returned is of the form:
  431.  
  432.             Volume:Dir1/Dir2/Dir3/.../Name\x00
  433.  
  434.     INPUTS
  435.         Lock -- Thisis a lock on the file or directory obtained from Lock()
  436.                 or DupLock(), or some such function.
  437.  
  438.         Destination -- This is the area of memory to place the filename in.
  439.  
  440.         NumberNames -- This is the number of names that can be placed in
  441.                        the destination area.  You should reserve 31 bytes
  442.                        for each pathname component.  The minimum buffer
  443.                        size would be 32 bytes, which would allow room for
  444.                        one name.
  445.  
  446.     RESULT
  447.         The resulting pathname will be placed in Destination.
  448.  
  449.         If everything goes well, then you get the total length of the
  450.         pathname, in characters accumulated.  If there is a problem (either
  451.         the buffer is too small, or there was a disk error), you will get a
  452.         zero.
  453.  
  454.     BUGS
  455.         None known.
  456.  
  457.     SEE ALSO
  458.  
  459.     Author: SDB
  460.  
  461. arp.doc/ReadLine (V31)
  462.  
  463.     NAME
  464.         ReadLine -- Get a line from current input. (stdin)
  465.  
  466.     SYNOPSIS
  467.         Count = ReadLine("Address")
  468.        d0            A0
  469.  
  470.     FUNCTION
  471.        This function reads a line of up to MaxInputBuf characters from
  472.        stdin.  You must have a buffer available of this size, or you
  473.        run the risk of overwriting innocent memory.  MaxInputBuf is
  474.        defined in arpbase.[h|i].
  475.  
  476.        This function does no editing or echoing of the command line,
  477.        although it does guarantee the returned string is null terminated.
  478.  
  479.     INPUTS
  480.         Address - Pointer to a 256 byte buffer to store the input
  481.                   string in.
  482.  
  483.     RESULT
  484.         Count - The actual count of the characters returned.
  485.         Address will contain a null terminated string of Count characters.
  486.        
  487.     BUGS
  488.         None known - there may be problems using this function on other
  489.                      than a CON: window (i.e., a file, or RAW:), but
  490.                      nothing definite is known at this time.
  491.  
  492.     ADDITIONAL NOTES:
  493.         For the convenience of assembly language programs, A0 is guaranteed
  494.         to contain the same value on exit as it did on entry.
  495.  
  496.     SEE ALSO
  497.         GADS, EscapeString.
  498.  
  499.     Author: SDB
  500.     Revised: VERSION 8, removed SIZE argument, returns NULL if no input handle.
  501.  
  502. arp.doc/Atol (V31)
  503.  
  504.     NAME
  505.         Atol -- Ascii string to long int.
  506.  
  507.     SYNOPSIS
  508.         intval = Atol("string")
  509.           d0             a0
  510.  
  511.     FUNCTION
  512.         Convert "string" to a long integer.  This function will skip
  513.         leading whitespace.
  514.         This function returns an error if a non-whitespace non-digit
  515.         is encountered during processing.
  516.  
  517.     INPUTS
  518.         string - pointer ascii string, which may be null terminated
  519.                  or whitespace terminated.  The digits may have
  520.                  leading whitespace.
  521.  
  522.     RESULT
  523.         intval -- a long integer value.
  524.                   If an non-numeric is encountered during processing 
  525.                   other than surrounding whitespace or null
  526.                   terminators), this function will return with the Z
  527.                   flag SET, and the offending character value in d0.
  528.  
  529.                   If the Z flag is clear, then all characters
  530.                   encountered were either whitespace or digits.
  531.  
  532.     ADDITIONAL CONSIDERATIONS
  533.         This function is callable by higher level languages,
  534.         but the glue routine must take the responsibility
  535.         for detecting the error returns, and informing the
  536.         caller in a fashion appropriate to the language in use.
  537.  
  538.     BUGS
  539.         Values which cannot be represented as a 32bit integer will
  540.         not cause an error.
  541.  
  542.      Author: SDB
  543.  
  544. arp.doc/Puts (V31)
  545.  
  546.     NAME
  547.         Puts -- Print string with newline on stdout.
  548.  
  549.     SYNOPSIS
  550.         BOOL = Puts("string")
  551.          d0             a1
  552.  
  553.     FUNCTION
  554.         Writes a string to stdout, and then writes a terminating newline.
  555.         This is currently implemented as Printf("%s\n", string).
  556.  
  557.     INPUTS
  558.         string - pointer to ascii string. (null terminated)
  559.                  String may be null, in which case a newline only will
  560.                  be displayed.
  561.  
  562.     RESULT
  563.         See FPrintf page for more information - note that this
  564.         function always trys to write a newline.
  565.  
  566.     BUGS
  567.         None known.
  568.  
  569.     SEE ALSO
  570.         Printf, FPrintf.
  571.  
  572.     Author: SDB
  573.     Revised:  String is now in A1 to allow a more efficient implementation.
  574.               THIS IS INCOMPATIBLE WITH EARLIER VERSION OF THE LIBARARY.
  575.               SDB.
  576. arp.doc/GetDevInfo (V31)
  577.  
  578.     NAME
  579.      GetDevInfo -- traverse through DevInfo device list
  580.      Traverse through Devinfo list
  581.      Call with A2 = current position in Devinfo list (or NULL)
  582.      Returns D0 ( and A2 ) = next entry in Devinfo list (or head)
  583.      Also - side effect - ZERO FLAG IS SET ZERO if end of list
  584.         Puts -- Print string with newline on stdout.
  585.  
  586.     SYNOPSIS
  587.         devinfo = GetDevInfo( devinfo | NULL )
  588.          d0/A2                   A2
  589.  
  590.     FUNCTION
  591.      Traverse to next entry in DevInfo device list
  592.      If input is NULL, returns head of DevInfo
  593.      At end of list, returns NULL.
  594.      Side Effect - Zero Flag is NULL return status
  595.  
  596.     INPUTS
  597.         devinfo - pointer to current entry in devinfo list.
  598.          if NULL, get head of list
  599.  
  600.     RESULT
  601.      Next entry of devinfo list is in D0 and A2
  602.      If result is NULL, end of list (Zero flag is set)
  603.  
  604.     BUGS
  605.         None known.
  606.  
  607.     SEE ALSO
  608.         Assign
  609.  
  610.     Author: cdh
  611.     Revised:  20-sep-87 cdh Added traversal (originally only got head
  612.          of list ).
  613. arp.doc/Assign (V31)
  614.  
  615.     NAME
  616.         Assign -- Assigns a logical device name
  617.  
  618.     SYNOPSIS
  619.         Result = Assign("name:","physical")
  620.           D0              ao        a1
  621.  
  622.     FUNCTION
  623.         This function performs the guts of an AmigaDOS "assign"
  624.         function.  The arguments are similar to the arguments of the
  625.         ADOS program "Assign logicaldev: directory".
  626.  
  627.  
  628.     INPUTS
  629.         "name" -- Name to create a Devinfo assigned name for.
  630.  
  631.         "physical" -- Name of file or directory to get a Lock from.
  632.            NOTE - if physical is NULL, remove existing name.
  633.  
  634.     RESULT
  635.         A Devinfo entry is created for the requested name. Any prior
  636.         assignment for that name is removed.
  637.  
  638.         Result -- an error code return which may be one of:
  639.  
  640.             ASSIGN_OK       everything worked this time.
  641.             ASSIGN_NODEV    "physical" did not represent a valid directory.
  642.             ASSIGN_FATAL    Something is really rotten somewhere.
  643.             ASSIGN_CANCEL   Attempt to cancel something (like a
  644.                             volume) that can't be canceled.
  645.  
  646.     BUGS
  647.         None known.
  648.  
  649.  
  650.     Author: cdh    15-may-87
  651.     Revised: SDB Version 8.1, make A6=ArpBase for most ArpLib calls,
  652.             Various other minor changes.
  653.      20-sep-87 cdh Added null input calls "DeleteDevice"
  654. arp.doc/BtoCStr (V31)
  655.  
  656.     NAME
  657.         BtoCStr -- Copy a BSTR to a C null terminated string
  658.  
  659.     SYNOPSIS
  660.         Count = BtoCStr("CString", BSTR, MaxLength)
  661.           d0                A0      D0      D1
  662.  
  663.     FUNCTION
  664.         This function copies a BSTR into a null terminated string.
  665.         The BCPL string is passed as an unconverted icky BCPL ptr.
  666.  
  667.     INPUTS
  668.         CString - Pointer to a buffer area for the resulting string.
  669.  
  670.         BSTR - BPTR to the BSTR to convert.
  671.  
  672.         MaxLength - Maximum number of characters in buffer (not
  673.                     including NULL terminator).
  674.  
  675.     RESULT
  676.         Count -- Actual number of characters copied.
  677.         A0 has START of C string for assembly convenience.
  678.  
  679.     ADDITIONAL NOTES:
  680.         This function does NOT require A6 to be ArpBase.  This info
  681.         if for internal (library) use only!  Within the Arp library
  682.         you can bsr CtoBStr without setting A6 = ArpBase.
  683.      
  684.      Author: cdh  15-May-87
  685.      Revised:
  686. arp.doc/CtoBStr (V31)
  687.  
  688.     NAME
  689.         CtoBStr -- Copy a C null terminated string to a BSTR
  690.  
  691.     SYNOPSIS
  692.         Count = CtoBStr("CString", BSTR, MaxLength)
  693.           d0                A0      D0      D1
  694.  
  695.     FUNCTION
  696.         This function copies a null terminated string into a BCPL
  697.         string.  The BCPL string is passed as an unconverted icky
  698.         pointer.
  699.  
  700.     INPUTS
  701.         CString - pointer to the string to convert.
  702.  
  703.         BSTR - BPTR to the destination string.
  704.  
  705.         MaxLength -- Number of characters available in BSTR (not
  706.                      including initial count byte.)
  707.  
  708.     RESULT
  709.         Count -- actual number of characters transferred.
  710.         A0 and A1 are zapped.
  711.  
  712.     ADDITIONAL NOTES:
  713.         This function does NOT require A6 to be ArpBase.  This info
  714.         is for internal (library) use only!  Within the Arp library
  715.         you can bsr CtoBStr without setting A6 = ArpBase.
  716.      
  717.     Author: cdh  15-May-87
  718.     Revised:
  719. arp.doc/FindProcess (V31)
  720.  
  721.     NAME
  722.         FindProcess -- Find a process given a CLI task number.
  723.  
  724.     SYNOPSIS
  725.         Process = FindProcess(tasknum)
  726.            d0             d0
  727.  
  728.     FUNCTION
  729.         This function returns the pointer to the process structure
  730.         associated with tasknum.  This is a pointer to the start of
  731.         the process structure, usable with EXEC calls, and not the
  732.         process value returned by DOS calls.
  733.  
  734.     INPUTS
  735.         The CLI task number for the process, or special case ZERO,
  736.      which returns the total number of process slots.
  737.  
  738.      NOTE:  YOU MUST FORBID PRIOR TO CALLING THIS FUNCTION!
  739.  
  740.      This function only makes sense when you are Forbidden, as
  741.      otherwise the process may squirt away from you before you
  742.      can use the result!  Thus this function does NOT Forbid
  743.      around a critical section.  You have been warned!
  744.  
  745.     RESULT
  746.         Process -- a pointer to a Process structure, or NULL.  A NULL
  747.                    return indicates that there is no currently active
  748.                    process associated with that CLI task number.
  749.  
  750.          ( Except if tasknum was Zero )
  751.  
  752.     BUGS
  753.         None known.
  754.  
  755.     Author: SDB
  756.     Revised:
  757. arp.doc/CheckAbort (V31)
  758.  
  759.     NAME
  760.         CheckAbort -- Check for control C
  761.  
  762.     SYNOPSIS
  763.         BOOL = CheckAbort( *Func() )
  764.          d0                  A1
  765.  
  766.     FUNCTION
  767.         This function checks to see if the user issued a CNTRL-C abort
  768.         for this process (either keyboard, or from Break).  It can
  769.         one of three possible actions.
  770.  
  771.         If CNTRL-C occurred:
  772.  
  773.             If (*)(func)() is NULL, then the CNTRL-C system flag will
  774.             be returned.
  775.  
  776.             If (*)(func)() is NOT null, it will be called.  If it
  777.             returns, you will see the return code from your function.
  778.  
  779.             If CNTRL-C did not occur, you will get a ZERO return, and
  780.             (*)(func)() will not be called, even if non-null.
  781.  
  782.     INPUTS
  783.         *Func() -- an (optional) function to call if CNTRL-C occured.
  784.  
  785.     NOTE - if Func() is called, the and you "rts" from Func, you will
  786.     return to the caller of CheckAbort.
  787.  
  788.     RESULT
  789.         Zero if no CNTRL-C.
  790.         If *Func() is null, a NON-Zero function return will occurr.
  791.         If *Func() is not null, you will see this return value.
  792.  
  793.     BUGS
  794.     None known.
  795.  
  796.     Author: SDB
  797.     Revised:
  798. arp.doc/CheckBreak (V31)
  799.  
  800.     NAME
  801.         CheckBreak -- Check for control C/D/E/F
  802.  
  803.     SYNOPSIS
  804.         BOOL = CheckAbort( Mask(s), *Func() )
  805.          d0                  D1        A1
  806.  
  807.     FUNCTION
  808.         This function will check to see if the user issued a
  809.         CNTRL-C/E/D/F abort (from keyboard or Break program), and will
  810.         take one of three possible actions.
  811.  
  812.         If the BREAK occurred:
  813.  
  814.             If *Func() is null, then the Actual Mask will be returned.
  815.  
  816.             If *Func() is NOT null, it will be called, and you will
  817.             see the return code from that function.
  818.  
  819.             If a BREAK did not occur, you will get a ZERO (false)
  820.             return, and    *Func() will not be called, even if non-null.
  821.  
  822.     INPUTS
  823.         Mask(s) -- One (or more) of SIGBREAKF_CTRL_C/D/E/F masks.
  824.         *Func() -- an (optional) function to call if the BREAK occured.
  825.  
  826.     RESULT
  827.         Zero if no Break
  828.  
  829.         If *Func() is null, you will get the masks that caused
  830.         this break.
  831.  
  832.         If *Func() is not null, you will see your return value.
  833.  
  834.     ADDITIONAL:
  835.         For this function, we guarantee all registers preserved,
  836.         except for D0, which will hold the masks.
  837.  
  838.         For CheckAbort, all registers will be preserved, except
  839.         for D0/D1.
  840.  
  841.     BUGS
  842.         None known.
  843.  
  844.     Author: SDB
  845.     Revised: cdh V25 return ***BREAK string in A1, return is same level
  846.              as call (return address overwritten)
  847. arp.doc/GADS (V31)
  848.  
  849.     NAME
  850.         GADS -- Do standard AmigaDOS command line parsing.
  851.  
  852.     SYNOPSIS
  853.         Count = GADS( "line", len, "help"  args, "tplate");
  854.           d0            a0     d0    a1     a2       a3
  855.  
  856.     FUNCTION
  857.         This function performs the standard AmigaDOS style command
  858.         line parsing, using the standard AmigaDOS style templates. It
  859.         also handles interactive command lines for you.
  860.  
  861.         Interactive command lines occur under AmigaDOS when the user
  862.         types a command name followed by a '?' as the first argument.
  863.  
  864.         This program will also perform all the normal AmigaDOS
  865.         processing on the command line before the parse.  In
  866.         particular, this means handling any escape characters that are
  867.         found in the line.  The method used by AmigaDOS (and in this
  868.         function) is to escape quoted commands, but not unquoted
  869.         commands. Quotes will be stripped unless escaped.
  870.  
  871.         Note that ArpLib recognizes a more extensive escape vocabulary
  872.         than AmigDOS (see EscapeString).  Note also that one exception
  873.         to the above occurs when a function is passed a null 'tplate'
  874.         pointer. 
  875.  
  876.     GENERAL DISCUSSION
  877.         Programs calling this function present a very different
  878.         appearance to the calling program than is presented to the
  879.         user of the program.
  880.  
  881.         To the user, it appears as though they have a fair amount of
  882.         flexibility in the order in which they type their arguments.
  883.  
  884.         To the calling program, an argument which is specified as
  885.         first in the template will ALWAYS occupy that slot, if it
  886.         occurs in the users command line, no matter where in the
  887.         command line this argument occurs.  Here is an example:
  888.  
  889.  
  890.             FROM/A,TO,OPT/K,FOOBAR/S        ( template )
  891.               0     1   2      3            ( arg position)
  892.  
  893.         This is how it appears to both the user and the caller:
  894.  
  895.         USER OF PROGRAM TYPES:       PROGRAM SEES:
  896.         f1 f2                        |  arg[0] = f1, arg[1] = f2
  897.         f1 TO f2                     |  arg[0] = f1, arg[1] = f2
  898.         TO f2 FROM f1                |  arg[0] = f1, arg[1] = f2
  899.         OPT zip FOOBAR TO f2 FROM f1 |  arg[0] = f1, arg[1] = f2
  900.                                      |  arg[2] = zip arg[3] = TRUE
  901.  
  902.         If an argument is a string (\A \K or optional), then a pointer
  903.         to the string which is the value of that argument is placed
  904.         in the args array.  If the string is not found, then a NULL
  905.         will be placed in the array slot for that argument (although
  906.         this might cause an error under certain circumstances - see
  907.         below).
  908.  
  909.         If the argument is a SWITCH (\S) then -1L will be placed in
  910.         the args slot for that switch, or FALSE, if the switch was
  911.         not found on the command line.
  912.  
  913.         Note that this function DOES DO ERROR CHECKING on the
  914.         arguments. In particular, this means that if you specify a
  915.         template with a required argument (\A), you can count on it
  916.         being there, you do not have to check for it's existance, as
  917.         this function will return an error to you if it is not present.
  918.  
  919.         There are other conditions which can cause an error to be
  920.         returned, see below for more information.
  921.  
  922.     INPUTS
  923.         "cmdline" -- pointer to the command line, just as you get it
  924.                      from DOS.
  925.  
  926.         cmdlen -- length of command line, just as handed to you by
  927.                    DOS. 
  928.  
  929.         argarray -- Pointer to the start of an array of longwords
  930.                     which will receive the results of the argument
  931.                     parse. There must be as many longwords in this
  932.                     array as there are arguments in the template. 
  933.                     There must ALWAYS be at least one element in this array.
  934.  
  935.                     You may declare this in C as an array of:
  936.  
  937.                         union { char *string;   for optional, /a, /k.
  938.                                 long boolean;   for /s
  939.                         }
  940.  
  941.         "tplate" -- Pointer to an AmigaDOS style template.  This
  942.                     function assumes that the template is 'well
  943.                     formed', i.e., no spaces, tabs, etc., and that it
  944.                     null terminated.  Do NOT end your template
  945.                     with ':'.  It may contain mixed cases.
  946.  
  947.  
  948.         "xtra help" -- optional extra help string, which may be as
  949.                        long as you like, and include any type of
  950.                        characters you desire.  The user will see this
  951.                        string if they type a question mark after they
  952.                        have already entered interactive processing.
  953.  
  954.                        If you don't have any xtra help to supply, then
  955.                        this should be NULL, and this routine will use
  956.                        a default help string.
  957.     RESULT
  958.         COUNT -- The number of arguments found, or -1 if there is an
  959.                  error in the comand line.  This function is fairly
  960.                  demanding about command line syntax.  Here are some
  961.                  of the things that currently cause an error:
  962.  
  963.                     An opening quote without a closing quote. (Note
  964.                     that the inverse is ok: "OOPS is a mistake, but
  965.                     OOPS" is ok.  This is consistant with the behavior
  966.                     of AmigaDOS.)
  967.  
  968.                     An argument specified as required (\A) was not supplied.
  969.  
  970.                     Too many arguments were supplied.
  971.  
  972.                     An argument was supplied where a keyword was expected.
  973.  
  974.                     A Template word which required an argument (i.e.,
  975.                     anything except a \S element) was supplied, but no
  976.                     argument was found.
  977.  
  978.                     In interactive mode, no memory for input buffer.
  979.  
  980.         ArgArray -- If COUNT is nonzero, ArgArray contains the results
  981.                     of the parse.  The actual value of the arguments
  982.                     will be placed in the position of the ArgArray
  983.                     corresponding to their descriptor in the
  984.                     template.  If the user supplied a quoted string,
  985.                     the string will be scanned for escape characters,
  986.                     and the appropriate substitutions made.
  987.  
  988.                     If COUNT is ZERO, arg array will contain the same
  989.                     values as those it had at entry to this function. 
  990.                     This allows you to preinitialize the arg array.
  991.  
  992.                     If COUNT is -1, then ArgArray is in an unknown
  993.                     state.  The only option open to you at this point
  994.                     is to issue an error message and scram.
  995.  
  996.  
  997.     WARNING/ADDITIONAL CONSIDERATIONS
  998.         Note that the initial commandline pointer may not be valid
  999.         after a call to this function, due to the interactive command
  1000.         line feature.  Use only the argarray values.
  1001.  
  1002.     BUGS
  1003.         No error checking is performed on the actual syntax of the
  1004.         template.  This routine assumes you did it right.
  1005.  
  1006.         Could alter the original cmdline area, and will, except in
  1007.         the case of interactive input.
  1008.  
  1009.         Does not recoginze the ';' CLI comment character on interactive
  1010.         input.
  1011.  
  1012.     ADDITIONAL NOTES:
  1013.         If "template" is null (i.e., as might be used by Echo, for
  1014.         example), interactive command line processing will take
  1015.         place, and arg[0] will contain a pointer to the processed
  1016.         string.  Quotes will be stripped, if found (note that
  1017.         unmatched quotes will return an error.).  Currently, in the
  1018.         case of a NULL template, the single argument will be escaped
  1019.         whether it is quoted or not.  This should be ok, since only ECHO
  1020.         currently uses this facility.
  1021.  
  1022.      Author: SDB
  1023.     Revised: Version 16
  1024.      Bug fix:
  1025.          Templates with 'holes' such as arg1,arg2,,arg3
  1026.          are now correctly parsed.
  1027.      New Feature:
  1028.          If a command line error occurs which is detectable
  1029.          by this program, the first element of the argument
  1030.          array will contain a pointer to a null terminated
  1031.          string which may by Puts() to inform the user of
  1032.          an error.  Comments on the error messages are welcome.
  1033.          Please use this feature if you can, to avoid the
  1034.          "Bad Args for Glork" syndrome.
  1035.  
  1036.      Clarification:
  1037.          GADS() will only detect a missing \A argument if
  1038.          there is NOT a null command line.  So if you have
  1039.          a template with a \A argument, if the return from GADS
  1040.          is not 0 (NULL command line), then you can count on
  1041.          the \a argument being there.  A simple test:
  1042.              if (GADS() <= 0)
  1043.                  ERROR
  1044.          will suffice.
  1045.  
  1046.   Final Fixes (I hope):
  1047.      Use toupper for case change
  1048.      Will treat an unquoted ';' as EOL.
  1049. arp.doc/GetDataSegment (V31)
  1050.  
  1051.     NAME
  1052.         GetDataSegment -- Get a data segment + ptr for resident program.
  1053.  
  1054.     SYNOPSIS
  1055.         memBase = GetDataSegment(base, size)
  1056.            d0                     a0    d0
  1057.  
  1058.     FUNCTION
  1059.         This function provides a method where programs which
  1060.         ordinarily could not be made resident will work as resident
  1061.         code modules.
  1062.  
  1063.         Resident code modules have only one copy of the program text
  1064.         in memory at one time, no matter how many instances of that
  1065.         program may exist in the system.  Ordinarily, programs must be
  1066.         written in a special manner to allow this to occur.  However,
  1067.         this function should allow most programs to run as resident software.
  1068.  
  1069.         The only restriction on a program which intends to be resident
  1070.         is that it's data must reside in a single block of memory, no
  1071.         greater than 64k in size, and it must access it's data by
  1072.         offsets from a base register (which will point in the middle
  1073.         of this area, of course).
  1074.  
  1075.     INPUTS
  1076.         base -- pointer to the base of the programs data
  1077.         size -- size of data region in bytes.
  1078.  
  1079.     RESULT
  1080.         Memory will be allocated for the new data area, the original
  1081.         data will be copied to this location, and a pointer to the
  1082.         middle of this region will be returned.
  1083.  
  1084.     ADDTIONAL CONSIDERATIONS
  1085.         Many, but note that for Manx users, they will need special
  1086.         startup code, as well as a new version of geta4().   They
  1087.         should be extremely careful to link only with libraries that
  1088.         use the same code model.  Exiting should be done with care,
  1089.      since the data region is automatically deallocated when ArpLib
  1090.      is closed.
  1091.  
  1092.         Note also that any additional initialization of the data area
  1093.         must be carried out before this function is called.
  1094.  
  1095.     BUGS
  1096.         None known.
  1097.  
  1098.     Author: SDB (V11)
  1099.     Revision:  cdh v26 save bytes use CALLEXE
  1100. arp.doc/GetEnv (V31)
  1101.  
  1102.     NAME
  1103.         GetEnv -- Get the value of an environment variable
  1104.  
  1105.     SYNOPSIS
  1106.         strptr = Getenv("string", buffer, size)
  1107.           d0              A0        A1     d0
  1108.  
  1109.     FUNCTION
  1110.         This function provides an environment variable mechanism
  1111.         compatible with MANX.  Note that this call is more efficient
  1112.         than using the manx getenv() function call when arplibrary is
  1113.         installed.  
  1114.  
  1115.     INPUTS
  1116.         string -- pointer to an environment variable name.
  1117.         buffer -- a user allocated area which will be used to store
  1118.                   the value associated with the environment variable.
  1119.                   This may be NULL.
  1120.         size -- size of buffer region in bytes.
  1121.  
  1122.     RESULT
  1123.         If found, a pointer to the start of the value string for that
  1124.         variable will be returned.
  1125.  
  1126.         If buffer is non-null, then as much of the value string as
  1127.         allowed by size will be copied into the user buffer.
  1128.  
  1129.  
  1130.  
  1131.     ADDTIONAL CONSIDERATIONS
  1132.         MANX was the first to implement environment variables on the
  1133.         Amiga.  As a result, we are trying to be compatible with their
  1134.         implementation.  Note that this function is NOT equivalent to
  1135.         MANX getenv() call, but can easily be constructed using this
  1136.         this function.  Note also that all calls by MANX will be handled
  1137.         by arplibrary when it is installed.
  1138.  
  1139.         You would be wise to run as Forbidden all code which examines the
  1140.         environment space of the arp.library (for example, using the
  1141.         return value of this function).  As an example, the following code
  1142.         performs identically to the manx getenv() function:
  1143.  
  1144.             char getenv(variable)
  1145.                  char *variable;
  1146.                  {
  1147.                         char *temp;
  1148.                         static char *buffer;
  1149.  
  1150.                         free(buffer);   /* Free memory from last call */
  1151.                         Forbid();
  1152.                         temp = Getenv(name, 0L, 0L);
  1153.                         if (!temp)
  1154.                             Permit(), return(0);
  1155.                         buffer = malloc(strlen(temp));
  1156.                         strcpy(buffer, temp);
  1157.                         Permit();
  1158.                         return (buffer);
  1159.                    }
  1160.  
  1161.     BUGS
  1162.         If size is not large enough, the complete value of that
  1163.         environment variable will not be copied to the user buffer.
  1164.  
  1165.     Author: SDB (V12)
  1166.     Revision:
  1167. arp.doc/SetEnv (V31)
  1168.  
  1169.     NAME
  1170.         Setenv -- Set the value of an environment variable
  1171.  
  1172.     SYNOPSIS
  1173.          BOOL = Setenv("string", buffer)
  1174.           d0              A0        A1
  1175.  
  1176.     FUNCTION
  1177.         This function provides an environment variable mechanism
  1178.         compatible with MANX.  Note that this call is more efficient
  1179.         than using the manx setenv() function call when arplibrary is
  1180.         installed.
  1181.  
  1182.     INPUTS
  1183.         string -- pointer to an environment variable name.
  1184.         buffer -- a user allocated area which will contains the values
  1185.                   to be associated with this environment variabnle.
  1186.  
  1187.     RESULT
  1188.         If the value was succesfully established, a TRUE result will
  1189.         be returned, otherwise, a FALSE value will be returned.
  1190.  
  1191.  
  1192.     ADDTIONAL CONSIDERATIONS
  1193.         MANX was the first to implement environment variables on the
  1194.         Amiga.  As a result, we are trying to be compatible with their
  1195.         implementation.
  1196.  
  1197.     BUGS
  1198.         None known.
  1199.  
  1200.     Author: SDB (V12)
  1201.     Revision:
  1202. arp.doc/CompareLock (V31)
  1203.  
  1204.     NAME
  1205.         CompareLock -- Compares two filesystem Locks to see if they
  1206.              belong to the same object.
  1207.  
  1208.     SYNOPSIS
  1209.        Result = CompareLock( Lock1, Lock2 )
  1210.       D0/Z flag              D0     D1  
  1211.  
  1212.     FUNCTION
  1213.      This function may be used to determine if two file Locks obtained
  1214.      with the DOS Lock() function belong to the same file/object.
  1215.      Using this library call allows an application to avoid using
  1216.      private information; this call may be updated if/when a DOS
  1217.      Packet ACTION_COMPARE_LOCK is implemented.
  1218.  
  1219.     INPUTS
  1220.         D0 and D1 are Locks obtained with DOS Lock()
  1221.  
  1222.     RESULTS
  1223.      Return is in D0.  If D0 is:
  1224.  
  1225.          0 - Locks are identical
  1226.          1 - Locks are on same Volume
  1227.          2 - Locks are on different Volumes (dn_Task?)
  1228.          3 - Locks are on different Volumes
  1229.  
  1230.      Z-Flag reflects return status
  1231.  
  1232.     BUGS
  1233.      Caveat, this function now uses information that is considered
  1234.      "private" to each filehandler; thus, it is possible it will
  1235.      give an erroneous result if somebody implements a funny
  1236.      filehandler.
  1237.      This function was included primarily for the Rename program,
  1238.      to prevent Rename from creating directory loops that cause the
  1239.      directory to be lost in BCPL-space.
  1240.  
  1241.     SEE ALSO
  1242.         
  1243.     Author: cdh (V19)
  1244.     Revision:
  1245.  
  1246. arp.doc/PatternMatch (V31)
  1247.  
  1248.      NAME
  1249.         PatternMatch - perform a wildcard match on a string
  1250.  
  1251.      SYNOPSIS
  1252.         result = PatternMatch(pat,str)
  1253.           D0                 A0   A1
  1254.  
  1255.      FUNCTION
  1256.         This function compares a string to the given pattern and determines
  1257.            if it is a valid match.  If so it returns a true result.
  1258.            The pattern must be constructed with special preparsed tokens and
  1259.            supports the following patterns:
  1260.             (p1|p2|p3)  One of the patterns p1, p2 or p3
  1261.             ?           Any single character
  1262.             #<pat>      Pattern repeated 0 or more times
  1263.             [class]     Character class
  1264.             [^class]    Negated character class
  1265.             {pat}       Structure tag for replacement
  1266.             *           0 or more occurances of any character
  1267.  
  1268.      INPUTS
  1269.        char *pat     The pattern string to match against
  1270.           char *str     The string to be matched
  1271.  
  1272.      RESULT
  1273.        result - a boolean value indicating success/failure.  The condition
  1274.             codes are guarenteed to reflect the status of the result
  1275.      
  1276.      BUGS
  1277.        None known.
  1278.  
  1279.      SEE ALSO
  1280.  
  1281.      Author:    JAT
  1282. arp.doc/FindFirst (V31)
  1283.  
  1284.      NAME
  1285.         FindFirst -- Search for multilevel pattern match
  1286.  
  1287.      SYNOPSIS
  1288.         rc = FindFirst(pat, chain, info)
  1289.            d0              D0    A0     A1
  1290.                      xxxx ( Removed V22 )
  1291.      FUNCTION
  1292.            This function locates the first match for a pattern
  1293.  
  1294.      INPUTS
  1295.           char *pat - pattern to search for
  1296.           struct Anchor **chain  - pointer to file chain
  1297.           struct FileInfoBlock *info - pointer to file info buffer
  1298.  
  1299.      RESULT
  1300.        long rc - 0 for success, non-zero for any error
  1301.      
  1302.      BUGS
  1303.        None known.
  1304.  
  1305.      SEE ALSO
  1306.           FindNext(), MakeAnchor(), FreeAnchorChain()
  1307.  
  1308.      Author:    JAT
  1309.          cdh 02-Oct-87 Removed info calling arg - now it is in
  1310.              the anchor base.
  1311.  
  1312. arp.doc/FindNext (V31)
  1313.  
  1314.      NAME
  1315.         FindNext -- Locate next match for a file pattern
  1316.  
  1317.      SYNOPSIS
  1318.         rc = FindNext(chain)
  1319.            d0             A0
  1320.  
  1321.      FUNCTION
  1322.            This function locates the next match for a pattern
  1323.  
  1324.      INPUTS
  1325.        struct Anchor **chain  - pointer to file chain
  1326.  
  1327.      RESULT
  1328.        long rc - 0 for success, non-zero for any error
  1329.      
  1330.      BUGS
  1331.        None known.
  1332.  
  1333.      SEE ALSO
  1334.  
  1335.      Author:    JAT
  1336.          cdh 02-Oct-87 added break checks
  1337. arp.doc/FreeAnchorChain (V31)
  1338.  
  1339.      NAME
  1340.         FreeAnchorChain -- Free an allocated Anchor Chain
  1341.  
  1342.      SYNOPSIS
  1343.         FreeAnchorChain(chain)
  1344.                            A0
  1345.  
  1346.      FUNCTION
  1347.            This function frees an anchor chain allocated by FindFirst/FindNext
  1348.            It may be called multiple times without harm
  1349.  
  1350.      INPUTS
  1351.        struct Anchor **chain  - pointer to file chain
  1352.  
  1353.      BUGS
  1354.        None known.
  1355.  
  1356.      SEE ALSO
  1357.          FindFirst(), FindNext(), MakeAnchor()
  1358.  
  1359.      Author:    JAT
  1360. arp.doc/Strcmp (V31)
  1361.  
  1362.      NAME
  1363.          Strcmp -- Compare two strings, ignoring case.
  1364.  
  1365.      SYNOPSIS
  1366.          result = strcmp(s1, s2)
  1367.            d0        a0  a1
  1368.  
  1369.      FUNCTION
  1370.          returns <0 =0 or >0
  1371.  
  1372.      AUTHOR:
  1373.          sdb
  1374. arp.doc/Strncmp (V31)
  1375.  
  1376.      NAME
  1377.          Strncmp -- Compare two strings for n bytes, ignoring case.
  1378.  
  1379.      SYNOPSIS
  1380.          result = strcmp(s1, s2, n)
  1381.            d0        a0  a1    d0
  1382.  
  1383.      FUNCTION
  1384.          returns <0 =0 or >0
  1385.  
  1386.      AUTHOR:
  1387.          sdb
  1388. arp.doc/QSort (V31)
  1389.  
  1390.      FUNCTION
  1391.      QSort -- Quickly sort whatever you want.
  1392.  
  1393.      SYNOPSIS
  1394.      stkerr = QSort( baseptr, region_size, byte_size, user_function)
  1395.        d0          a0            d0           d1        a1
  1396.  
  1397.      FUNCTION
  1398.      QSort is an implementation of Hoares sorting algorithm.  It
  1399.      uses a constant amount of stack no matter what the size of the
  1400.      file.
  1401.  
  1402.      INPUTS
  1403.      baseptr    - pointer to the start of a memory region to be sorted
  1404.      region_size - size of region to be sorted, in number of elements (not bytes!)
  1405.      byte_size - size of sorted elements, in bytes.
  1406.      user_function - function to be provided by caller, which compares two
  1407.      elements from the set to be sorted.  QSort will call the user function
  1408.      like so:
  1409.  
  1410.          return = user_function(el1, el2)
  1411.          d0                  a0    a1
  1412.  
  1413.      Your function must return the following in D0:
  1414.  
  1415.          if (el1 < el2)    return < 0
  1416.          if (el1 > el2)    return > 0
  1417.          if (el1 == el2) return = 0
  1418.  
  1419.      You must save all registers except a0, a1, d0, d1.
  1420.      (See below for an example of a C calling sequence)
  1421.  
  1422.      QSort will also pass A5 to you unchanged.  You can use this register
  1423.      to point to pass information to your comparison routine.
  1424.  
  1425.     RETURNS
  1426.      -1 if everything is cool, 0 if there was an internal recursion
  1427.      stack overflow (not too likely).
  1428.  
  1429.     EXAMPLE:
  1430.      Here is an example of a calling sequence from C, which is to sort
  1431.      an array of pointers to strings:
  1432.  
  1433.      char    **names;
  1434.      long    numEls;
  1435.      extern    Cmp();
  1436.  
  1437.      if (QSort(names, numELs, 4L, Cmp))
  1438.          do whatever
  1439.      else
  1440.          STACK_ERROR
  1441.  
  1442.      the Cmp function would look like this:
  1443.  
  1444.      Cmp()
  1445.      {
  1446.          {
  1447.      #asm
  1448.          public    _geta4
  1449.          movem.l    d2-d3/a4/a6,-(sp)    ; save important registers
  1450.          movem.l    a0/a1,-(sp)        ; push args
  1451.          bsr    _geta4
  1452.          bsr    _cmp            ; call real compare function
  1453.          addq.l    #8,sp            ; clean up args
  1454.          movem.l    (sp)+,d2-d3/a4/a6    ; restore registers
  1455.      #endasm
  1456.          }
  1457.      }
  1458.  
  1459.      The cmp function called by the above is a normal C function, it can
  1460.      be whatever you like.  Here is a sample one:
  1461.  
  1462.      cmp(s1,s2)
  1463.      char **s1, **s2;
  1464.      {
  1465.          return strcmp(*a, *b);
  1466.      }
  1467.  
  1468.      BUGS
  1469.          None known.
  1470.  
  1471.      AUTHOR:    SDB    (V17)
  1472.      REVISED:
  1473.  
  1474. (sorry for the skimpy doc on the next few .. out of time! )
  1475.  
  1476.     NAME
  1477.     FileRequest -- Get filename from user
  1478.  
  1479.     SYNOPSIS
  1480.     retstr = FileRequest( filereqstruct )
  1481.       D0                A0
  1482.     
  1483.     FUNCTION
  1484.     Prompts the user for a filename.  See struct FR_struct in arpbase.i,
  1485.  
  1486.     NOTE
  1487.     V1.0 of Arp does not support the FR_Flags, FR_Wildfunc,
  1488.     or FR_MsgFunc entries in the struct, but you MUST allocate these
  1489.     and pass NULL values if you want to work with V1.1 of arplib!
  1490.  
  1491.  
  1492.     NAME
  1493.         CloseWindowSafely -- close a window without GURUing.
  1494.  
  1495.     SYNOPSIS
  1496.     CloseWindowSafely( window, morewindows )
  1497.                 A0,      A1
  1498.  
  1499.     FUNCTION
  1500.     Closes window after removing any messages pending for it in
  1501.     the window msgport, for use with a shared window.  Without
  1502.     this precaution, you will GURU when there is fast mouse
  1503.     activity (or multitasking).
  1504.  
  1505.     The second arguement is NON-ZERO if there is another window
  1506.     that still is sharing the msgport (ie, the msgport should
  1507.     remain unfreed).  If the second arguement is NULL, the
  1508.     msgport is freed as well.  Most often, the value morewindows
  1509.     will be an actual windowptr or NULL; the value doesn't really
  1510.     matter though, it is just a flag
  1511.  
  1512.  
  1513.     NAME
  1514.     AddDANode -- add a new entry to a DAList
  1515.  
  1516.     SYNOPSIS
  1517.     newnode = AddDANode( NewNode, *DaList, length, ID )
  1518.                   A0    A1      D0    D1
  1519.  
  1520.     FUNCTION
  1521.     Adds a node to a DAList.  The address of the DAList header
  1522.     is in A1; A0 points at the buffer that you want copied
  1523.     as a DANode.  If length is ZERO, NewNode is a null-terminated
  1524.     string; if length != 0, it is the length of the mem to
  1525.     copy.  ID is a sort key, which may be used by your program
  1526.     either for sorting or for classification; see AddDADevs
  1527.     and the bitdefs for how they are used for getting device
  1528.     names.
  1529.  
  1530.     SEE ALSO- FreeDAList
  1531.     
  1532.     NAME
  1533.     AddDADevs -- get a private list of devices/assignments/volumes
  1534.  
  1535.     SYNOPSIS
  1536.     numentries = AddDADevs( dalist, select )
  1537.                   A0,      D0
  1538.     FUNCTION
  1539.     Adds devices, volumes, and/or assigned names to a DAlist in
  1540.     a way that is both safe for multitasking, and easily accessible
  1541.     for C/assembler programs.
  1542.  
  1543.     See bitdefs in arpbase.i for selecting which devlist entries
  1544.     you want, and identifying what each entry is.  The returned
  1545.     list is sorted both by class, and then by alpha-numeric.
  1546.  
  1547.     SEE ALSO - FreeDAList
  1548.  
  1549.     
  1550.     NAME
  1551.     FreeDAList -- Free a DosAllocmem (DA) list
  1552.  
  1553.     SYNOPSIS
  1554.     FreeDAList ( dalist )
  1555.                A1
  1556.  
  1557.     FUNCTION
  1558.     Frees all DAList nodes from a DA list.  Each node is a singly
  1559.     linked DosAllocMem block, seach for "DA_" in arpbase.i.
  1560.  
  1561.     NOTE - The dalist arguement is the actual first item of the list,
  1562.     NOT a pointer to the list-head!
  1563.  
  1564.  
  1565.     NAME
  1566.     FindTaskResList -- find a pointer to current task's reslist
  1567.  
  1568.     SYNOPSIS  Finds the Resource List for this task, or NULL
  1569.     ResList = FindTaskResList()
  1570.       D0 (A1) ( Zero flag )
  1571.  
  1572.     FUNCTION
  1573.     This function searches for the most recently nested ResList
  1574.     for the current task, if any.  If there are no resource lists
  1575.     for this task, the return pointer points at NULL.
  1576.  
  1577.     NOTE - This implementation may change.  FindTaskResList is normally
  1578.     not needed as an external callout, as all task tracking is
  1579.     done automaticly without the application needing to know about
  1580.     this
  1581.  
  1582.     BUGS
  1583.     None known.  Will change to work with SyncRun
  1584.  
  1585. arp.doc/ArpExit (V31)
  1586.  
  1587.     NAME
  1588.         ArpExit -- exit immediately, closing arp, freeing resources.
  1589.  
  1590.     SYNOPSIS
  1591.         ArpExit( ReturnCode, (Fault) )
  1592.                     d0        d2
  1593.  
  1594.     FUNCTION
  1595.         This function will cause a currently running program to
  1596.         terminate.  It will first CloseLibrary(ArpBase), which will
  1597.         cause all tracked resources to be freed.  It will then force
  1598.         DOS to unload your program, returning the error code to the CLI.
  1599.  
  1600.     INPUTS
  1601.         ReturnCode -- The integer value you wish to return. By
  1602.                         convention, 0 means a normal exit.
  1603.      Fault -- If ReturnCode is non-zero, this value is the ADOS
  1604.              error code which is used with the "Why" program,
  1605.              in pr_Result2. ( If ReturnCode is ZERO, pr_Result2
  1606.              will be set to 0).
  1607.  
  1608.     RESULT
  1609.         No results, in fact, no return.
  1610.  
  1611.     BUGS
  1612.         None known.
  1613.  
  1614.     Author: SDB
  1615.     Revised: cdh 16-sep-87 Add pr_Result2 fault value in D2
  1616.           cdh 28-sep-87 Frees ResLists before CloseLibrary,
  1617.              because CloseLibrary Forbids first - nasty
  1618.              for system performance.
  1619.           cdh 29-sep-87 Use pr_ReturnAddr rather than DOS Exit(). Hah.
  1620.  
  1621. arp.doc/CreateTaskResList (V31)
  1622.  
  1623.     NAME
  1624.     CreateTaskResList -- Create a new nested ResList for this task
  1625.  
  1626.     SYNOPSIS
  1627.     ResList = CreateTaskResList()
  1628.       D0 / Z Flag
  1629.  
  1630.     FUNCTION
  1631.     Create a new Resource list for this task, and insert it at the
  1632.     HEAD of the ResourceArray list.
  1633.  
  1634.     You do not normally need to use CreateTaskResList, because the
  1635.     functions which insert tracked items into the task reslist
  1636.     will automaticly create a reslist if one did not exist before.
  1637.  
  1638.     This function may be used to explictly create a nested ResList
  1639.     for this task; all resources allocated after CreateTaskReslist
  1640.     will be stored in the new ResList until you call FreeTaskResList.
  1641.     This would allow you, for instance, to call CreateTaskResList at
  1642.     the start of a function, and FreeTaskResList at the end of the
  1643.     function, and any resources tracked in the interum would be
  1644.     freed; but all other tracked resources for the task would
  1645.     remain tracked.
  1646.  
  1647.     All Task reslists will also be automaticly freed when you call
  1648.  
  1649.     BUGS
  1650.     None known.  Current implementation will change slightly when
  1651.     SyncRun is added to arp.library
  1652.  
  1653.     Author - cdh V18
  1654.  
  1655. arp.doc/ArpAllocMem (V31)
  1656.  
  1657.     NAME
  1658.         ArpAllocMem -- Allocate and track memory.
  1659.  
  1660.     SYNOPSIS
  1661.         MemPtr = ArpAlloc( size, reqs )
  1662.           d0 (a1)        D0 / D1
  1663.  
  1664.     FUNCTION
  1665.  
  1666.         This function is identical to the Exec AllocMem call, but will
  1667.         track memory resources for you.
  1668.  
  1669.         When you CloseLibrary(ArpBase), any memory allocated with this
  1670.         function will be freed, which provides a simpler means of
  1671.         termination than is ordinarily found.
  1672.  
  1673.         You may make multiple calls to this routine -- all memory
  1674.         resources will be tracked.  Note also that this function
  1675.         requires you to specify the type of memory, so that you may
  1676.         also allocate and track CHIP memory using this function.
  1677.  
  1678.     INPUTS
  1679.         Same args as Exec AllocMem request, size / reqs
  1680.  
  1681.     RESULT
  1682.         MemPtr -- pointer to the memory requested, same as Exec AllocMem
  1683.            return.  If this is NON-ZERO, the memory allocation
  1684.            succeeded.
  1685.      Tracker -- same as all the tracking calls, register A1 contains
  1686.            the pointer to the TRACKER.  See ArpAlloc, GetTracker,
  1687.            CreateTaskReslist,FreeTaskReslist.
  1688.  
  1689.     WARNING
  1690.      Do NOT call FreeMem to free the memory from this allocation!
  1691.      If you want to free this allocation before terminating the task,
  1692.      or before calling FreeTaskReslist, you MUST use the TRACKER pointer
  1693.      and use FreeTrackedItem.
  1694.  
  1695.         If you want to manage your own memory, use the exec calls directly.
  1696.  
  1697.     BUGS
  1698.         None known.
  1699.  
  1700.     SEE ALSO
  1701.         ArpAlloc(),  GetTracker(), FreeTaskResList()
  1702.  
  1703.     AUTHOR: SDB (V8.4)
  1704.     Revised:    cdh V23 converted to AllocMem rather than AllocEntry
  1705.  
  1706. arp.doc/ArpOpen (V31)
  1707.  
  1708.     NAME
  1709.         ArpOpen -- Open a file and track it.
  1710.  
  1711.     SYNOPSIS
  1712.         FileHandle = ArpOpen("name", accessmode)
  1713.             d0                 d1        d2
  1714.  
  1715.     FUNCTION
  1716.         This function is equivalent to the AmigaDOS Open(), except
  1717.         that this function will remember that the file is open when
  1718.         you do a CloseLibrary(ArpBase) and close it for you.
  1719.  
  1720.         This is part of the Resource tracking of ArpLib, which also
  1721.         tracks memory allocations and Locks.
  1722.  
  1723.     INPUTS
  1724.         name - pointer to a null terminated string.
  1725.  
  1726.         accessmode -- pointer to a valid AmigaDOS access mode.
  1727.  
  1728.     RESULT
  1729.         A BPTR to a filehandle, or NULL, if an error occurred.
  1730.  
  1731.     BUGS
  1732.         None known.
  1733.  
  1734.     SEE ALSO
  1735.         ArpAllocEntry(), ArpAlloc(), ArpLock(), FreeTaskResList().
  1736.         dos.doc/Open
  1737.  
  1738.     AUTHOR:  SDB (V9.0)
  1739.     Revised:
  1740. arp.doc/ArpDupLock (V31)
  1741.  
  1742.     NAME
  1743.         ArpDupLock -- Duplicate a lock and track it.
  1744.  
  1745.     SYNOPSIS
  1746.         Lock = ArpDupLock( lock )
  1747.          d0                 d1
  1748.  
  1749.     FUNCTION
  1750.         This function is completely equivalent to the AmigaDOS DupLock(),
  1751.         except that ArpLib will remember that you have duped this lock,
  1752.         and will UnLock() for you when you CloseLibrary(ArpBase).
  1753.  
  1754.     INPUTS
  1755.         lock -- pointer to a lock
  1756.  
  1757.     RESULTS
  1758.         A lock or NULL, if no lock.
  1759.  
  1760.     BUGS
  1761.         None known.
  1762.  
  1763.     SEE ALSO
  1764.         DOS DOCUMENTATION, FreeTaskResList, ArpAlloc(), ArpAllocEntry(),
  1765.         ArpClose().
  1766. arp.doc/ArpLock (V31)
  1767.  
  1768.     NAME
  1769.         ArpLock -- Get a lock and track it.
  1770.  
  1771.     SYNOPSIS
  1772.         Lock = ArpLock("name", accessmode)
  1773.          d0              d1       d2
  1774.  
  1775.     FUNCTION
  1776.         This function is completely equivalent to the AmigaDOS Lock(),
  1777.         except that ArpLib will remember that you have opened this lock,
  1778.         and will UnLock() for you when you CloseLibrary(ArpBase).
  1779.  
  1780.     INPUTS
  1781.         name -- pointer to a null terminated string
  1782.  
  1783.         accessmode -- a valid AmigaDOS access value.
  1784.  
  1785.     RESULTS
  1786.         A lock or NULL, if no lock.
  1787.  
  1788.     BUGS
  1789.         None known.
  1790.  
  1791.     SEE ALSO
  1792.         DOS DOCUMENTATION, FreeTaskResList, ArpAlloc(), ArpAllocEntry(),
  1793.         ArpClose().
  1794. arp.doc/GetTracker (V31)
  1795.  
  1796.     NAME
  1797.      GetTracker -- Get a tracking node for resource tracking.
  1798.  
  1799.     SYNOPSIS
  1800.      Tracker = GetTracker()        /* PRESERVES D0/D1/A0 */
  1801.        A1
  1802.  
  1803.      FUNCTION
  1804.      This call creates a tracking node which you may use to track
  1805.      whatever type of resource you want tracked.  If you leave
  1806.      the TRU_ID field null, this tracker is just considered as a
  1807.      memory node, and properly freed.  In fact, you can use
  1808.      ArpAlloc to and build your own tracking node; all nodes have
  1809.      the same basic structure, with the default being a simple
  1810.      memory allocation.
  1811.  
  1812.      This call preserves registers D0/D1/A0, unless the request
  1813.      fails in which case D0 is set to 0 for your convenience,
  1814.      as a NULL result.  On sucess, register A1 is a pointer to
  1815.      the tracking node, and the Z flag is set NOT-ZERO.
  1816.  
  1817.      Normally for C language use, the details of tracking will be
  1818.      hidden in a binding routine designed for the particular thing
  1819.      you want to track.
  1820.  
  1821.      Normally you should call this function prior to allocating
  1822.      the resource you want to track, see the library functions like
  1823.      ArpLock for an example of how to use this function efficiently.
  1824.  
  1825.      The worst case as to what will happen if you use GetTracker
  1826.      and then fall off the end of the world, is that the tracking node
  1827.      will be treated as a ArpAlloc memory item, which will be freed
  1828.       by FreeTaskResList or by a cleanup routine at some later time.
  1829.  
  1830.     SEE ALSO
  1831.         ArpAlloc, FreeTaskResList, ArpOpen, ArpUnLock, ArpDupLock.
  1832.  
  1833.     Author: cdh
  1834.  
  1835. arp.doc/ArpAlloc (V31)
  1836.  
  1837.     NAME
  1838.         ArpAlloc -- Allocate memory and track.
  1839.  
  1840.     SYNOPSIS
  1841.         Memory = ArpAlloc( size_in_bytes )
  1842.           d0                    d0
  1843.  
  1844.     FUNCTION
  1845.         This function provides a simple memory allocation/tracking
  1846.         mechanism. You can allocate memory with this function and,
  1847.         when you CloseLibrary(ArpBase) or ArpExit(code), the memory
  1848.         will be automatically freed for you.  You can make multiple
  1849.         calls to ArpAlloc(), each allocation will be tracked.
  1850.  
  1851.     INPUTS
  1852.         size_in_bytes - Amount of memory required.
  1853.  
  1854.     RESULT
  1855.         Pointer to a memory block with attributes (MEMF_PUBLIC | MEMF_CLEAR),
  1856.         or zero, if an error occurred.
  1857.  
  1858.     WARNINGS/ADDITIONAL CONSIDERATIONS
  1859.         REMEMBER: You must call CloseLibrary(ArpBase) for the resource
  1860.         freeing to occur.
  1861.  
  1862.  
  1863.  
  1864.     SEE ALSO
  1865.         ArpAllocEntry, FreeTaskResList, ArpOpen, ArpUnLock, ArpDupLock.
  1866.  
  1867.     Author: SDB
  1868.     Revised: Use ArpAllocEntry (version 8)
  1869. arp.doc/FreeTaskResList (V31)
  1870.  
  1871.     NAME
  1872.         FreeTaskResList -- Free tracked resources for this task
  1873.  
  1874.     SYNOPSIS
  1875.         BOOL = FreeTaskResList()
  1876.          d0
  1877.  
  1878.     FUNCTION
  1879.         This function frees ALL resources tracked by arplibs resource
  1880.         tracking mechanism.  This includes memory as well as open
  1881.         files and locks.  Ordinarily, you will call this function
  1882.         indirectly by CloseLibrary(ArpBase) or ArpExit().  This
  1883.         mechanism allows easier exits (whether normal or abnormal)
  1884.         than is usually found.
  1885.  
  1886.  
  1887.     INPUTS
  1888.         NONE
  1889.  
  1890.     RESULT
  1891.         TRUE if resource deallocation occurred, otherwise FALSE.
  1892.  
  1893.     ADDITIONAL
  1894.         The tracking scheme has been radically changed from eariler
  1895.         versions of arplib, but this should not break any programs.
  1896.  
  1897.     BUGS
  1898.         None known.
  1899.  
  1900.     Author: SDB
  1901.     Revised: Track more stuff (SDB V9).
  1902.  
  1903. arp.doc/FreeTrackedItem (V31)
  1904.  
  1905.     NAME
  1906.     FreeTrackedItem -- Free a tracked item from a ResList
  1907.  
  1908.     SYNOPSIS
  1909.     FreeTrackedItem( ItemPtr )
  1910.                A1
  1911.  
  1912.     FUNCTION
  1913.     Frees an individual tracked resource.  You need the address of
  1914.     the tracking node (which is returned by ArpAlloc or GetTracker,
  1915.     or for functions ArpLock/ArpOpen/ArpDupLock, in register A1 as
  1916.     the secondary result after the primary value in D0 )
  1917.  
  1918.     The resource is removed from the tasks tracking list, automajikly.
  1919.  
  1920.     BUGS
  1921.     None known.
  1922.  
  1923.     Author: CDH V18
  1924. arp.doc/GetAccess (V31)
  1925.  
  1926.     NAME
  1927.         GetAccess -- Locks access to a tracked resource.
  1928.  
  1929.     SYNOPSIS
  1930.      Pointer = GetAccess( tracker )
  1931.        d0               A1
  1932.  
  1933.     FUNCTION
  1934.      This function is used in conjunction with FreeAccess() for
  1935.      tracked items. If you call FreeAccess, a tracked item may
  1936.      be freed by the OS during memory crunch.  GetAccess is used
  1937.      to try to reclaim the object for continued use.
  1938.  
  1939.      When you call GetAccess, if the item has not been flushed, the
  1940.      return value in D0 is the tracked item pointer (not the tracker),
  1941.      and the item is locked so the system will not attempt to flush
  1942.      it on you again.
  1943.  
  1944.      If the system has FREED the tracked item, the return value from
  1945.      the GetAccess call will be ZERO.  In this case, it is best for
  1946.      you to then call FreeTrackedItem on the tracker node, to free
  1947.      the tracking link.  Otherwise the link may cause fragmentation
  1948.      until your task terminates or until you FreeTaskReslist.
  1949.  
  1950.      BUGS
  1951.      None Known.
  1952.  
  1953.      AUTHOR: CDH V18
  1954.  
  1955. arp.doc/FreeAccess (V31)
  1956.  
  1957.     NAME
  1958.      FreeAccess -- Decrements use count for a tracked item.
  1959.  
  1960.     SYNOPSIS
  1961.      FreeAccess( Tracker )
  1962.                A1
  1963.  
  1964.      FUNCTION
  1965.      Decrements the user count on a tracked item.  If the user count
  1966.      goes to (-1), the item may be freed during a memory crunch.  To
  1967.      find out if the item was freed, use GetAccess, which will return
  1968.      NULL if the item is gone, or the value if it was not freed.
  1969.  
  1970.      This maintains private values in the tracking node. If you
  1971.      directly access this information, your program will probably
  1972.      not work in future releases of ArpLibrary.
  1973.  
  1974.      BUGS:
  1975.      None Known.
  1976.  
  1977.      AUTHOR
  1978.      CDH V18
  1979.  
  1980.