-
Notifications
You must be signed in to change notification settings - Fork 8
/
grok_mail_folder
executable file
·41 lines (36 loc) · 1.41 KB
/
grok_mail_folder
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
#! /usr/bin/awk -f
BEGIN { FALSE = 0; TRUE = 1 }
$1 == "From" && (byte_num == content_length + 1 || content_length == 0) \
{
in_header = TRUE
content_length = 0
byte_num = 0
++message_num
matched_to = FALSE
matched_cc = FALSE
matched_bcc = FALSE
}
in_header == FALSE { byte_num += length( $0 ) + 1 }
in_header == TRUE {
if (NF > 0)
{
if ($1 == "Content-Length:")
content_length = $2
else
if ($1 == "To:")
matched_to = /bugtraq/ || /BUGTRAQ/
else if ($1 ~ /^C[cC]:$/)
matched_cc = /bugtraq/ || /BUGTRAQ/
else if ($1 ~ /^B[cC][cC]:$/)
matched_bcc = /bugtraq/ || /BUGTRAQ/
else
if ($1 == "Subject:")
subject = substr( $0, 10 )
}
else
{
in_header = FALSE
if (! (matched_to || matched_cc || matched_bcc))
printf( "%3d %s\n", message_num, subject )
}
}