2011-11-30 23:42:15 +01:00
|
|
|
/*
|
|
|
|
* pilerget.c, SJ
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-12-28 15:30:53 +01:00
|
|
|
#include <sys/time.h>
|
2011-11-30 23:42:15 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2011-12-28 15:30:53 +01:00
|
|
|
#include <time.h>
|
|
|
|
#include <locale.h>
|
2011-11-30 23:42:15 +01:00
|
|
|
#include <syslog.h>
|
|
|
|
#include <piler.h>
|
|
|
|
|
|
|
|
|
2011-12-27 20:51:56 +01:00
|
|
|
int main(int argc, char **argv){
|
2012-11-03 23:42:36 +01:00
|
|
|
int readkey=1;
|
2011-12-28 15:30:53 +01:00
|
|
|
struct session_data sdata;
|
2017-08-08 15:34:45 +02:00
|
|
|
struct data data;
|
|
|
|
struct config cfg;
|
2011-12-27 20:51:56 +01:00
|
|
|
|
|
|
|
|
2011-12-28 15:30:53 +01:00
|
|
|
if(argc < 2){
|
2011-12-29 21:25:40 +01:00
|
|
|
printf("usage: %s <piler-id>\n", argv[0]);
|
2011-12-28 15:30:53 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2012-10-23 10:12:56 +02:00
|
|
|
(void) openlog("pilerget", LOG_PID, LOG_MAIL);
|
2011-12-28 15:30:53 +01:00
|
|
|
|
|
|
|
cfg = read_config(CONFIG_FILE);
|
|
|
|
|
2013-11-11 11:48:13 +01:00
|
|
|
if(argc >= 3){
|
|
|
|
readkey = 0;
|
|
|
|
cfg.encrypt_messages = 0;
|
|
|
|
}
|
2011-12-27 20:51:56 +01:00
|
|
|
|
2012-08-16 12:45:03 +02:00
|
|
|
if(readkey == 1 && read_key(&cfg)){
|
2011-12-27 20:51:56 +01:00
|
|
|
printf("%s\n", ERR_READING_KEY);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-28 14:18:09 +02:00
|
|
|
if(open_database(&sdata, &cfg) == ERR) return 0;
|
2011-12-28 15:30:53 +01:00
|
|
|
|
|
|
|
|
2012-01-07 23:26:47 +01:00
|
|
|
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
|
|
|
|
snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", sdata.ttmpfile);
|
2013-01-28 12:10:39 +01:00
|
|
|
retrieve_email_from_archive(&sdata, &data, stdout, &cfg);
|
2011-12-27 20:51:56 +01:00
|
|
|
|
|
|
|
|
2013-04-28 14:18:09 +02:00
|
|
|
close_database(&sdata);
|
2011-12-27 20:51:56 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-28 15:30:53 +01:00
|
|
|
|
|
|
|
|