2 * dofmt -- format to a buffer
3 * the number of characters formatted is returned,
4 * or -1 if there was an error.
5 * if the buffer is ever filled, flush is called.
6 * it should reset the buffer and return whether formatting should continue.
9 typedef int (*Fmts)(Fmt*);
11 typedef struct Quoteinfo Quoteinfo;
14 int quoted; /* if set, string must be quoted */
15 int nrunesin; /* number of input runes that can be accepted */
16 int nbytesin; /* number of input bytes that can be accepted */
17 int nrunesout; /* number of runes that will be generated */
18 int nbytesout; /* number of bytes that will be generated */
21 void *_fmtflush(Fmt*, void*, int);
22 void *_fmtdispatch(Fmt*, void*, int);
23 int _floatfmt(Fmt*, double);
24 int _fmtpad(Fmt*, int);
25 int _rfmtpad(Fmt*, int);
26 int _fmtFdFlush(Fmt*);
32 int _percentfmt(Fmt*);
38 int _fmtcpy(Fmt*, void*, int, int);
39 int _fmtrcpy(Fmt*, void*, int n);
42 void _fmtunlock(void);
44 #define FMTCHAR(f, t, s, c)\
46 if(t + 1 > (char*)s){\
47 t = _fmtflush(f, t, 1);\
56 #define FMTRCHAR(f, t, s, c)\
58 if(t + 1 > (Rune*)s){\
59 t = _fmtflush(f, t, sizeof(Rune));\
68 #define FMTRUNE(f, t, s, r)\
72 if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\
73 t = _fmtflush(f, t, _runelen);\
83 t += runetochar(t, &_rune);\