MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / zebra / lib / str.c
blob797e9b87033224f2550c3933694c26eda74f404d
1 /*
2 * zebra string function
4 * these functions are just very basic wrappers around exiting ones and
5 * do not offer the protection that might be expected against buffer
6 * overruns etc
7 */
9 #include <zebra.h>
11 #include "str.h"
13 #ifndef HAVE_SNPRINTF
15 * snprint() is a real basic wrapper around the standard sprintf()
16 * without any bounds checking
18 int
19 snprintf(char *str, size_t size, const char *format, ...)
21 va_list args;
23 va_start (args, format);
25 return vsprintf (str, format, args);
27 #endif
29 #ifndef HAVE_STRLCPY
31 * strlcpy is a safer version of strncpy(), checking the total
32 * size of the buffer
34 size_t
35 strlcpy(char *dst, const char *src, size_t size)
37 strncpy(dst, src, size);
39 return (strlen(dst));
41 #endif
43 #ifndef HAVE_STRLCAT
45 * strlcat is a safer version of strncat(), checking the total
46 * size of the buffer
48 size_t
49 strlcat(char *dst, const char *src, size_t size)
51 /* strncpy(dst, src, size - strlen(dst)); */
53 /* I've just added below code only for workable under Linux. So
54 need rewrite -- Kunihiro. */
55 if (strlen (dst) + strlen (src) >= size)
56 return -1;
58 strcat (dst, src);
60 return (strlen(dst));
62 #endif