diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-11-11 14:49:35 -0800 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-11-11 14:49:35 -0800 |
commit | c65794b50b1bc729e7a4e940b76a973afa3030b9 (patch) | |
tree | bc435fea0f3179ac9a4b8de9fdaf993dade9e4ff /include | |
parent | cc7d219e080263da9813e570436bfd34ab8b1bff (diff) |
feat: libfmt prototype added from plan9
Diffstat (limited to 'include')
-rw-r--r-- | include/libfmt.h | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/include/libfmt.h b/include/libfmt.h index 17effc6..7ba40a0 100644 --- a/include/libfmt.h +++ b/include/libfmt.h @@ -9,13 +9,21 @@ struct fmt·State char *cur; char *end; } buffer; - int (*flush)(fmt·State *); int n; + va_list args; rune verb; ulong flag; int width; int prec; + char *thousands, *groups, *decimal; + + void *file; + int (*flush)(fmt·State *); + struct { + void *heap; + mem·Reallocator mem; + }; }; #define iota(x) (1 << (x)) @@ -41,22 +49,24 @@ enum #undef iota /* normal printing interface */ -int fmt·print(char *fmt, ...); -int fmt·fprint(int fd, char *fmt, ...); - -int fmt·sprint(char *buf, char *fmt, ...); -int fmt·nsprint(int len, char *buf, char *fmt, ...); -int fmt·esprint(char *buf, char *end, char *fmt, ...); - -int fmt·vprint(char *fmt, va_list args); -int fmt·vfprint(int fd, char *fmt, va_list args); -int fmt·vwrite(char *buf, char *fmt, va_list args); -int fmt·vnwrite(int len, char *buf, char *fmt, va_list args); -int fmt·vewrite(char *buf, char *end, char *fmt, va_list args); - -/* low-level interface: custom printing verbs */ -int fmt·do(fmt·State *, char *fmt); -int fmt·put(fmt·State *, char *fmt, ...); -int fmt·vput(fmt·State *, char *fmt, va_list args); -int fmt·install(fmt·State *, int (*put)(fmt·State*)); -int fmt·flush(fmt·State *); +int fmt·print(char *fmt, ...); +int fmt·fprint(int fd, char *fmt, ...); + +int fmt·sprint(char *buf, char *fmt, ...); +int fmt·nsprint(int len, char *buf, char *fmt, ...); +char *fmt·esprint(char *buf, char *end, char *fmt, ...); + +int fmt·vprint(char *fmt, va_list args); +int fmt·vfprint(int fd, char *fmt, va_list args); +int fmt·vnsprint(int len, char *buf, char *fmt, va_list args); +char *fmt·vesprint(char *buf, char *end, char *fmt, va_list args); + +/* low-level interface: used for custom printing verbs */ +int fmt·open(int fd, int len, char *buf, fmt·State *); // creates a buffer on a file +int fmt·make(mem·Reallocator mem, void *heap, fmt·State *); // creates an in-memory buffer +void fmt·free(fmt·State *); // releases an in-memory buffer + +int fmt·do(fmt·State *, char *fmt); +int fmt·write(fmt·State *, char *fmt, ...); +int fmt·vwrite(fmt·State *, char *fmt, va_list args); +int fmt·install(int c, int (*format)(fmt·State *)); |