Back to index

php5  5.3.10
Functions
strlcat.c File Reference
#include "php.h"
#include <sys/types.h>
#include <string.h>

Go to the source code of this file.

Functions

PHPAPI size_t php_strlcat (char *dst, const char *src, size_t siz)

Function Documentation

PHPAPI size_t php_strlcat ( char *  dst,
const char *  src,
size_t  siz 
)

Definition at line 67 of file strlcat.c.

{
       register char *d = dst;
       register const char *s = src;
       register size_t n = siz;
       size_t dlen;

       /* Find the end of dst and adjust bytes left but don't go past end */
       while (*d != '\0' && n-- != 0)
              d++;
       dlen = d - dst;
       n = siz - dlen;

       if (n == 0)
              return(dlen + strlen(s));
       while (*s != '\0') {
              if (n != 1) {
                     *d++ = *s;
                     n--;
              }
              s++;
       }
       *d = '\0';

       return(dlen + (s - src));   /* count does not include NUL */
}