]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add _gnutls_string_append_printf.
authorSimon Josefsson <simon@josefsson.org>
Thu, 8 Feb 2007 11:53:10 +0000 (11:53 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 8 Feb 2007 11:53:10 +0000 (11:53 +0000)
lib/gnutls_str.c
lib/gnutls_str.h

index cbda764af2a9b91872ff83112596226f133db851..a03f00f4b863446c3460b61b328cf89b78654e75 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2002, 2004, 2005  Free Software Foundation
+ * Copyright (C) 2002, 2004, 2005, 2007  Free Software Foundation
  *
  * Author: Nikos Mavroyanopoulos
  *
@@ -227,6 +227,29 @@ _gnutls_string_append_data (gnutls_string * dest, const void *data,
     }
 }
 
+#include <vasnprintf.h>
+
+int
+_gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
+{
+  va_list args;
+  int len;
+  char *str;
+
+  va_start (args, fmt);
+  len = vasprintf (&str, fmt, args);
+  va_end (args);
+
+  if (len < 0 || !str)
+    return -1;
+
+  len = _gnutls_string_append_str (dest, str);
+
+  free (str);
+
+  return len;
+}
+
 /* Converts the given string (old) to hex. A buffer must be provided
  * to hold the new hex string. The new string will be null terminated.
  * If the buffer does not have enough space to hold the string, a
index 3acf071a29483575c86caa1aa33adaa8e20d0cfd..ad7c1159a70b0ea9a76439b8a50abe87ae68a1a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
+ * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation
  *
  * Author: Nikos Mavroyanopoulos
  *
@@ -55,6 +55,7 @@ int _gnutls_string_copy_str (gnutls_string * dest, const char *src);
 int _gnutls_string_append_str (gnutls_string *, const char *str);
 int _gnutls_string_append_data (gnutls_string *, const void *data,
                                size_t data_size);
+int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...);
 
 char *_gnutls_bin2hex (const void *old, size_t oldlen, char *buffer,
                       size_t buffer_size);