SCPreferencesPathKey.c [plain text]
#include <SystemConfiguration/SystemConfiguration.h>
#include <stdarg.h>
__private_extern__ CFStringRef
SCPreferencesPathKeyCreate(CFAllocatorRef allocator,
CFStringRef fmt,
...)
{
va_list args;
CFStringRef result;
va_start(args, fmt);
result = CFStringCreateWithFormatAndArguments(allocator,
NULL,
fmt,
args);
va_end(args);
return result;
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateNetworkServices(CFAllocatorRef allocator)
{
return CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@"),
kSCPrefNetworkServices);
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateNetworkServiceEntity(CFAllocatorRef allocator,
CFStringRef service,
CFStringRef entity)
{
CFStringRef path;
if (entity == NULL) {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@"),
kSCPrefNetworkServices,
service);
} else {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@"),
kSCPrefNetworkServices,
service,
entity);
}
return path;
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSets(CFAllocatorRef allocator)
{
return (CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@"),
kSCPrefSets));
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSet(CFAllocatorRef allocator,
CFStringRef set)
{
return (CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@"),
kSCPrefSets,
set));
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSetNetworkGlobalEntity(CFAllocatorRef allocator,
CFStringRef set,
CFStringRef entity)
{
return CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompGlobal,
entity);
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSetNetworkInterfaceEntity(CFAllocatorRef allocator,
CFStringRef set,
CFStringRef ifname,
CFStringRef entity)
{
return CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompInterface,
ifname,
entity);
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSetNetworkService(CFAllocatorRef allocator,
CFStringRef set,
CFStringRef service)
{
CFStringRef path;
if (service == NULL) {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompService);
} else {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompService,
service);
}
return path;
}
__private_extern__ CFStringRef
SCPreferencesPathKeyCreateSetNetworkServiceEntity(CFAllocatorRef allocator,
CFStringRef set,
CFStringRef service,
CFStringRef entity)
{
CFStringRef path;
if (entity == NULL) {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompService,
service);
} else {
path = CFStringCreateWithFormat(allocator,
NULL,
CFSTR("/%@/%@/%@/%@/%@/%@"),
kSCPrefSets,
set,
kSCCompNetwork,
kSCCompService,
service,
entity);
}
return path;
}