Mercurial > libpst
comparison src/lspst.c @ 202:2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 18 May 2009 15:55:05 -0700 |
parents | e3a46f66332b |
children | 94bde95d7e18 |
comparison
equal
deleted
inserted
replaced
201:3850a3b11745 | 202:2f38c4ce606f |
---|---|
52 memset(&ff, 0, sizeof(ff)); | 52 memset(&ff, 0, sizeof(ff)); |
53 create_enter_dir(&ff, outeritem); | 53 create_enter_dir(&ff, outeritem); |
54 | 54 |
55 while (d_ptr) { | 55 while (d_ptr) { |
56 if (!d_ptr->desc) { | 56 if (!d_ptr->desc) { |
57 DEBUG_WARN(("main: ERROR item's desc record is NULL\n")); | 57 DEBUG_WARN(("ERROR item's desc record is NULL\n")); |
58 ff.skip_count++; | 58 ff.skip_count++; |
59 } | 59 } |
60 else { | 60 else { |
61 DEBUG_MAIN(("main: Desc Email ID %"PRIx64" [d_ptr->d_id = %"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id)); | 61 DEBUG_INFO(("Desc Email ID %"PRIx64" [d_ptr->d_id = %"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id)); |
62 | 62 |
63 item = pst_parse_item(&pstfile, d_ptr, NULL); | 63 item = pst_parse_item(&pstfile, d_ptr, NULL); |
64 DEBUG_MAIN(("main: About to process item @ %p.\n", item)); | 64 DEBUG_INFO(("About to process item @ %p.\n", item)); |
65 if (item) { | 65 if (item) { |
66 if (item->message_store) { | 66 if (item->message_store) { |
67 // there should only be one message_store, and we have already done it | 67 // there should only be one message_store, and we have already done it |
68 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n")); | 68 DIE(("A second message_store has been found. Sorry, this must be an error.\n")); |
69 } | 69 } |
70 | 70 |
71 if (item->folder && d_ptr->child) { | 71 if (item->folder && d_ptr->child) { |
72 // if this is a folder, we want to recurse into it | 72 // if this is a folder, we want to recurse into it |
73 pst_convert_utf8(item, &item->file_as); | 73 pst_convert_utf8(item, &item->file_as); |
76 | 76 |
77 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { | 77 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { |
78 if (!ff.type) ff.type = item->type; | 78 if (!ff.type) ff.type = item->type; |
79 // Process Contact item | 79 // Process Contact item |
80 if (ff.type != PST_TYPE_CONTACT) { | 80 if (ff.type != PST_TYPE_CONTACT) { |
81 DEBUG_MAIN(("main: I have a contact, but the folder isn't a contacts folder. Processing anyway\n")); | 81 DEBUG_INFO(("I have a contact, but the folder isn't a contacts folder. Processing anyway\n")); |
82 } | 82 } |
83 printf("Contact"); | 83 printf("Contact"); |
84 if (item->contact->fullname.str) | 84 if (item->contact->fullname.str) |
85 printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str)); | 85 printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str)); |
86 printf("\n"); | 86 printf("\n"); |
87 | 87 |
88 } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) { | 88 } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) { |
89 if (!ff.type) ff.type = item->type; | 89 if (!ff.type) ff.type = item->type; |
90 // Process Email item | 90 // Process Email item |
91 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_SCHEDULE) && (ff.type != PST_TYPE_REPORT)) { | 91 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_SCHEDULE) && (ff.type != PST_TYPE_REPORT)) { |
92 DEBUG_MAIN(("main: I have an email, but the folder isn't an email folder. Processing anyway\n")); | 92 DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n")); |
93 } | 93 } |
94 printf("Email"); | 94 printf("Email"); |
95 if (item->email->outlook_sender_name.str) | 95 if (item->email->outlook_sender_name.str) |
96 printf("\tFrom: %s", item->email->outlook_sender_name.str); | 96 printf("\tFrom: %s", item->email->outlook_sender_name.str); |
97 if (item->subject.str) | 97 if (item->subject.str) |
100 | 100 |
101 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { | 101 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { |
102 if (!ff.type) ff.type = item->type; | 102 if (!ff.type) ff.type = item->type; |
103 // Process Journal item | 103 // Process Journal item |
104 if (ff.type != PST_TYPE_JOURNAL) { | 104 if (ff.type != PST_TYPE_JOURNAL) { |
105 DEBUG_MAIN(("main: I have a journal entry, but folder isn't specified as a journal type. Processing...\n")); | 105 DEBUG_INFO(("I have a journal entry, but folder isn't specified as a journal type. Processing...\n")); |
106 } | 106 } |
107 if (item->subject.str) | 107 if (item->subject.str) |
108 printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str)); | 108 printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str)); |
109 | 109 |
110 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) { | 110 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) { |
111 char time_buffer[30]; | 111 char time_buffer[30]; |
112 if (!ff.type) ff.type = item->type; | 112 if (!ff.type) ff.type = item->type; |
113 // Process Calendar Appointment item | 113 // Process Calendar Appointment item |
114 DEBUG_MAIN(("main: Processing Appointment Entry\n")); | 114 DEBUG_INFO(("Processing Appointment Entry\n")); |
115 if (ff.type != PST_TYPE_APPOINTMENT) { | 115 if (ff.type != PST_TYPE_APPOINTMENT) { |
116 DEBUG_MAIN(("main: I have an appointment, but folder isn't specified as an appointment type. Processing...\n")); | 116 DEBUG_INFO(("I have an appointment, but folder isn't specified as an appointment type. Processing...\n")); |
117 } | 117 } |
118 printf("Appointment"); | 118 printf("Appointment"); |
119 if (item->subject.str) | 119 if (item->subject.str) |
120 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str)); | 120 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str)); |
121 if (item->appointment->start) | 121 if (item->appointment->start) |
125 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No")); | 125 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No")); |
126 printf("\n"); | 126 printf("\n"); |
127 | 127 |
128 } else { | 128 } else { |
129 ff.skip_count++; | 129 ff.skip_count++; |
130 DEBUG_MAIN(("main: Unknown item type. %i. Ascii1=\"%s\"\n", | 130 DEBUG_INFO(("Unknown item type. %i. Ascii1=\"%s\"\n", |
131 item->type, item->ascii_type)); | 131 item->type, item->ascii_type)); |
132 } | 132 } |
133 pst_freeItem(item); | 133 pst_freeItem(item); |
134 } else { | 134 } else { |
135 ff.skip_count++; | 135 ff.skip_count++; |
136 DEBUG_MAIN(("main: A NULL item was seen\n")); | 136 DEBUG_INFO(("A NULL item was seen\n")); |
137 } | 137 } |
138 d_ptr = d_ptr->next; | 138 d_ptr = d_ptr->next; |
139 } | 139 } |
140 } | 140 } |
141 close_enter_dir(&ff); | 141 close_enter_dir(&ff); |
201 | 201 |
202 #ifdef DEBUG_ALL | 202 #ifdef DEBUG_ALL |
203 // force a log file | 203 // force a log file |
204 if (!d_log) d_log = "lspst.log"; | 204 if (!d_log) d_log = "lspst.log"; |
205 #endif // defined DEBUG_ALL | 205 #endif // defined DEBUG_ALL |
206 DEBUG_INIT(d_log); | 206 DEBUG_INIT(d_log, NULL); |
207 DEBUG_REGISTER_CLOSE(); | |
208 DEBUG_ENT("main"); | 207 DEBUG_ENT("main"); |
209 | 208 |
210 if (argc <= optind) { | 209 if (argc <= optind) { |
211 usage(argv[0]); | 210 usage(argv[0]); |
212 exit(2); | 211 exit(2); |
222 | 221 |
223 d_ptr = pstfile.d_head; // first record is main record | 222 d_ptr = pstfile.d_head; // first record is main record |
224 item = pst_parse_item(&pstfile, d_ptr, NULL); | 223 item = pst_parse_item(&pstfile, d_ptr, NULL); |
225 if (!item || !item->message_store) { | 224 if (!item || !item->message_store) { |
226 DEBUG_RET(); | 225 DEBUG_RET(); |
227 DIE(("main: Could not get root record\n")); | 226 DIE(("Could not get root record\n")); |
228 } | 227 } |
229 | 228 |
230 // default the file_as to the same as the main filename if it doesn't exist | 229 // default the file_as to the same as the main filename if it doesn't exist |
231 if (!item->file_as.str) { | 230 if (!item->file_as.str) { |
232 if (!(temp = strrchr(argv[1], '/'))) | 231 if (!(temp = strrchr(argv[1], '/'))) |