#include <stdarg.h>
#include <stdlib.h>
Go to the source code of this file.
|
| 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.
|
| |
| 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.
|
| |
| size_t | _daq_strlremainder (const char *src, size_t size) |
| | Return the number of usable bytes left at the end of the given string.
|
| |
| size_t | _daq_slprintf (char *dst, size_t size, const char *fmt,...) |
| | a length aware printf that appends to dst.
|
| |
◆ _daq_slprintf()
| size_t _daq_slprintf |
( |
char * |
dst, |
|
|
size_t |
size, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
a length aware printf that appends to dst.
- Parameters
-
| dst | The destination character array to append data to |
| size | The total size of the destination buffer |
| fmt | The 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. @notes Use this as snprintf, except that the size is the total buffer size, not just the remaining amount.
◆ _daq_strlcat()
| 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
-
| dst | Pointer 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). |
| src | Source buffer, which must be a NULL terminated string |
| size | the 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.
◆ _daq_strlcpy()
| 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
-
| dst | Pointer to the destination which is at least size bytes long |
| src | Source buffer, which must be a NULL terminated string |
| size | the 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
◆ _daq_strlremainder()
| 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
-
| src | A NULL terminated string |
| size | The 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).