2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Text fragments inspired by Martin Schulze <joey@infodrom.org>.
|
|
|
|
.\"
|
|
|
|
.TH ASPRINTF 3 2001-12-18 "GNU" "Linux Programmer's Manual"
|
|
|
|
.SH NAME
|
|
|
|
asprintf, vasprintf \- print to allocated string
|
|
|
|
.SH SYNOPSIS
|
getresuid.2, mremap.2, poll.2, remap_file_pages.2, setresuid.2, splice.2, sync_file_range.2, syscall.2, tee.2, vmsplice.2, INFINITY.3, aio_init.3, asprintf.3, assert_perror.3, basename.3, bsd_signal.3, canonicalize_file_name.3, clog10.3, crypt.3, dl_iterate_phdr.3, dlopen.3, encrypt.3, exp10.3, fcloseall.3, fenv.3, fopencookie.3, ftw.3, getaddrinfo_a.3, getloadavg.3, getutent.3, grantpt.3, hsearch.3, lseek64.3, memmem.3, mempcpy.3, pow10.3, program_invocation_name.3, ptsname.3, putgrent.3, sched_getcpu.3, sincos.3, strchr.3, strfry.3, strnlen.3, strptime.3, strstr.3, strverscmp.3, swab.3, sysv_signal.3, tsearch.3, unlockpt.3, wcwidth.3: Add reference to feature_test_macros(7)
Some pages simply list feature test macro requirements in
the form:
#define #GNU_SOURCE
#include <someheader.h>
For these pages, add a "See feature_test_macros(7)" comment
on the "#define" line.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-31 04:31:47 +00:00
|
|
|
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
|
2004-11-03 13:51:07 +00:00
|
|
|
.br
|
|
|
|
.B #include <stdio.h>
|
|
|
|
.sp
|
|
|
|
.BI "int asprintf(char **" strp ", const char *" fmt ", ...);"
|
|
|
|
.sp
|
|
|
|
.BI "int vasprintf(char **" strp ", const char *" fmt ", va_list " ap );
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The functions
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR asprintf ()
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR vasprintf ()
|
2007-06-08 09:56:56 +00:00
|
|
|
are analogs of
|
2007-05-12 00:30:29 +00:00
|
|
|
.BR sprintf (3)
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2007-05-12 00:30:29 +00:00
|
|
|
.BR vsprintf (3),
|
2004-11-03 13:51:07 +00:00
|
|
|
except that they allocate a string large enough to hold the output
|
2006-01-13 02:09:44 +00:00
|
|
|
including the terminating null byte,
|
2008-07-10 20:53:08 +00:00
|
|
|
and return a pointer to it via the first argument.
|
2004-11-03 13:51:07 +00:00
|
|
|
This pointer should be passed to
|
|
|
|
.BR free (3)
|
|
|
|
to release the allocated storage when it is no longer needed.
|
|
|
|
.SH "RETURN VALUE"
|
|
|
|
When successful, these functions return the number of bytes printed,
|
|
|
|
just like
|
|
|
|
.BR sprintf (3).
|
|
|
|
If memory allocation wasn't possible, or some other error occurs,
|
|
|
|
these functions will return \-1, and the contents of
|
|
|
|
.I strp
|
|
|
|
is undefined.
|
2006-08-04 12:39:17 +00:00
|
|
|
.SH CONFORMING TO
|
2004-11-03 13:51:07 +00:00
|
|
|
These functions are GNU extensions, not in C or POSIX.
|
|
|
|
They are also available under *BSD.
|
|
|
|
The FreeBSD implementation sets
|
|
|
|
.I strp
|
|
|
|
to NULL on error.
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR free (3),
|
|
|
|
.BR malloc (3),
|
getresuid.2, intro.2, mremap.2, open.2, poll.2, posix_fadvise.2, pread.2, remap_file_pages.2, setresuid.2, signal.2, splice.2, sync_file_range.2, tee.2, vmsplice.2, INFINITY.3, asprintf.3, assert_perror.3, basename.3, bsd_signal.3, canonicalize_file_name.3, clog10.3, crypt.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, encrypt.3, exp10.3, fcloseall.3, fenv.3, ffs.3, fmemopen.3, fopencookie.3, ftw.3, getdate.3, getline.3, getloadavg.3, getopt.3, getsubopt.3, getutent.3, grantpt.3, hsearch.3, intro.3, lseek64.3, memmem.3, mempcpy.3, mq_receive.3, mq_send.3, posix_fallocate.3, pow10.3, program_invocation_name.3, ptsname.3, putgrent.3, readdir.3, sigset.3, sincos.3, stpcpy.3, stpncpy.3, strchr.3, strfry.3, strnlen.3, strptime.3, strsignal.3, strstr.3, strverscmp.3, swab.3, sysv_signal.3, tsearch.3, unlocked_stdio.3, unlockpt.3, wcpcpy.3, wcpncpy.3, wcsdup.3, wcwidth.3: SEE ALSO: Remove redundant reference to feature_test_macros(7)
Reported-by: Florian Lehmann <flo.lehmann@googlemail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-31 05:05:22 +00:00
|
|
|
.BR printf (3)
|