2 * transsip - the telephony network
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
7 * strlcpy: Copyright (C) 1991, 1992 Linus Torvalds, GPL, version 2
19 size_t strlcpy(char *dest
, const char *src
, size_t size
)
21 size_t ret
= strlen(src
);
23 size_t len
= (ret
>= size
) ? size
- 1 : ret
;
24 memcpy(dest
, src
, len
);
30 int slprintf(char *dst
, size_t size
, const char *fmt
, ...)
35 ret
= vsnprintf(dst
, size
, fmt
, ap
);
41 char **strntoargv(char *str
, size_t len
, int *argc
)
46 panic("argc is null!\n");
48 if (len
<= 1) /* '\0' */
51 while (len
> 0 && *str
== ' ') {
55 if (len
> 0 && *str
!= '\0') {
57 argv
= xrealloc(argv
, 1, sizeof(char *) * (*argc
));
58 argv
[(*argc
) - 1] = str
;
59 while (len
> 0 && *str
!= ' ') {
63 if (len
> 0 && *str
== ' ') {