TipcMsgAddNamedMsgArrayPtr add a field containing an array of MSG fields to a message using a name, and a pointer to the field value, rather than a copy
T_BOOL TipcMsgAddNamedMsgArrayPtr(msg
,name
,value
,size
,field_return
) T_IPC_MSGmsg
; T_STRname
; T_MSG *value
; T_INT4size
; T_IPC_MSG_FIELD *field_return
;
msg
message to add field to
name
name of the field
value
value of the field
size
number of elements in the field
field_return
optional value to return field (use NULL
if not needed)
TRUE
if the addition was successful, FALSE
otherwise.
If TipcMsgAddNamedMsgArrayPtr fails, it returns FALSE
and sets the global SmartSockets error number to:
TipcMsgAddNamedMsgArrayPtr adds a field containing an array of MSG fields to a message, associating that field with a name. If the name already exists in the message, this fails, and the field is not added to the message. The value given is used as a pointer to the value, so the copy is made when the message is actually sent, not when the call is made. You must ensure that the data pointed to remains valid until the message is sent.
TipcMsgAppendMsgArrayPtr, TipcMsgUpdateNamedMsgArrayPtr, TipcMsgFieldUpdateMsgArrayPtr
This example creates a message and adds a pointer to a MSG_ARRAY value to it:
T_IPC_MT mt; T_IPC_MSG msg; #define ARRAY_SIZE 3 T_IPC_MSG msg_array_data[ARRAY_SIZE]; #define USER_MT_CONTAINER 3 mt = TipcMtCreate("container", USER_MT_CONTAINER, "msg_array"); if (mt == NULL) {return
; /* error */
} msg = TipcMsgCreate(mt); if (msg == NULL) {return
; /* error */
} mt = TipcMtLookupByNum(T_MT_TIME); if (mt == NULL) {return
; /* error */
} msg_array_data[0] = TipcMsgCreate(mt); if (msg_array_data[0] == NULL) {return
; /* error */
} mt = TipcMtLookupByNum(T_MT_NUMERIC_DATA); if (mt == NULL) {return
; /* error */
} msg_array_data[1] = TipcMsgCreate(mt); if (msg_array_data[1] == NULL) {return
; /* error */
} mt = TipcMtLookupByNum(T_MT_END_OF_FRAME); if (mt == NULL) {return
; /* error */
} msg_array_data[2] = TipcMsgCreate(mt); if (msg_array_data[2] == NULL) {return
; /* error */
} if (!TipcMsgAddNamedMsgArrayPtr(msg, "named_msg_array", msg_array_data, ARRAY_SIZE, NULL)) {return
; /* error */
} if (!TipcMsgAppendReal8(msg_array_data[0], TutGetWallTime())) {return
; /* error */
} if (!TipcMsgAppendStrReal8(msg_array_data[1], "speed_limit", 70.0)) {return
; /* error */
}
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |