summaryrefslogtreecommitdiffstats
path: root/include/stdio.h
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-05-27 10:49:43 +0000
committerpeter <peter@FreeBSD.org>1996-05-27 10:49:43 +0000
commitfbe63391875b9762cc438066b5f20fce1ab43a26 (patch)
tree46b469e307f5817e3d72000c1cb25e1b95261d2d /include/stdio.h
parent83ae023014d7ed4c9a0e539a355ced30d9fb758b (diff)
downloadFreeBSD-src-fbe63391875b9762cc438066b5f20fce1ab43a26.zip
FreeBSD-src-fbe63391875b9762cc438066b5f20fce1ab43a26.tar.gz
Add an implementation of the gnu-ish asprintf() and vasprintf(). They are
not based on gpl'ed code, just prototype and usage. I'm not 100% certain they behave the same while the system is in trouble (eg: malloc() failing) but in those circumstances all bets would be off anyway. These routines work like sprintf() and vsprintf(), except that instead of using a fixed buffer, they allocate memory and return it to the user and it's the user's responsibility to free() it. They have allocate as much memory as they need (and can get), so the size of strings it can deal with is limited only by the amount of memory it can malloc() on your behalf. There are a few gpl'ed programs starting to use this interface, and it's becoming more common with the scares about security risks with sprintf(). I dont like the look of the code that the various programs (including cvs, gdb, libg++, etc) provide if configure can't find it on the system. It should be possible to modify the stdio core code to provide this interface more efficiently, I was more worried about having something that worked and was secure. :-) (I noticed that there was once intended to be a smprintf() routine when our stdio was written for 4.4BSD, but it looks pretty stillborn, and it's intended interface is not clear). Since Linux and gnu libc have this interface, it seemed silly to bring yet another one onto the scene.
Diffstat (limited to 'include/stdio.h')
-rw-r--r--include/stdio.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h
index e930010..9c4c37e 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -283,6 +283,7 @@ __END_DECLS
*/
#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
__BEGIN_DECLS
+int asprintf __P((char **, const char *, ...));
char *fgetln __P((FILE *, size_t *));
int fpurge __P((FILE *));
int getw __P((FILE *));
@@ -293,6 +294,7 @@ void setbuffer __P((FILE *, char *, int));
int setlinebuf __P((FILE *));
char *tempnam __P((const char *, const char *));
int snprintf __P((char *, size_t, const char *, ...));
+int vasprintf __P((char **, const char *, _BSD_VA_LIST_));
int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_));
int vscanf __P((const char *, _BSD_VA_LIST_));
int vsscanf __P((const char *, const char *, _BSD_VA_LIST_));
OpenPOWER on IntegriCloud