comparison python/python-libpst.cpp @ 298:201464dd356e

add default character set for items where the pst file does not specify a character set
author Carl Byington <carl@five-ten-sg.com>
date Tue, 02 Aug 2011 17:02:39 -0700
parents 8b3a827b71f4
children 1ddc61fd6189
comparison
equal deleted inserted replaced
297:8b3a827b71f4 298:201464dd356e
25 { 25 {
26 }; 26 };
27 27
28 class pst { 28 class pst {
29 public: 29 public:
30 pst(const string filename); 30 pst(const string filename, const string charset);
31 virtual ~pst(); 31 virtual ~pst();
32 pst_desc_tree* pst_getTopOfFolders(); 32 pst_desc_tree* pst_getTopOfFolders();
33 ppst_binary pst_attach_to_mem(pst_item_attach *attach); 33 ppst_binary pst_attach_to_mem(pst_item_attach *attach);
34 size_t pst_attach_to_file(pst_item_attach *attach, FILE* fp); 34 size_t pst_attach_to_file(pst_item_attach *attach, FILE* fp);
35 size_t pst_attach_to_file_base64(pst_item_attach *attach, FILE* fp); 35 size_t pst_attach_to_file_base64(pst_item_attach *attach, FILE* fp);
59 pst_desc_tree* topf; 59 pst_desc_tree* topf;
60 60
61 }; 61 };
62 62
63 63
64 pst::pst(const string filename) { 64 pst::pst(const string filename, const string charset) {
65 char *f = (char *)filename.c_str(); // ok, since pst_open does not actually modify this buffer, and newer versions will change the signature to const anyway 65 is_open = (::pst_open(&pf, filename.c_str(), charset.c_str()) == 0);
66 is_open = (::pst_open(&pf, f) == 0);
67 root = NULL; 66 root = NULL;
68 topf = NULL; 67 topf = NULL;
69 if (is_open) { 68 if (is_open) {
70 ::pst_load_index(&pf); 69 ::pst_load_index(&pf);
71 ::pst_load_extended_attributes(&pf); 70 ::pst_load_extended_attributes(&pf);
600 .def_readonly("size", &pst_file::size) 599 .def_readonly("size", &pst_file::size)
601 .def_readonly("encryption", &pst_file::encryption) 600 .def_readonly("encryption", &pst_file::encryption)
602 .def_readonly("ind_type", &pst_file::ind_type) 601 .def_readonly("ind_type", &pst_file::ind_type)
603 ; 602 ;
604 603
605 class_<pst>("pst", init<string>()) 604 class_<pst>("pst", init<string,string>())
606 .def("pst_getTopOfFolders", &pst::pst_getTopOfFolders, return_value_policy<reference_existing_object>()) 605 .def("pst_getTopOfFolders", &pst::pst_getTopOfFolders, return_value_policy<reference_existing_object>())
607 .def("pst_attach_to_mem", &pst::pst_attach_to_mem) 606 .def("pst_attach_to_mem", &pst::pst_attach_to_mem)
608 .def("pst_attach_to_file", &pst::pst_attach_to_file) 607 .def("pst_attach_to_file", &pst::pst_attach_to_file)
609 .def("pst_attach_to_file_base64", &pst::pst_attach_to_file_base64) 608 .def("pst_attach_to_file_base64", &pst::pst_attach_to_file_base64)
610 .def("pst_getNextDptr", &pst::pst_getNextDptr, return_value_policy<reference_existing_object>()) 609 .def("pst_getNextDptr", &pst::pst_getNextDptr, return_value_policy<reference_existing_object>())