TipcMsgFileWrite


Name

TipcMsgFileWrite — write a message to a message file

Synopsis

T_BOOL TipcMsgFileWrite(msg_file, msg) 
T_IPC_MSG_FILE msg_file; 
T_IPC_MSG msg; 

Arguments

msg_file — message file

msg — message to write to message file

Return Values

TRUE if the message was successfully written to the message file, FALSE otherwise.

Diagnostics

If TipcMsgFileWrite fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

TipcMsgFileWrite writes a message to a message file. See TipcMsgFileCreate for more information on message files.

Text Message Files

TipcMsgFileWrite writes the message type, then the destination (or _null if the destination is null), and finally writes the fields to the file. The message source and priority are not written to the file. After all output has been written to the file, TipcMsgFileWrite flushes the file to disk.

TipcMsgFileWrite first looks up the message type with TipcMtLookupByNum. If the message type does not exist (this can happen if a process such as RTserver receives a message for which it has not created a message type with TipcMtCreate), then TipcMsgFileWrite writes the message type number (for example, 22); otherwise it writes the message type name (for example, numeric_data).

The message fields are written to the file in a verbose format if the message type does not exist or the message type grammar is "verbose". The verbose format uses a type name and value for each field (such as real8 34.567891). Arrays are delimited by {}.

If the verbose format is not used, then only the value is used for each field (such as 34.567891). The message type grammar is used to help format the output. Both groups and arrays are delimited by {}.

Caution

For text message files, TipcMsgFileWrite fails if the fields in the message do not match the grammar of the message type (for example, the number of fields in the grammar is not the same as the number of fields in the message, or the types of the fields in the grammar do not match the types of the fields in the message).

See Also

TipcMsgFileRead, TipcMtCreate, TipcMtLookup, TipcMtLookupByNum

Examples

This example creates a NUMERIC_DATA message and writes it to the message file data.msg:

T_IPC_MSG_FILE msg_file; 
T_IPC_MT mt; 
T_IPC_MSG msg; 
 
msg_file = TipcMsgFileCreate("data.msg", 
T_IPC_MSG_FILE_CREATE_WRITE); 
if (msg_file == NULL) { 
  return;  /* error */ 
}  
 
mt = TipcMtLookupByNum(T_MT_NUMERIC_DATA); 
if (mt == NULL) { 
  return;  /* error */ 
}  
 
msg = TipcMsgCreate(mt); 
if (msg == NULL) { 
  return;  /* error */ 
}  
 
if (!TipcMsgSetDest(msg, "/system/thermal")) { 
  return;  /* error */ 
} 
  
if (!TipcMsgAppendStrReal8(msg, "bat1_voltage", 42.4)) { 
  return;  /* error */ 
} 
if (!TipcMsgFileWrite(msg_file, msg)) { 
  return;  /* error */ 
}  

The output from this message in data.msg would look like:

numeric_data /system/thermal { 
  bat1_voltage 42.4000000 
} 

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