2 * Copyright (c) 2006,2011-2012,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
30 #include <security_cdsa_utilities/cssmdb.h>
32 bool_t
xdr_DLDbFlatIdentifier(XDR
*xdrs
, DataWalkers::DLDbFlatIdentifier
*objp
);
33 bool_t
xdr_DLDbFlatIdentifierRef(XDR
*xdrs
, DataWalkers::DLDbFlatIdentifier
**objp
);
37 CopyIn(const void *data
, xdrproc_t proc
) : mLength(0), mData(0) {
38 if (data
&& !::copyin(static_cast<uint8_t*>(const_cast<void *>(data
)), proc
, &mData
, &mLength
))
39 CssmError::throwMe(CSSM_ERRCODE_MEMORY_ERROR
);
41 ~CopyIn() { if (mData
) free(mData
); }
42 u_int
length() { return mLength
; }
43 void *data() { return mData
; }
49 // split out CSSM_DATA variant
52 // CSSM_DATA can be output only if empty, but also specify preallocated memory to use
53 CopyOut(void *copy
, size_t size
, xdrproc_t proc
, bool dealloc
= false, CSSM_DATA
*in_out_data
= NULL
) : mLength(in_out_data
?(u_int
)in_out_data
->Length
:0), mData(NULL
), mInOutData(in_out_data
), mDealloc(dealloc
), mSource(copy
), mSourceLen(size
) {
54 if (copy
&& size
&& !::copyout(copy
, (u_int
)size
, proc
, mInOutData
? reinterpret_cast<void**>(&mInOutData
) : &mData
, &mLength
)) {
55 if (mInOutData
&& mInOutData
->Length
) // DataOut behaviour: error back to user if likely related to amount of space passed in
56 CssmError::throwMe(CSSMERR_CSP_OUTPUT_LENGTH_ERROR
);
58 CssmError::throwMe(CSSM_ERRCODE_MEMORY_ERROR
);
62 u_int
length() { return mLength
; }
63 void* data() { return mData
; }
64 void* get() { void *tmp
= mData
; mData
= NULL
; return tmp
; }
68 CSSM_DATA
*mInOutData
;
74 #endif /* !_XDR_AUTH_H */