FRAMEWORK_SUBPROJECTS = SystemConfiguration.fproj
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble
+OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\
+ preferences.xml
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
CODE_GEN_STYLE = DYNAMIC
# owned by the top-level Makefile API and no context has been set up for where
# derived files should go.
#
+SYSCONFIG_PREFS_DIR = /private/var/db/SystemConfiguration
+install_extra:
+ $(MKDIRS) $(DSTROOT)$(SYSCONFIG_PREFS_DIR)
+ install -c -m 644 preferences.xml $(DSTROOT)$(SYSCONFIG_PREFS_DIR)/preferences.xml
# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems
# and "" on other systems.
DSTROOT = $(HOME)
+AFTER_INSTALL = install_extra
DYNAMIC_CODE_GEN = YES;
FILESTABLE = {
H_FILES = ();
- OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble);
+ OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, preferences.xml);
PRECOMPILED_HEADERS = ();
PROJECT_HEADERS = ();
PUBLIC_HEADERS = ();
{
CFBundleName = "SystemConfiguration";
CFBundleIdentifier = "com.apple.SystemConfiguration";
- CFBundleShortVersionString = "1.1.0";
+ CFBundleShortVersionString = "1.2.0";
}
--- /dev/null
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ * May 29, 2002 Roger Smith <rsmith@apple.com>
+ * - initial revision
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <mach/mach.h>
+#include <mach-o/dyld.h>
+#include <pthread.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreFoundation/CFRuntime.h>
+
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCValidation.h>
+#include <SystemConfiguration/SCPrivate.h>
+
+#include <IOKit/IOKitLib.h>
+
+#include "moh_msg.h"
+#include "moh.h"
+#include "DeviceOnHold.h"
+
+
+#define kIODeviceSupportsHoldKey "DeviceSupportsHold"
+
+
+static void *
+__loadIOKit(void) {
+ static const void *image = NULL;
+ if (NULL == image) {
+ const char *framework = "/System/Library/Frameworks/IOKit.framework/IOKit";
+ struct stat statbuf;
+ const char *suffix = getenv("DYLD_IMAGE_SUFFIX");
+ char path[MAXPATHLEN];
+
+ strcpy(path, framework);
+ if (suffix) strcat(path, suffix);
+ if (0 <= stat(path, &statbuf)) {
+ image = NSAddImage(path, NSADDIMAGE_OPTION_NONE);
+ } else {
+ image = NSAddImage(framework, NSADDIMAGE_OPTION_NONE);
+ }
+ }
+ return (void *)image;
+}
+
+
+static io_object_t
+_IOIteratorNext(io_iterator_t iterator)
+{
+ static io_object_t (*dyfunc)(io_iterator_t) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOIteratorNext", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(iterator) : 0;
+}
+#define IOIteratorNext _IOIteratorNext
+
+
+static kern_return_t
+_IOMasterPort(mach_port_t bootstrapPort, mach_port_t *masterPort)
+{
+ static kern_return_t (*dyfunc)(mach_port_t, mach_port_t *) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOMasterPort", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(bootstrapPort, masterPort) : KERN_FAILURE;
+}
+#define IOMasterPort _IOMasterPort
+
+
+static kern_return_t
+_IOObjectRelease(io_object_t object)
+{
+ static kern_return_t (*dyfunc)(io_object_t) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOObjectRelease", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(object) : KERN_FAILURE;
+}
+#define IOObjectRelease _IOObjectRelease
+
+
+static kern_return_t
+_IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, IOOptionBits options)
+{
+ static kern_return_t (*dyfunc)(io_registry_entry_t, CFMutableDictionaryRef *, CFAllocatorRef, IOOptionBits) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryCreateCFProperties", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(entry, properties, allocator, options) : KERN_FAILURE;
+}
+#define IORegistryEntryCreateCFProperties _IORegistryEntryCreateCFProperties
+
+
+static kern_return_t
+_IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path)
+{
+ static kern_return_t (*dyfunc)(io_registry_entry_t, const io_name_t, io_string_t) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IORegistryEntryGetPath", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(entry, plane, path) : KERN_FAILURE;
+}
+#define IORegistryEntryGetPath _IORegistryEntryGetPath
+
+
+static kern_return_t
+_IOServiceGetMatchingServices(mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t *existing)
+{
+ static kern_return_t (*dyfunc)(mach_port_t, CFDictionaryRef, io_iterator_t *) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceGetMatchingServices", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(masterPort, matching, existing) : KERN_FAILURE;
+}
+#define IOServiceGetMatchingServices _IOServiceGetMatchingServices
+
+
+static CFMutableDictionaryRef
+_IOServiceMatching(const char *name)
+{
+ static CFMutableDictionaryRef (*dyfunc)(const char *) = NULL;
+ if (!dyfunc) {
+ void *image = __loadIOKit();
+ if (image) dyfunc = NSAddressOfSymbol(NSLookupSymbolInImage(image, "_IOServiceMatching", NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
+ }
+ return dyfunc ? dyfunc(name) : NULL;
+}
+#define IOServiceMatching _IOServiceMatching
+
+
+typedef struct {
+
+ /* base CFType information */
+ CFRuntimeBase cfBase;
+
+ /* device name (e.g. "modem") */
+ CFStringRef name;
+
+ int sock;
+
+} DeviceOnHoldPrivate, *DeviceOnHoldPrivateRef;
+
+
+static CFStringRef
+__DeviceOnHoldCopyDescription(CFTypeRef cf)
+{
+ CFAllocatorRef allocator = CFGetAllocator(cf);
+ CFMutableStringRef result;
+
+ result = CFStringCreateMutable(allocator, 0);
+ CFStringAppendFormat(result, NULL, CFSTR("<DeviceOnHold %p [%p]> {\n"), cf, allocator);
+ CFStringAppendFormat(result, NULL, CFSTR("}"));
+
+ return result;
+}
+
+
+static void
+__DeviceOnHoldDeallocate(CFTypeRef cf)
+{
+ DeviceOnHoldPrivateRef DeviceOnHoldPrivate = (DeviceOnHoldPrivateRef)cf;
+
+ SCLog(_sc_verbose, LOG_DEBUG, CFSTR("__DeviceOnHoldDeallocate:"));
+
+ /* release resources */
+ if (DeviceOnHoldPrivate->name) CFRelease(DeviceOnHoldPrivate->name);
+ if (DeviceOnHoldPrivate->sock != -1) {
+
+ }
+
+ return;
+}
+
+
+static CFTypeID __kDeviceOnHoldTypeID = _kCFRuntimeNotATypeID;
+
+
+static const CFRuntimeClass __DeviceOnHoldClass = {
+ 0, // version
+ "DeviceOnHold", // className
+ NULL, // init
+ NULL, // copy
+ __DeviceOnHoldDeallocate, // dealloc
+ NULL, // equal
+ NULL, // hash
+ NULL, // copyFormattingDesc
+ __DeviceOnHoldCopyDescription // copyDebugDesc
+};
+
+
+static pthread_once_t initialized = PTHREAD_ONCE_INIT;
+
+
+static void
+__DeviceOnHoldInitialize(void)
+{
+ __kDeviceOnHoldTypeID = _CFRuntimeRegisterClass(&__DeviceOnHoldClass);
+ return;
+}
+
+
+DeviceOnHoldRef
+__DeviceOnHoldCreatePrivate(CFAllocatorRef allocator)
+{
+ DeviceOnHoldPrivateRef devicePrivate;
+ UInt32 size;
+
+ /* initialize runtime */
+ pthread_once(&initialized, __DeviceOnHoldInitialize);
+
+ /* allocate session */
+ size = sizeof(DeviceOnHoldPrivate) - sizeof(CFRuntimeBase);
+ devicePrivate = (DeviceOnHoldPrivateRef)_CFRuntimeCreateInstance(allocator,
+ __kDeviceOnHoldTypeID,
+ size,
+ NULL);
+ if (!devicePrivate) {
+ return NULL;
+ }
+
+ devicePrivate->name = NULL;
+ devicePrivate->sock = -1;
+
+ return (DeviceOnHoldRef)devicePrivate;
+}
+
+
+/*
+ * TBD: We determine whether a device supports on hold capability by looking at
+ * the numeric property DeviceSupportsHold (1 - yes, 0 or no property - no). For
+ * the Apple Dash II internal modem we also use the property V92Modem to track
+ * this same capability.
+ */
+
+Boolean
+IsDeviceOnHoldSupported(CFStringRef deviceName, // "modem"
+ CFDictionaryRef options)
+{
+ CFMutableDictionaryRef deviceToMatch;
+ u_int32_t deviceSupportsHoldValue;
+ kern_return_t kr;
+ mach_port_t masterPort;
+ io_iterator_t matchingServices;
+ CFNumberRef num;
+ CFMutableDictionaryRef properties;
+ Boolean result = FALSE;
+ io_service_t service;
+
+ if (CFStringCompare(deviceName, CFSTR("modem"), NULL) == kCFCompareEqualTo) {
+ kr = IOMasterPort(MACH_PORT_NULL, &masterPort);
+ if (kr != KERN_SUCCESS) {
+ goto errorExit;
+ }
+
+ deviceToMatch = IOServiceMatching("InternalModemSupport");
+ if (!deviceToMatch) {
+ goto errorExit;
+ }
+
+ kr = IOServiceGetMatchingServices(masterPort, deviceToMatch, &matchingServices);
+ if (kr != KERN_SUCCESS) {
+ goto errorExit;
+ }
+
+ for ( ; service = IOIteratorNext(matchingServices) ; IOObjectRelease(service)) {
+ io_string_t path;
+
+ kr = IORegistryEntryGetPath(service, kIOServicePlane, path);
+ assert( kr == KERN_SUCCESS );
+
+ // grab a copy of the properties
+ kr = IORegistryEntryCreateCFProperties(service, &properties, kCFAllocatorDefault, kNilOptions);
+ assert( kr == KERN_SUCCESS );
+
+ num = CFDictionaryGetValue(properties, CFSTR(kIODeviceSupportsHoldKey));
+ if (isA_CFNumber(num)) {
+ CFNumberGetValue(num, kCFNumberSInt32Type, &deviceSupportsHoldValue);
+ if (deviceSupportsHoldValue == 1) {
+ result = TRUE;
+ }
+ }
+
+ CFRelease(properties);
+ }
+
+ IOObjectRelease(matchingServices);
+ }
+
+ // Note: The issue for the general case is how to go from the SystemConfiguration
+ // dynamic store to the actual driver. The devicesupportshold property is not
+ // copied the either of the setup/state descriptions so the caller would need
+ // to know the exact driver they are searching for.
+
+ return result;
+
+ errorExit:
+
+ return FALSE;
+}
+
+
+DeviceOnHoldRef
+DeviceOnHoldCreate(CFAllocatorRef allocator,
+ CFStringRef deviceName, // "modem"
+ CFDictionaryRef options)
+{
+ DeviceOnHoldRef device = NULL;
+ DeviceOnHoldPrivateRef devicePrivate;
+ int status;
+
+ if (CFStringCompare(deviceName, CFSTR("modem"), NULL) != kCFCompareEqualTo) {
+ return NULL;
+ }
+
+ device = __DeviceOnHoldCreatePrivate(allocator);
+ if (!device) {
+ return NULL;
+ }
+
+ devicePrivate = (DeviceOnHoldPrivateRef)device;
+
+ status = MOHInit(&devicePrivate->sock, deviceName);
+ if (status != 0) {
+ CFRelease(device);
+ return NULL;
+ }
+
+ devicePrivate->name = CFRetain(deviceName);
+
+ return device;
+}
+
+
+
+int32_t
+DeviceOnHoldGetStatus(DeviceOnHoldRef device)
+{
+ DeviceOnHoldPrivateRef devicePrivate = (DeviceOnHoldPrivateRef)device;
+ int err;
+ u_long link = 1;
+ void *replyBuf;
+ u_long replyBufLen;
+ int32_t result = -1;
+
+ if (!device) {
+ return -1;
+ }
+
+ if (devicePrivate->sock == -1) {
+ return -1;
+ }
+
+ err = MOHExec(devicePrivate->sock,
+ link,
+ MOH_SESSION_GET_STATUS,
+ NULL,
+ 0,
+ &replyBuf,
+ &replyBufLen);
+
+ if (err != 0) {
+ return -1;
+ }
+
+ if (replyBufLen == sizeof(result)) {
+ result = *(int32_t *)replyBuf;
+ }
+
+ if (replyBuf) CFAllocatorDeallocate(NULL, replyBuf);
+ return result;
+}
+
+
+Boolean
+DeviceOnHoldSuspend(DeviceOnHoldRef device)
+{
+ DeviceOnHoldPrivateRef devicePrivate = (DeviceOnHoldPrivateRef)device;
+ int err;
+ u_long link = 1;
+ void *replyBuf;
+ u_long replyBufLen;
+ Boolean result = FALSE;
+
+ if (!device) {
+ return FALSE;
+ }
+
+ if (devicePrivate->sock == -1) {
+ return FALSE;
+ }
+
+ err = MOHExec(devicePrivate->sock,
+ link,
+ MOH_PUT_SESSION_ON_HOLD,
+ NULL,
+ 0,
+ &replyBuf,
+ &replyBufLen);
+
+ if (err != 0) {
+ return -1;
+ }
+
+ if (replyBufLen == sizeof(result)) {
+ result = (*(int32_t *)replyBuf) ? TRUE : FALSE;
+ }
+
+ if (replyBuf) CFAllocatorDeallocate(NULL, replyBuf);
+ return result;
+}
+
+
+Boolean
+DeviceOnHoldResume(DeviceOnHoldRef device)
+{
+ DeviceOnHoldPrivateRef devicePrivate = (DeviceOnHoldPrivateRef)device;
+ int err;
+ u_long link = 1;
+ void *replyBuf;
+ u_long replyBufLen;
+ Boolean result = FALSE;
+
+ if (!device) {
+ return FALSE;
+ }
+
+ if (devicePrivate->sock == -1) {
+ return FALSE;
+ }
+
+ err = MOHExec(devicePrivate->sock,
+ link,
+ MOH_RESUME_SESSION_ON_HOLD,NULL,
+ 0,
+ &replyBuf,
+ &replyBufLen);
+
+ if (err != 0) {
+ return -1;
+ }
+
+ if (replyBufLen == sizeof(result)) {
+ result = (*(int32_t *)replyBuf) ? TRUE : FALSE;
+ }
+
+ if (replyBuf) CFAllocatorDeallocate(NULL, replyBuf);
+ return result;
+}
--- /dev/null
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+
+#ifndef _DEVICEONHOLD_H
+#define _DEVICEONHOLD_H
+
+#include <sys/cdefs.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+
+/*!
+ @enum
+ @discussion Returned status codes from DeviceOnHoldGetStatus()
+
+ @constant kDeviceIdle
+ @constant kDeviceConnecting
+ @constant kDeviceDataConnectionActive
+ @constant kDeviceDataConnectionOnHold
+ @constant kDeviceDisconnecting
+*/
+enum
+{
+ kDeviceIdle = 0,
+ kDeviceConnecting,
+ kDeviceDataConnectionActive,
+ kDeviceDataConnectionOnHold,
+ kDeviceDisconnecting
+};
+
+
+/*!
+ @typedef DeviceOnHoldRef
+ @discussion This is the handle to a specific device
+ which is used by the DeviceOnHold APIs.
+ */
+typedef const struct __DeviceOnHoldRef * DeviceOnHoldRef;
+
+
+__BEGIN_DECLS
+
+
+/*!
+ @function IsDeviceOnHoldSupported
+ @discussion Determines whether a device has the capability to have
+ a connection placed "on hold".
+
+ This function determines whether the device specified supports
+ the "on hold" capabality.
+
+ @param devname A CFStringRef that represents the device being queried.
+ @param options A CFDictionaryRef of various options for the device.
+ @result TRUE if device supports "on hold".
+
+ */
+Boolean
+IsDeviceOnHoldSupported (
+ CFStringRef devname, // e.g. "modem"
+ CFDictionaryRef options
+ );
+
+/*!
+ @function DeviceOnHoldCreate
+ @discussion Creates a DeviceOnHoldRef for the specified device supports.
+
+ This function creates a DeviceOnHoldRef handle which will be used
+ in all subsequent calls to the "on hold" API's.
+
+ @param allocator A CFAllocatorRef.
+ @param devname A CFStringRef that represents the device being queried.
+ @param options A CFDictionaryRef of various options for the device.
+ @result DeviceOnHoldRef to pass to subsequent device hold api's.
+
+ */
+DeviceOnHoldRef
+DeviceOnHoldCreate (
+ CFAllocatorRef allocator,
+ CFStringRef devname, // e.g. "modem"
+ CFDictionaryRef options
+ );
+
+
+/*!
+ @function DeviceOnHoldGetStatus
+ @discussion Returns the "on hold" status of the device.
+
+ @param deviceRef A DeviceOnHoldRef.
+ @result The status of device.
+
+ */
+int32_t
+DeviceOnHoldGetStatus (
+ DeviceOnHoldRef deviceRef
+ );
+
+
+/*!
+ @function DeviceOnHoldSuspend
+ @discussion Tells the device to go "on hold".
+
+ This function will signal the deviceRef to suspend operations
+
+ @param deviceRef A DeviceOnHoldRef.
+ @result Boolean if call succeeded.
+
+ */
+Boolean
+DeviceOnHoldSuspend (
+ DeviceOnHoldRef deviceRef
+ );
+
+/*!
+ @function DeviceOnHoldResume
+ @discussion Tells the device to resume.
+
+ This function will signal the deviceRef to resume operations
+
+ @param deviceRef A DeviceOnHoldRef.
+ @result Boolean if call succeeded.
+
+ */
+Boolean
+DeviceOnHoldResume (
+ DeviceOnHoldRef deviceRef
+ );
+
+__END_DECLS
+
+#endif /* _DEVICEONHOLD_H */
+
SCPreferencesPath.h SCPreferencesSetSpecific.h SCNetwork.h\
SCValidation.h ppp_msg.h ppp.h v1Compatibility.h SCD.h\
SCDKeys.h SCP.h SCPPath.h SCDConsoleUser.h SCDHostName.h\
- DHCPClientPreferences.h SCDynamicStoreCopyDHCPInfo.h
-
-CFILES = SCD.c SCDKeys.c SCDPrivate.c SCDOpen.c SCDLock.c SCDUnlock.c\
- SCDList.c SCDAdd.c SCDAddSession.c SCDGet.c SCDSet.c\
- SCDRemove.c SCDTouch.c SCDNotify.c SCDNotifierSetKeys.c\
- SCDNotifierList.c SCDNotifierAdd.c SCDNotifierRemove.c\
- SCDNotifierGetChanges.c SCDNotifierWait.c\
+ DHCPClientPreferences.h SCDynamicStoreCopyDHCPInfo.h moh_msg.h\
+ moh.h DeviceOnHold.h
+
+CFILES = SCD.c SCDKeys.c SCDPrivate.c SCDPlugin.c SCDOpen.c SCDLock.c\
+ SCDUnlock.c SCDList.c SCDAdd.c SCDAddSession.c SCDGet.c\
+ SCDSet.c SCDRemove.c SCDTouch.c SCDNotify.c\
+ SCDNotifierSetKeys.c SCDNotifierList.c SCDNotifierAdd.c\
+ SCDNotifierRemove.c SCDNotifierGetChanges.c SCDNotifierWait.c\
SCDNotifierInformViaCallback.c SCDNotifierInformViaMachPort.c\
SCDNotifierInformViaFD.c SCDNotifierInformViaSignal.c\
SCDNotifierCancel.c SCDSnapshot.c SCP.c SCPOpen.c SCPLock.c\
SCPUnlock.c SCPList.c SCPGet.c SCPAdd.c SCPSet.c SCPRemove.c\
SCPCommit.c SCPApply.c SCPPath.c SCDConsoleUser.c\
- SCDHostName.c SCNetwork.c SCProxies.c ppp.c v1Compatibility.c\
- DHCP.c
+ SCDHostName.c SCLocation.c SCNetwork.c SCProxies.c ppp.c\
+ v1Compatibility.c DHCP.c moh.c DeviceOnHold.c
OTHERSRCS = Makefile.preamble Makefile Makefile.postamble m.template\
h.template config.defs genSCPreferences.c CustomInfo.plist
PROF_LIBS = $(LIBS)
-NEXTSTEP_PB_CFLAGS = -DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS
FRAMEWORKS = -framework CoreFoundation
PUBLIC_HEADERS = SystemConfiguration.h SCDynamicStore.h\
SCDynamicStoreKey.h SCDynamicStoreCopySpecific.h\
SCPreferences.h SCPreferencesPath.h\
- SCPreferencesSetSpecific.h SCNetwork.h
+ SCPreferencesSetSpecific.h SCNetwork.h\
+ DHCPClientPreferences.h SCDynamicStoreCopyDHCPInfo.h
-PROJECT_HEADERS = SystemConfiguration.h SCPrivate.h config_types.h\
- SCDynamicStoreInternal.h SCDynamicStore.h\
- SCDynamicStorePrivate.h SCDynamicStoreKey.h\
- SCDynamicStoreCopySpecific.h\
+PROJECT_HEADERS = SCPrivate.h config_types.h SCDynamicStoreInternal.h\
+ SCDynamicStore.h SCDynamicStorePrivate.h\
+ SCDynamicStoreKey.h SCDynamicStoreCopySpecific.h\
SCDynamicStoreSetSpecificPrivate.h\
SCPreferencesInternal.h SCPreferences.h\
SCPreferencesPrivate.h SCPreferencesPath.h\
SCPreferencesSetSpecific.h SCNetwork.h SCValidation.h\
- v1Compatibility.h
+ SystemConfiguration.h v1Compatibility.h
/tmp/genSCFiles cfile > /tmp/SCSchemaDefinitions.c
dhcp: DHCP.c
- cc -Wall -DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS -DTEST_DHCPCLIENT_PREFERENCES -g -o dhcp DHCP.c -framework CoreFoundation -framework SystemConfiguration
+ cc -Wall -DTEST_DHCPCLIENT_PREFERENCES -g -o dhcp DHCP.c -framework CoreFoundation -framework SystemConfiguration
# DSTROOT = $(HOME)
# Additional flags for MiG generated files
-OTHER_PROJECT_HEADERS += config.defs config.h
+OTHER_PRIVATE_HEADERS += config.defs config.h
OTHER_PRIVATE_HEADERS += SCPrivate.h
OTHER_PRIVATE_HEADERS += SCDynamicStorePrivate.h
OTHER_PRIVATE_HEADERS += SCPreferencesPrivate.h
OTHER_PRIVATE_HEADERS += SCValidation.h
OTHER_PRIVATE_HEADERS += SCDPlugin.h
-OTHER_PRIVATE_HEADERS += SCDynamicStoreCopyDHCPInfo.h
-OTHER_PRIVATE_HEADERS += DHCPClientPreferences.h
+OTHER_PRIVATE_HEADERS += DeviceOnHold.h
#
# XXX INSTALL V1 COMPATIBILITY HEADERS XXX
SCDConsoleUser.h,
SCDHostName.h,
DHCPClientPreferences.h,
- SCDynamicStoreCopyDHCPInfo.h
+ SCDynamicStoreCopyDHCPInfo.h,
+ moh_msg.h,
+ moh.h,
+ DeviceOnHold.h
);
OTHER_LINKED = (
SCD.c,
SCDKeys.c,
SCDPrivate.c,
+ SCDPlugin.c,
SCDOpen.c,
SCDLock.c,
SCDUnlock.c,
SCPPath.c,
SCDConsoleUser.c,
SCDHostName.c,
+ SCLocation.c,
SCNetwork.c,
SCProxies.c,
ppp.c,
v1Compatibility.c,
- DHCP.c
+ DHCP.c,
+ moh.c,
+ DeviceOnHold.c
);
OTHER_SOURCES = (
Makefile.preamble,
);
PRECOMPILED_HEADERS = ();
PROJECT_HEADERS = (
- SystemConfiguration.h,
SCPrivate.h,
config_types.h,
SCDynamicStoreInternal.h,
SCPreferencesSetSpecific.h,
SCNetwork.h,
SCValidation.h,
+ SystemConfiguration.h,
v1Compatibility.h
);
PUBLIC_HEADERS = (
SCPreferences.h,
SCPreferencesPath.h,
SCPreferencesSetSpecific.h,
- SCNetwork.h
+ SCNetwork.h,
+ DHCPClientPreferences.h,
+ SCDynamicStoreCopyDHCPInfo.h
);
SUBPROJECTS = ();
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
NEXTSTEP_BUILDTOOL = /usr/bin/gnumake;
- NEXTSTEP_COMPILEROPTIONS = "-DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS";
NEXTSTEP_INSTALLDIR = "$(SYSTEM_LIBRARY_DIR)/Frameworks";
NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
{ kSCStatusInvalidArgument, "Invalid argument" },
{ kSCStatusKeyExists, "Key already defined" },
{ kSCStatusLocked, "Lock already held" },
+ { kSCStatusMaxLink, "Maximum link count exceeded" },
{ kSCStatusNeedLock, "Lock required for this operation" },
{ kSCStatusNoStoreServer, "Configuration daemon not (no longer) available" },
{ kSCStatusNoStoreSession, "Configuration daemon session not active" },
CFTypeID type = CFGetTypeID(info);
if (!formatOptions ||
- !CFDictionaryGetValueIfPresent(formatOptions, CFSTR("PREFIX1"), (void **)&prefix1)) {
+ !CFDictionaryGetValueIfPresent(formatOptions, CFSTR("PREFIX1"), (const void **)&prefix1)) {
prefix1 = CFSTR("");
}
}
if (!formatOptions ||
- !CFDictionaryGetValueIfPresent(formatOptions, CFSTR("PREFIX2"), (void **)&prefix2)) {
+ !CFDictionaryGetValueIfPresent(formatOptions, CFSTR("PREFIX2"), (const void **)&prefix2)) {
prefix2 = CFStringCreateCopy(NULL, prefix1);
}
}
if (type == CFArrayGetTypeID()) {
- void **elements;
+ const void **elements;
CFIndex i;
CFIndex nElements;
CFMutableStringRef str;
CFStringAppendFormat(str, formatOptions, CFSTR("%@<array> {"), prefix1);
nElements = CFArrayGetCount(info);
- elements = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
- CFArrayGetValues(info, CFRangeMake(0, nElements), elements);
- for (i=0; i<nElements; i++) {
- CFMutableStringRef nPrefix1;
- CFMutableStringRef nPrefix2;
- CFStringRef nStr;
- CFStringRef vStr;
-
- nStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%u"), i);
-
- nPrefix1 = CFStringCreateMutable(NULL, 0);
- CFStringAppendFormat(nPrefix1,
- formatOptions,
- CFSTR("%@ %@ : "),
- prefix2,
- nStr);
- nPrefix2 = CFStringCreateMutable(NULL, 0);
- CFStringAppendFormat(nPrefix2,
- formatOptions,
- CFSTR("%@ "),
- prefix2);
-
- CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX1"), nPrefix1);
- CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX2"), nPrefix2);
- CFRelease(nPrefix1);
- CFRelease(nPrefix2);
- CFRelease(nStr);
-
- vStr = _SCCopyDescription(elements[i], nFormatOptions);
- CFStringAppendFormat(str,
- formatOptions,
- CFSTR("\n%@"),
- vStr);
- CFRelease(vStr);
+ if (nElements > 0) {
+ elements = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
+ CFArrayGetValues(info, CFRangeMake(0, nElements), elements);
+ for (i=0; i<nElements; i++) {
+ CFMutableStringRef nPrefix1;
+ CFMutableStringRef nPrefix2;
+ CFStringRef nStr;
+ CFStringRef vStr;
+
+ nStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%u"), i);
+
+ nPrefix1 = CFStringCreateMutable(NULL, 0);
+ CFStringAppendFormat(nPrefix1,
+ formatOptions,
+ CFSTR("%@ %@ : "),
+ prefix2,
+ nStr);
+ nPrefix2 = CFStringCreateMutable(NULL, 0);
+ CFStringAppendFormat(nPrefix2,
+ formatOptions,
+ CFSTR("%@ "),
+ prefix2);
+
+ CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX1"), nPrefix1);
+ CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX2"), nPrefix2);
+ CFRelease(nPrefix1);
+ CFRelease(nPrefix2);
+ CFRelease(nStr);
+
+ vStr = _SCCopyDescription((void *)elements[i], nFormatOptions);
+ CFStringAppendFormat(str,
+ formatOptions,
+ CFSTR("\n%@"),
+ vStr);
+ CFRelease(vStr);
+ }
+ CFAllocatorDeallocate(NULL, elements);
}
- CFAllocatorDeallocate(NULL, elements);
CFStringAppendFormat(str, formatOptions, CFSTR("\n%@}"), prefix2);
CFRelease(nFormatOptions);
}
if (type == CFDictionaryGetTypeID()) {
- void **keys;
+ const void **keys;
CFIndex i;
CFIndex nElements;
CFMutableStringRef nPrefix1;
CFMutableStringRef nPrefix2;
CFMutableStringRef str;
- void **values;
+ const void **values;
str = CFStringCreateMutable(NULL, 0);
CFStringAppendFormat(str, formatOptions, CFSTR("%@<dictionary> {"), prefix1);
nElements = CFDictionaryGetCount(info);
- keys = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
- values = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
- CFDictionaryGetKeysAndValues(info, keys, values);
- for (i=0; i<nElements; i++) {
- CFStringRef kStr;
- CFStringRef vStr;
-
- kStr = _SCCopyDescription(keys[i], NULL);
-
- nPrefix1 = CFStringCreateMutable(NULL, 0);
- CFStringAppendFormat(nPrefix1,
- formatOptions,
- CFSTR("%@ %@ : "),
- prefix2,
- kStr);
- nPrefix2 = CFStringCreateMutable(NULL, 0);
- CFStringAppendFormat(nPrefix2,
- formatOptions,
- CFSTR("%@ "),
- prefix2);
-
- CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX1"), nPrefix1);
- CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX2"), nPrefix2);
- CFRelease(nPrefix1);
- CFRelease(nPrefix2);
- CFRelease(kStr);
-
- vStr = _SCCopyDescription(values[i], nFormatOptions);
- CFStringAppendFormat(str,
- formatOptions,
- CFSTR("\n%@"),
- vStr);
- CFRelease(vStr);
+ if (nElements > 0) {
+ keys = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
+ values = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
+ CFDictionaryGetKeysAndValues(info, keys, values);
+ for (i=0; i<nElements; i++) {
+ CFStringRef kStr;
+ CFStringRef vStr;
+
+ kStr = _SCCopyDescription((void *)keys[i], NULL);
+
+ nPrefix1 = CFStringCreateMutable(NULL, 0);
+ CFStringAppendFormat(nPrefix1,
+ formatOptions,
+ CFSTR("%@ %@ : "),
+ prefix2,
+ kStr);
+ nPrefix2 = CFStringCreateMutable(NULL, 0);
+ CFStringAppendFormat(nPrefix2,
+ formatOptions,
+ CFSTR("%@ "),
+ prefix2);
+
+ CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX1"), nPrefix1);
+ CFDictionarySetValue(nFormatOptions, CFSTR("PREFIX2"), nPrefix2);
+ CFRelease(nPrefix1);
+ CFRelease(nPrefix2);
+ CFRelease(kStr);
+
+ vStr = _SCCopyDescription((void *)values[i], nFormatOptions);
+ CFStringAppendFormat(str,
+ formatOptions,
+ CFSTR("\n%@"),
+ vStr);
+ CFRelease(vStr);
+ }
+ CFAllocatorDeallocate(NULL, keys);
+ CFAllocatorDeallocate(NULL, values);
}
- CFAllocatorDeallocate(NULL, keys);
- CFAllocatorDeallocate(NULL, values);
CFStringAppendFormat(str, formatOptions, CFSTR("\n%@}"), prefix2);
CFRelease(nFormatOptions);
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
return FALSE;
}
- /* serialize the key and data */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ /* serialize the key */
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
- xmlData = CFPropertyListCreateXMLData(NULL, value);
- myDataRef = (xmlData_t)CFDataGetBytePtr(xmlData);
- myDataLen = CFDataGetLength(xmlData);
+ /* serialize the data */
+ if (!_SCSerialize(value, &xmlData, (void **)&myDataRef, &myDataLen)) {
+ CFRelease(xmlKey);
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key & data to the server */
status = configadd(storePrivate->server,
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
return FALSE;
}
- /* serialize the key and data */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ /* serialize the key */
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
- xmlData = CFPropertyListCreateXMLData(NULL, value);
- myDataRef = (xmlData_t)CFDataGetBytePtr(xmlData);
- myDataLen = CFDataGetLength(xmlData);
+ /* serialize the data */
+ if (!_SCSerialize(value, &xmlData, (void **)&myDataRef, &myDataLen)) {
+ CFRelease(xmlKey);
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key & data to the server */
status = configadd_s(storePrivate->server,
*/
#include <SystemConfiguration/SystemConfiguration.h>
-#include <SystemConfiguration/SCPrivate.h>
#include <SystemConfiguration/SCValidation.h>
+#include <SystemConfiguration/SCPrivate.h>
CFStringRef
SCDynamicStoreKeyCreateConsoleUser(CFAllocatorRef allocator)
CFStringRef consoleUser = NULL;
CFDictionaryRef dict = NULL;
CFStringRef key;
- SCDynamicStoreRef mySession = store;
+ Boolean tempSession = FALSE;
if (!store) {
- mySession = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreCopyConsoleUser"),
- NULL,
- NULL);
- if (!mySession) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreCopyConsoleUser"),
+ NULL,
+ NULL);
+ if (!store) {
SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
return NULL;
}
+ tempSession = TRUE;
}
key = SCDynamicStoreKeyCreateConsoleUser(NULL);
- dict = SCDynamicStoreCopyValue(mySession, key);
+ dict = SCDynamicStoreCopyValue(store, key);
CFRelease(key);
if (!isA_CFDictionary(dict)) {
_SCErrorSet(kSCStatusNoKey);
done :
- if (!store && mySession) CFRelease(mySession);
- if (dict) CFRelease(dict);
+ if (tempSession) CFRelease(store);
+ if (dict) CFRelease(dict);
return consoleUser;
}
CFStringRef consoleUser;
CFMutableDictionaryRef dict = NULL;
CFStringRef key = SCDynamicStoreKeyCreateConsoleUser(NULL);
- SCDynamicStoreRef mySession = store;
CFNumberRef num;
Boolean ok = TRUE;
+ Boolean tempSession = FALSE;
if (!store) {
- mySession = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreSetConsoleUser"),
- NULL,
- NULL);
- if (!mySession) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreSetConsoleUser"),
+ NULL,
+ NULL);
+ if (!store) {
SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
return FALSE;
}
+ tempSession = TRUE;
}
if (user == NULL) {
- ok = SCDynamicStoreRemoveValue(mySession, key);
+ ok = SCDynamicStoreRemoveValue(store, key);
goto done;
}
CFDictionarySetValue(dict, kSCPropUsersConsoleUserGID, num);
CFRelease(num);
- ok = SCDynamicStoreSetValue(mySession, key, dict);
+ ok = SCDynamicStoreSetValue(store, key, dict);
done :
- if (dict) CFRelease(dict);
- if (key) CFRelease(key);
- if (!store && mySession) CFRelease(mySession);
+ if (dict) CFRelease(dict);
+ if (key) CFRelease(key);
+ if (tempSession) CFRelease(store);
return ok;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFIndex myPatternsLen = 0;
xmlDataOut_t xmlDictRef; /* dict (serialized) */
CFIndex xmlDictLen;
- CFDataRef xmlDict; /* dict (XML serialized) */
- CFDictionaryRef dict; /* dict (un-serialized) */
+ CFDictionaryRef dict = NULL; /* dict (un-serialized) */
int sc_status;
- CFStringRef xmlError;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCopyMultiple:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" keys = %@"), keys);
/* serialize the keys */
if (keys) {
- xmlKeys = CFPropertyListCreateXMLData(NULL, keys);
- myKeysRef = (xmlData_t)CFDataGetBytePtr(xmlKeys);
- myKeysLen = CFDataGetLength(xmlKeys);
+ if (!_SCSerialize(keys, &xmlKeys, (void **)&myKeysRef, &myKeysLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
}
/* serialize the patterns */
if (patterns) {
- xmlPatterns = CFPropertyListCreateXMLData(NULL, patterns);
- myPatternsRef = (xmlData_t)CFDataGetBytePtr(xmlPatterns);
- myPatternsLen = CFDataGetLength(xmlPatterns);
+ if (!_SCSerialize(patterns, &xmlPatterns, (void **)&myPatternsRef, &myPatternsLen)) {
+ CFRelease(xmlKeys);
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
}
/* send the keys and patterns, fetch the associated result from the server */
return NULL;
}
- /* un-serialize the dict, return a value associated with the key */
- xmlDict = CFDataCreate(NULL, xmlDictRef, xmlDictLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)xmlDictRef, xmlDictLen);
- if (status != KERN_SUCCESS) {
- SCLog(_sc_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- dict = CFPropertyListCreateFromXMLData(NULL,
- xmlDict,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlDict);
- if (!dict) {
- if (xmlError) {
- SCLog(_sc_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() dict: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ /* un-serialize the dictionary */
+ if (!_SCUnserialize((CFPropertyListRef *)&dict, xmlDictRef, xmlDictLen)) {
_SCErrorSet(kSCStatusFailed);
return NULL;
}
CFIndex myKeyLen;
xmlDataOut_t xmlDataRef; /* data (serialized) */
CFIndex xmlDataLen;
- CFDataRef xmlData; /* data (XML serialized) */
CFPropertyListRef data; /* data (un-serialized) */
int newInstance;
int sc_status;
- CFStringRef xmlError;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCopyValue:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" key = %@"), key);
}
/* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
/* send the key & fetch the associated data from the server */
status = configget(storePrivate->server,
return NULL;
}
- /* un-serialize the data, return a value associated with the key */
- xmlData = CFDataCreate(NULL, xmlDataRef, xmlDataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)xmlDataRef, xmlDataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_sc_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- data = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!data) {
- if (xmlError) {
- SCLog(_sc_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() data: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ /* un-serialize the data */
+ if (!_SCUnserialize(&data, xmlDataRef, xmlDataLen)) {
_SCErrorSet(kSCStatusFailed);
return NULL;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFDictionaryRef dict = NULL;
CFStringRef key;
CFStringRef name = NULL;
- SCDynamicStoreRef mySession = store;
+ Boolean tempSession = FALSE;
if (!store) {
- mySession = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreCopyComputerName"),
- NULL,
- NULL);
- if (!mySession) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreCopyComputerName"),
+ NULL,
+ NULL);
+ if (!store) {
SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
return NULL;
}
+ tempSession = TRUE;
}
key = SCDynamicStoreKeyCreateComputerName(NULL);
- dict = SCDynamicStoreCopyValue(mySession, key);
+ dict = SCDynamicStoreCopyValue(store, key);
CFRelease(key);
if (!dict) {
goto done;
done :
- if (!store && mySession) CFRelease(mySession);
- if (dict) CFRelease(dict);
+ if (tempSession) CFRelease(store);
+ if (dict) CFRelease(dict);
return name;
}
Boolean ok = FALSE;
CFStringRef path = NULL;
- if (CFGetTypeID(name) != CFStringGetTypeID()) {
+ if (!isA_CFString(name)) {
_SCErrorSet(kSCStatusInvalidArgument);
return FALSE;
}
return ok;
}
+
+
+CFStringRef
+SCDynamicStoreKeyCreateHostNames(CFAllocatorRef allocator)
+{
+ return SCDynamicStoreKeyCreate(allocator,
+ CFSTR("%@/%@/%@"),
+ kSCDynamicStoreDomainSetup,
+ kSCCompNetwork,
+ kSCCompHostNames);
+}
+
+
+CFStringRef
+SCDynamicStoreCopyLocalHostName(SCDynamicStoreRef store)
+{
+ CFDictionaryRef dict = NULL;
+ CFStringRef key;
+ CFStringRef name = NULL;
+ Boolean tempSession = FALSE;
+
+ if (!store) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreCopyLocalHostName"),
+ NULL,
+ NULL);
+ if (!store) {
+ SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
+ return NULL;
+ }
+ tempSession = TRUE;
+ }
+
+ key = SCDynamicStoreKeyCreateHostNames(NULL);
+ dict = SCDynamicStoreCopyValue(store, key);
+ CFRelease(key);
+ if (!dict) {
+ goto done;
+ }
+ if (!isA_CFDictionary(dict)) {
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ name = isA_CFString(CFDictionaryGetValue(dict, kSCPropNetLocalHostName));
+ if (!name) {
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+ CFRetain(name);
+
+ done :
+
+ if (tempSession) CFRelease(store);
+ if (dict) CFRelease(dict);
+ return name;
+}
+
+
+Boolean
+_SC_stringIsValidDNSName(const char *name)
+{
+ int i;
+ int len = strlen(name);
+ char prev = '\0';
+ const char *scan;
+
+ if (len == 0) {
+ return FALSE;
+ }
+
+ for (scan = name, i = 0; i < len; i++, scan++) {
+ char ch = *scan;
+ char next = *(scan + 1);
+
+ if (prev == '.' || prev == '\0') {
+ if (isalpha(ch) == 0) {
+ return FALSE;
+ }
+ } else if (next == '\0' || next == '.') {
+ if (isalnum(ch) == 0) {
+ return FALSE;
+ }
+ } else if (isalnum(ch) == 0) {
+ switch (ch) {
+ case '.':
+ case '-':
+ if (prev == '.' || prev == '-') {
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ }
+ prev = ch;
+ }
+
+ return TRUE;
+}
+
+Boolean
+_SC_CFStringIsValidDNSName(CFStringRef name)
+{
+ Boolean clean = FALSE;
+ CFIndex len;
+ char *str = NULL;
+
+ if (!isA_CFString(name)) {
+ goto failed;
+ }
+
+ len = CFStringGetLength(name) + 1;
+ if (len == 0) {
+ goto failed;
+ }
+
+ str = CFAllocatorAllocate(NULL, len, 0);
+ if (str == NULL) {
+ goto failed;
+ }
+
+ if (!CFStringGetCString(name, str, len, kCFStringEncodingASCII)) {
+ goto failed;
+ }
+
+ clean = _SC_stringIsValidDNSName(str);
+
+ failed:
+
+ if (str) CFAllocatorDeallocate(NULL, str);
+ return clean;
+}
+
+
+Boolean
+SCPreferencesSetLocalHostName(SCPreferencesRef session,
+ CFStringRef name)
+{
+ CFDictionaryRef dict;
+ CFMutableDictionaryRef newDict = NULL;
+ Boolean ok = FALSE;
+ CFStringRef path = NULL;
+
+ if (name) {
+ if (!isA_CFString(name)) {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return FALSE;
+ }
+
+ if (CFStringGetLength(name) == 0) {
+ name = NULL;
+ }
+ }
+
+ if (name && !_SC_CFStringIsValidDNSName(name)) {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return FALSE;
+ }
+
+ path = CFStringCreateWithFormat(NULL,
+ NULL,
+ CFSTR("/%@/%@/%@"),
+ kSCPrefSystem,
+ kSCCompNetwork,
+ kSCCompHostNames);
+
+ dict = SCPreferencesPathGetValue(session, path);
+ if (dict) {
+ newDict = CFDictionaryCreateMutableCopy(NULL, 0, dict);
+ } else {
+ newDict = CFDictionaryCreateMutable(NULL,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ }
+
+ if (name) {
+ CFDictionarySetValue(newDict, kSCPropNetLocalHostName, name);
+ } else {
+ CFDictionaryRemoveValue(newDict, kSCPropNetLocalHostName);
+ }
+
+ if (CFDictionaryGetCount(newDict) > 0) {
+ ok = SCPreferencesPathSetValue(session, path, newDict);
+ if (!ok) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesPathSetValue() failed"));
+ }
+ } else {
+ ok = SCPreferencesPathRemoveValue(session, path);
+ if (!ok) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("SCPreferencesPathRemoveValue() failed"));
+ }
+ }
+
+ if (path) CFRelease(path);
+ if (newDict) CFRelease(newDict);
+
+ return ok;
+}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFDataRef xmlPattern; /* serialized pattern */
xmlData_t myPatternRef;
CFIndex myPatternLen;
- CFDataRef xmlData; /* data (XML serialized) */
xmlDataOut_t xmlDataRef; /* serialized data */
int xmlDataLen;
int sc_status;
CFArrayRef allKeys;
- CFStringRef xmlError;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCopyKeyList:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" pattern = %@"), pattern);
}
/* serialize the pattern */
- xmlPattern = CFPropertyListCreateXMLData(NULL, pattern);
- myPatternRef = (xmlData_t)CFDataGetBytePtr(xmlPattern);
- myPatternLen = CFDataGetLength(xmlPattern);
+ if (!_SCSerialize(pattern, &xmlPattern, (void **)&myPatternRef, &myPatternLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
/* send the pattern & fetch the associated data from the server */
status = configlist(storePrivate->server,
}
/* un-serialize the list of keys */
- xmlData = CFDataCreate(NULL, xmlDataRef, xmlDataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)xmlDataRef, xmlDataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_sc_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- allKeys = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!allKeys) {
- if (xmlError) {
- SCLog(_sc_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() list: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&allKeys, xmlDataRef, xmlDataLen)) {
_SCErrorSet(kSCStatusFailed);
return NULL;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
/* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
- /* send the key & data to the server */
+ /* send the key to the server */
status = notifyadd(storePrivate->server,
myKeyRef,
myKeyLen,
/* if no notifications have been registered */
return TRUE;
case Using_NotifierInformViaRunLoop :
- /* once activated, a RunLoop notifier cannot be cancelled */
- _SCErrorSet(kSCStatusNotifierActive);
- return FALSE;
+ CFRunLoopSourceInvalidate(storePrivate->rls);
+ return TRUE;
case Using_NotifierInformViaCallback :
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" cancel callback runloop source"));
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
{
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
kern_return_t status;
- CFDataRef xmlData; /* data (XML serialized) */
xmlDataOut_t xmlDataRef; /* serialized data */
int xmlDataLen;
int sc_status;
CFArrayRef allKeys;
- CFStringRef xmlError;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCopyNotifiedKeys:"));
}
/* un-serialize the list of keys which have changed */
- xmlData = CFDataCreate(NULL, xmlDataRef, xmlDataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)xmlDataRef, xmlDataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_sc_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- allKeys = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!allKeys) {
- if (xmlError) {
- SCLog(_sc_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() list: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&allKeys, xmlDataRef, xmlDataLen)) {
_SCErrorSet(kSCStatusFailed);
return NULL;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
mach_port_t port;
mach_port_t oldNotify;
int sc_status;
- CFMachPortContext context = { 0, (void *)store, NULL, NULL, NULL };
+ CFMachPortContext context = { 0
+ , (void *)store
+ , CFRetain
+ , CFRelease
+ , NULL
+ };
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreNotifyCallback:"));
/* remove the run loop source(s) */
CFRunLoopSourceInvalidate(storePrivate->callbackRunLoopSource);
CFRelease(storePrivate->callbackRunLoopSource);
+ storePrivate->callbackRunLoopSource = NULL;
/* invalidate port */
CFMachPortInvalidate(storePrivate->callbackPort);
CFRelease(storePrivate->callbackPort);
+ storePrivate->callbackPort = NULL;
return;
}
}
+static void
+rlsPortInvalidate(CFMachPortRef mp, void *info) {
+ mach_port_t port = CFMachPortGetPort(mp);
+
+ // A simple deallocate won't get rid of all the references we've accumulated
+ SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" invalidate = %d"), port);
+ mach_port_destroy(mach_task_self(), port);
+}
+
+
static void
rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode)
{
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("schedule notifications for mode %@"), mode);
if (storePrivate->rlsRefs++ == 0) {
- CFMachPortContext context = { 0, (void *)store, NULL, NULL, NULL };
+ CFMachPortContext context = { 0
+ , (void *)store
+ , CFRetain
+ , CFRelease
+ , NULL
+ };
mach_port_t oldNotify;
mach_port_t port;
int sc_status;
}
storePrivate->callbackPort = CFMachPortCreateWithPort(NULL, port, rlsCallback, &context, NULL);
+ CFMachPortSetInvalidationCallBack(storePrivate->callbackPort, rlsPortInvalidate);
storePrivate->callbackRunLoopSource = CFMachPortCreateRunLoopSource(NULL, storePrivate->callbackPort, 0);
}
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("cancel notifications for mode %@"), mode);
CFRunLoopRemoveSource(rl, storePrivate->callbackRunLoopSource, mode);
+
if (--storePrivate->rlsRefs == 0) {
int sc_status;
kern_return_t status;
/* remove the run loop source */
CFRelease(storePrivate->callbackRunLoopSource);
+ storePrivate->callbackRunLoopSource = NULL;
/* invalidate port */
CFMachPortInvalidate(storePrivate->callbackPort);
CFRelease(storePrivate->callbackPort);
+ storePrivate->callbackPort = NULL;
status = notifycancel(storePrivate->server, (int *)&sc_status);
if (status != KERN_SUCCESS) {
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" executing notifiction function"));
changedKeys = SCDynamicStoreCopyNotifiedKeys(store);
+ if (!changedKeys) {
+ /* something happened to the server */
+ return;
+ }
+
rlsFunction = storePrivate->rlsFunction;
if (NULL != storePrivate->rlsContext.retain) {
context_info = storePrivate->rlsContext.info;
context_release = NULL;
}
- (*rlsFunction)(store, changedKeys, storePrivate->rlsContext.info);
+ (*rlsFunction)(store, changedKeys, context_info);
if (context_release) {
context_release(context_info);
}
}
+static CFTypeRef
+rlsRetain(CFTypeRef cf)
+{
+ SCDynamicStoreRef store = (SCDynamicStoreRef)cf;
+ SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
+
+ if (storePrivate->notifyStatus != Using_NotifierInformViaRunLoop) {
+ /* mark RLS active */
+ storePrivate->notifyStatus = Using_NotifierInformViaRunLoop;
+ /* keep a reference to the store */
+ CFRetain(store);
+ }
+
+ return cf;
+}
+
+static void
+rlsRelease(CFTypeRef cf)
+{
+ SCDynamicStoreRef store = (SCDynamicStoreRef)cf;
+ SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
+
+ /* mark RLS inactive */
+ storePrivate->notifyStatus = NotifierNotRegistered;
+ storePrivate->rls = NULL;
+
+ /* release our reference to the store */
+ CFRelease(store);
+
+ return;
+}
+
+
CFRunLoopSourceRef
SCDynamicStoreCreateRunLoopSource(CFAllocatorRef allocator,
SCDynamicStoreRef store,
CFIndex order)
{
- SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
+ SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCreateRunLoopSource:"));
switch (storePrivate->notifyStatus) {
case NotifierNotRegistered :
case Using_NotifierInformViaRunLoop :
- /* set notifier active */
- storePrivate->notifyStatus = Using_NotifierInformViaRunLoop;
+ /* OK to enable runloop notification */
break;
default :
/* sorry, you can only have one notification registered at once */
return NULL;
}
- if (!storePrivate->rls) {
- CFRunLoopSourceContext context;
-
- context.version = 0;
- context.info = (void *)store;
- context.retain = (const void *(*)(const void *))CFRetain;
- context.release = (void (*)(const void *))CFRelease;
- context.copyDescription = (CFStringRef (*)(const void *))CFCopyDescription;
- context.equal = (Boolean (*)(const void *, const void *))CFEqual;
- context.hash = (CFHashCode (*)(const void *))CFHash;
- context.schedule = rlsSchedule;
- context.cancel = rlsCancel;
- context.perform = rlsPerform;
+ if (storePrivate->rls) {
+ CFRetain(storePrivate->rls);
+ } else {
+ CFRunLoopSourceContext context = { 0 // version
+ , (void *)store // info
+ , rlsRetain // retain
+ , rlsRelease // release
+ , CFCopyDescription // copyDescription
+ , CFEqual // equal
+ , CFHash // hash
+ , rlsSchedule // schedule
+ , rlsCancel // cancel
+ , rlsPerform // perform
+ };
storePrivate->rls = CFRunLoopSourceCreate(allocator, order, &context);
}
- return (CFRunLoopSourceRef)CFRetain(storePrivate->rls);
-}
+ if (!storePrivate->rls) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
+ return storePrivate->rls;
+}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
{
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
CFIndex keyCnt;
- void **keyRefs;
+ CFSetRef keys;
+ const void **keyRefs;
CFArrayRef watchedKeys = NULL;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCDynamicStoreCopyWatchedKeyList:"));
- if (isRegex) {
- keyCnt = CFSetGetCount(storePrivate->reKeys);
+ keys = isRegex ? storePrivate->reKeys : storePrivate->keys;
+ keyCnt = CFSetGetCount(keys);
+ if (keyCnt > 0) {
keyRefs = CFAllocatorAllocate(NULL, keyCnt * sizeof(CFStringRef), 0);
- CFSetGetValues(storePrivate->reKeys, keyRefs);
+ CFSetGetValues(keys, keyRefs);
watchedKeys = CFArrayCreate(NULL, keyRefs, keyCnt, &kCFTypeArrayCallBacks);
CFAllocatorDeallocate(NULL, keyRefs);
} else {
- keyCnt = CFSetGetCount(storePrivate->keys);
- keyRefs = CFAllocatorAllocate(NULL, keyCnt * sizeof(CFStringRef), 0);
- CFSetGetValues(storePrivate->keys, keyRefs);
- watchedKeys = CFArrayCreate(NULL, keyRefs, keyCnt, &kCFTypeArrayCallBacks);
- CFAllocatorDeallocate(NULL, keyRefs);
+ watchedKeys = CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks);
}
return watchedKeys;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
/* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key to the server */
status = notifyremove(storePrivate->server,
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
return FALSE;
}
- /* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ /* serialize the key */
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key to the server */
status = confignotify(storePrivate->server,
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* - initial revision
*/
+#include <stdlib.h>
#include <mach/mach.h>
#include <mach/mach_error.h>
#include <servers/bootstrap.h>
(void) pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldThreadState);
/* Remove notification keys */
- if ((keyCnt = CFSetGetCount(storePrivate->keys)) > 0) {
- void **watchedKeys;
+ keyCnt = CFSetGetCount(storePrivate->keys);
+ if (keyCnt > 0) {
+ const void **watchedKeys;
CFArrayRef keysToRemove;
CFIndex i;
}
/* Remove regex notification keys */
- if ((keyCnt = CFSetGetCount(storePrivate->reKeys)) > 0) {
- void **watchedKeys;
+ keyCnt = CFSetGetCount(storePrivate->reKeys);
+ if (keyCnt > 0) {
+ const void **watchedKeys;
CFArrayRef keysToRemove;
CFIndex i;
static const CFRuntimeClass __SCDynamicStoreClass = {
0, // version
- "SCDynamicStore", // className
+ "SCDynamicStore", // className
NULL, // init
NULL, // copy
- __SCDynamicStoreDeallocate, // dealloc
+ __SCDynamicStoreDeallocate, // dealloc
NULL, // equal
NULL, // hash
NULL, // copyFormattingDesc
kern_return_t status;
mach_port_t bootstrap_port;
mach_port_t server;
+ char *server_name;
CFDataRef xmlName; /* serialized name */
xmlData_t myNameRef;
CFIndex myNameLen;
return NULL;
}
- status = bootstrap_look_up(bootstrap_port, SCD_SERVER, &server);
+ server_name = getenv("SCD_SERVER");
+ if (!server_name) {
+ server_name = SCD_SERVER;
+ }
+
+ status = bootstrap_look_up(bootstrap_port, server_name, &server);
switch (status) {
case BOOTSTRAP_SUCCESS :
/* service currently registered, "a good thing" (tm) */
}
/* serialize the name */
- xmlName = CFPropertyListCreateXMLData(NULL, name);
- myNameRef = (xmlData_t)CFDataGetBytePtr(xmlName);
- myNameLen = CFDataGetLength(xmlName);
+ if (!_SCSerialize(name, &xmlName, (void **)&myNameRef, &myNameLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
/* open a new session with the server */
status = configopen(server, myNameRef, myNameLen, &storePrivate->server, (int *)&sc_status);
--- /dev/null
+/*
+ * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ * October 12, 2001 Allan Nathanson <ajn@apple.com>
+ * - initial revision
+ */
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SCDPlugin.h>
+
+
+
+typedef struct childInfo *childInfoRef;
+
+struct childInfo {
+ pid_t pid;
+ SCDPluginExecCallBack callout;
+ void *context;
+ int status;
+ struct rusage rusage;
+ childInfoRef next;
+};
+
+
+/*
+ * Mach port used to notify runloop when a child process
+ * has been reaped.
+ */
+static CFMachPortRef childReaped = NULL;
+
+/*
+ * The following dictionaries contain information about child
+ * processes, reaped processes, and any associated callback
+ * information.
+ *
+ * Important: Access to these dictionaries should only be
+ * made when in a SIGCHLD handler (or when the
+ * childLock mutex is held *AND* the signal
+ * has been blocked).
+ */
+static childInfoRef activeChildren = NULL;
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static inline void
+blockSignal()
+{
+ sigset_t mask = sigmask(SIGCHLD);
+
+ // block SIGCHLD
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) {
+ perror("sigprocmask(SIG_BLOCK)");
+ }
+
+ return;
+}
+
+
+static inline void
+unblockSignal()
+{
+ sigset_t mask = sigmask(SIGCHLD);
+
+ // unblock SIGCHLD
+ if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == -1) {
+ perror("sigprocmask(SIG_UNBLOCK)");
+ }
+
+ return;
+}
+
+
+static void
+reaper(int sigraised)
+{
+ mach_msg_empty_send_t msg;
+ mach_msg_option_t options;
+ kern_return_t status;
+
+ /*
+ * block additional SIGCHLD's until current children have
+ * been reaped.
+ */
+ blockSignal();
+
+ /*
+ * send message to indicate that at least one child is ready
+ * to be reaped.
+ */
+ msg.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
+ msg.header.msgh_size = sizeof(msg);
+ msg.header.msgh_remote_port = CFMachPortGetPort(childReaped);
+ msg.header.msgh_local_port = MACH_PORT_NULL;
+ msg.header.msgh_id = 0;
+ options = MACH_SEND_TIMEOUT;
+ status = mach_msg(&msg.header, /* msg */
+ MACH_SEND_MSG|options, /* options */
+ msg.header.msgh_size, /* send_size */
+ 0, /* rcv_size */
+ MACH_PORT_NULL, /* rcv_name */
+ 0, /* timeout */
+ MACH_PORT_NULL); /* notify */
+
+ return;
+}
+
+
+static void
+childrenReaped(CFMachPortRef port, void *msg, CFIndex size, void *info)
+{
+ pid_t pid = 0;
+ childInfoRef reapedChildren = NULL;
+
+ do {
+ struct rusage rusage;
+ int status;
+
+ pid = wait4(-1, &status, WNOHANG, &rusage);
+ switch (pid) {
+ case -1 : // if error
+ if (errno != ECHILD) {
+ perror("wait4");
+ }
+ break;
+
+ case 0 : // if no more children
+ break;
+
+ default : {
+ childInfoRef last;
+ childInfoRef this;
+
+ // grab the activeChildren mutex
+ pthread_mutex_lock(&lock);
+
+ last = NULL;
+ this = activeChildren;
+ while (this) {
+ if (this->pid == pid) {
+ /* save exit status & usage */
+ this->status = status;
+ this->rusage = rusage;
+
+ /* remove from activeChildren */
+ if (last) {
+ last->next = this->next;
+ } else {
+ activeChildren = this->next;
+ }
+
+ /* add to reapedChildren */
+ this->next = reapedChildren;
+ reapedChildren = this;
+
+ break;
+ } else {
+ /* if not this child */
+ last = this;
+ this = this->next;
+ }
+ }
+
+ // release the activeChildren mutex
+ pthread_mutex_unlock(&lock);
+
+ break;
+ }
+ }
+ } while (pid > 0);
+
+ /*
+ * we need to know about any new children waiting to be reaped so
+ * re-enable the SIGCHLD handler.
+
+ */
+ unblockSignal();
+
+ while (reapedChildren) {
+ childInfoRef child = reapedChildren;
+
+ reapedChildren = reapedChildren->next;
+ (*child->callout)(child->pid,
+ child->status,
+ &child->rusage,
+ child->context);
+ CFAllocatorDeallocate(NULL, child);
+ }
+
+ return;
+}
+
+
+void
+_SCDPluginExecInit()
+{
+ struct sigaction act;
+ CFRunLoopSourceRef rls;
+
+ // create the "a child has been reaped" notification port
+ childReaped = CFMachPortCreate(NULL, childrenReaped, NULL, NULL);
+
+ // set queue limit
+ {
+ mach_port_limits_t limits;
+ kern_return_t status;
+
+ limits.mpl_qlimit = 1;
+ status = mach_port_set_attributes(mach_task_self(),
+ CFMachPortGetPort(childReaped),
+ MACH_PORT_LIMITS_INFO,
+ (mach_port_info_t)&limits,
+ MACH_PORT_LIMITS_INFO_COUNT);
+ if (status != KERN_SUCCESS) {
+ perror("mach_port_set_attributes");
+ }
+ }
+
+ // add to our runloop
+ rls = CFMachPortCreateRunLoopSource(NULL, childReaped, 0);
+ CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
+ CFRelease(rls);
+
+ // enable signal handler
+ act.sa_handler = reaper;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_RESTART|SA_NOCLDSTOP;
+ if (sigaction(SIGCHLD, &act, NULL) == -1) {
+ perror("sigaction");
+ }
+
+ return;
+}
+
+
+pid_t
+_SCDPluginExecCommand(SCDPluginExecCallBack callout,
+ void *context,
+ uid_t uid,
+ gid_t gid,
+ const char *path,
+ char * const argv[])
+{
+ pid_t pid;
+
+ // grab the activeChildren mutex
+ pthread_mutex_lock(&lock);
+
+ pid = fork();
+ switch (pid) {
+ case -1 : { /* if error */
+
+ int status;
+
+ status = errno;
+ printf("fork() failed: %s", strerror(status));
+ errno = status;
+ break;
+ }
+
+ case 0 : { /* if child */
+
+ uid_t curUID = geteuid();
+ gid_t curGID = getegid();
+ int i;
+ int status;
+
+ if (curUID != uid) {
+ (void) setuid(uid);
+ }
+
+ if (curGID != gid) {
+ (void) setgid(gid);
+ }
+
+ /* close any open FDs */
+ for (i = getdtablesize()-1; i>=0; i--) close(i);
+ open("/dev/null", O_RDWR, 0);
+ dup(0);
+ dup(0);
+
+ /* execute requested command */
+ (void) execv(path, argv);
+
+ /* if the execv failed */
+ status = W_EXITCODE(errno, 0);
+ _exit (WEXITSTATUS(status));
+ }
+
+ default : { /* if parent */
+
+ if (callout) {
+ childInfoRef child;
+
+ // create child process info
+ child = CFAllocatorAllocate(NULL, sizeof(struct childInfo), 0);
+ bzero(child, sizeof(struct childInfo));
+ child->pid = pid;
+ child->callout = callout;
+ child->context = context;
+
+ // add the new child to the activeChildren list
+ child->next = activeChildren;
+ activeChildren = child;
+ }
+ break;
+ }
+ }
+
+ // release the activeChildren mutex
+ pthread_mutex_unlock(&lock);
+
+ return pid;
+}
#define _SCDPLUGIN_H
#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <CoreFoundation/CoreFoundation.h>
typedef void (*SCDynamicStoreBundlePrimeFunction) ();
+/*!
+ @typedef SCDPluginExecCallBack
+ @discussion Type of the callback function used when a child process
+ started by a plug-in has exited.
+ @param pid The process id of the child which has exited.
+ @param status The exit status of the child which has exited.
+ @param rusage A summary of the resources used by the child process
+ and all its children.
+ @param context The callback argument specified on the call
+ to _SCDPluginExecCommand().
+ */
+typedef void (*SCDPluginExecCallBack) (pid_t pid,
+ int status,
+ struct rusage *rusage,
+ void *context);
+
+
__BEGIN_DECLS
+/*!
+ @function _SCDPluginExecCommand
+ @discussion Starts a child process.
+ @param callout The function to be called when the child
+ process exits. A NULL value can be specified if no
+ callouts are desired.
+ @param context A argument which will be passed
+ to the callout function.
+ @param uid The desired user id of the child process.
+ @param gid The desired group id of the child process.
+ @param path The command to be executed.
+ @param argv The arguments to be passed to the child process.
+ @result The process ID of the child.
+ */
+pid_t
+_SCDPluginExecCommand (
+ SCDPluginExecCallBack callout,
+ void *context,
+ uid_t uid,
+ gid_t gid,
+ const char *path,
+ char * const argv[]
+ );
+
__END_DECLS
#endif /* _SCDPLUGIN_H */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <mach/mach_error.h>
#include <pthread.h>
+Boolean
+_SCSerialize(CFPropertyListRef obj,
+ CFDataRef *xml,
+ void **dataRef,
+ CFIndex *dataLen)
+{
+ CFDataRef myXml;
+
+ if (!obj) {
+ /* if no object to serialize */
+ return FALSE;
+ }
+
+ if (!xml && !(dataRef && dataLen)) {
+ /* if not keeping track of allocated space */
+ return FALSE;
+ }
+
+ myXml = CFPropertyListCreateXMLData(NULL, obj);
+ if (!myXml) {
+ SCLog(TRUE, LOG_ERR, CFSTR("CFPropertyListCreateXMLData() failed"));
+ if (xml) *xml = NULL;
+ if (dataRef) *dataRef = NULL;
+ if (dataLen) *dataLen = 0;
+ return FALSE;
+ }
+
+ if (xml) {
+ *xml = myXml;
+ if (dataRef) {
+ *dataRef = (void *)CFDataGetBytePtr(myXml);
+ }
+ if (dataLen) {
+ *dataLen = CFDataGetLength(myXml);
+ }
+ } else {
+ kern_return_t status;
+
+ *dataLen = CFDataGetLength(myXml);
+ status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
+ if (status != KERN_SUCCESS) {
+ SCLog(TRUE,
+ LOG_ERR,
+ CFSTR("vm_allocate(): %s"),
+ mach_error_string(status));
+ CFRelease(myXml);
+ *dataRef = NULL;
+ *dataLen = 0;
+ return FALSE;
+ }
+
+ bcopy((char *)CFDataGetBytePtr(myXml), *dataRef, *dataLen);
+ CFRelease(myXml);
+ }
+
+ return TRUE;
+}
+
+
+Boolean
+_SCUnserialize(CFPropertyListRef *obj,
+ void *dataRef,
+ CFIndex dataLen)
+{
+ kern_return_t status;
+ CFDataRef xml;
+ CFStringRef xmlError;
+
+ if (!obj) {
+ return FALSE;
+ }
+
+ xml = CFDataCreate(NULL, (void *)dataRef, dataLen);
+ status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
+ if (status != KERN_SUCCESS) {
+ SCLog(_sc_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
+ /* non-fatal???, proceed */
+ }
+ *obj = CFPropertyListCreateFromXMLData(NULL,
+ xml,
+ kCFPropertyListImmutable,
+ &xmlError);
+ CFRelease(xml);
+
+ if (!obj) {
+ if (xmlError) {
+ SCLog(TRUE,
+ LOG_ERR,
+ CFSTR("CFPropertyListCreateFromXMLData() failed: %@"),
+ xmlError);
+ CFRelease(xmlError);
+ }
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
void
__showMachPortStatus()
{
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
/* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key to the server */
status = configremove(storePrivate->server,
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
/* serialize the key/value pairs to set*/
if (keysToSet) {
- xmlSet = CFPropertyListCreateXMLData(NULL, keysToSet);
- mySetRef = (xmlData_t)CFDataGetBytePtr(xmlSet);
- mySetLen = CFDataGetLength(xmlSet);
+ if (!_SCSerialize(keysToSet, &xmlSet, (void **)&mySetRef, &mySetLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
}
/* serialize the keys to remove */
if (keysToRemove) {
- xmlRemove = CFPropertyListCreateXMLData(NULL, keysToRemove);
- myRemoveRef = (xmlData_t)CFDataGetBytePtr(xmlRemove);
- myRemoveLen = CFDataGetLength(xmlRemove);
+ if (!_SCSerialize(keysToRemove, &xmlRemove, (void **)&myRemoveRef, &myRemoveLen)) {
+ if (xmlSet) CFRelease(xmlSet);
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
}
/* serialize the keys to notify */
if (keysToNotify) {
- xmlNotify = CFPropertyListCreateXMLData(NULL, keysToNotify);
- myNotifyRef = (xmlData_t)CFDataGetBytePtr(xmlNotify);
- myNotifyLen = CFDataGetLength(xmlNotify);
+ if (!_SCSerialize(keysToNotify, &xmlNotify, (void **)&myNotifyRef, &myNotifyLen)) {
+ if (xmlSet) CFRelease(xmlSet);
+ if (xmlRemove) CFRelease(xmlRemove);
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
}
/* send the keys and patterns, fetch the associated result from the server */
return FALSE;
}
- /* serialize the key and data */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ /* serialize the key */
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
- xmlData = CFPropertyListCreateXMLData(NULL, value);
- myDataRef = (xmlData_t)CFDataGetBytePtr(xmlData);
- myDataLen = CFDataGetLength(xmlData);
+ /* serialize the data */
+ if (!_SCSerialize(value, &xmlData, (void **)&myDataRef, &myDataLen)) {
+ CFRelease(xmlKey);
+ _SCErrorSet(kSCStatusFailed);
+ return NULL;
+ }
/* send the key & data to the server, get new instance id */
status = configset(storePrivate->server,
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
/* serialize the key */
- xmlKey = CFPropertyListCreateXMLData(NULL, key);
- myKeyRef = (xmlData_t)CFDataGetBytePtr(xmlKey);
- myKeyLen = CFDataGetLength(xmlKey);
+ if (!_SCSerialize(key, &xmlKey, (void **)&myKeyRef, &myKeyLen)) {
+ _SCErrorSet(kSCStatusFailed);
+ return FALSE;
+ }
/* send the key to the server */
status = configtouch(storePrivate->server,
/*
- * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2001-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
data for.
@result A non-NULL CFDataRef containing the option data,
NULL otherwise.
-
+
The return value must NOT be released.
*/
CFDataRef
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
gid_t *gid
);
+/*!
+ @function SCDynamicStoreCopyLocalHostName
+ @discussion Gets the current local host name.
+
+ See SCDynamicStoreKeyCreateHostNames() for notification
+ key information.
+ @param store An SCDynamicStoreRef that should be used for communication
+ with the server.
+ If NULL, a temporary session will be used.
+ @result The current local host name;
+ NULL if the name has not been set or if an error was encountered.
+ You must release the returned value.
+ */
+CFStringRef
+SCDynamicStoreCopyLocalHostName (
+ SCDynamicStoreRef store
+ );
+
+/*!
+ @function SCDynamicStoreCopyLocation
+ @discussion Gets the current "location" identifier.
+ @param store An SCDynamicStoreRef that should be used for communication
+ with the server.
+ If NULL, a temporary session will be used.
+ @result A string representing the current "location" identifier;
+ NULL if no "location" identifier has been defined or if an error
+ was encountered.
+ You must release the returned value.
+ */
+CFStringRef
+SCDynamicStoreCopyLocation (
+ SCDynamicStoreRef store
+ );
+
/*!
@function SCDynamicStoreCopyProxies
@discussion Gets the current internet proxy settings.
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFAllocatorRef allocator
);
+/*!
+ @function SCDynamicStoreKeyCreateHostNames
+ @discussion Creates a key that can be used in conjunction with
+ SCDynamicStoreSetNotificationKeys() to receive
+ notifications when the HostNames entity changes. The
+ HostNames entity contains the LocalHostName.
+ @result A notification string for the HostNames entity.
+*/
+CFStringRef
+SCDynamicStoreKeyCreateHostNames (
+ CFAllocatorRef allocator
+ );
+
+/*!
+ @function SCDynamicStoreKeyCreateLocation
+ @discussion Creates a key that can be used in conjunction with
+ SCDynamicStoreSetNotificationKeys() to receive
+ notifications when the "location" identifier changes.
+ @result A notification string for the current "location" identifier.
+*/
+CFStringRef
+SCDynamicStoreKeyCreateLocation (
+ CFAllocatorRef allocator
+ );
+
/*!
@function SCDynamicStoreKeyCreateProxies
@discussion Creates a key that can be used by the SCDynamicStoreSetNotificationKeys()
--- /dev/null
+/*
+ * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ * Nov 28, 2001 Allan Nathanson <ajn@apple.com>
+ * - initial revision
+ */
+
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCValidation.h>
+#include <SystemConfiguration/SCPrivate.h>
+
+CFStringRef
+SCDynamicStoreKeyCreateLocation(CFAllocatorRef allocator)
+{
+ return CFRetain(kSCDynamicStoreDomainSetup);
+}
+
+
+CFStringRef
+SCDynamicStoreCopyLocation(SCDynamicStoreRef store)
+{
+ CFDictionaryRef dict = NULL;
+ CFStringRef key;
+ CFStringRef location = NULL;
+ Boolean tempSession = FALSE;
+
+ if (!store) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreCopyLocation"),
+ NULL,
+ NULL);
+ if (!store) {
+ SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
+ return NULL;
+ }
+ tempSession = TRUE;
+ }
+
+ key = SCDynamicStoreKeyCreateLocation(NULL);
+ dict = SCDynamicStoreCopyValue(store, key);
+ CFRelease(key);
+ if (!isA_CFDictionary(dict)) {
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ location = CFDictionaryGetValue(dict, kSCDynamicStorePropSetupCurrentSet);
+ if (!isA_CFString(location)) {
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ CFRetain(location);
+
+ done :
+
+ if (tempSession) CFRelease(store);
+ if (dict) CFRelease(dict);
+
+ return location;
+}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
case PPP_RUNNING :
/* if we're really UP and RUNNING */
break;
+ case PPP_ONHOLD :
+ /* if we're effectively UP and RUNNING */
+ break;
case PPP_IDLE :
/* if we're not connected at all */
SCLog(_sc_debug, LOG_INFO, CFSTR(" PPP link idle, dial-on-traffic to connect"));
Boolean haveDNS = FALSE;
int i;
Boolean ok = TRUE;
+#ifdef CHECK_IPV6_REACHABILITY
struct addrinfo *res = NULL;
struct addrinfo *resP;
+#endif /* CHECK_IPV6_REACHABILITY */
CFArrayRef serviceOrder = NULL;
SCDynamicStoreRef store = NULL;
/*
* resolve the nodename into an address
*/
+
+#ifdef CHECK_IPV6_REACHABILITY
i = getaddrinfo(nodename, NULL, NULL, &res);
if (i != 0) {
SCLog(_sc_verbose, LOG_ERR,
LOG_INFO,
CFSTR("getaddrinfo() returned no addresses, try gethostbyname()"));
#endif /* DEBUG */
+#endif /* CHECK_IPV6_REACHABILITY */
h = gethostbyname(nodename);
if (h && h->h_length) {
_CheckReachabilityFree(config, active, serviceOrder, defaultRoute);
if (store) CFRelease(store);
+#ifdef CHECK_IPV6_REACHABILITY
if (res) freeaddrinfo(res);
+#endif /* CHECK_IPV6_REACHABILITY */
return ok;
}
/*
- * Copyright(c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright(c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFArrayRef keys;
SCPreferencesPrivateRef sessionPrivate = (SCPreferencesPrivateRef)session;
CFIndex prefsCnt;
- void **prefsKeys;
+ const void **prefsKeys;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesCopyKeyList:"));
prefsCnt = CFDictionaryGetCount(sessionPrivate->prefs);
- prefsKeys = CFAllocatorAllocate(allocator, prefsCnt * sizeof(CFStringRef), 0);
- CFDictionaryGetKeysAndValues(sessionPrivate->prefs, prefsKeys, NULL);
- keys = CFArrayCreate(allocator, prefsKeys, prefsCnt, &kCFTypeArrayCallBacks);
- CFAllocatorDeallocate(allocator, prefsKeys);
+ if (prefsCnt > 0) {
+ prefsKeys = CFAllocatorAllocate(allocator, prefsCnt * sizeof(CFStringRef), 0);
+ CFDictionaryGetKeysAndValues(sessionPrivate->prefs, prefsKeys, NULL);
+ keys = CFArrayCreate(allocator, prefsKeys, prefsCnt, &kCFTypeArrayCallBacks);
+ CFAllocatorDeallocate(allocator, prefsKeys);
+ } else {
+ keys = CFArrayCreate(allocator, NULL, 0, &kCFTypeArrayCallBacks);
+ }
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" keys = %@"), keys);
/*
- * Copyright(c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright(c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
/* synchronize this sessions prefs/signature */
newPrivate = (SCPreferencesPrivateRef)newPrefs;
CFRelease(sessionPrivate->prefs);
- sessionPrivate->prefs = CFRetain(newPrivate->prefs);
+ sessionPrivate->prefs = newPrivate->prefs;
+ CFRetain(sessionPrivate->prefs);
CFRelease(sessionPrivate->signature);
sessionPrivate->signature = CFRetain(newPrivate->signature);
CFRelease(newPrefs);
/*
- * Copyright(c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright(c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <SystemConfiguration/SystemConfiguration.h>
#include <SystemConfiguration/SCPrivate.h>
+#include <SystemConfiguration/SCValidation.h>
#include "SCPreferencesInternal.h"
#include <fcntl.h>
prefsPrivate->signature = __SCPSignatureFromStatbuf(&statBuf);
if (statBuf.st_size > 0) {
+ CFDictionaryRef dict;
+
/*
* extract property list
*/
/*
* load preferences
*/
- prefsPrivate->prefs = (CFMutableDictionaryRef)
- CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListMutableContainers,
- &xmlError);
+ dict = CFPropertyListCreateFromXMLData(NULL,
+ xmlData,
+ kCFPropertyListImmutable,
+ &xmlError);
CFRelease(xmlData);
- if (!prefsPrivate->prefs) {
+ if (!dict) {
/* corrupt prefs file, start fresh */
if (xmlError) {
- SCLog(_sc_verbose, LOG_DEBUG,
- CFSTR("_SCPOpen CFPropertyListCreateFromXMLData(): %@"),
- xmlError);
+ SCLog(TRUE, LOG_ERR,
+ CFSTR("_SCPOpen CFPropertyListCreateFromXMLData(): %@"),
+ xmlError);
CFRelease(xmlError);
}
goto create_2;
/*
* make sure that we've got a dictionary
*/
- if (CFGetTypeID(prefsPrivate->prefs) != CFDictionaryGetTypeID()) {
+ if (!isA_CFDictionary(dict)) {
/* corrupt prefs file, start fresh */
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCPOpen CFGetTypeID(): not a dictionary."));
- CFRelease(prefsPrivate->prefs);
- prefsPrivate->prefs = NULL;
+ CFRelease(dict);
goto create_2;
}
+
+ prefsPrivate->prefs = CFDictionaryCreateMutableCopy(NULL, 0, dict);
+ CFRelease(dict);
}
create_2 :
/*
- * Copyright(c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright(c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*/
#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCValidation.h>
#include <SystemConfiguration/SCPrivate.h>
+#include "SCPreferencesInternal.h"
+
+#define MAXLINKS 8
static CFArrayRef
normalizePath(CFStringRef path)
}
-static int
-getPath(SCPreferencesRef session, CFStringRef path, CFMutableDictionaryRef *entity)
+static Boolean
+getPath(SCPreferencesRef session, CFStringRef path, CFDictionaryRef *entity)
{
+ CFStringRef element;
CFArrayRef elements;
CFIndex i;
+ CFStringRef link;
CFIndex nElements;
- int status = kSCStatusFailed;
- CFMutableDictionaryRef value = NULL;
+ CFIndex nLinks = 0;
+ Boolean ok = FALSE;
+ SCPreferencesPrivateRef sessionPrivate = (SCPreferencesPrivateRef)session;
+ CFDictionaryRef value = NULL;
elements = normalizePath(path);
if (elements == NULL) {
- return kSCStatusNoKey;
- }
-
- /* get preferences key */
- value = (CFMutableDictionaryRef)SCPreferencesGetValue(session,
- CFArrayGetValueAtIndex(elements, 0));
- if (!value) {
- status = kSCStatusNoKey;
- goto done;
+ _SCErrorSet(kSCStatusNoKey);
+ return FALSE;
}
- if (CFGetTypeID(value) != CFDictionaryGetTypeID()) {
- status = kSCStatusNoKey;
- goto done;
- }
+ restart :
nElements = CFArrayGetCount(elements);
- for (i=1; i<nElements; i++) {
- CFStringRef element;
-
+ for (i=0; i<nElements; i++) {
element = CFArrayGetValueAtIndex(elements, i);
- value = (CFMutableDictionaryRef)CFDictionaryGetValue(value, element);
+ if (i == 0) {
+ sessionPrivate->accessed = TRUE;
+ value = CFDictionaryGetValue(sessionPrivate->prefs,
+ CFArrayGetValueAtIndex(elements, 0));
+ } else {
+ value = CFDictionaryGetValue(value, element);
+ }
if (value == NULL) {
- /* if (parent) path component does not exist */
- status = kSCStatusNoKey;
+ /* if path component does not exist */
+ _SCErrorSet(kSCStatusNoKey);
goto done;
}
- if (CFGetTypeID(value) != CFDictionaryGetTypeID()) {
- status = kSCStatusNoKey;
+ if (!isA_CFDictionary(value)) {
+ /* if path component not a dictionary */
+ _SCErrorSet(kSCStatusNoKey);
goto done;
}
+ if ((i < nElements-1) &&
+ CFDictionaryGetValueIfPresent(value, kSCResvLink, (const void **)&link)) {
+ /*
+ * if not the last path component and this
+ * element is a link
+ */
+ CFArrayRef linkElements;
+ CFMutableArrayRef newElements;
+
+ if (++nLinks > MAXLINKS) {
+ /* if we are chasing our tail */
+ _SCErrorSet(kSCStatusMaxLink);
+ goto done;
+ }
+
+ linkElements = normalizePath(link);
+ if (linkElements == NULL) {
+ /* if the link is bad */
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ newElements = CFArrayCreateMutableCopy(NULL, 0, linkElements);
+ CFArrayAppendArray(newElements,
+ elements,
+ CFRangeMake(i+1, nElements-i-1));
+ CFRelease(elements);
+ elements = newElements;
+
+ goto restart;
+ }
}
*entity = value;
- status = kSCStatusOK;
+ ok = TRUE;
done :
CFRelease(elements);
- return status;
+ return ok;
+}
+
+
+static Boolean
+setPath(SCPreferencesRef session, CFStringRef path, CFDictionaryRef entity)
+{
+ CFStringRef element;
+ CFArrayRef elements;
+ CFIndex i;
+ CFStringRef link;
+ CFIndex nElements;
+ CFIndex nLinks = 0;
+ CFDictionaryRef newEntity = NULL;
+ CFDictionaryRef node = NULL;
+ CFMutableArrayRef nodes;
+ Boolean ok = FALSE;
+ SCPreferencesPrivateRef sessionPrivate = (SCPreferencesPrivateRef)session;
+
+ elements = normalizePath(path);
+ if (elements == NULL) {
+ _SCErrorSet(kSCStatusNoKey);
+ return FALSE;
+ }
+
+ restart :
+
+ nElements = CFArrayGetCount(elements);
+ nodes = CFArrayCreateMutable(NULL, nElements-1, &kCFTypeArrayCallBacks);
+ for (i=0; i<nElements-1; i++) {
+ element = CFArrayGetValueAtIndex(elements, i);
+ if (i == 0) {
+ sessionPrivate->accessed = TRUE;
+ node = CFDictionaryGetValue(sessionPrivate->prefs, element);
+ } else {
+ node = CFDictionaryGetValue(node, element);
+
+ }
+
+ if (node) {
+ /* if path component exists */
+ CFArrayAppendValue(nodes, node);
+ } else {
+ /* if path component does not exist */
+ node = CFDictionaryCreate(NULL,
+ NULL,
+ NULL,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ CFArrayAppendValue(nodes, node);
+ CFRelease(node);
+ }
+
+ if (!isA_CFDictionary(node)) {
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ if ((i < nElements-1) &&
+ CFDictionaryGetValueIfPresent(node, kSCResvLink, (const void **)&link)) {
+ /*
+ * if not the last path component and this
+ * element is a link
+ */
+ CFArrayRef linkElements;
+ CFMutableArrayRef newElements;
+
+ if (++nLinks > MAXLINKS) {
+ /* if we are chasing our tail */
+ _SCErrorSet(kSCStatusMaxLink);
+ goto done;
+ }
+
+ linkElements = normalizePath(link);
+ if (linkElements == NULL) {
+ /* if the link is bad */
+ _SCErrorSet(kSCStatusNoKey);
+ goto done;
+ }
+
+ newElements = CFArrayCreateMutableCopy(NULL, 0, linkElements);
+ CFArrayAppendArray(newElements,
+ elements,
+ CFRangeMake(i+1, nElements-i-1));
+ CFRelease(elements);
+ elements = newElements;
+
+ CFRelease(nodes);
+ goto restart;
+ }
+ }
+
+ if (entity) {
+ newEntity = CFRetain(entity);
+ }
+ for (i=nElements-1; i>=0; i--) {
+ element = CFArrayGetValueAtIndex(elements, i);
+ if (i == 0) {
+ if (newEntity) {
+ CFDictionarySetValue(sessionPrivate->prefs, element, newEntity);
+ } else {
+ CFDictionaryRemoveValue(sessionPrivate->prefs, element);
+ }
+ sessionPrivate->changed = TRUE;
+ ok = TRUE;
+ } else {
+ CFMutableDictionaryRef newNode;
+
+ node = CFArrayGetValueAtIndex(nodes, i-1);
+ newNode = CFDictionaryCreateMutableCopy(NULL, 0, node);
+ if (newEntity) {
+ CFDictionarySetValue(newNode, element, newEntity);
+ CFRelease(newEntity);
+ } else {
+ CFDictionaryRemoveValue(newNode, element);
+ }
+ newEntity = newNode;
+ }
+ }
+ if (newEntity) {
+ CFRelease(newEntity);
+ }
+
+ done :
+
+ CFRelease(nodes);
+ CFRelease(elements);
+ return ok;
}
SCPreferencesPathCreateUniqueChild(SCPreferencesRef session,
CFStringRef prefix)
{
- int status;
- CFMutableDictionaryRef value;
+ CFStringRef child;
CFStringRef newPath = NULL;
- Boolean newValue = FALSE;
- CFIndex i;
CFMutableDictionaryRef newDict = NULL;
+ CFUUIDRef uuid;
+ CFDictionaryRef entity;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathCreateUniqueChild:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" prefix = %@"), prefix);
- status = getPath(session, prefix, &value);
- switch (status) {
- case kSCStatusOK :
- break;
- case kSCStatusNoKey :
- value = CFDictionaryCreateMutable(NULL,
- 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- newValue = TRUE;
- break;
- default :
+ if (getPath(session, prefix, &entity)) {
+ // if prefix path exists
+ if (CFDictionaryContainsKey(entity, kSCResvLink)) {
+ /* the path is a link... */
+ _SCErrorSet(kSCStatusFailed);
return NULL;
- }
-
- if (CFGetTypeID(value) != CFDictionaryGetTypeID()) {
- /* if specified path is not a dictionary */
- status = kSCStatusNoKey;
- goto error;
- }
-
- if (CFDictionaryContainsKey(value, kSCResvLink)) {
- /* the path is a link... */
- status = kSCStatusFailed;
- goto error;
- }
-
- i = 0;
- while (TRUE) {
- CFStringRef pathComponent;
- Boolean found;
-
- pathComponent = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), i);
- found = CFDictionaryContainsKey(value, pathComponent);
- CFRelease(pathComponent);
-
- if (!found) {
- /* if we've identified the next unique key */
- newPath = CFStringCreateWithFormat(NULL,
- NULL,
- CFSTR("%@/%i"),
- prefix,
- i);
- break;
}
- i++;
+ } else if (SCError() != kSCStatusNoKey) {
+ // if any error except for a missing prefix path component
+ return NULL;
}
+ uuid = CFUUIDCreate(NULL);
+ child = CFUUIDCreateString(NULL, uuid);
+ newPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@"), prefix, child);
+ CFRelease(child);
+ CFRelease(uuid);
+
/* save the new dictionary */
newDict = CFDictionaryCreateMutable(NULL,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- if (!SCPreferencesPathSetValue(session, newPath, newDict)) {
- goto error;
+ if (setPath(session, newPath, newDict)) {
+ SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" child = %@"), newPath);
+ } else {
+ CFRelease(newPath);
+ newPath = NULL;
}
CFRelease(newDict);
- SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" child = %@"), newPath);
- if (newValue) CFRelease(value);
return newPath;
-
- error :
-
- if (newDict) CFRelease(newDict);
- if (newValue) CFRelease(value);
- if (newPath) CFRelease(newPath);
- return NULL;
}
SCPreferencesPathGetValue(SCPreferencesRef session,
CFStringRef path)
{
- int status;
- CFMutableDictionaryRef entity;
- CFStringRef entityLink;
+ CFDictionaryRef entity;
+ CFStringRef entityLink;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathGetValue:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" path = %@"), path);
- status = getPath(session, path, &entity);
- if (status != kSCStatusOK) {
+ if (!getPath(session, path, &entity)) {
return NULL;
}
-/* XXXX Add code here to chase multiple links XXXXX */
-
- if ((CFGetTypeID(entity) == CFDictionaryGetTypeID()) &&
- (CFDictionaryGetValueIfPresent(entity, kSCResvLink, (void **)&entityLink))) {
- /* if this is a dictionary AND it is a link */
- status = getPath(session, entityLink, &entity);
- if (status != kSCStatusOK) {
- /* if it was a bad link */
- return NULL;
- }
+ if (isA_CFDictionary(entity) &&
+ (CFDictionaryGetValueIfPresent(entity, kSCResvLink, (const void **)&entityLink))) {
+ /* if this is a dictionary AND it is a link */
+ if (!getPath(session, entityLink, &entity)) {
+ /* if it was a bad link */
+ return NULL;
+ }
}
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" value = %@"), entity);
SCPreferencesPathGetLink(SCPreferencesRef session,
CFStringRef path)
{
- int status;
- CFMutableDictionaryRef entity;
- CFStringRef entityLink;
+ CFDictionaryRef entity;
+ CFStringRef entityLink;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathGetLink:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" path = %@"), path);
- status = getPath(session, path, &entity);
- if (status != kSCStatusOK) {
+ if (!getPath(session, path, &entity)) {
return NULL;
}
- if ((CFGetTypeID(entity) == CFDictionaryGetTypeID()) &&
- (CFDictionaryGetValueIfPresent(entity, kSCResvLink, (void **)&entityLink))) {
- /* if this is a dictionary AND it is a link */
+ if (isA_CFDictionary(entity) &&
+ (CFDictionaryGetValueIfPresent(entity, kSCResvLink, (const void **)&entityLink))) {
+ /* if this is a dictionary AND it is a link */
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" link = %@"), entityLink);
return entityLink;
}
CFStringRef path,
CFDictionaryRef value)
{
- CFMutableDictionaryRef element;
- CFArrayRef elements = NULL;
- CFIndex i;
- CFIndex nElements;
- Boolean newRoot = FALSE;
Boolean ok;
- CFMutableDictionaryRef root = NULL;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathSetValue:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" path = %@"), path);
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" value = %@"), value);
- elements = normalizePath(path);
- if (elements == NULL) {
- _SCErrorSet(kSCStatusNoKey);
+ if (!value) {
+ _SCErrorSet(kSCStatusInvalidArgument);
return FALSE;
}
- /* get preferences key */
- root = (CFMutableDictionaryRef)SCPreferencesGetValue(session,
- CFArrayGetValueAtIndex(elements, 0));
- if (!root) {
- root = CFDictionaryCreateMutable(NULL,
- 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- newRoot = TRUE;
- }
-
- nElements = CFArrayGetCount(elements);
- if (nElements == 1) {
- /* if we are only updating the data associated with the preference key */
- if (newRoot) {
- CFRelease(root);
- newRoot = FALSE;
- }
- root = (CFMutableDictionaryRef)value;
- }
-
- element = root;
- for (i=1; i<nElements-1; i++) {
- CFStringRef pathComponent;
- CFMutableDictionaryRef tmpElement;
-
- pathComponent = CFArrayGetValueAtIndex(elements, i);
- tmpElement = (void *)CFDictionaryGetValue(element, pathComponent);
- if (tmpElement == NULL) {
- /* if (parent) path component does not exist */
- tmpElement = CFDictionaryCreateMutable(NULL,
- 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(element, pathComponent, tmpElement);
- CFRelease(tmpElement);
- }
- element = tmpElement;
- }
-
- if (nElements > 1) {
- CFDictionarySetValue(element,
- CFArrayGetValueAtIndex(elements, nElements-1),
- value);
- }
- ok = SCPreferencesSetValue(session, CFArrayGetValueAtIndex(elements, 0), root);
- if (newRoot) CFRelease(root);
- CFRelease(elements);
+ ok = setPath(session, path, value);
return ok;
}
CFStringRef link)
{
CFMutableDictionaryRef dict;
+ CFDictionaryRef entity;
Boolean ok;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathSetLink:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" path = %@"), path);
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" link = %@"), link);
+ if (!link) {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return FALSE;
+ }
+
+ if (!getPath(session, link, &entity)) {
+ // if bad link
+ return FALSE;
+ }
+
dict = CFDictionaryCreateMutable(NULL,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(dict, kSCResvLink, link);
- ok = SCPreferencesPathSetValue(session, path, dict);
+ ok = setPath(session, path, dict);
CFRelease(dict);
return ok;
SCPreferencesPathRemoveValue(SCPreferencesRef session,
CFStringRef path)
{
- CFMutableDictionaryRef element;
CFArrayRef elements = NULL;
- CFIndex i;
- CFIndex nElements;
Boolean ok = FALSE;
- CFMutableDictionaryRef root = NULL;
+ CFDictionaryRef value;
SCLog(_sc_verbose, LOG_DEBUG, CFSTR("SCPreferencesPathRemoveValue:"));
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" path = %@"), path);
+ if (!getPath(session, path, &value)) {
+ // if no such path
+ return FALSE;
+ }
+
elements = normalizePath(path);
if (elements == NULL) {
_SCErrorSet(kSCStatusNoKey);
return FALSE;
}
- /* get preferences key */
- root = (CFMutableDictionaryRef)SCPreferencesGetValue(session,
- CFArrayGetValueAtIndex(elements, 0));
- if (!root) {
- goto done;
- }
-
- nElements = CFArrayGetCount(elements);
- if (nElements == 1) {
- /* if we are removing the data associated with the preference key */
- ok = SCPreferencesRemoveValue(session, CFArrayGetValueAtIndex(elements, 0));
- goto done;
- }
-
- element = root;
- for (i=1; i<nElements-1; i++) {
- CFStringRef pathComponent;
- CFMutableDictionaryRef tmpElement;
-
- pathComponent = CFArrayGetValueAtIndex(elements, i);
- tmpElement = (void *)CFDictionaryGetValue(element, pathComponent);
- if (tmpElement == NULL) {
- goto done;
- }
- element = tmpElement;
- }
-
- CFDictionaryRemoveValue(element,
- CFArrayGetValueAtIndex(elements, nElements-1));
- ok = SCPreferencesSetValue(session, CFArrayGetValueAtIndex(elements, 0), root);
-
- done :
+ ok = setPath(session, path, NULL);
CFRelease(elements);
return ok;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@param session The SCPreferencesRef handle that should be used to
communicate with the APIs.
@param prefix A string that represents the parent path.
- @param newPath A pointer to memory that will be filled with a
- string representing the new child path.
@result A string representing the new (unique) child path; NULL
if the specified path does not exist.
*/
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
Note: In order to commit these changes to permanent storage a call
must be made to SCPreferencesCommitChanges().
+ A call to SCPreferencesApplyChanges() is also required for the new
+ name to become active.
@param prefs An SCPreferencesRef that should be used for all API calls.
@param name The computer/host name to be set.
@param nameEncoding The encoding associated with the computer/host name.
CFStringEncoding nameEncoding
);
+/*!
+ @function SCPreferencesSetLocalHostName
+ @discussion Updates the local host name in the system preferences.
+
+ Note: In order to commit these changes to permanent storage a call
+ must be made to SCPreferencesCommitChanges().
+ A call to SCPreferencesApplyChanges() is also required for the new
+ name to become active.
+ @param prefs An SCPreferencesRef that should be used for all API calls.
+ @param name The local host name to be set.
+
+ Note: the string must conform to the naming conventions of a DNS host
+ name as specified in RFC 1034 (section 3.5).
+ @result A boolean indicating the success (or failure) of the call.
+ */
+Boolean
+SCPreferencesSetLocalHostName (
+ SCPreferencesRef prefs,
+ CFStringRef name
+ );
+
__END_DECLS
#endif /* _SCPREFERENCESSETSPECIFIC_H */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*/
void _SCErrorSet (int error);
+/*
+ @function _SCSerialize
+ @discussion Serialize a CFPropertyList object for passing
+ to/from configd.
+ @param obj CFPropertyList object to serialize
+ @param xml A pointer to a CFDataRef, NULL if data should be
+ vm_allocated.
+ @param data A pointer to the newly allocated/serialized data
+ @param dataLen A pointer to the length in bytes of the newly
+ allocated/serialized data
+ */
+Boolean _SCSerialize (CFPropertyListRef obj,
+ CFDataRef *xml,
+ void **dataRef,
+ CFIndex *dataLen);
+
+/*
+ @function _SCUnserialize
+ @discussion Unserialize a stream of bytes passed from/to configd
+ into a CFPropertyList object.
+ @param obj A pointer to memory that will be filled with the CFPropertyList
+ associated with the stream of bytes.
+ @param data A pointer to the serialized data
+ @param dataLen A pointer to the length of the serialized data
+ */
+Boolean _SCUnserialize (CFPropertyListRef *obj,
+ void *dataRef,
+ CFIndex dataLen);
+
/*
@function SCLog
@discussion Conditionally issue a log message.
*/
#include <SystemConfiguration/SystemConfiguration.h>
-#include <SystemConfiguration/SCPrivate.h>
#include <SystemConfiguration/SCValidation.h>
+#include <SystemConfiguration/SCPrivate.h>
CFStringRef
SCDynamicStoreKeyCreateProxies(CFAllocatorRef allocator)
{
CFDictionaryRef dict = NULL;
CFStringRef key;
- SCDynamicStoreRef mySession = store;
CFDictionaryRef proxies = NULL;
+ Boolean tempSession = FALSE;
if (!store) {
- mySession = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreCopyConsoleUser"),
- NULL,
- NULL);
- if (!mySession) {
+ store = SCDynamicStoreCreate(NULL,
+ CFSTR("SCDynamicStoreCopyConsoleUser"),
+ NULL,
+ NULL);
+ if (!store) {
SCLog(_sc_verbose, LOG_INFO, CFSTR("SCDynamicStoreCreate() failed"));
return NULL;
}
+ tempSession = TRUE;
}
key = SCDynamicStoreKeyCreateProxies(NULL);
- dict = SCDynamicStoreCopyValue(mySession, key);
+ dict = SCDynamicStoreCopyValue(store, key);
CFRelease(key);
if (!isA_CFDictionary(dict)) {
_SCErrorSet(kSCStatusNoKey);
done :
- if (!store && mySession) CFRelease(mySession);
- if (dict) CFRelease(dict);
+ if (tempSession) CFRelease(store);
+ if (dict) CFRelease(dict);
return proxies;
}
/*
- * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2001-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
return (isA_CFType(obj, CFStringGetTypeID()));
}
+
+Boolean
+_SC_stringIsValidDNSName (const char *name);
+
+
+Boolean
+_SC_CFStringIsValidDNSName (CFStringRef name);
+
+
__END_DECLS
#endif /* _SCVALIDATION_H */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@constant kSCStatusNoConfigFile Configuration file not found
@constant kSCStatusNoLink No such link
@constant kSCStatusStale Write attempted on stale version of object
+ @constant kSCStatusMaxLink Maximum link count exceeded
@constant kSCStatusReachabilityUnknown
A determination could not be made regarding the reachability
kSCStatusNoConfigFile = 3003, /* Configuration file not found */
kSCStatusNoLink = 3004, /* No such link */
kSCStatusStale = 3005, /* Write attempted on stale version of object */
+ kSCStatusMaxLink = 3006, /* Maximum link count exceeded */
/*
* SCNetwork status codes
*/
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <mach/boolean.h>
char copyright_string[] =
"/*\n"
-" * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.\n"
+" * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.\n"
" *\n"
" * @APPLE_LICENSE_HEADER_START@\n"
" * \n"
COMMENT,
OBSOLETE,
REGULAR,
- DEFINE ,
+ DEFINE,
FUTURE,
END
} controlType;
#define CFARRAY_CFNUMBER "CFArray[CFNumber]"
#define CFARRAY_CFSTRING "CFArray[CFString]"
#define CFBOOLEAN "CFBoolean"
+#define CFDATA "CFData"
#define CFDICTIONARY "CFDictionary"
#define CFNUMBER "CFNumber"
#define CFNUMBER_BOOL "CFNumber (0 or 1)"
#define ADDRESSES "Addresses"
#define AIRPORT "AirPort"
#define ALERT "Alert"
+#define ALLOWNETCREATION "AllowNetCreation"
#define ALTERNATEREMOTEADDRESS "AlternateRemoteAddress"
#define ANYREGEX "AnyRegex"
#define APPLETALK "AppleTalk"
#define BROADCAST "Broadcast"
#define BROADCASTADDRESSES "BroadcastAddresses"
#define BROADCASTSERVERTAG "BroadcastServerTag"
+#define CALLWAITINGAUDIBLEALERT "CallWaitingAudibleAlert"
+#define CCP "CCP"
#define CHAP "CHAP"
#define COMM "Comm"
#define COMPRESSIONACFIELD "CompressionACField"
#define CONFIGMETHOD "ConfigMethod"
#define CONNECTDELAY "ConnectDelay"
#define CONNECTIONSCRIPT "ConnectionScript"
+#define CONNECTSPEED "ConnectSpeed"
+#define CONNECTTIME "ConnectTime"
#define CONSOLEUSER "ConsoleUser"
#define CURRENTSET "CurrentSet"
#define DATACOMPRESSION "DataCompression"
#define DEFAULTSERVERTAG "DefaultServerTag"
#define DEFAULTZONE "DefaultZone"
#define DESTADDRESSES "DestAddresses"
+#define DETACHING "Detaching"
+#define DEVICE "Device"
#define DEVICENAME "DeviceName"
#define DHCP "DHCP"
#define DHCPCLIENTID "DHCPClientID"
#define DIALMODE "DialMode"
#define DIALONDEMAND "DialOnDemand"
+#define DISCONNECTONANSWER "DisconnectOnAnswer"
#define DISCONNECTONIDLE "DisconnectOnIdle"
#define DISCONNECTONIDLETIMER "DisconnectOnIdleTimer"
#define DISCONNECTONLOGOUT "DisconnectOnLogout"
+#define DISCONNECTONSLEEP "DisconnectOnSleep"
#define DISPLAYTERMINALWINDOW "DisplayTerminalWindow"
#define DNS "DNS"
#define DOMAIN "Domain"
#define ECHOENABLED "EchoEnabled"
#define ECHOFAILURE "EchoFailure"
#define ECHOINTERVAL "EchoInterval"
+#define ENABLED "Enabled"
#define ENCODING "Encoding"
#define ENCRYPTION "Encryption"
#define ERRORCORRECTION "ErrorCorrection"
#define GOPHERPORT "GopherPort"
#define GOPHERPROXY "GopherProxy"
#define HARDWARE "Hardware"
+#define HOLD "Hold"
+#define HOSTNAMES "HostNames"
#define HTTPENABLE "HTTPEnable"
#define HTTPPORT "HTTPPort"
#define HTTPPROXY "HTTPProxy"
#define IPCP "IPCP"
#define IPV4 "IPv4"
#define IPV6 "IPv6"
+#define JOINMODE "JoinMode"
+#define LASTCAUSE "LastCause"
#define LASTUPDATED "LastUpdated"
#define LCP "LCP"
#define LINK "Link"
+#define LINKLOCAL "LinkLocal"
+#define LOCALHOSTNAME "LocalHostName"
#define LOGFILE "Logfile"
#define MACADDRESS "MACAddress"
#define MANUAL "Manual"
#define NETINFO "NetInfo"
#define NETWORK "Network"
#define NETWORKID "NetworkID"
+#define NETWORKRANGE "NetworkRange"
#define NETWORKSERVICES "NetworkServices"
#define NIS "NIS"
#define NODE "Node"
#define NODEID "NodeID"
+#define NOTE "Note"
+#define OVERRIDEPRIMARY "OverridePrimary"
#define PAP "PAP"
#define PASSWORD "Password"
#define PLUGIN "Plugin"
+#define PLUGINS "Plugins"
#define POWERENABLED "PowerEnabled"
#define PPP "PPP"
#define PPPOE "PPPoE"
#define PPPOVERRIDEPRIMARY "PPPOverridePrimary"
#define PPPSERIAL "PPPSerial"
+#define PPTP "PPTP"
+#define PREFERRED "Preferred"
#define PREFERREDNETWORK "PreferredNetwork"
#define PREFS "Prefs"
#define PRIMARYINTERFACE "PrimaryInterface"
#define PROXIES "Proxies"
#define PULSEDIAL "PulseDial"
#define RECEIVEACCM "ReceiveACCM"
+#define RECENT "Recent"
#define REDIALCOUNT "RedialCount"
#define REDIALENABLED "RedialEnabled"
#define REDIALINTERVAL "RedialInterval"
+#define REMINDER "Reminder"
+#define REMINDERTIME "ReminderTime"
#define REMOTEADDRESS "RemoteAddress"
#define ROOTSEPARATOR "RootSeparator"
#define ROUTER "Router"
#define RTSPENABLE "RTSPEnable"
#define RTSPPORT "RTSPPort"
#define RTSPPROXY "RTSPProxy"
+#define SAVEPASSWORDS "SavePasswords"
#define SEARCHDOMAINS "SearchDomains"
#define SEEDNETWORKRANGE "SeedNetworkRange"
#define SEEDROUTER "SeedRouter"
#define SPEAKER "Speaker"
#define SPEED "Speed"
#define STATE "State"
+#define STATUS "Status"
+#define STRONGEST "Strongest"
#define SUBNETMASKS "SubnetMasks"
#define SUBTYPE "SubType"
+#define SUPPORTSMODEMONHOLD "SupportsModemOnHold"
#define SYSTEM "System"
#define TERMINALSCRIPT "TerminalScript"
#define TRANSMITACCM "TransmitACCM"
#define TYPE "Type"
#define UID "UID"
#define USERDEFINEDNAME "UserDefinedName"
+#define USE "Use"
#define USERS "Users"
#define VERBOSELOGGING "VerboseLogging"
#define WAITFORDIALTONE "WaitForDialTone"
{ REGULAR, COMP, NETWORK, NULL, NULL },
{ REGULAR, COMP, SERVICE, NULL, NULL },
{ REGULAR, COMP, GLOBAL, NULL, NULL },
+ { DEFINE , COMP, HOSTNAMES, NULL, NULL },
{ REGULAR, COMP, INTERFACE, NULL, NULL },
{ REGULAR, COMP, SYSTEM, NULL, NULL },
{ REGULAR, COMP, USERS, NULL, NULL },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX COMP NETWORK " Properties\n */", NULL },
+ { DEFINE , NETPROP, OVERRIDEPRIMARY, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP, SERVICEORDER, NULL, CFARRAY_CFSTRING },
{ REGULAR, NETPROP, PPPOVERRIDEPRIMARY, NULL, CFNUMBER_BOOL },
{ COMMENT, "", NULL, NULL, NULL },
+ { COMMENT, "/*\n * " KEY_PREFIX COMP NETWORK INTERFACE " Properties\n */", NULL },
+ { DEFINE , NETPROP, INTERFACES, NULL, CFARRAY_CFSTRING },
+ { COMMENT, "", NULL, NULL, NULL },
+
+ { COMMENT, "/*\n * " KEY_PREFIX COMP NETWORK HOSTNAMES " Properties\n */", NULL },
+ { DEFINE , NETPROP, LOCALHOSTNAME, NULL, CFSTRING },
+ { COMMENT, "", NULL, NULL, NULL },
+
{ COMMENT, "/*\n * " KEY_PREFIX NETENT AIRPORT " (Hardware) Entity Keys\n */", NULL, NULL, NULL },
- { REGULAR, NETPROP AIRPORT, POWERENABLED, NULL, CFNUMBER_BOOL },
- { REGULAR, NETPROP AIRPORT, AUTH PASSWORD, NULL, CFSTRING },
+ { DEFINE , NETPROP AIRPORT, ALLOWNETCREATION, NULL, CFNUMBER_BOOL },
+ { REGULAR, NETPROP AIRPORT, AUTH PASSWORD, NULL, CFDATA },
{ REGULAR, NETPROP AIRPORT, AUTH PASSWORD ENCRYPTION, NULL, CFSTRING },
+ { DEFINE , NETPROP AIRPORT, JOINMODE, NULL, CFSTRING },
+ { REGULAR, NETPROP AIRPORT, POWERENABLED, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP AIRPORT, PREFERREDNETWORK, NULL, CFSTRING },
+ { DEFINE , NETPROP AIRPORT, SAVEPASSWORDS, NULL, CFNUMBER_BOOL },
+ { COMMENT, "", NULL, NULL, NULL },
+ { COMMENT, "/* " KEY_PREFIX NETPROP AIRPORT JOINMODE " values */", NULL, NULL, NULL },
+ { DEFINE , NETVAL AIRPORT JOINMODE, PREFERRED, NULL, NULL },
+ { DEFINE , NETVAL AIRPORT JOINMODE, RECENT, NULL, NULL },
+ { DEFINE , NETVAL AIRPORT JOINMODE, STRONGEST, NULL, NULL },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX NETENT APPLETALK " Entity Keys\n */", NULL, NULL, NULL },
{ REGULAR, NETPROP APPLETALK, CONFIGMETHOD, NULL, CFSTRING },
{ REGULAR, NETPROP APPLETALK, DEFAULTZONE, NULL, CFSTRING },
{ REGULAR, NETPROP APPLETALK, NETWORKID, NULL, CFNUMBER },
+ { REGULAR, NETPROP APPLETALK, NETWORKRANGE, NULL, CFARRAY_CFNUMBER },
{ REGULAR, NETPROP APPLETALK, NODEID, NULL, CFNUMBER },
{ REGULAR, NETPROP APPLETALK, SEEDNETWORKRANGE, NULL, CFARRAY_CFNUMBER },
{ REGULAR, NETPROP APPLETALK, SEEDZONES, NULL, CFARRAY_CFSTRING },
{ REGULAR, NETPROP INTERFACE, HARDWARE, NULL, CFSTRING },
{ REGULAR, NETPROP INTERFACE, TYPE, NULL, CFSTRING },
{ REGULAR, NETPROP INTERFACE, SUBTYPE, NULL, CFSTRING },
+ { DEFINE , NETPROP INTERFACE, SUPPORTSMODEMONHOLD, NULL, CFNUMBER_BOOL },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/* " KEY_PREFIX NETPROP INTERFACE TYPE " values */", NULL, NULL, NULL },
{ REGULAR, NETVAL INTERFACE TYPE, ETHERNET, NULL, NULL },
{ COMMENT, "/* " KEY_PREFIX NETPROP SERVICE SUBTYPE " values (for " PPP ") */", NULL, NULL, NULL },
{ REGULAR, NETVAL INTERFACE SUBTYPE, PPPOE, NULL, NULL },
{ REGULAR, NETVAL INTERFACE SUBTYPE, PPPSERIAL, NULL, NULL },
+ { DEFINE , NETVAL INTERFACE SUBTYPE, PPTP, NULL, NULL },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX NETENT IPV4 " Entity Keys\n */", NULL, NULL, NULL },
{ REGULAR, NETVAL IPV4 CONFIGMETHOD, BOOTP, NULL, NULL },
{ REGULAR, NETVAL IPV4 CONFIGMETHOD, DHCP, NULL, NULL },
{ REGULAR, NETVAL IPV4 CONFIGMETHOD, INFORM, NULL, NULL },
+ { REGULAR, NETVAL IPV4 CONFIGMETHOD, LINKLOCAL, NULL, NULL },
{ REGULAR, NETVAL IPV4 CONFIGMETHOD, MANUAL, NULL, NULL },
{ REGULAR, NETVAL IPV4 CONFIGMETHOD, PPP, NULL, NULL },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX NETENT LINK " Entity Keys\n */", NULL, NULL, NULL },
{ REGULAR, NETPROP LINK, ACTIVE, NULL, CFBOOLEAN },
+ { DEFINE , NETPROP LINK, DETACHING, NULL, CFBOOLEAN },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX NETENT MODEM " (Hardware) Entity Keys\n */", NULL, NULL, NULL },
{ REGULAR, NETPROP MODEM, CONNECTIONSCRIPT, NULL, CFSTRING },
+ { DEFINE , NETPROP MODEM, CONNECTSPEED, NULL, CFNUMBER },
{ DEFINE , NETPROP MODEM, DATACOMPRESSION, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP MODEM, DIALMODE, NULL, CFSTRING },
{ DEFINE , NETPROP MODEM, ERRORCORRECTION, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP MODEM, HOLD CALLWAITINGAUDIBLEALERT, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP MODEM, HOLD DISCONNECTONANSWER, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP MODEM, HOLD ENABLED, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP MODEM, HOLD REMINDER, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP MODEM, HOLD REMINDERTIME, NULL, CFNUMBER },
+ { DEFINE , NETPROP MODEM, NOTE, NULL, CFSTRING },
{ REGULAR, NETPROP MODEM, PULSEDIAL, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP MODEM, SPEAKER, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP MODEM, SPEED, NULL, CFNUMBER },
{ COMMENT, "", NULL, NULL, NULL },
{ COMMENT, "/*\n * " KEY_PREFIX NETENT PPP " Entity Keys\n */", NULL, NULL, NULL },
+ { DEFINE , NETPROP PPP, CONNECTTIME, NULL, CFNUMBER },
+ { DEFINE , NETPROP PPP, DEVICE LASTCAUSE, NULL, CFNUMBER },
{ REGULAR, NETPROP PPP, DIALONDEMAND, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP PPP, DISCONNECTONIDLE, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP PPP, DISCONNECTONIDLETIMER, NULL, CFNUMBER },
{ REGULAR, NETPROP PPP, DISCONNECTONLOGOUT, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP PPP, DISCONNECTONSLEEP, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP PPP, IDLEREMINDERTIMER, NULL, CFNUMBER },
{ REGULAR, NETPROP PPP, IDLEREMINDER, NULL, CFNUMBER_BOOL },
+ { DEFINE , NETPROP PPP, LASTCAUSE, NULL, CFNUMBER },
{ REGULAR, NETPROP PPP, LOGFILE, NULL, CFSTRING },
+ { DEFINE , NETPROP PPP, PLUGINS, NULL, CFARRAY_CFSTRING },
{ DEFINE , NETPROP PPP, SESSIONTIMER, NULL, CFNUMBER },
+ { DEFINE , NETPROP PPP, STATUS, NULL, CFSTRING },
+ { DEFINE , NETPROP PPP, USE SESSIONTIMER, NULL, CFNUMBER_BOOL },
{ REGULAR, NETPROP PPP, VERBOSELOGGING, NULL, CFNUMBER_BOOL },
{ COMMENT, "", NULL, NULL, NULL },
{ REGULAR, NETPROP PPP, COMM REDIALINTERVAL, NULL, CFNUMBER },
{ REGULAR, NETPROP PPP, COMM REMOTEADDRESS, NULL, CFSTRING },
{ REGULAR, NETPROP PPP, COMM TERMINALSCRIPT, NULL, CFSTRING },
+ { DEFINE , NETPROP PPP, COMM USE TERMINALSCRIPT, NULL, CFNUMBER_BOOL },
+
+ { COMMENT, "\n/* " CCP ": */", NULL, NULL, NULL },
+ { DEFINE , NETPROP PPP, CCP ENABLED, NULL, CFNUMBER_BOOL },
{ COMMENT, "\n/* " IPCP ": */", NULL, NULL, NULL },
{ REGULAR, NETPROP PPP, IPCP COMPRESSIONVJ, NULL, CFNUMBER_BOOL },
--- /dev/null
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ * May 29, 2002 Roger Smith <rsmith@apple.com>
+ * - initial revision
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCPrivate.h>
+
+#include "moh.h"
+#include "moh_msg.h"
+
+// Note: right now we are not currently using the deviceName. This could be the raw
+// tty name such as "modem" since this is guaranteed to be unique in the /dev.
+// We would use this deviceName to differientate between multiple MOH devices
+// present in the system when we create the socket.
+
+
+static int
+readn(int ref, void *data, int len)
+{
+ int left = len;
+ int n;
+ void *p = data;
+
+ while (left > 0) {
+ if ((n = read(ref, p, left)) < 0) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ n = 0;
+ } else if (n == 0) {
+ break; /* EOF */
+ }
+
+ left -= n;
+ p += n;
+ }
+ return (len - left);
+}
+
+
+static int
+writen(int ref, void *data, int len)
+{
+ int left = len;
+ int n;
+ void *p = data;
+
+ while (left > 0) {
+ if ((n = write(ref, p, left)) <= 0) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ n = 0;
+ }
+ left -= n;
+ p += n;
+ }
+ return len;
+}
+
+
+__private_extern__
+int
+MOHInit(int *ref, CFStringRef deviceName)
+{
+ int sock;
+ int status;
+ struct sockaddr_un sun;
+
+ sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+
+ bzero(&sun, sizeof(sun));
+ sun.sun_family = AF_LOCAL;
+ strncpy(sun.sun_path, MOH_PATH, sizeof(sun.sun_path));
+
+ status = connect(sock, (struct sockaddr *)&sun, sizeof(sun));
+ if (status < 0) {
+ return errno;
+ }
+
+ *ref = sock;
+ return 0;
+}
+
+
+__private_extern__
+int
+MOHDispose(int ref)
+{
+ if (close(ref) < 0) {
+ return errno;
+ }
+ return 0;
+}
+
+
+__private_extern__
+int
+MOHExec(int ref,
+ u_long link,
+ u_int32_t cmd,
+ void *request,
+ u_long requestLen,
+ void **reply,
+ u_long *replyLen)
+{
+ struct moh_msg_hdr msg;
+ char *buf = NULL;
+ ssize_t n;
+
+ bzero(&msg, sizeof(msg));
+ msg.m_type = cmd;
+ msg.m_link = link;
+ msg.m_len = ((request != NULL) && (requestLen > 0)) ? requestLen : 0;
+
+ // send the command
+ n = writen(ref, &msg, sizeof(msg));
+ if (n == -1) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: %s"), strerror(errno));
+ return errno;
+ } else if (n != sizeof(msg)) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: wrote=%d"), n);
+ return -1;
+ }
+
+ if ((request != NULL) && (requestLen > 0)) {
+ n = writen(ref, request, requestLen);
+ if (n == -1) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: %s"), strerror(errno));
+ return errno;
+ } else if (n != requestLen) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec writen() failed: wrote=%d"), n);
+ return -1;
+ }
+ }
+
+ // always expect a reply
+ n = readn(ref, &msg, sizeof(msg));
+ if (n == -1) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: error=%s"), strerror(errno));
+ return errno;
+ } else if (n != sizeof(msg)) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: insufficent data, read=%d"), n);
+ return -1;
+ }
+
+ if (msg.m_len) {
+ buf = CFAllocatorAllocate(NULL, msg.m_len, 0);
+ if (buf) {
+ // read reply
+ n = readn(ref, buf, msg.m_len);
+ if (n == -1) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: error=%s"), strerror(errno));
+ CFAllocatorDeallocate(NULL, buf);
+ return errno;
+ } else if (n != msg.m_len) {
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("MOHExec readn() failed: insufficent data, read=%d"), n);
+ CFAllocatorDeallocate(NULL, buf);
+ return -1;
+ }
+ }
+ }
+
+ if (reply && replyLen) {
+ *reply = buf;
+ *replyLen = msg.m_len;
+ } else if (buf) {
+ // if additional returned data is unwanted
+ CFAllocatorDeallocate(NULL, buf);
+ }
+
+ return msg.m_result;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ */
+
+#ifndef _MOH_H
+#define _MOH_H
+
+#include <sys/cdefs.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+__BEGIN_DECLS
+
+int
+MOHInit (
+ int *ref,
+ CFStringRef deviceName
+ );
+
+int
+MOHDispose (
+ int ref
+ );
+
+int
+MOHExec (int ref,
+ u_long link,
+ u_int32_t cmd,
+ void *request,
+ u_long requestLen,
+ void **reply,
+ u_long *replyLen
+ );
+
+__END_DECLS
+
+#endif /* _MOH_H */
--- /dev/null
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _MOH_MSG_H
+#define _MOH_MSG_H
+
+#include <sys/types.h>
+
+/* local socket path */
+#define MOH_PATH "/tmp/.modemOnHold"
+#define CURRENT_VERSION 1
+
+/* MOH message paquets */
+struct moh_msg_hdr {
+ u_int32_t m_type; // type of the message
+ u_int32_t m_result; // error code of notification message
+ u_int32_t m_cookie; // user param
+ u_int32_t m_link; // link for this message
+ u_int32_t m_len; // len of the following data
+};
+
+struct moh_msg {
+ u_int32_t m_type; // type of the message
+ u_int32_t m_result; // error code of notification message
+ u_int32_t m_cookie; // user param, or error num for event
+ u_int32_t m_link; // link for this message
+ u_int32_t m_len; // len of the following data
+ u_char m_data[1]; // msg data sent or received
+};
+
+/* codes for MOH messages */
+enum {
+ /* API client commands */
+ MOH_VERSION = 1,
+ MOH_DEVICE_SUPPORTS_HOLD,
+ MOH_SESSION_SUPPORTS_HOLD,
+ MOH_PUT_SESSION_ON_HOLD,
+ MOH_RESUME_SESSION_ON_HOLD,
+ MOH_SESSION_IS_ON_HOLD,
+ MOH_SESSION_GET_STATUS
+};
+
+#endif /* _MOH_MSG_H */
+
/*
- * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+/*
+ * Modification History
+ *
+ * Feb 28, 2002 Christophe Allie <callie@apple.com>
+ * - socket API fixes
+ *
+ * Feb 10, 2001 Allan Nathanson <ajn@apple.com>
+ * - cleanup API
+ *
+ * Feb 2000 Christophe Allie <callie@apple.com>
+ * - initial revision (as ppplib.c)
+ */
+
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include "ppp_msg.h"
#include "ppp.h"
+
+static int
+readn(int ref, void *data, int len)
+{
+ int left = len;
+ int n;
+ void *p = data;
+
+ while (left > 0) {
+ if ((n = read(ref, p, left)) < 0) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ n = 0;
+ } else if (n == 0) {
+ break; /* EOF */
+ }
+
+ left -= n;
+ p += n;
+ }
+ return (len - left);
+}
+
+
+static int
+writen(int ref, void *data, int len)
+{
+ int left = len;
+ int n;
+ void *p = data;
+
+ while (left > 0) {
+ if ((n = write(ref, p, left)) <= 0) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ n = 0;
+ }
+ left -= n;
+ p += n;
+ }
+ return len;
+}
+
+
__private_extern__
int
PPPInit(int *ref)
msg.m_len = ((request != NULL) && (requestLen > 0)) ? requestLen : 0;
// send the command
- n = write(ref, &msg, sizeof(msg));
- if (n == -1) {
+ if (writen(ref, &msg, sizeof(msg)) < 0) {
SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec write() failed: %s"), strerror(errno));
return errno;
- } else if (n != sizeof(msg)) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec write() failed: wrote=%d"), n);
- return -1;
}
if ((request != NULL) && (requestLen > 0)) {
- n = write(ref, request, requestLen);
- if (n == -1) {
+ if (writen(ref, request, requestLen) < 0) {
SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec write() failed: %s"), strerror(errno));
return errno;
- } else if (n != requestLen) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec write() failed: wrote=%d"), n);
- return -1;
}
}
// always expect a reply
- n = read(ref, &msg, sizeof(msg));
+ n = readn(ref, &msg, sizeof(msg));
if (n == -1) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec read() failed: error=%s"), strerror(errno));
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec readn() failed: error=%s"), strerror(errno));
return errno;
} else if (n != sizeof(msg)) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec read() failed: insufficent data, read=%d"), n);
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec readn() failed: insufficent data, read=%d"), n);
return -1;
}
buf = CFAllocatorAllocate(NULL, msg.m_len, 0);
if (buf) {
// read reply
- n = read(ref, buf, msg.m_len);
+ n = readn(ref, buf, msg.m_len);
if (n == -1) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec read() failed: error=%s"), strerror(errno));
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec readn() failed: error=%s"), strerror(errno));
CFAllocatorDeallocate(NULL, buf);
return errno;
} else if (n != msg.m_len) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec read() failed: insufficent data, read=%d"), n);
+ SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec readn() failed: insufficent data, read=%d"), n);
CFAllocatorDeallocate(NULL, buf);
return -1;
}
return status;
}
-
-
-int
-PPPListen(int ref, u_long link)
-{
- int status;
-
- status = PPPExec(ref,
- link,
- PPP_LISTEN,
- NULL,
- 0,
- NULL,
- NULL);
- if (status != 0) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec(PPP_LISTEN) failed: status = %d"), status);
- return status;
- }
-
- return status;
-}
-
-
-int
-PPPApply(int ref, u_long link)
-{
- int status;
-
- status = PPPExec(ref,
- link,
- PPP_APPLY,
- NULL,
- 0,
- NULL,
- NULL);
- if (status != 0) {
- SCLog(_sc_verbose, LOG_ERR, CFSTR("PPPExec(PPP_APPLY) failed: status = %d"), status);
- return status;
- }
-
- return status;
-}
#endif /* NOT_NEEDED */
return status;
}
+
+
+#ifdef NOT_NEEDED
+__private_extern__
+int
+PPPEnableEvents(int ref, u_long link, u_char enable)
+{
+ int status;
+
+ status = PPPExec(ref,
+ link,
+ enable ? PPP_ENABLE_EVENT : PPP_DISABLE_EVENT,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ if (status != 0) {
+ SCLog(_sc_verbose,
+ LOG_ERR,
+ CFSTR("PPPExec(%s) failed: status = %d"),
+ enable ? "PPP_ENABLE_EVENT" : "PPP_DISABLE_EVENT",
+ status);
+ return status;
+ }
+
+ return status;
+}
+#endif /* NOT_NEEDED */
/*
- * Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+/*
+ * Modification History
+ *
+ * Feb 10, 2001 Allan Nathanson <ajn@apple.com>
+ * - cleanup API
+ *
+ * Feb 2000 Christophe Allie <callie@apple.com>
+ * - initial revision (as ppplib.h)
+ */
+
#ifndef _PPP_H
#define _PPP_H
int PPPDisconnect (int ref,
u_long link);
-
-int PPPListen (int ref,
- u_long link);
-
-int PPPApply (int ref,
- u_long link);
#endif /* NOT_NEEDED */
int PPPGetNumberOfLinks (int ref,
u_long link,
struct ppp_status **stat);
+#ifdef NOT_NEEDED
+int PPPEnableEvents (int ref,
+ u_long link,
+ u_char enable);
+#endif /* NOT_NEEDED */
+
__END_DECLS
#endif /* _PPP_H */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
PPP_NETWORK,
PPP_RUNNING,
PPP_TERMINATE,
- PPP_DISCONNECTLINK
+ PPP_DISCONNECTLINK,
+ PPP_HOLDOFF,
+ PPP_ONHOLD
};
// events
PROF_LIBS = $(LIBS)
-NEXTSTEP_PB_CFLAGS = -DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS
FRAMEWORKS = -framework CoreFoundation -framework SystemConfiguration
# and "" on other systems.
# DSTROOT = $(HOME)
-# Additional flags (MiG generated files)
+# Additional flags (for MiG generated files)
+ALL_MIGFLAGS = -F$(SYMROOT)
OTHER_OFILES = configServer.o
{
- DYNAMIC_CODE_GEN = YES;
+ "DYNAMIC_CODE_GEN" = YES;
FILESTABLE = {
- FRAMEWORKS = (CoreFoundation.framework, SystemConfiguration.framework);
+ FRAMEWORKS = ("CoreFoundation.framework", "SystemConfiguration.framework");
FRAMEWORKSEARCH = ();
HEADERSEARCH = ();
- H_FILES = (
- configd.h,
- _SCD.h,
- configd_server.h,
- notify_server.h,
- plugin_support.h,
- session.h,
- notify.h
+ "H_FILES" = (
+ "configd.h",
+ "_SCD.h",
+ "configd_server.h",
+ "notify_server.h",
+ "plugin_support.h",
+ "session.h",
+ "notify.h"
);
- OTHER_LIBS = (objc);
- OTHER_LINKED = (
- configd.m,
- _SCD.c,
- configd_server.c,
- notify_server.c,
- plugin_support.c,
- session.c,
- notify.c,
- _configopen.c,
- _configclose.c,
- _configlock.c,
- _configunlock.c,
- _configlist.c,
- _configadd.c,
- _configadd_s.c,
- _configget.c,
- _configset.c,
- _configremove.c,
- _configtouch.c,
- _confignotify.c,
- _notifyadd.c,
- _notifyremove.c,
- _notifychanges.c,
- _notifyviaport.c,
- _notifyviafd.c,
- _notifyviasignal.c,
- _notifycancel.c,
- _snapshot.c
+ "OTHER_LIBS" = (objc);
+ "OTHER_LINKED" = (
+ "configd.m",
+ "_SCD.c",
+ "configd_server.c",
+ "notify_server.c",
+ "plugin_support.c",
+ "session.c",
+ "notify.c",
+ "_configopen.c",
+ "_configclose.c",
+ "_configlock.c",
+ "_configunlock.c",
+ "_configlist.c",
+ "_configadd.c",
+ "_configadd_s.c",
+ "_configget.c",
+ "_configset.c",
+ "_configremove.c",
+ "_configtouch.c",
+ "_confignotify.c",
+ "_notifyadd.c",
+ "_notifyremove.c",
+ "_notifychanges.c",
+ "_notifyviaport.c",
+ "_notifyviafd.c",
+ "_notifyviasignal.c",
+ "_notifycancel.c",
+ "_snapshot.c"
);
- OTHER_SOURCES = (
- Makefile.preamble,
+ "OTHER_SOURCES" = (
+ "Makefile.preamble",
Makefile,
- Makefile.postamble,
- m.template,
- h.template,
- config.defs
+ "Makefile.postamble",
+ "m.template",
+ "h.template",
+ "config.defs"
);
- PRECOMPILED_HEADERS = ();
- PROJECT_HEADERS = ();
- PUBLIC_HEADERS = ();
+ "PRECOMPILED_HEADERS" = ();
+ "PROJECT_HEADERS" = ();
+ "PUBLIC_HEADERS" = ();
SUBPROJECTS = ();
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
- NEXTSTEP_BUILDTOOL = /usr/bin/gnumake;
- NEXTSTEP_COMPILEROPTIONS = "-DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS";
- NEXTSTEP_INSTALLDIR = /usr/sbin;
- NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
- NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
- PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make;
- PDO_UNIX_INSTALLDIR = /bin;
- PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac";
- PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc";
+ "NEXTSTEP_BUILDTOOL" = "/usr/bin/gnumake";
+ "NEXTSTEP_INSTALLDIR" = "/usr/sbin";
+ "NEXTSTEP_JAVA_COMPILER" = "/usr/bin/javac";
+ "NEXTSTEP_OBJCPLUS_COMPILER" = "/usr/bin/cc";
+ "PDO_UNIX_BUILDTOOL" = "$NEXT_ROOT/Developer/bin/make";
+ "PDO_UNIX_INSTALLDIR" = "/bin";
+ "PDO_UNIX_JAVA_COMPILER" = "$(JDKBINDIR)/javac";
+ "PDO_UNIX_OBJCPLUS_COMPILER" = "$(NEXTDEV_BIN)/gcc";
PROJECTNAME = configd;
PROJECTTYPE = Tool;
- PROJECTVERSION = 2.8;
- WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make;
- WINDOWS_INSTALLDIR = /Library/Executables;
- WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe";
- WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc";
+ PROJECTVERSION = "2.8";
+ "WINDOWS_BUILDTOOL" = "$NEXT_ROOT/Developer/Executables/make";
+ "WINDOWS_INSTALLDIR" = "/Library/Executables";
+ "WINDOWS_JAVA_COMPILER" = "$(JDKBINDIR)/javac.exe";
+ "WINDOWS_OBJCPLUS_COMPILER" = "$(DEVDIR)/gcc";
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
char reErrBuf[256];
int reErrStrLen;
- if (CFDictionaryContainsKey(info, kSCDData) == FALSE) {
+ if (!CFDictionaryContainsKey(info, kSCDData)) {
/* if no data (yet) */
return;
}
*
* This is a CFDictionaryApplierFunction which will iterate over each session
* defined in the "sessionData" dictionary. The arguments are the session
- * key, it's associated session dictionary, , and the store key being added.
+ * key, it's associated session dictionary, and the store key being added.
*
* If an active session includes any regular expression keys which match the
* key being added to the "storeData" dictionary then we mark this key as being
CFArrayRef rData;
CFIndex i;
- if (info == NULL) {
- /* if no dictionary for this session */
- return;
- }
-
rKeys = CFDictionaryGetValue(info, kSCDRegexKeys);
if (rKeys == NULL) {
/* if no regex keys for this session */
char reErrBuf[256];
int reErrStrLen;
- if ((info == NULL) || (CFDictionaryContainsKey(info, kSCDWatchers) == FALSE)) {
- /* no dictionary or no watchers */
+ if (CFDictionaryContainsKey(info, kSCDWatchers) == FALSE) {
+ /* if no watchers */
return;
}
CFArrayRef rData;
CFIndex i;
- if (info == NULL) {
- /* if no dictionary for this session */
- return;
- }
-
rKeys = CFDictionaryGetValue(info, kSCDRegexKeys);
if (rKeys == NULL) {
/* if no regex keys for this session */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFDataRef xmlData; /* data (XML serialized) */
CFPropertyListRef data; /* data (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Add key to configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
*sc_status = kSCStatusOK;
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
*sc_status = kSCStatusInvalidArgument;
}
/* un-serialize the data */
- xmlData = CFDataCreate(NULL, dataRef, dataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- data = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!data) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() data: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&data, (void *)dataRef, dataLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFPropertyList(data)) {
+ }
+
+ if (!isA_CFPropertyList(data)) {
*sc_status = kSCStatusInvalidArgument;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFDataRef xmlData; /* data (XML serialized) */
CFPropertyListRef data; /* data (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Add (session) key to configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
*sc_status = kSCStatusOK;
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
*sc_status = kSCStatusInvalidArgument;
}
/* un-serialize the data */
- xmlData = CFDataCreate(NULL, dataRef, dataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- data = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!data) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() data: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&data, (void *)dataRef, dataLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFPropertyList(data)) {
+ }
+
+ if (!isA_CFPropertyList(data)) {
*sc_status = kSCStatusInvalidArgument;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
/* Remove notification keys */
- if ((keyCnt = CFSetGetCount(storePrivate->keys)) > 0) {
- void **watchedKeys;
+ keyCnt = CFSetGetCount(storePrivate->keys);
+ if (keyCnt > 0) {
+ const void **watchedKeys;
CFArrayRef keysToRemove;
CFIndex i;
}
/* Remove regex notification keys */
- if ((keyCnt = CFSetGetCount(storePrivate->reKeys)) > 0) {
- void **watchedKeys;
+ keyCnt = CFSetGetCount(storePrivate->reKeys);
+ if (keyCnt > 0) {
+ const void **watchedKeys;
CFArrayRef keysToRemove;
CFIndex i;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
- serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFDataRef xmlData; /* data (XML serialized) */
+ serverSessionRef mySession = getSession(server);
+ Boolean ok;
CFPropertyListRef value;
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Get key from configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
+ *dataRef = NULL;
+ *dataLen = 0;
+
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
*sc_status = __SCDynamicStoreCopyValue(mySession->store, key, &value);
CFRelease(key);
if (*sc_status != kSCStatusOK) {
- *dataRef = NULL;
- *dataLen = 0;
return KERN_SUCCESS;
}
- /*
- * serialize the data, copy it into an allocated buffer which will be
- * released when it is returned as part of a Mach message.
- */
- xmlData = CFPropertyListCreateXMLData(NULL, value);
+ /* serialize the data */
+ ok = _SCSerialize(value, NULL, (void **)dataRef, (CFIndex *)dataLen);
CFRelease(value);
- *dataLen = CFDataGetLength(xmlData);
- status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_allocate(): %s"), mach_error_string(status));
+ if (!ok) {
*sc_status = kSCStatusFailed;
- CFRelease(xmlData);
- *dataRef = NULL;
- *dataLen = 0;
return KERN_SUCCESS;
}
- bcopy((char *)CFDataGetBytePtr(xmlData), *dataRef, *dataLen);
- CFRelease(xmlData);
-
/*
* return the instance number associated with the returned data.
*/
mach_msg_type_number_t *dataLen,
int *sc_status)
{
- kern_return_t status;
- serverSessionRef mySession = getSession(server);
CFArrayRef keys = NULL; /* keys (un-serialized) */
- CFArrayRef patterns = NULL; /* patterns (un-serialized) */
- CFDataRef xmlData; /* data (XML serialized) */
addSpecific myContext;
+ serverSessionRef mySession = getSession(server);
+ Boolean ok;
+ CFArrayRef patterns = NULL; /* patterns (un-serialized) */
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Get key from configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
+ *dataRef = NULL;
+ *dataLen = 0;
*sc_status = kSCStatusOK;
if (keysRef && (keysLen > 0)) {
- CFDataRef xmlKeys; /* keys (XML serialized) */
- CFStringRef xmlError;
-
/* un-serialize the keys */
- xmlKeys = CFDataCreate(NULL, keysRef, keysLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keysRef, keysLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- keys = CFPropertyListCreateFromXMLData(NULL,
- xmlKeys,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKeys);
- if (!keys) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() keys: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&keys, (void *)keysRef, keysLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFArray(keys)) {
+ }
+
+ if (!isA_CFArray(keys)) {
*sc_status = kSCStatusInvalidArgument;
}
}
if (patternsRef && (patternsLen > 0)) {
- CFDataRef xmlPatterns; /* patterns (XML serialized) */
- CFStringRef xmlError;
-
/* un-serialize the patterns */
- xmlPatterns = CFDataCreate(NULL, patternsRef, patternsLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)patternsRef, patternsLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- patterns = CFPropertyListCreateFromXMLData(NULL,
- xmlPatterns,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlPatterns);
- if (!patterns) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() patterns: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&patterns, (void *)patternsRef, patternsLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFArray(patterns)) {
+ }
+
+ if (!isA_CFArray(patterns)) {
*sc_status = kSCStatusInvalidArgument;
}
}
if (*sc_status != kSCStatusOK) {
if (keys) CFRelease(keys);
if (patterns) CFRelease(patterns);
- *dataRef = NULL;
- *dataLen = 0;
return KERN_SUCCESS;
}
CFRelease(patterns);
}
- /*
- * serialize the dictionary of matching keys/patterns, copy it into an
- * allocated buffer which will be released when it is returned as part
- * of a Mach message.
- */
- xmlData = CFPropertyListCreateXMLData(NULL, myContext.dict);
+ /* serialize the dictionary of matching keys/patterns */
+ ok = _SCSerialize(myContext.dict, NULL, (void **)dataRef, (CFIndex *)dataLen);
CFRelease(myContext.dict);
- *dataLen = CFDataGetLength(xmlData);
- status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_allocate(): %s"), mach_error_string(status));
+ if (!ok) {
*sc_status = kSCStatusFailed;
- CFRelease(xmlData);
- *dataRef = NULL;
- *dataLen = 0;
return KERN_SUCCESS;
}
- bcopy((char *)CFDataGetBytePtr(xmlData), *dataRef, *dataLen);
- CFRelease(xmlData);
-
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
{
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
CFIndex storeCnt;
- void **storeKeys;
- void **storeValues;
+ const void **storeKeys;
+ const void **storeValues;
CFMutableArrayRef keyArray;
int i;
CFStringRef storeStr;
* compile the provided regular expression using the
* provided isRegex.
*/
- regexBufLen = CFStringGetLength(regexStr)+1;
+ regexBufLen = CFStringGetLength(regexStr) + 1;
regexBuf = CFAllocatorAllocate(NULL, regexBufLen, 0);
ok = CFStringGetCString(regexStr, regexBuf, regexBufLen, kCFStringEncodingMacRoman);
CFRelease(regexStr);
}
}
- storeKeys = CFAllocatorAllocate(NULL, storeCnt * sizeof(CFStringRef), 0);
- storeValues = CFAllocatorAllocate(NULL, storeCnt * sizeof(CFStringRef), 0);
- CFDictionaryGetKeysAndValues(storeData, storeKeys, storeValues);
- for (i=0; i<storeCnt; i++) {
- storeStr = (CFStringRef)storeKeys[i];
- storeValue = (CFDictionaryRef)storeValues[i];
- if (isRegex) {
- /*
- * only return those keys which match the regular
- * expression specified in the provided key.
- */
-
- int storeKeyLen = CFStringGetLength(storeStr) + 1;
- char *storeKey = CFAllocatorAllocate(NULL, storeKeyLen, 0);
-
- if (!CFStringGetCString(storeStr,
- storeKey,
- storeKeyLen,
- kCFStringEncodingMacRoman)) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("CFStringGetCString: could not convert store key to C string"));
+ if (storeCnt > 0) {
+ storeKeys = CFAllocatorAllocate(NULL, storeCnt * sizeof(CFStringRef), 0);
+ storeValues = CFAllocatorAllocate(NULL, storeCnt * sizeof(CFStringRef), 0);
+ CFDictionaryGetKeysAndValues(storeData, storeKeys, storeValues);
+ for (i=0; i<storeCnt; i++) {
+ storeStr = (CFStringRef)storeKeys[i];
+ storeValue = (CFDictionaryRef)storeValues[i];
+ if (isRegex) {
+ /*
+ * only return those keys which match the regular
+ * expression specified in the provided key.
+ */
+
+ int storeKeyLen = CFStringGetLength(storeStr) + 1;
+ char *storeKey = CFAllocatorAllocate(NULL, storeKeyLen, 0);
+
+ if (!CFStringGetCString(storeStr,
+ storeKey,
+ storeKeyLen,
+ kCFStringEncodingMacRoman)) {
+ SCLog(_configd_verbose, LOG_DEBUG, CFSTR("CFStringGetCString: could not convert store key to C string"));
+ CFAllocatorDeallocate(NULL, storeKey);
+ continue;
+ }
+
+ reError = regexec(&preg,
+ storeKey,
+ 0,
+ NULL,
+ 0);
+ switch (reError) {
+ case 0 :
+ /* we've got a match */
+ if (CFDictionaryContainsKey(storeValue, kSCDData))
+ CFArrayAppendValue(keyArray, storeStr);
+ break;
+ case REG_NOMATCH :
+ /* no match */
+ break;
+ default :
+ reErrStrLen = regerror(reError,
+ &preg,
+ reErrBuf,
+ sizeof(reErrBuf));
+ SCLog(_configd_verbose, LOG_DEBUG, CFSTR("regexec(): %s"), reErrBuf);
+ break;
+ }
CFAllocatorDeallocate(NULL, storeKey);
- continue;
- }
-
- reError = regexec(&preg,
- storeKey,
- 0,
- NULL,
- 0);
- switch (reError) {
- case 0 :
- /* we've got a match */
- if (CFDictionaryContainsKey(storeValue, kSCDData))
- CFArrayAppendValue(keyArray, storeStr);
- break;
- case REG_NOMATCH :
- /* no match */
- break;
- default :
- reErrStrLen = regerror(reError,
- &preg,
- reErrBuf,
- sizeof(reErrBuf));
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("regexec(): %s"), reErrBuf);
- break;
- }
- CFAllocatorDeallocate(NULL, storeKey);
- } else {
- /*
- * only return those keys which are prefixed by the
- * provided key string and have data.
- */
- if (((CFStringGetLength(key) == 0) || CFStringHasPrefix(storeStr, key)) &&
- CFDictionaryContainsKey(storeValue, kSCDData)) {
- CFArrayAppendValue(keyArray, storeStr);
+ } else {
+ /*
+ * only return those keys which are prefixed by the
+ * provided key string and have data.
+ */
+ if (((CFStringGetLength(key) == 0) || CFStringHasPrefix(storeStr, key)) &&
+ CFDictionaryContainsKey(storeValue, kSCDData)) {
+ CFArrayAppendValue(keyArray, storeStr);
+ }
}
}
+ CFAllocatorDeallocate(NULL, storeKeys);
+ CFAllocatorDeallocate(NULL, storeValues);
}
- CFAllocatorDeallocate(NULL, storeKeys);
- CFAllocatorDeallocate(NULL, storeValues);
if (isRegex) {
regfree(&preg);
int *sc_status
)
{
- kern_return_t status;
- serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
+ serverSessionRef mySession = getSession(server);
+ Boolean ok;
CFArrayRef subKeys; /* array of CFStringRef's */
- CFDataRef xmlList; /* list (XML serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("List keys in configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
*listLen = 0;
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
return KERN_SUCCESS;
}
- /*
- * serialize the array, copy it into an allocated buffer which will be
- * released when it is returned as part of a Mach message.
- */
- xmlList = CFPropertyListCreateXMLData(NULL, subKeys);
+ /* serialize the list of keys */
+ ok = _SCSerialize(subKeys, NULL, (void **)listRef, (CFIndex *)listLen);
CFRelease(subKeys);
- *listLen = CFDataGetLength(xmlList);
- status = vm_allocate(mach_task_self(), (void *)listRef, *listLen, TRUE);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_allocate(): %s"), mach_error_string(status));
+ if (!ok) {
*sc_status = kSCStatusFailed;
- CFRelease(xmlList);
- *listRef = NULL;
- *listLen = 0;
return KERN_SUCCESS;
}
- bcopy((char *)CFDataGetBytePtr(xmlList), *listRef, *listLen);
- CFRelease(xmlList);
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 2. Tickle the value in the dynamic store
*/
dict = CFDictionaryGetValue(storeData, key);
- if (!dict || !CFDictionaryGetValueIfPresent(dict, kSCDData, (void **)&value)) {
+ if (!dict || !CFDictionaryGetValueIfPresent(dict, kSCDData, (const void **)&value)) {
/* key doesn't exist (or data never defined) */
value = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
newValue = TRUE;
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Notify key in configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
- *sc_status = kSCStatusFailed;
- return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
+ *sc_status = kSCStatusFailed;
+ return KERN_SUCCESS;
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
{
kern_return_t status;
serverSessionRef mySession, newSession;
- CFDataRef xmlName; /* name (XML serialized) */
CFStringRef name; /* name (un-serialized) */
- CFStringRef xmlError;
mach_port_t oldNotify;
CFStringRef sessionKey;
CFDictionaryRef info;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the name */
- xmlName = CFDataCreate(NULL, nameRef, nameLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)nameRef, nameLen);
- if (status != KERN_SUCCESS) {
- CFRelease(xmlName);
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- name = CFPropertyListCreateFromXMLData(NULL,
- xmlName,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlName);
- if (!name) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() name: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&name, (void *)nameRef, nameLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(name)) {
+ }
+
+ if (!isA_CFString(name)) {
CFRelease(name);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Remove key from configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFDataRef xmlData; /* data (XML serialized) */
CFPropertyListRef data; /* data (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Set key to configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
*sc_status = kSCStatusOK;
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
*sc_status = kSCStatusInvalidArgument;
}
/* un-serialize the data */
- xmlData = CFDataCreate(NULL, dataRef, dataLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- data = CFPropertyListCreateFromXMLData(NULL,
- xmlData,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlData);
- if (!data) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() data: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&data, (void *)dataRef, dataLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFPropertyList(data)) {
+ }
+
+ if (!isA_CFPropertyList(data)) {
*sc_status = kSCStatusInvalidArgument;
}
mach_msg_type_number_t notifyLen,
int *sc_status)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
CFDictionaryRef dict = NULL; /* key/value dictionary (un-serialized) */
CFArrayRef remove = NULL; /* keys to remove (un-serialized) */
*sc_status = kSCStatusOK;
if (dictRef && (dictLen > 0)) {
- CFDataRef xmlDict; /* key/value dictionary (XML serialized) */
- CFStringRef xmlError;
-
/* un-serialize the key/value pairs to set */
- xmlDict = CFDataCreate(NULL, dictRef, dictLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)dictRef, dictLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- dict = CFPropertyListCreateFromXMLData(NULL,
- xmlDict,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlDict);
- if (!dict) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() dict: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&dict, (void *)dictRef, dictLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFDictionary(dict)) {
+ }
+
+ if (!isA_CFDictionary(dict)) {
*sc_status = kSCStatusInvalidArgument;
}
}
if (removeRef && (removeLen > 0)) {
- CFDataRef xmlRemove; /* keys to remove (XML serialized) */
- CFStringRef xmlError;
-
/* un-serialize the keys to remove */
- xmlRemove = CFDataCreate(NULL, removeRef, removeLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)removeRef, removeLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- remove = CFPropertyListCreateFromXMLData(NULL,
- xmlRemove,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlRemove);
- if (!remove) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() remove: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&remove, (void *)removeRef, removeLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFArray(remove)) {
+ }
+
+ if (!isA_CFArray(remove)) {
*sc_status = kSCStatusInvalidArgument;
}
}
if (notifyRef && (notifyLen > 0)) {
- CFDataRef xmlNotify; /* keys to notify (XML serialized) */
- CFStringRef xmlError;
-
/* un-serialize the keys to notify */
- xmlNotify = CFDataCreate(NULL, notifyRef, notifyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)notifyRef, notifyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- notify = CFPropertyListCreateFromXMLData(NULL,
- xmlNotify,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlNotify);
- if (!notify) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() notify: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)¬ify, (void *)notifyRef, notifyLen)) {
*sc_status = kSCStatusFailed;
- } else if (!isA_CFArray(notify)) {
+ }
+
+ if (!isA_CFArray(notify)) {
*sc_status = kSCStatusInvalidArgument;
}
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
case kSCStatusOK :
/* store entry exists */
- if (CFGetTypeID(value) == CFDateGetTypeID()) {
+ if (isA_CFDate(value)) {
/* the value is a CFDate, update the time stamp */
CFRelease(value);
value = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Touch key in configuration database."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
_notifyWatchers()
{
CFIndex keyCnt;
- void **keys;
+ const void **keys;
- if ((keyCnt = CFSetGetCount(changedKeys)) == 0)
+ keyCnt = CFSetGetCount(changedKeys);
+ if (keyCnt == 0)
return; /* if nothing to do */
keys = CFAllocatorAllocate(NULL, keyCnt * sizeof(CFStringRef), 0);
CFDictionaryRef dict;
CFArrayRef sessionsWatchingKey;
CFIndex watcherCnt;
- void **watchers;
+ const void **watchers;
CFDictionaryRef info;
CFMutableDictionaryRef newInfo;
CFArrayRef changes;
*/
sessionsWatchingKey = CFDictionaryGetValue(dict, kSCDWatchers);
watcherCnt = CFArrayGetCount(sessionsWatchingKey);
- watchers = CFAllocatorAllocate(NULL, watcherCnt * sizeof(CFNumberRef), 0);
- CFArrayGetValues(sessionsWatchingKey,
- CFRangeMake(0, CFArrayGetCount(sessionsWatchingKey)),
- watchers);
- while (--watcherCnt >= 0) {
- CFStringRef sessionKey;
-
- sessionKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), watchers[watcherCnt]);
- info = CFDictionaryGetValue(sessionData, sessionKey);
- if (info) {
- newInfo = CFDictionaryCreateMutableCopy(NULL, 0, info);
- } else {
- newInfo = CFDictionaryCreateMutable(NULL,
- 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
+ if (watcherCnt > 0) {
+ watchers = CFAllocatorAllocate(NULL, watcherCnt * sizeof(CFNumberRef), 0);
+ CFArrayGetValues(sessionsWatchingKey,
+ CFRangeMake(0, CFArrayGetCount(sessionsWatchingKey)),
+ watchers);
+ while (--watcherCnt >= 0) {
+ CFStringRef sessionKey;
+
+ sessionKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), watchers[watcherCnt]);
+ info = CFDictionaryGetValue(sessionData, sessionKey);
+ if (info) {
+ newInfo = CFDictionaryCreateMutableCopy(NULL, 0, info);
+ } else {
+ newInfo = CFDictionaryCreateMutable(NULL,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ }
+
+ changes = CFDictionaryGetValue(newInfo, kSCDChangedKeys);
+ if (changes) {
+ newChanges = CFArrayCreateMutableCopy(NULL, 0, changes);
+ } else {
+ newChanges = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ }
+
+ if (CFArrayContainsValue(newChanges,
+ CFRangeMake(0, CFArrayGetCount(newChanges)),
+ (CFStringRef)keys[keyCnt]) == FALSE) {
+ CFArrayAppendValue(newChanges, (CFStringRef)keys[keyCnt]);
+ }
+ CFDictionarySetValue(newInfo, kSCDChangedKeys, newChanges);
+ CFRelease(newChanges);
+ CFDictionarySetValue(sessionData, sessionKey, newInfo);
+ CFRelease(newInfo);
+ CFRelease(sessionKey);
+
+ /*
+ * flag this session as needing a kick
+ */
+ if (needsNotification == NULL)
+ needsNotification = CFSetCreateMutable(NULL,
+ 0,
+ &kCFTypeSetCallBacks);
+ CFSetAddValue(needsNotification, watchers[watcherCnt]);
}
-
- changes = CFDictionaryGetValue(newInfo, kSCDChangedKeys);
- if (changes) {
- newChanges = CFArrayCreateMutableCopy(NULL, 0, changes);
- } else {
- newChanges = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- }
-
- if (CFArrayContainsValue(newChanges,
- CFRangeMake(0, CFArrayGetCount(newChanges)),
- (CFStringRef)keys[keyCnt]) == FALSE) {
- CFArrayAppendValue(newChanges, (CFStringRef)keys[keyCnt]);
- }
- CFDictionarySetValue(newInfo, kSCDChangedKeys, newChanges);
- CFRelease(newChanges);
- CFDictionarySetValue(sessionData, sessionKey, newInfo);
- CFRelease(newInfo);
- CFRelease(sessionKey);
-
- /*
- * flag this session as needing a kick
- */
- if (needsNotification == NULL)
- needsNotification = CFSetCreateMutable(NULL,
- 0,
- &kCFTypeSetCallBacks);
- CFSetAddValue(needsNotification, watchers[watcherCnt]);
+ CFAllocatorDeallocate(NULL, watchers);
}
- CFAllocatorDeallocate(NULL, watchers);
}
CFAllocatorDeallocate(NULL, keys);
_processDeferredRemovals()
{
CFIndex keyCnt;
- void **keys;
+ const void **keys;
- if ((keyCnt = CFSetGetCount(deferredRemovals)) == 0)
+ keyCnt = CFSetGetCount(deferredRemovals);
+ if (keyCnt == 0)
return; /* if nothing to do */
keys = CFAllocatorAllocate(NULL, keyCnt * sizeof(CFStringRef), 0);
while (--keyCnt >= 0) {
CFDictionaryApplyFunction(sessionData,
(CFDictionaryApplierFunction)_removeRegexWatchersBySession,
- keys[keyCnt]);
+ (void *)keys[keyCnt]);
}
CFAllocatorDeallocate(NULL, keys);
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
CFRelease(newRData);
CFDictionarySetValue(sessionData, sessionKey, newInfo);
}
+ CFRelease(regexData);
CFRelease(newInfo);
CFRelease(sessionKey);
} else {
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Add notification key for this session."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
CFArrayRef notifierKeys; /* array of CFStringRef's */
- CFDataRef xmlList; /* list (XML serialized) */
+ Boolean ok;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("List notification keys which have changed."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
+ *listRef = NULL;
+ *listLen = 0;
+
*sc_status = __SCDynamicStoreCopyNotifiedKeys(mySession->store, ¬ifierKeys);
if (*sc_status != kSCStatusOK) {
- *listRef = NULL;
- *listLen = 0;
return KERN_SUCCESS;
}
- /*
- * serialize the array, copy it into an allocated buffer which will be
- * released when it is returned as part of a Mach message.
- */
- xmlList = CFPropertyListCreateXMLData(NULL, notifierKeys);
+ /* serialize the array of keys */
+ ok = _SCSerialize(notifierKeys, NULL, (void **)listRef, (CFIndex *)listLen);
CFRelease(notifierKeys);
- *listLen = CFDataGetLength(xmlList);
- status = vm_allocate(mach_task_self(), (void *)listRef, *listLen, TRUE);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_allocate(): %s"), mach_error_string(status));
- CFRelease(xmlList);
- *listRef = NULL;
- *listLen = 0;
+ if (!ok) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
}
- bcopy((char *)CFDataGetBytePtr(xmlList), *listRef, *listLen);
- CFRelease(xmlList);
-
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
int *sc_status
)
{
- kern_return_t status;
serverSessionRef mySession = getSession(server);
- CFDataRef xmlKey; /* key (XML serialized) */
CFStringRef key; /* key (un-serialized) */
- CFStringRef xmlError;
SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Remove notification key for this session."));
SCLog(_configd_verbose, LOG_DEBUG, CFSTR(" server = %d"), server);
/* un-serialize the key */
- xmlKey = CFDataCreate(NULL, keyRef, keyLen);
- status = vm_deallocate(mach_task_self(), (vm_address_t)keyRef, keyLen);
- if (status != KERN_SUCCESS) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("vm_deallocate(): %s"), mach_error_string(status));
- /* non-fatal???, proceed */
- }
- key = CFPropertyListCreateFromXMLData(NULL,
- xmlKey,
- kCFPropertyListImmutable,
- &xmlError);
- CFRelease(xmlKey);
- if (!key) {
- if (xmlError) {
- SCLog(_configd_verbose, LOG_DEBUG,
- CFSTR("CFPropertyListCreateFromXMLData() key: %@"),
- xmlError);
- CFRelease(xmlError);
- }
+ if (!_SCUnserialize((CFPropertyListRef *)&key, (void *)keyRef, keyLen)) {
*sc_status = kSCStatusFailed;
return KERN_SUCCESS;
- } else if (!isA_CFString(key)) {
+ }
+
+ if (!isA_CFString(key)) {
+ CFRelease(key);
*sc_status = kSCStatusInvalidArgument;
return KERN_SUCCESS;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
if (pid == getpid()) {
/* sorry, you can't request that configd be signalled */
- return kSCStatusFailed;
+ return kSCStatusInvalidArgument;
}
if ((sig <= 0) || (sig > NSIG)) {
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
xmlData = CFPropertyListCreateXMLData(NULL, storeData);
+ if (!xmlData) {
+ SCLog(TRUE, LOG_ERR, CFSTR("CFPropertyListCreateXMLData() failed"));
+ close(fd);
+ return kSCStatusFailed;
+ }
(void) write(fd, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData));
(void) close(fd);
CFRelease(xmlData);
/* Save a snapshot of the "session" data */
xmlData = CFPropertyListCreateXMLData(NULL, sessionData);
+ if (!xmlData) {
+ SCLog(TRUE, LOG_ERR, CFSTR("CFPropertyListCreateXMLData() failed"));
+ close(fd);
+ return kSCStatusFailed;
+ }
(void) write(fd, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData));
(void) close(fd);
CFRelease(xmlData);
* As such... IF YOU CHANGE THE ".defs" FILE, MAKE CLEAN!
*/
-#import "../SystemConfiguration.fproj/config.defs"
\ No newline at end of file
+#include <SystemConfiguration/config.defs>
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include "configd_server.h"
#include "plugin_support.h"
-Boolean _configd_fork = TRUE; /* TRUE if process should be run in the background */
-Boolean _configd_verbose = FALSE; /* TRUE if verbose logging enabled */
+Boolean _configd_fork = TRUE; /* TRUE if process should be run in the background */
+Boolean _configd_verbose = FALSE; /* TRUE if verbose logging enabled */
CFMutableSetRef _plugins_exclude = NULL; /* bundle identifiers to exclude from loading */
CFMutableSetRef _plugins_verbose = NULL; /* bundle identifiers to enable verbose logging */
(void) chdir("/");
- if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+ fd = open(_PATH_DEVNULL, O_RDWR, 0);
+ if (fd != -1) {
+ int ofd;
+
+ // stdin
(void) dup2(fd, STDIN_FILENO);
+
+ // stdout, stderr
+ ofd = open("/var/log/configd.log", O_WRONLY|O_APPEND, 0);
+ if (ofd != -1) {
+ if (fd > STDIN_FILENO) {
+ (void) close(fd);
+ }
+ fd = ofd;
+ }
(void) dup2(fd, STDOUT_FILENO);
(void) dup2(fd, STDERR_FILENO);
- if (fd > 2)
+ if (fd > STDERR_FILENO) {
(void) close(fd);
+ }
}
return 0;
}
+
+static void
+writepid(void)
+{
+ FILE *fp;
+
+ fp = fopen("/var/run/configd.pid", "w");
+ if (fp != NULL) {
+ fprintf(fp, "%d\n", getpid());
+ fclose(fp);
+ }
+}
+
+
int
-main(int argc, const char *argv[])
+main(int argc, char * const argv[])
{
Boolean loadBundles = TRUE;
struct sigaction nact;
/* now the child process, parent waits in fork_child */
}
+ /* record process id */
+ if (testBundle == NULL) {
+ writepid();
+ }
+
/* open syslog() facility */
if (_configd_fork) {
int logopt = LOG_NDELAY|LOG_PID;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
boolean_t
server_active()
{
- kern_return_t status;
- mach_port_t bootstrap_port;
boolean_t active;
+ mach_port_t bootstrap_port;
+ char *server_name;
+ kern_return_t status;
+
+ server_name = getenv("SCD_SERVER");
+ if (!server_name) {
+ server_name = SCD_SERVER;
+ }
/* Getting bootstrap server port */
status = task_get_bootstrap_port(mach_task_self(), &bootstrap_port);
}
/* Check "configd" server status */
- status = bootstrap_status(bootstrap_port, SCD_SERVER, &active);
+ status = bootstrap_status(bootstrap_port, server_name, &active);
switch (status) {
case BOOTSTRAP_SUCCESS :
if (active) {
fprintf(stderr, "configd: '%s' server already active\n",
- SCD_SERVER);
+ server_name);
return TRUE;
}
break;
void
server_init()
{
- kern_return_t status;
- mach_port_t bootstrap_port;
boolean_t active;
+ mach_port_t bootstrap_port;
CFRunLoopSourceRef rls;
+ char *server_name;
+ kern_return_t status;
+
+ server_name = getenv("SCD_SERVER");
+ if (!server_name) {
+ server_name = SCD_SERVER;
+ }
/* Getting bootstrap server port */
status = task_get_bootstrap_port(mach_task_self(), &bootstrap_port);
}
/* Check "configd" server status */
- status = bootstrap_status(bootstrap_port, SCD_SERVER, &active);
+ status = bootstrap_status(bootstrap_port, server_name, &active);
switch (status) {
case BOOTSTRAP_SUCCESS :
if (active) {
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("\"%s\" is currently active, exiting."), SCD_SERVER);
+ SCLog(_configd_verbose, LOG_DEBUG, CFSTR("\"%s\" is currently active, exiting."), server_name);
exit (EX_UNAVAILABLE);
}
break;
/* Create a session for the primary / new connection port */
(void) addSession(configd_port);
- SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Registering service \"%s\""), SCD_SERVER);
- status = bootstrap_register(bootstrap_port, SCD_SERVER, CFMachPortGetPort(configd_port));
+ SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Registering service \"%s\""), server_name);
+ status = bootstrap_register(bootstrap_port, server_name, CFMachPortGetPort(configd_port));
switch (status) {
case BOOTSTRAP_SUCCESS :
/* service not currently registered, "a good thing" (tm) */
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
void
pushNotifications()
{
- void **sessionsToNotify;
+ const void **sessionsToNotify;
CFIndex notifyCnt;
int server;
serverSessionRef theSession;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include "configd.h"
#include <SystemConfiguration/SCDPlugin.h>
+void _SCDPluginExecInit();
/*
}
if (!bundleVerbose) {
- dict = CFBundleGetInfoDictionary(bundle);
- if (isA_CFDictionary(dict)) {
- CFBooleanRef bool;
+ dict = CFBundleGetInfoDictionary(bundle);
+ if (isA_CFDictionary(dict)) {
+ CFBooleanRef bVal;
- bool = CFDictionaryGetValue(dict, kSCBundleVerbose);
- if (isA_CFBoolean(bool) && CFBooleanGetValue(bool)) {
+ bVal = CFDictionaryGetValue(dict, kSCBundleVerbose);
+ if (isA_CFBoolean(bVal) && CFBooleanGetValue(bVal)) {
bundleVerbose = TRUE;
}
}
}
+#ifdef DEBUG
+
static void
timerCallback(CFRunLoopTimerRef timer, void *info)
{
return;
}
+#endif /* DEBUG */
+
static void
sortBundles(CFMutableArrayRef orig)
Boolean inserted = FALSE;
for (i = 0; i < CFArrayGetCount(orig); i++) {
- CFBundleRef bundle1 = CFArrayGetValueAtIndex(orig, i);
+ CFBundleRef bundle1 = (CFBundleRef)CFArrayGetValueAtIndex(orig, i);
CFStringRef bundleID1 = CFBundleGetIdentifier(bundle1);
int count;
CFDictionaryRef dict;
CFStringRef r = CFArrayGetValueAtIndex(requires, j);
for (k = 0; k < CFArrayGetCount(new); k++) {
- CFBundleRef bundle2 = CFArrayGetValueAtIndex(new, k);
+ CFBundleRef bundle2 = (CFBundleRef)CFArrayGetValueAtIndex(new, k);
CFStringRef bundleID2 = CFBundleGetIdentifier(bundle2);
if (bundleID2 && CFEqual(bundleID2, r)) {
/* keep track of bundles */
allBundles = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ /* allow plug-ins to exec child/helper processes */
+ _SCDPluginExecInit();
+
if (arg == NULL) {
char path[MAXPATHLEN];
NSSearchPathEnumerationState state;
primeBundle,
NULL);
+#ifdef DEBUG
if (arg == NULL && (nLoaded > 0)) {
CFRunLoopTimerRef timer;
/* allocate a periodic event (to help show we're not blocking) */
- timer = CFRunLoopTimerCreate(NULL, /* allocator */
- CFAbsoluteTimeGetCurrent() + 1.0, /* fireDate */
- 60.0, /* interval */
- 0, /* flags */
- 0, /* order */
- timerCallback, /* callout */
- NULL); /* context */
- CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode);
- CFRelease(timer);
- }
+ timer = CFRunLoopTimerCreate(NULL, /* allocator */
+ CFAbsoluteTimeGetCurrent() + 1.0, /* fireDate */
+ 60.0, /* interval */
+ 0, /* flags */
+ 0, /* order */
+ timerCallback, /* callout */
+ NULL); /* context */
+ CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode);
+ CFRelease(timer);
+ }
+#endif /* DEBUG */
if (_configd_fork) {
/* synchronize with parent process */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>CurrentSet</key>
+ <string>/Sets/0</string>
+ <key>NetworkServices</key>
+ <dict>
+ <key>0</key>
+ <dict>
+ <key>AppleTalk</key>
+ <dict>
+ <key>ConfigMethod</key>
+ <string>Node</string>
+ <key>__INACTIVE__</key>
+ <integer>1</integer>
+ </dict>
+ <key>DNS</key>
+ <dict/>
+ <key>Ethernet</key>
+ <dict>
+ </dict>
+ <key>IPv4</key>
+ <dict>
+ <key>ConfigMethod</key>
+ <string>DHCP</string>
+ </dict>
+ <key>Interface</key>
+ <dict>
+ <key>DeviceName</key>
+ <string>en0</string>
+ <key>Hardware</key>
+ <string>Ethernet</string>
+ <key>Type</key>
+ <string>Ethernet</string>
+ <key>UserDefinedName</key>
+ <string>Built-in Ethernet</string>
+ </dict>
+ <key>PPP</key>
+ <dict>
+ <key>CommDisplayTerminalWindow</key>
+ <integer>0</integer>
+ <key>CommRedialCount</key>
+ <integer>1</integer>
+ <key>CommRedialEnabled</key>
+ <integer>1</integer>
+ <key>CommRedialInterval</key>
+ <integer>30</integer>
+ <key>DialOnDemand</key>
+ <integer>0</integer>
+ <key>DisconnectOnIdle</key>
+ <integer>1</integer>
+ <key>DisconnectOnIdleTimer</key>
+ <integer>600</integer>
+ <key>DisconnectOnLogout</key>
+ <integer>0</integer>
+ <key>IPCPCompressionVJ</key>
+ <integer>1</integer>
+ <key>IdleReminder</key>
+ <integer>1</integer>
+ <key>IdleReminderTimer</key>
+ <integer>900</integer>
+ <key>LCPEchoEnabled</key>
+ <integer>1</integer>
+ <key>LCPEchoFailure</key>
+ <integer>4</integer>
+ <key>LCPEchoInterval</key>
+ <integer>10</integer>
+ <key>Logfile</key>
+ <string>/tmp/ppp.log</string>
+ <key>VerboseLogging</key>
+ <integer>0</integer>
+ <key>__INACTIVE__</key>
+ <integer>1</integer>
+ </dict>
+ <key>Proxies</key>
+ <dict>
+ <key>FTPEnable</key>
+ <integer>0</integer>
+ <key>FTPPassive</key>
+ <integer>1</integer>
+ <key>GopherEnable</key>
+ <integer>0</integer>
+ <key>HTTPEnable</key>
+ <integer>0</integer>
+ <key>HTTPSEnable</key>
+ <integer>0</integer>
+ <key>RTSPEnable</key>
+ <integer>0</integer>
+ <key>SOCKSEnable</key>
+ <integer>0</integer>
+ </dict>
+ <key>UserDefinedName</key>
+ <string>Built-in Ethernet</string>
+ </dict>
+ </dict>
+ <key>Sets</key>
+ <dict>
+ <key>0</key>
+ <dict>
+ <key>Network</key>
+ <dict>
+ <key>Global</key>
+ <dict>
+ <key>IPv4</key>
+ <dict>
+ <key>PPPOverridePrimary</key>
+ <integer>0</integer>
+ <key>ServiceOrder</key>
+ <array>
+ <string>0</string>
+ </array>
+ </dict>
+ <key>NetInfo</key>
+ <dict>
+ <key>BindingMethods</key>
+ <array>
+ <string>DHCP</string>
+ </array>
+ </dict>
+ </dict>
+ <key>Service</key>
+ <dict>
+ <key>0</key>
+ <dict>
+ <key>__LINK__</key>
+ <string>/NetworkServices/0</string>
+ </dict>
+ </dict>
+ </dict>
+ <key>UserDefinedName</key>
+ <string>Automatic</string>
+ </dict>
+ </dict>
+ <key>System</key>
+ <dict>
+ </dict>
+</dict>
+</plist>
PROF_LIBS = $(LIBS)
-NEXTSTEP_PB_CFLAGS = -DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS
FRAMEWORKS = -framework CoreFoundation -framework SystemConfiguration
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
NEXTSTEP_BUILDTOOL = /usr/bin/gnumake;
- NEXTSTEP_COMPILEROPTIONS = "-DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS";
NEXTSTEP_INSTALLDIR = /usr/sbin;
NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
SCPreferencesRef session;
CFDictionaryRef sets;
CFIndex nSets;
- void **setKeys;
- void **setVals;
+ const void **setKeys = NULL;
+ const void **setVals = NULL;
CFIndex i;
/* process any arguments */
}
nSets = CFDictionaryGetCount(sets);
- setKeys = CFAllocatorAllocate(NULL, nSets * sizeof(CFStringRef), 0);
- setVals = CFAllocatorAllocate(NULL, nSets * sizeof(CFDictionaryRef), 0);
- CFDictionaryGetKeysAndValues(sets, setKeys, setVals);
+ if (nSets > 0) {
+ setKeys = CFAllocatorAllocate(NULL, nSets * sizeof(CFStringRef), 0);
+ setVals = CFAllocatorAllocate(NULL, nSets * sizeof(CFDictionaryRef), 0);
+ CFDictionaryGetKeysAndValues(sets, setKeys, setVals);
+ }
/* check for set with matching name */
for (i=0; i<nSets; i++) {
PROF_LIBS = $(LIBS)
-NEXTSTEP_PB_CFLAGS = -DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS
FRAMEWORKS = -framework CoreFoundation -framework SystemConfiguration
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
NEXTSTEP_BUILDTOOL = /usr/bin/gnumake;
- NEXTSTEP_COMPILEROPTIONS = "-DUSE_SYSTEMCONFIGURATION_PUBLIC_APIS";
NEXTSTEP_INSTALLDIR = /usr/sbin;
NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
list = SCDynamicStoreCopyKeyList(store, pattern);
CFRelease(pattern);
if (!list) {
- SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
+ if (SCError() != kSCStatusOK) {
+ SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
+ } else {
+ SCPrint(TRUE, stdout, CFSTR(" no keys.\n"));
+ }
return;
}
CFArrayGetValueAtIndex(sortedList, i));
}
} else {
- SCPrint(TRUE, stdout, CFSTR(" no subKey's.\n"));
+ SCPrint(TRUE, stdout, CFSTR(" no keys.\n"));
}
CFRelease(sortedList);
return;
}
- if (CFGetTypeID(value) != CFDictionaryGetTypeID()) {
+ if (!isA_CFDictionary(value)) {
SCPrint(TRUE, stdout, CFSTR("d.add: data (fetched from configuration server) is not a dictionary.\n"));
return;
}
return;
}
- if (CFGetTypeID(value) != CFDictionaryGetTypeID()) {
+ if (!isA_CFDictionary(value)) {
SCPrint(TRUE, stdout, CFSTR("d.remove: data (fetched from configuration server) is not a dictionary.\n"));
return;
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
for (i=0; i<n; i++) {
SCPrint(TRUE,
stdout,
- CFSTR(" changedKey [%d] = %@\n"),
+ CFSTR(" changed key [%d] = %@\n"),
i,
CFArrayGetValueAtIndex(changedKeys, i));
}
} else {
- SCPrint(TRUE, stdout, CFSTR(" no changedKey's.\n"));
+ SCPrint(TRUE, stdout, CFSTR(" no changed key's.\n"));
}
return;
list = SCDynamicStoreCopyWatchedKeyList(store, isRegex);
if (!list) {
- SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
+ if (SCError() != kSCStatusOK) {
+ SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError()));
+ } else {
+ SCPrint(TRUE,
+ stdout,
+ CFSTR(" no notifier %s.\n"),
+ isRegex ? "patterns" : "keys");
+ }
return;
}
for (i=0; i<listCnt; i++) {
SCPrint(TRUE,
stdout,
- CFSTR(" notifierKey [%d] = %@\n"),
+ CFSTR(" notifier %s [%d] = %@\n"),
+ isRegex ? "pattern" : "key",
i,
CFArrayGetValueAtIndex(sortedList, i));
}
} else {
- SCPrint(TRUE, stdout, CFSTR(" no notifierKey's.\n"));
+ SCPrint(TRUE,
+ stdout,
+ CFSTR(" no notifier %s.\n"),
+ isRegex ? "patterns" : "keys");
}
CFRelease(sortedList);
}
-static char *signames[] = {
- "" , "HUP" , "INT" , "QUIT", "ILL" , "TRAP", "ABRT", "EMT" ,
- "FPE" , "KILL", "BUS" , "SEGV", "SYS" , "PIPE", "ALRM", "TERM",
- "URG" , "STOP", "TSTP" , "CONT", "CHLD" , "TTIN", "TTOU", "IO" ,
- "XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "INFO", "USR1",
- "USR2"
-};
-
-
static void
signalCatcher(int signum)
{
static int n = 0;
- SCPrint(TRUE, stdout, CFSTR("Received SIG%s (#%d).\n"), signames[signum], n++);
+ SCPrint(TRUE, stdout, CFSTR("Received sig%s (#%d).\n"), sys_signame[signum], n++);
return;
}
}
} else {
for (sig=1; sig<NSIG; sig++) {
- if (strcasecmp(argv[0], signames[sig]) == 0)
+ if (strcasecmp(argv[0], sys_signame[sig]) == 0)
break;
}
if (sig >= NSIG) {
str = CFStringCreateMutable(NULL, 0);
for (sig=1; sig<NSIG; sig++) {
- CFStringAppendFormat(str, NULL, CFSTR(" %-6s"), signames[sig]);
+ CFStringAppendFormat(str, NULL, CFSTR(" %-6s"), sys_signame[sig]);
if ((sig % 10) == 0) {
CFStringAppendFormat(str, NULL, CFSTR("\n"));
}
/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
return FALSE;
if (nesting > 0) {
- SCPrint(TRUE, stdout, CFSTR("%d> %s"), nesting, line);
+ SCPrint(TRUE, stdout, CFSTR("%d> %s\n"), nesting, line);
}
/* if requested, exit */
int
-main(int argc, const char *argv[])
+main(int argc, char * const argv[])
{
CFSocketContext context = { 0, stdin, NULL, NULL, NULL };
char *dest = NULL;
case '?':
default :
usage(prog);
- }
+ }
argc -= optind;
argv += optind;
#include <sys/cdefs.h>
#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCValidation.h>
#include <SystemConfiguration/SCPrivate.h>