STRUCTS_TYPE_STRING(3)

NAME
structs_type_string, structs_type_string_null, - structs types for strings

LIBRARY
PDEL Library (libpdel, -lpdel)

SYNOPSIS
#include <sys/types.h>
#include <pdel/structs/structs.h>
#include <pdel/structs/type/string.h>
STRUCTS_STRING_TYPE(mtype, asnull);
STRUCTS_FIXEDSTRING_TYPE(bufsize);
extern const struct structs_type structs_type_string;
extern const struct structs_type structs_type_string_null;

DESCRIPTION
The STRUCTS_STRING_TYPE() and STRUCTS_FIXEDSTRING_TYPE() macros define a structs(3) type (i.e., a struct structs_type) for describing variable and bounded length strings, respectively.

STRUCTS_STRING_TYPE() describes a char * data type which points to a string buffer allocated with typed_mem(3) type mtype. If asnull is non-zero, then an empty string may be represented as a NULL pointer; otherwise, the char * pointer can never be NULL (or else the program may core dump) and so the empty string must always be represented as a pointer to a zero length string.

STRUCTS_FIXEDSTRING_TYPE() describes an array of char having length bufsize in which a string having length at most bufsize - 1 is stored. The string is always terminated with a '\0' byte.

The structs(3) library supplies two pre-defined variable length string types, structs_type_string and structs_type_string_null. Both types use the typed_mem(3) type STRUCTS_TYPE_STRING_MTYPE, defined in the header file. structs_type_string represents empty strings as pointers to an empty string, while structs_type_string_null represents empty strings as NULL pointers.

SEE ALSO
libpdel(3), structs(3), structs_type(3), typed_mem(3)

HISTORY
The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

AUTHORS
Archie Cobbs <archie@packetdesign.com>