TutOptionChangeCbCreate create a callback that is called when an option value changes
T_CB TutOptionChangeCbCreate(option, change_func, arg
) T_OPTIONoption
; T_OPTION_CHANGE_CB_FUNCchange_func
; T_CB_ARGarg
;
option
option to register the change callback for; NULL
if callback is to be registered for all options
change_func
callback function
arg
callback function argument
New callback if successful, NULL
otherwise.
If TutOptionChangeCbCreate fails, it returns NULL
and sets the global SmartSockets error number to one of:
TutOptionChangeCbCreate attaches the change_func
callback to option
. When the value of option
changes, change_func
is called with three arguments:
The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.
This example prints the value of bool_opt
when its value changes:
/* This callback function is called when the */
/* value of option "bool_opt" changes. */
void T_ENTRY BoolChanged(option, data, arg) T_OPTION option; T_OPTION_CHANGE_CB_DATA data; T_CB_ARG arg; { T_BOOL bool_return; if (!TutOptionGetBool(option, &bool_return)) {/* error */
} if (bool_return) { TutOut("Value of option %s is TRUE\n", TutOptionGetName(option)); } else { TutOut("Value of option %s is FALSE\n", TutOptionGetName(option)); } }/* BoolChanged */
/* Below is a code fragment that could go into an initialization routine. */
T_OPTION option; T_CB cb; option = TutOptionCreate("bool_opt", T_OPT_TYPE_BOOLEAN); if (option == NULL) {/* error */
} cb = TutOptionChangeCbCreate(option, BoolChanged, NULL); if (cb == NULL) {/* error */
}
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |