Mercurial > libpst
annotate src/pst2ldif.cpp @ 247:85d77d7b034b
another patche from Kenneth Berland for solaris
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 07 May 2010 12:07:46 -0700 |
parents | 67b24d6a45d6 |
children | 898118c3675e |
rev | line source |
---|---|
16 | 1 /* |
2 | |
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under | |
4 the GPL version 2 or any later version at your choice available at | |
5 http://www.fsf.org/licenses/gpl.txt | |
6 | |
7 Based on readpst.c by David Smith | |
8 | |
9 */ | |
10 | |
11 using namespace std; | |
12 | |
13 // needed for std c++ collections | |
14 #include <set> | |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
15 #include <vector> |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
16 #include <string> |
16 | 17 |
18 extern "C" { | |
122
bdb38b434c0a
more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents:
120
diff
changeset
|
19 #include "define.h" |
bdb38b434c0a
more changes from Fridrich Strba to avoid installing our config.h
Carl Byington <carl@five-ten-sg.com>
parents:
120
diff
changeset
|
20 #include "lzfu.h" |
16 | 21 } |
22 | |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
114
diff
changeset
|
23 void usage(void); |
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
114
diff
changeset
|
24 void version(void); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
25 char *check_filename(char *fname); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
26 void print_ldif_single(const char *attr, const char *value); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
27 void print_ldif_single(const char *attr, pst_string value); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
28 void print_ldif_address(const char *attr, int nvalues, pst_string value, ...); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
29 void print_ldif_dn(const char *attr, pst_string value, const char *base); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
30 void print_ldif_multi(const char *dn, pst_string value); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
31 void print_ldif_two(const char *attr, pst_string value1, pst_string value2); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
32 void print_escaped_dn(const char *value); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
33 void build_cn(char *cn, size_t len, int nvalues, pst_string value, ...); |
16 | 34 |
35 char *prog_name; | |
36 pst_file pstfile; | |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
37 bool old_schema = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
38 char *ldap_base = NULL; // 'o=some.domain.tld,c=US' |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
39 int ldif_extra_line_count = 0; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
40 vector<string> ldap_class; // 'newPerson' or 'inetOrgPerson' |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
41 vector<string> ldif_extra_line; // 'o: myorg' |
16 | 42 |
43 | |
44 //////////////////////////////////////////////// | |
45 // define our ordering | |
46 struct ltstr { | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
47 bool operator()(const char* s1, const char* s2) const { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
48 return strcasecmp(s1, s2) < 0; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
49 } |
16 | 50 }; |
51 // define our set | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
52 typedef set<const char *, ltstr> string_set; |
16 | 53 // make a static set to hold the cn values |
54 static string_set all_strings; | |
55 | |
56 | |
57 //////////////////////////////////////////////// | |
41
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
58 // helper to free all the strings in a set |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
59 // |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
60 static void free_strings(string_set &s); |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
61 static void free_strings(string_set &s) |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
62 { |
230
42b38d65f7e4
patches from Justin Greer
Carl Byington <carl@five-ten-sg.com>
parents:
202
diff
changeset
|
63 if (s.empty()) return; |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
64 for (string_set::iterator i=s.begin(); i!=s.end(); i++) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
65 free((void*)*i); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
66 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
67 s.clear(); |
41
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
68 } |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
69 |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
70 |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
71 //////////////////////////////////////////////// |
16 | 72 // helper to register a string in a string set |
73 // | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
74 static const char* register_string(string_set &s, const char *name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
75 static const char* register_string(string_set &s, const char *name) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
76 string_set::const_iterator i = s.find(name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
77 if (i != s.end()) return *i; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
78 char *x = strdup(name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
79 s.insert(x); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
80 return x; |
16 | 81 } |
82 | |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
83 |
16 | 84 //////////////////////////////////////////////// |
85 // register a global string | |
86 // | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
87 static const char* register_string(const char *name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
88 static const char* register_string(const char *name) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
89 return register_string(all_strings, name); |
16 | 90 } |
91 | |
92 | |
93 //////////////////////////////////////////////// | |
94 // make a unique string | |
95 // | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
96 static const char* unique_string(const char *name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
97 static const char* unique_string(const char *name) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
98 int unique = 2; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
99 string_set::iterator i = all_strings.find(name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
100 if (i == all_strings.end()) return register_string(name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
101 while (true) { |
128
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
102 vector<char> n(strlen(name)+10); |
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
103 snprintf(&n[0], n.size(), "%s %d", name, unique++); |
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
104 string_set::iterator i = all_strings.find(&n[0]); |
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
105 if (i == all_strings.end()) return register_string(&n[0]); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
106 } |
16 | 107 } |
108 | |
109 | |
186
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
110 static void process(pst_desc_tree *d_ptr); |
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
111 static void process(pst_desc_tree *d_ptr) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
112 DEBUG_ENT("process"); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
113 pst_item *item = NULL; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
114 while (d_ptr) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
115 if (d_ptr->desc) { |
143
fdc58ad2c758
fix embedded rfc822 messages with attachments
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
116 item = pst_parse_item(&pstfile, d_ptr, NULL); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
117 DEBUG_INFO(("item pointer is %p\n", item)); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
118 if (item) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
119 if (item->folder && d_ptr->child && item->file_as.str && strcasecmp(item->file_as.str, "Deleted Items")) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
120 //if this is a non-empty folder other than deleted items, we want to recurse into it |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
121 fprintf(stderr, "entering folder %s\n", item->file_as.str); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
122 process(d_ptr->child); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
123 |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
124 } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
125 // deal with a contact |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
126 char cn[1000]; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
127 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
128 // convert everything to utf8 |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
129 pst_convert_utf8_null(item, &item->contact->display_name_prefix); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
130 pst_convert_utf8_null(item, &item->contact->first_name); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
131 pst_convert_utf8_null(item, &item->contact->surname); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
132 pst_convert_utf8_null(item, &item->contact->suffix); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
133 pst_convert_utf8_null(item, &item->contact->company_name); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
134 pst_convert_utf8_null(item, &item->contact->job_title); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
135 pst_convert_utf8_null(item, &item->contact->address1); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
136 pst_convert_utf8_null(item, &item->contact->address2); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
137 pst_convert_utf8_null(item, &item->contact->address3); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
138 pst_convert_utf8_null(item, &item->contact->address1a); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
139 pst_convert_utf8_null(item, &item->contact->address2a); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
140 pst_convert_utf8_null(item, &item->contact->address3a); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
141 pst_convert_utf8_null(item, &item->contact->business_address); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
142 pst_convert_utf8_null(item, &item->contact->business_po_box); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
143 pst_convert_utf8_null(item, &item->contact->business_street); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
144 pst_convert_utf8_null(item, &item->contact->business_city); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
145 pst_convert_utf8_null(item, &item->contact->business_state); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
146 pst_convert_utf8_null(item, &item->contact->business_postal_code); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
147 pst_convert_utf8_null(item, &item->contact->home_address); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
148 pst_convert_utf8_null(item, &item->contact->home_po_box); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
149 pst_convert_utf8_null(item, &item->contact->home_street); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
150 pst_convert_utf8_null(item, &item->contact->home_city); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
151 pst_convert_utf8_null(item, &item->contact->home_state); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
152 pst_convert_utf8_null(item, &item->contact->home_postal_code); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
153 pst_convert_utf8_null(item, &item->contact->other_address); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
154 pst_convert_utf8_null(item, &item->contact->other_po_box); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
155 pst_convert_utf8_null(item, &item->contact->other_street); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
156 pst_convert_utf8_null(item, &item->contact->other_city); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
157 pst_convert_utf8_null(item, &item->contact->other_state); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
158 pst_convert_utf8_null(item, &item->contact->other_postal_code); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
159 pst_convert_utf8_null(item, &item->contact->business_fax); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
160 pst_convert_utf8_null(item, &item->contact->home_fax); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
161 pst_convert_utf8_null(item, &item->contact->business_phone); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
162 pst_convert_utf8_null(item, &item->contact->home_phone); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
163 pst_convert_utf8_null(item, &item->contact->car_phone); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
164 pst_convert_utf8_null(item, &item->contact->mobile_phone); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
165 pst_convert_utf8_null(item, &item->contact->other_phone); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
166 pst_convert_utf8_null(item, &item->contact->business_homepage); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
167 pst_convert_utf8_null(item, &item->contact->personal_homepage); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
168 pst_convert_utf8_null(item, &item->comment); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
169 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
170 build_cn(cn, sizeof(cn), 4, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
171 item->contact->display_name_prefix, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
172 item->contact->first_name, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
173 item->contact->surname, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
174 item->contact->suffix); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
175 if (cn[0] != 0) { |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
176 // have a valid cn |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
177 pst_string ucn; |
160
252ad66d3d6e
fix ppc64 compile error
Carl Byington <carl@five-ten-sg.com>
parents:
151
diff
changeset
|
178 ucn.str = (char*)unique_string(cn); |
252ad66d3d6e
fix ppc64 compile error
Carl Byington <carl@five-ten-sg.com>
parents:
151
diff
changeset
|
179 ucn.is_utf8 = 1; // all the components are already utf8 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
180 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
181 print_ldif_dn("dn", ucn, ldap_base); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
182 print_ldif_single("cn", ucn); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
183 if (item->contact->first_name.str) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
184 print_ldif_two("givenName", |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
185 item->contact->display_name_prefix, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
186 item->contact->first_name); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
187 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
188 if (item->contact->surname.str) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
189 print_ldif_two("sn", |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
190 item->contact->surname, |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
191 item->contact->suffix); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
192 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
193 else if (item->contact->company_name.str) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
194 print_ldif_single("sn", item->contact->company_name); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
195 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
196 else |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
197 print_ldif_single("sn", ucn); // use cn as sn if we cannot find something better |
16 | 198 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
199 if (old_schema) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
200 if (item->contact->job_title.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
201 print_ldif_single("personalTitle", item->contact->job_title); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
202 if (item->contact->company_name.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
203 print_ldif_single("company", item->contact->company_name); |
108
1b2a4fac1303
fix title bug with old schema in pst2ldif, also escape commas in distinguished names per rfc4514.
Carl Byington <carl@five-ten-sg.com>
parents:
106
diff
changeset
|
204 } |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
205 else { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
206 // new schema |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
207 if (item->contact->job_title.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
208 print_ldif_single("title", item->contact->job_title); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
209 if (item->contact->company_name.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
210 print_ldif_single("o", item->contact->company_name); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
211 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
212 if (item->contact->address1.str && *item->contact->address1.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
213 print_ldif_single("mail", item->contact->address1); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
214 if (item->contact->address2.str && *item->contact->address2.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
215 print_ldif_single("mail", item->contact->address2); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
216 if (item->contact->address3.str && *item->contact->address3.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
217 print_ldif_single("mail", item->contact->address3); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
218 if (item->contact->address1a.str && *item->contact->address1a.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
219 print_ldif_single("mail", item->contact->address1a); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
220 if (item->contact->address2a.str && *item->contact->address2a.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
221 print_ldif_single("mail", item->contact->address2a); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
222 if (item->contact->address3a.str && *item->contact->address3a.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
223 print_ldif_single("mail", item->contact->address3a); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
224 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
225 if (old_schema) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
226 if (item->contact->business_address.str) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
227 if (item->contact->business_po_box.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
228 print_ldif_single("postalAddress", item->contact->business_po_box); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
229 if (item->contact->business_street.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
230 print_ldif_multi("postalAddress", item->contact->business_street); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
231 if (item->contact->business_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
232 print_ldif_single("l", item->contact->business_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
233 if (item->contact->business_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
234 print_ldif_single("st", item->contact->business_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
235 if (item->contact->business_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
236 print_ldif_single("postalCode", item->contact->business_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
237 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
238 else if (item->contact->home_address.str) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
239 if (item->contact->home_po_box.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
240 print_ldif_single("postalAddress", item->contact->home_po_box); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
241 if (item->contact->home_street.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
242 print_ldif_multi("postalAddress", item->contact->home_street); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
243 if (item->contact->home_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
244 print_ldif_single("l", item->contact->home_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
245 if (item->contact->home_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
246 print_ldif_single("st", item->contact->home_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
247 if (item->contact->home_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
248 print_ldif_single("postalCode", item->contact->home_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
249 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
250 else if (item->contact->other_address.str) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
251 if (item->contact->other_po_box.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
252 print_ldif_single("postalAddress", item->contact->other_po_box); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
253 if (item->contact->other_street.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
254 print_ldif_multi("postalAddress", item->contact->other_street); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
255 if (item->contact->other_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
256 print_ldif_single("l", item->contact->other_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
257 if (item->contact->other_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
258 print_ldif_single("st", item->contact->other_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
259 if (item->contact->other_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
260 print_ldif_single("postalCode", item->contact->other_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
261 } |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
262 } |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
263 else { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
264 // new schema, with proper RFC4517 postal addresses |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
265 if (item->contact->business_address.str) { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
266 print_ldif_address("postalAddress", 6, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
267 item->contact->business_po_box, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
268 item->contact->business_street, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
269 item->contact->business_city, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
270 item->contact->business_state, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
271 item->contact->business_postal_code, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
272 item->contact->business_country); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
273 if (item->contact->business_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
274 print_ldif_single("l", item->contact->business_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
275 if (item->contact->business_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
276 print_ldif_single("st", item->contact->business_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
277 if (item->contact->business_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
278 print_ldif_single("postalCode", item->contact->business_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
279 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
280 else if (item->contact->home_address.str) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
281 if (item->contact->home_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
282 print_ldif_single("l", item->contact->home_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
283 if (item->contact->home_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
284 print_ldif_single("st", item->contact->home_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
285 if (item->contact->home_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
286 print_ldif_single("postalCode", item->contact->home_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
287 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
288 else if (item->contact->other_address.str) { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
289 print_ldif_address("postalAddress", 6, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
290 item->contact->other_po_box, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
291 item->contact->other_street, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
292 item->contact->other_city, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
293 item->contact->other_state, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
294 item->contact->other_postal_code, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
295 item->contact->other_country); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
296 if (item->contact->other_city.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
297 print_ldif_single("l", item->contact->other_city); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
298 if (item->contact->other_state.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
299 print_ldif_single("st", item->contact->other_state); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
300 if (item->contact->other_postal_code.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
301 print_ldif_single("postalCode", item->contact->other_postal_code); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
302 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
303 if (item->contact->home_address.str) { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
304 print_ldif_address("homePostalAddress", 6, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
305 item->contact->home_po_box, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
306 item->contact->home_street, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
307 item->contact->home_city, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
308 item->contact->home_state, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
309 item->contact->home_postal_code, |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
310 item->contact->home_country); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
311 } |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
312 } |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
313 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
314 if (item->contact->business_fax.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
315 print_ldif_single("facsimileTelephoneNumber", item->contact->business_fax); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
316 else if (item->contact->home_fax.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
317 print_ldif_single("facsimileTelephoneNumber", item->contact->home_fax); |
16 | 318 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
319 if (item->contact->business_phone.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
320 print_ldif_single("telephoneNumber", item->contact->business_phone); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
321 if (item->contact->home_phone.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
322 print_ldif_single("homePhone", item->contact->home_phone); |
16 | 323 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
324 if (item->contact->car_phone.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
325 print_ldif_single("mobile", item->contact->car_phone); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
326 else if (item->contact->mobile_phone.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
327 print_ldif_single("mobile", item->contact->mobile_phone); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
328 else if (item->contact->other_phone.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
329 print_ldif_single("mobile", item->contact->other_phone); |
16 | 330 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
331 if (!old_schema) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
332 if (item->contact->business_homepage.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
333 print_ldif_single("labeledURI", item->contact->business_homepage); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
334 if (item->contact->personal_homepage.str) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
335 print_ldif_single("labeledURI", item->contact->personal_homepage); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
336 } |
16 | 337 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
338 if (item->comment.str) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
339 print_ldif_single("description", item->comment); |
16 | 340 |
106
07d090676ce9
cleanup fedora9 compile warnings
Carl Byington <carl@five-ten-sg.com>
parents:
105
diff
changeset
|
341 for (vector<string>::size_type i=0; i<ldap_class.size(); i++) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
342 print_ldif_single("objectClass", ldap_class[i].c_str()); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
343 printf("\n"); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
344 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
345 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
346 else { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
347 DEBUG_INFO(("item is not a contact\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
348 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
349 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
350 pst_freeItem(item); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
351 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
352 d_ptr = d_ptr->next; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
353 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
354 DEBUG_RET(); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
355 } |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
356 |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
357 |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
358 void print_ldif_single(const char *attr, pst_string value) |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
359 { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
360 print_ldif_single(attr, value.str); |
16 | 361 } |
362 | |
363 | |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
364 // Prints an attribute together with its value. |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
365 // If the value isn't a "SAFE STRING" (as defined in RFC2849), |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
366 // then it is output as a BASE-64 encoded value |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
367 void print_ldif_single(const char *attr, const char *value) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
368 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
369 size_t len; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
370 bool is_safe_string = true; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
371 bool space_flag = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
372 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
373 // Strip leading spaces |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
374 while (*value == ' ') value++; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
375 len = strlen(value) + 1; |
128
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
376 vector<char> buffer(len); |
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
377 char *p = &buffer[0]; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
378 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
379 // See if "value" is a "SAFE STRING" |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
380 // First check characters that are safe but not safe as initial characters |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
381 if (*value == ':' || *value == '<') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
382 is_safe_string = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
383 for (;;) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
384 char ch = *value++; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
385 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
386 if (ch == 0 || ch == '\n') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
387 break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
388 else if (ch == '\r') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
389 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
390 else if (ch == ' ') { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
391 space_flag = true; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
392 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
393 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
394 else { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
395 if ((ch & 0x80) == 0x80) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
396 is_safe_string = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
397 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
398 if (space_flag) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
399 *p++ = ' '; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
400 space_flag = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
401 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
402 *p++ = ch; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
403 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
404 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
405 *p = 0; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
406 if (is_safe_string) { |
128
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
407 printf("%s: %s\n", attr, &buffer[0]); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
408 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
409 else { |
172
6954d315aaa8
move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents:
160
diff
changeset
|
410 p = pst_base64_encode(&buffer[0], buffer.size()); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
411 printf("%s:: %s\n", attr, p); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
412 free(p); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
413 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
414 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
415 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
416 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
417 // Combines values representing address lines into an address,i |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
418 // lines separated with "$" as per PostalAddress syntax in RFC4517 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
419 void print_ldif_address(const char *attr, int nvalues, pst_string value, ...) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
420 { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
421 DEBUG_ENT("print_ldif_address"); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
422 bool space_flag = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
423 bool newline_flag = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
424 char *address = NULL; // Buffer where address is built up |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
425 int len = 0; // Length of buffer |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
426 int i = 0; // Index of next character position in buffer |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
427 va_list ap; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
428 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
429 va_start(ap, value); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
430 while (!value.str) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
431 nvalues--; |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
432 if (nvalues == 0) { // Nothing at all to do! |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
433 va_end(ap); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
434 DEBUG_RET(); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
435 return; |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
436 } |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
437 value = va_arg(ap, pst_string); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
438 } |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
439 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
440 for (;;) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
441 char ch = *(value.str)++; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
442 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
443 if (ch == 0) { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
444 do { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
445 nvalues--; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
446 if (nvalues == 0) break; |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
447 value = va_arg(ap, pst_string); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
448 } while (!value.str); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
449 if (!nvalues || !value.str) break; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
450 space_flag = true; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
451 newline_flag = true; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
452 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
453 else if (ch == '\r') |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
454 continue; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
455 else if (ch == '\n') { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
456 newline_flag = true; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
457 continue; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
458 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
459 else if (ch == ' ') { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
460 space_flag = true; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
461 continue; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
462 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
463 else { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
464 if (i > (len-5)) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
465 len += 256; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
466 address = (char *)realloc(address, len); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
467 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
468 if (newline_flag) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
469 address[i++] = '$'; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
470 newline_flag = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
471 space_flag = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
472 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
473 else if (space_flag) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
474 address[i++] = ' '; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
475 space_flag = false; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
476 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
477 if (ch == '$' || ch == '\\') address[i++] = '\\'; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
478 address[i++] = ch; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
479 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
480 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
481 va_end(ap); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
482 if (i == 0) return; // Nothing to do |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
483 address[i] = 0; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
484 print_ldif_single(attr, address); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
485 free(address); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
486 DEBUG_RET(); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
487 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
488 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
489 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
490 void print_ldif_multi(const char *dn, pst_string value) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
491 { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
492 char *n; |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
493 char *valuestr = value.str; |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
494 while ((n = strchr(valuestr, '\n'))) { |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
495 print_ldif_single(dn, valuestr); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
496 valuestr = n + 1; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
497 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
498 print_ldif_single(dn, valuestr); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
499 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
500 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
501 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
502 void print_ldif_two(const char *attr, pst_string value1, pst_string value2) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
503 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
504 size_t len1, len2; |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
505 if (value1.str && *value1.str) |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
506 len1 = strlen(value1.str); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
507 else { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
508 print_ldif_single(attr, value2); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
509 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
510 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
511 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
512 if (value2.str && *value2.str) |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
513 len2 = strlen(value2.str); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
514 else { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
515 print_ldif_single(attr, value1); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
516 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
517 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
518 |
128
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
519 vector<char> value(len1 + len2 + 2); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
520 memcpy(&value[0], value1.str, len1); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
521 value[len1] = ' '; |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
522 memcpy(&value[0] + len1 + 1, value2.str, len2 + 1); |
128
7f747c8c9d02
cleanup installed headers
Carl Byington <carl@five-ten-sg.com>
parents:
122
diff
changeset
|
523 print_ldif_single(attr, &value[0]); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
524 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
525 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
526 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
527 void build_cn(char *cn, size_t len, int nvalues, pst_string value, ...) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
528 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
529 bool space_flag = false; |
105
4703d622e95b
cleanup fedora9 compile warnings
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
530 size_t i = 0; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
531 va_list ap; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
532 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
533 va_start(ap, value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
534 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
535 while (!value.str) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
536 nvalues--; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
537 if (nvalues == 0) { |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
538 cn[0] = 0; // Just a terminating NUL |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
539 va_end(ap); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
540 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
541 } |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
542 value = va_arg(ap, pst_string); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
543 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
544 for (;;) { |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
545 char ch = *(value.str)++; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
546 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
547 if (ch == 0 || ch == '\n') { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
548 do { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
549 nvalues--; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
550 if (nvalues == 0) break; |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
551 value = va_arg(ap, pst_string); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
552 } while (!value.str); |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
553 if (!nvalues || !value.str) break; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
554 space_flag = true; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
555 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
556 else if (ch == '\r') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
557 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
558 else if (ch == ' ') { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
559 space_flag = true; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
560 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
561 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
562 else { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
563 if (space_flag) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
564 if (i > 0) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
565 if (i < (len - 2)) cn[i++] = ' '; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
566 else break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
567 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
568 space_flag = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
569 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
570 if (i < (len - 1)) cn[i++] = ch; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
571 else break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
572 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
573 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
574 cn[i] = 0; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
575 va_end(ap); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
576 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
577 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
578 |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
114
diff
changeset
|
579 int main(int argc, char* const* argv) { |
186
0a4f7ecd7452
more cleanup of external names in the shared library
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
580 pst_desc_tree *d_ptr; |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
581 char *fname = NULL; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
582 int c; |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
583 char *d_log = NULL; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
584 prog_name = argv[0]; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
585 pst_item *item = NULL; |
16 | 586 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
587 while ((c = getopt(argc, argv, "b:c:d:l:oVh"))!= -1) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
588 switch (c) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
589 case 'b': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
590 ldap_base = optarg; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
591 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
592 case 'c': |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
593 ldap_class.push_back(string(optarg)); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
594 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
595 case 'd': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
596 d_log = optarg; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
597 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
598 case 'h': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
599 usage(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
600 exit(0); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
601 break; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
602 case 'l': |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
603 ldif_extra_line.push_back(string(optarg)); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
604 break; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
605 case 'o': |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
606 old_schema = true; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
607 break; |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
608 case 'V': |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
609 version(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
610 exit(0); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
611 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
612 default: |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
613 usage(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
614 exit(1); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
615 break; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
616 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
617 } |
16 | 618 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
619 if ((argc > optind) && (ldap_base)) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
620 fname = argv[optind]; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
621 } else { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
622 usage(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
623 exit(2); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
624 } |
16 | 625 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
626 #ifdef DEBUG_ALL |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
627 // force a log file |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
628 if (!d_log) d_log = "pst2ldif.log"; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
629 #endif |
202
2f38c4ce606f
remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents:
186
diff
changeset
|
630 DEBUG_INIT(d_log, NULL); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
631 DEBUG_ENT("main"); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
632 RET_DERROR(pst_open(&pstfile, fname), 1, ("Error opening File\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
633 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); |
16 | 634 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
635 pst_load_extended_attributes(&pstfile); |
16 | 636 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
637 d_ptr = pstfile.d_head; // first record is main record |
143
fdc58ad2c758
fix embedded rfc822 messages with attachments
Carl Byington <carl@five-ten-sg.com>
parents:
129
diff
changeset
|
638 item = (pst_item*)pst_parse_item(&pstfile, d_ptr, NULL); |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
639 if (!item || !item->message_store) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
640 DEBUG_RET(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
641 DIE(("main: Could not get root record\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
642 } |
16 | 643 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
644 d_ptr = pst_getTopOfFolders(&pstfile, item); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
645 if (!d_ptr) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
646 DEBUG_RET(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
647 DIE(("Top of folders record not found. Cannot continue\n")); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
648 } |
16 | 649 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
650 pst_freeItem(item); |
16 | 651 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
652 if (old_schema && (strlen(ldap_base) > 2)) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
653 char *ldap_org = strdup(ldap_base+2); // assume first 2 chars are o= |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
654 char *temp = strchr(ldap_org, ','); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
655 if (temp) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
656 *temp = '\0'; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
657 // write the ldap header |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
658 printf("dn: %s\n", ldap_base); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
659 printf("o: %s\n", ldap_org); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
660 printf("objectClass: organization\n\n"); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
661 printf("dn: cn=root, %s\n", ldap_base); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
662 printf("cn: root\n"); |
108
1b2a4fac1303
fix title bug with old schema in pst2ldif, also escape commas in distinguished names per rfc4514.
Carl Byington <carl@five-ten-sg.com>
parents:
106
diff
changeset
|
663 printf("sn: root\n"); |
106
07d090676ce9
cleanup fedora9 compile warnings
Carl Byington <carl@five-ten-sg.com>
parents:
105
diff
changeset
|
664 for (vector<string>::size_type i=0; i<ldap_class.size(); i++) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
665 print_ldif_single("objectClass", ldap_class[i].c_str()); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
666 printf("\n"); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
667 } |
242
67b24d6a45d6
patch from Hugo DesRosiers to export categories and notes into vcards.
Carl Byington <carl@five-ten-sg.com>
parents:
238
diff
changeset
|
668 free(ldap_org); // found by cppcheck |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
669 } |
16 | 670 |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
671 process(d_ptr->child); // do the children of TOPF |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
672 pst_close(&pstfile); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
673 DEBUG_RET(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
674 free_strings(all_strings); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
675 return 0; |
16 | 676 } |
677 | |
678 | |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
114
diff
changeset
|
679 void usage(void) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
680 version(); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
681 printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
682 printf("OPTIONS:\n"); |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
683 printf("\t-V\t- Version. Display program version\n"); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
684 printf("\t-b ldapbase\t- set the LDAP base value\n"); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
685 printf("\t-c class\t- set the class of the LDAP objects (may contain more than one)\n"); |
238
410b6422d65b
fix --help usage; readpstlog is gone
Carl Byington <carl@five-ten-sg.com>
parents:
230
diff
changeset
|
686 printf("\t-d <filename>\t- Debug to file.\n"); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
687 printf("\t-h\t- Help. This screen\n"); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
688 printf("\t-l line\t- extra line to insert in the LDIF file for each contact\n"); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
689 printf("\t-o\t- use old schema, default is new schema\n"); |
16 | 690 } |
691 | |
692 | |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
114
diff
changeset
|
693 void version(void) { |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
694 printf("pst2ldif v%s\n", VERSION); |
16 | 695 #if BYTE_ORDER == BIG_ENDIAN |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
696 printf("Big Endian implementation being used.\n"); |
16 | 697 #elif BYTE_ORDER == LITTLE_ENDIAN |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
698 printf("Little Endian implementation being used.\n"); |
16 | 699 #else |
700 # error "Byte order not supported by this library" | |
701 #endif | |
702 #ifdef __GNUC__ | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
703 printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__); |
16 | 704 #endif |
705 } | |
706 | |
707 | |
708 char *check_filename(char *fname) { | |
73
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
709 char *t = fname; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
710 if (t == NULL) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
711 return fname; |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
712 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
713 while ((t = strpbrk(t, "/\\:"))) { |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
714 // while there are characters in the second string that we don't want |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
715 *t = '_'; //replace them with an underscore |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
716 } |
3cb02cb1e6cd
Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
717 return fname; |
16 | 718 } |
719 | |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
720 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
721 // This function escapes Distinguished Names (as per RFC4514) |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
722 void print_ldif_dn(const char *attr, pst_string value, const char *base) |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
723 { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
724 printf("dn: cn="); |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
725 const char *valuestr = value.str; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
726 // remove leading spaces (RFC says escape them) |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
727 while (*valuestr == ' ') |
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
728 valuestr++; |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
729 |
151
cda7c812ec01
track character set individually for each mapi element
Carl Byington <carl@five-ten-sg.com>
parents:
143
diff
changeset
|
730 print_escaped_dn(valuestr); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
731 if (base && base[0]) { |
108
1b2a4fac1303
fix title bug with old schema in pst2ldif, also escape commas in distinguished names per rfc4514.
Carl Byington <carl@five-ten-sg.com>
parents:
106
diff
changeset
|
732 printf(", %s", base); |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
733 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
734 printf("\n"); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
735 return; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
736 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
737 |
16 | 738 |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
739 void print_escaped_dn(const char *value) |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
740 { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
741 char ch; |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
742 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
743 // escape initial '#' and space |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
744 if (*value == '#' || *value == ' ') |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
745 putchar('\\'); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
746 |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
747 while ((ch = *value++) != 0) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
748 if (((ch & 0x80) != 0) || (ch <= 0x1F)) |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
749 // Print as escaped hex digits |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
750 printf("\\%2.2X", ch & 0xFF); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
751 else switch (ch) { |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
752 case '\\': |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
753 case '"' : |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
754 case '+' : |
108
1b2a4fac1303
fix title bug with old schema in pst2ldif, also escape commas in distinguished names per rfc4514.
Carl Byington <carl@five-ten-sg.com>
parents:
106
diff
changeset
|
755 case ',' : |
104
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
756 case ';' : |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
757 case '<' : |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
758 case '>' : |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
759 putchar('\\'); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
760 // Fall through |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
761 default: |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
762 putchar(ch); |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
763 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
764 } |
39ba19372732
many fixes in pst2ldif by Robert Harris
Carl Byington <carl@five-ten-sg.com>
parents:
99
diff
changeset
|
765 return; |
16 | 766 } |