2 * The authors of this software are Rob Pike and Ken Thompson.
3 * Copyright (c) 2002 by Lucent Technologies.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose without fee is hereby granted, provided that this entire notice
6 * is included in all copies of any software which is or includes a copy
7 * or modification of this software and in all copies of the supporting
8 * documentation for such software.
9 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
10 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
11 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
12 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
16 * dofmt -- format to a buffer
17 * the number of characters formatted is returned,
18 * or -1 if there was an error.
19 * if the buffer is ever filled, flush is called.
20 * it should reset the buffer and return whether formatting should continue.
23 typedef int (*Fmts)(Fmt*);
25 typedef struct Quoteinfo Quoteinfo;
28 int quoted; /* if set, string must be quoted */
29 int nrunesin; /* number of input runes that can be accepted */
30 int nbytesin; /* number of input bytes that can be accepted */
31 int nrunesout; /* number of runes that will be generated */
32 int nbytesout; /* number of bytes that will be generated */
35 /* Edit .+1,/^$/ |cfn |grep -v static | grep __ */
36 double __Inf(int sign);
39 int __charfmt(Fmt *f);
40 int __countfmt(Fmt *f);
41 int __efgfmt(Fmt *fmt);
43 int __flagfmt(Fmt *f);
44 int __fmtFdFlush(Fmt *f);
45 int __fmtcpy(Fmt *f, const void *vm, int n, int sz);
46 void* __fmtdispatch(Fmt *f, void *fmt, int isrunes);
47 void * __fmtflush(Fmt *f, void *t, int len);
49 int __fmtpad(Fmt *f, int n);
50 double __fmtpow10(int n);
51 int __fmtrcpy(Fmt *f, const void *vm, int n);
52 void __fmtunlock(void);
54 int __isInf(double d, int sign);
55 int __isNaN(double d);
56 int __needsquotes(char *s, int *quotelenp);
57 int __percentfmt(Fmt *f);
58 void __quotesetup(char *s, Rune *r, int nin, int nout, Quoteinfo *q, int sharp, int runesout);
59 int __quotestrfmt(int runesin, Fmt *f);
60 int __rfmtpad(Fmt *f, int n);
61 int __runefmt(Fmt *f);
62 int __runeneedsquotes(Rune *r, int *quotelenp);
63 int __runesfmt(Fmt *f);
66 #define FMTCHAR(f, t, s, c)\
68 if(t + 1 > (char*)s){\
69 t = __fmtflush(f, t, 1);\
78 #define FMTRCHAR(f, t, s, c)\
80 if(t + 1 > (Rune*)s){\
81 t = __fmtflush(f, t, sizeof(Rune));\
90 #define FMTRUNE(f, t, s, r)\
94 if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*)s){\
95 t = __fmtflush(f, t, _runelen);\
105 t += runetochar(t, &_rune);\
110 # define VA_COPY(a,b) va_copy(a,b)
111 # define VA_END(a) va_end(a)
113 # define VA_COPY(a,b) (a) = (b)