diff options
author | Kay Sievers <kay@vrfy.org> | 2013-01-04 19:08:08 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-01-04 19:08:08 +0100 |
commit | 1328f66ad16b5afeb5684858c27e121a46c1959e (patch) | |
tree | fc76ff4b7b279f4842e4184eee237ce5985c4cf1 /src/libudev/libudev-util.c | |
parent | 48a849ee17fb25e0001bfcc0f28a4aa633d016a1 (diff) |
udev: net_id - append "dev_id" value if needed
Diffstat (limited to 'src/libudev/libudev-util.c')
-rw-r--r-- | src/libudev/libudev-util.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index cb9ed9c84b..b55bf75bfc 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -321,14 +321,32 @@ size_t util_strpcpy(char **dest, size_t size, const char *src) if (size > 1) *dest = mempcpy(*dest, src, size-1); size = 0; - *dest[0] = '\0'; } else { if (len > 0) { *dest = mempcpy(*dest, src, len); size -= len; } - *dest[0] = '\0'; } + *dest[0] = '\0'; + return size; +} + +size_t util_strpcpyf(char **dest, size_t size, const char *src, ...) +{ + va_list va; + int i; + + va_start(va, src); + i = vsnprintf(*dest, size, src, va); + if (i < (int)size) { + *dest += i; + size -= i; + } else { + *dest += size; + size = 0; + } + va_end(va); + *dest[0] = '\0'; return size; } @@ -343,7 +361,6 @@ size_t util_strpcpyl(char **dest, size_t size, const char *src, ...) src = va_arg(va, char *); } while (src != NULL); va_end(va); - return size; } |