1 /* $OpenLDAP: pkg/ldap/libraries/libldap/txn.c,v 1.8.2.3 2008/02/11 23:26:41 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2006-2008 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
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>.
16 * This program was orignally developed by Kurt D. Zeilenga for inclusion
17 * in OpenLDAP Software.
21 * LDAPv3 Transactions (draft-zeilenga-ldap-txn)
27 #include <ac/stdlib.h>
29 #include <ac/socket.h>
30 #include <ac/string.h>
44 return ldap_extended_operation( ld
, LDAP_EXOP_X_TXN_START
,
45 NULL
, sctrls
, cctrls
, msgidp
);
53 struct berval
**txnid
)
55 assert( txnid
!= NULL
);
57 return ldap_extended_operation_s( ld
, LDAP_EXOP_X_TXN_START
,
58 NULL
, sctrls
, cctrls
, NULL
, txnid
);
71 BerElement
*txnber
= NULL
;
72 struct berval
*txnval
= NULL
;
74 assert( txnid
!= NULL
);
76 txnber
= ber_alloc_t( LBER_USE_DER
);
79 ber_printf( txnber
, "{ON}", txnid
);
81 ber_printf( txnber
, "{bON}", commit
, txnid
);
84 ber_flatten( txnber
, &txnval
);
86 rc
= ldap_extended_operation( ld
, LDAP_EXOP_X_TXN_END
,
87 txnval
, sctrls
, cctrls
, msgidp
);
89 ber_free( txnber
, 1 );
103 BerElement
*txnber
= NULL
;
104 struct berval
*txnval
= NULL
;
105 struct berval
*retdata
= NULL
;
107 if ( retidp
!= NULL
) *retidp
= -1;
109 txnber
= ber_alloc_t( LBER_USE_DER
);
112 ber_printf( txnber
, "{ON}", txnid
);
114 ber_printf( txnber
, "{bON}", commit
, txnid
);
117 ber_flatten( txnber
, &txnval
);
119 rc
= ldap_extended_operation_s( ld
, LDAP_EXOP_X_TXN_END
,
120 txnval
, sctrls
, cctrls
, NULL
, &retdata
);
122 ber_free( txnber
, 1 );
125 if( retdata
!= NULL
) {
130 if( retidp
== NULL
) goto done
;
132 ber
= ber_init( retdata
);
135 rc
= ld
->ld_errno
= LDAP_NO_MEMORY
;
139 tag
= ber_scanf( ber
, "i", &retid
);
142 if ( tag
!= LBER_INTEGER
) {
143 rc
= ld
->ld_errno
= LDAP_DECODING_ERROR
;
147 *retidp
= (int) retid
;
150 ber_bvfree( retdata
);