summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorIan Stakenvicius <axs@gentoo.org>2013-01-25 11:47:47 -0500
committerAnthony G. Basile <blueness@gentoo.org>2013-01-28 17:42:47 -0500
commite34b05dc4c5c8b48cbc0428b29344f7634b3b4a5 (patch)
tree6fa23a172bd969ba20c8c8e2c80121a7f20bad97 /src/libudev
parentab779c81460ce48e6b270977ef339b32d87c1f41 (diff)
Port new net_id capabilities from systemd-udev-197
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-private.h1
-rw-r--r--src/libudev/libudev-util.c19
2 files changed, 20 insertions, 0 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 d3bbd05927..0ca86c815d 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -334,6 +334,25 @@ size_t util_strpcpy(char **dest, size_t size, const char *src)
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;
+}
+
/* concatenates list of strings, moves dest forward */
size_t util_strpcpyl(char **dest, size_t size, const char *src, ...)
{