vprintf/vfprintf/vsprintf

Peter Eriksson d89peter at odalix.ida.liu.se
Fri Feb 1 03:05:15 AEST 1991


jonabbey at ccwf.cc.utexas.edu (Jonathan Abbey) writes:

>Greetings.. I am trying to put together a package on our Alliant (apE 2.0),
>and have been unsucessful in doing so, as of the moment.  One of the
>stumbling blocks is that a library in apE uses vfprintf and vsprintf, which
>are versions of fprintf and sprintf designed to work with the varargs
>macros.  I have looked at the source for sprintf and fprintf on our system,
>and they use a common routine called doprnt(), which accepts arguments in
>terms of an argument list, such as would be constructed by the varargs
>macros.  It seems what I can see that I should be able to simply substitute
>sprintf and fprintf for the varargs-specialized versions, but this does not
>seem to work.

>Any hints would be gratefully accepted.

'uunet.uu.net' has in the directory 'bsd-source/lib/libc/stdio' a
set of C-sources that implemement a full set of *printf routines..

Or if anyone is interrested I could post/email our version of a modified
'doprnt.c' (that contains all the *printf.c routines as well). The features
of this is that the doprnt() routine has been replaced by a more general
function that allows you to specify a function to be called when a 
character is to be output (instead of doing like 'doprnt' does -
fiddle with FILE-structures which limits you to strings and FILEs...
As you may notice, I think doprnt() is _ugly_). The syntax of our
general (and extendible! One can add new output formats (like %Q, or
whatever) on the fly with it) function is:

   int _printf(
	int (*out_char)(int ch, void *uptr),
 	const char *format,
  	va_list AP,
	void *uptr)

With it it is easy to implement just about any variation of the *printf()
functions. (it is even possible to emulate the doprnt() function with it..)

/Peter

--
Peter Eriksson                                              pen at lysator.liu.se
Lysator Computer Club                             ...!uunet!lysator.liu.se!pen
University of Linkoping, Sweden                               Support the LPF!



More information about the Comp.unix.programmer mailing list