vsprintf.c revision 89857
1132720Skan/* Simple implementation of vsprintf for systems without it.
2132720Skan   Highly system-dependent, but should work on most "traditional"
3169691Skan   implementations of stdio; newer ones should already have vsprintf.
4132720Skan   Written by Per Bothner of Cygnus Support.
5132720Skan   Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
6132720Skan   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
7132720Skan
8132720SkanThis file is part of the libiberty library.  This library is free
9132720Skansoftware; you can redistribute it and/or modify it under the
10132720Skanterms of the GNU General Public License as published by the
11132720SkanFree Software Foundation; either version 2, or (at your option)
12132720Skanany later version.
13132720Skan
14132720SkanThis library is distributed in the hope that it will be useful,
15132720Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
16132720SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17132720SkanGNU General Public License for more details.
18132720Skan
19169691SkanYou should have received a copy of the GNU General Public License
20132720Skanalong with GNU CC; see the file COPYING.  If not, write to
21132720Skanthe Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22132720Skan
23132720SkanAs a special exception, if you link this library with files
24132720Skancompiled with a GNU compiler to produce an executable, this does not cause
25132720Skanthe resulting executable to be covered by the GNU General Public License.
26132720SkanThis exception does not however invalidate any other reasons why
27132720Skanthe executable file might be covered by the GNU General Public License. */
28132720Skan
29132720Skan#include <varargs.h>
30132720Skan#include <stdio.h>
31169691Skan#include <ansidecl.h>
32169691Skan#undef vsprintf
33169691Skan
34169691Skan#if defined _IOSTRG && defined _IOWRT
35169691Skan
36132720Skanint
37132720Skanvsprintf (buf, format, ap)
38132720Skan     char *buf;
39132720Skan     const char *format;
40132720Skan     va_list ap;
41132720Skan{
42132720Skan  FILE b;
43132720Skan  int ret;
44132720Skan#ifdef VMS
45132720Skan  b->_flag = _IOWRT|_IOSTRG;
46132720Skan  b->_ptr = buf;
47132720Skan  b->_cnt = 12000;
48132720Skan#else
49132720Skan  b._flag = _IOWRT|_IOSTRG;
50132720Skan  b._ptr = buf;
51132720Skan  b._cnt = 12000;
52169691Skan#endif
53169691Skan  ret = _doprnt(format, ap, &b);
54132720Skan  putc('\0', &b);
55132720Skan  return ret;
56132720Skan
57132720Skan}
58132720Skan
59132720Skan#endif
60132720Skan