4 #include <gsf/gsf-utils.h> 6 #include <gsf/gsf-input-stdio.h> 7 #include <gsf/gsf-infile.h> 8 #include <gsf/gsf-infile-stdio.h> 10 #include <gsf/gsf-output-stdio.h> 11 #include <gsf/gsf-outfile.h> 12 #include <gsf/gsf-outfile-msole.h> 42 size_t strsize = strlen(str.
str);
44 if (rc == (
size_t)-1) {
47 DEBUG_INFO((
"Failed to convert utf-8 to %s\n", charset));
53 newer->
b[newer->
dlen] =
'\0';
65 snprintf(&n[0], n.size(),
"__substg1.0_%08X", tag);
66 GsfOutput* dst = gsf_outfile_new_child(out, &n[0],
false);
67 gsf_output_close(dst);
68 g_object_unref(G_OBJECT(dst));
74 if (!contents)
return;
75 size_t term = ((tag & 0x0000ffff) == 0x001e) ? 1 :
76 ((tag & 0x0000ffff) == 0x001f) ? 2 : 0;
78 snprintf(&n[0], n.size(),
"__substg1.0_%08X", tag);
79 GsfOutput* dst = gsf_outfile_new_child(out, &n[0],
false);
80 gsf_output_write(dst, size, (
const guint8*)contents);
82 memset(&n[0], 0, term);
83 gsf_output_write(dst, term, (
const guint8*)&n[0]);
86 gsf_output_close(dst);
87 g_object_unref(G_OBJECT(dst));
101 snprintf(&n[0], n.size(),
"__substg1.0_%08X", tag);
102 GsfOutput* dst = gsf_outfile_new_child(out, &n[0],
false);
105 const size_t bsize = 10000;
109 size_t s = fread(buf, 1, bsize, fp);
111 gsf_output_write(dst, s, (
const guint8*)buf);
114 gsf_output_close(dst);
115 g_object_unref(G_OBJECT(dst));
158 GsfOutput* dst = gsf_outfile_new_child(out,
"__properties_version1.0",
false);
159 gsf_output_write(dst, hlen, header);
160 for (property_list::iterator i=prop.begin(); i!=prop.end(); i++) {
162 gsf_output_write(dst,
sizeof(
property), (
const guint8*)&p);
164 gsf_output_close(dst);
165 g_object_unref(G_OBJECT(dst));
176 prop_list.push_back(p);
188 prop_list.push_back(p);
201 if (!item->
email)
return;
208 DEBUG_INFO((
"%s body charset seems to be %s\n", fname, body_charset));
209 body_charset =
"iso-8859-1//TRANSLIT//IGNORE";
217 output = gsf_output_stdio_new(fname, &err);
218 if (output == NULL) {
220 DEBUG_INFO((
"unable to open output .msg file %s\n", fname));
225 struct top_property_header {
228 uint32_t next_recipient;
229 uint32_t next_attachment;
230 uint32_t recipient_count;
231 uint32_t attachment_count;
236 top_property_header top_head;
237 memset(&top_head, 0,
sizeof(top_head));
239 outfile = gsf_outfile_msole_new(output);
240 g_object_unref(G_OBJECT(output));
242 output = GSF_OUTPUT(outfile);
255 GsfOutfile *out = GSF_OUTFILE (output);
297 snprintf(&n[0], n.size(),
"__recip_version1.0_#%08X", top_head.recipient_count);
298 GsfOutput *output = gsf_outfile_new_child(out, &n[0],
true);
303 int_property(prop_list, 0x30000003, 0x6, top_head.recipient_count);
304 GsfOutfile *out = GSF_OUTFILE (output);
313 gsf_output_close(output);
314 g_object_unref(G_OBJECT(output));
315 top_head.next_recipient++;
316 top_head.recipient_count++;
320 snprintf(&n[0], n.size(),
"__recip_version1.0_#%08X", top_head.recipient_count);
321 GsfOutput *output = gsf_outfile_new_child(out, &n[0],
true);
326 int_property(prop_list, 0x30000003, 0x6, top_head.recipient_count);
327 GsfOutfile *out = GSF_OUTFILE (output);
332 gsf_output_close(output);
333 g_object_unref(G_OBJECT(output));
334 top_head.next_recipient++;
335 top_head.recipient_count++;
339 snprintf(&n[0], n.size(),
"__recip_version1.0_#%08X", top_head.recipient_count);
340 GsfOutput *output = gsf_outfile_new_child(out, &n[0],
true);
345 int_property(prop_list, 0x30000003, 0x6, top_head.recipient_count);
346 GsfOutfile *out = GSF_OUTFILE (output);
351 gsf_output_close(output);
352 g_object_unref(G_OBJECT(output));
353 top_head.next_recipient++;
354 top_head.recipient_count++;
366 snprintf(&n[0], n.size(),
"__attach_version1.0_#%08X", top_head.attachment_count);
367 GsfOutput *output = gsf_outfile_new_child(out, &n[0],
true);
369 FILE *fp = fopen(
"temp_file_attachment",
"w+b");
372 fseek(fp, 0, SEEK_SET);
374 int_property(prop_list, 0x0E210003, 0x2, top_head.attachment_count);
381 GsfOutfile *out = GSF_OUTFILE (output);
394 const char *n =
"inline";
399 gsf_output_close(output);
400 g_object_unref(G_OBJECT(output));
401 top_head.next_attachment++;
402 top_head.attachment_count++;
410 write_properties(out, prop_list, (
const guint8*)&top_head,
sizeof(top_head));
413 GsfOutput *output = gsf_outfile_new_child(out,
"__nameid_version1.0",
true);
415 GsfOutfile *out = GSF_OUTFILE (output);
419 gsf_output_close(output);
420 g_object_unref(G_OBJECT(output));
424 gsf_output_close(output);
425 g_object_unref(G_OBJECT(output));
pst_string sender_address
mapi element 0x0065 PR_SENT_REPRESENTING_EMAIL_ADDRESS
pst_string original_cc
mapi element 0x0073 PR_ORIGINAL_DISPLAY_CC
pst_string outlook_received_name1
mapi element 0x0040 PR_RECEIVED_BY_NAME
pst_item_contact * contact
contact mapi elements
int32_t importance
mapi element 0x0017 PR_IMPORTANCE
int32_t flags
mapi element 0x0e07 PR_MESSAGE_FLAGS
pst_string subject
mapi element 0x0037 PR_SUBJECT
pst_vbuf * pst_vballoc(size_t len)
pst_binary record_key
mapi element 0x0ff9 PR_RECORD_KEY
pst_string header
mapi element 0x007d PR_TRANSPORT_MESSAGE_HEADERS
int32_t original_sensitivity
mapi element 0x002e PR_ORIGINAL_SENSITIVITY
pst_binary conversation_index
mapi element 0x0071 PR_CONVERSATION_INDEX
int delete_after_submit
mapi element 0x0e01 PR_DELETE_AFTER_SUBMIT
pst_string processed_subject
mapi element 0x0070 PR_CONVERSATION_TOPIC
char * ascii_type
mapi element 0x001a PR_MESSAGE_CLASS or 0x3613 PR_CONTAINER_CLASS
void write_msg_email(char *fname, pst_item *item, pst_file *pst)
static void nzi_property(property_list &prop_list, uint32_t tag, uint32_t flags, uint32_t value)
pst_string outlook_sender
mapi element 0x003b PR_SENT_REPRESENTING_SEARCH_KEY
pst_string sender2_access
mapi element 0x0c1e PR_SENDER_ADDRTYPE
This contains the common mapi elements, and pointers to structures for each major mapi item type...
list< property > property_list
int32_t method
mapi element 0x3705 PR_ATTACH_METHOD
static void convert_8bit(pst_string &str, const char *charset)
Convert str to an 8 bit charset if it is utf8, null strings are preserved.
static void write_properties(GsfOutfile *out, property_list &prop, const guint8 *header, size_t hlen)
This contains the attachment related mapi elements.
const char * pst_default_charset(pst_item *item, int buflen, char *result)
Get the default character set for this item.
pst_string reply_to
mapi element 0x0050 PR_REPLY_RECIPIENT_NAMES
pst_string outlook_recipient_name
mapi element 0x0044 PR_RCVD_REPRESENTING_NAME
pst_binary data
mapi element 0x3701 PR_ATTACH_DATA_OBJ
a simple wrapper for binary blobs
pst_string file_as
mapi element 0x3001 PR_DISPLAY_NAME
pst_string messageid
mapi element 0x1035
#define PST_ATTACH_EMBEDDED
pst_string outlook_sender_name2
mapi element 0x0c1a PR_SENDER_NAME
pst_string outlook_search_key
mapi element 0x300b PR_SEARCH_KEY
The string is either utf8 encoded, or it is in the code page specified by the containing mapi object...
size_t pst_vb_utf8to8bit(pst_vbuf *dest, const char *inbuf, int iblen, const char *charset)
pst_string recip2_address
mapi element 0x0078 PR_RCVD_REPRESENTING_EMAIL_ADDRESS
int32_t priority
mapi element 0x0026 PR_PRIORITY
pst_string recip_access
mapi element 0x0075 PR_RECEIVED_BY_ADDRTYPE
pst_string outlook_recipient2
mapi element 0x0052 PR_RCVD_REPRESENTING_SEARCH_KEY
pst_string mimetype
mapi element 0x370e PR_ATTACH_MIME_TAG
void pst_vbgrow(pst_vbuf *vb, size_t len)
out: vbavail(vb) >= len, data are preserved
pst_string cc_address
mapi element 0x0e03 PR_DISPLAY_CC
pst_string sentto_address
mapi element 0x0e04 PR_DISPLAY_TO
FILETIME * sent_date
mapi element 0x0039 PR_CLIENT_SUBMIT_TIME
int delivery_report
mapi element 0x0023 PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED
pst_string filename1
mapi element 0x3704 PR_ATTACH_FILENAME
pst_string body
mapi element 0x1000 PR_BODY
static void int_property(property_list &prop_list, uint32_t tag, uint32_t flags, uint32_t value)
#define DEBUG_HEXDUMPC(x, s, c)
pst_string sender_access
mapi element 0x0064 PR_SENT_REPRESENTING_ADDRTYPE
pst_string outlook_recipient
mapi element 0x0051 PR_RECEIVED_BY_SEARCH_KEY
int read_receipt
mapi element 0x0029 PR_READ_RECEIPT_REQUESTED
uint64_t i_id
calculated from id2_val during creation of record
pst_string bcc_address
mapi element 0x0e02 PR_DISPLAY_BCC
static void strin0_property(GsfOutfile *out, property_list &prop, uint32_t tag, const char *charset, pst_string &contents)
pst_string htmlbody
mapi element 0x1013
int32_t sequence
mapi element 0x3710 PR_ATTACH_MIME_SEQUENCE
int reply_requested
mapi element 0x0c17 PR_REPLY_REQUESTED
pst_string in_reply_to
mapi element 0x1042
pst_string outlook_normalized_subject
mapi element 0x0e1d PR_NORMALIZED_SUBJECT
pst_string outlook_sender_name
mapi element 0x0042 PR_SENT_REPRESENTING_NAME
pst_string sender2_address
mapi element 0x0c1f PR_SENDER_EMAIL_ADDRESS
This contains the email related mapi elements.
pst_string return_path_address
mapi element 0x1046, this seems to be the message-id of the rfc822 mail that is being returned ...
pst_string filename2
mapi element 0x3707 PR_ATTACH_LONG_FILENAME
size_t pst_attach_to_file(pst_file *pf, pst_item_attach *attach, FILE *fp)
Write a binary attachment to a file.
pst_string recip_address
mapi element 0x0076 PR_RECEIVED_BY_EMAIL_ADDRESS
static void i64_property(property_list &prop_list, uint32_t tag, uint32_t flags, FILETIME *value)
static void empty_property(GsfOutfile *out, uint32_t tag)
pst_item_email * email
email mapi elements
int32_t sensitivity
mapi element 0x0036 PR_SENSITIVITY
pst_item_attach * attach
linked list of attachments
pst_string recip2_access
mapi element 0x0077 PR_RCVD_REPRESENTING_ADDRTYPE
pst_string original_to
mapi element 0x0074 PR_ORIGINAL_DISPLAY_TO
struct pst_item_attach * next
int32_t position
mapi element 0x370b PR_RENDERING_POSITION
pst_string outlook_sender2
mapi element 0x0c1d PR_SENDER_SEARCH_KEY
pst_string original_bcc
mapi element 0x0072 PR_ORIGINAL_DISPLAY_BCC
static void string_property(GsfOutfile *out, property_list &prop, uint32_t tag, const char *contents, size_t size)