2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <SystemConfiguration/SCD.h>
24 #include "SCDPrivate.h"
30 SCDHandlePrivateRef privateHandle
= CFAllocatorAllocate(NULL
, sizeof(SCDHandlePrivate
), 0);
33 privateHandle
->data
= NULL
;
36 privateHandle
->instance
= 0;
38 return (SCDHandleRef
)privateHandle
;
43 SCDHandleRelease(SCDHandleRef handle
)
45 SCDHandlePrivateRef privateHandle
= (SCDHandlePrivateRef
)handle
;
47 if (privateHandle
->data
)
48 CFRelease(privateHandle
->data
);
50 CFAllocatorDeallocate(NULL
, privateHandle
);
56 SCDHandleGetInstance(SCDHandleRef handle
)
58 SCDHandlePrivateRef privateHandle
= (SCDHandlePrivateRef
)handle
;
60 return privateHandle
->instance
;
65 _SCDHandleSetInstance(SCDHandleRef handle
, int instance
)
67 SCDHandlePrivateRef privateHandle
= (SCDHandlePrivateRef
)handle
;
69 privateHandle
->instance
= instance
;
75 SCDHandleGetData(SCDHandleRef handle
)
77 SCDHandlePrivateRef privateHandle
= (SCDHandlePrivateRef
)handle
;
79 if (privateHandle
->data
== NULL
) {
80 return CFSTR("SCDHandleRef not initialized.");
83 return privateHandle
->data
;
88 SCDHandleSetData(SCDHandleRef handle
, CFPropertyListRef data
)
90 SCDHandlePrivateRef privateHandle
= (SCDHandlePrivateRef
)handle
;
92 /* remove reference to data previously associated with handle */
93 if (privateHandle
->data
)
94 CFRelease(privateHandle
->data
);
96 /* associate new data with handle, keep a reference as needed */
97 privateHandle
->data
= data
;
98 if (privateHandle
->data
)
99 CFRetain(privateHandle
->data
);