/*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* - initial revision
*/
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreFoundation/CFStringDefaultEncoding.h> // for __CFStringGetUserDefaultEncoding
#include <SystemConfiguration/SystemConfiguration.h>
#include <SystemConfiguration/SCValidation.h>
#include <SystemConfiguration/SCPrivate.h>
+
+#pragma mark ComputerName
+
+
CFStringRef
SCDynamicStoreKeyCreateComputerName(CFAllocatorRef allocator)
{
CFDictionarySetValue(newDict, kSCPropSystemComputerName, name);
- num = CFNumberCreate(NULL, kCFNumberIntType, &encoding);
+ num = CFNumberCreate(NULL, kCFNumberSInt32Type, &encoding);
CFDictionarySetValue(newDict, kSCPropSystemComputerNameEncoding, num);
CFRelease(num);
+ CFDictionaryRemoveValue(newDict, kSCPropSystemComputerNameRegion);
+ if (encoding == kCFStringEncodingMacRoman) {
+ UInt32 userEncoding = 0;
+ UInt32 userRegion = 0;
+
+ __CFStringGetUserDefaultEncoding(&userEncoding, &userRegion);
+ if ((userEncoding == kCFStringEncodingMacRoman) && (userRegion != 0)) {
+ num = CFNumberCreate(NULL, kCFNumberSInt32Type, &userRegion);
+ CFDictionarySetValue(newDict, kSCPropSystemComputerNameRegion, num);
+ CFRelease(num);
+ }
+ }
+
ok = SCPreferencesPathSetValue(prefs, path, newDict);
CFRelease(path);
}
-#ifndef kSCPropNetHostName
-#define kSCPropNetHostName CFSTR("HostName")
-#endif
+#pragma mark -
+#pragma mark HostName
CFStringRef
return NULL;
}
- name = isA_CFString(CFDictionaryGetValue(dict, kSCPropNetHostName));
+ name = isA_CFString(CFDictionaryGetValue(dict, kSCPropSystemHostName));
if (name == NULL) {
_SCErrorSet(kSCStatusNoKey);
return NULL;
}
if (name != NULL) {
- CFDictionarySetValue(newDict, kSCPropNetHostName, name);
+ CFDictionarySetValue(newDict, kSCPropSystemHostName, name);
} else {
- CFDictionaryRemoveValue(newDict, kSCPropNetHostName);
+ CFDictionaryRemoveValue(newDict, kSCPropSystemHostName);
}
if (CFDictionaryGetCount(newDict) > 0) {
}
+#pragma mark -
+#pragma mark LocalHostName
+
+
CFStringRef
SCDynamicStoreKeyCreateHostNames(CFAllocatorRef allocator)
{
return TRUE;
}
+
Boolean
_SC_CFStringIsValidDNSName(CFStringRef name)
{
return ok;
}
+
+
+Boolean
+_SC_CFStringIsValidNetBIOSName(CFStringRef name)
+{
+ if (!isA_CFString(name)) {
+ return FALSE;
+ }
+
+ if (CFStringGetLength(name) > 15) {
+ return FALSE;
+ }
+
+ return TRUE;
+}