TutCbSetArgument


Name

TutCbSetArgument — set the callback argument used by the specified callback

Synopsis

T_BOOL TutCbSetArgument(cb, arg) 
T_CB cb; 
T_CB_ARG arg; 

Arguments

cb — callback to set the argument of

arg — new value for the callback argument

Return Values

TRUE if successful, FALSE otherwise.

Diagnostics

None

Description

This function sets the callback argument that is used the next time cb is called. This ability means you can affect existing callbacks without having to destroy and recreate the callback.

Caution

The callback list to which cb belongs is searched to make sure arg and the existing callback function do not match any existing callbacks in the list. If a match is found, the function returns FALSE.

The callback routines do not make a copy of the argument provided. Caller must manage the storage pointed to. This means that the address of an automatic variable, for example, should not be used as arg.

See Also

TutCbGetArgument

Examples

This example gets the argument of a callback and prints it out:

static void T_ENTRY time_change_cb(dummy, data, arg) 
T_PTR dummy; /* always NULL */ 
T_TIME_CHANGE_CB_DATA data; 
T_CB_ARG arg; 
{ 
  TutOut("Time change callback called, argument: %s\n", arg); 
 
  if (T_STREQI(arg, "hello")) { 
  TutCbSetArgument(data->cb, "bye"); 
  } 
  else { 
    TutCbSetArgument(data->cb, "hello"); 
  } 
} 
... 
T_CB cb; 
T_PTR cb_arg; 
 
cb = TutTimeChangeCbCreate(time_change_cb, "hello"); 
 
/* other code */ 
 
if (!TutCbGetArgument(cb, &cb_arg)) { 
  /* error */ 
} 
TutOut("Callback argument: %s\n", (T_STR)cb_arg); 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com