| formathtml(char *body, int *np) |
| e = emalloc(sizeof(struct Exec)); |
| if(pipe(p) < 0 || pipe(q) < 0) |
| error("can't create pipe: %r"); |
| e->argv = emalloc(3*sizeof(char*)); |
| e->argv[0] = estrdup("htmlfmt"); |
| e->argv[1] = estrdup("-cutf-8"); |
| sync = chancreate(sizeof(int), 0); |
| proccreate(execproc, e, EXECSTACK); |
| if((i=write(p[1], body, *np)) != *np){ |
| fprint(2, "Mail: warning: htmlfmt failed: wrote %d of %d: %r\n", i, *np); |
| j = read(q[0], buf, sizeof buf); |
| body = realloc(body, i+j+1); |
| error("realloc failed: %r"); |
| readbody(char *type, char *dir, int *np) |
| body = readfile(dir, "body", np); |
| if(body != nil && strcmp(type, "text/html") == 0) |
| return formathtml(body, np); |