HTML automatically generated with rman
Table of Contents

Name

getxstr, putxstr, copxstr, xstrlen, xstreq - extended string functions

Synopsis


#include <stdinc.h>#include <extstring.h>void *getxstr(str, nbyt)stream str;int
nbyt;
bool putxstr(str, xstr, nbyt)stream str;void *xstr;int nbyt;
void *copxstr(xstr,
nbyt)void *xstr;int nbyt;
int xstrlen(xstr, nbyt)void *xstr;int nbyt;
bool
xstreq(xstr1, xstr2, nbyt)void *xstr1, *xstr2;int nbyt;

Description

These routines extend the usual C notion of NULL-terminated character strings to strings of nbyt-byte values, terminated by nbyt NULL bytes. For example, on a 32-bit machine, an int takes 4 bytes, so an extended string of ints is a sequence of 4-byte values, terminated by 4 NULL bytes.

getxstr and putxstr perform I/O of extended strings via the usual stdio(3) primatives. getxstr reads nbyt-long values from the input stream str until it encounters nbyt NULL bytes. It stores the values in space dynamically allocated using malloc(3) and returns a pointer to the extended string, or NULL on end of file or error. putxstr writes an extended string xstr of nbyt-long values, including the terminating NULLs, to an output stream str. It returns TRUE unless an I/O error occured.

copxstr copies its extended string argument xstr to space allocated using malloc.

xstrlen counts the number of nbyt-long values in xstr, including the terminating NULL-value.

xstreq compares extended strings, and returns TRUE if they are equal.

See Also

stdio(3) , malloc(3)

Diagnostics

Low-level catastrophies (eg, running out of memory) generate messages via error(3) .

History


24-jul-95    document written    JEB
18-feb-04    char->void    PJT