comparison src/libpst.c @ 297:8b3a827b71f4

add alarm reminders to calendar events
author Carl Byington <carl@five-ten-sg.com>
date Thu, 28 Jul 2011 17:28:49 -0700
parents cc8ee701f190
children 201464dd356e
comparison
equal deleted inserted replaced
296:2066f13990a3 297:8b3a827b71f4
279 static uint64_t pst_getIntAt(pst_file *pf, char *buf); 279 static uint64_t pst_getIntAt(pst_file *pf, char *buf);
280 static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos); 280 static uint64_t pst_getIntAtPos(pst_file *pf, int64_t pos);
281 static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head); 281 static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head);
282 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr); 282 static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr);
283 static void pst_printID2ptr(pst_id2_tree *ptr); 283 static void pst_printID2ptr(pst_id2_tree *ptr);
284 static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach); 284 static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach);
285 static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf); 285 static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf);
286 static int pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type); 286 static int pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type);
287 static int pst_stricmp(char *a, char *b); 287 static int pst_stricmp(char *a, char *b);
288 static int pst_strincmp(char *a, char *b, size_t x); 288 static int pst_strincmp(char *a, char *b, size_t x);
289 static char* pst_wide_to_single(char *wt, size_t size); 289 static char* pst_wide_to_single(char *wt, size_t size);
1244 } 1244 }
1245 1245
1246 item = (pst_item*) pst_malloc(sizeof(pst_item)); 1246 item = (pst_item*) pst_malloc(sizeof(pst_item));
1247 memset(item, 0, sizeof(pst_item)); 1247 memset(item, 0, sizeof(pst_item));
1248 1248
1249 if (pst_process(list, item, NULL)) { 1249 if (pst_process(d_ptr->desc->i_id, list, item, NULL)) {
1250 DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n")); 1250 DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n"));
1251 pst_freeItem(item); 1251 pst_freeItem(item);
1252 pst_free_list(list); 1252 pst_free_list(list);
1253 if (!m_head) pst_free_id2(id2_head); 1253 if (!m_head) pst_free_id2(id2_head);
1254 DEBUG_RET(); 1254 DEBUG_RET();
1265 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach)); 1265 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
1266 memset(attach, 0, sizeof(pst_item_attach)); 1266 memset(attach, 0, sizeof(pst_item_attach));
1267 attach->next = item->attach; 1267 attach->next = item->attach;
1268 item->attach = attach; 1268 item->attach = attach;
1269 } 1269 }
1270 if (pst_process(list, item, item->attach)) { 1270 if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) {
1271 DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n")); 1271 DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n"));
1272 pst_freeItem(item); 1272 pst_freeItem(item);
1273 pst_free_list(list); 1273 pst_free_list(list);
1274 if (!m_head) pst_free_id2(id2_head); 1274 if (!m_head) pst_free_id2(id2_head);
1275 DEBUG_RET(); 1275 DEBUG_RET();
1297 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach)); 1297 attach = (pst_item_attach*) pst_malloc(sizeof(pst_item_attach));
1298 memset(attach, 0, sizeof(pst_item_attach)); 1298 memset(attach, 0, sizeof(pst_item_attach));
1299 attach->next = item->attach; 1299 attach->next = item->attach;
1300 item->attach = attach; 1300 item->attach = attach;
1301 } 1301 }
1302 if (pst_process(list, item, item->attach)) { 1302 if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) {
1303 DEBUG_WARN(("ERROR pst_process() failed with attachments\n")); 1303 DEBUG_WARN(("ERROR pst_process() failed with attachments\n"));
1304 pst_freeItem(item); 1304 pst_freeItem(item);
1305 pst_free_list(list); 1305 pst_free_list(list);
1306 if (!m_head) pst_free_id2(id2_head); 1306 if (!m_head) pst_free_id2(id2_head);
1307 DEBUG_RET(); 1307 DEBUG_RET();
1327 if (list->count_objects > 1) { 1327 if (list->count_objects > 1) {
1328 DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n")); 1328 DEBUG_WARN(("ERROR probably fatal, list count array will overrun attach structure.\n"));
1329 } 1329 }
1330 // reprocess the same attachment list against new data 1330 // reprocess the same attachment list against new data
1331 // this might update attach->id2_val 1331 // this might update attach->id2_val
1332 if (pst_process(list, item, attach)) { 1332 if (pst_process(id2_ptr->id->i_id, list, item, attach)) {
1333 DEBUG_WARN(("ERROR pst_process() failed with an attachment\n")); 1333 DEBUG_WARN(("ERROR pst_process() failed with an attachment\n"));
1334 pst_free_list(list); 1334 pst_free_list(list);
1335 continue; 1335 continue;
1336 } 1336 }
1337 pst_free_list(list); 1337 pst_free_list(list);
2119 * this is non-null, the length of the this attachment list 2119 * this is non-null, the length of the this attachment list
2120 * must be at least as large as the length of the MAPI objects list. 2120 * must be at least as large as the length of the MAPI objects list.
2121 * 2121 *
2122 * @return 0 for ok, -1 for error. 2122 * @return 0 for ok, -1 for error.
2123 */ 2123 */
2124 static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { 2124 static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach) {
2125 DEBUG_ENT("pst_process"); 2125 DEBUG_ENT("pst_process");
2126 if (!item) { 2126 if (!item) {
2127 DEBUG_WARN(("item cannot be NULL.\n")); 2127 DEBUG_WARN(("item cannot be NULL.\n"));
2128 DEBUG_RET(); 2128 DEBUG_RET();
2129 return -1; 2129 return -1;
2130 } 2130 }
2131 2131
2132 item->block_id = block_id;
2132 while (list) { 2133 while (list) {
2133 int32_t x; 2134 int32_t x;
2134 char time_buffer[30]; 2135 char time_buffer[30];
2135 for (x=0; x<list->count_elements; x++) { 2136 for (x=0; x<list->count_elements; x++) {
2136 int32_t t; 2137 int32_t t;