[Pkg-libvirt-commits] [libguestfs] 01/24: daemon: add add_sprintf
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:41:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch master
in repository libguestfs.
commit ea0a8d82051ed18236c8722b5ee07ea4cb6dd1cd
Author: Pino Toscano <ptoscano at redhat.com>
Date: Tue Aug 26 14:31:05 2014 +0200
daemon: add add_sprintf
Bring the add_sprintf function for stringsbuf from the library.
(cherry picked from commit 9b501fa5c6365958de362ecaf0f4e90c147978a2)
---
daemon/daemon.h | 2 ++
daemon/guestfsd.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 08799e1..0091120 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -88,6 +88,8 @@ struct stringsbuf {
*/
extern int add_string_nodup (struct stringsbuf *sb, char *str);
extern int add_string (struct stringsbuf *sb, const char *str);
+extern int add_sprintf (struct stringsbuf *sb, const char *fs, ...)
+ __attribute__((format (printf,2,3)));
extern int end_stringsbuf (struct stringsbuf *sb);
extern size_t count_strings (char *const *argv);
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 0f847ea..54a4afb 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -539,6 +539,26 @@ add_string (struct stringsbuf *sb, const char *str)
}
int
+add_sprintf (struct stringsbuf *sb, const char *fs, ...)
+{
+ va_list args;
+ char *str;
+ int r;
+
+ va_start (args, fs);
+ r = vasprintf (&str, fs, args);
+ va_end (args);
+ if (r == -1) {
+ reply_with_perror ("vasprintf");
+ free_stringslen (sb->argv, sb->size);
+ sb->argv = NULL;
+ return -1;
+ }
+
+ return add_string_nodup (sb, str);
+}
+
+int
end_stringsbuf (struct stringsbuf *sb)
{
return add_string_nodup (sb, NULL);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list