libhpdftbl 1.5.0
Table construction library for Haru PDF library
Loading...
Searching...
No Matches
xstr.c File Reference

Safe version of strncat() and strncpy() taken from the BSD stdlib. More...

#include "stdio.h"
#include "stdlib.h"
#include "string.h"

Functions

size_t xstrlcpy (char *__restrict dst, const char *__restrict src, size_t dsize)
 Safe string copy. More...
 
size_t xstrlcat (char *dst, const char *src, size_t siz)
 Safe string concatenation. More...
 

Detailed Description

Safe version of strncat() and strncpy() taken from the BSD stdlib.

Function Documentation

◆ xstrlcat()

size_t xstrlcat ( char *  dst,
const char *  src,
size_t  siz 
)

Safe string concatenation.

Appends src to string dst of size siz (unlike strncat, siz is the full size of dst, not space left). At most siz-1 characters will be copied. Always NUL terminates (unless siz <= strlen(dst)). Returns strlen(src) + MIN(siz, strlen(initial dst)). If retval >= siz, truncation occurred.

Taken from BSD library.

Parameters
dstDestination buffer
srcSource buffer
sizMax size of destination buffer including terminating NULL
Returns
The number of bytes needed to be copied. If this is > siz then data truncation happened.

Referenced by hpdftbl_read_file(), and mkfullpath().

◆ xstrlcpy()

size_t xstrlcpy ( char *__restrict  dst,
const char *__restrict  src,
size_t  dsize 
)

Safe string copy.

Copy string src to buffer dst of size dsize. At most dsize-1 chars will be copied. Always NUL terminates (unless dsize == 0). Returns strlen(src); if retval >= dsize, truncation occurred.

Taken from BSD library.

Parameters
dstDestination string
srcSource string
dsizeMaximum size of destination
Returns
strlen(src); if retval >= dsize, truncation occurred.