|
a/src/internfile/mh_mbox.cpp |
|
b/src/internfile/mh_mbox.cpp |
|
... |
|
... |
27 |
#include <errno.h>
|
27 |
#include <errno.h>
|
28 |
|
28 |
|
29 |
#include <cstring>
|
29 |
#include <cstring>
|
30 |
#include <map>
|
30 |
#include <map>
|
31 |
|
31 |
|
|
|
32 |
#include "cstr.h"
|
32 |
#include "mimehandler.h"
|
33 |
#include "mimehandler.h"
|
33 |
#include "debuglog.h"
|
34 |
#include "debuglog.h"
|
34 |
#include "readfile.h"
|
35 |
#include "readfile.h"
|
35 |
#include "mh_mbox.h"
|
36 |
#include "mh_mbox.h"
|
36 |
#include "smallut.h"
|
37 |
#include "smallut.h"
|
|
... |
|
... |
142 |
}
|
143 |
}
|
143 |
FpKeeper keeper(&fp);
|
144 |
FpKeeper keeper(&fp);
|
144 |
string blk1;
|
145 |
string blk1;
|
145 |
blk1.append("udi=");
|
146 |
blk1.append("udi=");
|
146 |
blk1.append(udi);
|
147 |
blk1.append(udi);
|
147 |
blk1.append("\n");
|
148 |
blk1.append(cstr_newline);
|
148 |
blk1.resize(o_b1size, 0);
|
149 |
blk1.resize(o_b1size, 0);
|
149 |
if (fwrite(blk1.c_str(), 1, o_b1size, fp) != o_b1size) {
|
150 |
if (fwrite(blk1.c_str(), 1, o_b1size, fp) != o_b1size) {
|
150 |
LOGDEB(("MboxCache::put_offsets: fwrite errno %d\n", errno));
|
151 |
LOGDEB(("MboxCache::put_offsets: fwrite errno %d\n", errno));
|
151 |
return;
|
152 |
return;
|
152 |
}
|
153 |
}
|
|
... |
|
... |
382 |
if (!m_havedoc) {
|
383 |
if (!m_havedoc) {
|
383 |
return false;
|
384 |
return false;
|
384 |
}
|
385 |
}
|
385 |
FILE *fp = (FILE *)m_vfp;
|
386 |
FILE *fp = (FILE *)m_vfp;
|
386 |
int mtarg = 0;
|
387 |
int mtarg = 0;
|
387 |
if (m_ipath != "") {
|
388 |
if (!m_ipath.empty()) {
|
388 |
sscanf(m_ipath.c_str(), "%d", &mtarg);
|
389 |
sscanf(m_ipath.c_str(), "%d", &mtarg);
|
389 |
} else if (m_forPreview) {
|
390 |
} else if (m_forPreview) {
|
390 |
// Can't preview an mbox.
|
391 |
// Can't preview an mbox.
|
391 |
LOGDEB(("MimeHandlerMbox::next_document: can't preview folders!\n"));
|
392 |
LOGDEB(("MimeHandlerMbox::next_document: can't preview folders!\n"));
|
392 |
return false;
|
393 |
return false;
|
|
... |
|
... |
432 |
}
|
433 |
}
|
433 |
|
434 |
|
434 |
off_t message_end = 0;
|
435 |
off_t message_end = 0;
|
435 |
bool iseof = false;
|
436 |
bool iseof = false;
|
436 |
bool hademptyline = true;
|
437 |
bool hademptyline = true;
|
437 |
string& msgtxt = m_metaData["content"];
|
438 |
string& msgtxt = m_metaData[cstr_content];
|
438 |
msgtxt.erase();
|
439 |
msgtxt.erase();
|
439 |
line_type line;
|
440 |
line_type line;
|
440 |
for (;;) {
|
441 |
for (;;) {
|
441 |
message_end = ftello(fp);
|
442 |
message_end = ftello(fp);
|
442 |
if (!fgets(line, LL, fp)) {
|
443 |
if (!fgets(line, LL, fp)) {
|
|
... |
|
... |
496 |
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str()));
|
497 |
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str()));
|
497 |
char buf[20];
|
498 |
char buf[20];
|
498 |
// m_msgnum was incremented when hitting the next From_ or eof, so the data
|
499 |
// m_msgnum was incremented when hitting the next From_ or eof, so the data
|
499 |
// is for m_msgnum - 1
|
500 |
// is for m_msgnum - 1
|
500 |
sprintf(buf, "%d", m_msgnum - 1);
|
501 |
sprintf(buf, "%d", m_msgnum - 1);
|
501 |
m_metaData["ipath"] = buf;
|
502 |
m_metaData[cstr_ipath] = buf;
|
502 |
m_metaData["mimetype"] = "message/rfc822";
|
503 |
m_metaData[cstr_mimetype] = "message/rfc822";
|
503 |
if (iseof) {
|
504 |
if (iseof) {
|
504 |
LOGDEB2(("MimeHandlerMbox::next: eof hit\n"));
|
505 |
LOGDEB2(("MimeHandlerMbox::next: eof hit\n"));
|
505 |
m_havedoc = false;
|
506 |
m_havedoc = false;
|
506 |
if (!m_udi.empty() && storeoffsets) {
|
507 |
if (!m_udi.empty() && storeoffsets) {
|
507 |
o_mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets);
|
508 |
o_mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets);
|
|
... |
|
... |
588 |
if (!mh.next_document()) {
|
589 |
if (!mh.next_document()) {
|
589 |
cerr << "next_document failed after skipping to " << msgnum << endl;
|
590 |
cerr << "next_document failed after skipping to " << msgnum << endl;
|
590 |
exit(1);
|
591 |
exit(1);
|
591 |
}
|
592 |
}
|
592 |
map<string, string>::const_iterator it =
|
593 |
map<string, string>::const_iterator it =
|
593 |
mh.get_meta_data().find("content");
|
594 |
mh.get_meta_data().find(cstr_content);
|
594 |
int size;
|
595 |
int size;
|
595 |
if (it == mh.get_meta_data().end()) {
|
596 |
if (it == mh.get_meta_data().end()) {
|
596 |
size = -1;
|
597 |
size = -1;
|
597 |
cerr << "No content!!" << endl;
|
598 |
cerr << "No content!!" << endl;
|
598 |
exit(1);
|
599 |
exit(1);
|
|
... |
|
... |
608 |
cerr << "next_document failed" << endl;
|
609 |
cerr << "next_document failed" << endl;
|
609 |
exit(1);
|
610 |
exit(1);
|
610 |
}
|
611 |
}
|
611 |
docnt++;
|
612 |
docnt++;
|
612 |
map<string, string>::const_iterator it =
|
613 |
map<string, string>::const_iterator it =
|
613 |
mh.get_meta_data().find("content");
|
614 |
mh.get_meta_data().find(cstr_content);
|
614 |
int size;
|
615 |
int size;
|
615 |
if (it == mh.get_meta_data().end()) {
|
616 |
if (it == mh.get_meta_data().end()) {
|
616 |
size = -1;
|
617 |
size = -1;
|
617 |
} else {
|
618 |
} else {
|
618 |
size = it->second.length();
|
619 |
size = it->second.length();
|