save old text color during a call of DrawCaptionTempW
[wine/kumbayo.git] / dlls / wldap32 / wldap32.h
blobb21f24e3d9ffc8387d3999daa2d127a4def76bba
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 /* A set of helper functions to convert LDAP data structures
22 * to and from ansi (A), wide character (W) and utf8 (U) encodings.
25 static inline char *strdupU( const char *src )
27 char *dst;
29 if (!src) return NULL;
30 dst = HeapAlloc( GetProcessHeap(), 0, (strlen( src ) + 1) * sizeof(char) );
31 if (dst)
32 strcpy( dst, src );
33 return dst;
36 static inline LPWSTR strAtoW( LPCSTR str )
38 LPWSTR ret = NULL;
39 if (str)
41 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
42 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
43 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
45 return ret;
48 static inline LPSTR strWtoA( LPCWSTR str )
50 LPSTR ret = NULL;
51 if (str)
53 DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
54 if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
55 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
57 return ret;
60 static inline char *strWtoU( LPCWSTR str )
62 LPSTR ret = NULL;
63 if (str)
65 DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
66 if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
67 WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
69 return ret;
72 static inline LPWSTR strUtoW( char *str )
74 LPWSTR ret = NULL;
75 if (str)
77 DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
78 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
79 MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
81 return ret;
84 static inline void strfreeA( LPSTR str )
86 HeapFree( GetProcessHeap(), 0, str );
89 static inline void strfreeW( LPWSTR str )
91 HeapFree( GetProcessHeap(), 0, str );
94 static inline void strfreeU( char *str )
96 HeapFree( GetProcessHeap(), 0, str );
99 static inline DWORD strarraylenA( LPSTR *strarray )
101 LPSTR *p = strarray;
102 while (*p) p++;
103 return p - strarray;
106 static inline DWORD strarraylenW( LPWSTR *strarray )
108 LPWSTR *p = strarray;
109 while (*p) p++;
110 return p - strarray;
113 static inline DWORD strarraylenU( char **strarray )
115 char **p = strarray;
116 while (*p) p++;
117 return p - strarray;
120 static inline LPWSTR *strarrayAtoW( LPSTR *strarray )
122 LPWSTR *strarrayW = NULL;
123 DWORD size;
125 if (strarray)
127 size = sizeof(WCHAR*) * (strarraylenA( strarray ) + 1);
128 strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
130 if (strarrayW)
132 LPSTR *p = strarray;
133 LPWSTR *q = strarrayW;
135 while (*p) *q++ = strAtoW( *p++ );
136 *q = NULL;
139 return strarrayW;
142 static inline LPSTR *strarrayWtoA( LPWSTR *strarray )
144 LPSTR *strarrayA = NULL;
145 DWORD size;
147 if (strarray)
149 size = sizeof(LPSTR) * (strarraylenW( strarray ) + 1);
150 strarrayA = HeapAlloc( GetProcessHeap(), 0, size );
152 if (strarrayA)
154 LPWSTR *p = strarray;
155 LPSTR *q = strarrayA;
157 while (*p) *q++ = strWtoA( *p++ );
158 *q = NULL;
161 return strarrayA;
164 static inline char **strarrayWtoU( LPWSTR *strarray )
166 char **strarrayU = NULL;
167 DWORD size;
169 if (strarray)
171 size = sizeof(char*) * (strarraylenW( strarray ) + 1);
172 strarrayU = HeapAlloc( GetProcessHeap(), 0, size );
174 if (strarrayU)
176 LPWSTR *p = strarray;
177 char **q = strarrayU;
179 while (*p) *q++ = strWtoU( *p++ );
180 *q = NULL;
183 return strarrayU;
186 static inline LPWSTR *strarrayUtoW( char **strarray )
188 LPWSTR *strarrayW = NULL;
189 DWORD size;
191 if (strarray)
193 size = sizeof(WCHAR*) * (strarraylenU( strarray ) + 1);
194 strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
196 if (strarrayW)
198 char **p = strarray;
199 LPWSTR *q = strarrayW;
201 while (*p) *q++ = strUtoW( *p++ );
202 *q = NULL;
205 return strarrayW;
208 static inline void strarrayfreeA( LPSTR *strarray )
210 if (strarray)
212 LPSTR *p = strarray;
213 while (*p) strfreeA( *p++ );
214 HeapFree( GetProcessHeap(), 0, strarray );
218 static inline void strarrayfreeW( LPWSTR *strarray )
220 if (strarray)
222 LPWSTR *p = strarray;
223 while (*p) strfreeW( *p++ );
224 HeapFree( GetProcessHeap(), 0, strarray );
228 static inline void strarrayfreeU( char **strarray )
230 if (strarray)
232 char **p = strarray;
233 while (*p) strfreeU( *p++ );
234 HeapFree( GetProcessHeap(), 0, strarray );
238 #ifdef HAVE_LDAP
240 static inline struct berval *bvdup( struct berval *bv )
242 struct berval *berval;
243 DWORD size = sizeof(struct berval) + bv->bv_len;
245 berval = HeapAlloc( GetProcessHeap(), 0, size );
246 if (berval)
248 char *val = (char *)berval + sizeof(struct berval);
250 berval->bv_len = bv->bv_len;
251 berval->bv_val = val;
252 memcpy( val, bv->bv_val, bv->bv_len );
254 return berval;
257 static inline DWORD bvarraylen( struct berval **bv )
259 struct berval **p = bv;
260 while (*p) p++;
261 return p - bv;
264 static inline struct berval **bvarraydup( struct berval **bv )
266 struct berval **berval = NULL;
267 DWORD size;
269 if (bv)
271 size = sizeof(struct berval *) * (bvarraylen( bv ) + 1);
272 berval = HeapAlloc( GetProcessHeap(), 0, size );
274 if (berval)
276 struct berval **p = bv;
277 struct berval **q = berval;
279 while (*p) *q++ = bvdup( *p++ );
280 *q = NULL;
283 return berval;
286 static inline void bvarrayfree( struct berval **bv )
288 struct berval **p = bv;
289 while (*p) HeapFree( GetProcessHeap(), 0, *p++ );
290 HeapFree( GetProcessHeap(), 0, bv );
293 static inline LDAPModW *modAtoW( LDAPModA *mod )
295 LDAPModW *modW;
297 modW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPModW) );
298 if (modW)
300 modW->mod_op = mod->mod_op;
301 modW->mod_type = strAtoW( mod->mod_type );
303 if (mod->mod_op & LDAP_MOD_BVALUES)
304 modW->mod_vals.modv_bvals = bvarraydup( mod->mod_vals.modv_bvals );
305 else
306 modW->mod_vals.modv_strvals = strarrayAtoW( mod->mod_vals.modv_strvals );
308 return modW;
311 static inline LDAPMod *modWtoU( LDAPModW *mod )
313 LDAPMod *modU;
315 modU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPMod) );
316 if (modU)
318 modU->mod_op = mod->mod_op;
319 modU->mod_type = strWtoU( mod->mod_type );
321 if (mod->mod_op & LDAP_MOD_BVALUES)
322 modU->mod_vals.modv_bvals = bvarraydup( mod->mod_vals.modv_bvals );
323 else
324 modU->mod_vals.modv_strvals = strarrayWtoU( mod->mod_vals.modv_strvals );
326 return modU;
329 static inline void modfreeW( LDAPModW *mod )
331 if (mod->mod_op & LDAP_MOD_BVALUES)
332 bvarrayfree( mod->mod_vals.modv_bvals );
333 else
334 strarrayfreeW( mod->mod_vals.modv_strvals );
335 HeapFree( GetProcessHeap(), 0, mod );
338 static inline void modfreeU( LDAPMod *mod )
340 if (mod->mod_op & LDAP_MOD_BVALUES)
341 bvarrayfree( mod->mod_vals.modv_bvals );
342 else
343 strarrayfreeU( mod->mod_vals.modv_strvals );
344 HeapFree( GetProcessHeap(), 0, mod );
347 static inline DWORD modarraylenA( LDAPModA **modarray )
349 LDAPModA **p = modarray;
350 while (*p) p++;
351 return p - modarray;
354 static inline DWORD modarraylenW( LDAPModW **modarray )
356 LDAPModW **p = modarray;
357 while (*p) p++;
358 return p - modarray;
361 static inline LDAPModW **modarrayAtoW( LDAPModA **modarray )
363 LDAPModW **modarrayW = NULL;
364 DWORD size;
366 if (modarray)
368 size = sizeof(LDAPModW*) * (modarraylenA( modarray ) + 1);
369 modarrayW = HeapAlloc( GetProcessHeap(), 0, size );
371 if (modarrayW)
373 LDAPModA **p = modarray;
374 LDAPModW **q = modarrayW;
376 while (*p) *q++ = modAtoW( *p++ );
377 *q = NULL;
380 return modarrayW;
383 static inline LDAPMod **modarrayWtoU( LDAPModW **modarray )
385 LDAPMod **modarrayU = NULL;
386 DWORD size;
388 if (modarray)
390 size = sizeof(LDAPMod*) * (modarraylenW( modarray ) + 1);
391 modarrayU = HeapAlloc( GetProcessHeap(), 0, size );
393 if (modarrayU)
395 LDAPModW **p = modarray;
396 LDAPMod **q = modarrayU;
398 while (*p) *q++ = modWtoU( *p++ );
399 *q = NULL;
402 return modarrayU;
405 static inline void modarrayfreeW( LDAPModW **modarray )
407 if (modarray)
409 LDAPModW **p = modarray;
410 while (*p) modfreeW( *p++ );
411 HeapFree( GetProcessHeap(), 0, modarray );
415 static inline void modarrayfreeU( LDAPMod **modarray )
417 if (modarray)
419 LDAPMod **p = modarray;
420 while (*p) modfreeU( *p++ );
421 HeapFree( GetProcessHeap(), 0, modarray );
425 static inline LDAPControlW *controlAtoW( LDAPControlA *control )
427 LDAPControlW *controlW;
428 DWORD len = control->ldctl_value.bv_len;
429 char *val = NULL;
431 if (control->ldctl_value.bv_val)
433 val = HeapAlloc( GetProcessHeap(), 0, len );
434 if (!val) return NULL;
435 memcpy( val, control->ldctl_value.bv_val, len );
438 controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
439 if (!controlW)
441 HeapFree( GetProcessHeap(), 0, val );
442 return NULL;
445 controlW->ldctl_oid = strAtoW( control->ldctl_oid );
446 controlW->ldctl_value.bv_len = len;
447 controlW->ldctl_value.bv_val = val;
448 controlW->ldctl_iscritical = control->ldctl_iscritical;
450 return controlW;
453 static inline LDAPControlA *controlWtoA( LDAPControlW *control )
455 LDAPControlA *controlA;
456 DWORD len = control->ldctl_value.bv_len;
457 char *val = NULL;
459 if (control->ldctl_value.bv_val)
461 val = HeapAlloc( GetProcessHeap(), 0, len );
462 if (!val) return NULL;
463 memcpy( val, control->ldctl_value.bv_val, len );
466 controlA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlA) );
467 if (!controlA)
469 HeapFree( GetProcessHeap(), 0, val );
470 return NULL;
473 controlA->ldctl_oid = strWtoA( control->ldctl_oid );
474 controlA->ldctl_value.bv_len = len;
475 controlA->ldctl_value.bv_val = val;
476 controlA->ldctl_iscritical = control->ldctl_iscritical;
478 return controlA;
481 static inline LDAPControl *controlWtoU( LDAPControlW *control )
483 LDAPControl *controlU;
484 DWORD len = control->ldctl_value.bv_len;
485 char *val = NULL;
487 if (control->ldctl_value.bv_val)
489 val = HeapAlloc( GetProcessHeap(), 0, len );
490 if (!val) return NULL;
491 memcpy( val, control->ldctl_value.bv_val, len );
494 controlU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControl) );
495 if (!controlU)
497 HeapFree( GetProcessHeap(), 0, val );
498 return NULL;
501 controlU->ldctl_oid = strWtoU( control->ldctl_oid );
502 controlU->ldctl_value.bv_len = len;
503 controlU->ldctl_value.bv_val = val;
504 controlU->ldctl_iscritical = control->ldctl_iscritical;
506 return controlU;
509 static inline LDAPControlW *controlUtoW( LDAPControl *control )
511 LDAPControlW *controlW;
512 DWORD len = control->ldctl_value.bv_len;
513 char *val = NULL;
515 if (control->ldctl_value.bv_val)
517 val = HeapAlloc( GetProcessHeap(), 0, len );
518 if (!val) return NULL;
519 memcpy( val, control->ldctl_value.bv_val, len );
522 controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
523 if (!controlW)
525 HeapFree( GetProcessHeap(), 0, val );
526 return NULL;
529 controlW->ldctl_oid = strUtoW( control->ldctl_oid );
530 controlW->ldctl_value.bv_len = len;
531 controlW->ldctl_value.bv_val = val;
532 controlW->ldctl_iscritical = control->ldctl_iscritical;
534 return controlW;
537 static inline void controlfreeA( LDAPControlA *control )
539 if (control)
541 strfreeA( control->ldctl_oid );
542 HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
543 HeapFree( GetProcessHeap(), 0, control );
547 static inline void controlfreeW( LDAPControlW *control )
549 if (control)
551 strfreeW( control->ldctl_oid );
552 HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
553 HeapFree( GetProcessHeap(), 0, control );
557 static inline void controlfreeU( LDAPControl *control )
559 if (control)
561 strfreeU( control->ldctl_oid );
562 HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
563 HeapFree( GetProcessHeap(), 0, control );
567 static inline DWORD controlarraylenA( LDAPControlA **controlarray )
569 LDAPControlA **p = controlarray;
570 while (*p) p++;
571 return p - controlarray;
574 static inline DWORD controlarraylenW( LDAPControlW **controlarray )
576 LDAPControlW **p = controlarray;
577 while (*p) p++;
578 return p - controlarray;
581 static inline DWORD controlarraylenU( LDAPControl **controlarray )
583 LDAPControl **p = controlarray;
584 while (*p) p++;
585 return p - controlarray;
588 static inline LDAPControlW **controlarrayAtoW( LDAPControlA **controlarray )
590 LDAPControlW **controlarrayW = NULL;
591 DWORD size;
593 if (controlarray)
595 size = sizeof(LDAPControlW*) * (controlarraylenA( controlarray ) + 1);
596 controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
598 if (controlarrayW)
600 LDAPControlA **p = controlarray;
601 LDAPControlW **q = controlarrayW;
603 while (*p) *q++ = controlAtoW( *p++ );
604 *q = NULL;
607 return controlarrayW;
610 static inline LDAPControlA **controlarrayWtoA( LDAPControlW **controlarray )
612 LDAPControlA **controlarrayA = NULL;
613 DWORD size;
615 if (controlarray)
617 size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
618 controlarrayA = HeapAlloc( GetProcessHeap(), 0, size );
620 if (controlarrayA)
622 LDAPControlW **p = controlarray;
623 LDAPControlA **q = controlarrayA;
625 while (*p) *q++ = controlWtoA( *p++ );
626 *q = NULL;
629 return controlarrayA;
632 static inline LDAPControl **controlarrayWtoU( LDAPControlW **controlarray )
634 LDAPControl **controlarrayU = NULL;
635 DWORD size;
637 if (controlarray)
639 size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
640 controlarrayU = HeapAlloc( GetProcessHeap(), 0, size );
642 if (controlarrayU)
644 LDAPControlW **p = controlarray;
645 LDAPControl **q = controlarrayU;
647 while (*p) *q++ = controlWtoU( *p++ );
648 *q = NULL;
651 return controlarrayU;
654 static inline LDAPControlW **controlarrayUtoW( LDAPControl **controlarray )
656 LDAPControlW **controlarrayW = NULL;
657 DWORD size;
659 if (controlarray)
661 size = sizeof(LDAPControlW*) * (controlarraylenU( controlarray ) + 1);
662 controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
664 if (controlarrayW)
666 LDAPControl **p = controlarray;
667 LDAPControlW **q = controlarrayW;
669 while (*p) *q++ = controlUtoW( *p++ );
670 *q = NULL;
673 return controlarrayW;
676 static inline void controlarrayfreeA( LDAPControlA **controlarray )
678 if (controlarray)
680 LDAPControlA **p = controlarray;
681 while (*p) controlfreeA( *p++ );
682 HeapFree( GetProcessHeap(), 0, controlarray );
686 static inline void controlarrayfreeW( LDAPControlW **controlarray )
688 if (controlarray)
690 LDAPControlW **p = controlarray;
691 while (*p) controlfreeW( *p++ );
692 HeapFree( GetProcessHeap(), 0, controlarray );
696 static inline void controlarrayfreeU( LDAPControl **controlarray )
698 if (controlarray)
700 LDAPControl **p = controlarray;
701 while (*p) controlfreeU( *p++ );
702 HeapFree( GetProcessHeap(), 0, controlarray );
706 static inline LDAPSortKeyW *sortkeyAtoW( LDAPSortKeyA *sortkey )
708 LDAPSortKeyW *sortkeyW;
710 sortkeyW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyW) );
711 if (sortkeyW)
713 sortkeyW->sk_attrtype = strAtoW( sortkey->sk_attrtype );
714 sortkeyW->sk_matchruleoid = strAtoW( sortkey->sk_matchruleoid );
715 sortkeyW->sk_reverseorder = sortkey->sk_reverseorder;
717 return sortkeyW;
720 static inline LDAPSortKeyA *sortkeyWtoA( LDAPSortKeyW *sortkey )
722 LDAPSortKeyA *sortkeyA;
724 sortkeyA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyA) );
725 if (sortkeyA)
727 sortkeyA->sk_attrtype = strWtoA( sortkey->sk_attrtype );
728 sortkeyA->sk_matchruleoid = strWtoA( sortkey->sk_matchruleoid );
729 sortkeyA->sk_reverseorder = sortkey->sk_reverseorder;
731 return sortkeyA;
734 static inline LDAPSortKey *sortkeyWtoU( LDAPSortKeyW *sortkey )
736 LDAPSortKey *sortkeyU;
738 sortkeyU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKey) );
739 if (sortkeyU)
741 sortkeyU->attributeType = strWtoU( sortkey->sk_attrtype );
742 sortkeyU->orderingRule = strWtoU( sortkey->sk_matchruleoid );
743 sortkeyU->reverseOrder = sortkey->sk_reverseorder;
745 return sortkeyU;
748 static inline void sortkeyfreeA( LDAPSortKeyA *sortkey )
750 if (sortkey)
752 strfreeA( sortkey->sk_attrtype );
753 strfreeA( sortkey->sk_matchruleoid );
754 HeapFree( GetProcessHeap(), 0, sortkey );
758 static inline void sortkeyfreeW( LDAPSortKeyW *sortkey )
760 if (sortkey)
762 strfreeW( sortkey->sk_attrtype );
763 strfreeW( sortkey->sk_matchruleoid );
764 HeapFree( GetProcessHeap(), 0, sortkey );
768 static inline void sortkeyfreeU( LDAPSortKey *sortkey )
770 if (sortkey)
772 strfreeU( sortkey->attributeType );
773 strfreeU( sortkey->orderingRule );
774 HeapFree( GetProcessHeap(), 0, sortkey );
778 static inline DWORD sortkeyarraylenA( LDAPSortKeyA **sortkeyarray )
780 LDAPSortKeyA **p = sortkeyarray;
781 while (*p) p++;
782 return p - sortkeyarray;
785 static inline DWORD sortkeyarraylenW( LDAPSortKeyW **sortkeyarray )
787 LDAPSortKeyW **p = sortkeyarray;
788 while (*p) p++;
789 return p - sortkeyarray;
792 static inline LDAPSortKeyW **sortkeyarrayAtoW( LDAPSortKeyA **sortkeyarray )
794 LDAPSortKeyW **sortkeyarrayW = NULL;
795 DWORD size;
797 if (sortkeyarray)
799 size = sizeof(LDAPSortKeyW*) * (sortkeyarraylenA( sortkeyarray ) + 1);
800 sortkeyarrayW = HeapAlloc( GetProcessHeap(), 0, size );
802 if (sortkeyarrayW)
804 LDAPSortKeyA **p = sortkeyarray;
805 LDAPSortKeyW **q = sortkeyarrayW;
807 while (*p) *q++ = sortkeyAtoW( *p++ );
808 *q = NULL;
811 return sortkeyarrayW;
814 static inline LDAPSortKey **sortkeyarrayWtoU( LDAPSortKeyW **sortkeyarray )
816 LDAPSortKey **sortkeyarrayU = NULL;
817 DWORD size;
819 if (sortkeyarray)
821 size = sizeof(LDAPSortKey*) * (sortkeyarraylenW( sortkeyarray ) + 1);
822 sortkeyarrayU = HeapAlloc( GetProcessHeap(), 0, size );
824 if (sortkeyarrayU)
826 LDAPSortKeyW **p = sortkeyarray;
827 LDAPSortKey **q = sortkeyarrayU;
829 while (*p) *q++ = sortkeyWtoU( *p++ );
830 *q = NULL;
833 return sortkeyarrayU;
836 static inline void sortkeyarrayfreeW( LDAPSortKeyW **sortkeyarray )
838 if (sortkeyarray)
840 LDAPSortKeyW **p = sortkeyarray;
841 while (*p) sortkeyfreeW( *p++ );
842 HeapFree( GetProcessHeap(), 0, sortkeyarray );
846 static inline void sortkeyarrayfreeU( LDAPSortKey **sortkeyarray )
848 if (sortkeyarray)
850 LDAPSortKey **p = sortkeyarray;
851 while (*p) sortkeyfreeU( *p++ );
852 HeapFree( GetProcessHeap(), 0, sortkeyarray );
856 #endif /* HAVE_LDAP */