aboutsummaryrefslogtreecommitdiff
path: root/hdr.c
blob: 03ac9859e4de3ae7b481deb43a26da62da25dbb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <wchar.h>

#include "blaze822.h"

static size_t l;
static char *hdr;

void
header(char *file)
{
	struct message *msg;

	msg = blaze822(file);
	if (!msg)
		return;

	char *v = blaze822_hdr_(msg, hdr, l);
	if (v)
		printf("%s\n", v);
}

int
main(int argc, char *argv[])
{
	l = strlen(argv[1])+2;
        hdr = malloc(l);
	hdr[0] = 0;
	char *s = hdr+1;
	char *t = argv[1];
	while (*t)
		*s++ = tolower(*t++);
	*s = ':';

	int i = blaze822_loop(argc-2, argv+2, header);
	
	printf("%d mails scanned\n", i);
	
	return 0;
}