aboutsummaryrefslogtreecommitdiff
path: root/include/libfmt.h
diff options
context:
space:
mode:
authorNicholas <nbnoll@eml.cc>2021-11-20 10:53:19 -0800
committerNicholas <nbnoll@eml.cc>2021-11-20 10:53:19 -0800
commita9bfe650038afea8b751175cac16f6027345e45f (patch)
tree9a7f9feb76a64bb3efe573036d80b7bdbf8a59a5 /include/libfmt.h
parent1c8d4e69205fd875f6bec3fa3bd929c2e7f52f62 (diff)
Chore: reorganize libutf and libfmt into base
I found the split to be arbitrary. Better to include the functionality in the standard library. I also split the headers to allow for more granular inclusion (but the library is still monolithic). The only ugliness is the circular dependency introduced with libutf's generated functions. We put explicit prereqs with the necessary object files instead.
Diffstat (limited to 'include/libfmt.h')
-rw-r--r--include/libfmt.h73
1 files changed, 0 insertions, 73 deletions
diff --git a/include/libfmt.h b/include/libfmt.h
deleted file mode 100644
index 4c187fd..0000000
--- a/include/libfmt.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-typedef struct fmt·State fmt·State;
-
-struct fmt·State
-{
- struct{
- char *beg;
- char *cur;
- char *end;
- } buffer;
- 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))
-enum
-{
- fmt·Width = iota(0),
- fmt·Left = iota(1),
- fmt·Prec = iota(2),
- fmt·Sharp = iota(3),
- fmt·Space = iota(4),
- fmt·Sign = iota(5),
- fmt·Apost = iota(6),
- fmt·Zero = iota(7),
- fmt·Unsigned = iota(8),
- fmt·Short = iota(9),
- fmt·Long = iota(10),
- fmt·Vlong = iota(11),
- fmt·Comma = iota(12),
- fmt·Byte = iota(13),
- fmt·Ldouble = iota(14),
- fmt·Flag = iota(15),
-};
-#undef iota
-
-/* normal printing interface */
-int fmt·print(char *fmt, ...);
-int fmt·fprint(int fd, char *fmt, ...);
-void fmt·panic(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 *));