VgaGames4

VgaGames4 - miscellaneous man-pages

[.. upper level ..]

# vg4->misc->strccat()

Concatenate all strings into a buffer with a maximal size.

SYNTAX
size_t vg4->misc->strccat(char *dest, size_t dsize, ...)
FUNCTION PARAMETERS

dest | Destination buffer
dsize | Maximal bytes to copy including terminating null
... | Further parameters are strings, last parameter must be NULL

RETURN VALUE
Returns the number of copied bytes (excluding terminating null)
DESCRIPTION
Concatenate all strings into a buffer with a maximal size. Concatenate all strings into dest with maximal size of dsize (including terminating null), dest will always be null-terminated and remaining space will be filled with 0. The last parameter must be NULL. This function does not copy more than dsize bytes (including terminating null). If the copying was truncated due to this limit, then the return value is the number of bytes (excluding terminating null), which would have been copied if enough space had been available. Thus, a return value of dsize or more means that the copying was truncated.
EXAMPLE

    char buf[128];
    const char *homep = "/home/fred";
    const char *dirp = "subdir1/subdir2";
    const char *filep = "freds_file.txt";
    size_t slen;

    /* copy path to filep includig filep into buf */
    slen = vg4->misc->strccat(buf, sizeof(buf), homep, "/", dirp, "/", filep, NULL);
    if (slen >= sizeof(buf)) { fprintf(stderr, "buf is too small\n"); }