aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-14 15:40:48 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-14 15:40:48 +0200
commit54f695dddf65bc8270825fdf08ed0ddc34a58ec3 (patch)
tree39e1f5b88af5d26ede8f3d98c9b2759d96a33d4c
parentff7771d4fb524148e21045b911a869041b9271af (diff)
downloadmblaze-54f695dddf65bc8270825fdf08ed0ddc34a58ec3.tar.gz
blaze822: iterate over headers
-rw-r--r--blaze822.c17
-rw-r--r--blaze822.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/blaze822.c b/blaze822.c
index 53fc2e4..6f6542a 100644
--- a/blaze822.c
+++ b/blaze822.c
@@ -559,3 +559,20 @@ blaze822_bodylen(struct message *mesg)
return 0;
return mesg->bodyend - mesg->body;
}
+
+char *
+blaze822_next_header(struct message *mesg, char *prev)
+{
+ if (!prev) {
+ prev = mesg->msg;
+ } else {
+ if (prev >= mesg->end)
+ return 0;
+ prev = prev + strlen(prev);
+ }
+ while (prev < mesg->end && *prev == 0)
+ prev++;
+ if (prev >= mesg->end)
+ return 0;
+ return prev;
+}
diff --git a/blaze822.h b/blaze822.h
index 7626ca2..190cb55 100644
--- a/blaze822.h
+++ b/blaze822.h
@@ -13,6 +13,8 @@ struct message *blaze822_mem(char *buf, size_t len); // header + body
char *blaze822_hdr_(struct message *mesg, const char *hdr, size_t len);
#define blaze822_hdr(mesg, hdr) blaze822_hdr_(mesg, "\0" hdr ":", 2+strlen((hdr)))
+char *blaze822_next_header(struct message *mesg, char *prev);
+
void blaze822_free(struct message *mesg);
time_t blaze822_date(char *);