[Open-scap] [PATCH 6/9] Added implementation of vasprintf
Marshall Miller
mmiller at tresys.com
Fri Apr 29 21:20:57 UTC 2011
vasprintf is not implemented on Solaris, so added it.
---
configure.ac | 5 +++++
src/OVAL/probes/SEAP/Makefile.am | 2 ++
src/OVAL/probes/SEAP/sexp-manip.c | 1 +
src/OVAL/probes/SEAP/vasprintf.c | 31 +++++++++++++++++++++++++++++++
src/OVAL/probes/SEAP/vasprintf.h | 14 ++++++++++++++
5 files changed, 53 insertions(+), 0 deletions(-)
create mode 100644 src/OVAL/probes/SEAP/vasprintf.c
create mode 100644 src/OVAL/probes/SEAP/vasprintf.h
diff --git a/configure.ac b/configure.ac
index 915bb01..76005e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,11 @@ CFLAGS_DEBUGGING="-fno-inline-functions -O0 -g3"
CFLAGS_NODEBUG="-DNDEBUG"
#
+# vasprintf
+#
+AC_CHECK_FUNCS([vasprintf])
+
+#
# posix_memalign
#
AC_CHECK_FUNCS([posix_memalign memalign])
diff --git a/src/OVAL/probes/SEAP/Makefile.am b/src/OVAL/probes/SEAP/Makefile.am
index 74decd9..28ca81d 100644
--- a/src/OVAL/probes/SEAP/Makefile.am
+++ b/src/OVAL/probes/SEAP/Makefile.am
@@ -76,6 +76,8 @@ libseap_la_SOURCES= generic/bfind.c \
public/seap-error.h \
public/sexp-datatype.h \
public/strbuf.h \
+ vasprintf.h \
+ vasprintf.c \
_sexp-rawptr.h
libseap_la_CFLAGS= @pthread_cflags@ -DUSE_XMALLOC -DXMALLOC_EXIT -DWANT_BASE64 -I$(top_srcdir) -I$(top_srcdir)/src -I. -I$(top_srcdir)/src/OVAL/probes/SEAP/public -DSEAP_THREAD_SAFE -DSEAP_MSGID_BITS=32
diff --git a/src/OVAL/probes/SEAP/sexp-manip.c b/src/OVAL/probes/SEAP/sexp-manip.c
index 1a3e603..2afc02d 100644
--- a/src/OVAL/probes/SEAP/sexp-manip.c
+++ b/src/OVAL/probes/SEAP/sexp-manip.c
@@ -45,6 +45,7 @@
#include "_sexp-rawptr.h"
#include "public/sexp-manip.h"
#include "public/sexp-manip_r.h"
+#include "vasprintf.h"
static void SEXP_free_lmemb (SEXP_t *s_exp);
diff --git a/src/OVAL/probes/SEAP/vasprintf.c b/src/OVAL/probes/SEAP/vasprintf.c
new file mode 100644
index 0000000..c4dd698
--- /dev/null
+++ b/src/OVAL/probes/SEAP/vasprintf.c
@@ -0,0 +1,31 @@
+#include "config.h"
+#if !defined(HAVE_VASPRINTF)
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "vasprintf.h"
+
+int vasprintf(char **strp, const char *fmt, va_list ap) {
+ va_list ap2;
+ char tmpchar[1];
+ char *newstr;
+ int s;
+
+ va_copy(ap2, ap);
+ s = vsnprintf(tmpchar, 1, fmt, ap);
+
+ newstr = malloc(s+1);
+ if (newstr == NULL) {
+ va_end(ap2);
+ return (-1);
+ }
+ s = vsnprintf(newstr, s+1, fmt, ap2);
+ va_end(ap2);
+
+ *strp = newstr;
+ return (s);
+}
+
+#endif
+
diff --git a/src/OVAL/probes/SEAP/vasprintf.h b/src/OVAL/probes/SEAP/vasprintf.h
new file mode 100644
index 0000000..05ca6fc
--- /dev/null
+++ b/src/OVAL/probes/SEAP/vasprintf.h
@@ -0,0 +1,14 @@
+#ifndef _VASPRINTF_H
+#define _VASPRINTF_H
+
+#include "config.h"
+#if !defined(HAVE_VASPRINTF)
+
+#include <stdarg.h>
+
+int vasprintf(char **strp, const char *fmt, va_list ap);
+
+#endif
+
+#endif
+
--
1.6.2.5
More information about the Open-scap-list
mailing list