Mercurial > urweb
diff src/c/lacweb.c @ 106:d101cb1efe55
More with attributes and efficient serialization
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 10 Jul 2008 15:49:14 -0400 |
parents | 5f04adf47f48 |
children | 94856a3b4752 |
line wrap: on
line diff
--- a/src/c/lacweb.c Thu Jul 10 15:19:06 2008 -0400 +++ b/src/c/lacweb.c Thu Jul 10 15:49:14 2008 -0400 @@ -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); +}