1
1
/******************************************************************************
2
* $Id: utils.c 3665 2007-10-31 18:10:54Z charles $
2
* $Id: utils.c 3972 2007-11-26 05:03:34Z charles $
4
4
* Copyright (c) 2005-2007 Transmission authors and contributors
826
tr_bitfieldAnd( tr_bitfield * a, const tr_bitfield * b )
830
tr_bitfieldOr( tr_bitfield * a, const tr_bitfield * b )
829
833
const uint8_t *aend, *bit;
892
896
usleep( 1000 * delay_milliseconds );
908
* Copy src to string dst of size siz. At most siz-1 characters
909
* will be copied. Always NUL terminates (unless siz == 0).
910
* Returns strlen(src); if retval >= siz, truncation occurred.
913
strlcpy(char *dst, const char *src, size_t siz)
919
/* Copy as many bytes as will fit */
922
if ((*d++ = *s++) == '\0')
927
/* Not enough room in dst, add NUL and traverse rest of src */
930
*d = '\0'; /* NUL-terminate dst */
935
return(s - src - 1); /* count does not include NUL */
938
#endif /* HAVE_STRLCPY */
944
* Appends src to string dst of size siz (unlike strncat, siz is the
945
* full size of dst, not space left). At most siz-1 characters
946
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
947
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
948
* If retval >= siz, truncation occurred.
951
strlcat(char *dst, const char *src, size_t siz)
958
/* Find the end of dst and adjust bytes left but don't go past end */
959
while (n-- != 0 && *d != '\0')
965
return(dlen + strlen(s));
975
return(dlen + (s - src)); /* count does not include NUL */
978
#endif /* HAVE_STRLCAT */