5 #include "headerbody.h"
7 static int getsa(ss,sa,match)
12 if (!*match) return 0;
13 if (getln(ss,sa,match,'\n') == -1) return -1;
15 if (!sa->len) return 0;
16 if (!stralloc_append(sa,"\n")) return -1;
20 static stralloc line = {0};
21 static stralloc nextline = {0};
23 int headerbody(ss,dohf,hdone,dobl)
35 switch(getsa(ss,&nextline,&match))
40 if (flaglineok) dohf(&line);
42 /* no message body; could insert blank line here */
47 if ((nextline.s[0] == ' ') || (nextline.s[0] == '\t'))
49 if (!stralloc_cat(&line,&nextline)) return -1;
54 if (nextline.len == 1)
60 if (stralloc_starts(&nextline,"From "))
62 if (!stralloc_copys(&line,"MBOX-Line: ")) return -1;
63 if (!stralloc_cat(&line,&nextline)) return -1;
66 if (hfield_valid(nextline.s,nextline.len))
68 if (!stralloc_copy(&line,&nextline)) return -1;
73 if (!stralloc_copys(&line,"\n")) return -1;
81 switch(getsa(ss,&nextline,&match))
85 case 1: dobl(&nextline);