diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-10 15:49:14 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-10 15:49:14 -0400 |
commit | 0e95aa2c802d0a4fa54ebf985133eb2584a1d9ba (patch) | |
tree | f8d063fc040cfc82b2b55093ef6053799b1c0a97 /src/c | |
parent | 0c1f369955bcdfe949bb6793812ef8ead2963228 (diff) |
More with attributes and efficient serialization
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/lacweb.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/c/lacweb.c b/src/c/lacweb.c index 5054d8d5..10ccd6a0 100644 --- a/src/c/lacweb.c +++ b/src/c/lacweb.c @@ -1,9 +1,51 @@ #include <stdio.h> +#include <ctype.h> #include "types.h" lw_unit lw_unit_v = {}; +void lw_writec(char c) { + fputc(c, stdout); +} + void lw_write(const char* s) { fputs(s, stdout); } + +char *lw_Basis_attrifyInt(lw_Basis_int n) { + return "0"; +} + +char *lw_Basis_attrifyFloat(lw_Basis_float n) { + return "0.0"; +} + +char *lw_Basis_attrifyString(lw_Basis_string s) { + return ""; +} + +char *lw_Basis_attrifyInt_w(lw_Basis_int n) { + printf("%d", n); +} + +char *lw_Basis_attrifyFloat_w(lw_Basis_float n) { + printf("%g", n); +} + +char *lw_Basis_attrifyString_w(lw_Basis_string s) { + for (; *s; s++) { + char c = *s; + + if (c == '"') + lw_write("""); + else if (isprint(c)) + lw_writec(c); + else { + lw_write("&#"); + lw_Basis_attrifyInt_w(c); + lw_writec(';'); + } + } + lw_write(s); +} |