mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:51:59 +01:00
removed obsoleted test stuff
This commit is contained in:
parent
d203ee63d4
commit
c691a4e37e
@ -1,55 +0,0 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
mandir = @mandir@
|
||||
datarootdir = @datarootdir@
|
||||
localstatedir = @localstatedir@
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
||||
DEFS = @defs@
|
||||
INCDIR = -I. -I.. -I../.. -I../../src -I../src @INCDIR@ @sql_includes@
|
||||
LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../src
|
||||
LIBS = @LIBS@ @sql_libs@
|
||||
RUNNING_USER = @RUNNING_USER@
|
||||
RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)`
|
||||
OBJS = import_helper.o
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
all: $(OBJS) parser debug import ptest test
|
||||
|
||||
parser: parser.c ../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
ptest: ptest.c ../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
debug: debug.c ../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
import: import.c ../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler import_helper.o $(LIBS) $(LIBDIR)
|
||||
|
||||
test: test.c ../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) -fPIC $(INCDIR) $(DEFS) -c $< -o $@
|
||||
|
||||
|
||||
install:
|
||||
|
||||
clean:
|
||||
rm -f parser debug import ptest test
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in ../testemails/raw/*; do
|
||||
./test $i > aa;
|
||||
diff aa ../testemails/parsed/`basename $i`;
|
||||
if [ $? -eq 0 ]; then echo OK; else echo `basename $i`": ERROR"; fi
|
||||
done
|
||||
|
||||
rm -f aa
|
||||
|
||||
|
63
test/debug.c
63
test/debug.c
@ -1,63 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
struct stat st;
|
||||
struct session_data sdata;
|
||||
struct _state state;
|
||||
struct __data data;
|
||||
struct __config cfg;
|
||||
|
||||
|
||||
if(argc < 2){
|
||||
fprintf(stderr, "usage: %s <message>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(stat(argv[1], &st) != 0){
|
||||
fprintf(stderr, "%s is not found\n", argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
cfg = read_config(CONFIG_FILE);
|
||||
|
||||
|
||||
init_session_data(&sdata, &cfg);
|
||||
|
||||
sdata.sent = 0;
|
||||
sdata.tot_len = st.st_size;
|
||||
|
||||
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
|
||||
snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", argv[1]);
|
||||
snprintf(sdata.tmpframe, SMALLBUFSIZE-1, "%s.m", argv[1]);
|
||||
|
||||
cfg.debug = 1;
|
||||
|
||||
state = parse_message(&sdata, 0, &data, &cfg);
|
||||
post_parse(&sdata, &state, &cfg);
|
||||
|
||||
printf("message-id: %s\n", state.message_id);
|
||||
printf("from: *%s (%s)*\n", state.b_from, state.b_from_domain);
|
||||
printf("to: *%s (%s)*\n", state.b_to, state.b_to_domain);
|
||||
printf("reference: *%s*\n", state.reference);
|
||||
printf("subject: *%s*\n", state.b_subject);
|
||||
printf("body: *%s*\n", state.b_body);
|
||||
|
||||
printf("sent: %ld\n", sdata.sent);
|
||||
|
||||
make_digests(&sdata, &cfg);
|
||||
|
||||
return 0;
|
||||
}
|
250
test/import.c
250
test/import.c
@ -1,250 +0,0 @@
|
||||
/*
|
||||
* pilerimport.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <syslog.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
|
||||
int connect_to_imap_server(int sd, int *seq, char *imapserver, char *username, char *password);
|
||||
int list_folders(int sd, int *seq, char *folders, int foldersize);
|
||||
int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, struct __config *cfg);
|
||||
int import_message2(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg);
|
||||
|
||||
|
||||
int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
FILE *F, *f=NULL;
|
||||
int rc=ERR, tot_msgs=0, ret=OK;
|
||||
char buf[MAXBUFSIZE], fname[SMALLBUFSIZE];
|
||||
time_t t;
|
||||
|
||||
|
||||
F = fopen(mailbox, "r");
|
||||
if(!F){
|
||||
printf("cannot open mailbox: %s\n", mailbox);
|
||||
return rc;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
while(fgets(buf, sizeof(buf)-1, F)){
|
||||
|
||||
if(buf[0] == 'F' && buf[1] == 'r' && buf[2] == 'o' && buf[3] == 'm' && buf[4] == ' '){
|
||||
tot_msgs++;
|
||||
if(f){
|
||||
fclose(f);
|
||||
rc = import_message2(fname, sdata, data, cfg);
|
||||
printf("processed: %7d\r", tot_msgs); fflush(stdout);
|
||||
|
||||
if(rc == ERR) ret = ERR;
|
||||
unlink(fname);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs);
|
||||
f = fopen(fname, "w+");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(f) fprintf(f, "%s", buf);
|
||||
}
|
||||
|
||||
if(f){
|
||||
fclose(f);
|
||||
rc = import_message2(fname, sdata, data, cfg);
|
||||
printf("processed: %7d\r", tot_msgs); fflush(stdout);
|
||||
|
||||
if(rc == ERR) ret = ERR;
|
||||
unlink(fname);
|
||||
}
|
||||
|
||||
fclose(F);
|
||||
|
||||
printf("\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int import_from_maildir(char *directory, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
int rc=ERR, ret=OK, tot_msgs=0;
|
||||
char fname[SMALLBUFSIZE];
|
||||
struct stat st;
|
||||
|
||||
dir = opendir(directory);
|
||||
if(!dir){
|
||||
printf("cannot open directory: %s\n", directory);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
while((de = readdir(dir))){
|
||||
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
||||
|
||||
snprintf(fname, sizeof(fname)-1, "%s/%s", directory, de->d_name);
|
||||
|
||||
if(stat(fname, &st) == 0){
|
||||
if(S_ISDIR(st.st_mode)){
|
||||
rc = import_from_maildir(fname, sdata, data, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
}
|
||||
else {
|
||||
|
||||
if(S_ISREG(st.st_mode)){
|
||||
rc = import_message2(fname, sdata, data, cfg);
|
||||
if(rc == OK) tot_msgs++;
|
||||
else ret = ERR;
|
||||
}
|
||||
else {
|
||||
printf("%s is not a file\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("cannot stat() %s\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int import_from_imap_server(char *imapserver, char *username, char *password, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
int rc=ERR, ret=OK, sd, seq=1, result;
|
||||
char *p, puf[MAXBUFSIZE];
|
||||
char folders[MAXBUFSIZE];
|
||||
|
||||
if((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
|
||||
printf("cannot create socket\n");
|
||||
return ERR;
|
||||
}
|
||||
|
||||
if(connect_to_imap_server(sd, &seq, imapserver, username, password) == ERR){
|
||||
close(sd);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
list_folders(sd, &seq, &folders[0], sizeof(folders));
|
||||
|
||||
|
||||
p = &folders[0];
|
||||
do {
|
||||
memset(puf, 0, sizeof(puf));
|
||||
p = split(p, '\n', puf, sizeof(puf)-1, &result);
|
||||
|
||||
printf("processing folder: %s... ", puf);
|
||||
|
||||
rc = process_imap_folder(sd, &seq, puf, sdata, data, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
|
||||
} while(p);
|
||||
|
||||
|
||||
close(sd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void usage(){
|
||||
printf("usage: pilerimport [-c <config file>] -e <eml file> | -m <mailbox file> | -d <directory> | -i <imap server> -u <imap username> -p <imap password>\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int i, rc=0;
|
||||
char *configfile=CONFIG_FILE, *mailbox=NULL, *emlfile=NULL, *directory=NULL;
|
||||
char *imapserver=NULL, *username=NULL, *password=NULL;
|
||||
struct session_data sdata;
|
||||
struct __config cfg;
|
||||
struct __data data;
|
||||
|
||||
|
||||
while((i = getopt(argc, argv, "c:m:e:d:i:u:p:h?")) > 0){
|
||||
switch(i){
|
||||
|
||||
case 'c' :
|
||||
configfile = optarg;
|
||||
break;
|
||||
|
||||
case 'e' :
|
||||
emlfile = optarg;
|
||||
break;
|
||||
|
||||
case 'd' :
|
||||
directory = optarg;
|
||||
break;
|
||||
|
||||
case 'm' :
|
||||
mailbox = optarg;
|
||||
break;
|
||||
|
||||
case 'i' :
|
||||
imapserver = optarg;
|
||||
break;
|
||||
|
||||
case 'u' :
|
||||
username = optarg;
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
password = optarg;
|
||||
break;
|
||||
|
||||
case 'h' :
|
||||
case '?' :
|
||||
usage();
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!mailbox && !emlfile && !directory && !imapserver) usage();
|
||||
|
||||
|
||||
cfg = read_config(configfile);
|
||||
|
||||
setlocale(LC_CTYPE, cfg.locale);
|
||||
|
||||
initrules(data.archiving_rules);
|
||||
initrules(data.retention_rules);
|
||||
|
||||
if(emlfile) rc = import_message2(emlfile, &sdata, &data, &cfg);
|
||||
if(mailbox) rc = import_from_mailbox(mailbox, &sdata, &data, &cfg);
|
||||
if(directory) rc = import_from_maildir(directory, &sdata, &data, &cfg);
|
||||
if(imapserver && username && password) rc = import_from_imap_server(imapserver, username, password, &sdata, &data, &cfg);
|
||||
|
||||
clearrules(data.archiving_rules);
|
||||
clearrules(data.retention_rules);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* import.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <syslog.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
int import_message2(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
int rc=ERR, i, fd;
|
||||
char *rule;
|
||||
struct stat st;
|
||||
struct _state state;
|
||||
|
||||
|
||||
init_session_data(sdata, cfg);
|
||||
|
||||
|
||||
if(strcmp(filename, "-") == 0){
|
||||
|
||||
if(read_from_stdin(sdata) == ERR){
|
||||
printf("error reading from stdin\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", sdata->ttmpfile);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if(stat(filename, &st) != 0){
|
||||
printf("cannot stat() %s\n", filename);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if(S_ISREG(st.st_mode) == 0){
|
||||
printf("%s is not a file\n", filename);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if(fd == -1){
|
||||
printf("cannot open %s\n", filename);
|
||||
return rc;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename);
|
||||
|
||||
sdata->tot_len = st.st_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sdata->sent = 0;
|
||||
|
||||
state = parse_message(sdata, 1, data, cfg);
|
||||
post_parse(sdata, &state, cfg);
|
||||
|
||||
if(sdata->sent > sdata->now) sdata->sent = sdata->now;
|
||||
if(sdata->sent == -1) sdata->sent = 0;
|
||||
|
||||
/* fat chances that you won't import emails before 1990.01.01 */
|
||||
|
||||
if(sdata->sent > 631148400) sdata->retained = sdata->sent;
|
||||
|
||||
rule = check_againt_ruleset(data->archiving_rules, &state, sdata->tot_len, sdata->spam_message);
|
||||
|
||||
if(rule){
|
||||
printf("discarding %s by archiving policy: %s\n", filename, rule);
|
||||
rc = OK;
|
||||
goto ENDE;
|
||||
}
|
||||
|
||||
make_digests(sdata, cfg);
|
||||
|
||||
ENDE:
|
||||
unlink(sdata->tmpframe);
|
||||
|
||||
if(strcmp(filename, "-") == 0) unlink(sdata->ttmpfile);
|
||||
|
||||
for(i=1; i<=state.n_attachments; i++) unlink(state.attachments[i].internalname);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
192
test/parser.c
192
test/parser.c
@ -1,192 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
int test_url(char *url, char *expected_result){
|
||||
char buf[SMALLBUFSIZE];
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s", url);
|
||||
fixURL(buf);
|
||||
|
||||
if(strcmp(buf, expected_result)){
|
||||
printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", url, buf, expected_result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_translate(char *what, char *expected, struct _state *state){
|
||||
char buf[SMALLBUFSIZE];
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s", what);
|
||||
|
||||
translateLine((unsigned char*)buf, state);
|
||||
|
||||
if(strcmp(buf, expected)){
|
||||
printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_urls(){
|
||||
int count=0;
|
||||
|
||||
count += test_url("http://sourceforge.net/projects/blogsmanager/", "__URL__sourceforgeXnet ");
|
||||
count += test_url("http://localhost/blogs/_authors_list.php?a=search&value=1&SearchFor=muuratsalo&SearchOption=Contains&SearchField=[SQL", "__URL__localhost ");
|
||||
count += test_url("http://www.debian.org/security/faq", "__URL__wwwXdebianXorg ");
|
||||
count += test_url("http://www.debian.org/", "__URL__wwwXdebianXorg ");
|
||||
count += test_url("https://www.debian.org", "__URL__wwwXdebianXorg ");
|
||||
count += test_url("HTTP://www.debian.o", "__URL__wwwXdebianXo ");
|
||||
count += test_url("http://www.debian.", "__URL__wwwXdebian ");
|
||||
count += test_url("www.debian.org", "__URL__wwwXdebianXorg ");
|
||||
count += test_url("http://web.nvd.nist.gov/view/vuln/detail?vulnId=3DCVE-2011-3892", "__URL__webXnvdXnistXgov ");
|
||||
count += test_url("http://bugs.sitracker.org/view.php?id=1737", "__URL__bugsXsitrackerXorg ");
|
||||
count += test_url("http://googlechromereleases.blogspot.com/2011/11/stable-channel-update.ht", "__URL__googlechromereleasesXblogspotXcom ");
|
||||
count += test_url("http://security.gentoo.org/glsa/glsa-201111-05.xml", "__URL__securityXgentooXorg ");
|
||||
count += test_url("https://bugs.gentoo.org.", "__URL__bugsXgentooXorg ");
|
||||
count += test_url("https://bugs.gentoo.org./ajajajajaaj", "__URL__bugsXgentooXorg ");
|
||||
count += test_url("http://creativecommons.org/licenses/by-sa/2.5", "__URL__creativecommonsXorg ");
|
||||
count += test_url("http://www.site.com/[path]/wp-content/plugins/advanced-text-widget/advancedtext.php?page=[xss]", "__URL__wwwXsiteXcom ");
|
||||
count += test_url("http://canadamedshealth.ru", "__URL__canadamedshealthXru ");
|
||||
count += test_url("http://[HOSTNAME]:4848/configuration/httpListenerEdit.jsf?name=<script>alert(document.cookie);</script>&configName=server-config", "__URL__[HOSTNAME]:4848 ");
|
||||
count += test_url("http://go.theregister.com/news/http://www.theregister.co.uk/2007/07/", "__URL__goXtheregisterXcom ");
|
||||
count += test_url("http://dl.shadowserver.org/IpE6yFKxIPARB8447vAQoyeVtbs?Rq123jTRTTrzApVs0vTzyQ", "__URL__dlXshadowserverXorg ");
|
||||
count += test_url("http://dl.shadowserver.org/IpE6yFKx%EAPARB8447vAQoyeVtbs?Rq123jTRTTrzApVs0vTzyQ", "__URL__dlXshadowserverXorg ");
|
||||
count += test_url("", "");
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
int test_translates(){
|
||||
int count=0;
|
||||
struct _state state;
|
||||
|
||||
init_state(&state);
|
||||
|
||||
count += test_translate("To: \"Suto, Janos\" <Janos.Suto@foo.bar>", "To Suto Janos Janos.Suto@foo.bar", &state);
|
||||
count += test_translate("Ez most akkor beteg, vagy sem?", "Ez most akkor beteg vagy sem ", &state);
|
||||
count += test_translate("MAIL FROM: <zoltan.szabo@zte.com.cn>", "MAIL FROM zoltan.szabo@zte.com.cn ", &state);
|
||||
count += test_translate("Enjoy your game, and then enjoy your jackpot!", "Enjoy your game and then enjoy your jackpot!", &state);
|
||||
count += test_translate("Az Ãn által megküldött,", "Az Ãn által megküldött ", &state);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
int test_html(char *what, char *expected, struct _state *state){
|
||||
char buf[SMALLBUFSIZE];
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "%s", what);
|
||||
|
||||
markHTML(buf, state);
|
||||
|
||||
if(strcmp(buf, expected)){
|
||||
printf("FAILED: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//printf("OK: '%s' => fixed: '%s', expected: '%s'\n", what, buf, expected);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int test_htmls(){
|
||||
int count=0;
|
||||
struct _state state;
|
||||
|
||||
init_state(&state);
|
||||
|
||||
count += test_html("</div>", " ", &state);
|
||||
count += test_html("jackpot!</o:p></p>", "jackpot! ", &state);
|
||||
count += test_html("<p class=3DMsoNormal><o:p>Enjoy your game, and then enjoy your =", " Enjoy your game, and then enjoy your =", &state);
|
||||
count += test_html(" <p class style>ooooo", " ooooo", &state);
|
||||
count += test_html(" ", " ", &state);
|
||||
count += test_html("<html><center><table border=10 cellspacing=0 cellpadding=10 bordercolor=C0C0C0 width=600>", " ", &state);
|
||||
count += test_html("<td bgcolor=FFFFFF align=center><font size=3 face=Dotum color=5F5F5F>", " ", &state);
|
||||
count += test_html("<font size=5 color=0000FF><b>Viagra50/100mg - $1.85 |BUY NOW|</b></font><br>", " Viagra50/100mg - $1.85 |BUY NOW| ", &state);
|
||||
count += test_html("High Qua1ityMedications + Discount On All Reorders +<br>", "High Qua1ityMedications + Discount On All Reorders + ", &state);
|
||||
count += test_html("<a href=http://canadamedshealth.ru target=_blank><img src = http://aaa.fu/1.gif><font size=2 color=D90000><b>Free Shipping Options + Free Pills With Every Order = Best Deal Ever!<br>''''''''''click here''''''''''</b></font></a><br></font></td></tr></table></center></html>", " Free Shipping Options + Free Pills With Every Order = Best Deal Ever! ''''''''''click here'''''''''", &state);
|
||||
count += test_html("http://bbb.fu/2.gif", "http://bbb.fu/2.gif", &state);
|
||||
|
||||
count += test_html("<html>", " ", &state);
|
||||
count += test_html(" <style type=3D\"text/css\">", " ", &state);
|
||||
count += test_html(" <span class=3D\"style3\">=E2=ED =E1=F1=FA=E9=E5 =E9=F9 =EE=E1=F6=F2=", " =E2=ED =E1=F1=FA=E9=E5 =E9=F9 =EE=E1=F6=F2=", &state);
|
||||
count += test_html("=E9=ED =E1</span> <a href=3D\"http://www=2Eybay=2Eco=2Eil/\">=E0=E9=F0=E3=", "=E9=ED =E1 =E0=E9=F0=E3=", &state);
|
||||
count += test_html("=F7=F1 =F2=F1=F7=E9=ED</a><o:p></o:p></span></b></p>", "=F7=F1 =F2=F1=F7=E9=ED ", &state);
|
||||
count += test_html(" <span dir=3D\"rtl\" lang=3D\"HE\"=20", " ", &state);
|
||||
|
||||
state.htmltag = 1;
|
||||
count += test_html("span></p>llll", " llll", &state);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int test_dates(){
|
||||
int count=0;
|
||||
unsigned long ts;
|
||||
char datestr[SMALLBUFSIZE];
|
||||
struct __config cfg;
|
||||
|
||||
cfg.tweak_sent_time_offset = 0;
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: Mon, 3 Feb 2014 13:16:09 +0100");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: Sat, 4 Aug 07 13:36:52 GMT-0700");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: 23 Sep 09 07:03 -0800");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: 16 Dec 07 20:45:52");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: 30.06.2005 17:47:42");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: 03 Jun 06 05:59:00 +0100");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
snprintf(datestr, sizeof(datestr)-2, "Date: 03-Feb-2014 18:00:00");
|
||||
ts = parse_date_header(datestr, &cfg); printf("%s => %ld\n", datestr, ts);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int n;
|
||||
|
||||
n = test_urls();
|
||||
printf("testing fixURL(), errors: %d\n", n);
|
||||
|
||||
|
||||
n = test_translates();
|
||||
printf("testing translateLine(), errors: %d\n", n);
|
||||
|
||||
|
||||
n = test_htmls();
|
||||
printf("testing markHTML(), errors: %d\n", n);
|
||||
|
||||
n = test_dates();
|
||||
printf("testing parse_date_header(), errors: %d\n", n);
|
||||
|
||||
return 0;
|
||||
}
|
451
test/ptest.c
451
test/ptest.c
@ -1,451 +0,0 @@
|
||||
/*
|
||||
* pilerimport.c, SJ
|
||||
*/
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <getopt.h>
|
||||
#include <syslog.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
#define SKIPLIST "junk,trash,spam,draft"
|
||||
#define MBOX_ARGS 1024
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
int quiet=0;
|
||||
|
||||
int connect_to_imap_server(int sd, int *seq, char *imapserver, char *username, char *password);
|
||||
int list_folders(int sd, int *seq, char *folders, int foldersize);
|
||||
int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, struct __config *cfg);
|
||||
|
||||
|
||||
int parse_it(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
int i, rc=ERR, fd;
|
||||
struct stat st;
|
||||
struct _state state;
|
||||
|
||||
|
||||
init_session_data(sdata, cfg);
|
||||
|
||||
if(stat(filename, &st) != 0){
|
||||
printf("cannot stat() %s\n", filename);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if(S_ISREG(st.st_mode) == 0){
|
||||
printf("%s is not a file\n", filename);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if(fd == -1){
|
||||
printf("cannot open %s\n", filename);
|
||||
return rc;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename);
|
||||
|
||||
sdata->tot_len = st.st_size;
|
||||
|
||||
|
||||
|
||||
sdata->sent = 0;
|
||||
|
||||
state = parse_message(sdata, 1, data, cfg);
|
||||
post_parse(sdata, &state, cfg);
|
||||
|
||||
unlink(sdata->tmpframe);
|
||||
|
||||
for(i=1; i<=state.n_attachments; i++) unlink(state.attachments[i].internalname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data *data, struct __config *cfg){
|
||||
FILE *F, *f=NULL;
|
||||
int rc=ERR, tot_msgs=0, ret=OK;
|
||||
char buf[MAXBUFSIZE], fname[SMALLBUFSIZE];
|
||||
time_t t;
|
||||
|
||||
|
||||
F = fopen(mailbox, "r");
|
||||
if(!F){
|
||||
printf("cannot open mailbox: %s\n", mailbox);
|
||||
return rc;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
while(fgets(buf, sizeof(buf)-1, F)){
|
||||
|
||||
if(buf[0] == 'F' && buf[1] == 'r' && buf[2] == 'o' && buf[3] == 'm' && buf[4] == ' '){
|
||||
tot_msgs++;
|
||||
if(f){
|
||||
fclose(f);
|
||||
rc = parse_it(fname, sdata, data, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
unlink(fname);
|
||||
|
||||
if(quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs);
|
||||
f = fopen(fname, "w+");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(f) fprintf(f, "%s", buf);
|
||||
}
|
||||
|
||||
if(f){
|
||||
fclose(f);
|
||||
rc = parse_it(fname, sdata, data, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
unlink(fname);
|
||||
|
||||
if(quiet == 0) printf("processed: %7d\r", ++tot_msgs); fflush(stdout);
|
||||
}
|
||||
|
||||
fclose(F);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int import_mbox_from_dir(char *directory, struct session_data *sdata, struct __data *data, int *tot_msgs, struct __config *cfg){
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
int rc=ERR, ret=OK;
|
||||
char fname[SMALLBUFSIZE];
|
||||
struct stat st;
|
||||
|
||||
dir = opendir(directory);
|
||||
if(!dir){
|
||||
printf("cannot open directory: %s\n", directory);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
while((de = readdir(dir))){
|
||||
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
||||
|
||||
snprintf(fname, sizeof(fname)-1, "%s/%s", directory, de->d_name);
|
||||
|
||||
if(stat(fname, &st) == 0){
|
||||
if(S_ISDIR(st.st_mode)){
|
||||
rc = import_mbox_from_dir(fname, sdata, data, tot_msgs, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
}
|
||||
else {
|
||||
|
||||
if(S_ISREG(st.st_mode)){
|
||||
rc = import_from_mailbox(fname, sdata, data, cfg);
|
||||
if(rc == OK) (*tot_msgs)++;
|
||||
else ret = ERR;
|
||||
|
||||
}
|
||||
else {
|
||||
printf("%s is not a file\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("cannot stat() %s\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int import_from_maildir(char *directory, struct session_data *sdata, struct __data *data, int *tot_msgs, struct __config *cfg){
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
int rc=ERR, ret=OK;
|
||||
char fname[SMALLBUFSIZE];
|
||||
struct stat st;
|
||||
|
||||
dir = opendir(directory);
|
||||
if(!dir){
|
||||
printf("cannot open directory: %s\n", directory);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
while((de = readdir(dir))){
|
||||
if(strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;
|
||||
|
||||
snprintf(fname, sizeof(fname)-1, "%s/%s", directory, de->d_name);
|
||||
|
||||
if(stat(fname, &st) == 0){
|
||||
if(S_ISDIR(st.st_mode)){
|
||||
rc = import_from_maildir(fname, sdata, data, tot_msgs, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
}
|
||||
else {
|
||||
|
||||
if(S_ISREG(st.st_mode)){
|
||||
rc = parse_it(fname, sdata, data, cfg);
|
||||
if(rc == OK) (*tot_msgs)++;
|
||||
else ret = ERR;
|
||||
|
||||
if(quiet == 0) printf("processed: %7d\r", *tot_msgs); fflush(stdout);
|
||||
}
|
||||
else {
|
||||
printf("%s is not a file\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("cannot stat() %s\n", fname);
|
||||
}
|
||||
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int import_from_imap_server(char *imapserver, char *username, char *password, struct session_data *sdata, struct __data *data, char *skiplist, struct __config *cfg){
|
||||
int rc=ERR, ret=OK, sd, seq=1, skipmatch, result;
|
||||
char *p, puf[SMALLBUFSIZE];
|
||||
char *q, muf[SMALLBUFSIZE];
|
||||
char folders[MAXBUFSIZE];
|
||||
|
||||
if((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
|
||||
printf("cannot create socket\n");
|
||||
return ERR;
|
||||
}
|
||||
|
||||
if(connect_to_imap_server(sd, &seq, imapserver, username, password) == ERR){
|
||||
close(sd);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
|
||||
list_folders(sd, &seq, &folders[0], sizeof(folders));
|
||||
|
||||
|
||||
p = &folders[0];
|
||||
do {
|
||||
memset(puf, 0, sizeof(puf));
|
||||
p = split(p, '\n', puf, sizeof(puf)-1, &result);
|
||||
|
||||
if(strlen(puf) < 1) continue;
|
||||
|
||||
skipmatch = 0;
|
||||
|
||||
if(skiplist && strlen(skiplist) > 0){
|
||||
q = skiplist;
|
||||
do {
|
||||
memset(muf, 0, sizeof(muf));
|
||||
q = split(q, ',', muf, sizeof(muf)-1, &result);
|
||||
if(strncasecmp(puf, muf, strlen(muf)) == 0){
|
||||
skipmatch = 1;
|
||||
break;
|
||||
}
|
||||
} while(q);
|
||||
}
|
||||
|
||||
if(skipmatch == 1){
|
||||
if(quiet == 0) printf("SKIPPING FOLDER: %s\n", puf);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(quiet == 0) printf("processing folder: %s... ", puf);
|
||||
|
||||
rc = process_imap_folder(sd, &seq, puf, sdata, data, cfg);
|
||||
if(rc == ERR) ret = ERR;
|
||||
|
||||
} while(p);
|
||||
|
||||
|
||||
close(sd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void usage(){
|
||||
printf("usage: pilerimport [-c <config file>] -e <eml file> | -m <mailbox file> | -M <mailbox directory> | -d <directory> | -i <imap server> -u <imap username> -p <imap password>\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int i, c, rc=0, n_mbox=0, tot_msgs=0;
|
||||
char *configfile=CONFIG_FILE, *emlfile=NULL, *mboxdir=NULL, *mbox[MBOX_ARGS], *directory=NULL;
|
||||
char *imapserver=NULL, *username=NULL, *password=NULL, *skiplist=SKIPLIST;
|
||||
struct session_data sdata;
|
||||
struct __config cfg;
|
||||
struct __data data;
|
||||
|
||||
for(i=0; i<MBOX_ARGS; i++) mbox[i] = NULL;
|
||||
|
||||
|
||||
data.folder = 0;
|
||||
initrules(data.archiving_rules);
|
||||
initrules(data.retention_rules);
|
||||
|
||||
|
||||
while(1){
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"config", required_argument, 0, 'c' },
|
||||
{"eml", required_argument, 0, 'e' },
|
||||
{"dir", required_argument, 0, 'd' },
|
||||
{"mbox", required_argument, 0, 'm' },
|
||||
{"mboxdir", required_argument, 0, 'M' },
|
||||
{"imapserver", required_argument, 0, 'i' },
|
||||
{"username", required_argument, 0, 'u' },
|
||||
{"password", required_argument, 0, 'p' },
|
||||
{"skiplist", required_argument, 0, 'x' },
|
||||
{"folder", required_argument, 0, 'F' },
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{0,0,0,0}
|
||||
};
|
||||
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long(argc, argv, "c:m:M:e:d:i:u:p:x:F:h?", long_options, &option_index);
|
||||
#else
|
||||
c = getopt(argc, argv, "c:m:M:e:d:i:u:p:x:F:h?");
|
||||
#endif
|
||||
|
||||
if(c == -1) break;
|
||||
|
||||
switch(c){
|
||||
|
||||
case 'c' :
|
||||
configfile = optarg;
|
||||
break;
|
||||
|
||||
case 'e' :
|
||||
emlfile = optarg;
|
||||
break;
|
||||
|
||||
case 'd' :
|
||||
directory = optarg;
|
||||
break;
|
||||
|
||||
case 'm' :
|
||||
if(n_mbox < MBOX_ARGS){
|
||||
mbox[n_mbox++] = optarg;
|
||||
} else {
|
||||
printf("too many -m <mailbox> arguments: %s\n", optarg);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'M' :
|
||||
mboxdir = optarg;
|
||||
break;
|
||||
|
||||
case 'i' :
|
||||
imapserver = optarg;
|
||||
break;
|
||||
|
||||
case 'u' :
|
||||
username = optarg;
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
password = optarg;
|
||||
break;
|
||||
|
||||
case 'x' :
|
||||
skiplist = optarg;
|
||||
break;
|
||||
|
||||
case 'F' :
|
||||
//folder = optarg;
|
||||
break;
|
||||
|
||||
case 'h' :
|
||||
case '?' :
|
||||
usage();
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!mbox[0] && !mboxdir && !emlfile && !directory && !imapserver) usage();
|
||||
|
||||
|
||||
cfg = read_config(configfile);
|
||||
|
||||
if(read_key(&cfg)){
|
||||
printf("%s\n", ERR_READING_KEY);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
mysql_init(&(sdata.mysql));
|
||||
mysql_options(&(sdata.mysql), MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&cfg.mysql_connect_timeout);
|
||||
if(mysql_real_connect(&(sdata.mysql), cfg.mysqlhost, cfg.mysqluser, cfg.mysqlpwd, cfg.mysqldb, cfg.mysqlport, cfg.mysqlsocket, 0) == 0){
|
||||
printf("cant connect to mysql server\n");
|
||||
return ERR;
|
||||
}
|
||||
|
||||
mysql_real_query(&(sdata.mysql), "SET NAMES utf8", strlen("SET NAMES utf8"));
|
||||
mysql_real_query(&(sdata.mysql), "SET CHARACTER SET utf8", strlen("SET CHARACTER SET utf8"));
|
||||
|
||||
setlocale(LC_CTYPE, cfg.locale);
|
||||
|
||||
(void) openlog("pilerimport", LOG_PID, LOG_MAIL);
|
||||
|
||||
load_rules(&sdata, &data, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE, &cfg);
|
||||
load_rules(&sdata, &data, data.retention_rules, SQL_RETENTION_RULE_TABLE, &cfg);
|
||||
|
||||
load_mydomains(&sdata, &data, &cfg);
|
||||
|
||||
if(emlfile) rc = import_message(emlfile, &sdata, &data, &cfg);
|
||||
if(mbox[0]){
|
||||
for(i=0; i<n_mbox; i++){
|
||||
rc = import_from_mailbox(mbox[i], &sdata, &data, &cfg);
|
||||
}
|
||||
}
|
||||
if(mboxdir) rc = import_mbox_from_dir(mboxdir, &sdata, &data, &tot_msgs, &cfg);
|
||||
if(directory) rc = import_from_maildir(directory, &sdata, &data, &tot_msgs, &cfg);
|
||||
if(imapserver && username && password) rc = import_from_imap_server(imapserver, username, password, &sdata, &data, skiplist, &cfg);
|
||||
|
||||
|
||||
if(quiet == 0) printf("\n");
|
||||
|
||||
clearrules(data.archiving_rules);
|
||||
clearrules(data.retention_rules);
|
||||
|
||||
mysql_close(&(sdata.mysql));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
105
test/test.c
105
test/test.c
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* test.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <syslog.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int i;
|
||||
struct stat st;
|
||||
struct session_data sdata;
|
||||
struct _state state;
|
||||
struct __config cfg;
|
||||
struct __data data;
|
||||
struct import import;
|
||||
|
||||
srand(getpid());
|
||||
|
||||
if(argc < 2){
|
||||
fprintf(stderr, "usage: %s <message>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
||||
|
||||
if(stat(argv[1], &st) != 0){
|
||||
fprintf(stderr, "%s is not found\n", argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) openlog("test", LOG_PID, LOG_MAIL);
|
||||
|
||||
cfg = read_config(CONFIG_FILE);
|
||||
|
||||
if(open_database(&sdata, &cfg) == ERR) return 0;
|
||||
|
||||
setlocale(LC_MESSAGES, cfg.locale);
|
||||
setlocale(LC_CTYPE, cfg.locale);
|
||||
|
||||
import.extra_recipient = NULL;
|
||||
|
||||
data.import = &import;
|
||||
|
||||
data.folder = 0;
|
||||
data.recursive_folder_names = 0;
|
||||
|
||||
inithash(data.mydomains);
|
||||
|
||||
init_session_data(&sdata, &cfg);
|
||||
|
||||
sdata.sent = 0;
|
||||
sdata.delivered = 0;
|
||||
sdata.tot_len = st.st_size;
|
||||
sdata.import = 1;
|
||||
|
||||
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
|
||||
snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", argv[1]);
|
||||
snprintf(sdata.tmpframe, SMALLBUFSIZE-1, "%s.m", argv[1]);
|
||||
|
||||
state = parse_message(&sdata, 1, &data, &cfg);
|
||||
|
||||
post_parse(&sdata, &state, &cfg);
|
||||
|
||||
printf("message-id: %s / %s\n", state.message_id, state.message_id_hash);
|
||||
printf("from: *%s (%s)*\n", state.b_from, state.b_from_domain);
|
||||
printf("to: *%s (%s)*\n", state.b_to, state.b_to_domain);
|
||||
printf("reference: *%s*\n", state.reference);
|
||||
printf("subject: *%s*\n", state.b_subject);
|
||||
printf("body: *%s*\n", state.b_body);
|
||||
|
||||
printf("sent: %ld, delivered-date: %ld\n", sdata.sent, sdata.delivered);
|
||||
|
||||
make_digests(&sdata, &cfg);
|
||||
|
||||
printf("hdr len: %d\n", sdata.hdr_len);
|
||||
|
||||
printf("body digest: %s\n", sdata.bodydigest);
|
||||
|
||||
clearhash(data.mydomains);
|
||||
|
||||
for(i=1; i<=state.n_attachments; i++){
|
||||
printf("i:%d, name=*%s*, type: *%s*, size: %d, int.name: %s, digest: %s\n", i, state.attachments[i].filename, state.attachments[i].type, state.attachments[i].size, state.attachments[i].internalname, state.attachments[i].digest);
|
||||
unlink(state.attachments[i].internalname);
|
||||
}
|
||||
|
||||
unlink(sdata.tmpframe);
|
||||
|
||||
printf("attachments:%s\n", sdata.attachments);
|
||||
|
||||
close_database(&sdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user