No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / openldap / dist / libraries / libldap / turn.c
bloba92470b38e94d0070cedcdcb9e4489958e95cd3c
1 /* $OpenLDAP: pkg/ldap/libraries/libldap/turn.c,v 1.3.2.3 2008/02/11 23:26:41 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2005-2008 The OpenLDAP Foundation.
5 * All rights reserved.
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.
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>.
15 /* ACKNOWLEDGEMENTS:
16 * This program was orignally developed by Kurt D. Zeilenga for inclusion in
17 * OpenLDAP Software.
21 * LDAPv3 Turn Operation Request
24 #include "portable.h"
26 #include <stdio.h>
27 #include <ac/stdlib.h>
29 #include <ac/socket.h>
30 #include <ac/string.h>
31 #include <ac/time.h>
33 #include "ldap-int.h"
34 #include "ldap_log.h"
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 )
45 #ifdef LDAP_EXOP_X_TURN
46 BerElement *turnvalber = NULL;
47 struct berval *turnvalp = NULL;
48 int rc;
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 );
56 ber_flatten( turnvalber, &turnvalp );
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
67 int
68 ldap_turn_s(
69 LDAP *ld,
70 int mutual,
71 LDAP_CONST char* identifier,
72 LDAPControl **sctrls,
73 LDAPControl **cctrls )
75 #ifdef LDAP_EXOP_X_TURN
76 BerElement *turnvalber = NULL;
77 struct berval *turnvalp = NULL;
78 int rc;
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 );
86 ber_flatten( turnvalber, &turnvalp );
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