localspl: Add unixname port extension.
[wine.git] / dlls / wldap32 / add.c
blob6fd0f82cf333ea9f575481cf544962ac80813342
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winnls.h"
26 #include "wine/debug.h"
27 #include "winldap_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
31 /***********************************************************************
32 * ldap_addA (WLDAP32.@)
34 ULONG CDECL ldap_addA( LDAP *ld, char *dn, LDAPModA **attrs )
36 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
37 WCHAR *dnW = NULL;
38 LDAPModW **attrsW = NULL;
40 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
42 if (!ld) return ~0u;
44 if (dn && !(dnW = strAtoW( dn ))) goto exit;
45 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
47 ret = ldap_addW( ld, dnW, attrsW );
49 exit:
50 free( dnW );
51 modarrayfreeW( attrsW );
52 return ret;
55 /***********************************************************************
56 * ldap_addW (WLDAP32.@)
58 ULONG CDECL ldap_addW( LDAP *ld, WCHAR *dn, LDAPModW **attrs )
60 ULONG ret, msg;
62 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
64 ret = ldap_add_extW( ld, dn, attrs, NULL, NULL, &msg );
65 if (ret == WLDAP32_LDAP_SUCCESS) return msg;
66 return ~0u;
69 /***********************************************************************
70 * ldap_add_extA (WLDAP32.@)
72 ULONG CDECL ldap_add_extA( LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **serverctrls,
73 LDAPControlA **clientctrls, ULONG *message )
75 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
76 WCHAR *dnW = NULL;
77 LDAPModW **attrsW = NULL;
78 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
80 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), attrs, serverctrls, clientctrls, message );
82 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
84 if (dn && !(dnW = strAtoW( dn ))) goto exit;
85 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
86 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
87 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
89 ret = ldap_add_extW( ld, dnW, attrsW, serverctrlsW, clientctrlsW, message );
91 exit:
92 free( dnW );
93 modarrayfreeW( attrsW );
94 controlarrayfreeW( serverctrlsW );
95 controlarrayfreeW( clientctrlsW );
96 return ret;
99 /***********************************************************************
100 * ldap_add_extW (WLDAP32.@)
102 ULONG CDECL ldap_add_extW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW **serverctrls,
103 LDAPControlW **clientctrls, ULONG *message )
105 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
106 char *dnU = NULL;
107 LDAPMod **attrsU = NULL;
108 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
110 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), attrs, serverctrls, clientctrls, message );
112 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
114 if (dn && !(dnU = strWtoU( dn ))) goto exit;
115 if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
116 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
117 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
118 else
120 ret = map_error( ldap_add_ext( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU, (int *)message ) );
123 exit:
124 free( dnU );
125 modarrayfreeU( attrsU );
126 controlarrayfreeU( serverctrlsU );
127 controlarrayfreeU( clientctrlsU );
128 return ret;
131 /***********************************************************************
132 * ldap_add_ext_sA (WLDAP32.@)
134 ULONG CDECL ldap_add_ext_sA( LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **serverctrls,
135 LDAPControlA **clientctrls )
137 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
138 WCHAR *dnW = NULL;
139 LDAPModW **attrsW = NULL;
140 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
142 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), attrs, serverctrls, clientctrls );
144 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
146 if (dn && !(dnW = strAtoW( dn ))) goto exit;
147 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
148 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
149 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
151 ret = ldap_add_ext_sW( ld, dnW, attrsW, serverctrlsW, clientctrlsW );
153 exit:
154 free( dnW );
155 modarrayfreeW( attrsW );
156 controlarrayfreeW( serverctrlsW );
157 controlarrayfreeW( clientctrlsW );
158 return ret;
161 /***********************************************************************
162 * ldap_add_ext_sW (WLDAP32.@)
164 ULONG CDECL ldap_add_ext_sW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW **serverctrls,
165 LDAPControlW **clientctrls )
167 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
168 char *dnU = NULL;
169 LDAPMod **attrsU = NULL;
170 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
172 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), attrs, serverctrls, clientctrls );
174 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
176 if (dn && !(dnU = strWtoU( dn ))) goto exit;
177 if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
178 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
179 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
180 else
182 ret = map_error( ldap_add_ext_s( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU ) );
185 exit:
186 free( dnU );
187 modarrayfreeU( attrsU );
188 controlarrayfreeU( serverctrlsU );
189 controlarrayfreeU( clientctrlsU );
190 return ret;
193 /***********************************************************************
194 * ldap_add_sA (WLDAP32.@)
196 ULONG CDECL ldap_add_sA( LDAP *ld, char *dn, LDAPModA **attrs )
198 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
199 WCHAR *dnW = NULL;
200 LDAPModW **attrsW = NULL;
202 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
204 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
206 if (dn && !(dnW = strAtoW( dn ))) goto exit;
207 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
209 ret = ldap_add_sW( ld, dnW, attrsW );
211 exit:
212 free( dnW );
213 modarrayfreeW( attrsW );
214 return ret;
217 /***********************************************************************
218 * ldap_add_sW (WLDAP32.@)
220 ULONG CDECL ldap_add_sW( LDAP *ld, WCHAR *dn, LDAPModW **attrs )
222 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
223 return ldap_add_ext_sW( ld, dn, attrs, NULL, NULL );