Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stralloc(3) [debian man page]

stralloc(3)						     Library Functions Manual						       stralloc(3)

NAME
stralloc - dynamically allocated strings SYNTAX
#include <stralloc.h> int stralloc_ready(&sa,len); int stralloc_readyplus(&sa,len); int stralloc_copy(&sa,&sa2); int stralloc_copys(&sa,buf); int stralloc_copyb(&sa,buf,len); int stralloc_cat(&sa,&sa2); int stralloc_cats(&sa,buf); int stralloc_catb(&sa,buf,len); int stralloc_append(&sa,buf); int stralloc_0(&sa); int stralloc_starts(&sa,buf); stralloc sa = {0}; stralloc sa2 = {0}; unsigned int len; char *buf; DESCRIPTION
A stralloc variable holds a string in dynamically allocated space. String length is limited only by memory. String contents are unre- stricted. The stralloc structure has three components: sa.s is a pointer to the string, or 0 if it is not allocated; sa.len is the number of bytes in the string, if it is allocated; sa.a is the number of bytes allocated for the string, if it is allocated. A stralloc variable should be initialized to {0}, meaning unallocated. stralloc_ready makes sure that sa has enough space allocated for len characters. It allocates extra space if necessary. stralloc_readyplus makes sure that sa has enough space allocated for len characters more than its current length. If sa is unallocated, stralloc_readyplus is the same as stralloc_ready. stralloc_copy copies sa2 to sa, allocating space if necessary. Here sa2 is an allocated stralloc variable. stralloc_copys copies a 0-terminated string, buf, to sa, without the 0. stralloc_copyb copies len characters from buf to sa. stralloc_cat appends sa2 to sa, allocating space if necessary. If sa is unallocated, stralloc_cat is the same as stralloc_copy. stralloc_cats and stralloc_catb are analogous to stralloc_copys and stralloc_copyb. stralloc_append adds a single character, *buf, to sa, allocating space if necessary. stralloc_0 adds a single 0 character to sa. stralloc_starts returns 1 if the 0-terminated string buf, without the 0, is a prefix of sa. ERROR HANDLING
If a stralloc routine runs out of memory, it leaves sa alone and returns 0, setting errno appropriately. On success it returns 1; this guarantees that sa is allocated. SEE ALSO
alloc(3), error(3) stralloc(3)

Check Out this Related Man Page

CONFSTR(3)						   BSD Library Functions Manual 						CONFSTR(3)

NAME
confstr -- get string-valued configurable variables LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> size_t confstr(int name, char *buf, size_t len); DESCRIPTION
This interface is specified by IEEE Std 1003.1-2001 (``POSIX.1''). A more flexible (but non-portable) interface is provided by sysctl(3). The confstr() function provides a method for applications to get configuration defined string values. Shell programmers needing access to these parameters should use the getconf(1) utility. The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file <unistd.h>. The len argument specifies the size of the buffer referenced by the argument buf. If len is non-zero, buf is a non-null pointer, and name has a value, up to len - 1 bytes of the value are copied into the buffer buf. The copied value is always null terminated. The available values are as follows: _CS_PATH Return a value for the PATH environment variable that finds all the standard utilities. RETURN VALUES
If the call to confstr() is not successful, 0 is returned and errno is set appropriately. Otherwise, if the variable does not have a config- uration defined value, 0 is returned and errno is not modified. Otherwise, the buffer size needed to hold the entire configuration-defined value is returned. If this size is greater than the argument len, the string in buf was truncated. ERRORS
The confstr() function may fail and set errno for any of the errors specified for the library functions malloc(3) and sysctl(3). In addition, the following errors may be reported: [EINVAL] The value of the name argument is invalid. SEE ALSO
getconf(1), pathconf(2), sysconf(3), sysctl(3) HISTORY
The confstr() function first appeared in 4.4BSD. BSD
December 3, 2006 BSD
Man Page