Implement ldap_{get,set}_option{A,W}.
[wine] / dlls / wldap32 / wldap32.h
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 /* A set of helper functions to convert LDAP data structures
22  * to and from ansi (A), wide character (W) and utf8 (U) encodings.
23  */
24
25 static inline LPWSTR strAtoW( LPCSTR str )
26 {
27     LPWSTR ret = NULL;
28     if (str)
29     {
30         DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
31         if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
32             MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
33     }
34     return ret;
35 }
36
37 static inline LPSTR strWtoA( LPCWSTR str )
38 {
39     LPSTR ret = NULL;
40     if (str)
41     {
42         DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
43         if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
44             WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
45     }
46     return ret;
47 }
48
49 static inline char *strWtoU( LPCWSTR str )
50 {
51     LPSTR ret = NULL;
52     if (str)
53     {
54         DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
55         if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
56             WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
57     }
58     return ret;
59 }
60
61 static inline LPWSTR strUtoW( char *str )
62 {
63     LPWSTR ret = NULL;
64     if (str)
65     {
66         DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
67         if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
68             MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
69     }
70     return ret;
71 }
72
73 static inline void strfreeA( LPSTR str )
74 {
75     HeapFree( GetProcessHeap(), 0, str );
76 }
77
78 static inline void strfreeW( LPWSTR str )
79 {
80     HeapFree( GetProcessHeap(), 0, str );
81 }
82
83 static inline void strfreeU( char *str )
84 {
85     HeapFree( GetProcessHeap(), 0, str );
86 }
87
88 static inline DWORD strarraylenA( LPSTR *strarray )
89 {
90     LPSTR *p = strarray;
91     while (*p) p++;
92     return p - strarray;
93 }
94
95 static inline DWORD strarraylenW( LPWSTR *strarray )
96 {
97     LPWSTR *p = strarray;
98     while (*p) p++;
99     return p - strarray;
100 }
101
102 static inline DWORD strarraylenU( char **strarray )
103 {
104     char **p = strarray;
105     while (*p) p++;
106     return p - strarray;
107 }
108
109 static inline LPWSTR *strarrayAtoW( LPSTR *strarray )
110 {
111     LPWSTR *strarrayW = NULL;
112     DWORD size;
113
114     if (strarray)
115     {
116         size  = sizeof(WCHAR*) * (strarraylenA( strarray ) + 1);
117         strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
118
119         if (strarrayW)
120         {
121             LPSTR *p = strarray;
122             LPWSTR *q = strarrayW;
123
124             while (*p) *q++ = strAtoW( *p++ );
125             *q = NULL;
126         }
127     }
128     return strarrayW;
129 }
130
131 static inline LPSTR *strarrayWtoA( LPWSTR *strarray )
132 {
133     LPSTR *strarrayA = NULL;
134     DWORD size;
135
136     if (strarray)
137     {
138         size = sizeof(LPSTR) * (strarraylenW( strarray ) + 1);
139         strarrayA = HeapAlloc( GetProcessHeap(), 0, size );
140
141         if (strarrayA)
142         {
143             LPWSTR *p = strarray;
144             LPSTR *q = strarrayA;
145
146             while (*p) *q++ = strWtoA( *p++ );
147             *q = NULL;
148         }
149     }
150     return strarrayA;
151 }
152
153 static inline char **strarrayWtoU( LPWSTR *strarray )
154 {
155     char **strarrayU = NULL;
156     DWORD size;
157
158     if (strarray)
159     {
160         size = sizeof(char*) * (strarraylenW( strarray ) + 1);
161         strarrayU = HeapAlloc( GetProcessHeap(), 0, size );
162
163         if (strarrayU)
164         {
165             LPWSTR *p = strarray;
166             char **q = strarrayU;
167
168             while (*p) *q++ = strWtoU( *p++ );
169             *q = NULL;
170         }
171     }
172     return strarrayU;
173 }
174
175 static inline LPWSTR *strarrayUtoW( char **strarray )
176 {
177     LPWSTR *strarrayW = NULL;
178     DWORD size;
179
180     if (strarray)
181     {
182         size = sizeof(WCHAR*) * (strarraylenU( strarray ) + 1);
183         strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
184
185         if (strarrayW)
186         {
187             char **p = strarray;
188             LPWSTR *q = strarrayW;
189
190             while (*p) *q++ = strUtoW( *p++ );
191             *q = NULL;
192         }
193     }
194     return strarrayW;
195 }
196
197 static inline void strarrayfreeA( LPSTR *strarray )
198 {
199     if (strarray)
200     {
201         LPSTR *p = strarray;
202         while (*p) strfreeA( *p++ );
203         HeapFree( GetProcessHeap(), 0, strarray );
204     }
205 }
206
207 static inline void strarrayfreeW( LPWSTR *strarray )
208 {
209     if (strarray)
210     {
211         LPWSTR *p = strarray;
212         while (*p) strfreeW( *p++ );
213         HeapFree( GetProcessHeap(), 0, strarray );
214     }
215 }
216
217 static inline void strarrayfreeU( char **strarray )
218 {
219     if (strarray)
220     {
221         char **p = strarray;
222         while (*p) strfreeU( *p++ );
223         HeapFree( GetProcessHeap(), 0, strarray );
224     }
225 }
226
227 #ifdef HAVE_LDAP
228
229 static inline LDAPControlW *controlAtoW( LDAPControlA *control )
230 {
231     LDAPControlW *controlW;
232
233     controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
234     if (controlW)
235     {
236         memcpy( controlW, control, sizeof(LDAPControlW) );
237         controlW->ldctl_oid = strAtoW( control->ldctl_oid );
238     }
239     return controlW;
240 }
241
242 static inline LDAPControlA *controlWtoA( LDAPControlW *control )
243 {
244     LDAPControlA *controlA;
245
246     controlA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControl) );
247     if (controlA)
248     {
249         memcpy( controlA, control, sizeof(LDAPControlA) );
250         controlA->ldctl_oid = strWtoA( control->ldctl_oid );
251     }
252     return controlA;
253 }
254
255 static inline LDAPControl *controlWtoU( LDAPControlW *control )
256 {
257     LDAPControl *controlU;
258
259     controlU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControl) );
260     if (controlU)
261     {
262         memcpy( controlU, control, sizeof(LDAPControl) );
263         controlU->ldctl_oid = strWtoU( control->ldctl_oid );
264     }
265     return controlU;
266 }
267
268 static inline LDAPControlW *controlUtoW( LDAPControl *control )
269 {
270     LDAPControlW *controlW;
271
272     controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
273     if (controlW)
274     {
275         memcpy( controlW, control, sizeof(LDAPControlW) );
276         controlW->ldctl_oid = strUtoW( control->ldctl_oid );
277     }
278     return controlW;
279 }
280
281 static inline void controlfreeA( LDAPControlA *control )
282 {
283     if (control)
284     {
285         strfreeA( control->ldctl_oid );
286         HeapFree( GetProcessHeap(), 0, control );
287     }
288 }
289
290 static inline void controlfreeW( LDAPControlW *control )
291 {
292     if (control)
293     {
294         strfreeW( control->ldctl_oid );
295         HeapFree( GetProcessHeap(), 0, control );
296     }
297 }
298
299 static inline void controlfreeU( LDAPControl *control )
300 {
301     if (control)
302     {
303         strfreeU( control->ldctl_oid );
304         HeapFree( GetProcessHeap(), 0, control );
305     }
306 }
307
308 static inline DWORD controlarraylenA( LDAPControlA **controlarray )
309 {
310     LDAPControlA **p = controlarray;
311     while (*p) p++;
312     return p - controlarray;
313 }
314
315 static inline DWORD controlarraylenW( LDAPControlW **controlarray )
316 {
317     LDAPControlW **p = controlarray;
318     while (*p) p++;
319     return p - controlarray;
320 }
321
322 static inline DWORD controlarraylenU( LDAPControl **controlarray )
323 {
324     LDAPControl **p = controlarray;
325     while (*p) p++;
326     return p - controlarray;
327 }
328
329 static inline LDAPControlW **controlarrayAtoW( LDAPControlA **controlarray )
330 {
331     LDAPControlW **controlarrayW = NULL;
332     DWORD size;
333
334     if (controlarray)
335     {
336         size = sizeof(LDAPControlW*) * (controlarraylenA( controlarray ) + 1);
337         controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
338
339         if (controlarrayW)
340         {
341             LDAPControlA **p = controlarray;
342             LDAPControlW **q = controlarrayW;
343
344             while (*p) *q++ = controlAtoW( *p++ );
345             *q = NULL;
346         }
347     }
348     return controlarrayW;
349 }
350
351 static inline LDAPControlA **controlarrayWtoA( LDAPControlW **controlarray )
352 {
353     LDAPControlA **controlarrayA = NULL;
354     DWORD size;
355
356     if (controlarray)
357     {
358         size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
359         controlarrayA = HeapAlloc( GetProcessHeap(), 0, size );
360
361         if (controlarrayA)
362         {
363             LDAPControlW **p = controlarray;
364             LDAPControlA **q = controlarrayA;
365
366             while (*p) *q++ = controlWtoA( *p++ );
367             *q = NULL;
368         }
369     }
370     return controlarrayA;
371 }
372
373 static inline LDAPControl **controlarrayWtoU( LDAPControlW **controlarray )
374 {
375     LDAPControl **controlarrayU = NULL;
376     DWORD size;
377
378     if (controlarray)
379     {
380         size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
381         controlarrayU = HeapAlloc( GetProcessHeap(), 0, size );
382
383         if (controlarrayU)
384         {
385             LDAPControlW **p = controlarray;
386             LDAPControl **q = controlarrayU;
387
388             while (*p) *q++ = controlWtoU( *p++ );
389             *q = NULL;
390         }
391     }
392     return controlarrayU;
393 }
394
395 static inline LDAPControlW **controlarrayUtoW( LDAPControl **controlarray )
396 {
397     LDAPControlW **controlarrayW = NULL;
398     DWORD size;
399
400     if (controlarray)
401     {
402         size = sizeof(LDAPControlW*) * (controlarraylenU( controlarray ) + 1);
403         controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
404
405         if (controlarrayW)
406         {
407             LDAPControl **p = controlarray;
408             LDAPControlW **q = controlarrayW;
409
410             while (*p) *q++ = controlUtoW( *p++ );
411             *q = NULL;
412         }
413     }
414     return controlarrayW;
415 }
416
417 static inline void controlarrayfreeA( LDAPControlA **controlarray )
418 {
419     if (controlarray)
420     {
421         LDAPControlA **p = controlarray;
422         while (*p) controlfreeA( *p++ );
423         HeapFree( GetProcessHeap(), 0, controlarray );
424     }
425 }
426
427 static inline void controlarrayfreeW( LDAPControlW **controlarray )
428 {
429     if (controlarray)
430     {
431         LDAPControlW **p = controlarray;
432         while (*p) controlfreeW( *p++ );
433         HeapFree( GetProcessHeap(), 0, controlarray );
434     }
435 }
436
437 static inline void controlarrayfreeU( LDAPControl **controlarray )
438 {
439     if (controlarray)
440     {
441         LDAPControl **p = controlarray;
442         while (*p) controlfreeU( *p++ );
443         HeapFree( GetProcessHeap(), 0, controlarray );
444     }
445 }
446
447 static inline LDAPSortKeyW *sortkeyAtoW( LDAPSortKeyA *sortkey )
448 {
449     LDAPSortKeyW *sortkeyW;
450
451     sortkeyW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyW) );
452     if (sortkeyW)
453     {
454         sortkeyW->sk_attrtype = strAtoW( sortkey->sk_attrtype );
455         sortkeyW->sk_matchruleoid = strAtoW( sortkey->sk_matchruleoid );
456         sortkeyW->sk_reverseorder = sortkey->sk_reverseorder;
457     }
458     return sortkeyW;
459 }
460
461 static inline LDAPSortKeyA *sortkeyWtoA( LDAPSortKeyW *sortkey )
462 {
463     LDAPSortKeyA *sortkeyA;
464
465     sortkeyA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyA) );
466     if (sortkeyA)
467     {
468         sortkeyA->sk_attrtype = strWtoA( sortkey->sk_attrtype );
469         sortkeyA->sk_matchruleoid = strWtoA( sortkey->sk_matchruleoid );
470         sortkeyA->sk_reverseorder = sortkey->sk_reverseorder;
471     }
472     return sortkeyA;
473 }
474
475 static inline LDAPSortKey *sortkeyWtoU( LDAPSortKeyW *sortkey )
476 {
477     LDAPSortKey *sortkeyU;
478
479     sortkeyU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKey) );
480     if (sortkeyU)
481     {
482         sortkeyU->attributeType = strWtoU( sortkey->sk_attrtype );
483         sortkeyU->orderingRule = strWtoU( sortkey->sk_matchruleoid );
484         sortkeyU->reverseOrder = sortkey->sk_reverseorder;
485     }
486     return sortkeyU;
487 }
488
489 static inline void sortkeyfreeA( LDAPSortKeyA *sortkey )
490 {
491     if (sortkey)
492     {
493         strfreeA( sortkey->sk_attrtype );
494         strfreeA( sortkey->sk_matchruleoid );
495         HeapFree( GetProcessHeap(), 0, sortkey );
496     }
497 }
498
499 static inline void sortkeyfreeW( LDAPSortKeyW *sortkey )
500 {
501     if (sortkey)
502     {
503         strfreeW( sortkey->sk_attrtype );
504         strfreeW( sortkey->sk_matchruleoid );
505         HeapFree( GetProcessHeap(), 0, sortkey );
506     }
507 }
508
509 static inline void sortkeyfreeU( LDAPSortKey *sortkey )
510 {
511     if (sortkey)
512     {
513         strfreeU( sortkey->attributeType );
514         strfreeU( sortkey->orderingRule );
515         HeapFree( GetProcessHeap(), 0, sortkey );
516     }
517 }
518
519 static inline DWORD sortkeyarraylenA( LDAPSortKeyA **sortkeyarray )
520 {
521     LDAPSortKeyA **p = sortkeyarray;
522     while (*p) p++;
523     return p - sortkeyarray;
524 }
525
526 static inline DWORD sortkeyarraylenW( LDAPSortKeyW **sortkeyarray )
527 {
528     LDAPSortKeyW **p = sortkeyarray;
529     while (*p) p++;
530     return p - sortkeyarray;
531 }
532
533 static inline LDAPSortKeyW **sortkeyarrayAtoW( LDAPSortKeyA **sortkeyarray )
534 {
535     LDAPSortKeyW **sortkeyarrayW = NULL;
536     DWORD size;
537
538     if (sortkeyarray)
539     {
540         size = sizeof(LDAPSortKeyW*) * (sortkeyarraylenA( sortkeyarray ) + 1);
541         sortkeyarrayW = HeapAlloc( GetProcessHeap(), 0, size );
542
543         if (sortkeyarrayW)
544         {
545             LDAPSortKeyA **p = sortkeyarray;
546             LDAPSortKeyW **q = sortkeyarrayW;
547
548             while (*p) *q++ = sortkeyAtoW( *p++ );
549             *q = NULL;
550         }
551     }
552     return sortkeyarrayW;
553 }
554
555 static inline LDAPSortKey **sortkeyarrayWtoU( LDAPSortKeyW **sortkeyarray )
556 {
557     LDAPSortKey **sortkeyarrayU = NULL;
558     DWORD size;
559
560     if (sortkeyarray)
561     {
562         size = sizeof(LDAPSortKey*) * (sortkeyarraylenW( sortkeyarray ) + 1);
563         sortkeyarrayU = HeapAlloc( GetProcessHeap(), 0, size );
564
565         if (sortkeyarrayU)
566         {
567             LDAPSortKeyW **p = sortkeyarray;
568             LDAPSortKey **q = sortkeyarrayU;
569
570             while (*p) *q++ = sortkeyWtoU( *p++ );
571             *q = NULL;
572         }
573     }
574     return sortkeyarrayU;
575 }
576
577 static inline void sortkeyarrayfreeW( LDAPSortKeyW **sortkeyarray )
578 {
579     if (sortkeyarray)
580     {
581         LDAPSortKeyW **p = sortkeyarray;
582         while (*p) sortkeyfreeW( *p++ );
583         HeapFree( GetProcessHeap(), 0, sortkeyarray );
584     }
585 }
586
587 static inline void sortkeyarrayfreeU( LDAPSortKey **sortkeyarray )
588 {
589     if (sortkeyarray)
590     {
591         LDAPSortKey **p = sortkeyarray;
592         while (*p) sortkeyfreeU( *p++ );
593         HeapFree( GetProcessHeap(), 0, sortkeyarray );
594     }
595 }
596
597 static inline LDAPAPIInfoW *infoAtoW( LDAPAPIInfoA *info )
598 {
599     LDAPAPIInfoW *infoW;
600
601     infoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoW) );
602     if (infoW)
603     {
604         memcpy( infoW, info, sizeof(LDAPAPIInfoA) );
605         infoW->ldapai_extensions = strarrayAtoW( info->ldapai_extensions );
606         infoW->ldapai_vendor_name = strAtoW( info->ldapai_vendor_name );
607     }
608     return infoW;
609 }
610
611 static inline LDAPAPIInfoA *infoWtoA( LDAPAPIInfoW *info )
612 {
613     LDAPAPIInfoA *infoA;
614
615     infoA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoA) );
616     if (infoA)
617     {
618         memcpy( infoA, info, sizeof(LDAPAPIInfoW) );
619         infoA->ldapai_extensions = strarrayWtoA( info->ldapai_extensions );
620         infoA->ldapai_vendor_name = strWtoA( info->ldapai_vendor_name );
621     }
622     return infoA;
623 }
624
625 static inline LDAPAPIInfoW *infoUtoW( LDAPAPIInfo *info )
626 {
627     LDAPAPIInfoW *infoW;
628
629     infoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoW) );
630     if (infoW)
631     {
632         memcpy( infoW, info, sizeof(LDAPAPIInfo) );
633         infoW->ldapai_extensions = strarrayUtoW( info->ldapai_extensions );
634         infoW->ldapai_vendor_name = strUtoW( info->ldapai_vendor_name );
635     }
636     return infoW;
637 }
638
639 static inline LDAPAPIInfo *infoWtoU( LDAPAPIInfoW *info )
640 {
641     LDAPAPIInfo *infoU;
642
643     infoU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfo) );
644     if (infoU)
645     {
646         memcpy( infoU, info, sizeof(LDAPAPIInfoW) );
647         infoU->ldapai_extensions = strarrayWtoU( info->ldapai_extensions );
648         infoU->ldapai_vendor_name = strWtoU( info->ldapai_vendor_name );
649     }
650     return infoU;
651 }
652
653 static inline void infofreeW( LDAPAPIInfoW *info )
654 {
655     if (info)
656     {
657         strarrayfreeW( info->ldapai_extensions );
658         strfreeW( info->ldapai_vendor_name );
659         HeapFree( GetProcessHeap(), 0, info );
660     }
661 }
662
663 static inline void infofreeU( LDAPAPIInfo *info )
664 {
665     if (info)
666     {
667         strarrayfreeU( info->ldapai_extensions );
668         strfreeU( info->ldapai_vendor_name );
669         HeapFree( GetProcessHeap(), 0, info );
670     }
671 }
672
673 static inline LDAPAPIFeatureInfoW *featureinfoAtoW( LDAPAPIFeatureInfoA *featureinfo )
674 {
675     LDAPAPIFeatureInfoW *featureinfoW;
676
677     featureinfoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoW) );
678     if (featureinfoW)
679     {
680         featureinfoW->ldapaif_info_version = featureinfo->ldapaif_info_version;
681         featureinfoW->ldapaif_name = strAtoW( featureinfo->ldapaif_name );
682         featureinfoW->ldapaif_version = featureinfo->ldapaif_version;
683     }
684     return featureinfoW;
685 }
686
687 static inline LDAPAPIFeatureInfoA *featureinfoWtoA( LDAPAPIFeatureInfoW *featureinfo )
688 {
689     LDAPAPIFeatureInfoA *featureinfoA;
690
691     featureinfoA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoA) );
692     if (featureinfoA)
693     {
694         featureinfoA->ldapaif_info_version = featureinfo->ldapaif_info_version;
695         featureinfoA->ldapaif_name = strWtoA( featureinfo->ldapaif_name );
696         featureinfoA->ldapaif_version = featureinfo->ldapaif_version;
697     }
698     return featureinfoA;
699 }
700
701 static inline LDAPAPIFeatureInfoW *featureinfoUtoW( LDAPAPIFeatureInfo *featureinfo )
702 {
703     LDAPAPIFeatureInfoW *featureinfoW;
704
705     featureinfoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoW) );
706     if (featureinfoW)
707     {
708         featureinfoW->ldapaif_info_version = featureinfo->ldapaif_info_version;
709         featureinfoW->ldapaif_name = strUtoW( featureinfo->ldapaif_name );
710         featureinfoW->ldapaif_version = featureinfo->ldapaif_version;
711     }
712     return featureinfoW;
713 }
714
715 static inline LDAPAPIFeatureInfo *featureinfoWtoU( LDAPAPIFeatureInfoW *featureinfo )
716 {
717     LDAPAPIFeatureInfo *featureinfoU;
718
719     featureinfoU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfo) );
720     if (featureinfoU)
721     {
722         featureinfoU->ldapaif_info_version = featureinfo->ldapaif_info_version;
723         featureinfoU->ldapaif_name = strWtoU( featureinfo->ldapaif_name );
724         featureinfoU->ldapaif_version = featureinfo->ldapaif_version;
725     }
726     return featureinfoU;
727 }
728
729 static inline void featureinfofreeW( LDAPAPIFeatureInfoW *featureinfo )
730 {
731     if (featureinfo)
732     {
733         strfreeW( featureinfo->ldapaif_name );
734         HeapFree( GetProcessHeap(), 0, featureinfo );
735     }
736 }
737
738 static inline void featureinfofreeU( LDAPAPIFeatureInfo *featureinfo )
739 {
740     if (featureinfo)
741     {
742         strfreeU( featureinfo->ldapaif_name );
743         HeapFree( GetProcessHeap(), 0, featureinfo );
744     }
745 }
746
747 #endif /* HAVE_LDAP */