xref: /netbsd-src/external/bsd/openldap/dist/libraries/libldap/cancel.c (revision 549b59ed3ccf0d36d3097190a0db27b770f3a839)
1 /*	$NetBSD: cancel.c,v 1.3 2021/08/14 16:14:55 christos Exp $	*/
2 
3 /* $OpenLDAP$ */
4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5  *
6  * Copyright 1998-2021 The OpenLDAP Foundation.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in the file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This program was originally developed by Kurt D. Zeilenga for inclusion
19  * in OpenLDAP Software.
20  */
21 
22 /*
23  * LDAPv3 Cancel Operation Request
24  */
25 
26 #include <sys/cdefs.h>
27 __RCSID("$NetBSD: cancel.c,v 1.3 2021/08/14 16:14:55 christos Exp $");
28 
29 #include "portable.h"
30 
31 #include <stdio.h>
32 #include <ac/stdlib.h>
33 
34 #include <ac/socket.h>
35 #include <ac/string.h>
36 #include <ac/time.h>
37 
38 #include "ldap-int.h"
39 #include "ldap_log.h"
40 
41 int
ldap_cancel(LDAP * ld,int cancelid,LDAPControl ** sctrls,LDAPControl ** cctrls,int * msgidp)42 ldap_cancel(
43 	LDAP		*ld,
44 	int		cancelid,
45 	LDAPControl	**sctrls,
46 	LDAPControl	**cctrls,
47 	int		*msgidp )
48 {
49 	BerElement *cancelidber = NULL;
50 	struct berval cancelidvalp = { 0, NULL };
51 	int rc;
52 
53 	cancelidber = ber_alloc_t( LBER_USE_DER );
54 	ber_printf( cancelidber, "{i}", cancelid );
55 	ber_flatten2( cancelidber, &cancelidvalp, 0 );
56 	rc = ldap_extended_operation( ld, LDAP_EXOP_CANCEL,
57 		&cancelidvalp, sctrls, cctrls, msgidp );
58 	ber_free( cancelidber, 1 );
59 	return rc;
60 }
61 
62 int
ldap_cancel_s(LDAP * ld,int cancelid,LDAPControl ** sctrls,LDAPControl ** cctrls)63 ldap_cancel_s(
64 	LDAP		*ld,
65 	int		cancelid,
66 	LDAPControl	**sctrls,
67 	LDAPControl	**cctrls )
68 {
69 	BerElement *cancelidber = NULL;
70 	struct berval cancelidvalp = { 0, NULL };
71 	int rc;
72 
73 	cancelidber = ber_alloc_t( LBER_USE_DER );
74 	ber_printf( cancelidber, "{i}", cancelid );
75 	ber_flatten2( cancelidber, &cancelidvalp, 0 );
76 	rc = ldap_extended_operation_s( ld, LDAP_EXOP_CANCEL,
77 		&cancelidvalp, sctrls, cctrls, NULL, NULL );
78 	ber_free( cancelidber, 1 );
79 	return rc;
80 }
81 
82