Specify 64-bit integers as double instead of long long in spec files
[wine/testsucceed.git] / dlls / wldap32 / value.c
blob0159bc3e131206b16509464f4003cf77b78b74f2
1 /*
2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
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.
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.
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
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
37 #endif
39 #include "winldap_private.h"
40 #include "wldap32.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 ULONG WLDAP32_ldap_count_values_len( struct WLDAP32_berval **vals )
46 ULONG ret = LDAP_NOT_SUPPORTED;
47 #ifdef HAVE_LDAP
49 TRACE( "(%p)\n", vals );
50 ret = ldap_count_values_len( (struct berval **)vals );
52 #endif
53 return ret;
56 ULONG ldap_count_valuesA( PCHAR *vals )
58 ULONG ret = LDAP_NOT_SUPPORTED;
59 #ifdef HAVE_LDAP
60 WCHAR **valsW = NULL;
62 TRACE( "(%p)\n", vals );
64 if (vals) {
65 valsW = strarrayAtoW( vals );
66 if (!valsW) return WLDAP32_LDAP_NO_MEMORY;
69 ret = ldap_count_valuesW( valsW );
70 strarrayfreeW( valsW );
72 #endif
73 return ret;
76 ULONG ldap_count_valuesW( PWCHAR *vals )
78 ULONG ret = LDAP_NOT_SUPPORTED;
79 #ifdef HAVE_LDAP
80 char **valsU = NULL;
82 TRACE( "(%p)\n", vals );
84 if (vals) {
85 valsU = strarrayWtoU( vals );
86 if (!valsU) return WLDAP32_LDAP_NO_MEMORY;
89 ret = ldap_count_values( valsU );
90 strarrayfreeU( valsU );
92 #endif
93 return ret;
96 PCHAR *ldap_get_valuesA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PCHAR attr )
98 PCHAR *ret = NULL;
99 #ifdef HAVE_LDAP
100 WCHAR *attrW = NULL, **retW;
102 TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_a(attr) );
104 if (!ld || !entry || !attr) return NULL;
106 attrW = strAtoW( attr );
107 if (!attrW) return NULL;
109 retW = ldap_get_valuesW( ld, entry, attrW );
111 ret = strarrayWtoA( retW );
112 ldap_value_freeW( retW );
113 strfreeW( attrW );
115 #endif
116 return ret;
119 PWCHAR *ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PWCHAR attr )
121 PWCHAR *ret = NULL;
122 #ifdef HAVE_LDAP
123 char *attrU = NULL, **retU;
125 TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
127 if (!ld || !entry || !attr) return NULL;
129 attrU = strWtoU( attr );
130 if (!attrU) return NULL;
132 retU = ldap_get_values( ld, entry, attrU );
134 ret = strarrayUtoW( retU );
135 ldap_value_free( retU );
136 strfreeU( attrU );
138 #endif
139 return ret;
142 struct WLDAP32_berval **ldap_get_values_lenA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
143 PCHAR attr )
145 #ifdef HAVE_LDAP
146 WCHAR *attrW = NULL;
147 struct WLDAP32_berval **ret;
149 TRACE( "(%p, %p, %s)\n", ld, message, debugstr_a(attr) );
151 if (!ld || !message || !attr) return NULL;
153 attrW = strAtoW( attr );
154 if (!attrW) return NULL;
156 ret = ldap_get_values_lenW( ld, message, attrW );
158 strfreeW( attrW );
159 return ret;
161 #endif
162 return NULL;
165 struct WLDAP32_berval **ldap_get_values_lenW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
166 PWCHAR attr )
168 #ifdef HAVE_LDAP
169 char *attrU = NULL;
170 struct berval **ret;
172 TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
174 if (!ld || !message || !attr) return NULL;
176 attrU = strWtoU( attr );
177 if (!attrU) return NULL;
179 ret = ldap_get_values_len( ld, message, attrU );
181 strfreeU( attrU );
182 return (struct WLDAP32_berval **)ret;
184 #endif
185 return NULL;
188 ULONG WLDAP32_ldap_value_free_len( struct WLDAP32_berval **vals )
190 #ifdef HAVE_LDAP
192 TRACE( "(%p)\n", vals );
193 ldap_value_free_len( (struct berval **)vals );
195 #endif
196 return LDAP_SUCCESS;
199 ULONG ldap_value_freeA( PCHAR *vals )
201 TRACE( "(%p)\n", vals );
203 strarrayfreeA( vals );
204 return LDAP_SUCCESS;
207 ULONG ldap_value_freeW( PWCHAR *vals )
209 TRACE( "(%p)\n", vals );
211 strarrayfreeW( vals );
212 return LDAP_SUCCESS;