12 formathtml(char *body, int *np)
19 e = emalloc(sizeof(struct Exec));
20 if(pipe(p) < 0 || pipe(q) < 0)
21 error("can't create pipe: %r");
27 e->argv = emalloc(3*sizeof(char*));
28 e->argv[0] = estrdup("htmlfmt");
29 e->argv[1] = estrdup("-cutf-8");
31 e->prog = unsharp("#9/bin/htmlfmt");
32 sync = chancreate(sizeof(int), 0);
34 proccreate(execproc, e, EXECSTACK);
39 if((i=write(p[1], body, *np)) != *np){
40 fprint(2, "Mail: warning: htmlfmt failed: wrote %d of %d: %r\n", i, *np);
51 j = read(q[0], buf, sizeof buf);
54 body = realloc(body, i+j+1);
56 error("realloc failed: %r");
57 memmove(body+i, buf, j);
68 readbody(char *type, char *dir, int *np)
72 body = readfile(dir, "body", np);
73 if(body != nil && strcmp(type, "text/html") == 0)
74 return formathtml(body, np);