/*
Displays all contents related to email
content.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <eps.h>
int main(int argc, char *argv[])
{
char *l = NULL;
int ret = 0, fd = 0;
mime_t *m = NULL;
header_t *h = NULL;
eps_t *eps = NULL;
if (argc < 2)
fd = 0;
else {
fd = open(argv[1], O_RDONLY);
if (fd == -1)
return 1;
}
ret = 0;
eps = eps_begin(INTERFACE_STREAM, &fd);
if (!eps)
return 1;
for (h = eps_next_header(eps); h; h = eps_next_header(eps)) {
if ((h->name) && (h->data))
printf("HEADER:[%s]\n", h->orig);
eps_header_free(eps);
}
printf("\n");
for (l = eps_next_line(eps); l; l = eps_next_line(eps))
printf("LINE:[%s]\n", l);
printf("\n");
while((!(eps->u->b->eof)) && (eps->content_type & CON_MULTI)) {
ret = mime_init_stream(eps);
if (!ret)
break;
for (h = mime_next_header(eps); h; h = mime_next_header(eps)) {
if ((h->name) && (h->data)) {
printf("MHEADER:[%s]\n", h->orig);
}
}
for (l = mime_next_line(eps); l; l = mime_next_line(eps))
printf("MLINE:[%s]\n", l);
printf("\n");
}
eps_end(eps);
return 0;
}
syntax highlighted by Code2HTML, v. 0.9.1