Blame


1 f7012583 2003-11-25 devnull #ifndef _FMT_H_
2 f7012583 2003-11-25 devnull #define _FMT_H_ 1
3 f7012583 2003-11-25 devnull #if defined(__cplusplus)
4 f7012583 2003-11-25 devnull extern "C" {
5 f7012583 2003-11-25 devnull #endif
6 b2cfc4e2 2003-09-30 devnull /*
7 b2cfc4e2 2003-09-30 devnull * The authors of this software are Rob Pike and Ken Thompson.
8 b2cfc4e2 2003-09-30 devnull * Copyright (c) 2002 by Lucent Technologies.
9 b2cfc4e2 2003-09-30 devnull * Permission to use, copy, modify, and distribute this software for any
10 b2cfc4e2 2003-09-30 devnull * purpose without fee is hereby granted, provided that this entire notice
11 b2cfc4e2 2003-09-30 devnull * is included in all copies of any software which is or includes a copy
12 b2cfc4e2 2003-09-30 devnull * or modification of this software and in all copies of the supporting
13 b2cfc4e2 2003-09-30 devnull * documentation for such software.
14 b2cfc4e2 2003-09-30 devnull * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
15 b2cfc4e2 2003-09-30 devnull * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
16 b2cfc4e2 2003-09-30 devnull * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
17 b2cfc4e2 2003-09-30 devnull * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
18 b2cfc4e2 2003-09-30 devnull */
19 b2cfc4e2 2003-09-30 devnull
20 b2cfc4e2 2003-09-30 devnull #include <stdarg.h>
21 b2cfc4e2 2003-09-30 devnull #include <utf.h>
22 b2cfc4e2 2003-09-30 devnull
23 b2cfc4e2 2003-09-30 devnull typedef struct Fmt Fmt;
24 b2cfc4e2 2003-09-30 devnull struct Fmt{
25 b2cfc4e2 2003-09-30 devnull unsigned char runes; /* output buffer is runes or chars? */
26 b2cfc4e2 2003-09-30 devnull void *start; /* of buffer */
27 b2cfc4e2 2003-09-30 devnull void *to; /* current place in the buffer */
28 b2cfc4e2 2003-09-30 devnull void *stop; /* end of the buffer; overwritten if flush fails */
29 b2cfc4e2 2003-09-30 devnull int (*flush)(Fmt *); /* called when to == stop */
30 b2cfc4e2 2003-09-30 devnull void *farg; /* to make flush a closure */
31 b2cfc4e2 2003-09-30 devnull int nfmt; /* num chars formatted so far */
32 b2cfc4e2 2003-09-30 devnull va_list args; /* args passed to dofmt */
33 b2cfc4e2 2003-09-30 devnull int r; /* % format Rune */
34 b2cfc4e2 2003-09-30 devnull int width;
35 b2cfc4e2 2003-09-30 devnull int prec;
36 b2cfc4e2 2003-09-30 devnull unsigned long flags;
37 b2cfc4e2 2003-09-30 devnull };
38 b2cfc4e2 2003-09-30 devnull
39 b2cfc4e2 2003-09-30 devnull enum{
40 b2cfc4e2 2003-09-30 devnull FmtWidth = 1,
41 b2cfc4e2 2003-09-30 devnull FmtLeft = FmtWidth << 1,
42 b2cfc4e2 2003-09-30 devnull FmtPrec = FmtLeft << 1,
43 b2cfc4e2 2003-09-30 devnull FmtSharp = FmtPrec << 1,
44 b2cfc4e2 2003-09-30 devnull FmtSpace = FmtSharp << 1,
45 b2cfc4e2 2003-09-30 devnull FmtSign = FmtSpace << 1,
46 b2cfc4e2 2003-09-30 devnull FmtZero = FmtSign << 1,
47 b2cfc4e2 2003-09-30 devnull FmtUnsigned = FmtZero << 1,
48 b2cfc4e2 2003-09-30 devnull FmtShort = FmtUnsigned << 1,
49 b2cfc4e2 2003-09-30 devnull FmtLong = FmtShort << 1,
50 b2cfc4e2 2003-09-30 devnull FmtVLong = FmtLong << 1,
51 b2cfc4e2 2003-09-30 devnull FmtComma = FmtVLong << 1,
52 b2cfc4e2 2003-09-30 devnull FmtByte = FmtComma << 1,
53 b2cfc4e2 2003-09-30 devnull FmtLDouble = FmtByte << 1,
54 b2cfc4e2 2003-09-30 devnull
55 b2cfc4e2 2003-09-30 devnull FmtFlag = FmtLDouble << 1
56 b2cfc4e2 2003-09-30 devnull };
57 b2cfc4e2 2003-09-30 devnull
58 b2cfc4e2 2003-09-30 devnull extern int (*fmtdoquote)(int);
59 b2cfc4e2 2003-09-30 devnull
60 8bbb2f64 2004-12-25 devnull /* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/fmt/?*.c | grep -v static |grep -v __ */
61 8bbb2f64 2004-12-25 devnull int dofmt(Fmt *f, char *fmt);
62 8bbb2f64 2004-12-25 devnull int dorfmt(Fmt *f, const Rune *fmt);
63 8bbb2f64 2004-12-25 devnull double fmtcharstod(int(*f)(void*), void *vp);
64 8bbb2f64 2004-12-25 devnull int fmtfdflush(Fmt *f);
65 8bbb2f64 2004-12-25 devnull int fmtfdinit(Fmt *f, int fd, char *buf, int size);
66 8bbb2f64 2004-12-25 devnull int fmtinstall(int c, int (*f)(Fmt*));
67 8bbb2f64 2004-12-25 devnull int fmtprint(Fmt *f, char *fmt, ...);
68 8bbb2f64 2004-12-25 devnull int fmtrune(Fmt *f, int r);
69 8bbb2f64 2004-12-25 devnull int fmtrunestrcpy(Fmt *f, Rune *s);
70 8bbb2f64 2004-12-25 devnull int fmtstrcpy(Fmt *f, char *s);
71 8bbb2f64 2004-12-25 devnull char* fmtstrflush(Fmt *f);
72 8bbb2f64 2004-12-25 devnull int fmtstrinit(Fmt *f);
73 8bbb2f64 2004-12-25 devnull double fmtstrtod(const char *as, char **aas);
74 8bbb2f64 2004-12-25 devnull int fmtvprint(Fmt *f, char *fmt, va_list args);
75 8bbb2f64 2004-12-25 devnull int fprint(int fd, char *fmt, ...);
76 8bbb2f64 2004-12-25 devnull int print(char *fmt, ...);
77 8bbb2f64 2004-12-25 devnull void quotefmtinstall(void);
78 8bbb2f64 2004-12-25 devnull int quoterunestrfmt(Fmt *f);
79 8bbb2f64 2004-12-25 devnull int quotestrfmt(Fmt *f);
80 8bbb2f64 2004-12-25 devnull Rune* runefmtstrflush(Fmt *f);
81 8bbb2f64 2004-12-25 devnull int runefmtstrinit(Fmt *f);
82 8bbb2f64 2004-12-25 devnull Rune* runeseprint(Rune *buf, Rune *e, char *fmt, ...);
83 8bbb2f64 2004-12-25 devnull Rune* runesmprint(char *fmt, ...);
84 8bbb2f64 2004-12-25 devnull int runesnprint(Rune *buf, int len, char *fmt, ...);
85 8bbb2f64 2004-12-25 devnull int runesprint(Rune *buf, char *fmt, ...);
86 8bbb2f64 2004-12-25 devnull Rune* runevseprint(Rune *buf, Rune *e, char *fmt, va_list args);
87 8bbb2f64 2004-12-25 devnull Rune* runevsmprint(char *fmt, va_list args);
88 8bbb2f64 2004-12-25 devnull int runevsnprint(Rune *buf, int len, char *fmt, va_list args);
89 8bbb2f64 2004-12-25 devnull char* seprint(char *buf, char *e, char *fmt, ...);
90 8bbb2f64 2004-12-25 devnull char* smprint(char *fmt, ...);
91 8bbb2f64 2004-12-25 devnull int snprint(char *buf, int len, char *fmt, ...);
92 8bbb2f64 2004-12-25 devnull int sprint(char *buf, char *fmt, ...);
93 8bbb2f64 2004-12-25 devnull int vfprint(int fd, char *fmt, va_list args);
94 8bbb2f64 2004-12-25 devnull char* vseprint(char *buf, char *e, char *fmt, va_list args);
95 8bbb2f64 2004-12-25 devnull char* vsmprint(char *fmt, va_list args);
96 8bbb2f64 2004-12-25 devnull int vsnprint(char *buf, int len, char *fmt, va_list args);
97 b2cfc4e2 2003-09-30 devnull
98 f7012583 2003-11-25 devnull #if defined(__cplusplus)
99 f7012583 2003-11-25 devnull }
100 b2cfc4e2 2003-09-30 devnull #endif
101 f7012583 2003-11-25 devnull #endif