| runevsnprint.c - 9base - revived minimalist port of Plan 9 userland to Unix | |
| git clone git://git.suckless.org/9base | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| runevsnprint.c (515B) | |
| --- | |
| 1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ | |
| 2 #include <stdarg.h> | |
| 3 #include <string.h> | |
| 4 #include "plan9.h" | |
| 5 #include "fmt.h" | |
| 6 #include "fmtdef.h" | |
| 7 | |
| 8 int | |
| 9 runevsnprint(Rune *buf, int len, char *fmt, va_list args) | |
| 10 { | |
| 11 Fmt f; | |
| 12 | |
| 13 if(len <= 0) | |
| 14 return -1; | |
| 15 f.runes = 1; | |
| 16 f.start = buf; | |
| 17 f.to = buf; | |
| 18 f.stop = buf + len - 1; | |
| 19 f.flush = nil; | |
| 20 f.farg = nil; | |
| 21 f.nfmt = 0; | |
| 22 VA_COPY(f.args,args); | |
| 23 fmtlocaleinit(&f, nil, nil, nil); | |
| 24 dofmt(&f, fmt); | |
| 25 VA_END(f.args); | |
| 26 *(Rune*)f.to = '\0'; | |
| 27 return (Rune*)f.to - buf; | |
| 28 } |