DX Infrastructure Manager

Expand all | Collapse all

How to get the PDS arguments from NIMCB* in a callback ?

Jump to Best Answer
  • 1.  How to get the PDS arguments from NIMCB* in a callback ?

    Posted 09-16-2009 03:29 AM
    Within my callback function that takes an argument of NIMCB *cb, how do I get the PDS arguments ?


  • 2.  How to get the PDS arguments from NIMCB* in a callback ?
    Best Answer

    Posted 09-16-2009 01:26 PM
    This depends on the SDK, but from your declaration it looks like you're using the C SDK.
    You have 2 options (depending on your version of the SDK),

    Option 1:
    If you are using the nimSessionAddCallback function the parameters are
    added to your call interface in the same order that you declared it. E.g

    nimSessionAddCallback(nims,"get_info",  cbGetInfo,  "name,address", 0);

    static int cbGetInfo (NIMCB * cb, char *name, char *addr)
    {
       :
    }

    Option 2:
    Use nimSessionAddCallbackPds function then the argument PDS is the second parameter to your function.

    nimSessionAddCallbackPds(nims,"note_detach",  cbNoteDetach,  "note_id%d,nimid", 0);

    static int cbNoteDetach (NIMCB * cb, PDS *pdsArgs)
    {
        extern    int    NoteDetach();

        int        rc=NIME_INVAL;
        char    **ppNimIds = NULL;

        long note_id = 0;
        char *nimid = NULL;

        if (pdsArgs)
        {
            pdsGet_LONG(pdsArgs,"note_id",&note_id);
            pdsGet_CPCH(pdsArgs,"nimid",&nimid);
        }

    :

    Note that we added option 2 due to issues we discovered during our 64-bit
    ports regarding transferring data (particulary integers) on the stack 
    So our general rule is, if you have integers in the parameter list for
    your callback, then use option 2.  I would suggest that you implement
    on option 2 regardless, since it makes use of a single callbackfunction
    for readability.

    Carstein


  • 3.  How to get the PDS arguments from NIMCB* in a callback ?

    Posted 09-16-2009 11:09 PM
    I used option 2 and it works like a charm, thank you.