Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!liuida!d89peter From: d89peter@odalix.ida.liu.se (Peter Eriksson) Newsgroups: comp.unix.programmer Subject: Re: vprintf/vfprintf/vsprintf Message-ID: <1991Jan31.160515.8734@ida.liu.se> Date: 31 Jan 91 16:05:15 GMT References: <43453@ut-emx.uucp> Sender: news@ida.liu.se (News Subsystem) Organization: CIS Dept, Univ of Linkoping, Sweden Lines: 43 jonabbey@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@lysator.liu.se Lysator Computer Club ...!uunet!lysator.liu.se!pen University of Linkoping, Sweden Support the LPF!