comparison pst2ldif.c @ 7:3e3d8b576630

changes to look for duplicates
author carl
date Thu, 23 Dec 2004 13:38:01 -0800
parents 28737b9480e4
children
comparison
equal deleted inserted replaced
6:3484500f514e 7:3e3d8b576630
41 #include "timeconv.h" 41 #include "timeconv.h"
42 #include "lzfu.h" 42 #include "lzfu.h"
43 43
44 #define OUTPUT_TEMPLATE "%s" 44 #define OUTPUT_TEMPLATE "%s"
45 45
46 #define VERSION "0.1" 46 #define VERSION "0.2"
47 // max size of the c_time char*. It will store the date of the email 47 // max size of the c_time char*. It will store the date of the email
48 #define C_TIME_SIZE 500 48 #define C_TIME_SIZE 500
49 #define PERM_DIRS 0777 49 #define PERM_DIRS 0777
50 50
51 // macro used for creating directories 51 // macro used for creating directories
58 int32_t usage(); 58 int32_t usage();
59 int32_t version(); 59 int32_t version();
60 char *my_stristr(char *haystack, char *needle); 60 char *my_stristr(char *haystack, char *needle);
61 char *check_filename(char *fname); 61 char *check_filename(char *fname);
62 char *single(char *str); 62 char *single(char *str);
63 char *multi(char *fmt, char *str); 63 char *folded(char *str);
64 void multi(char *fmt, char *str);
64 char *rfc2426_escape(char *str); 65 char *rfc2426_escape(char *str);
65 int32_t chr_count(char *str, char x); 66 int32_t chr_count(char *str, char x);
66 67
67 char *prog_name; 68 char *prog_name;
68 pst_file pstfile; 69 pst_file pstfile;
91 if (item->message_store) { 92 if (item->message_store) {
92 // there should only be one message_store, and we have already done it 93 // there should only be one message_store, and we have already done it
93 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n")); 94 DIE(("main: A second message_store has been found. Sorry, this must be an error.\n"));
94 } 95 }
95 96
96 if (item->folder) { //if this is a folder, we want to recurse into it 97 if (item->folder && d_ptr->child && strcasecmp(item->file_as, "Deleted Items")) {
98 //if this is a non-empty folder other than deleted items, we want to recurse into it
99 fprintf(stderr, "entering folder %s\n", item->file_as);
97 process(d_ptr->child); 100 process(d_ptr->child);
98 } else if (item->contact) { 101 } else if (item->contact) {
99 // deal with a contact 102 // deal with a contact
100 if (item->type != PST_TYPE_CONTACT) { 103 if (item->type != PST_TYPE_CONTACT) {
101 DIE(("type should be contact\n")); 104 DIE(("type should be contact\n"));
108 single(item->contact->display_name_prefix), 111 single(item->contact->display_name_prefix),
109 single(item->contact->first_name), 112 single(item->contact->first_name),
110 single(item->contact->surname), 113 single(item->contact->surname),
111 single(item->contact->suffix)); 114 single(item->contact->suffix));
112 if (strcmp(cn, " ")) { 115 if (strcmp(cn, " ")) {
116 // fprintf(stderr, "\n\n\n");
117 // fprintf(stderr, "access_method %s\n", item->contact->access_method);
118 // fprintf(stderr, "account_name %s\n", item->contact->account_name);
119 // fprintf(stderr, "address1 %s\n", item->contact->address1);
120 // fprintf(stderr, "address1_desc %s\n", item->contact->address1_desc);
121 // fprintf(stderr, "address1_transport %s\n", item->contact->address1_transport);
122 // fprintf(stderr, "address2 %s\n", item->contact->address2);
123 // fprintf(stderr, "address2_desc %s\n", item->contact->address2_desc);
124 // fprintf(stderr, "address2_transport %s\n", item->contact->address2_transport);
125 // fprintf(stderr, "address3 %s\n", item->contact->address3);
126 // fprintf(stderr, "address3_desc %s\n", item->contact->address3_desc);
127 // fprintf(stderr, "address3_transport %s\n", item->contact->address3_transport);
128 // fprintf(stderr, "assistant_name %s\n", item->contact->assistant_name);
129 // fprintf(stderr, "assistant_phone %s\n", item->contact->assistant_phone);
130 // fprintf(stderr, "billing_information %s\n", item->contact->billing_information);
131 // fprintf(stderr, "business_address %s\n", item->contact->business_address);
132 // fprintf(stderr, "business_city %s\n", item->contact->business_city);
133 // fprintf(stderr, "business_country %s\n", item->contact->business_country);
134 // fprintf(stderr, "business_fax %s\n", item->contact->business_fax);
135 // fprintf(stderr, "business_homepage %s\n", item->contact->business_homepage);
136 // fprintf(stderr, "business_phone %s\n", item->contact->business_phone);
137 // fprintf(stderr, "business_phone2 %s\n", item->contact->business_phone2);
138 // fprintf(stderr, "business_po_box %s\n", item->contact->business_po_box);
139 // fprintf(stderr, "business_postal_code %s\n", item->contact->business_postal_code);
140 // fprintf(stderr, "business_state %s\n", item->contact->business_state);
141 // fprintf(stderr, "business_street %s\n", item->contact->business_street);
142 // fprintf(stderr, "callback_phone %s\n", item->contact->callback_phone);
143 // fprintf(stderr, "car_phone %s\n", item->contact->car_phone);
144 // fprintf(stderr, "company_main_phone %s\n", item->contact->company_main_phone);
145 // fprintf(stderr, "company_name %s\n", item->contact->company_name);
146 // fprintf(stderr, "computer_name %s\n", item->contact->computer_name);
147 // fprintf(stderr, "customer_id %s\n", item->contact->customer_id);
148 // fprintf(stderr, "def_postal_address %s\n", item->contact->def_postal_address);
149 // fprintf(stderr, "department %s\n", item->contact->department);
150 // fprintf(stderr, "display_name_prefix %s\n", item->contact->display_name_prefix);
151 // fprintf(stderr, "first_name %s\n", item->contact->first_name);
152 // fprintf(stderr, "followup %s\n", item->contact->followup);
153 // fprintf(stderr, "free_busy_address %s\n", item->contact->free_busy_address);
154 // fprintf(stderr, "ftp_site %s\n", item->contact->ftp_site);
155 // fprintf(stderr, "fullname %s\n", item->contact->fullname);
156 // fprintf(stderr, "gov_id %s\n", item->contact->gov_id);
157 // fprintf(stderr, "hobbies %s\n", item->contact->hobbies);
158 // fprintf(stderr, "home_address %s\n", item->contact->home_address);
159 // fprintf(stderr, "home_city %s\n", item->contact->home_city);
160 // fprintf(stderr, "home_country %s\n", item->contact->home_country);
161 // fprintf(stderr, "home_fax %s\n", item->contact->home_fax);
162 // fprintf(stderr, "home_phone %s\n", item->contact->home_phone);
163 // fprintf(stderr, "home_phone2 %s\n", item->contact->home_phone2);
164 // fprintf(stderr, "home_po_box %s\n", item->contact->home_po_box);
165 // fprintf(stderr, "home_postal_code %s\n", item->contact->home_postal_code);
166 // fprintf(stderr, "home_state %s\n", item->contact->home_state);
167 // fprintf(stderr, "home_street %s\n", item->contact->home_street);
168 // fprintf(stderr, "initials %s\n", item->contact->initials);
169 // fprintf(stderr, "isdn_phone %s\n", item->contact->isdn_phone);
170 // fprintf(stderr, "job_title %s\n", item->contact->job_title);
171 // fprintf(stderr, "keyword %s\n", item->contact->keyword);
172 // fprintf(stderr, "language %s\n", item->contact->language);
173 // fprintf(stderr, "location %s\n", item->contact->location);
174 // fprintf(stderr, "manager_name %s\n", item->contact->manager_name);
175 // fprintf(stderr, "middle_name %s\n", item->contact->middle_name);
176 // fprintf(stderr, "mileage %s\n", item->contact->mileage);
177 // fprintf(stderr, "mobile_phone %s\n", item->contact->mobile_phone);
178 // fprintf(stderr, "nickname %s\n", item->contact->nickname);
179 // fprintf(stderr, "office_loc %s\n", item->contact->office_loc);
180 // fprintf(stderr, "org_id %s\n", item->contact->org_id);
181 // fprintf(stderr, "other_address %s\n", item->contact->other_address);
182 // fprintf(stderr, "other_city %s\n", item->contact->other_city);
183 // fprintf(stderr, "other_country %s\n", item->contact->other_country);
184 // fprintf(stderr, "other_phone %s\n", item->contact->other_phone);
185 // fprintf(stderr, "other_po_box %s\n", item->contact->other_po_box);
186 // fprintf(stderr, "other_postal_code %s\n", item->contact->other_postal_code);
187 // fprintf(stderr, "other_state %s\n", item->contact->other_state);
188 // fprintf(stderr, "other_street %s\n", item->contact->other_street);
189 // fprintf(stderr, "pager_phone %s\n", item->contact->pager_phone);
190 // fprintf(stderr, "personal_homepage %s\n", item->contact->personal_homepage);
191 // fprintf(stderr, "pref_name %s\n", item->contact->pref_name);
192 // fprintf(stderr, "primary_fax %s\n", item->contact->primary_fax);
193 // fprintf(stderr, "primary_phone %s\n", item->contact->primary_phone);
194 // fprintf(stderr, "profession %s\n", item->contact->profession);
195 // fprintf(stderr, "radio_phone %s\n", item->contact->radio_phone);
196 // fprintf(stderr, "spouse_name %s\n", item->contact->spouse_name);
197 // fprintf(stderr, "suffix %s\n", item->contact->suffix);
198 // fprintf(stderr, "surname %s\n", item->contact->surname);
199 // fprintf(stderr, "telex %s\n", item->contact->telex);
200 // fprintf(stderr, "transmittable_display_name %s\n", item->contact->transmittable_display_name);
201 // fprintf(stderr, "ttytdd_phone %s\n", item->contact->ttytdd_phone);
113 // have a valid cn 202 // have a valid cn
114 printf("dn: cn=%s, %s\n", trim(cn), ldap_base); 203 printf("dn: cn=%s, %s\n", trim(cn), ldap_base);
115 printf("cn: %s\n", trim(cn)); 204 printf("cn: %s\n", trim(cn));
116 if (item->contact->first_name) { 205 if (item->contact->first_name) {
117 snprintf(cn, sizeof(cn), "%s %s", 206 snprintf(cn, sizeof(cn), "%s %s",
353 if (n) *n = '\0'; 442 if (n) *n = '\0';
354 return ret; 443 return ret;
355 } 444 }
356 445
357 446
358 char *multi(char *fmt, char *str) { 447 char *folded(char *str) {
359 if (!str) return ""; 448 if (!str) return "";
449 char *ret = rfc2426_escape(str);
450 char *n = ret;
451 while (n = strchr(n, '\n')) {
452 *n = ' ';
453 }
454 n = ret;
455 while (n = strchr(n, ',')) {
456 *n = ' ';
457 }
458 return ret;
459 }
460
461
462 void multi(char *fmt, char *str) {
463 if (!str) return;
360 char *ret = rfc2426_escape(str); 464 char *ret = rfc2426_escape(str);
361 char *n = ret; 465 char *n = ret;
362 while (n = strchr(ret, '\n')) { 466 while (n = strchr(ret, '\n')) {
363 *n = '\0'; 467 *n = '\0';
364 printf(fmt, ret); 468 printf(fmt, ret);