summaryrefslogtreecommitdiff
path: root/src/headerbody.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/headerbody.c')
-rw-r--r--src/headerbody.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/headerbody.c b/src/headerbody.c
index 82c5684..4173824 100644
--- a/src/headerbody.c
+++ b/src/headerbody.c
@@ -1,16 +1,18 @@
-#include "stralloc.h"
+#include "headerbody.h"
+
#include "buffer.h"
#include "getln.h"
+#include "stralloc.h"
+
#include "hfield.h"
-#include "headerbody.h"
-static int getsa(buffer *b,stralloc *sa,int *match)
+static int getsa(buffer *b, stralloc *sa, int *match)
{
if (!*match) return 0;
- if (getln(b,sa,match,'\n') == -1) return -1;
+ if (getln(b, sa, match, '\n') == -1) return -1;
if (*match) return 1;
if (!sa->len) return 0;
- if (!stralloc_append(sa,"\n")) return -1;
+ if (!stralloc_append(sa, "\n")) return -1;
return 1;
}
@@ -18,7 +20,7 @@ static int getsa(buffer *b,stralloc *sa,int *match)
static stralloc line = {0};
static stralloc nextline = {0};
-int headerbody(b,dohf,hdone,dobl)
+int headerbody(b, dohf, hdone, dobl)
buffer *b;
void (*dohf)();
void (*hdone)();
@@ -30,9 +32,8 @@ void (*dobl)();
flaglineok = 0;
for (;;) {
- switch (getsa(b,&nextline,&match)) {
- case -1:
- return -1;
+ switch (getsa(b, &nextline, &match)) {
+ case -1: return -1;
case 0:
if (flaglineok) dohf(&line);
hdone();
@@ -42,7 +43,7 @@ void (*dobl)();
if (flaglineok) {
if ((nextline.s[0] == ' ') || (nextline.s[0] == '\t')) {
- if (!stralloc_cat(&line,&nextline)) return -1;
+ if (!stralloc_cat(&line, &nextline)) return -1;
continue;
}
dohf(&line);
@@ -54,14 +55,14 @@ void (*dobl)();
break;
}
- if (stralloc_starts(&nextline,"From ")) {
- if (!stralloc_copys(&line,"MBOX-Line: ")) return -1;
- if (!stralloc_cat(&line,&nextline)) return -1;
- } else if (hfield_valid(nextline.s,nextline.len)) {
- if (!stralloc_copy(&line,&nextline)) return -1;
+ if (stralloc_starts(&nextline, "From ")) {
+ if (!stralloc_copys(&line, "MBOX-Line: ")) return -1;
+ if (!stralloc_cat(&line, &nextline)) return -1;
+ } else if (hfield_valid(nextline.s, nextline.len)) {
+ if (!stralloc_copy(&line, &nextline)) return -1;
} else {
hdone();
- if (!stralloc_copys(&line,"\n")) return -1;
+ if (!stralloc_copys(&line, "\n")) return -1;
dobl(&line);
dobl(&nextline);
break;
@@ -69,10 +70,10 @@ void (*dobl)();
flaglineok = 1;
}
- for (;;)
- switch (getsa(b,&nextline,&match)) {
+ for (;;) switch (getsa(b, &nextline, &match))
+ {
case -1: return -1;
- case 0: return 0;
- case 1: dobl(&nextline);
+ case 0: return 0;
+ case 1: dobl(&nextline);
}
}