2 * Copyright (c) 2000-2002 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@
24 * Modification History
26 * June 1, 2001 Allan Nathanson <ajn@apple.com>
27 * - public API conversion
29 * June 20, 2000 Allan Nathanson <ajn@apple.com>
37 __SCDynamicStoreTouchValue(SCDynamicStoreRef store
, CFStringRef key
)
39 SCDynamicStorePrivateRef storePrivate
= (SCDynamicStorePrivateRef
)store
;
41 Boolean newValue
= FALSE
;
42 CFPropertyListRef value
;
44 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("__SCDynamicStoreTouchValue:"));
45 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" key = %@"), key
);
47 if (!store
|| (storePrivate
->server
== MACH_PORT_NULL
)) {
48 return kSCStatusNoStoreSession
; /* you must have an open session to play */
52 * 1. Ensure that we hold the lock.
54 sc_status
= __SCDynamicStoreLock(store
, TRUE
);
55 if (sc_status
!= kSCStatusOK
) {
60 * 2. Grab the current (or establish a new) store entry for this key.
62 sc_status
= __SCDynamicStoreCopyValue(store
, key
, &value
);
65 /* store entry does not exist, create */
66 value
= CFDateCreate(NULL
, CFAbsoluteTimeGetCurrent());
68 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" new time stamp = %@"), value
);
72 /* store entry exists */
73 if (isA_CFDate(value
)) {
74 /* the value is a CFDate, update the time stamp */
76 value
= CFDateCreate(NULL
, CFAbsoluteTimeGetCurrent());
78 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" new time stamp = %@"), value
);
79 } /* else, we'll just save the data (again) to bump the instance */
83 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" __SCDynamicStoreCopyValue(): %s"), SCErrorString(sc_status
));
87 sc_status
= __SCDynamicStoreSetValue(store
, key
, value
);
96 * 8. Release our lock.
98 __SCDynamicStoreUnlock(store
, TRUE
);
105 _configtouch(mach_port_t server
,
106 xmlData_t keyRef
, /* raw XML bytes */
107 mach_msg_type_number_t keyLen
,
111 serverSessionRef mySession
= getSession(server
);
112 CFStringRef key
; /* key (un-serialized) */
114 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR("Touch key in configuration database."));
115 SCLog(_configd_verbose
, LOG_DEBUG
, CFSTR(" server = %d"), server
);
117 /* un-serialize the key */
118 if (!_SCUnserialize((CFPropertyListRef
*)&key
, (void *)keyRef
, keyLen
)) {
119 *sc_status
= kSCStatusFailed
;
123 if (!isA_CFString(key
)) {
125 *sc_status
= kSCStatusInvalidArgument
;
129 *sc_status
= __SCDynamicStoreTouchValue(mySession
->store
, key
);