SILC_STR_*_NSTRING
NAME
#define SILC_STR_UI8_NSTRING() ...
#define SILC_STR_UI8_NSTRING_ALLOC() ...
#define SILC_STR_UI16_NSTRING() ...
#define SILC_STR_UI16_NSTRING_ALLOC() ...
#define SILC_STR_UI32_NSTRING() ...
#define SILC_STR_UI32_NSTRING_ALLOC() ...
DESCRIPTION
Unsigned string. Second argument is the length of the string.
Formatting: SILC_STR_UI32_NSTRING(unsigned char *, SilcUInt32)
Unformatting: SILC_STR_UI32_NSTRING(unsigned char **, SilcUInt32 *)
Unformatting procedure will check for length of the string from the
buffer before trying to get the string out. Thus, one *must* format the
length as UI_INT or UI_SHORT into the buffer *before* formatting the
actual string to the buffer, and, in unformatting one must ignore the
length of the string because unformatting procedure will take it
automatically.
Example:
Formatting: ..., SILC_STR_UI_INT(strlen(string)),
SILC_STR_UI32_NSTRING(string, strlen(string)), ...
Unformatting: ..., SILC_STR_UI32_NSTRING(&string, &len), ...
I.e., you can ignore the formatted length field in unformatting. The
length taken from the buffer is returned to the pointer sent as
argument (&len in above example).
UI8, UI16 and UI32 means that the length is considered to be
either char (8 bits), short (16 bits) or int (32 bits) in
unformatting.
_ALLOC routines automatically allocates memory for the variable sent
as argument in unformatting.
|