Mercurial > libpst
diff src/readpst.c @ 195:320cfcba8058
add python module interface to the shared library for easy scripting.
the shared library must never write to stdout or stderr.
fix pst_attach_to_mem so the caller does not need to initialize the buffer pointer.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 20 Apr 2009 19:39:26 -0700 |
parents | 4b498fd68464 |
children | 07ceebd115ce |
line wrap: on
line diff
--- a/src/readpst.c Fri Apr 17 13:08:31 2009 -0700 +++ b/src/readpst.c Mon Apr 20 19:39:26 2009 -0700 @@ -786,11 +786,7 @@ if (!(fp = fopen(temp, "w"))) { WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp)); } else { - if (attach->data.data) - pst_fwrite(attach->data.data, (size_t)1, attach->data.size, fp); - else { - (void)pst_attach_to_file(pst, attach, fp); - } + (void)pst_attach_to_file(pst, attach, fp); fclose(fp); } if (temp) free(temp); @@ -829,18 +825,10 @@ void write_inline_attachment(FILE* f_output, pst_item_attach* attach, char *boundary, pst_file* pst) { char *attach_filename; - char *enc = NULL; // base64 encoded attachment DEBUG_ENT("write_inline_attachment"); DEBUG_EMAIL(("Attachment Size is %"PRIu64", id %#"PRIx64"\n", (uint64_t)attach->data.size, attach->i_id)); - if (attach->data.data) { - enc = pst_base64_encode (attach->data.data, attach->data.size); - if (!enc) { - DEBUG_EMAIL(("ERROR base64_encode returned NULL. Must have failed\n")); - DEBUG_RET(); - return; - } - } - else { + + if (!attach->data.data) { // make sure we can fetch data from the id pst_index_ll *ptr = pst_getID(pst, attach->i_id); if (!ptr) { @@ -867,13 +855,7 @@ fprintf(f_output, "Content-Disposition: attachment; filename=\"%s\"\n\n", attach_filename); } - if (attach->data.data) { - pst_fwrite(enc, 1, strlen(enc), f_output); - DEBUG_EMAIL(("Attachment Size after encoding is %i\n", strlen(enc))); - free(enc); // caught by valgrind - } else { - (void)pst_attach_to_file_base64(pst, attach, f_output); - } + (void)pst_attach_to_file_base64(pst, attach, f_output); fprintf(f_output, "\n\n"); DEBUG_RET(); }