1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
4 * dofmt -- format to a buffer
5 * the number of characters formatted is returned,
6 * or -1 if there was an error.
7 * if the buffer is ever filled, flush is called.
8 * it should reset the buffer and return whether formatting should continue.
11 typedef int (*Fmts)(Fmt*);
13 typedef struct Quoteinfo Quoteinfo;
16 int quoted; /* if set, string must be quoted */
17 int nrunesin; /* number of input runes that can be accepted */
18 int nbytesin; /* number of input bytes that can be accepted */
19 int nrunesout; /* number of runes that will be generated */
20 int nbytesout; /* number of bytes that will be generated */
23 /* Edit .+1,/^$/ |cfn |grep -v static | grep __ */
24 double __Inf(int sign);
27 int __charfmt(Fmt *f);
28 int __countfmt(Fmt *f);
29 int __efgfmt(Fmt *fmt);
31 int __flagfmt(Fmt *f);
32 int __fmtFdFlush(Fmt *f);
33 int __fmtcpy(Fmt *f, const void *vm, int n, int sz);
34 void* __fmtdispatch(Fmt *f, void *fmt, int isrunes);
35 void * __fmtflush(Fmt *f, void *t, int len);
37 int __fmtpad(Fmt *f, int n);
38 double __fmtpow10(int n);
39 int __fmtrcpy(Fmt *f, const void *vm, int n);
40 void __fmtunlock(void);
42 int __isInf(double d, int sign);
43 int __isNaN(double d);
44 int __needsep(int*, char**);
45 int __needsquotes(char *s, int *quotelenp);
46 int __percentfmt(Fmt *f);
47 void __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int runesout);
48 int __quotestrfmt(int runesin, Fmt *f);
49 int __rfmtpad(Fmt *f, int n);
50 int __runefmt(Fmt *f);
51 int __runeneedsquotes(Rune *r, int *quotelenp);
52 int __runesfmt(Fmt *f);
55 #define FMTCHAR(f, t, s, c)\
57 if(t + 1 > (char*)s){\
58 t = (char*)__fmtflush(f, t, 1);\
67 #define FMTRCHAR(f, t, s, c)\
69 if(t + 1 > (Rune*)s){\
70 t = (Rune*)__fmtflush(f, t, sizeof(Rune));\
79 #define FMTRUNE(f, t, s, r)\
83 if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\
84 t = (char*)__fmtflush(f, t, _runelen);\
94 t += runetochar(t, &_rune);\
99 # define VA_COPY(a,b) va_copy(a,b)
100 # define VA_END(a) va_end(a)
102 # define VA_COPY(a,b) (a) = (b)