TipcMsgTraverse traverse all fields in a message
msg
message whose fields are traversed
func
function to call once for each field
arg
user-defined argument to pass to func
The first non-null return value from func
, or NULL
if func
always returns NULL
.
If TipcMsgTraverse fails or traverses all the fields in msg
, it returns NULL
and sets the global SmartSockets error number to one of:
TipcMsgTraverse traverses a message’s data fields in order and calls func
once for each field. When func
returns a non-null value, then TipcMsgTraverse returns with that value.
One of the arguments passed to func
is a T_IPC_MSG_TRAV pointer. This data structure contains a pointer to the field type (which is stored as a two-byte integer to save space), a pointer to the field value, and the array size. (Array size is set only if the field is an array type.)
If TipcMsgTraverse returns NULL
, it may be because there was an error or simply because func
always returned null.
This example prints a message’s field types:
T_PTR T_ENTRY print_one_field(msg, trav, arg) T_IPC_MSG msg; T_IPC_MSG_TRAV trav; T_PTR arg;/* really (T_INT4 *) */
{ T_INT4 *counter_ptr = arg; TutOut(" Field %d:\n", *counter_ptr); (*counter_ptr)++; TutOut(" Type: %d\n", (T_IPC_FT)(*trav->type_ptr)); return NULL;/* continue traversal */
}/* print_one_field */
void print_field_offsets(msg) T_IPC_MSG msg; { T_INT4 num_fields; T_INT4 counter; if (!TipcMsgGetNumFields(msg, &num_fields)) {return
; /* error */
} TutOut("This message has %d fields.\n", num_fields); counter = 1; (void)TipcMsgTraverse(msg, print_one_field, &counter); }/* print_field_offsets */
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |