home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 534.lha / vmalloc_v1.2 / libs / track.doc.pp / track.doc
Encoding:
Text File  |  1991-08-08  |  58.9 KB  |  2,424 lines

  1.  
  2.  
  3. TABLE OF CONTENTS
  4.  
  5. track.library/AbsChk
  6. track.library/AbsChkWord
  7. track.library/AddProcess
  8. track.library/Atol
  9. track.library/CheckPacket
  10. track.library/ChkBound
  11. track.library/ChkRange
  12. track.library/CreateExtIO
  13. track.library/CreatePacket
  14. track.library/CreatePort
  15. track.library/DeleteExtIO
  16. track.library/DeletePacket
  17. track.library/DeletePort
  18. track.library/DoPacket
  19. track.library/ExceptCall
  20. track.library/ExceptCode
  21. track.library/ExceptEnter
  22. track.library/ExceptInit
  23. track.library/ExceptLeave
  24. track.library/ExceptRaise
  25. track.library/FPrintf
  26. track.library/FreeTrackedItem
  27. track.library/FreeTrackList
  28. track.library/GetTrap
  29. track.library/LongJmp
  30. track.library/MakeBStr
  31. track.library/MemAlloc
  32. track.library/MemFree
  33. track.library/NewList
  34. track.library/OnSignal
  35. track.library/Printf
  36. track.library/Reads
  37. track.library/RemoveProcess
  38. track.library/SendPacket
  39. track.library/SetJmp
  40. track.library/SetTrap
  41. track.library/SPrintf
  42. track.library/Strcat
  43. track.library/Strchr
  44. track.library/TCreateExtIO
  45. track.library/TCreatePacket
  46. track.library/TCreatePort
  47. track.library/TLock
  48. track.library/TMemAlloc
  49. track.library/TOpen
  50. track.library/TOpenDevice
  51. track.library/TOpenLibrary
  52. track.library/TOpenScreen
  53. track.library/TOpenWindow
  54. track.library/TrackItem
  55. track.library/TrapMsg
  56. track.library/TSetDMRequest
  57. track.library/TSetMenuStrip
  58. track.library/WaitPacket
  59.  
  60.  
  61. track.library/AbsChk                           track.library/AbsChk
  62.  
  63.    NAME
  64.         AbsChk -- Compare a 32bit value against an absolute maximum.
  65.  
  66.    SYNOPSIS
  67.         AbsChk( var, max )
  68.                 D0   D1
  69.  
  70.         long int var ;
  71.     long int max ;
  72.  
  73.    FUNCTION
  74.         Compares a 32bit value such as a pointer, against a maximum possible
  75.     value. If the value is less than or equal to the maximum, this
  76.     function returns. Otherwise an exception EX_CHK is generated.
  77.  
  78.    INPUTS
  79.         var should be an unsigned 32bit quantity. I don't think it will
  80.         handle signed comparisons properly, if at all.
  81.  
  82.         max should again be an unsigned 32bit quantity.
  83.  
  84.    RESULTS
  85.         It either returns or it doesn't. Excellent for applications where
  86.     if the value is out of range, then the logic is broken. Better to
  87.     cause an exception than possibly bring the machine down.
  88.  
  89.    NOTES
  90.         This was designed to be used while the trap handling is enabled,
  91.     to enable you to capture the exception. If the trap handling is
  92.     not enabled, you will get a 'SOFTWARE FAILURE - Task Help' 
  93.     requester.
  94.  
  95.    SEE ALSO
  96.         libraries/track.h (for EX_CHK),  SetTrap(), AbsChkWord()
  97.  
  98.    BUGS
  99.        none known.
  100.  
  101.  
  102. track.library/AbsChkWord                   track.library/AbsChkWord
  103.  
  104.    NAME
  105.     AbsChkWord -- Compare a 16bit value against an absolute maximum.
  106.  
  107.    SYNOPSIS
  108.         AbsChkWord( var, max )
  109.                     D0   D1
  110.  
  111.         short int var ;
  112.         short int max ;
  113.  
  114.    FUNCTION
  115.         Compares a 16bit value such as a short int, against a maximum
  116.     possible value. If the value is less than or equal to the maximum,
  117.     this function returns. Otherwise an exception EX_CHK is generated.
  118.  
  119.    INPUTS
  120.         var should be an unsigned 16bit quantity. I don't think it will
  121.         handle signed comparisons properly, if at all.
  122.  
  123.         max should again be an unsigned 16bit quantity.
  124.  
  125.    RESULTS
  126.         It either returns or it doesn't. Excellent for applications where
  127.     if the value is out of range, then the logic is broken. Better to
  128.     cause an exception than possibly bring the machine down.
  129.  
  130.    NOTES
  131.         This is an entrypoint *WITHIN* AbsChk() that shortcuts the high
  132.     word comparison. Hence, if the inputs are 32bits, only the lower
  133.     words make any difference.
  134.  
  135.    SEE ALSO
  136.     AbsChk()
  137.  
  138.    BUGS
  139.        none known.
  140.  
  141.  
  142. track.library/AddProcess                   track.library/AddProcess  
  143.  
  144.    NAME
  145.     AddProcess -- Setup a process node for the current process
  146.  
  147.    SYNOPSIS
  148.         ProcessList = AddProcess()
  149.         D0
  150.  
  151.        struct ProcessList *ProcessList ;
  152.  
  153.    FUNCTION
  154.         This allocates an area of memory using AllocMem(), sets it up for
  155.     the current task/process, and links it to an internal list.
  156.  
  157.    INPUTS
  158.  
  159.    RESULTS
  160.        A pointer to the process node is returned, or NULL if memory was not
  161.     available.
  162.  
  163.     EG.
  164.        struct ProcessList *pl = AddProcess() ;
  165.        .
  166.        . During this space, the SetTrap(), Exception handling functions
  167.        . and the Resource Tracking functions are valid.
  168.        .
  169.        RemoveProcess() ;
  170.  
  171.    NOTES
  172.     This should never need to be called since it is already called for
  173.     each process when the library is opened. Note that RemoveProcess()
  174.     will reset the Trap/Exception handler, free *ALL* tracked items
  175.     (and is called automatically when you close the library). One use
  176.     for these is if you CreateProc() a process, and wish the process
  177.     to use the libraries tracking/excepion handling functions.
  178.  
  179.     EG
  180.        Global TrackBase ;
  181.  
  182.        blah = CreateProc(...) ;
  183.        if (blah) {
  184.           .
  185.           . Just sort of do things...
  186.           .
  187.           }
  188.  
  189.        -- Proc --
  190.        AddProcess() ; /* This process how has Resource tracking etc */
  191.        .
  192.        . Things to be done.
  193.        .
  194.        RemoveProcess(); /* Free all tracked items, and reset handlers */
  195.  
  196.     Note the lack of parameters. The process node is identified by the
  197.     unique number returned by FindTask(0).
  198.  
  199.    SEE ALSO
  200.     RemoveProcess(), AllocMem()
  201.  
  202.    BUGS
  203.     The return value IS NOT THE PROCESS LIST POINTER as documented.
  204.     The function works fine, but the return value is gibberish.
  205.     (not that it is needed right? It is a private structure anyway.)
  206.  
  207.  
  208. track.library/Atol                               track.library/Atol  
  209.  
  210.    NAME
  211.     Atol -- Convert an ASCII string to a 32bit long int. (unsigned)
  212.  
  213.    SYNOPSIS
  214.         result = Atol( str )
  215.     D0           A0
  216.  
  217.        char *str ;
  218.  
  219.    FUNCTION
  220.     The string 'str' is scanned to skip spaces, then converted to a
  221.     32bit unsigned long. Note that leading signs are not accepted nor
  222.         processed. Conversion stops immediately a non-numeric character
  223.     is located.
  224.  
  225.    INPUTS
  226.        str    A pointer to a terminated string. Spaces at the beginning
  227.         of the string are automatically skipped.
  228.  
  229.    RESULTS
  230.        result    A 32bit unsigned long. Note that a value of zero can be
  231.         either a numeric zero, or that no numeric characters were
  232.         found.
  233.  
  234.    NOTES
  235.        Since only one return code is generally accepted when using 'C', it
  236.     is difficult to gain access to A0 *after* the call to Atol().
  237.     If you can, via lattice's getreg() for example, then A0 contains a
  238.     pointer to the string *AFTER* the number.
  239.  
  240.    SEE ALSO
  241.        getreg(), atol()
  242.  
  243.    BUGS
  244.     A0 is ALWAYS advanced by a minimum of one character. If no
  245.     numeric input is found, it should not be advanced.
  246.     (but that isn't a real problem is it..)
  247.  
  248.  
  249. track.library/CheckPacket                 track.library/CheckPacket  
  250.  
  251.    NAME
  252.     CheckPacket -- Check to see if a DOS packet submitted with
  253.                SendPacket() has been finished with.
  254.  
  255.    SYNOPSIS
  256.         result = CheckPacket( packet )
  257.     D0                    A1
  258.  
  259.        struct StandardPacket *packet ;
  260.        struct StandardPacket *result ;
  261.  
  262.    FUNCTION
  263.     Check the packets' reply port message list to see if this packet is
  264.     in its reply queue. This only works if the packet has been
  265.     initialised such that :
  266.  
  267.     packet->sp_Msg.mn_ReplyPort = packet->sp_Pkt.dp_Reply
  268.  
  269.     This is done automatically by the function CreatePacket()
  270.  
  271.    INPUTS
  272.      packet    A pointer to a DOS StandardPacket structure.
  273.  
  274.    RESULTS
  275.        result    A pointer to the returned packet. By all coincidence, this
  276.         is the same as the pointer you gave it. UNLESS the packet
  277.         was not finished with, in which case NULL is returned.
  278.  
  279.    NOTES
  280.        The packet should be created with 'CreatePacket()'. You may then
  281.     fill in the dp_Arg's and Action's and Type's, then submit the packet
  282.     do DOS using the 'SendPacket()' call.
  283.  
  284.     IMPORTANT. DOS is *documented* to corrupt dp_Reply in the DOS packet.
  285.            That does not mean it *WILL* change it, just that it is
  286.            allowed to. To overcome this, the contents of dp_Reply
  287.            is duplicated into mn_ReplyPort in the exec message 
  288.            section of the StandardPacket.
  289.  
  290.            The CheckPacket() and WaitPacket() rely on the
  291.            mn_ReplyPort, and SendPacket() sets the dp_Reply to
  292.            the contents of mn_ReplyPort before submitting the
  293.            packet to DOS. As long as mn_ReplyPort is not modified,
  294.            this clearly solves one of the more annoying aspects
  295.            of dealing with DOS packets. (Not BCPL though!!)
  296.  
  297.                CheckPacket() does only that, *CHECK*. You must call
  298.            WaitPacket() to actually remove the packet from the 
  299.            reply Queue, or if you want to, do the following.
  300.  
  301.            if (CheckPacket(packet))
  302.               Remove(packet) ;
  303.  
  304.            Since WaitPacket() will actually call CheckPacket() again
  305.            to check if the packet is finished with.
  306.  
  307.     To find the packet, it scan's the ReplyPort list for the Message.
  308.     This can be inefficient if called in a busy/wait loop. Hence it
  309.     is best to check if a *new* message was received in the reply queue
  310.     (with, SetSignal()) before calling CheckPacket() again. However,
  311.     since generally only one packet will ever exists on the reply
  312.     queue, a :
  313.  
  314.     packet = GetMsg(packet->sp_Msg.mn_ReplyPort) ;
  315.  
  316.     will generally give the same result more efficiently. IE, returns
  317.     NULL if the reply is not yet available.
  318.  
  319.     However, if *MANY* DOS packets are outstanding on a particular port,
  320.     CheckPacket() can be used to check for a particular DOS packet.
  321.  
  322.    SEE ALSO
  323.     SendPacket(), WaitPacket(), DoPacket(), CreatePacket(),
  324.     DeletePacket(), SetSignal()
  325.  
  326.    BUGS
  327.        None known. It is guaranteed that dp_Reply is corrupted by
  328.     DOS, but it is *NOT* guaranteed that the mn_ReplyPort is not
  329.     corrupted. I am relying on the Message structure *NOT* being
  330.     modified by DOS, which may change as commodore see fit.
  331.     Use at own risk. Apart from that, it works fine under 2.0!!
  332.  
  333.  
  334. track.library/ChkBound                       track.library/ChkBound
  335.  
  336.    NAME
  337.     ChkBound -- Compare a 32bit value against low/high bounds.
  338.  
  339.    SYNOPSIS
  340.         ChkBound( var, min, max )
  341.               D0   D2   D1
  342.  
  343.         long int var ;
  344.     long int min ;
  345.     long int max ;
  346.  
  347.    FUNCTION
  348.         Compares a 32bit value such as a pointer, against a minimum and
  349.     a maximum possible value. If the value is outside of either bound
  350.     then an exception EX_CHK is generated. Otherwise it returns 
  351.     normally.
  352.  
  353.    INPUTS
  354.         var should be an unsigned 32bit quantity. I don't think it will
  355.         handle signed comparisons properly, if at all.
  356.  
  357.         min and
  358.         max should again be a unsigned 32bit quantities.
  359.  
  360.    RESULTS
  361.         It either returns or it doesnt. Excellent for applications where
  362.     if the value is out of range, then the logic is broken. Better to
  363.     cause an exception than possibly bring the machine down.
  364.  
  365.    NOTES
  366.         This was designed to be used while the trap handling is enabled,
  367.     to enable you to capture the exception. If the trap handling is
  368.     not enabled, you will get a 'SOFTWARE FAILURE - Task Help' 
  369.     requester.
  370.  
  371.    SEE ALSO
  372.         libraries/track.h (for EX_CHK),  SetTrap(), AbsChkWord()
  373.     AbsChk()
  374.  
  375.    BUGS
  376.        none known.
  377.  
  378.  
  379. track.library/ChkRange                       track.library/ChkRange
  380.  
  381.    NAME
  382.     ChkRange -- Compare a 32bit value against start and size bounds.
  383.  
  384.    SYNOPSIS
  385.         ChkRange( var, min, size )
  386.               D0   D2   D1
  387.  
  388.         long int var ;
  389.     long int min ;
  390.     long int size ;
  391.  
  392.    FUNCTION
  393.         Compares a 32bit value such as a pointer, against a minimum value
  394.     and a range value. If the value is out of range then an exception
  395.     EX_CHK is generated. Otherwise it returns normally.
  396.  
  397.    INPUTS
  398.         var should be an unsigned 32bit quantity. I don't think it will
  399.         handle signed comparisons properly, if at all.
  400.  
  401.         min   and
  402.         size  should again be a unsigned 32bit quantities.
  403.  
  404.    RESULTS
  405.         It either returns or it doesnt. Excellent for applications where
  406.     if the value is out of range, then the logic is broken. Better to
  407.     cause an exception than possibly bring the machine down.
  408.  
  409.    NOTES
  410.     This is most useful for string manipulation. For example, if
  411.     you do the following :
  412.  
  413.         char buf[LENGTH] ;
  414.         ptr = strchr(buf,':') ;
  415.         /*
  416.          * Check that ptr is within reason. This could only
  417.          * fail if 
  418.          * a) ':' not found
  419.          * b) The search went passed the 80 character boundary.
  420.          *
  421.          * You say LENGTH-1, since ptr can only be from
  422.          * buf+0 to buf+79.
  423.          */
  424.         ChkRange(ptr,buf,LENGTH-1) ;
  425.  
  426.         This was designed to be used while the trap handling is enabled,
  427.     to enable you to capture the exception. If the trap handling is
  428.     not enabled, you will get a 'SOFTWARE FAILURE - Task Help' 
  429.     requester.
  430.  
  431.    SEE ALSO
  432.         libraries/track.h (for EX_CHK),  SetTrap(), AbsChkWord()
  433.     AbsChk(), ChkBound()
  434.  
  435.    BUGS
  436.        none known.
  437.  
  438.  
  439. track.library/CreateExtIO                 track.library/CreateExtIO  
  440.  
  441.    NAME
  442.        CreateExtIO -- Create an Extended IO Request.
  443.  
  444.    SYNOPSIS
  445.         IORequest = CreateExtIO( reply, size )
  446.     D0                       A0     D0
  447.  
  448.     struct IORequest *IORequest ;
  449.        struct MsgPort *reply ;
  450.         size = size of Request structure.
  451.  
  452.    FUNCTION
  453.     This allocates memory for an IORequest structure, filling in the
  454.     exec Message information, and linking in the replyport specified.
  455.  
  456.    INPUTS
  457.        reply    A pointer to the replyport for the IORequest.
  458.  
  459.     size    The size of the IORequest. Since difference devices use
  460.         different size custom request structures, it is important that
  461.         you specify the correct size.
  462.  
  463.    RESULTS
  464.        Returns a pointer to the allocated memory for the IORequest. If the
  465.     allocation failed, then a NULL is returned.
  466.  
  467.     The memory for the IORequest is cleared when allocated.
  468.  
  469.    NOTES
  470.        It is currently illegal to ask for an IORequest structure, with a
  471.     NULL reply port.
  472.  
  473.     The IORequests message type is set to NT_MESSAGE.
  474.  
  475.    SEE ALSO
  476.     DeleteExtIO(), CreatePort()
  477.  
  478.    BUGS
  479.        none known.
  480.  
  481.  
  482. track.library/CreatePacket               track.library/CreatePacket  
  483.  
  484.    NAME
  485.     CreatePacket -- Create and initialise a StandardPacket structure.
  486.  
  487.    SYNOPSIS
  488.         packet = CreatePacket( reply )
  489.     D0                     A0
  490.  
  491.        struct StandardPacket *packet;
  492.     struct MsgPort *reply;
  493.  
  494.    FUNCTION
  495.        This function allocates and clears a DOS StandardPacket structure,
  496.     filling in the strange DOS links, and storing the reply port address
  497.     in the Message structure's ReplyPort pointer.
  498.  
  499.     If the reply argument is NULL, a new MsgPort is created via
  500.     CreatePort().
  501.  
  502.    INPUTS
  503.        reply    A pointer to a standard MsgPort structure as returned by
  504.         CreatePort()
  505.  
  506.    RESULTS
  507.        A Pointer to a partially initialised DOS StandardPacket structure.
  508.  
  509.    NOTES
  510.        See CheckPacket() for important information about the *Packet() 
  511.     command set.
  512.  
  513.    SEE ALSO
  514.        CheckPacket(), WaitPacket(), DoPacket(), DeletePacket(),
  515.     CreatePort()
  516.  
  517.    BUGS
  518.        none known.
  519.  
  520.  
  521. track.library/CreatePort                   track.library/CreatePort  
  522.  
  523.    NAME
  524.     CreatePort -- Create an Exec MsgPort structure.
  525.  
  526.    SYNOPSIS
  527.     msgport = CreatePort( name, pri )
  528.     D0                    A0    D0
  529.  
  530.        struct MsgPort *msgport;
  531.     char *name;
  532.     int pri;
  533.  
  534.    FUNCTION
  535.        Allocates memory for a MsgPort structure, allocates a Signal,
  536.     initialises the name, priority, size, sigbit, and other important
  537.     information for the MsgPort to be immediately ready for use.
  538.  
  539.    INPUTS
  540.        name    A pointer to a string for the name. If no name (Ie NULL) is
  541.         supplied, the port is assumed to be private, and is not
  542.         added to the system MsgPort list.
  543.  
  544.     pri    The MsgPort priority. This is generally zero.
  545.  
  546.    RESULTS
  547.        Returns a pointer to a MsgPort structure, unless there was
  548.     insufficient memory, or not enough signals, in which case NULL
  549.     is returned.
  550.  
  551.    NOTES
  552.        This is *VERY* similar to the CreatePort() function in amiga.lib
  553.  
  554.    SEE ALSO
  555.     DeletePort()
  556.  
  557.    BUGS
  558.        none known.
  559.  
  560.  
  561. track.library/DeleteExtIO                 track.library/DeleteExtIO  
  562.  
  563.    NAME
  564.     DeleteExtIO -- Delete an Extended IO Request structure.
  565.  
  566.    SYNOPSIS
  567.     DeleteExtIO( request )
  568.                  A1
  569.  
  570.        struct IORequest *request ;
  571.  
  572.    FUNCTION
  573.     Free's the memory associated with the IORequest structure.
  574.  
  575.    INPUTS
  576.     request    A pointer to an IORequest created with CreateExtIO()
  577.  
  578.    RESULTS
  579.  
  580.    NOTES
  581.        Before freeing the memory, the IORequest is corrupted. Hence if you
  582.     accidentally reuse the deleted IORequest, you will most likely
  583.     crash the machine. Be Warned. (This is done on purpose)
  584.  
  585.     Note also that the replyport specified when you create the port 
  586.     is *NOT* free'd. You must DeletePort() it if you no longer need it.
  587.  
  588.    SEE ALSO
  589.     CreateExtIO(), DeletePort()
  590.  
  591.    BUGS
  592.        none known.
  593.  
  594.  
  595. track.library/DeletePacket               track.library/DeletePacket  
  596.  
  597.    NAME
  598.     DeletePacket -- Delete a DOS StandardPacket structure.
  599.  
  600.    SYNOPSIS
  601.     DeletePacket( packet, reply )
  602.               A0      D0
  603.  
  604.     struct StandardPacket *packet ;
  605.     Boolean reply;
  606.  
  607.    FUNCTION
  608.        This function free's memory associated with a StandardPacket.
  609.     It is *NOT* a good idea to free it while it is in use, but you
  610.     know that don't you.
  611.  
  612.    INPUTS
  613.        packet    A pointer to the StandardPacket to free.
  614.  
  615.        reply    A flag to indicating the status of the reply port.
  616.         TRUE indicates that the port was specified in the
  617.              CreatePacket() call. It is up to you to free it.
  618.         FALSE indicates that the port was created automatically by
  619.               CreatePacket(), and should be free'd by DeletePacket()
  620.  
  621.    RESULTS
  622.  
  623.    NOTES
  624.        The reply port is an issue because you can either create one and
  625.     share it, or create one for each DOS packet. If you let
  626.     CreatePacket() create the reply port, you should indicate FALSE, and
  627.     let DeletePacket() delete it.
  628.  
  629.     On the otherhand, if you created one for all packets, you must
  630.     specifiy TRUE, and not let DeletePacket() free it.
  631.  
  632.     The reason it is this way, is so that if you specify a port for the
  633.     CreatePacket(), then specify it for the DeletePacket() (hence TRUE),
  634.     and the same works for CreatePacket(NULL) and
  635.     DeletePacket(packet,NULL) (hence FALSE)
  636.  
  637.     You may perform trickery, such as creating a port, and many packets,
  638.     then using DeletePacket(packet,TRUE) on the LAST DeletePacket() to
  639.     remove the port automatically. *** Watchout if you track the
  640.     CreatePort(), you must FreeTrackItem() it, rather than let
  641.     DeletePacket() free it ***
  642.  
  643.    SEE ALSO
  644.     CreatePacket(), CreatePort(), DeletePort()
  645.  
  646.    BUGS
  647.        none known.
  648.  
  649.  
  650. track.library/DeletePort                   track.library/DeletePort  
  651.  
  652.    NAME
  653.        DeletePort -- free up an exec MsgPort structure.
  654.  
  655.    SYNOPSIS
  656.     DeletePort( port )
  657.                 A0
  658.  
  659.        struct MsgPort *port ;
  660.  
  661.    FUNCTION
  662.        This free's the signals and memory associated with a MsgPort
  663.     structure.
  664.  
  665.    INPUTS
  666.        port    A pointer the a MsgPort created via CreatePort().
  667.  
  668.    RESULTS
  669.  
  670.    NOTES
  671.        If the port has a name, DeletePort() *WILL* attempt to remove it
  672.     from the system ports list. HENCE, if you CreatePort() it without
  673.     a name, and add a name later, then you *MUST* remove the name
  674.     before calling DeletePort().
  675.  
  676.    SEE ALSO
  677.     CreatePort()
  678.  
  679.    BUGS
  680.        none known.
  681.  
  682.  
  683. track.library/DoPacket                       track.library/DoPacket  
  684.  
  685.    NAME
  686.        DoPacket -- Sends a packet to a device port synchronously.
  687.  
  688.    SYNOPSIS
  689.         result = DoPacket( Packet, Dest )
  690.     D0           A1      A0
  691.  
  692.       long result;
  693.     struct StandardPacket *Packet;
  694.     struct MsgPort *Dest;
  695.  
  696.    FUNCTION
  697.        Sends a DOS packet to the port specified, and waits until it has
  698.     completed. (Hence 'synchronously')
  699.  
  700.    INPUTS
  701.        Packet    A pointer to a DOS StandardPacket structure.
  702.  
  703.     Dest    A pointer to a device's message port as returned via
  704.         Open() or DeviceProc().
  705.  
  706.    RESULTS
  707.        result    The dp_Result field is extracted and returned as the result
  708.         code. Hence if only a dp_Result is expected, you do not
  709.         need to get it yourself.
  710.  
  711.    NOTES
  712.        This is a synchronous method of DOS communication. In general you
  713.     would do something like :
  714.  
  715.     struct StandardPacket *packet = CreatePacket(NULL);
  716.  
  717.     packet->sp_Pkt.dp_Action = ACTION_READ ;
  718.     packet->sp_Pkt.dp_Arg1 = fh->fh_Arg1 ;
  719.     packet->sp_Pkt.dp_Arg2 = buffer ;
  720.     packet->sp_Pkt.dp_Arg3 = 1024 ; /* length */
  721.  
  722.     length = DoPacket(packet,fh->fh_Type) ;
  723.  
  724.     Which would read from file handle 'fh', into buffer 'buffer' 
  725.     for 1024 bytes. The Actual length read would be returned in 
  726.     the variable length.
  727.  
  728.     DoPacket() is implemented along the following lines :
  729.  
  730.     SendPacket(packet,dest) ;
  731.     WaitPacket(packet) ;
  732.     return packet->sp_Pkt.dp_Res1 ;
  733.  
  734.    SEE ALSO
  735.        CheckPacket(), WaitPacket(), CreatePacket(), DeletePacket()
  736.  
  737.    BUGS
  738.        none known.
  739.  
  740.  
  741. track.library/ExceptCall                   track.library/ExceptCall  
  742.  
  743.    NAME
  744.        ExceptCall -- Break to a local exception handler.
  745.  
  746.    SYNOPSIS
  747.         ExceptCall( code )
  748.                 D0
  749.  
  750.        int code ;
  751.  
  752.    FUNCTION
  753.        This function switches from protected mode, to exception mode
  754.     (do not confuse any of this with user/supervisor mode.) and resets
  755.         control to the 'local' exception handler.
  756.  
  757.     NOTE: The alias for this function is CALLEXCEPTION(), and should
  758.           be used instead of ExceptCall() for implementation reasons.
  759.  
  760.    INPUTS
  761.        code    An integer code, which can be retrieved from within the
  762.         exception handler via the function 'ExceptCode()'
  763.  
  764.    RESULTS
  765.        This function does not return, unless there are no active exception
  766.     handlers.
  767.  
  768.    NOTES
  769.        Given a program fragment :
  770.  
  771.         PROTECTED
  772.             printf ("diff = %d\n",x/deltax) ; /* delta x = 0! */
  773.             printf ("This should not happen\n") ;
  774.         EXCEPTION
  775.             printf ("EXCEPTION : %d\n",LASTEXCEPTION()) ;
  776.            NORMAL
  777.  
  778.        When the division by zero occurs, within x/deltax, then the default
  779.     'trap' handler, will call ExceptCall() with the trap number. This
  780.     will cause execution to continue at the printf() after the 
  781.     statement 'EXCEPTION'
  782.  
  783.     You may of course call ExceptCall() yourself, but it is
  784.     recommended that you use the higher level ExceptRaise() call. 
  785.     This is because calling ExceptCall() from within the exception
  786.     handler will restart the hander, however ExceptRaise() will 
  787.     terminate the current exception handler and use ExceptCall() to
  788.     fall to the next exception handler in the stack.
  789.  
  790.     This is the current default 'trap' handler.
  791.  
  792.     ---------------------------------------------------------------
  793.     /*
  794.      * Exception handler.. This gets the cause of the exception and
  795.      * returns to the main program at the last exception entry point.
  796.      */
  797.  
  798.     #include <proto/track.h>
  799.     #include <libraries/track.h>
  800.  
  801.     void _DefaultEHandler(void) {
  802.        struct TrapInfo *codes = GetTrap() ;
  803.  
  804.        ExceptCall(codes->ti_TrapNO) ;
  805.        }
  806.     ---------------------------------------------------------------
  807.  
  808.    SEE ALSO
  809.        ExceptCode() (LASTEXCEPTION()), ExceptRaise() (RAISEEXCEPTION())
  810.  
  811.    BUGS
  812.        The macro CALLEXCEPTION() is disabled by default, since you should
  813.     have no reason to use it.
  814.  
  815.  
  816. track.library/ExceptCode                   track.library/ExceptCode  
  817.  
  818.    NAME
  819.        ExceptCode -- return the code used to raise the last exception.
  820.  
  821.    SYNOPSIS
  822.         code = ExceptCode()
  823.  
  824.     int code ;
  825.  
  826.    FUNCTION
  827.     Within an exception handler, ExceptCode() can be called to get
  828.     the code passed via ExceptCall() or ExceptRaise().
  829.  
  830.     NOTE: The alias for this function is LASTEXCEPTION(), and should
  831.           be used instead of ExceptCode() for implementation reasons.
  832.  
  833.    INPUTS
  834.  
  835.    RESULTS
  836.        code    A long int, passed via ExceptRaise().
  837.  
  838.    NOTES
  839.        A code can either be a processor trap code, eg Division by zero,
  840.     or a user code, such as a failed test. It is a good idea to
  841.     keep all user codes greater than the processor trap codes, so that
  842.     you don't confuse them.
  843.  
  844.     For this reason, all codes should be larger than EX_MC68000.
  845.  
  846.    SEE ALSO
  847.        ExceptRaise() (RAISEEXCEPTION())
  848.  
  849.    BUGS
  850.        none known.
  851.  
  852.  
  853. track.library/ExceptEnter                 track.library/ExceptEnter  
  854.  
  855.    NAME
  856.        ExceptEnter -- Exception gateway.
  857.  
  858.    SYNOPSIS
  859.         boolean = ExceptEnter( name )
  860.     D0                     A0
  861.  
  862.        char *name ;
  863.  
  864.    FUNCTION
  865.     This function immediately returns FALSE. If an exception occurs, 
  866.     control is passed back to this function, and it return TRUE.
  867.  
  868.     NOTE: The alias for this function is PROTECTED or PROTECT(name),
  869.           and should be used instead of ExceptEnter() for
  870.           implementation reasons.
  871.  
  872.    INPUTS
  873.        name    A pointer to a name string. This is used if a nested function
  874.         wants to break out to this exception handler.
  875.  
  876.    RESULTS
  877.        boolean        The first time this function is called, it
  878.             return FALSE. It then returns TRUE if an exception
  879.             is raised.
  880.  
  881.    NOTES
  882.        This function may be a tad difficult to understand. Given the
  883.     following code fragment.
  884.  
  885.         --------------------------------------------
  886.     if (ExceptEnter(NULL)) {
  887.        ExceptLeave() ;
  888.        exit(42) ;
  889.        }
  890.  
  891.     <code fragment>
  892.  
  893.     ExceptLeave() ;
  894.         --------------------------------------------
  895.  
  896.     The first time ExceptEnter() is called, it returns FALSE, and
  897.     execution continues to the <code fragment>. If during the code
  898.     fragment, an exception occurs, (Say a BUS ERROR), then control
  899.     is bounced back to the ExceptEnter() function, which will return
  900.     TRUE, causing the 'ExceptLeave() ; exit(42)' to be executed.
  901.  
  902.     Because of the difficulty visualising the flow of control, (after all
  903.     it does magically bounce around...) I have put some macros together 
  904.     to simplify the construction.
  905.  
  906.     The above code could be re-written as :
  907.  
  908.         --------------------------------------------
  909.         int code ;
  910.  
  911.         PROTECED
  912.             <code fragment>
  913.             code = 0 ;
  914.         EXCEPTION
  915.             code = 42
  916.         NORMAL
  917.  
  918.         return code ;
  919.         --------------------------------------------
  920.  
  921.     Here, the 'protected' code, and the 'exception' code are clearly
  922.     separated, and the flow of control is easier to follow, if you can
  923.     see where in the <code fragment> the exception was generated.
  924.  
  925.     Since exception information is stored 'stack' like, functions may
  926.     each have a different exception handler, or even nested exception
  927.     zones, within a function.
  928.  
  929.    SEE ALSO
  930.        ExceptRaise(), ExceptLeave().
  931.  
  932.    BUGS
  933.  
  934.  
  935. track.library/ExceptInit                   track.library/ExceptInit  
  936.  
  937.    NAME
  938.        ExceptInit -- Initialise the exception handler system.
  939.  
  940.    SYNOPSIS
  941.         ExceptInit( func )
  942.                 A0
  943.  
  944.        void (*func)()
  945.  
  946.    FUNCTION
  947.     This function starts the exception handler system, and sets the
  948.     function to call if a processor exception is generated.
  949.  
  950.     NOTE: The alias for this function is EINIT(handler) or EHANDLERINIT(),
  951.           and should be used instead of ExceptInit() for
  952.           implementation reasons.
  953.  
  954.    INPUTS
  955.        func    A pointer to a processor exception handler. An example is
  956.         given in the description of the ExceptCall() function.
  957.  
  958.    RESULTS
  959.  
  960.    NOTES
  961.        The 'func' is only needed if you intend to trap processor exceptions.
  962.     You can leave it NULL, and pass control around with the
  963.     RaiseException() call.
  964.  
  965.     This MUST be called before the first ExceptEnter() call, or you may
  966.     crash the system.
  967.  
  968.    SEE ALSO
  969.        ExceptCall(), RaiseException()
  970.  
  971.    BUGS
  972.        If you call this function a second time, deep within a nest of
  973.     exception handlers, it will immediately flush all the current
  974.     handlers, without passing control to any of them. However, it will
  975.     not free the memory associated with them.
  976.  
  977.     It is not a good idea to call this function a second time.
  978.  
  979. track.library/ExceptLeave                 track.library/ExceptLeave  
  980.  
  981.    NAME
  982.        ExceptLeave -- remove an exception handler from the top of the stack.
  983.  
  984.    SYNOPSIS
  985.         ExceptLeave()
  986.  
  987.    FUNCTION
  988.     This function undoes what ExceptEnter() does, removing the current
  989.     execption handler from the top of the stack. 
  990.  
  991.     NOTE: The alias for this function is NORMAL and should be used
  992.               instead of ExceptLeave() for implementation reasons.
  993.  
  994.    INPUTS
  995.  
  996.    RESULTS
  997.  
  998.    NOTES
  999.        Since any function can have an exception handler, and it may call a
  1000.     function that sets up its own handler, it is possible that an
  1001.     exception caused after the ExceptLeave() will be passed to the
  1002.     exception handler of the calling function.
  1003.  
  1004.     This feature is used by the ExceptRaise() function. If you are in
  1005.     an exception zone, ExceptRaise() will call ExceptLeave() once, and
  1006.     then jump to the next available exception handler.
  1007.  
  1008.    SEE ALSO
  1009.        ExceptRaise()
  1010.  
  1011.    BUGS
  1012.        If you return from a function without calling ExceptLeave(), there
  1013.     is no warning. However an exception will attempt to access an
  1014.     invalid stack frame, and very likely explode violently.
  1015.  
  1016.  
  1017. track.library/ExceptRaise                 track.library/ExceptRaise  
  1018.  
  1019.    NAME
  1020.        ExceptRaise -- Break to a local or external exception handler.
  1021.  
  1022.    SYNOPSIS
  1023.         ExceptRaise( code, name )
  1024.                  D0    A2
  1025.  
  1026.        int code ;
  1027.     char *name ;
  1028.  
  1029.    FUNCTION
  1030.     This function breaks to the next available exception handler, leaving
  1031.     the current function if necessary.
  1032.  
  1033.     NOTE: The alias for this function is RAISEEXCEPTION() and should be
  1034.           used instead of ExceptRaise() for implementation reasons.
  1035.  
  1036.    INPUTS
  1037.        code    An integer code, which will be passed to the exception code.
  1038.  
  1039.     name    A name string. If this is specified, then ExceptRaise() will
  1040.         Attempt to break out as far as the last ExceptEnter() with
  1041.         the same name.
  1042.  
  1043.    RESULTS
  1044.        If all went well, this function should not return.
  1045.  
  1046.    NOTES
  1047.        If you are in a protected zone, then this function is identical to
  1048.     ExceptCall() (unless you specified a name).
  1049.  
  1050.     If you are in an exception zone, or specified a name, then
  1051.     ExceptLeave() will be called either once, or until the zone
  1052.     with the correct name is found. Then control will be passed to
  1053.     that new exception handler.
  1054.  
  1055.    SEE ALSO
  1056.        ExceptCall()
  1057.  
  1058.    BUGS
  1059.        If you specify a name, and that name is NOT found, this will jump
  1060.     to the next available handler, without generating an error.
  1061.  
  1062.  
  1063. track.library/FPrintf                         track.library/FPrintf  
  1064.  
  1065.    NAME
  1066.        FPrintf -- Formatted Printf to a File Handle.
  1067.  
  1068.    SYNOPSIS
  1069.         FPrintf( Handle, Fmt, Args )
  1070.              A2      A0   A1
  1071.  
  1072.        BPTR Handle; 
  1073.     char *Fmt;
  1074.     long  Args;
  1075.  
  1076.    FUNCTION
  1077.        Standard 'C' fprintf function to an AmigaDos file handle, as supplied
  1078.     by Open(), or TOpen().
  1079.  
  1080.    INPUTS
  1081.        Handle        A BCPL pointer to a file handle.
  1082.  
  1083.     Fmt        A format string. Read the definition of printf() for
  1084.             the codes.
  1085.  
  1086.     Args        Argument pointer for the format string.
  1087.  
  1088.    RESULTS
  1089.  
  1090.    NOTES
  1091.        This calls the Exec RawDoFmt() function with the format and args,
  1092.     and writes the result to the file handle specified.
  1093.  
  1094.        This function required a stub to work with 'C'. 
  1095.  
  1096.    SEE ALSO
  1097.        printf(), Printf()
  1098.  
  1099.    BUGS
  1100.        If you compiler automatically promotes integers to 32bit longs, then
  1101.     all %d's and %u's must be written as %ld and %lu. 
  1102.  
  1103.  
  1104. track.library/FreeTrackedItem         track.library/FreeTrackedItem  
  1105.  
  1106.    NAME
  1107.        FreeTrackedItem -- Free a tracked resource item.
  1108.  
  1109.    SYNOPSIS
  1110.         FreeTrackedItem( Item )
  1111.                      A0
  1112.  
  1113.        long Item ;
  1114.  
  1115.    FUNCTION
  1116.        This function frees the item pointed to by Item.
  1117.  
  1118.    INPUTS
  1119.        Item    A pointer to value identifying the resource.
  1120.  
  1121.    RESULTS
  1122.  
  1123.    NOTES
  1124.        The Item is free'd by calling the 'Free' function in the items
  1125.     'tn_drop' pointer. The item node is then unlinked and deallocated.
  1126.  
  1127.     Note that the register A4 is stored as part of the tracking 
  1128.     environment, and is restored before calling the 'C' function. This
  1129.     is to aid 'C' programmer, who wish to use functions which
  1130.     are pre-compiled, such as the amiga.lib 'Close()' function.
  1131.  
  1132.    SEE ALSO
  1133.        TrackItem()
  1134.  
  1135.    BUGS
  1136.        none known.
  1137.  
  1138.  
  1139. track.library/FreeTrackList             track.library/FreeTrackList  
  1140.  
  1141.    NAME
  1142.        FreeTrackList -- Free all tracked items.
  1143.  
  1144.    SYNOPSIS
  1145.         FreeTrackList()
  1146.  
  1147.    FUNCTION
  1148.        This free's all items currently tracked by this process.
  1149.  
  1150.    INPUTS
  1151.  
  1152.    RESULTS
  1153.  
  1154.    NOTES
  1155.        This function is called automatically when the library is closed.
  1156.  
  1157.    SEE ALSO
  1158.        FreeTrackedItem(),TrackItem()
  1159.  
  1160.    BUGS
  1161.        none known.
  1162.  
  1163.  
  1164. track.library/GetTrap                         track.library/GetTrap  
  1165.  
  1166.    NAME
  1167.        GetTrap -- Get information about last processor trap.
  1168.  
  1169.    SYNOPSIS
  1170.         info = GetTrap()
  1171.  
  1172.     struct TrapInfo *info
  1173.  
  1174.    FUNCTION
  1175.        This functions returns a pointer to a structure containing the
  1176.     PC of the last TRAP, the TRAP number, and a pointer to a NULL
  1177.     terminated string describing the TRAP.
  1178.  
  1179.    INPUTS
  1180.  
  1181.    RESULTS
  1182.        info    A pointer to an instance of the TrapInfo structure. This
  1183.         is a pointer to an internal data structure, and its contents
  1184.         should not be altered.
  1185.  
  1186.    NOTES
  1187.        When a trap occurs, the lowlevel trap handler stores the trap number
  1188.     and trap address in a TrapInfo structure local to the current task
  1189.     or process. When GetTrap() is called, the trap number of used to 
  1190.     calculate a pointer to a message, which is stored in the structure,
  1191.     before returning the address of the structure in memory.
  1192.  
  1193.     The possible messages include :
  1194.  
  1195.         Trap 1
  1196.         Bus Error
  1197.         Address Error
  1198.         Illegal Instruction
  1199.         Divide by Zero
  1200.         CHK instruction
  1201.         TRAPV instruction
  1202.         Priviledge violation
  1203.         Trace
  1204.         Line 1010 emulation
  1205.         Line 1111 emulation
  1206.  
  1207.     An example of the use of GetTrap() :
  1208.  
  1209.         gurutrap( void ) {
  1210.               struct TrapInfo *codes = GetTrap() ;
  1211.            Printf ("SOFTWARE FAILURE : %s\n",codes->ti_TrapMsg) ;
  1212.               exit(1) ;
  1213.               }
  1214.  
  1215.        To use this, you would also use the command 'SetTrap(gurutrap).'
  1216.  
  1217.    SEE ALSO
  1218.        libraries/track.h for (struct TrapInfo), SetTrap()
  1219.  
  1220.    BUGS
  1221.        none known.
  1222.  
  1223.  
  1224. track.library/LongJmp                         track.library/LongJmp  
  1225.  
  1226.    NAME
  1227.        LongJump -- return to a previously saved context.
  1228.  
  1229.    SYNOPSIS
  1230.         LongJmp( save )
  1231.              A0
  1232.  
  1233.        jmpbuf    save
  1234.  
  1235.    FUNCTION
  1236.        LongJmp() returns to the context contained within the variable
  1237.     'save'.
  1238.  
  1239.    INPUTS
  1240.        save    A context buffer. defined in the ansi include file setjmp.h
  1241.  
  1242.    RESULTS
  1243.        This function should not return. (It should return to where the
  1244.     context was saved)
  1245.  
  1246.    NOTES
  1247.        This is a duplication of the ANSI setjmp()/longjmp() commands, used
  1248.     in the exception handling code. (Now you know how it all magically
  1249.     jumps around!)
  1250.  
  1251.    SEE ALSO
  1252.        setjmp(), SetJmp(), longjmp() setjmp.h
  1253.  
  1254.    BUGS
  1255.     This only works if it is called directly via inline assembly, or
  1256.     #pragma's. The use of a C language stub will invalidate the
  1257.     function, and probably crash the machine.
  1258.  
  1259.  
  1260. track.library/MakeBStr                       track.library/MakeBStr  
  1261.  
  1262.    NAME
  1263.        MakeBStr -- Convert a string to a BSTR.
  1264.  
  1265.    SYNOPSIS
  1266.         bstr = MakeBStr( string )
  1267.     D0               A0
  1268.  
  1269.     BSTR bstr;
  1270.     char *string;
  1271.  
  1272.    FUNCTION
  1273.        This function creates a BSTR from the character string, and returns
  1274.     a BPTR to the BSTR. (Don't you hate BCPL..)
  1275.  
  1276.    INPUTS
  1277.        string        A normal everyday NULL terminated string.
  1278.  
  1279.    RESULTS
  1280.        bstr        A BPTR to a BSTR, or NULL if memory was unavailable.
  1281.  
  1282.    NOTES
  1283.        A BSTR is a string, where the first byte is the length, and
  1284.     the string does not need a terminator byte. (Since you know its
  1285.     length.)
  1286.  
  1287.     A BPTR is a pointer divided by 4.
  1288.     Hence the string begins in memory at (BPTR << 2) + 1. 
  1289.  
  1290.     ALL DOS routines use BPTR's and some use BSTR's as well.
  1291.  
  1292.     IMPORTANT : The memory allocated for the BSTR is tracked, and should
  1293.             be free'd by passing the REAL ADDRESS to FreeTrackItem()
  1294.             not the BPTR.
  1295.  
  1296.             Eg, 
  1297.             dev = MakeBStr("DF0") ;
  1298.             .
  1299.             .
  1300.             .
  1301.             FreeTrackedItem( dev << 2 ) ;
  1302.  
  1303.             Since it is tracked, it will be free'd when the program
  1304.             closes the track.library.
  1305.  
  1306.    SEE ALSO
  1307.        Dos functions, FreeTrackedItem().
  1308.  
  1309.    BUGS
  1310.        A BSTR may be up to 255 bytes, but a normal C string can be
  1311.     infinitely long. This routine DOES NOT MAKE SURE that the initial
  1312.     string is short enough to be a BSTR.
  1313.  
  1314.  
  1315. track.library/MemAlloc                       track.library/MemAlloc  
  1316.  
  1317.    NAME
  1318.        MemAlloc -- Allocate memory.
  1319.  
  1320.    SYNOPSIS
  1321.         buffer = MemAlloc( Size, Type )
  1322.     D0                 D0    D1
  1323.  
  1324.        void *buffer ;
  1325.     ULONG Size ;
  1326.     ULONG Type ;
  1327.  
  1328.    FUNCTION
  1329.        This function allocated Size bytes of type Type, returning the
  1330.     address of the allocated block.
  1331.  
  1332.    INPUTS
  1333.        Size    The size of the block to allocate in bytes.
  1334.  
  1335.        Type    The type of memory to allocate, ie CHIP, FAST or PUBLIC.
  1336.  
  1337.    RESULTS
  1338.        buffer    A pointer to the allocated memory.
  1339.  
  1340.    NOTES
  1341.        This function allocates four extra bytes, using 'AllocMem()' and
  1342.     stores the length of the block in the first longword. The pointer
  1343.     returned is a pointer to the second longword.
  1344.  
  1345.     When MemFree(buffer) is called, it subtracts 4 bytes from buffer, and
  1346.     uses the contents of the first longword as the 'size' argument
  1347.     for 'FreeMem(buffer,size)'
  1348.  
  1349.    SEE ALSO
  1350.        MemFree(), AllocMem(), FreeMem()
  1351.  
  1352.    BUGS
  1353.        none known.
  1354.  
  1355.  
  1356. track.library/MemFree                         track.library/MemFree  
  1357.  
  1358.    NAME
  1359.        MemFree -- Free a memory block allocated with MemAlloc()
  1360.  
  1361.    SYNOPSIS
  1362.         MemFree( Block )
  1363.          A1
  1364.  
  1365.        void *Block;
  1366.  
  1367.    FUNCTION
  1368.        This function free's the memory block pointed to by Block.
  1369.  
  1370.    INPUTS
  1371.        Block    A pointer to the memory allocated with MemAlloc()
  1372.  
  1373.    RESULTS
  1374.  
  1375.    NOTES
  1376.        MemFree() looks for the size of the allocated block at
  1377.     Block-4, and uses this size when calling FreeMem(Block-4,size); 
  1378.  
  1379.     See MemAlloc() for more information.
  1380.  
  1381.    SEE ALSO
  1382.        MemAlloc(), AllocMem(), FreeMem()
  1383.  
  1384.    BUGS
  1385.        none known.
  1386.  
  1387.  
  1388. track.library/NewList                         track.library/NewList  
  1389.  
  1390.    NAME
  1391.        NewList -- Initialise an Exec list header.
  1392.  
  1393.    SYNOPSIS
  1394.         NewList( List )
  1395.              A0
  1396.  
  1397.        struct List *List ;
  1398.  
  1399.    FUNCTION
  1400.        This function initialises an exec list header for use.
  1401.  
  1402.    INPUTS
  1403.        List    A pointer to a list header.
  1404.  
  1405.    RESULTS
  1406.  
  1407.    NOTES
  1408.        An EXEC list header must be initialised before use. The usual method
  1409.     is :
  1410.         List->lh_Head = & ( List->lh_Tail ) ;
  1411.         List->lh_Tail = NULL ;
  1412.         List->lh_TailPred = & ( List->lh_Head ) ;
  1413.  
  1414.     The NewList() function call will do this for you.
  1415.  
  1416.    SEE ALSO
  1417.     exec/lists.h (RKM/exec for List management)
  1418.  
  1419.    BUGS
  1420.        none known.
  1421.  
  1422.  
  1423. track.library/OnSignal                       track.library/OnSignal  
  1424.  
  1425.    NAME
  1426.         OnSignal -- Initialise signal handling, and set function pointer.
  1427.  
  1428.    SYNOPSIS
  1429.         OnSignal( sigmask ,func )
  1430.           D0       A0
  1431.  
  1432.        ULONG    sigmask ;
  1433.     void (*func)(void) ;
  1434.  
  1435.    FUNCTION
  1436.        This function initialises the signal handling mechanism if it is
  1437.     the first call, and sets up to call 'func()' when a signal in 
  1438.     'sigmask' is generated.
  1439.  
  1440.    INPUTS
  1441.        sigmask        A 32bit mask of which signals will cause function
  1442.             func() to be called.
  1443.  
  1444.        func        A pointer to the function to be called when a signal
  1445.             is generated.
  1446.  
  1447.    RESULTS
  1448.  
  1449.    NOTES
  1450.        An array of 32 function pointers is allocated, with one entry per
  1451.     possible signal. Each call of OnSignal() will set the appropriate
  1452.     bits in the exception mask using 'SetExcept()', and place the
  1453.     function address in each array position indicated by the signal
  1454.     mask.
  1455.  
  1456.     When the signal occurs, program context switches to a software
  1457.     exception state, and execution continues with the signal handler.
  1458.     When the signal handler returns, execution is continued where it 
  1459.     left off.
  1460.  
  1461.     A signal handler can be easily disabled by specifying the correct
  1462.     mask, and a NULL function.
  1463.  
  1464.     Example : setup to call 'windowhandler()' on intuition messages,
  1465.           and to call 'aborthandler()' in the event of a control C
  1466.           or control D.
  1467.  
  1468.        OnSignal ( 1 << window->UserPort . mp_SigBit, windowhandler ) ;
  1469.  
  1470.        OnSignal ( SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D, aborthandler ) ;
  1471.  
  1472.            Now turn off the control D signal handler.
  1473.  
  1474.        OnSignal ( SIGBREAKF_CTRL_D, NULL ) ;
  1475.  
  1476.           NOTE that this leave control C handling active. Ie it
  1477.           is not affected.
  1478.  
  1479.    SEE ALSO
  1480.        SetExcept()
  1481.  
  1482.    BUGS
  1483.        This is not a real bug, more of a restriction. I wrote a program
  1484.     that used 'Printf()' in a loop, and OnSignal(SIGBREAKF_CTRL_C,exit).
  1485.  
  1486.     If the control-C arrived, and the program exit()'ed while a DOS
  1487.     message (regarding the write to console) was active, the machine
  1488.     promply guru'ed.
  1489.  
  1490.     MOTTO : Dont let a signal interupt a DOS function, unless you are
  1491.             guaranteed to return to where you left off.
  1492.             
  1493.  
  1494. track.library/Printf                           track.library/Printf  
  1495.  
  1496.    NAME
  1497.     Printf -- Print formatted string to console.
  1498.  
  1499.    SYNOPSIS
  1500.         Printf( String, Args )
  1501.         A0    A1
  1502.  
  1503.     char *String ;
  1504.     Arguments Args ;
  1505.  
  1506.    FUNCTION
  1507.     This is a printf() compatible Printf() function, whose output goes
  1508.     to the file handle returned by the Output() function.
  1509.  
  1510.    INPUTS
  1511.     String    A pointer to a printf() like format string. Note that floats
  1512.         are not supported.
  1513.  
  1514.     Args    Standard C arguments. example 'Printf("%d = %x",42,blah) ;'
  1515.  
  1516.    RESULTS
  1517.  
  1518.    NOTES
  1519.     Since Output() and Write() are functions callable only from DOS 
  1520.     processes, you MUST be a process to use this function!
  1521.  
  1522.     In C, a stub is required to get the address of the arguments which
  1523.     are on the stack.
  1524.  
  1525.    SEE ALSO
  1526.     printf(), Output(), Write()
  1527.  
  1528.    BUGS
  1529.     If your compiler promotes int's to 32bit, you must tell Printf() about
  1530.     it. Example, 'Printf ("%lx\n",42) ;'. The 'l' in '%lx' tells Printf()
  1531.     that the number is a 32bit LONG int.
  1532.  
  1533.  
  1534. track.library/Reads                             track.library/Reads  
  1535.  
  1536.    NAME
  1537.     Reads -- Read a string from a file handle.
  1538.  
  1539.    SYNOPSIS
  1540.         str = Reads( file, buf, len )
  1541.     D0           D1    D2   D3
  1542.  
  1543.     char *str ;
  1544.     BPTR file ;
  1545.     char *buf ;
  1546.     int len ;
  1547.  
  1548.    FUNCTION
  1549.     This function reads a carriage or EOF terminated string from the
  1550.     specified file.
  1551.  
  1552.    INPUTS
  1553.     file    A BPTR to a file handle.
  1554.  
  1555.     buf    Buffer space to place the input.
  1556.  
  1557.     len    The LENGTH of the available buffer.
  1558.  
  1559.    RESULTS
  1560.     str    A pointer to buf is returned, unless an error occurred, in
  1561.         which case a NULL is returned.
  1562.  
  1563.    NOTES
  1564.     This function reads a buffer full from the file, and scans for a
  1565.     linefeed. If a linefeed is found, then that linefeed is replaced 
  1566.     with a string terminator (NULL), and the file is seeked back
  1567.     to the next character past the linefeed.
  1568.  
  1569.     If no linefeed was found, then the *buffer* is NULL terminated.
  1570.  
  1571.     If *NO* character were succesfully read. (Ie an error, or the file
  1572.     was at EOF), then a NULL is returned.
  1573.  
  1574.    SEE ALSO
  1575.     Read(), Seek()
  1576.  
  1577.    BUGS
  1578.     This uses DOS functions, and must only be called from a process.
  1579.  
  1580.     Due to the method of seeking used, the input file handle must not
  1581.     be a pipe. It will read the pipe a buffer full at a time, and
  1582.     discard the remainder. This can only be fixed via a buffering
  1583.     machanism as supplied in stdio.
  1584.  
  1585.  
  1586. track.library/RemoveProcess             track.library/RemoveProcess  
  1587.  
  1588.    NAME
  1589.     RemoveProcess -- Remove a process from the resource list.
  1590.  
  1591.    SYNOPSIS
  1592.     RemoveProcess()
  1593.  
  1594.    FUNCTION
  1595.     This function removes a process from the resource list, disabling
  1596.     all signal handling, all exception handling, and freeing all tracked
  1597.     items.
  1598.  
  1599.    INPUTS
  1600.  
  1601.    RESULTS
  1602.  
  1603.    NOTES
  1604.     This function is called for each process automatically as it closes
  1605.     the library, hence there is no need to call it yourself.
  1606.  
  1607.    SEE ALSO
  1608.     AddProcess()
  1609.  
  1610.    BUGS
  1611.        none known.
  1612.  
  1613.  
  1614. track.library/SendPacket                   track.library/SendPacket  
  1615.  
  1616.    NAME
  1617.        SendPacket -- Send a DOS StandardPacket to a device.
  1618.  
  1619.    SYNOPSIS
  1620.     packet = SendPacket( packet, Dest )
  1621.     D0                   A1      A0
  1622.  
  1623.        struct StandardPacket *packet ;
  1624.     struct MsgPort *Dest ;
  1625.  
  1626.    FUNCTION
  1627.        This fixes the packets 'dp_Reply' pointer, and then sends the packet
  1628.     to the destination port specified.
  1629.  
  1630.    INPUTS
  1631.        packet    The StandardPacket to send to the device.
  1632.  
  1633.     Dest    The destination MsgPort.
  1634.  
  1635.    RESULTS
  1636.        packet    The original packet pointer is returned.
  1637.  
  1638.    NOTES
  1639.        DOS is documented to corrupt the dp_Reply pointer in its packets.
  1640.     Using the CreatePacket() call, the contents of dp_Reply are cached
  1641.     in the Message header, and copied back to dp_Reply whenever you
  1642.     call SendPacket().
  1643.  
  1644.     At anytime, CheckPacket() will return the packet if it is finished
  1645.     with, and can be Remove()'ed.
  1646.  
  1647.     At anytime, WaitPacket() will pause until the packet IS finished
  1648.     with, and will Remove() it before returning.
  1649.  
  1650.    SEE ALSO
  1651.        DoPacket()
  1652.  
  1653.    BUGS
  1654.        none known.
  1655.  
  1656.  
  1657. track.library/SetJmp                           track.library/SetJmp  
  1658.  
  1659.    NAME
  1660.        SetJmp -- Save current context for a later LongJmp().
  1661.  
  1662.    SYNOPSIS
  1663.     firstrun = SetJmp( save )
  1664.     D0                 A0
  1665.  
  1666.     boolean firstrun ;
  1667.        jmpbuf    save ;
  1668.  
  1669.    FUNCTION
  1670.        This function saves important processor information to enable the
  1671.     LongJmp() command to return to this point.
  1672.  
  1673.    INPUTS
  1674.        save        An area to save the context to. Defined in the ANSI
  1675.             include file setjmp.h
  1676.  
  1677.    RESULTS
  1678.        firstrun    FALSE if the SetJmp() saved the context,
  1679.             TRUE if a LongJmp() caused control to return to
  1680.             the SetJmp().
  1681.  
  1682.    NOTES
  1683.        This is an implementation of the ANSI setjmp() command, for use with
  1684.     the exception handling functions.
  1685.  
  1686.     Read a manual on setjmp()/longjmp() for a proper discussion of
  1687.     its use.
  1688.  
  1689.    SEE ALSO
  1690.        LongJmp()
  1691.  
  1692.    BUGS
  1693.     This only works if it is called directly via inline assembly, or
  1694.     #pragma's. The use of a C language stub will invalidate the
  1695.     function, and probably crash the machine.
  1696.  
  1697.  
  1698. track.library/SetTrap                         track.library/SetTrap  
  1699.  
  1700.    NAME
  1701.        SetTrap -- Setup a process trap handler.
  1702.  
  1703.    SYNOPSIS
  1704.     SetTrap( vec )
  1705.              A0
  1706.  
  1707.        void (*vec)(void) ;
  1708.  
  1709.    FUNCTION
  1710.        This function tells the library internal trap handler to call
  1711.     function vec() before returning. 
  1712.  
  1713.    INPUTS
  1714.        vec    A pointer to a function.
  1715.  
  1716.    RESULTS
  1717.  
  1718.    NOTES
  1719.        Although the internal trap handler is executed in supervisor mode,
  1720.     the processor is switched to user mode before calling your
  1721.     handler code.
  1722.  
  1723.     The special compiler register A4 is setup before calling the
  1724.     function, in case your compiler does not have a keyword to
  1725.     automatically reload this register. If you do not know know why A4 is
  1726.     so important, then you need not worry.
  1727.  
  1728.     Trap handling can the stopped via the call SetTrap(NULL). Note that
  1729.     this does not turn off the internal handler, it just tells it to
  1730.     call the standard 'Software Failure -- Task Held' routine!
  1731.  
  1732.    SEE ALSO
  1733.        GetTrap()
  1734.  
  1735.    BUGS
  1736.        none known.
  1737.  
  1738.  
  1739. track.library/SPrintf                         track.library/SPrintf  
  1740.  
  1741.    NAME
  1742.     SPrintf -- Printf formatted output to a buffer.
  1743.  
  1744.    SYNOPSIS
  1745.     SPrintf( String, Fmt, Args )
  1746.              A2      A0   A1
  1747.  
  1748.     char *String ;
  1749.     char *Fmt ;
  1750.     Arguments Args ;
  1751.  
  1752.    FUNCTION
  1753.     This function performs 'C' string formatting on 'Fmt' and places the
  1754.     formatting string in 'String'.
  1755.  
  1756.    INPUTS
  1757.     String    A pointer to a buffer.
  1758.  
  1759.     Fmt    A pointer to a format string.
  1760.  
  1761.     Args    C arguments for the Printf() formatting.
  1762.  
  1763.    RESULTS
  1764.  
  1765.    NOTES
  1766.     This function performs C like printf() formatting.
  1767.  
  1768.     Note that unlike Printf() and FPrintf(), no DOS functions are called,
  1769.     hence SPrintf() may be called from a task.
  1770.  
  1771.    SEE ALSO
  1772.     Printf(), printf(), FPrintf()
  1773.  
  1774.    BUGS
  1775.     If your compiler promotes int's to 32bit, you must tell Printf() about
  1776.     it. Example, 'Printf ("%lx\n",42) ;'. The 'l' in '%lx' tells Printf()
  1777.     that the number is a 32bit LONG int.
  1778.  
  1779.  
  1780. track.library/Strcat                           track.library/Strcat  
  1781.  
  1782.    NAME
  1783.     Strcat -- perform string concatenation.
  1784.  
  1785.    SYNOPSIS
  1786.     Strcat( str, data )
  1787.             A0   A1
  1788.  
  1789.     char *str, *data ;
  1790.  
  1791.    FUNCTION
  1792.     This function appends 'data' to the end of 'str'. The result is
  1793.     guaranteed to be NULL terminated.
  1794.  
  1795.    INPUTS
  1796.     str    A pointer to a string.
  1797.  
  1798.     data    A pointer to a second string.
  1799.  
  1800.    RESULTS
  1801.  
  1802.    NOTES
  1803.     str MUST be large enough to hold both strings.
  1804.  
  1805.     This function was implemented for internal use, however creating
  1806.     a library entry point was so trivial, I had to do it!
  1807.  
  1808.    SEE ALSO
  1809.     strcat()
  1810.  
  1811.    BUGS
  1812.        none known.
  1813.  
  1814.  
  1815. track.library/Strchr                           track.library/Strchr  
  1816.  
  1817.    NAME
  1818.     Strchr -- scan a string for a specific character.
  1819.  
  1820.    SYNOPSIS
  1821.     pos = Strchr( str, val )
  1822.     D0            A0   D1
  1823.  
  1824.     char *pos ;
  1825.     char *str ;
  1826.     int  val ;
  1827.  
  1828.    FUNCTION
  1829.     This function searches the NULL terminated string 'str' for the
  1830.     first occurence of the character 'val'
  1831.  
  1832.    INPUTS
  1833.     str    A pointer to a string to search.
  1834.  
  1835.     val    A character to search for.
  1836.  
  1837.    RESULTS
  1838.     pos    A pointer to the character within the string.
  1839.  
  1840.    NOTES
  1841.     This function was implemented for internal use, however creating
  1842.     a library entry point was so trivial, I had to do it!
  1843.  
  1844.    SEE ALSO
  1845.     strchr() 
  1846.  
  1847.    BUGS
  1848.        none known.
  1849.  
  1850.  
  1851. track.library/TCreateExtIO               track.library/TCreateExtIO  
  1852.  
  1853.    NAME
  1854.     TCreateExtIO -- Create Extended IO Request and track it.
  1855.  
  1856.    SYNOPSIS
  1857.     IORequest = TCreateExtIO( reply, size )
  1858.     D0                        A0     D0
  1859.  
  1860.     struct IORequest *IORequest ;
  1861.     struct MsgPort *reply ;
  1862.     int    size ;
  1863.  
  1864.    FUNCTION
  1865.     This function calls 'CreateExtIO()' with the arguments and
  1866.     tracks the result.
  1867.  
  1868.    INPUTS
  1869.     See CreateExtIO()
  1870.  
  1871.    RESULTS
  1872.     See CreateExtIO()
  1873.  
  1874.    NOTES
  1875.     Whereas for CreateExtIO() you call DeleteExtIO(), for this
  1876.     function you call FreeTrackedItem(). OR If you do not, it will
  1877.     be automatically freed when the track library is closed.
  1878.  
  1879.    SEE ALSO
  1880.     CreateExtIO(), TrackItem()
  1881.  
  1882.    BUGS
  1883.        none known.
  1884.  
  1885.  
  1886. track.library/TCreatePacket             track.library/TCreatePacket  
  1887.  
  1888.    NAME
  1889.     TCreatePacket -- Create DOS StandardPacket and track it.
  1890.  
  1891.    SYNOPSIS
  1892.     struct StandardPacket = TCreatePacket( reply )
  1893.     D0                                     A0
  1894.  
  1895.     struct StandardPacket *StandardPacket ;
  1896.     struct MsgPort *reply ;
  1897.  
  1898.    FUNCTION
  1899.     This function calls 'CreatePacket()' with the arguments and
  1900.     tracks the result.
  1901.  
  1902.    INPUTS
  1903.     See CreatePacket()
  1904.  
  1905.    RESULTS
  1906.     See CreatePacket()
  1907.  
  1908.    NOTES
  1909.     Whereas for CreatePacket() you call DeletePacket(), for this
  1910.     function you call FreeTrackedItem(). OR If you do not, it will
  1911.     be automatically freed when the track library is closed.
  1912.  
  1913.    SEE ALSO
  1914.     CreatePacket(), TrackItem()
  1915.  
  1916.    BUGS
  1917.        none known.
  1918.  
  1919.  
  1920. track.library/TCreatePort                 track.library/TCreatePort  
  1921.  
  1922.    NAME
  1923.     TCreatePort -- Create a Message Port and track it.
  1924.  
  1925.    SYNOPSIS
  1926.     MsgsPort = TCreatePort( name, pri )
  1927.     D0                      A0    D0
  1928.  
  1929.     struct MsgPort *MsgPort ;
  1930.     char *name ;
  1931.     int pri ;
  1932.  
  1933.    FUNCTION
  1934.     This function calls 'CreatePort()' with the arguments and
  1935.     tracks the result.
  1936.  
  1937.    INPUTS
  1938.     See CreatePort()
  1939.  
  1940.    RESULTS
  1941.     See CreatePort()
  1942.  
  1943.    NOTES
  1944.     Whereas for CreatePort() you call DeletePort(), for this
  1945.     function you call FreeTrackedItem(). OR If you do not, it will
  1946.     be automatically freed when the track library is closed.
  1947.  
  1948.    SEE ALSO
  1949.     CreatePort()
  1950.  
  1951.    BUGS
  1952.        none known.
  1953.  
  1954.  
  1955. track.library/TLock                             track.library/TLock  
  1956.  
  1957.    NAME
  1958.     TLock -- Create a lock and track it.
  1959.  
  1960.    SYNOPSIS
  1961.     lock = TLock( name, mode )
  1962.     D0            D1    D2
  1963.  
  1964.    FUNCTION
  1965.     This function calls 'CreatePort()' with the arguments and
  1966.     tracks the result.
  1967.  
  1968.    INPUTS
  1969.     See Lock() 
  1970.  
  1971.    RESULTS
  1972.     See Lock() 
  1973.  
  1974.    NOTES
  1975.     Whereas for Lock() you call UnLock(), for this function you call
  1976.     FreeTrackedItem(). OR If you do not, it will be automatically freed
  1977.     when the track library is closed.
  1978.  
  1979.    SEE ALSO
  1980.     Lock() 
  1981.  
  1982.    BUGS
  1983.     Since Lock() returns a BPTR, this function is currently tracked on
  1984.     the BPTR. However is it possible that another pointer (to a MsgPort
  1985.     for example) may happen to be equal. (I.E. The address of the message
  1986.     port happens to be equal to the address of the lock divided by 4!)
  1987.  
  1988.     If this happens, a FreeTrackedItem(lock) may free the wrong item!!
  1989.  
  1990.     RSN I will change this to track the proper address, (not the BPTR)
  1991.     BUT I WILL NOT CHANGE THE NAME. USE AT OWN RISK.
  1992.  
  1993.  
  1994. track.library/TMemAlloc                     track.library/TMemAlloc  
  1995.  
  1996.    NAME
  1997.     TMemAlloc -- Allocate memory and track it.
  1998.  
  1999.    SYNOPSIS
  2000.     block = TMemAlloc( Size, Type )
  2001.     D0                 D0    D1
  2002.  
  2003.     void *block ;
  2004.     int Size, Type ;
  2005.  
  2006.    FUNCTION
  2007.     This function calls 'CreatePort()' with the arguments and
  2008.     tracks the result.
  2009.  
  2010.    INPUTS
  2011.     See MemAlloc()
  2012.  
  2013.    RESULTS
  2014.     See MemAlloc()
  2015.  
  2016.    NOTES
  2017.     Whereas for MemAlloc() you call MemFree(), for this function you call
  2018.     FreeTrackedItem(). OR If you do not, it will be automatically freed
  2019.     when the track library is closed. (If you call MemFree(), the library
  2020.     will attempt to free it again when you close it, and the machine will
  2021.     guru.)
  2022.  
  2023.    SEE ALSO
  2024.     MemAlloc()
  2025.  
  2026.    BUGS
  2027.        none known.
  2028.  
  2029.  
  2030. track.library/TOpen                             track.library/TOpen  
  2031.  
  2032.    NAME
  2033.     TOpen -- Open a file and track it.
  2034.  
  2035.    SYNOPSIS
  2036.     fh = TOpen( file, mode )
  2037.     D0          D1    D2
  2038.  
  2039.     BPTR fh ;
  2040.     char *file ;
  2041.     int mode ;
  2042.  
  2043.    FUNCTION
  2044.     This function calls Open() with the arguments, and tracks the result.
  2045.  
  2046.    INPUTS
  2047.     See Open()
  2048.  
  2049.    RESULTS
  2050.     See Open()
  2051.  
  2052.    NOTES
  2053.     Whereas for Open() you call Close(), for this function you call
  2054.     FreeTrackedItem(). OR If you do not, it will be automatically freed
  2055.     when the track library is closed.
  2056.  
  2057.    SEE ALSO
  2058.     Open()
  2059.  
  2060.    BUGS
  2061.     Since Open() returns a BPTR, this function is currently tracked on
  2062.     the BPTR. However is it possible that another pointer (to a MsgPort
  2063.     for example) may happen to be equal. (I.E. The address of the message
  2064.     port happens to be equal to the address of the file handle divided
  2065.     by 4!)
  2066.  
  2067.     If this happens, a FreeTrackedItem(fh) may free the wrong item!!
  2068.  
  2069.     RSN I will change this to track the proper address, (not the BPTR)
  2070.     BUT I WILL NOT CHANGE THE NAME. USE AT OWN RISK.
  2071.  
  2072.  
  2073. track.library/TOpenDevice                 track.library/TOpenDevice  
  2074.  
  2075.    NAME
  2076.  
  2077.    SYNOPSIS
  2078.     error = TOpenDevice( devname, unit, ioRequest, flags )
  2079.     D0                   A0       D0    A1         D1
  2080.  
  2081.     int error ;
  2082.     char *devname ;
  2083.     int unit ;
  2084.     struct IORequest *ioRequest ;
  2085.     int flags ;
  2086.  
  2087.    FUNCTION
  2088.     This calls 'OpenDevice()' with the arguments, and tracks the result.
  2089.  
  2090.    INPUTS
  2091.     See OpenDevice()
  2092.  
  2093.    RESULTS
  2094.     See OpenDevice()
  2095.  
  2096.    NOTES
  2097.     This function cannot track the return value of OpenDevice() since
  2098.     it returns a boolean. Hence, it tracks the address of the IORequest
  2099.     structure. 
  2100.  
  2101.     This means the first call to FreeTrackItem(ioRequest) will close the
  2102.     device, and the next call will free the IORequest structure. This
  2103.     should pose no real problem, since you would not want to free an
  2104.     IO request without closing the device first.
  2105.  
  2106.    SEE ALSO
  2107.     OpenDevice()
  2108.  
  2109.    BUGS
  2110.        none known.
  2111.  
  2112.  
  2113. track.library/TOpenLibrary               track.library/TOpenLibrary  
  2114.  
  2115.    NAME
  2116.     TOpenLibrary -- Open a system library and track it.
  2117.  
  2118.    SYNOPSIS
  2119.     library = TOpenLibrary( lib, rev )
  2120.     D0                      A1   D0
  2121.  
  2122.     struct Library *library ;
  2123.     char *lib ;
  2124.     int rev ;
  2125.  
  2126.    FUNCTION
  2127.     This function calls 'OpenLibrary()' with the arguments, and tracks
  2128.     the result.
  2129.  
  2130.    INPUTS
  2131.     See OpenLibrary() 
  2132.  
  2133.    RESULTS
  2134.     See OpenLibrary() 
  2135.  
  2136.    NOTES
  2137.     This will track the open library, automatically closing it when
  2138.     you close 'track.library' if you do not FreeTrackItem() it first.
  2139.  
  2140.     WARNING : If you 'CloseLibrary()' a library, and FreeTrackedItem()
  2141.           closes it again, you may get a library with a negative use
  2142.           count. This means when the next program opens the library,
  2143.           and the counter increments to zero, any low memory 
  2144.           situation can cause the library to be unloaded WHILE STILL
  2145.           IN USE. Hence BOOM.
  2146.  
  2147.    SEE ALSO
  2148.     OpenLibrary()
  2149.  
  2150.    BUGS
  2151.        none known.
  2152.  
  2153.  
  2154. track.library/TOpenScreen                 track.library/TOpenScreen  
  2155.  
  2156.    NAME
  2157.     TOpenScreen -- Open a screen and track it.
  2158.  
  2159.    SYNOPSIS
  2160.     TOpenScreen( newscrptr )
  2161.                  A0
  2162.  
  2163.    FUNCTION
  2164.     The function calls OpenScreen(), and tracks the screen.
  2165.  
  2166.    INPUTS
  2167.     See OpenScreen()
  2168.  
  2169.    RESULTS
  2170.     See OpenScreen()
  2171.  
  2172.    NOTES
  2173.     The screen must be closed with FreeTrackedItem(). When using this,
  2174.     it is a good idea to track everything on the screen. That way
  2175.     if a guru is caught, and the library closed, everything will be
  2176.     free'd. If not, the screen may be free'd from under an open window!
  2177.     (See TOpenWindow())
  2178.  
  2179.    SEE ALSO
  2180.     OpenScreen()
  2181.  
  2182.    BUGS
  2183.        none known.
  2184.  
  2185.  
  2186. track.library/TOpenWindow                 track.library/TOpenWindow  
  2187.  
  2188.    NAME
  2189.     TOpenWindow -- Open a window and track it.
  2190.  
  2191.    SYNOPSIS
  2192.     window *TOpenWindow( newwinptr )
  2193.     D0                   A0
  2194.  
  2195.     struct Window *window ;
  2196.     struct NewWindow *newwinptr ;
  2197.  
  2198.    FUNCTION
  2199.     This function calls OpenWindow() and track the result.
  2200.  
  2201.    INPUTS
  2202.     See OpenWindow()
  2203.  
  2204.    RESULTS
  2205.     See OpenWindow()
  2206.  
  2207.    NOTES
  2208.     When tracking a window, it is a good idea to track everything you
  2209.     do to, or put in a window.
  2210.     
  2211.     Example : If you set a clip region, and then accidentaly do a division
  2212.           by zero, which causes the trap handler to close the library
  2213.           and exit gracefully, you may find the system does not like
  2214.           closing a window with custom clip regions and gadgets. If you
  2215.           had tracked the regions and gadget, they would have been
  2216.               clear away before the window was closed.
  2217.  
  2218.    SEE ALSO
  2219.     See OpenWindow()
  2220.  
  2221.    BUGS
  2222.        none known.
  2223.  
  2224.  
  2225. track.library/TrackItem                     track.library/TrackItem  
  2226.  
  2227.    NAME
  2228.     TrackItem -- Add an item description to the track list.
  2229.  
  2230.    SYNOPSIS
  2231.     TrackItem( Item, Code, Param )
  2232.                D0    A0    D1
  2233.  
  2234.     void *Item ;
  2235.     void (*Code)(void *item, void *Param) ;
  2236.     void Param ;
  2237.  
  2238.    FUNCTION
  2239.     This function creates and links in a new track node, filled in
  2240.     with the information about the item you gave it.
  2241.  
  2242.    INPUTS
  2243.     Item    A pointer to an ITEM. This should be a unique pointer.
  2244.  
  2245.     Code    A pointer to a function to free the ITEM.
  2246.  
  2247.     Param    A parameter, incase the function pointed to by Code requires
  2248.         a second parameter.
  2249.  
  2250.    RESULTS
  2251.  
  2252.    NOTES
  2253.     This is the call to track an item. Tracking an item is done as follows
  2254.  
  2255.     1) Prepare or find a routine to free the Item. For example,
  2256.        the Amige.lib 'Close()' stub.
  2257.  
  2258.     2) Create the Item. Eg. item = Open("henry",MODE_OLDFILE) ;
  2259.  
  2260.     3) Track the item.
  2261.           TrackItem(item,Close,NULL) ; /* Close does not need param */
  2262.  
  2263.     To close the file, you call :
  2264.           FreeTrackedItem(item) ;
  2265.  
  2266.     Notice that the item is actually the pointer to the file handle. It
  2267.     does not need to be, but in this case it was important because the
  2268.  
  2269.           FreeTrackedItem(item) ;
  2270.  
  2271.     call, will do a 'Close(item)'.
  2272.  
  2273.     Items are tracked in a stack. If you track a screen, then track 
  2274.     a window, and then track a gadget, then closing the library would
  2275.     cause the gadget to be freed, the window closed and the screen closed
  2276.     in that order.
  2277.          
  2278.    SEE ALSO
  2279.     FreeTrackedItem() ;
  2280.  
  2281.    BUGS
  2282.        none known.
  2283.  
  2284.  
  2285. track.library/TrapMsg                         track.library/TrapMsg  
  2286.  
  2287.    NAME
  2288.     TrapMsg -- Return a message describing a processor exception.
  2289.  
  2290.    SYNOPSIS
  2291.     msg = TrapMsg( code )
  2292.     D0             D0
  2293.  
  2294.     char *msg ;
  2295.     int code ;
  2296.  
  2297.    FUNCTION
  2298.     This function uses the exception code to look up a descriptive
  2299.     meaning in a table.
  2300.  
  2301.    INPUTS
  2302.     code    The processor exception code.
  2303.  
  2304.    RESULTS
  2305.     msg    A NULL terminate message.
  2306.  
  2307.    NOTES
  2308.     This function returns a Message describing an exception given an
  2309.     exception number. See GetTrap() to a description of the available
  2310.     messages.
  2311.  
  2312.     GetTrap() is similar, except it calls TrapMsg() with the last exception
  2313.     code storing in the internal process structure.
  2314.  
  2315.    SEE ALSO
  2316.     GetTrap()
  2317.  
  2318.    BUGS
  2319.        none known.
  2320.  
  2321.  
  2322. track.library/TSetDMRequest             track.library/TSetDMRequest  
  2323.  
  2324.    NAME
  2325.     TSetDMRequest -- Request DM events, and track it.
  2326.  
  2327.    SYNOPSIS
  2328.     TSetDMRequest( win, request )
  2329.                    A0   A1
  2330.  
  2331.     strict Window *win ;
  2332.     boolean request ;
  2333.  
  2334.    FUNCTION
  2335.     This function calls SetDMRequest() and tracks that it has been called.
  2336.  
  2337.    INPUTS
  2338.     See SetDMRequest()
  2339.  
  2340.    RESULTS
  2341.     See SetDMRequest()
  2342.  
  2343.    NOTES
  2344.  
  2345.    SEE ALSO
  2346.     SetDMRequest()
  2347.  
  2348.    BUGS
  2349.        none known.
  2350.  
  2351.  
  2352. track.library/TSetMenuStrip             track.library/TSetMenuStrip  
  2353.  
  2354.    NAME
  2355.     TSetMenuStrip -- Set a window Menu, and Track it.
  2356.  
  2357.    SYNOPSIS
  2358.     TSetMenuStrip( win, menu )
  2359.                    A0   A1
  2360.  
  2361.     struct Window *win ;
  2362.     struct Menu *menu ;
  2363.  
  2364.    FUNCTION
  2365.     This function attaches the menu to the window, and tracks the menu.
  2366.  
  2367.    INPUTS
  2368.     See SetMenuStrip()
  2369.  
  2370.    RESULTS
  2371.     See SetMenuStrip()
  2372.  
  2373.    NOTES
  2374.     When you use this, you MUST remember to FreeTrackedItem(menu) before
  2375.     freeing the window.
  2376.  
  2377.     When closing the track library, the menu will automatically be
  2378.     freed before the window is closed.
  2379.  
  2380.    SEE ALSO
  2381.     SetMenuStrip()
  2382.  
  2383.    BUGS
  2384.        none known.
  2385.  
  2386.  
  2387. track.library/WaitPacket                   track.library/WaitPacket  
  2388.  
  2389.    NAME
  2390.        WaitPacket -- Wait until a DOS request is complete.
  2391.  
  2392.    SYNOPSIS
  2393.     result = WaitPacket( packet )
  2394.     D0                   A1
  2395.  
  2396.        long result ;
  2397.     struct StandardPacket *packet;
  2398.  
  2399.    FUNCTION
  2400.        This function waits until the packet is finished with, and Remove()'s
  2401.     it from the reply queue. It then returns the dp_Result code.
  2402.  
  2403.    INPUTS
  2404.        packet    The StandardPacket to wait for.
  2405.  
  2406.    RESULTS
  2407.        result    The result code from dp_Result in the packet.
  2408.  
  2409.    NOTES
  2410.        This is implemented as a loop doing the following :
  2411.  
  2412.         While (!CheckPacket(packet))
  2413.             WaitPort(packet->sp_Msg.mn_ReplyPort);
  2414.         Remove(packet) ;
  2415.         return packet->sp_Pkt.dp_Result ;
  2416.  
  2417.    SEE ALSO
  2418.        CheckPacket(), Remove()
  2419.  
  2420.    BUGS
  2421.        none known.
  2422.  
  2423.  
  2424.