Mercurial > libpst
annotate src/pst2ldif.cpp @ 100:1e4a7610d525
fixes from Justin Greer to add -D option to include deleted items, to add missing email headers, to fix bug in my_stristr()
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 02 Oct 2008 15:29:36 -0700 |
parents | b7f456946c5b |
children | 39ba19372732 |
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> | |
15 | |
16 extern "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
|
17 #include "define.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
|
18 #include "libstrfunc.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
|
19 #include "libpst.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
|
20 #include "common.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
|
21 #include "timeconv.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
|
22 #include "lzfu.h" |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
23 #include "stdarg.h" |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
24 #include "iconv.h" |
16 | 25 } |
26 | |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
27 int32_t usage(); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
28 int32_t version(); |
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
|
29 char *check_filename(char *fname); |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
30 char *dn_escape(const char *str); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
31 void print_ldif(const char *dn, const char *value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
32 void print_ldif_single(const char *dn, const char *value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
33 void print_ldif_multi(const char *dn, const char *value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
34 void print_ldif_two(const char *dn, const char *value1, const char *value2); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
35 void build_cn(char *cn, size_t len, int nvalues, char *value, ...); |
16 | 36 |
37 char *prog_name; | |
38 pst_file pstfile; | |
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
|
39 char *ldap_base = NULL; // 'o=some.domain.tld, c=US' |
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
|
40 char *ldap_class = NULL; // 'newPerson' |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
41 char *ldap_org = NULL; // 'some.domain.tld', computed from ldap_base |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
42 iconv_t cd = 0; // Character set conversion descriptor |
16 | 43 |
44 | |
45 //////////////////////////////////////////////// | |
46 // define our ordering | |
47 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
|
48 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
|
49 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
|
50 } |
16 | 51 }; |
52 // 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
|
53 typedef set<const char *, ltstr> string_set; |
16 | 54 // make a static set to hold the cn values |
55 static string_set all_strings; | |
56 | |
57 | |
58 //////////////////////////////////////////////// | |
41
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
59 // helper to free all the strings in a set |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
60 // |
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 static void free_strings(string_set &s) |
183ae993b9ad
security fix for potential buffer overrun in lz decompress
carl
parents:
38
diff
changeset
|
63 { |
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) { |
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
|
102 char n[strlen(name)+10]; |
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
|
103 snprintf(n, sizeof(n), "%s %d", name, unique++); |
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
|
104 string_set::iterator i = all_strings.find(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
|
105 if (i == all_strings.end()) return register_string(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
|
106 } |
16 | 107 } |
108 | |
109 | |
110 static void process(pst_desc_ll *d_ptr); | |
111 static void process(pst_desc_ll *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
|
112 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
|
113 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
|
114 if (d_ptr->desc) { |
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 item = pst_parse_item(&pstfile, 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
|
116 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
|
117 if (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->folder && d_ptr->child && strcasecmp(item->file_as, "Deleted Items")) { |
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
|
119 //if this is a non-empty folder other than deleted items, we want to recurse into it |
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 fprintf(stderr, "entering folder %s\n", item->file_as); |
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
|
121 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
|
122 |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
123 } 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
|
124 // 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
|
125 char cn[1000]; |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 // have a valid cn |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
133 const char *ucn = unique_string(cn); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
134 char dn[strlen(ucn) + strlen(ldap_base) + 6]; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
135 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
136 sprintf(dn, "cn=%s, %s", ucn, ldap_base); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
137 print_ldif_single("dn", dn); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
138 print_ldif_single("cn", ucn); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
139 if (item->contact->first_name) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
144 if (item->contact->surname) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
145 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
|
146 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
|
147 item->contact->suffix); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
148 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
149 else if (item->contact->company_name) { |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
150 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
|
151 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
152 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
|
153 print_ldif_single("sn", ucn); // use cn as sn if we cannot find something better |
16 | 154 |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
155 if (item->contact->job_title) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
156 print_ldif_single("personalTitle", item->contact->job_title); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
157 if (item->contact->company_name) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
158 print_ldif_single("company", 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
|
159 if (item->contact->address1 && *item->contact->address1) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
160 print_ldif_single("mail", item->contact->address1); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
161 if (item->contact->address2 && *item->contact->address2) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
162 print_ldif_single("mail", item->contact->address2); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
163 if (item->contact->address3 && *item->contact->address3) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
164 print_ldif_single("mail", item->contact->address3); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
165 if (item->contact->address1a && *item->contact->address1a) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
166 print_ldif_single("mail", item->contact->address1a); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
167 if (item->contact->address2a && *item->contact->address2a) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
168 print_ldif_single("mail", item->contact->address2a); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
169 if (item->contact->address3a && *item->contact->address3a) |
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 print_ldif_single("mail", item->contact->address3a); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
171 if (item->contact->business_address) { |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
172 if (item->contact->business_po_box) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
173 print_ldif_single("postalAddress", item->contact->business_po_box); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
174 if (item->contact->business_street) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
175 print_ldif_multi("postalAddress", item->contact->business_street); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
176 if (item->contact->business_city) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
177 print_ldif_single("l", item->contact->business_city); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
178 if (item->contact->business_state) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
179 print_ldif_single("st", item->contact->business_state); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
180 if (item->contact->business_postal_code) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
181 print_ldif_single("postalCode", item->contact->business_postal_code); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
182 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
183 else if (item->contact->home_address) { |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
184 if (item->contact->home_po_box) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
185 print_ldif_single("postalAddress", item->contact->home_po_box); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
186 if (item->contact->home_street) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
187 print_ldif_multi("postalAddress", item->contact->home_street); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
188 if (item->contact->home_city) |
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_single("l", item->contact->home_city); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
190 if (item->contact->home_state) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
191 print_ldif_single("st", item->contact->home_state); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
192 if (item->contact->home_postal_code) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
193 print_ldif_single("postalCode", item->contact->home_postal_code); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
194 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
195 else if (item->contact->other_address) { |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
196 if (item->contact->other_po_box) |
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("postalAddress", item->contact->other_po_box); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
198 if (item->contact->other_street) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
199 print_ldif_multi("postalAddress", item->contact->other_street); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
200 if (item->contact->other_city) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
201 print_ldif_single("l", item->contact->other_city); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
202 if (item->contact->other_state) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
203 print_ldif_single("st", item->contact->other_state); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
204 if (item->contact->other_postal_code) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
205 print_ldif_single("postalCode", item->contact->other_postal_code); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
206 } |
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
207 if (item->contact->business_fax) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
208 print_ldif_single("facsimileTelephoneNumber", item->contact->business_fax); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
209 else if (item->contact->home_fax) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
210 print_ldif_single("facsimileTelephoneNumber", item->contact->home_fax); |
16 | 211 |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
212 if (item->contact->business_phone) |
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("telephoneNumber", item->contact->business_phone); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
214 if (item->contact->home_phone) |
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("homePhone", item->contact->home_phone); |
16 | 216 |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
217 if (item->contact->car_phone) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
218 print_ldif_single("mobile", item->contact->car_phone); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
219 else if (item->contact->mobile_phone) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
220 print_ldif_single("mobile", item->contact->mobile_phone); |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
221 else if (item->contact->other_phone) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
222 print_ldif_single("mobile", item->contact->other_phone); |
16 | 223 |
224 | |
79
56fa05fd5271
Patch from Robert Simpson for encryption type 2.
Carl Byington <carl@five-ten-sg.com>
parents:
73
diff
changeset
|
225 if (item->comment) |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
226 print_ldif_single("description", item->comment); |
16 | 227 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
228 print_ldif("objectClass", ldap_class); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
229 putchar('\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
|
230 } |
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
|
231 } |
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
|
232 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
|
233 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
|
234 } |
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
|
235 } |
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
|
236 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
|
237 } |
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
|
238 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
|
239 } |
16 | 240 } |
241 | |
242 | |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
243 void print_ldif(const char *dn, const char *value) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
244 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
245 printf("%s: %s\n", dn, value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
246 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
247 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
248 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
249 // Prints a Distinguished Name together with its value. |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
250 // 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
|
251 // then it is output as a BASE-64 encoded value |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
252 void print_ldif_single(const char *dn, const char *value) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
253 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
254 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
|
255 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
|
256 bool needs_code_conversion = false; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
257 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
|
258 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
259 // 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
|
260 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
|
261 len = strlen(value) + 1; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
262 char buffer[len]; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
263 char *p = buffer; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
264 // 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
|
265 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
266 // 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
|
267 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
|
268 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
|
269 for (;;) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
270 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
|
271 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
272 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
|
273 break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
274 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
|
275 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
276 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
|
277 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
|
278 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
279 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
280 else { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
281 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
|
282 needs_code_conversion = true; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
283 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
|
284 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
285 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
|
286 *p++ = ' '; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
287 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
|
288 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
289 *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
|
290 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
291 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
292 *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
|
293 if (is_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
|
294 printf("%s: %s\n", dn, buffer); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
295 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
296 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
297 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
298 if (needs_code_conversion && cd != 0) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
299 size_t inlen = p - buffer; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
300 size_t utf8_len = 2 * inlen + 1; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
301 char utf8_buffer[utf8_len]; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
302 char *utf8_p = utf8_buffer; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
303 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
304 iconv(cd, NULL, NULL, NULL, NULL); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
305 p = buffer; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
306 int ret = iconv(cd, &p, &inlen, &utf8_p, &utf8_len); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
307 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
308 if (ret >= 0) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
309 *utf8_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
|
310 p = base64_encode(utf8_buffer, utf8_p - utf8_buffer); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
311 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
312 else |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
313 p = base64_encode(buffer, strlen(buffer)); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
314 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
315 else |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
316 p = base64_encode(buffer, strlen(buffer)); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
317 printf("%s:: %s\n", dn, p); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
318 free(p); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
319 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
320 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
321 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
322 void print_ldif_multi(const char *dn, const char *value) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
323 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
324 const char *n; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
325 while ((n = strchr(value, '\n'))) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
326 print_ldif_single(dn, value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
327 value = n + 1; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
328 } |
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(dn, value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
330 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
331 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
332 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
333 void print_ldif_two(const char *dn, const char *value1, const char *value2) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
334 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
335 size_t len1, len2; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
336 if (value1 && *value1) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
337 len1 = strlen(value1); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
338 else { |
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(dn, value2); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
340 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
341 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
342 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
343 if (value2 && *value2) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
344 len2 = strlen(value2); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
345 else { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
346 print_ldif_single(dn, value1); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
347 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
348 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
349 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
350 char value[len1 + len2 + 2]; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
351 memcpy(value, value1, len1); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
352 value[len1] = ' '; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
353 memcpy(value + len1 + 1, value2, len2 + 1); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
354 print_ldif_single(dn, value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
355 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
356 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
357 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
358 void build_cn(char *cn, size_t len, int nvalues, char *value, ...) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
359 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
360 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
|
361 int 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
|
362 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
|
363 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
364 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
|
365 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
366 while (!value) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
367 nvalues--; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
368 if (nvalues == 0) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
369 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
|
370 return; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
371 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
372 value = va_arg(ap, char *); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
373 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
374 for (;;) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
375 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
|
376 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
377 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
|
378 do { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
379 value = NULL; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
380 nvalues--; |
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 (nvalues == 0) break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
382 value = va_arg(ap, char *); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
383 } while (!value); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
384 if (!value) break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
385 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
|
386 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
387 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
|
388 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
389 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
|
390 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
|
391 continue; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
392 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
393 else { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
399 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
|
400 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
401 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
|
402 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
|
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 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
|
406 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
|
407 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
408 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
409 |
16 | 410 int main(int argc, char** argv) { |
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
|
411 pst_desc_ll *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
|
412 char *fname = 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
|
413 char *temp = NULL; //temporary char pointer |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
414 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
|
415 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
|
416 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
|
417 pst_item *item = NULL; |
16 | 418 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
419 while ((c = getopt(argc, argv, "b:c:C:d:Vh"))!= -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
|
420 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
|
421 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
|
422 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
|
423 temp = strchr(ldap_base, ','); |
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
|
424 if (temp) { |
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
|
425 *temp = '\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
|
426 ldap_org = strdup(ldap_base+2); // assume first 2 chars are o= |
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
|
427 *temp = ','; |
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
|
428 } |
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
|
429 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
|
430 case '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
|
431 ldap_class = 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
|
432 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
|
433 case 'C': |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
434 cd = iconv_open("UTF-8", optarg); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
435 if (cd == (iconv_t)(-1)) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
436 fprintf(stderr, "I don't know character set \"%s\"!\n\n", optarg); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
437 fprintf(stderr, "Type: \"iconv --list\" to get list of known character sets\n"); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
438 return 1; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
439 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 } |
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
|
457 } |
16 | 458 |
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
|
459 if ((argc > optind) && (ldap_base) && (ldap_class) && (ldap_org)) { |
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
|
460 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
|
461 } 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
|
462 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
|
463 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
|
464 } |
16 | 465 |
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
|
466 #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
|
467 // 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
|
468 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
|
469 #endif |
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
|
470 DEBUG_INIT(d_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
|
471 DEBUG_REGISTER_CLOSE(); |
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
|
472 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
|
473 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
|
474 RET_DERROR(pst_load_index(&pstfile), 2, ("Index Error\n")); |
16 | 475 |
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
|
476 pst_load_extended_attributes(&pstfile); |
16 | 477 |
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
|
478 d_ptr = pstfile.d_head; // first record is main record |
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
|
479 item = (pst_item*)pst_parse_item(&pstfile, 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
|
480 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
|
481 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
|
482 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
|
483 } |
16 | 484 |
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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 } |
16 | 490 |
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
|
491 pst_freeItem(item); |
16 | 492 |
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
|
493 // write the ldap header |
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
|
494 printf("dn: %s\n", ldap_base); |
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
|
495 printf("o: %s\n", ldap_org); |
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
|
496 printf("objectClass: organization\n\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
|
497 printf("dn: cn=root, %s\n", ldap_base); |
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
|
498 printf("cn: root\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
|
499 printf("objectClass: %s\n\n", ldap_class); |
16 | 500 |
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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 return 0; |
16 | 506 } |
507 | |
508 | |
509 int usage() { | |
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
|
510 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
|
511 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
|
512 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
|
513 printf("\t-h\t- Help. This screen\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
|
514 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
|
515 printf("\t-b ldapbase\t- set the LDAP base value\n"); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
516 printf("\t-c class \t- set the class of the LDAP objects\n"); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
517 printf("\t-C charset \t- assumed character set of non-ASCII characters\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
|
518 return 0; |
16 | 519 } |
520 | |
521 | |
522 int version() { | |
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
|
523 printf("pst2ldif v%s\n", VERSION); |
16 | 524 #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
|
525 printf("Big Endian implementation being used.\n"); |
16 | 526 #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
|
527 printf("Little Endian implementation being used.\n"); |
16 | 528 #else |
529 # error "Byte order not supported by this library" | |
530 #endif | |
531 #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
|
532 printf("GCC %d.%d : %s %s\n", __GNUC__, __GNUC_MINOR__, __DATE__, __TIME__); |
16 | 533 #endif |
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
|
534 return 0; |
16 | 535 } |
536 | |
537 | |
538 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
|
539 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
|
540 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
|
541 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
|
542 } |
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
|
543 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
|
544 // 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
|
545 *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
|
546 } |
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
|
547 return fname; |
16 | 548 } |
549 | |
99
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 0 |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
551 // This function escapes Distinguished Names (as per RFC4514) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
552 char *dn_escape(const char *str) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
553 static char* buf = NULL; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
554 const char *a; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
555 char *ret, *b; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
556 if (str == NULL) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
557 ret = NULL; |
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 { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
559 // Calculate maximum space needed (if every character must be escaped) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
560 int x = 2 * strlen(str) + 1; // don't forget room for the NUL |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
561 buf = (char*) realloc(buf, x); |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
562 a = str; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
563 b = buf; |
16 | 564 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
565 // remove leading spaces (RFC says escape them) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
566 while (*a == ' ') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
567 a++; |
16 | 568 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
569 // escape initial '#' |
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 (*a == '#') |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
571 *b++ = '\\'; |
16 | 572 |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
573 while (*a != '\0') { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
574 switch(*a) { |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
575 case '\\': |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
576 case '"' : |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
577 case '+' : |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
578 case ';' : |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
579 case '<' : |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
580 case '>' : |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
581 *(b++)='\\'; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
582 *b=*a; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
583 break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
584 case '\r': // skip cr |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
585 b--; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
586 break; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
587 default: |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
588 *b=*a; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
589 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
590 b++; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
591 a++; |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
592 } |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
593 *b = '\0'; // NUL-terminate the string (buf) |
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
594 ret = buf; |
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
|
595 } |
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 return ret; |
16 | 597 } |
99
b7f456946c5b
add configure option --enable-dii=no to remove dependency on libgd.
Carl Byington <carl@five-ten-sg.com>
parents:
79
diff
changeset
|
598 #endif |