nds2-client - ClientDeveloper  0.16.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
daq_bsd_string.h File Reference
#include <stdarg.h>
#include <stdlib.h>
Include dependency graph for daq_bsd_string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t _daq_strlcpy (char *dst, const char *src, size_t size)
 Copy from src to dest. This copies from src to dest. It will always null terminate dest. More...
 
size_t _daq_strlcat (char *dst, const char *src, size_t size)
 Append src to dest. This copies from src to the end of dest. It will always null terminate dest. More...
 
size_t _daq_strlremainder (const char *src, size_t size)
 Return the number of usable bytes left at the end of the given string. More...
 
size_t _daq_slprintf (char *dst, size_t size, const char *fmt,...)
 a length aware printf that appends to dst. More...
 

Function Documentation

size_t _daq_slprintf ( char *  dst,
size_t  size,
const char *  fmt,
  ... 
)

a length aware printf that appends to dst.

Parameters
dstThe destination character array to append data to
sizeThe total size of the destination buffer
fmtThe format to apply, interpreted by printf
...The arguments to format
Returns
The size of the string after printing, if it is larger than size then the string is truncated. Use this as snprintf, except that the size is the total buffer size, not just the remaining amount.
size_t _daq_strlcat ( char *  dst,
const char *  src,
size_t  size 
)

Append src to dest. This copies from src to the end of dest. It will always null terminate dest.

Parameters
dstPointer to the destination which is at least size bytes long (this is the total size, including existing content, not just the remaining buffer space available).
srcSource buffer, which must be a NULL terminated string
sizethe length of dst (including space for a NULL byte)
Returns
The size of the string that was requested, ie strlen(src) + strlen(dst). This is done to match the bsd interface, which uses this feature to detect truncation when the return value is >= size.
Note
if src == NULL or dst == NULL or size == 0 this will do nothing
In a difference from the bsd version, strlcat ALWAYS null terminates if size > 0.
size_t _daq_strlcpy ( char *  dst,
const char *  src,
size_t  size 
)

Copy from src to dest. This copies from src to dest. It will always null terminate dest.

Parameters
dstPointer to the destination which is at least size bytes long
srcSource buffer, which must be a NULL terminated string
sizethe length of dst (including space for a NULL byte)
Returns
The size of the string that was requested, ie strlen(src). This is done to match the bsd interface, which uses this feature to detect truncation when the return value is >= size.
Note
if src == NULL or dst == NULL or size == 0 this will do nothing and will return 0
size_t _daq_strlremainder ( const char *  src,
size_t  size 
)

Return the number of usable bytes left at the end of the given string.

Parameters
srcA NULL terminated string
sizeThe maximum size of the string (counting the NULL terminator)
Returns
The number of bytes that can be appended to the string while staying withing a max size of size bytes (counting the NULL terminator).