summaryrefslogtreecommitdiffstats
path: root/common/estream.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-09-03 12:44:13 +0200
committerWerner Koch <wk@gnupg.org>2009-09-03 12:44:13 +0200
commit64c8f1777c4a634aabfd05433496f6b7f043774a (patch)
tree393369c3dce3ce54104fb330e6d19e2fd9752a1f /common/estream.c
parentMake use of strconcat to make the code more robust against future changes. (diff)
downloadgnupg2-64c8f1777c4a634aabfd05433496f6b7f043774a.tar.xz
gnupg2-64c8f1777c4a634aabfd05433496f6b7f043774a.zip
Update estream.
Diffstat (limited to '')
-rw-r--r--common/estream.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/common/estream.c b/common/estream.c
index c26df6323..fef9a210f 100644
--- a/common/estream.c
+++ b/common/estream.c
@@ -2756,7 +2756,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
out:
- return err ? err : line_n;
+ return err ? err : (ssize_t)line_n;
}
@@ -2929,6 +2929,44 @@ es_fprintf (estream_t ES__RESTRICT stream,
return ret;
}
+/* A variant of asprintf. The function returns the allocated buffer
+ or NULL on error; ERRNO is set in the error case. The caller
+ should use es_free to release the buffer. This function actually
+ belongs into estream-printf but we put it here as a convenience
+ and because es_free is required anyway. */
+char *
+es_asprintf (const char *ES__RESTRICT format, ...)
+{
+ int rc;
+ va_list ap;
+ char *buf;
+
+ va_start (ap, format);
+ rc = estream_vasprintf (&buf, format, ap);
+ va_end (ap);
+ if (rc < 0)
+ return NULL;
+ return buf;
+}
+
+
+/* A variant of vasprintf. The function returns the allocated buffer
+ or NULL on error; ERRNO is set in the error case. The caller
+ should use es_free to release the buffer. This function actually
+ belongs into estream-printf but we put it here as a convenience
+ and because es_free is required anyway. */
+char *
+es_vasprintf (const char *ES__RESTRICT format, va_list ap)
+{
+ int rc;
+ char *buf;
+
+ rc = estream_vasprintf (&buf, format, ap);
+ if (rc < 0)
+ return NULL;
+ return buf;
+}
+
static int
tmpfd (void)