annotate src/lspst.c @ 46:b2a7f2e0926a

more fixes for 64 bit format
author carl
date Sat, 12 Jan 2008 15:20:53 -0800
parents f6db1f060a95
children f66078abed38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
1 /***
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
2 * lspst.c
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
3 * Part of the LibPST project
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
4 * Author: Joe Nahmias <joe@nahmias.net>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
5 * Based on readpst.c by by David Smith <dave.s@earthcorp.com>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
6 *
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
7 */
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
8
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
9 // header file includes
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
10 #include <stdio.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
11 #include <stdlib.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
12 #include <time.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
13 #include <string.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
14 #include <ctype.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
15 #include <errno.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
17 #include "libpst.h"
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
18 #include "define.h"
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
19 #include "timeconv.h"
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
20
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
21 struct file_ll {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
22 char *dname;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
23 int32_t stored_count;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
24 int32_t email_count;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
25 int32_t skip_count;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
26 int32_t type;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
27 };
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
28
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
29
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
30 void canonicalize_filename(char *fname);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
31 void debug_print(char *fmt, ...);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
32
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
33 // global settings
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
34 pst_file pstfile;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
35
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
36
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
37 void create_enter_dir(struct file_ll* f, pst_item *item)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
38 {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
39 f->email_count = 0;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
40 f->skip_count = 0;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
41 f->type = item->type;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
42 f->stored_count = (item->folder) ? item->folder->email_count : 0;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
43 f->dname = (char*) xmalloc(strlen(item->file_as)+1);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
44 strcpy(f->dname, item->file_as);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
45 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
46
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
47
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
48 void close_enter_dir(struct file_ll *f)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
49 {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
50 free(f->dname);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
51 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
52
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
53
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
54 void process(pst_item *outeritem, pst_desc_ll *d_ptr)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
55 {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
56 struct file_ll ff;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
57 pst_item *item = NULL;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
58
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
59 DEBUG_ENT("process");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
60 memset(&ff, 0, sizeof(ff));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
61 create_enter_dir(&ff, outeritem);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
62
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
63 while (d_ptr) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
64 DEBUG_MAIN(("main: New item record, d_ptr = %p.\n", d_ptr));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
65 if (!d_ptr->desc) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
66 DEBUG_WARN(("main: ERROR ?? item's desc record is NULL\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
67 ff.skip_count++;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
68 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
69 else {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
70 DEBUG_MAIN(("main: Desc Email ID %x [d_ptr->id = %x]\n", d_ptr->desc->id, d_ptr->id));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
71
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
72 item = pst_parse_item(&pstfile, d_ptr);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
73 DEBUG_MAIN(("main: About to process item @ %p.\n", item));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
74 if (item) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
75 if (item->message_store) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
76 // there should only be one message_store, and we have already done it
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
77 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
78 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
79
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
80 if (item->folder && d_ptr->child) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
81 // if this is a folder, we want to recurse into it
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
82 printf("Folder \"%s\"\n", item->file_as);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
83 process(item, d_ptr->child);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
84
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
85 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
86 // Process Contact item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
87 if (ff.type != PST_TYPE_CONTACT) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
88 DEBUG_MAIN(("main: I have a contact, but the folder isn't a contacts folder. Processing anyway\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
89 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
90 printf("Contact");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
91 if (item->contact->fullname != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
92 printf("\t%s", pst_rfc2426_escape(item->contact->fullname));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
93 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
94
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
95 } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
96 // Process Email item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
97 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_REPORT)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
98 DEBUG_MAIN(("main: I have an email, but the folder isn't an email folder. Processing anyway\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
99 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
100 printf("Email");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
101 if (item->email->outlook_sender_name != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
102 printf("\tFrom: %s", item->email->outlook_sender_name);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
103 if (item->email->subject->subj != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
104 printf("\tSubject: %s", item->email->subject->subj);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
105 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
106
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
107 } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
108 // Process Journal item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
109 if (ff.type != PST_TYPE_JOURNAL) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
110 DEBUG_MAIN(("main: I have a journal entry, but folder isn't specified as a journal type. Processing...\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
111 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
112 printf("Journal\t%s\n", pst_rfc2426_escape(item->email->subject->subj));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
113
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
114 } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
115 // Process Calendar Appointment item
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
116 DEBUG_MAIN(("main: Processing Appointment Entry\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
117 if (ff.type != PST_TYPE_APPOINTMENT) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
118 DEBUG_MAIN(("main: I have an appointment, but folder isn't specified as an appointment type. Processing...\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
119 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
120 printf("Appointment");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
121 if (item->email != NULL && item->email->subject != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
122 printf("\tSUMMARY: %s", pst_rfc2426_escape(item->email->subject->subj));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
123 if (item->appointment != NULL) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
124 if (item->appointment->start != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
125 printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
126 if (item->appointment->end != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
127 printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
128 printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
129 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
130 printf("\n");
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
131
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
132 } else {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
133 ff.skip_count++;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
134 DEBUG_MAIN(("main: Unknown item type. %i. Ascii1=\"%s\"\n",
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
135 item->type, item->ascii_type));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
136 }
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
137 pst_freeItem(item);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
138 } else {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
139 ff.skip_count++;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
140 DEBUG_MAIN(("main: A NULL item was seen\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
141 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
142 d_ptr = d_ptr->next;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
143 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
144 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
145 close_enter_dir(&ff);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
146 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
147
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
148
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
149 int main(int argc, char** argv) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
150 pst_item *item = NULL;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
151 pst_desc_ll *d_ptr;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
152 char *temp = NULL; //temporary char pointer
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
153 char *d_log = NULL;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
154
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
155 if (argc <= 1) DIE(("Missing PST filename.\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
156
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
157 DEBUG_INIT(d_log);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
158 DEBUG_REGISTER_CLOSE();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
159 DEBUG_ENT("main");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
160
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
161 // Open PST file
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
162 if (pst_open(&pstfile, argv[1], "r")) DIE(("Error opening File\n"));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
163
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
164 // Load PST index
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
165 if (pst_load_index(&pstfile)) DIE(("Index Error\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
166
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
167 pst_load_extended_attributes(&pstfile);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
168
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
169 d_ptr = pstfile.d_head; // first record is main record
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
170 item = pst_parse_item(&pstfile, d_ptr);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
171 if (!item || !item->message_store) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
172 DEBUG_RET();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
173 DIE(("main: Could not get root record\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
174 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
175
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
176 // default the file_as to the same as the main filename if it doesn't exist
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
177 if (!item->file_as) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
178 if (!(temp = strrchr(argv[1], '/')))
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
179 if (!(temp = strrchr(argv[1], '\\')))
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
180 temp = argv[1];
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
181 else
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
182 temp++; // get past the "\\"
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
183 else
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
184 temp++; // get past the "/"
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
185 item->file_as = (char*)xmalloc(strlen(temp)+1);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
186 strcpy(item->file_as, temp);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
187 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
188 fprintf(stderr, "item->file_as = '%s'.\n", item->file_as);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
189
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
190 d_ptr = pst_getTopOfFolders(&pstfile, item);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
191 if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n"));
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
192 DEBUG_MAIN(("d_ptr(TOF) = %p.\n", d_ptr));
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
193
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
194 process(item, d_ptr->child); // do the childred of TOPF
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
195 pst_freeItem(item);
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
196 pst_close(&pstfile);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
197
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
198 DEBUG_RET();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
199 return 0;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
200 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
201
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
202
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
203 // This function will make sure that a filename is in cannonical form. That
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
204 // is, it will replace any slashes, backslashes, or colons with underscores.
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
205 void canonicalize_filename(char *fname) {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
206 DEBUG_ENT("canonicalize_filename");
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
207 if (fname == NULL) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
208 DEBUG_RET();
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
209 return;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
210 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
211 while ((fname = strpbrk(fname, "/\\:")) != NULL)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
212 *fname = '_';
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
213 DEBUG_RET();
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
214 }
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
215
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
216
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
217 void debug_print(char *fmt, ...) {
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
218 // shamlessly stolen from minprintf() in K&R pg. 156
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
219 va_list ap;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
220 char *p, *sval;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
221 void *pval;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
222 int ival;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
223 double dval;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
224 FILE *fp = stderr;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
225
43
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
226 va_start(ap, fmt);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
227 for(p = fmt; *p; p++) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
228 if (*p != '%') {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
229 fputc(*p, fp);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
230 continue;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
231 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
232 switch (tolower(*++p)) {
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
233 case 'd': case 'i':
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
234 ival = va_arg(ap, int);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
235 fprintf(fp, "%d", ival);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
236 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
237 case 'f':
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
238 dval = va_arg(ap, double);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
239 fprintf(fp, "%f", dval);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
240 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
241 case 's':
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
242 for (sval = va_arg(ap, char *); *sval; ++sval)
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
243 fputc(*sval, fp);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
244 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
245 case 'p':
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
246 pval = va_arg(ap, void *);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
247 fprintf(fp, "%p", pval);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
248 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
249 case 'x':
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
250 ival = va_arg(ap, int);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
251 fprintf(fp, "%#010x", ival);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
252 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
253 default:
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
254 fputc(*p, fp);
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
255 break;
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
256 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
257 }
f6db1f060a95 start on outlook 2003 64 bit format
carl
parents: 31
diff changeset
258 va_end(ap);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
259 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
260
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
261