Moved mciavi32 to the top-level dlls directory.
[wine] / dlls / wldap32 / misc.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_abandon( WLDAP32_LDAP *ld, ULONG msgid )
45 {
46     ULONG ret = LDAP_NOT_SUPPORTED;
47 #ifdef HAVE_LDAP
48
49     TRACE( "(%p, 0x%08lx)\n", ld, msgid );
50
51     if (!ld) return ~0UL;
52     ret = ldap_abandon( ld, msgid );
53
54 #endif
55     return ret;
56 }
57
58 ULONG ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
59 {
60     ULONG ret;
61     WCHAR *filterW = NULL;
62
63     TRACE( "(%p, %s)\n", ld, debugstr_a(filter) );
64
65     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
66
67     if (filter) {
68         filterW = strAtoW( filter );
69         if (!filterW) return WLDAP32_LDAP_NO_MEMORY;
70     }
71
72     ret = ldap_check_filterW( ld, filterW );
73
74     strfreeW( filterW );
75     return ret;
76 }
77
78 ULONG ldap_check_filterW( WLDAP32_LDAP *ld, PWCHAR filter )
79 {
80     TRACE( "(%p, %s)\n", ld, debugstr_w(filter) );
81
82     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
83     return LDAP_SUCCESS;
84 }
85
86 ULONG ldap_cleanup( HANDLE instance )
87 {
88     TRACE( "(%p)\n", instance );
89     return LDAP_SUCCESS;
90 }
91
92 WLDAP32_LDAP *ldap_conn_from_msg( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
93 {
94     TRACE( "(%p, %p)\n", ld, res );
95
96     if (!ld || !res) return NULL;
97     return ld; /* FIXME: not always correct */
98 }
99
100 void ldap_memfreeA( PCHAR block )
101 {
102     TRACE( "(%p)\n", block );
103     strfreeA( block );
104 }
105
106 void ldap_memfreeW( PWCHAR block )
107 {
108     TRACE( "(%p)\n", block );
109     strfreeW( block );
110 }
111
112 ULONG WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
113     struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
114 {
115     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
116 #ifdef HAVE_LDAP
117
118     TRACE( "(%p, 0x%08lx, 0x%08lx, %p, %p)\n", ld, msgid, all, timeout, res );
119
120     if (!ld || !res) return ~0UL;
121     ret = ldap_result( ld, msgid, all, (struct timeval *)timeout, res );
122
123 #endif
124     return ret;
125 }
126
127 ULONG ldap_value_freeA( PCHAR *vals )
128 {
129     TRACE( "(%p)\n", vals );
130
131     strarrayfreeA( vals );
132     return LDAP_SUCCESS;
133 }
134
135 ULONG ldap_value_freeW( PWCHAR *vals )
136 {
137     TRACE( "(%p)\n", vals );
138
139     strarrayfreeW( vals );
140     return LDAP_SUCCESS;
141 }
142
143 int LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
144 {
145     return WideCharToMultiByte( CP_UTF8, 0, src, srclen, dst, dstlen, NULL, NULL );
146 }
147
148 int LdapUTF8ToUnicode( LPCSTR src, int srclen, LPWSTR dst, int dstlen )
149 {
150     return MultiByteToWideChar( CP_UTF8, 0, src, srclen, dst, dstlen );
151 }