11 formathtml(char *body, int *np)
18 e = emalloc(sizeof(struct Exec));
19 if(pipe(p) < 0 || pipe(q) < 0)
20 error("can't create pipe: %r");
26 e->argv = emalloc(3*sizeof(char*));
27 e->argv[0] = estrdup("htmlfmt");
28 e->argv[1] = estrdup("-cutf-8");
30 e->prog = "/bin/htmlfmt";
31 sync = chancreate(sizeof(int), 0);
33 proccreate(execproc, e, EXECSTACK);
38 if((i=write(p[1], body, *np)) != *np){
39 fprint(2, "Mail: warning: htmlfmt failed: wrote %d of %d: %r\n", i, *np);
50 j = read(q[0], buf, sizeof buf);
53 body = realloc(body, i+j+1);
55 error("realloc failed: %r");
56 memmove(body+i, buf, j);
67 readbody(char *type, char *dir, int *np)
71 body = readfile(dir, "body", np);
72 if(body != nil && strcmp(type, "text/html") == 0)
73 return formathtml(body, np);