]> git.sur5r.net Git - openldap/blob - libraries/libldap/turn.c
ITS#8605 - spelling fixes
[openldap] / libraries / libldap / turn.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2005-2017 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* ACKNOWLEDGEMENTS:
16  * This program was originally developed by Kurt D. Zeilenga for inclusion in
17  * OpenLDAP Software.
18  */
19
20 /*
21  * LDAPv3 Turn Operation Request
22  */
23
24 #include "portable.h"
25
26 #include <stdio.h>
27 #include <ac/stdlib.h>
28
29 #include <ac/socket.h>
30 #include <ac/string.h>
31 #include <ac/time.h>
32
33 #include "ldap-int.h"
34 #include "ldap_log.h"
35
36 int
37 ldap_turn(
38         LDAP *ld,
39         int mutual,
40         LDAP_CONST char* identifier,
41         LDAPControl **sctrls,
42         LDAPControl **cctrls,
43         int *msgidp )
44 {
45 #ifdef LDAP_EXOP_X_TURN
46         BerElement *turnvalber = NULL;
47         struct berval *turnvalp = NULL;
48         int rc;
49
50         turnvalber = ber_alloc_t( LBER_USE_DER );
51         if( mutual ) {
52                 ber_printf( turnvalber, "{bs}", mutual, identifier );
53         } else {
54                 ber_printf( turnvalber, "{s}", identifier );
55         }
56         ber_flatten( turnvalber, &turnvalp );
57
58         rc = ldap_extended_operation( ld, LDAP_EXOP_X_TURN,
59                         turnvalp, sctrls, cctrls, msgidp );
60         ber_free( turnvalber, 1 );
61         return rc;
62 #else
63         return LDAP_CONTROL_NOT_FOUND;
64 #endif
65 }
66
67 int
68 ldap_turn_s(
69         LDAP *ld,
70         int mutual,
71         LDAP_CONST char* identifier,
72         LDAPControl **sctrls,
73         LDAPControl **cctrls )
74 {
75 #ifdef LDAP_EXOP_X_TURN
76         BerElement *turnvalber = NULL;
77         struct berval *turnvalp = NULL;
78         int rc;
79
80         turnvalber = ber_alloc_t( LBER_USE_DER );
81         if( mutual ) {
82                 ber_printf( turnvalber, "{bs}", 0xFF, identifier );
83         } else {
84                 ber_printf( turnvalber, "{s}", identifier );
85         }
86         ber_flatten( turnvalber, &turnvalp );
87
88         rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_TURN,
89                         turnvalp, sctrls, cctrls, NULL, NULL );
90         ber_free( turnvalber, 1 );
91         return rc;
92 #else
93         return LDAP_CONTROL_NOT_FOUND;
94 #endif
95 }
96