TipcMtTraverse


Name

TipcMtTraverse — traverse all message types

Synopsis

T_PTR TipcMtTraverse(func, arg) 
T_IPC_MT_TRAV_FUNC func; 
T_PTR arg; 

Arguments

func — function to call once for each message type

arg — user-defined argument to pass to func

Return Values

The first non-null return value from func, or NULL if func always returns NULL.

Diagnostics

If TipcMtTraverse fails or traverses all message types, it returns NULL and sets the global SmartSockets error number to one of:

Description

TipcMtTraverse traverses all message types and calls func once for each message type. When func returns a non-null value, then TipcMtTraverse returns with that value.

Caution

The traversal function must always return a value and must return NULL for the traversal to continue.

The T_ENTRY declaration specifier is required in the definition of all callback functions as well as their prototypes.

The order that the message types are traversed is not controllable by users.

If TipcMtTraverse returns NULL, it may be because there was an error or simply because func always returned NULL. If func always returns NULL, then the global SmartSockets error number is set to T_ERR_END_OF_TRAVERSAL.

See Also

TipcMtPrint; see TIBCO SmartSockets Utilities for information on TutHashTraverse.

Examples

This example prints the names and numbers of all message types:

T_PTR T_ENTRY print_one_mt(name, mt, arg) 
T_STR name; 
T_IPC_MT mt; 
T_PTR arg; /* not used */ 
{ 
  T_INT4 num; 
 
  /* could use TipcMtGetName, but easier to use name argument */ 
  TutOut("Message type name is %s.\n", name); 
 
  if (!TipcMtGetNum(mt, &num)) { 
    return;  /* error */ 
  }  
  TutOut("Message type number is %d.\n", num); 
 
  return NULL; /* continue traversal */ 
} /* print_one_mt */ 
 
/* =========================================================== */ 
/*...code from calling function is below */ 
 
(void)TipcMtTraverse(print_one_mt, NULL); 
 

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