From e5dd2f06a24d1a3f9d8ac021d7802fb25de3fbee Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 24 Sep 2013 21:04:15 +0200 Subject: [PATCH] tnef compile error fix --- src/extract.c | 86 +++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/src/extract.c b/src/extract.c index f7616960..cbdbb0e7 100644 --- a/src/extract.c +++ b/src/extract.c @@ -91,47 +91,6 @@ int extract_opendocument(struct session_data *sdata, struct _state *state, char } -int extract_tnef(struct session_data *sdata, struct _state *state, char *filename){ - int rc=0, n, rec=1; - char tmpdir[BUFLEN], buf[SMALLBUFSIZE]; - struct dirent **namelist; - - memset(tmpdir, 0, sizeof(tmpdir)); - make_random_string(&tmpdir[0], sizeof(tmpdir)-3); - - memcpy(&tmpdir[sizeof(tmpdir)-3], ".d", 2); - - printf("tmpname: %s, filename: %s\n", tmpdir, filename); - - if(mkdir(tmpdir, 0700)) return rc; - - snprintf(buf, sizeof(buf)-1, "%s -C %s %s", HAVE_TNEF, tmpdir, filename); - - system(buf); - - n = scandir(tmpdir, &namelist, NULL, alphasort); - if(n < 0) syslog(LOG_INFO, "error reading %s", tmpdir); - else { - while(n--){ - if(strcmp(namelist[n]->d_name, ".") && strcmp(namelist[n]->d_name, "..")){ - snprintf(buf, sizeof(buf)-1, "%s/%s", tmpdir, namelist[n]->d_name); - - extract_attachment_content(sdata, state, buf, get_attachment_extractor_by_filename(buf), &rec); - - unlink(buf); - } - - free(namelist[n]); - } - free(namelist); - } - - rmdir(tmpdir); - - return rc; -} - - int unzip_file(struct session_data *sdata, struct _state *state, char *filename, int *rec){ int errorp, i=0, len=0, fd; char *p, extracted_filename[SMALLBUFSIZE], buf[MAXBUFSIZE]; @@ -188,6 +147,51 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename, #endif + +#ifdef HAVE_TNEF + +int extract_tnef(struct session_data *sdata, struct _state *state, char *filename){ + int rc=0, n, rec=1; + char tmpdir[BUFLEN], buf[SMALLBUFSIZE]; + struct dirent **namelist; + + memset(tmpdir, 0, sizeof(tmpdir)); + make_random_string(&tmpdir[0], sizeof(tmpdir)-3); + + memcpy(&tmpdir[sizeof(tmpdir)-3], ".d", 2); + + printf("tmpname: %s, filename: %s\n", tmpdir, filename); + + if(mkdir(tmpdir, 0700)) return rc; + + snprintf(buf, sizeof(buf)-1, "%s -C %s %s", HAVE_TNEF, tmpdir, filename); + + system(buf); + + n = scandir(tmpdir, &namelist, NULL, alphasort); + if(n < 0) syslog(LOG_INFO, "error reading %s", tmpdir); + else { + while(n--){ + if(strcmp(namelist[n]->d_name, ".") && strcmp(namelist[n]->d_name, "..")){ + snprintf(buf, sizeof(buf)-1, "%s/%s", tmpdir, namelist[n]->d_name); + + extract_attachment_content(sdata, state, buf, get_attachment_extractor_by_filename(buf), &rec); + + unlink(buf); + } + + free(namelist[n]); + } + free(namelist); + } + + rmdir(tmpdir); + + return rc; +} + +#endif + void read_content_with_popen(struct session_data *sdata, struct _state *state, char *cmd){ int len; char buf[MAXBUFSIZE];