windowscodecs: Silence fixme for IID_CMetaBitmapRenderTarget.
[wine.git] / dlls / wldap32 / dn.c
blobc2e523d68d6841e594feb1c40867e8b9f713c1e4
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_dn2ufnA (WLDAP32.@)
34 char * CDECL ldap_dn2ufnA( char *dn )
36 char *ret = NULL;
37 WCHAR *dnW, *retW;
39 TRACE( "(%s)\n", debugstr_a(dn) );
41 if (!(dnW = strAtoW( dn ))) return NULL;
42 if ((retW = ldap_dn2ufnW( dnW ))) ret = strWtoA( retW );
43 free( dnW );
44 ldap_memfreeW( retW );
45 return ret;
48 /***********************************************************************
49 * ldap_dn2ufnW (WLDAP32.@)
51 WCHAR * CDECL ldap_dn2ufnW( WCHAR *dn )
53 WCHAR *ret = NULL;
54 char *dnU, *retU;
56 TRACE( "(%s)\n", debugstr_w(dn) );
58 if (!(dnU = strWtoU( dn ))) return NULL;
59 if ((retU = ldap_dn2ufn( dnU ))) ret = strUtoW( retU );
60 free( dnU );
61 ldap_memfree( retU );
62 return ret;
65 /***********************************************************************
66 * ldap_explode_dnA (WLDAP32.@)
68 char ** CDECL ldap_explode_dnA( char *dn, ULONG notypes )
70 char **ret = NULL;
71 WCHAR *dnW, **retW;
73 TRACE( "(%s, %#lx)\n", debugstr_a(dn), notypes );
75 if (!(dnW = strAtoW( dn ))) return NULL;
76 if ((retW = ldap_explode_dnW( dnW, notypes ))) ret = strarrayWtoA( retW );
77 free( dnW );
78 ldap_value_freeW( retW );
79 return ret;
82 /***********************************************************************
83 * ldap_explode_dnW (WLDAP32.@)
85 WCHAR ** CDECL ldap_explode_dnW( WCHAR *dn, ULONG notypes )
87 WCHAR **ret = NULL;
88 char *dnU, **retU;
90 TRACE( "(%s, %#lx)\n", debugstr_w(dn), notypes );
92 if (!(dnU = strWtoU( dn ))) return NULL;
93 if ((retU = ldap_explode_dn( dnU, notypes ))) ret = strarrayUtoW( retU );
94 free( dnU );
95 ldap_memvfree( (void **)retU );
96 return ret;
99 /***********************************************************************
100 * ldap_get_dnA (WLDAP32.@)
102 char * CDECL ldap_get_dnA( LDAP *ld, LDAPMessage *entry )
104 char *ret = NULL;
105 WCHAR *retW;
107 TRACE( "(%p, %p)\n", ld, entry );
109 if (!ld || !entry) return NULL;
111 if ((retW = ldap_get_dnW( ld, entry ))) ret = strWtoA( retW );
112 ldap_memfreeW( retW );
113 return ret;
116 /***********************************************************************
117 * ldap_get_dnW (WLDAP32.@)
119 WCHAR * CDECL ldap_get_dnW( LDAP *ld, LDAPMessage *entry )
121 WCHAR *ret = NULL;
122 char *retU;
124 TRACE( "(%p, %p)\n", ld, entry );
126 if (ld && entry)
128 if ((retU = ldap_get_dn( CTX(ld), MSG(entry) ))) ret = strUtoW( retU );
129 ldap_memfree( retU );
131 return ret;
134 /***********************************************************************
135 * ldap_ufn2dnA (WLDAP32.@)
137 ULONG CDECL ldap_ufn2dnA( char *ufn, char **dn )
139 ULONG ret;
140 WCHAR *ufnW = NULL, *dnW = NULL;
142 TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
144 if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
146 *dn = NULL;
147 if (ufn && !(ufnW = strAtoW( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
149 ret = ldap_ufn2dnW( ufnW, &dnW );
150 if (dnW)
152 char *str;
153 if (!(str = strWtoA( dnW ))) ret = WLDAP32_LDAP_NO_MEMORY;
154 else *dn = str;
157 free( ufnW );
158 ldap_memfreeW( dnW );
159 return ret;
162 /***********************************************************************
163 * ldap_ufn2dnW (WLDAP32.@)
165 ULONG CDECL ldap_ufn2dnW( WCHAR *ufn, WCHAR **dn )
167 ULONG ret = WLDAP32_LDAP_SUCCESS;
168 char *ufnU = NULL;
170 TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
172 if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
174 *dn = NULL;
175 if (ufn)
177 WCHAR *str;
178 if (!(ufnU = strWtoU( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
180 /* FIXME: do more than just a copy */
181 if (!(str = strUtoW( ufnU ))) ret = WLDAP32_LDAP_NO_MEMORY;
182 else *dn = str;
185 free( ufnU );
186 return ret;