comparison src/lspst.c @ 151:cda7c812ec01

track character set individually for each mapi element
author Carl Byington <carl@five-ten-sg.com>
date Sun, 08 Mar 2009 14:35:26 -0700
parents 06aa84023b48
children 581fab9f1dc7
comparison
equal deleted inserted replaced
150:06aa84023b48 151:cda7c812ec01
26 pst_file pstfile; 26 pst_file pstfile;
27 27
28 28
29 void create_enter_dir(struct file_ll* f, pst_item *item) 29 void create_enter_dir(struct file_ll* f, pst_item *item)
30 { 30 {
31 pst_convert_utf8(item, &item->file_as);
31 f->email_count = 0; 32 f->email_count = 0;
32 f->skip_count = 0; 33 f->skip_count = 0;
33 f->type = item->type; 34 f->type = item->type;
34 f->stored_count = (item->folder) ? item->folder->email_count : 0; 35 f->stored_count = (item->folder) ? item->folder->email_count : 0;
35 f->dname = (char*) xmalloc(strlen(item->file_as)+1); 36 f->dname = (char*) xmalloc(strlen(item->file_as.str)+1);
36 strcpy(f->dname, item->file_as); 37 strcpy(f->dname, item->file_as.str);
37 } 38 }
38 39
39 40
40 void close_enter_dir(struct file_ll *f) 41 void close_enter_dir(struct file_ll *f)
41 { 42 {
68 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n")); 69 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n"));
69 } 70 }
70 71
71 if (item->folder && d_ptr->child) { 72 if (item->folder && d_ptr->child) {
72 // if this is a folder, we want to recurse into it 73 // if this is a folder, we want to recurse into it
73 printf("Folder \"%s\"\n", item->file_as); 74 pst_convert_utf8(item, &item->file_as);
75 printf("Folder \"%s\"\n", item->file_as.str);
74 process(item, d_ptr->child); 76 process(item, d_ptr->child);
75 77
76 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { 78 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) {
77 // Process Contact item 79 // Process Contact item
78 if (ff.type != PST_TYPE_CONTACT) { 80 if (ff.type != PST_TYPE_CONTACT) {
79 DEBUG_MAIN(("main: I have a contact, but the folder isn't a contacts folder. Processing anyway\n")); 81 DEBUG_MAIN(("main: I have a contact, but the folder isn't a contacts folder. Processing anyway\n"));
80 } 82 }
81 printf("Contact"); 83 printf("Contact");
82 if (item->contact->fullname) 84 if (item->contact->fullname.str)
83 printf("\t%s", pst_rfc2426_escape(item->contact->fullname)); 85 printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str));
84 printf("\n"); 86 printf("\n");
85 87
86 } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT || item->type == PST_TYPE_OTHER)) { 88 } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT || item->type == PST_TYPE_OTHER)) {
87 // Process Email item 89 // Process Email item
88 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_REPORT) && (ff.type != PST_TYPE_OTHER)) { 90 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_REPORT) && (ff.type != PST_TYPE_OTHER)) {
89 DEBUG_MAIN(("main: I have an email, but the folder isn't an email folder. Processing anyway\n")); 91 DEBUG_MAIN(("main: I have an email, but the folder isn't an email folder. Processing anyway\n"));
90 } 92 }
91 printf("Email"); 93 printf("Email");
92 if (item->email->outlook_sender_name) 94 if (item->email->outlook_sender_name.str)
93 printf("\tFrom: %s", item->email->outlook_sender_name); 95 printf("\tFrom: %s", item->email->outlook_sender_name.str);
94 if (item->email->subject && item->email->subject->subj) 96 if (item->subject.str)
95 printf("\tSubject: %s", item->email->subject->subj); 97 printf("\tSubject: %s", item->subject.str);
96 printf("\n"); 98 printf("\n");
97 99
98 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { 100 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) {
99 // Process Journal item 101 // Process Journal item
100 if (ff.type != PST_TYPE_JOURNAL) { 102 if (ff.type != PST_TYPE_JOURNAL) {
101 DEBUG_MAIN(("main: I have a journal entry, but folder isn't specified as a journal type. Processing...\n")); 103 DEBUG_MAIN(("main: I have a journal entry, but folder isn't specified as a journal type. Processing...\n"));
102 } 104 }
103 if (item->email && item->email->subject && item->email->subject->subj) 105 if (item->subject.str)
104 printf("Journal\t%s\n", pst_rfc2426_escape(item->email->subject->subj)); 106 printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str));
105 107
106 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) { 108 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) {
107 // Process Calendar Appointment item 109 // Process Calendar Appointment item
108 DEBUG_MAIN(("main: Processing Appointment Entry\n")); 110 DEBUG_MAIN(("main: Processing Appointment Entry\n"));
109 if (ff.type != PST_TYPE_APPOINTMENT) { 111 if (ff.type != PST_TYPE_APPOINTMENT) {
110 DEBUG_MAIN(("main: I have an appointment, but folder isn't specified as an appointment type. Processing...\n")); 112 DEBUG_MAIN(("main: I have an appointment, but folder isn't specified as an appointment type. Processing...\n"));
111 } 113 }
112 printf("Appointment"); 114 printf("Appointment");
113 if (item->email && item->email->subject) 115 if (item->subject.str)
114 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->email->subject->subj)); 116 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str));
115 if (item->appointment->start) 117 if (item->appointment->start)
116 printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start)); 118 printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start));
117 if (item->appointment->end) 119 if (item->appointment->end)
118 printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end)); 120 printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end));
119 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No")); 121 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No"));
220 DEBUG_RET(); 222 DEBUG_RET();
221 DIE(("main: Could not get root record\n")); 223 DIE(("main: Could not get root record\n"));
222 } 224 }
223 225
224 // default the file_as to the same as the main filename if it doesn't exist 226 // default the file_as to the same as the main filename if it doesn't exist
225 if (!item->file_as) { 227 if (!item->file_as.str) {
226 if (!(temp = strrchr(argv[1], '/'))) 228 if (!(temp = strrchr(argv[1], '/')))
227 if (!(temp = strrchr(argv[1], '\\'))) 229 if (!(temp = strrchr(argv[1], '\\')))
228 temp = argv[1]; 230 temp = argv[1];
229 else 231 else
230 temp++; // get past the "\\" 232 temp++; // get past the "\\"
231 else 233 else
232 temp++; // get past the "/" 234 temp++; // get past the "/"
233 item->file_as = (char*)xmalloc(strlen(temp)+1); 235 item->file_as.str = (char*)xmalloc(strlen(temp)+1);
234 strcpy(item->file_as, temp); 236 strcpy(item->file_as.str, temp);
235 } 237 item->file_as.is_utf8 = 1;
236 fprintf(stderr, "item->file_as = '%s'.\n", item->file_as); 238 }
239 WARN(("item->file_as = '%s'.\n", item->file_as.str));
237 240
238 d_ptr = pst_getTopOfFolders(&pstfile, item); 241 d_ptr = pst_getTopOfFolders(&pstfile, item);
239 if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n")); 242 if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n"));
240 DEBUG_MAIN(("d_ptr(TOF) = %p.\n", d_ptr)); 243 DEBUG_MAIN(("d_ptr(TOF) = %p.\n", d_ptr));
241 244
260 *fname = '_'; 263 *fname = '_';
261 DEBUG_RET(); 264 DEBUG_RET();
262 } 265 }
263 266
264 267
265 void debug_print(char *fmt, ...) {
266 // shamlessly stolen from minprintf() in K&R pg. 156
267 va_list ap;
268 char *p, *sval;
269 void *pval;
270 int ival;
271 double dval;
272 FILE *fp = stderr;
273
274 va_start(ap, fmt);
275 for(p = fmt; *p; p++) {
276 if (*p != '%') {
277 fputc(*p, fp);
278 continue;
279 }
280 switch (tolower(*++p)) {
281 case 'd': case 'i':
282 ival = va_arg(ap, int);
283 fprintf(fp, "%d", ival);
284 break;
285 case 'f':
286 dval = va_arg(ap, double);
287 fprintf(fp, "%f", dval);
288 break;
289 case 's':
290 for (sval = va_arg(ap, char *); *sval; ++sval)
291 fputc(*sval, fp);
292 break;
293 case 'p':
294 pval = va_arg(ap, void *);
295 fprintf(fp, "%p", pval);
296 break;
297 case 'x':
298 ival = va_arg(ap, int);
299 fprintf(fp, "%#010x", ival);
300 break;
301 default:
302 fputc(*p, fp);
303 break;
304 }
305 }
306 va_end(ap);
307 }
308
309