Pass around what kind of transparency an image actually needs. Use
[wine] / dlls / wldap32 / value.c
1 /*
2  * WLDAP32 - LDAP support for Wine
3  *
4  * Copyright 2005 Hans Leidekker
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "wine/port.h"
24 #include "wine/debug.h"
25
26 #include <stdarg.h>
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
31
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_SUCCESS        0x00
36 #define LDAP_NOT_SUPPORTED  0x5c
37 #endif
38
39 #include "winldap_private.h"
40 #include "wldap32.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43
44 ULONG WLDAP32_ldap_count_values_len( struct WLDAP32_berval **vals )
45 {
46     ULONG ret = LDAP_NOT_SUPPORTED;
47 #ifdef HAVE_LDAP
48
49     TRACE( "(%p)\n", vals );
50     ret = ldap_count_values_len( (struct berval **)vals );
51
52 #endif
53     return ret;
54 }
55
56 ULONG ldap_count_valuesA( PCHAR *vals )
57 {
58     ULONG ret = LDAP_NOT_SUPPORTED;
59 #ifdef HAVE_LDAP
60     WCHAR **valsW = NULL;
61
62     TRACE( "(%p)\n", vals );
63
64     if (vals) {
65         valsW = strarrayAtoW( vals );
66         if (!valsW) return WLDAP32_LDAP_NO_MEMORY;
67     }
68
69     ret = ldap_count_valuesW( valsW );
70     strarrayfreeW( valsW );
71
72 #endif
73     return ret;
74 }
75
76 ULONG ldap_count_valuesW( PWCHAR *vals )
77 {
78     ULONG ret = LDAP_NOT_SUPPORTED;
79 #ifdef HAVE_LDAP
80     char **valsU = NULL;
81
82     TRACE( "(%p)\n", vals );
83
84     if (vals) {
85         valsU = strarrayWtoU( vals );
86         if (!valsU) return WLDAP32_LDAP_NO_MEMORY;
87     }
88
89     ret = ldap_count_values( valsU );
90     strarrayfreeU( valsU );
91
92 #endif
93     return ret;
94 }
95
96 PCHAR *ldap_get_valuesA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PCHAR attr )
97 {
98     PCHAR *ret = NULL;
99 #ifdef HAVE_LDAP
100     WCHAR *attrW = NULL, **retW;
101
102     TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_a(attr) );
103
104     if (!ld || !entry || !attr) return NULL;
105
106     attrW = strAtoW( attr );
107     if (!attrW) return NULL;
108
109     retW = ldap_get_valuesW( ld, entry, attrW );
110
111     ret = strarrayWtoA( retW );
112     ldap_value_freeW( retW );
113     strfreeW( attrW );
114
115 #endif
116     return ret;
117 }
118
119 PWCHAR *ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PWCHAR attr )
120 {
121     PWCHAR *ret = NULL;
122 #ifdef HAVE_LDAP
123     char *attrU = NULL, **retU;
124
125     TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
126
127     if (!ld || !entry || !attr) return NULL;
128
129     attrU = strWtoU( attr );
130     if (!attrU) return NULL;
131
132     retU = ldap_get_values( ld, entry, attrU );
133
134     ret = strarrayUtoW( retU );
135     ldap_value_free( retU );
136     strfreeU( attrU );
137
138 #endif
139     return ret;
140 }
141
142 struct WLDAP32_berval **ldap_get_values_lenA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
143     PCHAR attr )
144 {
145 #ifdef HAVE_LDAP
146     WCHAR *attrW = NULL;
147     struct WLDAP32_berval **ret;
148
149     TRACE( "(%p, %p, %s)\n", ld, message, debugstr_a(attr) );
150
151     if (!ld || !message || !attr) return NULL;
152
153     attrW = strAtoW( attr );
154     if (!attrW) return NULL;
155
156     ret = ldap_get_values_lenW( ld, message, attrW );
157
158     strfreeW( attrW );
159     return ret;
160
161 #endif
162     return NULL;
163 }
164
165 struct WLDAP32_berval **ldap_get_values_lenW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
166     PWCHAR attr )
167 {
168 #ifdef HAVE_LDAP
169     char *attrU = NULL;
170     struct berval **ret;
171
172     TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
173
174     if (!ld || !message || !attr) return NULL;
175
176     attrU = strWtoU( attr );
177     if (!attrU) return NULL;
178
179     ret = ldap_get_values_len( ld, message, attrU );
180
181     strfreeU( attrU );
182     return (struct WLDAP32_berval **)ret;
183
184 #endif
185     return NULL;
186 }
187
188 ULONG WLDAP32_ldap_value_free_len( struct WLDAP32_berval **vals )
189 {
190 #ifdef HAVE_LDAP
191
192     TRACE( "(%p)\n", vals );
193     ldap_value_free_len( (struct berval **)vals );
194
195 #endif
196     return LDAP_SUCCESS;
197 }
198
199 ULONG ldap_value_freeA( PCHAR *vals )
200 {
201     TRACE( "(%p)\n", vals );
202
203     strarrayfreeA( vals );
204     return LDAP_SUCCESS;
205 }
206
207 ULONG ldap_value_freeW( PWCHAR *vals )
208 {
209     TRACE( "(%p)\n", vals );
210
211     strarrayfreeW( vals );
212     return LDAP_SUCCESS;
213 }