summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-01-04 19:08:08 +0100
committerKay Sievers <kay@vrfy.org>2013-01-04 19:08:08 +0100
commit1328f66ad16b5afeb5684858c27e121a46c1959e (patch)
treefc76ff4b7b279f4842e4184eee237ce5985c4cf1 /src/libudev
parent48a849ee17fb25e0001bfcc0f28a4aa633d016a1 (diff)
udev: net_id - append "dev_id" value if needed
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-private.h1
-rw-r--r--src/libudev/libudev-util.c23
2 files changed, 21 insertions, 3 deletions
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index 5b7f0021e9..1b86384703 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -165,6 +165,7 @@ int util_log_priority(const char *priority);
size_t util_path_encode(const char *src, char *dest, size_t size);
void util_remove_trailing_chars(char *path, char c);
size_t util_strpcpy(char **dest, size_t size, const char *src);
+size_t util_strpcpyf(char **dest, size_t size, const char *src, ...) __attribute__((format(printf, 3, 4)));
size_t util_strpcpyl(char **dest, size_t size, const char *src, ...) __attribute__((sentinel));
size_t util_strscpy(char *dest, size_t size, const char *src);
size_t util_strscpyl(char *dest, size_t size, const char *src, ...) __attribute__((sentinel));
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;
}