home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / programm / libs / lib_coll.lha / COMMODIT.ZOO / Commodities / functions < prev    next >
Encoding:
Text File  |  1987-07-08  |  30.6 KB  |  1,181 lines

  1. :bk=0
  2.  
  3.     Commodities Exchange Function Reference
  4.         v0.3 March 19, 1987
  5.         Jim Mackraz, San Jose, California
  6.  
  7. NOTE: Starting with Version 0.3, new functions are added to the
  8. end of this file (and appended to the file "funcsummary").
  9.  
  10.  
  11. NAME    CreateCxObj()
  12.  
  13.     CxObj    *co = CreateCxObj(type, arg1, arg2);
  14.  
  15.     LONG    type;
  16.     LONG    arg1;
  17.     LONG    arg2;
  18.  
  19. DESCRIPTION
  20.     Creates a Commodities Object of type 'type.'  It is not proper
  21.     to call this function directly.  Each object creation routine
  22.     except CxBroker() is defined as a macro in "cxusr.h."  The
  23.     routines are independently documented.
  24.  
  25.     Note that the handle returned is a pointer to an abstract type
  26.     named 'CxObj.'  This type is defined as a LONG in "cxusr.h" but
  27.     internally has more content.  The specific size and contents of
  28.     internal data structures are 'private.'
  29.  
  30.     All functions which operate on a Commodities object are made with
  31.     a reference to the thirty-two bit value returned by this function
  32.     (or CxBroker()).
  33.  
  34. DIAGNOSTICS
  35.     A NULL returned value indicates that the requested object could not
  36.     be created, typically for lack of system memory.  Minor problems in
  37.     creating an object, such as providing a bad filter description to
  38.     CxFilter(), typically don't cause failure, but are recorded in
  39.     an internal error field in the new object.
  40.  
  41. SEE ALSO
  42.     CxObjError(), CxFilter(), CxTypeFilter(), CxSender(), CxSignal(),
  43.     CxTranslate(), CxDebug(), CxCustom(), CxBroker()
  44.  
  45.  
  46. NAME    CxBroker()
  47.  
  48.     CxObj    *broker    =    CxBroker(nb, error);
  49.  
  50.     struct NewBroker    *nb;
  51.     LONG                *error;
  52.  
  53. DESCRIPTION
  54.     Creates a broker from the specification found in the NewBroker
  55.     structure pointed to by 'nb.'  
  56.  
  57.     The purposes and meaning of the fields are described below.
  58.     See also the include file "broker.h."
  59.  
  60.     struct NewBroker {
  61.         BYTE    nb_Version;
  62.         BYTE    *nb_Name;
  63.         BYTE    *nb_Title;
  64.         BYTE    *nb_Descr;
  65.         SHORT    nb_Unique;
  66.         BYTE    nb_Pri;
  67.     };
  68.  
  69.     'nb_Version' is the way that future versions of the Commodities
  70.     library can identify which version of the NewBroker structure
  71.     you are using.  This should be set to NB_VERSION, defined in
  72.     "broker.h."
  73.  
  74.     'nb_Name' is a string which is to be the name of the broker
  75.     Node which is created.  This name is application internal,
  76.     and is used only to find the broker Node in the Commodities
  77.     Object List.
  78.  
  79.     'nb_Title' and 'nb_Descr' are two strings which appear to the
  80.     user and describe the application the broker is representing.
  81.     Note that all strings above are copied into the broker object.
  82.     The maximum length of these strings that will be recognized are
  83.     defined by constants in "broker.h."
  84.  
  85.     'nb_Unique' is a field that indicates what should happen if
  86.     a broker of the same name (nb_Name) already exists in the
  87.     Commodities Object List.  Constants in "broker.h" allow
  88.     the caller to specify whether another broker is to be created,
  89.     and whether any existing broker of the same name should be
  90.     notified that an attempt at creating a duplicate has been made.
  91.  
  92.     'nb_Pri' specifies with what priority in the Commodities
  93.     Object List that the new broker is to be inserted.  Higher
  94.     priority nodes appear earlier in a list.  See "broker.h"
  95.     for guidelines for priorities of different types of
  96.     applications.  It is strongly recommended that the
  97.     ToolTypes environment of an application be used to allow the
  98.     end-user to set the priority of the broker.
  99.  
  100. DIAGNOSTICS
  101.     Returns NULL in the event of failure.  If the pointer 'error'
  102.     is non-null, a further diagnostic code will be placed at
  103.     that address.  Error codes are in "broker.h" and include:
  104.  
  105.     CBERR_OK
  106.         No problems; broker created OK.
  107.  
  108.     CBERR_SYSERR
  109.         System problems, not your fault.  Sign of low memory or
  110.         big problems.
  111.  
  112.     CBERR_DUP
  113.         The nb_Unique field specified that only one broker of
  114.         'nb_Name' should be allowed, and one already exists.
  115.  
  116.     CBERR_VERSION
  117.         The field 'nb_Version' is unknown to the running version
  118.         of "commodities.library."
  119.  
  120. SEE ALSO
  121.     FindBroker()
  122.     Brokers and Application Sub-Trees (in Reference Manual)
  123.  
  124.  
  125. NAME    CxFilter()    --    MACRO
  126.  
  127.     CxObj *filter = CxFilter(description);
  128.  
  129.     BYTE    *description;
  130.  
  131. DESCRIPTION
  132.     Creates an input event filter object which matches Commodities
  133.     Input Messages fitting the 'description' string.  If
  134.     'description' is NULL, the filter will not match any messages.
  135.  
  136.     A filter may be modified by the functions SetFilter(), using
  137.     a description string, and SetFilterIX(), which takes a 
  138.     binary Input Expression as a parameter.
  139.  
  140.     This function is a C-language macro for CreateCxObj(), defined
  141.     in "cxfunctions.h."
  142.  
  143. DIAGNOSTICS
  144.     Returns NULL if the function fails, which only occurs
  145.     if there is no memory for the new filter object.  If there
  146.     is a problem in the description string, the internal error
  147.     code of the filter object will be set to so indicate.  This
  148.     error code may be interrogated using the function CxObjError().
  149.  
  150. SEE ALSO
  151.     CreateCxObj()
  152.     SetFilter(), SetFilterIX(), CxObjError()
  153.     Objects and Message (in Reference Manual)
  154.     Input Expressions and Description Strings
  155.     Objects and Messages (in Reference Manual)
  156.     Error Handling    (in Reference Manual)
  157.  
  158.  
  159. NAME    CxTypeFilter()    --    MACRO
  160.  
  161.     CxObj *typef = CxTypeFilter(typemask);
  162.  
  163.     LONG    typemask;
  164.  
  165. DESCRIPTION
  166.     Creates a Commodities Object similar to CxFilter(), but one
  167.     that diverts all Commodities messages whose type, which is
  168.     always a power of two, matches a bit set in 'typemask.'
  169.  
  170.     Values of message types are given in "cxusr.h."
  171.  
  172.     This function is a C-language macro for CreateCxObj(), defined
  173.     in "cxfunctions.h."
  174.  
  175. DIAGNOSTICS
  176.     Returns NULL if the function fails, which only occurs
  177.     if there is no memory for the new filter object.  If there
  178.     is a problem in the description string, the internal error
  179.     code of the filter object will be set to so indicate.  This
  180.     error code may be interrogated using the function CxObjError().
  181.  
  182. SEE ALSO
  183.     CreateCxObj()
  184.     SetFilter(), SetFilterIX(), CxObjError()
  185.     Object and Messages (in Reference Manual)
  186.     Input Expressions and Description Strings
  187.     Error Handling
  188.  
  189.  
  190. NAME    CxSignal()    --    MACRO
  191.  
  192.     CxObj    *signaler = CxSignal(task, signal);
  193.  
  194.     struct Task    *task;
  195.     LONG        signal;
  196.  
  197. DESCRIPTION
  198.     This function creates a Commodities signal object.  The action
  199.     of this object on receiving a Commodities message is to
  200.     send the 'signal' to the 'task.'  The caller is responsible
  201.     for allocating the signal and determining the proper task ID.
  202.  
  203.     Note that 'signal' is the signal value as returned by
  204.     AllocSignal() (example: 3) , not the mask made from
  205.     that value (i.e., not binary 0000000000001000).
  206.  
  207.     This function is a C-language macro for CreateCxObj(), defined
  208.     in "cxfunctions.h."
  209.  
  210. DIAGNOSTICS
  211.     Returns NULL if the object could not be created.
  212.  
  213. SEE ALSO
  214.     CreateCxObj()
  215.     Objects and Messages (in Reference Manual)
  216.     exec.library/Signal(), exec.library/AllocSignal(),
  217.     exec.library/FindTask()
  218.  
  219.  
  220. NAME    CxSender()    --    MACRO
  221.  
  222.     CxObj    *sender = CxSender(port, id)
  223.  
  224.     struct MsgPort    *port;
  225.     LONG            id;
  226.  
  227. DESCRIPTION
  228.     This function creates a Commodities sender object.  The action
  229.     of this object on receiving a Commodities message is to
  230.     copy the Commodities message into a standard Exec Message,
  231.     to put the value 'id' in the message as well, and to send the
  232.     message off to the Message Port 'port.'
  233.  
  234.     The value 'id' is used so that an application can monitor
  235.     messages from several senders at a single port.  It can
  236.     be retrieved from the Exec message by using the function
  237.     CxMsgID(). The value can be a simple integer ID, or a pointer
  238.     to some application data structure, for example.
  239.  
  240.     Note that Exec messages sent by sender objects arrive
  241.     asynchronously at the destination port.  Do not assume 
  242.     anything about the status of the Commodities message which
  243.     was copied into the Exec message you received.
  244.  
  245.     All Exec messages sent to your ports must be replied.
  246.     Messages may be replied after the sender object has been
  247.     deleted.
  248.  
  249.     This function is a C-language macro for CreateCxObj(), defined
  250.     in "cxfunctions.h."
  251.  
  252. DIAGNOSTICS
  253.     Returns NULL if the sender object cannot be created.
  254.  
  255. SEE ALSO
  256.     CreateCxObj()
  257.     exec.library/PutMsg(), exec.library/ReplyMsg()
  258.     CxMsgID()
  259.  
  260.  
  261. NAME    CxTranslate()    --    MACRO
  262.  
  263.     CxObj    *translator = CxTranslate(ie);
  264.  
  265.     struct InputEvent    *ie;
  266.  
  267. DESCRIPTION
  268.     This function creates a Commodities 'translate' object. 
  269.     The action of this object on receiving a Commodities
  270.     message is to replace that message in the commodities network
  271.     with a chain of Commodities input messages.
  272.  
  273.     One new Commodities input message for each input event
  274.     in the linked list starting at 'ie' (and NULL terminated).
  275.     The routing information of the new input messages will be
  276.     copied from the input message they replace.
  277.  
  278.     The linked list of input events associated with a translate
  279.     object can be changed using the SetTranslate() function.
  280.  
  281.     If 'ie' is NULL, the null translation occurs: that is, the
  282.     original commodities input message is disposed, and no
  283.     others are created to take its place.
  284.  
  285.     This function is a C-language macro for CreateCxObj(), defined
  286.     in "cxfunctions.h."
  287.  
  288. DIAGNOSTICS
  289.     Returns NULL if the translate object cannot be created.
  290.  
  291. SEE ALSO
  292.     CreateCxObj()
  293.     SetTranslate()
  294.     Commodities Input Messages and Filters
  295.  
  296.  
  297. NAME    CxCustom()    --    MACRO
  298.  
  299.     CxObj    *custom = CxCustom(action, id);
  300.  
  301.     LONG    (*action)();
  302.     LONG    id;
  303.  
  304. DESCRIPTION
  305.     This function creates a custom Commodities object.  The action
  306.     of this object on receiving a Commodities message is to
  307.     call a function of the application programmer's choice.
  308.  
  309.     The function provided ('action') will be passed a pointer to
  310.     the actual commodities message (in commodities private data
  311.     space), and will actually execute as part of the input handler
  312.     system task.  Among other things, the value of 'id' can be
  313.     recovered the message by using the function CxMsgID().
  314.  
  315.     The purpose of this function is two-fold.  First, it allows
  316.     programmers to create Commodities Exchange objects with
  317.     functionality that was not imagined or chosen for inclusion
  318.     by the designers.  Secondly, this is the only way to act
  319.     synchronously with Commodities. 
  320.  
  321.     For further explanation and examples, consult the Reference
  322.     Manual.
  323.  
  324.     This function is a C-language macro for CreateCxObj(), defined
  325.     in "cxfunctions.h."
  326.  
  327. DIAGNOSTICS
  328.     Returns NULL if the custom object cannot be created.
  329.  
  330. SEE ALSO
  331.     CreateCxObj()
  332.     Custom Objects (in Reference Manual)
  333.     CxMsgID()
  334.  
  335.  
  336. NAME    CxDebug()    --    MACRO
  337.  
  338.     CxObj    *debugger = CxDebug(id);
  339.  
  340.     LONG    id;
  341.  
  342. DESCRIPTION
  343.     This function creates a Commodities debug object.  The action
  344.     of this object on receiving a Commodities message is to
  345.     print out information about the Commodities message through
  346.     the Serial port (using the kprintf() routine).  The value
  347.     'id' will also be displayed.
  348.  
  349.     Note that this is a synchronous occurence (the printing
  350.     is done by the input device task).  If screen or file
  351.     output is desired, using a sender object instead of
  352.     debug object is necessary, since such output is best
  353.     done by your application process.
  354.  
  355.     This function is a C-language macro for CreateCxObj(), defined
  356.     in "cxfunctions.h."
  357.  
  358. DIAGNOSTICS
  359.     Returns NULL if the debug object cannot be created.
  360.  
  361. SEE ALSO
  362.     CreateCxObj()
  363.     CxSender()
  364.     exec_support/kprintf()
  365.  
  366.  
  367. NAME    DeleteCxObj()
  368.  
  369.     void    DeleteCxObj(co);
  370.  
  371.     CxObj    *co;
  372.  
  373. DESCRIPTION
  374.     Deletes a Commodities object of any type.  If the object
  375.     is linked into a list, will first be removed.  Note that
  376.     the handle 'co' is invalid after this function is called.
  377.  
  378.     Note also that deleting an object which has other objects attached
  379.     to it may be undesirable.  Use the function DeleteCxObjAll()
  380.     to delete an entire sub-tree of objects.
  381.  
  382. DIAGNOSTICS
  383.     None.  Possible system crash if fed fiction.
  384.  
  385. SEE ALSO
  386.     exec.library/Remove()
  387.     DeleteCxObjAll()
  388.  
  389.  
  390. NAME    DeleteCxObjAll()
  391.  
  392.     void    DeleteCxObjAll(co);
  393.  
  394.     CxObj    *co;
  395.  
  396. DESCRIPTION
  397.     This function deletes the Commodities object 'co,' and also
  398.     recursively deletes all objects attached to 'co,' and the
  399.     objects attached to them.
  400.  
  401.     If 'co' is linked into a list, it is removed first.  Note
  402.     that the handle 'co' is invalid after this function is called.
  403.  
  404.     This function is useful when an application exits: most
  405.     applications can clean up completely by deleting the
  406.     entire sub-tree of objects starting at their broker.
  407.  
  408. DIAGNOSTICS
  409.     None.  Definite system crash if fed fiction.
  410.  
  411. SEE ALSO
  412.     exec.library/Remove()
  413.     DeleteCxObj()
  414.  
  415.  
  416. NAME    CxObjType()
  417.  
  418.     LONG    type = CxObjType(co);
  419.  
  420.     CxObj    *co;
  421.  
  422. DESCRIPTION
  423.     This function should not really be necessary.  It returns
  424.     the type of a Commodities object, which you should already
  425.     know, since you created it in the first place.
  426.  
  427.     Values for 'type' are given in "cxusr.h."
  428.  
  429. DIAGNOSTICS
  430.     The value of 'type' will be CX_INVALID if you pass in a value of
  431.     NULL for 'co.'  If you pass a random value for 'co,' you
  432.     will get a random answer.
  433.  
  434. SEE ALSO
  435.     All Commodities object creation routines.
  436.  
  437.  
  438. NAME    ActivateCxObj()
  439.  
  440.     LONG    previous = ActivateCxObj(co, true);
  441.  
  442.     CxObj        *co;
  443.     LONG        true;    /* Aztec user's take note    */
  444.  
  445. DESCRIPTION
  446.     Commodities objects of all types maintain an "activation state."
  447.     If an object is "active," then it performs its particular action
  448.     whenever a Commodities message arrives.  If the object is
  449.     "inactive," no action is taken, and the message goes on to its
  450.     next destination.
  451.  
  452.     All objects are created in the "active" state except brokers,
  453.     which are created "inactive."  Thus, after you create your
  454.     broker and hang a tree of objects off of it, you must remember
  455.     to use this function to activate your broker.  This causes it
  456.     it to divert all messages to your tree of objects.
  457.  
  458.     This function activates 'co' if 'true,' and deactivates it
  459.     otherwise.  The previous value of activation is returned:
  460.     zero for inactive, non-zero for active.
  461.  
  462. DIAGNOSTICS
  463.     None.
  464.  
  465. SEE ALSO
  466.     CxBroker()
  467.     Brokers and Application Sub-Trees (in Reference Manual)
  468.  
  469.  
  470. NAME    SetTranslate()
  471.  
  472.     LONG    error = SetTranslate(translator, ie);
  473.  
  474.     CxObj                *translator;
  475.     struct InputEvent    *ie;
  476.  
  477. DESCRIPTION
  478.     This function replaces the translation list of a Commodities
  479.     translate object 'translator' with the linked list starting at 'ie.'
  480.  
  481.     A null value for 'ie' indicates that the object 'translator'
  482.     should swallow all Commodities messages that are sent its way.
  483.  
  484.     Note that the input events are not copied into Commodities private
  485.     memory, but the value of ie is used--asynchronously to the
  486.     application program--to find a chain of InputEvents in the
  487.     application's data space.
  488.  
  489.     At the time of translation, though, each input event is copied
  490.     into its own new Commodities message.
  491.  
  492.     This means that no other Commodities user, nor Commodities itself
  493.     will be modifying your list of InputEvents.  On the other
  494.     hand, your program must not corrupt the input event chain
  495.     that has been presented to a translator. 
  496.  
  497. DIAGNOSTICS
  498.     Returns zero if there is no problem, otherwise an error code
  499.     with values found in "cxusr.h."  The only forseeable error
  500.     could occur if 'translator' was not in fact a translate object.
  501.  
  502. SEE ALSO
  503.     include:devices/inputevent.h
  504.     CxTranslate()
  505.  
  506.  
  507. NAME    SetFilter()
  508.  
  509.     void    SetFilter(filter, text);
  510.  
  511.     CxObj    *filter;
  512.     char    *text;
  513.  
  514. DESCRIPTION
  515.     Changes the matching condition of a Commodities input filter to
  516.     that described by the input description string 'text.'
  517.  
  518. DIAGNOSTICS
  519.     The internal error of 'filter' will have the COERR_BADFILTER
  520.     bit set or cleared depending on the failure or success (resp.)
  521.     of SetFilter().
  522.  
  523. SEE ALSO
  524.     SetFilter(), SetFilterIX(), CxObjError()
  525.     Commodities Input Messages and Filters
  526.     Input Expressions and Description Strings
  527.  
  528.  
  529. NAME    SetFilterIX()
  530.  
  531.  
  532.     LONG    error = SetFilterIX(filter, ix);
  533.  
  534.     CxObj    *filter;
  535.     IX        *ix;
  536.  
  537. DESCRIPTION
  538.     Changes the matching condition of a Commodities input filter to
  539.     that described by the binary input expression pointed by 'ix.'
  540.  
  541.     Input expressions are defined in the file "ix.h."  It is important
  542.     to remember that the first field of the input expression structure
  543.     must indicate which type of version of the input expression structure
  544.     is being used.  See "ix.h."
  545.  
  546. DIAGNOSTICS
  547.     If 'error' returned is non-zero, it contains an error code from
  548.     "cxusr.h."
  549.  
  550. SEE ALSO
  551.     SetFilter(), SetFilterIX(), CxObjError()
  552.     Commodities Input Messages and Filters
  553.     Input Expressions and Description Strings
  554.  
  555.  
  556. NAME    ParseIX()
  557.  
  558.     LONG    failurecode = ParseIX(string, ix);
  559.  
  560.     char    *string;
  561.     IX        *ix;
  562.  
  563. DESCRIPTION
  564.     Given an input description string and an allocated, valid input
  565.     expression, sets the fields of the input expression to 
  566.     correspond to the description string.
  567.  
  568. DIAGNOSTICS
  569.     CHANGED FOR v0.3!!!
  570.     Returns zero if the string WAS successfully parsed.
  571.     Error codes will be formalized later.
  572.  
  573. SEE ALSO
  574.     Input Expressions and Description Strings
  575.  
  576.  
  577. NAME    CxObjError()
  578.  
  579.     LONG    error = CxObjError(co);
  580.  
  581.     CxObj    *co;
  582.  
  583. DESCRIPTION
  584.     When a function acting on an object fails, it records the failure
  585.     in the object's internal data.  This function returns the
  586.     accumulated error value.  The values are represented by flag
  587.     bits defined in "cxusr.h."  Several errors may be recorded
  588.     by multiple bits in 'error.'
  589.  
  590.     The possible errors (at current writing) are:
  591.  
  592.     COERR_ISNULL
  593.         The value of parameter 'co' was in fact NULL.  This error
  594.         means "the problem with the object you inquire about is
  595.         that it failed to be created."
  596.  
  597.     COERR_NULLATTACH
  598.         Using the Commodities list manipulation functions, an
  599.         attempt was made to add a NULL object to the list belonging
  600.         to 'co.'  This allows a line of code as follows to exist
  601.         in an error-tolerant program:
  602.  
  603.             AttachCxObj(filter, CxSender(myport, MY_ID));
  604.  
  605.     COERR_BADFILTER
  606.         The most recent filter specification for a Filter object
  607.         was faulty.  This happens if no sense can be made out
  608.         of a description string, or if an Input Expression (IX)
  609.         has in invalid format or version byte.  (See "ix.h.")
  610.  
  611.         When this bit is set in a filter's error field, the
  612.         filter will match nothing, but this is not the proper
  613.         way to "turn off" a filter.  Use ActivateCxObj().
  614.  
  615.     COERR_BADTYPE
  616.         A type specific operation, such as SetFilterIX(), was called
  617.         for object 'co,' but 'co' isn't of the proper type.
  618.  
  619. DIAGNOSTICS
  620.     Nothing but.
  621.  
  622. SEE ALSO
  623.     SetFilter(), SetFilterIX(), AttachCxObj(), ActivateCxObj(),
  624.     ClearCxObjError()
  625.  
  626.  
  627. NAME    ClearCxObjError()
  628.  
  629.     void    ClearCxObjError(co);
  630.  
  631.     CxObj    *co;
  632.  
  633. DESCRIPTION
  634.     Clears the accumulated error value of Commodities object 'co.'
  635.  
  636.     It is unwise to do this to a filter if COERR_BADFILTER is set.
  637.     This will fool the Commodities Exchange into thinking the
  638.     filter is OK.  Set another, valid, filter, or leave it alone.
  639.  
  640. DIAGNOSTICS
  641.     None.
  642.  
  643. SEE ALSO
  644.     CxObjError()
  645.  
  646.  
  647. NAME    CxMsgID()
  648.  
  649.     LONG    id = CxMsgID(cxm);
  650.  
  651.     CxMsg    *cxm;
  652.  
  653. DESCRIPTION
  654.     Returns the value associated with the cause or source of the
  655.     Commodities message 'cxm.'  Values are provided by the application
  656.     when a Sender or Custom object is created.
  657.  
  658. DIAGNOSTICS
  659.     If not specified by the application, the ID value of a Commodities
  660.     message will be null.  It is suggested that using non-null
  661.     values in your program as a rule may identify some possible errors.
  662.  
  663. SEE ALSO
  664.     CxSender()
  665.     CxCustom()
  666.  
  667.  
  668. NAME    AttachCxObj()
  669.  
  670.     void    AttachCxObj(headobj, co);
  671.  
  672.     CxObj    *headobj;
  673.     CxObj    *co;
  674.  
  675. DESCRIPTION
  676.     Appends object 'co' to the list of object 'headobj,' using the
  677.     Exec function AddTail().  Returns 'headobj.'
  678.  
  679. DIAGNOSTICS
  680.     If 'co' is null, this function will record that fact in the
  681.     internal accumulated error of 'headobj.'  This error record
  682.     can be retrieved using CxObjError() and cleared using
  683.     ClearCxObjError().
  684.  
  685. SEE ALSO
  686.     exec.library/AddTail()
  687.     Objects and Messages (in Reference Manual)
  688.     CxObjError(), ClearCxObjError()
  689.  
  690.  
  691. NAME    EnqueueCxObj()
  692.  
  693.     void    EnqueueCxObj(headobj, co);
  694.  
  695.     CxObj    *headobj;
  696.     CxObj    *co;
  697.  
  698. DESCRIPTION
  699.     Puts object 'co' into the list of object 'headobj,' using the
  700.     Exec function Enqueue().  Returns 'headobj.'
  701.  
  702.     This function uses the priority of the Commodities object as a node.
  703.     This priority can be set using SetCxObjPri().
  704.  
  705. DIAGNOSTICS
  706.     If 'co' is null, will record that fact in the internal accumulated
  707.     error of 'headobj.'  This error record can be retrieved using
  708.     CxObjError() and cleared using ClearCxObjError().
  709.  
  710. SEE ALSO
  711.     exec.library/Enqueue()
  712.     SetCxObjPri()
  713.     Objects and Messages (in Reference Manual)
  714.     CxObjError(), ClearCxObjError()
  715.  
  716.  
  717. NAME    InsertCxObj()
  718.  
  719.     void    InsertCxObj(headobj, co, pred);
  720.  
  721.     CxObj    *headobj;
  722.     CxObj    *co;
  723.     CxObj    *pred;
  724.  
  725. DESCRIPTION
  726.     Adds object 'co' to the list of object 'headobj,' using the
  727.     Exec function Insert().  Returns 'headobj.'
  728.  
  729.     As described in the autodocs for exec.library/Insert(), 'co' will
  730.     be inserted in the list of 'headobj' prior to 'pred.'  Even though
  731.     Insert() doesn't use the list header unless 'pred' is null, calling
  732.     InsertCxObj() you should always pass a valid 'headobj' and a possibly
  733.     null 'pred.'
  734.  
  735. DIAGNOSTICS
  736.     If 'co' is null, this will be recorded in the internal accumulated
  737.     error of 'headobj.'  This error record can be retrieved using
  738.     CxObjError() and cleared using ClearCxObjError().
  739.  
  740. SEE ALSO
  741.     exec.library/Insert()
  742.     Objects and Messages (in Reference Manual)
  743.     CxObjError(), ClearCxObjError()
  744.  
  745.  
  746. NAME    RemoveCxObj()
  747.  
  748.     void    RemoveCxObj(co);
  749.  
  750.     CxObj    *co;
  751.  
  752. DESCRIPTION
  753.     Removes Commodities object 'co' from any list he is be a part of.
  754.     Will not crash if 'co' is null, or if it has not been inserted
  755.     in a list (and is not corrupted).
  756.  
  757.     It is not recommended to remove a broker from the master list.
  758.  
  759. DIAGNOSTICS
  760.     None.
  761.  
  762. SEE ALSO
  763.     Objects and Messages (in Reference Manual)
  764.  
  765.  
  766. NAME    SetCxObjPri()
  767.  
  768.     void    SetCxObjPri(co, pri)
  769.  
  770.     CxObj    *co;
  771.     LONG    pri;
  772.  
  773. DESCRIPTION
  774.     This function sets the priority of a Commodities object for the
  775.     purposes of EnqueueCxObj().  Note that the Commodities list
  776.     mechanisms are based on Amiga Exec lists, so the priority is
  777.     recorded as a signed byte.  Please keep values in range.  A
  778.     value of zero is usually fine.
  779.  
  780.     It is strongly recommended that the ToolTypes environment be
  781.     utilized to provide end-user control over the priority of
  782.     brokers, but application specific ordering of other objects
  783.     within their lists is not dictated.
  784.  
  785. DIAGNOSTICS
  786.     None.
  787.  
  788. SEE ALSO
  789.     ToolTypes and the Commodities Environment (in Reference Manual)
  790.     EnqueueCxObj()
  791.  
  792.  
  793. NAME    FindBroker()
  794.  
  795.     CxObj    *broker = FindBroker(name);
  796.  
  797.     char    *name;
  798.  
  799. DESCRIPTION
  800.     Looks for a Commodities broker whose node name is 'name' in the
  801.     Commodities Object List.
  802.  
  803.     All uses of this function by applications are highly suspect.
  804.  
  805. DIAGNOSTICS
  806.     Returns NULL if 'name' not found.
  807.  
  808. SEE ALSO
  809.     Objects and Messages (in Reference Manual)
  810.  
  811.  
  812. NAME    CxMsgType()
  813.  
  814.     ULONG    type = CxMsgType(cxm);
  815.  
  816.     CxMsg    *cxm;
  817.  
  818. DESCRIPTION
  819.     Returns the type of a Commodities message.  Possible values of
  820.     'type' are found in "cxusr.h."  Most Commodities messages 
  821.     are Input Event messages.
  822.  
  823. DIAGNOSTICS
  824.     The value NULL should never be returned, if 'cxm' points to
  825.     a valid message.
  826.  
  827. SEE ALSO
  828.  
  829.  
  830. NAME    CxMsgData()
  831.  
  832.     char    *contents = CxMsgData(cxm);
  833.  
  834.     CxMsg    *cxm;
  835.  
  836. DESCRIPTION
  837.     Most Commodities messages contain meaningful data, such as an
  838.     InputEvent structure.  A pointer to this data may be obtained by
  839.     using this function.  A valid, non-null pointer will always
  840.     be returned if 'cxm' is valid.
  841.  
  842.     You may get a Commodities message from a synchronous (custom
  843.     object) or asynchronous (sender object) source.  In the second
  844.     case, 'contents' is not valid after you have replied to the message.
  845.  
  846. DIAGNOSTICS
  847.     If 'cxm' is null, returns NULL.
  848.  
  849. SEE ALSO
  850.     CxSender()
  851.     CxCustom()
  852.  
  853.  
  854. NAME    DisposeCxMsg()
  855.  
  856.     void    DisposeCxMsg(cxm);
  857.  
  858.     CxMsg    *cxm;
  859.  
  860. DESCRIPTION
  861.     Eliminates the Commodities message pointed to by 'cxm.'
  862.     Can be used to 'swallow' InputEvents by disposing of
  863.     every Commodities message of type CXM_IEVENT.
  864.  
  865. DIAGNOSTICS
  866.     None.
  867.  
  868. SEE ALSO
  869.  
  870.  
  871. NAME    RouteCxMsg()
  872.  
  873.     void    RouteCxMsg(cxm, co);
  874.  
  875.     CxMsg    *cxm;
  876.     CxObj    *co;
  877.  
  878. DESCRIPTION
  879.     Establishes the next destination of a Commodities message
  880.     to be 'co,' which must be a valid Commodities object, and
  881.     must be linked in ultimately to the Commodities Object List.
  882.  
  883.     Such a routing of an object is analogous to a 'goto' in a 
  884.     program.  There is no effect on the message's routing stack.
  885.  
  886. DIAGNOSTICS
  887.     None.
  888.  
  889. SEE ALSO
  890.     DivertCxMsg()
  891.  
  892.  
  893. NAME    DivertCxMsg()
  894.  
  895.     void    DivertCxMsg(cxm, headobj, returnobj);
  896.  
  897.     CxMsg    *cxm;
  898.     CxObj    *headobj;
  899.     CxObj    *returnobj;
  900.  
  901. DESCRIPTION
  902.     Sends Commodities message 'cxm' down the list of objects attached to
  903.     'headobj.'  The pointer 'returnobj' is first pushed onto the
  904.     routing stack of 'cxm' so that when the end of the list of 'headobj'
  905.     is reached the SUCCESSOR of 'returnobj' is the next destination.
  906.  
  907.     For example, when a filter finds a match with a message, the
  908.     message is diverted down the filter's list like this:
  909.  
  910.         DivertCxMsg(cxm, filter, filter);.
  911.  
  912. DIAGNOSTICS
  913.     None.
  914.  
  915. SEE ALSO
  916.     Reference Manual
  917.  
  918.  
  919. NAME    HotKey()  --    SCANNED LIBRARY
  920.  
  921.     CxObj    *filter = Hotkey(descr, port, ID);
  922.  
  923.     char            *descr;
  924.     struct MsgPort    *port;
  925.     LONG            ID;
  926.  
  927. DESCRIPTION
  928.     This function is not part of "commodities.library," but
  929.     is in the scanned library cx_support.lib.  It creates
  930.     a triad of Commodities objects to accomplish a high-level
  931.     function.
  932.  
  933.     The three objects are a filter, which is created to match
  934.     by the call CxFilter(descr), a sender created by the call
  935.     CxSender(port, ID), and a translator which is created by
  936.     CxTranslate(NULL), so that it swallows any Commodities
  937.     input event messages that are passed down by the filter.
  938.  
  939.     This is the simple way to get a message sent to your program
  940.     when the user performs a particular input action.
  941.  
  942.     It is strongly recommended that the ToolTypes environment
  943.     be used to allow the user to specify the input descriptions
  944.     for your application's hotkeys.
  945.  
  946. DIAGNOSTICS
  947.     Returns NULL and cleans up after itself if any problems occur
  948.     creating the objects.  It may be wise to test filter using
  949.     CxObjError() to insure that 'descr' was a valid description.
  950.  
  951. SEE ALSO
  952.     ToolTypes and the Commodities Environment (in Reference Manual)
  953.     CxFilter(), CxSender(), CxTranslate(), CxObjError()
  954.  
  955.  
  956. NAME    ArgArray    --    SCANNED LIBRARY
  957.  
  958.     char    **ttypes = ArgArrayInit(argc, argv);
  959.  
  960.     int        argc;
  961.     char    **argv;
  962.  
  963. DESCRIPTION
  964.     This function is not part of "commodities.library," but is
  965.     in "cx_support.lib."
  966.  
  967.     ArgArrayInit() returns a null-terminated array
  968.     of strings suitable for sending to the icon.library function
  969.     FindToolType().  This array will be the ToolTypes array of the
  970.     program's icon, if it was started from the workbench.  It will
  971.     be just 'argv' if the program was started from the CLI.
  972.  
  973.     NOTE WELL: Your C compiler must null terminate '*argv[]' for this
  974.     scheme to work.  Aztec does, in the version Commodities was
  975.     developed with.
  976.  
  977.     Pass ArgArrayInit() your startup arguments passed to main().
  978.  
  979.     ArgArrayInit() opens the icon.library (even if the caller was
  980.     started from a CLI, so that the function FindToolType() can 
  981.     be used) and may call GetDiskObject(), so clean up is necessary
  982.     when the strings are no longer needed.  The function ArgArrayDone()
  983.     does just that.
  984.  
  985.     Use of these routines facilitates the use of ToolTypes or command
  986.     line arguments to control end-user parameters in Commodities 
  987.     applications.  For example, a filter used to trap a keystroke for
  988.     popping up a window might be created by something like this:
  989.  
  990.     char    *ttypes = ArgArrayInit(argc, argv);
  991.     CxObj    *filter    = UserFilter(ttypes, "POPWINDOW", "alt f1");
  992.  
  993.     ... with ...
  994.  
  995.     CxObj    *
  996.     UserFilter(tt, action_name, default_descr)
  997.     char    **tt;            /* null-terminated (char *(*)[])    */
  998.     char    *action_name;    /* name of your semantic action        */
  999.     char    *default_descr;    /* used if user doesn't provide        */
  1000.     {
  1001.         char    *desc;
  1002.  
  1003.         desc = FindToolType(tt, action_name);
  1004.  
  1005.         return ( CxFilter(desc? desc: default_descr) );
  1006.     }
  1007.  
  1008.     In this way the user can assign "alt f2" to the action by
  1009.     entering a tooltype in the programs icon of the form:
  1010.  
  1011.         POPWINDOW=alt f2
  1012.  
  1013.     or by starting the program from the CLI with like so:
  1014.  
  1015.         myprogram "POPWINDOW=alt f2"
  1016.  
  1017. DIAGNOSTICS
  1018.     ArgArrayInit() would return NULL if any problems occured.
  1019.  
  1020. SEE ALSO
  1021.     ArgArrayDone()
  1022.     ArgString()
  1023.     ArgInt()
  1024.     icon.library/FindToolType()
  1025.     cx_support.lib probably will have UserFilter().
  1026.  
  1027. NAME    ArgArrayDone()        ---    SCANNED LIBRARY
  1028.  
  1029.     void    ArgArrayDone();
  1030.  
  1031. DESCRIPTION
  1032.     This function closes the disk object and Icon Library opened
  1033.     by ArgArrayInit().  Don't call this until you are done using
  1034.     the ToolTypes argument strings.
  1035.  
  1036. DIAGNOSTICS
  1037.     None.
  1038.  
  1039. SEE ALSO
  1040.     ArgArrayInit()
  1041.  
  1042. NAME    ArgString()        ---    SCANNED LIBRARY
  1043.  
  1044.     char    *string = ArgString(tt, string, defaultstring)
  1045.  
  1046.     char    **tt;
  1047.     char    *t;
  1048.     char    *defaultstring;
  1049.  
  1050. DESCRIPTION
  1051.     This function looks in the ToolTypes array 'tt' returned
  1052.     by ArgArrayInit() for the entry for 'string' and returns
  1053.     the "value" for 'string.'  The entry and value have the
  1054.     standard ToolTypes format such as:
  1055.  
  1056.         ENTRY=Value
  1057.  
  1058.     If an entry for 'string' is not found, the defaultstring
  1059.     will be returned.
  1060.  
  1061. DIAGNOSTICS
  1062.     None.
  1063.  
  1064. SEE ALSO
  1065.     ArgArrayInit()
  1066.  
  1067. NAME    ArgInt()        ---    SCANNED LIBRARY
  1068.  
  1069.     int    value = ArgInt(tt, string, defaultval)
  1070.  
  1071.     char    **tt;
  1072.     char    *t;
  1073.     int        defaultval;
  1074.  
  1075. DESCRIPTION
  1076.     This function looks in the ToolTypes array 'tt' returned
  1077.     by ArgArrayInit() for the entry for 'string' and returns
  1078.     the "value" for 'string.'  The entry and value have the
  1079.     standard ToolTypes format such as:
  1080.  
  1081.         ENTRY=Value
  1082.  
  1083.     In the case of this function, value will be passed through
  1084.     'atoi()' before returning.
  1085.  
  1086.     If an entry for 'string' is not found, the integer 'defaultval'
  1087.     will be returned.
  1088.  
  1089. DIAGNOSTICS
  1090.     None.
  1091.  
  1092. SEE ALSO
  1093.     ArgArrayInit()
  1094.  
  1095. NAME    InvertKeyMap()
  1096.  
  1097.     ULONG    retval = InvertKeyMap(ansicode, ie, km)
  1098.  
  1099.     ULONG                ansicode;
  1100.     struct InputEvent    *ie;
  1101.     struct KeyMap        *km;
  1102.  
  1103. DESCRIPTION
  1104.     Figures out what InputEvent translates to an ANSI character code
  1105.     'ansicode.'  The InputEvent pointed to by 'ie' is filled in
  1106.     with that information.  The KeyMap 'km' is used, unless it
  1107.     is NULL, in which case the system standard keymap (as defined
  1108.     when commodities.library is initialized) is used.
  1109.  
  1110.     This function currently handles one-deep dead keys (such as
  1111.     <alt f>o).  It does not look up the high key map (keystrokes
  1112.     with scan codes greater than 0x40), and misses system changes to
  1113.     the default key map.
  1114.  
  1115. DIAGNOSTICS
  1116.     Returns non-negative value if it worked, less than zero, with
  1117.     error values to be defined in the future.
  1118.  
  1119. SEE ALSO
  1120.     InvertString()
  1121.  
  1122. NAME    InvertString()    --    SCANNED LIBRARY
  1123.  
  1124.     struct InputEvent    *InvertString(str, km)
  1125.  
  1126.     char            *str;
  1127.     struct KeyMap    *km;
  1128.  
  1129. DESCRIPTION
  1130.     This function returns a linked list of input events which would
  1131.     translate into the string using the keymap 'km' (of the system
  1132.     default keymap if 'km' is NULL).
  1133.  
  1134.     The null-terminated 'str' may contain:
  1135.     -ANSI character codes
  1136.     -backslash escaped characters: 
  1137.         \n    -    return
  1138.         \r    -    return
  1139.         \t    -    tab
  1140.         \0    -    don't use this, ok?
  1141.         \\    -    backslash
  1142.     -a text description of an input event as used by ParseIX(),
  1143.      enclosed in angle brackets.
  1144.  
  1145.     An example is:
  1146.         abc<alt f1>\nhi there.
  1147.  
  1148.     NOTE: you are responsible for freeing the InputEvents that this
  1149.     function allocates.  You may use FreeIEvents().
  1150.  
  1151. DIAGNOSTICS
  1152.     Returns NULL if there is a problem, most often an illegal description
  1153.     enclosed in angles.
  1154.  
  1155. SEE ALSO
  1156.     ParseIX()
  1157.     FreeIEvents()
  1158.  
  1159. NAME    AddIEvents()
  1160.  
  1161.     void    AddIEvents(ie)
  1162.  
  1163.     struct InputEvent    *ie;
  1164.  
  1165. DESCRIPTION
  1166.     This function adds a null-terminated linked list to the input
  1167.     stream of Commodities.  It is a touch easier than using the
  1168.     input device directly.
  1169.  
  1170.     The contents of the input events are copied into Commodities internal
  1171.     messages, so they may be disposed of as soon as this call returns.
  1172.  
  1173.     The messages are initially routed to the first Broker in the
  1174.     Commodities Object List.
  1175.  
  1176. DIAGNOSTICS
  1177.     None.
  1178.  
  1179. SEE ALSO
  1180.     FreeIEvents()
  1181.