vsprintf.c revision 130561
133965Sjdp/* Simple implementation of vsprintf for systems without it.
233965Sjdp   Highly system-dependent, but should work on most "traditional"
333965Sjdp   implementations of stdio; newer ones should already have vsprintf.
433965Sjdp   Written by Per Bothner of Cygnus Support.
533965Sjdp   Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
689857Sobrien   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
733965Sjdp
833965SjdpThis file is part of the libiberty library.  This library is free
933965Sjdpsoftware; you can redistribute it and/or modify it under the
1033965Sjdpterms of the GNU General Public License as published by the
1133965SjdpFree Software Foundation; either version 2, or (at your option)
1233965Sjdpany later version.
1333965Sjdp
1433965SjdpThis library is distributed in the hope that it will be useful,
1533965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1633965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1733965SjdpGNU General Public License for more details.
1833965Sjdp
1933965SjdpYou should have received a copy of the GNU General Public License
2033965Sjdpalong with GNU CC; see the file COPYING.  If not, write to
2133965Sjdpthe Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2233965Sjdp
2333965SjdpAs a special exception, if you link this library with files
2433965Sjdpcompiled with a GNU compiler to produce an executable, this does not cause
2533965Sjdpthe resulting executable to be covered by the GNU General Public License.
2633965SjdpThis exception does not however invalidate any other reasons why
2733965Sjdpthe executable file might be covered by the GNU General Public License. */
2833965Sjdp
29130561Sobrien#include <ansidecl.h>
30130561Sobrien#ifdef ANSI_PROTOTYPES
31130561Sobrien#include <stdarg.h>
32130561Sobrien#else
3333965Sjdp#include <varargs.h>
34130561Sobrien#endif
3533965Sjdp#include <stdio.h>
3633965Sjdp#undef vsprintf
3733965Sjdp
3889857Sobrien#if defined _IOSTRG && defined _IOWRT
3989857Sobrien
4033965Sjdpint
4133965Sjdpvsprintf (buf, format, ap)
4233965Sjdp     char *buf;
4333965Sjdp     const char *format;
4433965Sjdp     va_list ap;
4533965Sjdp{
4633965Sjdp  FILE b;
4733965Sjdp  int ret;
4833965Sjdp#ifdef VMS
4933965Sjdp  b->_flag = _IOWRT|_IOSTRG;
5033965Sjdp  b->_ptr = buf;
5133965Sjdp  b->_cnt = 12000;
5233965Sjdp#else
5333965Sjdp  b._flag = _IOWRT|_IOSTRG;
5433965Sjdp  b._ptr = buf;
5533965Sjdp  b._cnt = 12000;
5633965Sjdp#endif
5733965Sjdp  ret = _doprnt(format, ap, &b);
5833965Sjdp  putc('\0', &b);
5933965Sjdp  return ret;
6033965Sjdp
6133965Sjdp}
6289857Sobrien
6389857Sobrien#endif
64