Factor out code to read mailboxes, and make read more robust

New tel_read_header(), tel_read_body().  Use them in rea(),
show_first_tel(), copy_and_expire().

rea() now stops when it encounters a corrupt telegram, and logs the
problem.  Before, error detection was incomplete, and errors were not
logged.  Corrupt mailboxes could make it crash.

show_first_tel() and copy_and_expire() can now cope with telegrams of
arbitrary length, like rea(), and sanity-check the header fields they
don't actually use.
This commit is contained in:
Markus Armbruster 2009-02-08 11:13:25 +01:00
parent 6f1e669bea
commit 4238323d63
5 changed files with 114 additions and 76 deletions

View file

@ -34,6 +34,7 @@
#ifndef TEL_H
#define TEL_H
#include <stdio.h>
#include <time.h>
#include "types.h"
@ -55,5 +56,9 @@ struct telstr {
};
extern char *mailbox(char *buf, natid cn);
extern int tel_read_header(FILE *, char *, struct telstr *);
extern int tel_read_body(FILE *, char *, struct telstr *,
int (*sink)(char *, size_t, void *),
void *);
#endif