thttpfmt.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
thttpfmt.c (472B)
---
1 #include <u.h>
2 #include <libc.h>
3 #include <bin.h>
4 #include <httpd.h>
5
6 int
7 httpfmt(Fmt *f)
8 {
9 char buf[HMaxWord*2];
10 Rune r;
11 char *t, *s;
12 Htmlesc *l;
13
14 s = va_arg(f->args, char*);
15 for(t = buf; t < buf + sizeof(buf) - 8; ){
16 s += chartorune(&r, s);
17 if(r == 0)
18 break;
19 for(l = htmlesc; l->name != nil; l++)
20 if(l->value == r)
21 break;
22 if(l->name != nil){
23 strcpy(t, l->name);
24 t += strlen(t);
25 }else
26 *t++ = r;
27 }
28 *t = 0;
29 return fmtstrcpy(f, buf);
30 }