X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcstrutil.c;h=b685f0557d0b10613f984d09ffcb6a928030fccb;hb=b424d54ae3239007b4d4e2e9b3f4bf55781450bb;hp=53c1a0241b9805731967f996c0e2f4571a5be9df;hpb=c32aeb89f054fc9f183120cc8e106f07e16a6472;p=silc.git diff --git a/lib/silcutil/silcstrutil.c b/lib/silcutil/silcstrutil.c index 53c1a024..b685f055 100644 --- a/lib/silcutil/silcstrutil.c +++ b/lib/silcutil/silcstrutil.c @@ -574,3 +574,25 @@ silc_mime_parse(const unsigned char *mime, SilcUInt32 mime_len, return TRUE; } + +/* Concatenates the `src' into `dest'. If `src_len' is more than the + size of the `dest' (minus NULL at the end) the `src' will be + truncated to fit. */ + +char *silc_strncat(char *dest, SilcUInt32 dest_size, + const char *src, SilcUInt32 src_len) +{ + int len; + + dest[dest_size - 1] = '\0'; + + len = dest_size - 1 - strlen(dest); + if (len < src_len) { + if (len > 0) + strncat(dest, src, len); + } else { + strncat(dest, src, src_len); + } + + return dest; +}