Introduction
Introduction Statistics Contact Development Disclaimer Help
fmtdef.h - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
fmtdef.h (2840B)
---
1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
2
3 /*
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 conti…
9 */
10
11 typedef int (*Fmts)(Fmt*);
12
13 typedef struct Quoteinfo Quoteinfo;
14 struct Quoteinfo
15 {
16 int quoted; /* if set, string must be quot…
17 int nrunesin; /* number of input runes that can be…
18 int nbytesin; /* number of input bytes that can be…
19 int nrunesout; /* number of runes that will be gen…
20 int nbytesout; /* number of bytes that will be gen…
21 };
22
23 /* Edit .+1,/^$/ |cfn |grep -v static | grep __ */
24 double __Inf(int sign);
25 double __NaN(void);
26 int __badfmt(Fmt *f);
27 int __charfmt(Fmt *f);
28 int __countfmt(Fmt *f);
29 int __efgfmt(Fmt *fmt);
30 int __errfmt(Fmt *f);
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);
36 void __fmtlock(void);
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);
41 int __ifmt(Fmt *f);
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…
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);
53 int __strfmt(Fmt *f);
54
55 #define FMTCHAR(f, t, s, c)\
56 do{\
57 if(t + 1 > (char*)s){\
58 t = (char*)__fmtflush(f, t, 1);\
59 if(t != nil)\
60 s = (char*)f->stop;\
61 else\
62 return -1;\
63 }\
64 *t++ = c;\
65 }while(0)
66
67 #define FMTRCHAR(f, t, s, c)\
68 do{\
69 if(t + 1 > (Rune*)s){\
70 t = (Rune*)__fmtflush(f, t, sizeof(Rune));\
71 if(t != nil)\
72 s = (Rune*)f->stop;\
73 else\
74 return -1;\
75 }\
76 *t++ = c;\
77 }while(0)
78
79 #define FMTRUNE(f, t, s, r)\
80 do{\
81 Rune _rune;\
82 int _runelen;\
83 if(t + UTFmax > (char*)s && t + (_runelen = runelen(r)) > (char*…
84 t = (char*)__fmtflush(f, t, _runelen);\
85 if(t != nil)\
86 s = (char*)f->stop;\
87 else\
88 return -1;\
89 }\
90 if(r < Runeself)\
91 *t++ = r;\
92 else{\
93 _rune = r;\
94 t += runetochar(t, &_rune);\
95 }\
96 }while(0)
97
98 #ifdef va_copy
99 # define VA_COPY(a,b) va_copy(a,b)
100 # define VA_END(a) va_end(a)
101 #else
102 # define VA_COPY(a,b) (a) = (b)
103 # define VA_END(a)
104 #endif
105
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.