Files:
*
Copyright:
- Copyright © 2004-2006, 2008-2022 Guillem Jover <guillem@hadrons.org>
+ Copyright © 2004-2024 Guillem Jover <guillem@hadrons.org>
License: BSD-3-clause
Files:
abi_accmode=unknown
abi_arc4random=unknown
abi_arc4random_stir=unknown
+abi_asprintf=unknown
abi_bsd_getopt=unknown
abi_closefrom=unknown
abi_err=unknown
#abi_arc4random=no
abi_arc4random=yes
abi_arc4random_stir=yes
+ abi_asprintf=no
abi_bsd_getopt=yes
# DROP: On glibc >= 2.34.
#abi_closefrom=no
abi_accmode=yes
abi_arc4random=yes
abi_arc4random_stir=yes
+ abi_asprintf=no
# DROP: On musl >= 0.9.7, optreset got implemented.
#abi_bsd_getopt=no
abi_bsd_getopt=yes
abi_accmode=no
abi_arc4random=no
abi_arc4random_stir=no
+ abi_asprintf=no
abi_bsd_getopt=no
abi_closefrom=yes
abi_err=no
abi_accmode=yes
abi_arc4random=no
abi_arc4random_stir=no
+ abi_asprintf=no
abi_bsd_getopt=yes
abi_closefrom=no
abi_err=no
LIBBSD_CHECK_REGISTER_ATFORK
AC_CHECK_FUNCS([\
+ vasprintf \
+ asprintf \
clearenv \
dirfd \
flock \
LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()])
LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
LIBBSD_SELECT_ABI([arc4random_stir], [arc4random_stir()/arc4random_addrandom()])
+LIBBSD_SELECT_ABI([asprintf], [vasprintf()/asprintf()])
LIBBSD_SELECT_ABI([bsd_getopt], [BSD getopt()])
LIBBSD_SELECT_ABI([closefrom], [closefrom()])
LIBBSD_SELECT_ABI([err], [err API])
/*
- * Copyright © 2004-2005, 2009, 2011-2013 Guillem Jover <guillem@hadrons.org>
+ * Copyright © 2004-2024 Guillem Jover <guillem@hadrons.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include <bsd/sys/cdefs.h>
#endif
#include <sys/types.h>
+#if defined(_AIX)
+#include <stdarg.h>
+#endif
__BEGIN_DECLS
+#if defined(_AIX)
+int asprintf(char **strp, char const *fmt, ...)
+ __printflike(2, 3);
+int vasprintf(char **strp, char const *fmt, va_list args)
+ __printflike(2, 0);
+#endif
+
const char *fmtcheck(const char *, const char *);
/* XXX: The function requires cooperation from the system libc to store the
# EOL
endif
+if ABI_ASPRINTF
+libbsd_la_SOURCES += \
+ asprintf.c \
+ vasprintf.c \
+ # EOL
+endif
+
if ABI_BSD_GETOPT
libbsd_la_SOURCES += \
bsd_getopt.c \
--- /dev/null
+/*
+ * Copyright © 2010-2024 Guillem Jover <guillem@hadrons.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+
+int
+asprintf(char **strp, char const *fmt, ...)
+{
+ va_list args;
+ int n;
+
+ va_start(args, fmt);
+ n = vasprintf(strp, fmt, args);
+ va_end(args);
+
+ return n;
+}
group_from_gid;
#endif
} LIBBSD_0.10.0;
+
+LIBBSD_0.12.0 {
+#if LIBBSD_ABI_ASPRINTF
+ vasprintf;
+ asprintf;
+#endif
+} LIBBSD_0.11.0;
--- /dev/null
+/*
+ * Copyright © 2010-2024 Guillem Jover <guillem@hadrons.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+vasprintf(char **strp, char const *fmt, va_list args)
+{
+ va_list args_copy;
+ int needed, n;
+ char *str;
+
+ va_copy(args_copy, args);
+ needed = vsnprintf(NULL, 0, fmt, args_copy);
+ va_end(args_copy);
+
+ if (needed < 0) {
+ *strp = NULL;
+ return -1;
+ }
+
+ str = malloc(needed + 1);
+ if (str == NULL) {
+ *strp = NULL;
+ return -1;
+ }
+
+ n = vsnprintf(str, needed + 1, fmt, args);
+ if (n < 0) {
+ free(str);
+ str = NULL;
+ }
+
+ *strp = str;
+
+ return n;
+}