xref: /inferno-os/lib9/vseprint.c (revision 2b1e4b84370b327f5eb17c9ba8bc44f4296e4a86)
137da2899SCharles.Forsyth /*
237da2899SCharles.Forsyth  * The authors of this software are Rob Pike and Ken Thompson.
337da2899SCharles.Forsyth  *              Copyright (c) 2002 by Lucent Technologies.
437da2899SCharles.Forsyth  * Permission to use, copy, modify, and distribute this software for any
537da2899SCharles.Forsyth  * purpose without fee is hereby granted, provided that this entire notice
637da2899SCharles.Forsyth  * is included in all copies of any software which is or includes a copy
737da2899SCharles.Forsyth  * or modification of this software and in all copies of the supporting
837da2899SCharles.Forsyth  * documentation for such software.
937da2899SCharles.Forsyth  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
1037da2899SCharles.Forsyth  * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
1137da2899SCharles.Forsyth  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
1237da2899SCharles.Forsyth  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
1337da2899SCharles.Forsyth  */
1437da2899SCharles.Forsyth #include "lib9.h"
15*2b1e4b84SCharles.Forsyth #include "fmtdef.h"
1637da2899SCharles.Forsyth 
1737da2899SCharles.Forsyth char*
vseprint(char * buf,char * e,char * fmt,va_list args)1837da2899SCharles.Forsyth vseprint(char *buf, char *e, char *fmt, va_list args)
1937da2899SCharles.Forsyth {
2037da2899SCharles.Forsyth 	Fmt f;
2137da2899SCharles.Forsyth 
2237da2899SCharles.Forsyth 	if(e <= buf)
2337da2899SCharles.Forsyth 		return nil;
2437da2899SCharles.Forsyth 	f.runes = 0;
2537da2899SCharles.Forsyth 	f.start = buf;
2637da2899SCharles.Forsyth 	f.to = buf;
2737da2899SCharles.Forsyth 	f.stop = e - 1;
2837da2899SCharles.Forsyth 	f.flush = nil;
2937da2899SCharles.Forsyth 	f.farg = nil;
3037da2899SCharles.Forsyth 	f.nfmt = 0;
311f44c82aSCharles.Forsyth 	va_copy(f.args, args);
3237da2899SCharles.Forsyth 	dofmt(&f, fmt);
331f44c82aSCharles.Forsyth 	va_end(f.args);
3437da2899SCharles.Forsyth 	*(char*)f.to = '\0';
3537da2899SCharles.Forsyth 	return f.to;
3637da2899SCharles.Forsyth }
3737da2899SCharles.Forsyth 
38