+static void dump_envelope(buffer_t *buf, ENVELOPE * e)
+{
+ int n;
+
+ dump_address(buf, e->return_path);
+ dump_address(buf, e->from);
+ dump_address(buf, e->to);
+ dump_address(buf, e->cc);
+ dump_address(buf, e->bcc);
+ dump_address(buf, e->sender);
+ dump_address(buf, e->reply_to);
+ dump_address(buf, e->mail_followup_to);
+
+ dump_cstr(buf, e->subject);
+ n = e->real_subj ? e->real_subj - e->subject : -1;
+ dump_int(buf, n);
+
+ dump_cstr(buf, e->message_id);
+ dump_cstr(buf, e->supersedes);
+ dump_cstr(buf, e->date);
+ dump_cstr(buf, e->x_label);
+ dump_cstr(buf, e->list_post);
+
+ dump_list(buf, e->references);
+ dump_list(buf, e->in_reply_to);
+ dump_list(buf, e->userhdrs);
+}
+
+static const void *restore_envelope(const char *d, ENVELOPE *e)
+{
+ int real_subj_off;
+
+ d = restore_address(d, &e->return_path);
+ d = restore_address(d, &e->from);
+ d = restore_address(d, &e->to);
+ d = restore_address(d, &e->cc);
+ d = restore_address(d, &e->bcc);
+ d = restore_address(d, &e->sender);
+ d = restore_address(d, &e->reply_to);
+ d = restore_address(d, &e->mail_followup_to);
+
+ d = restore_cstr(d, &e->subject);
+ d = restore_int(d, &real_subj_off);
+ if (real_subj_off >= 0) {
+ e->real_subj = e->subject + real_subj_off;
+ } else {
+ e->real_subj = NULL;
+ }
+ d = restore_cstr(d, &e->message_id);
+ d = restore_cstr(d, &e->supersedes);
+ d = restore_cstr(d, &e->date);
+ d = restore_cstr(d, &e->x_label);
+ d = restore_cstr(d, &e->list_post);
+
+ d = restore_list(d, &e->references);
+ d = restore_list(d, &e->in_reply_to);
+ d = restore_list(d, &e->userhdrs);
+ return d;