HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Working with SIP Messages 155
Working with SIP Messages
To encode a SIP message
1. Call the RvSipMsgEncode() function with the message handle
and the pool handle. The Encode() function receives the pool
handle and returns a handle to the new page containing the
encoded string and the length of the encoded string.
2. Allocate a buffer of the same length as the retrieved length, +1
if you want to place '\0' at the end.
3. Call the RPOOL_CopyToExternal() function—with the offset
parameter set to zero—to copy the encoded string from the
memory pool page to the allocated buffer.
Note The encoded string in the memory page is not necessarily consecutive.
Therefore, you must not use strcpy. Also, the string is not NULL-terminated so
you should insert the NULL value manually if required.
Sample Code
The following code demonstrates how to encode a message and copy it to a new
buffer and how to print the encoded message to the screen.