Back to index

im-sdk  12.3.91
Functions
genutil.c File Reference
#include <string.h>
#include <sys/types.h>

Go to the source code of this file.

Functions

size_t _genutil_strlcat (char *dst, const char *src, size_t dstsize)
size_t _genutil_strlcpy (char *dst, const char *src, size_t len)

Function Documentation

size_t _genutil_strlcat ( char *  dst,
const char *  src,
size_t  dstsize 
)

Definition at line 55 of file genutil.c.

{
       size_t l1 = strlen(dst);
       size_t l2 = strlen(src);
       size_t copied;

       if (dstsize == 0 || l1 >= dstsize - 1)
              return (l1 + l2);

       copied = l1 + l2 >= dstsize ? dstsize - l1 - 1 : l2;
       memcpy(dst + l1, src, copied);
       dst[l1+copied] = '\0';
       return (l1 + l2);
}

Here is the caller graph for this function:

size_t _genutil_strlcpy ( char *  dst,
const char *  src,
size_t  len 
)

Definition at line 77 of file genutil.c.

{
       size_t slen = strlen(src);
       size_t copied;

       if (len == 0)
              return (slen);

       if (slen >= len)
              copied = len - 1;
       else
              copied = slen;
       memcpy(dst, src, copied);
       dst[copied] = '\0';
       return (slen);
}

Here is the caller graph for this function: