]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferencesInternal.h
configd-963.200.27.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCPreferencesInternal.h
1 /*
2 * Copyright (c) 2000, 2001, 2003-2005, 2007-2011, 2013-2016 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _SCPREFERENCESINTERNAL_H
25 #define _SCPREFERENCESINTERNAL_H
26
27 #include <dispatch/dispatch.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/time.h>
31 #include <os/log.h>
32 #include <CoreFoundation/CoreFoundation.h>
33 #include <CoreFoundation/CFRuntime.h>
34
35 #ifndef SC_LOG_HANDLE
36 #define SC_LOG_HANDLE __log_SCPreferences()
37 #endif // SC_LOG_HANDLE
38 #include <SystemConfiguration/SystemConfiguration.h>
39 #include <SystemConfiguration/SCValidation.h>
40 #include <SystemConfiguration/SCPrivate.h>
41
42 #include <SystemConfiguration/SCPreferences.h>
43 #include <SystemConfiguration/SCDynamicStore.h>
44
45
46 #define PREFS_DEFAULT_DIR CFSTR("/Library/Preferences/SystemConfiguration")
47 #define PREFS_DEFAULT_CONFIG CFSTR("preferences.plist")
48
49 #define PREFS_DEFAULT_DIR_OLD CFSTR("/var/db/SystemConfiguration")
50 #define PREFS_DEFAULT_CONFIG_OLD CFSTR("preferences.xml")
51
52 #define PREFS_DEFAULT_USER_DIR CFSTR("Library/Preferences")
53
54 #define NETWORK_INTERFACES_PREFS CFSTR("NetworkInterfaces.plist")
55 #define INTERFACES CFSTR("Interfaces")
56
57
58 /* Define the per-preference-handle structure */
59 typedef struct {
60
61 /* base CFType information */
62 CFRuntimeBase cfBase;
63
64 /* lock */
65 pthread_mutex_t lock;
66
67 /* session name */
68 CFStringRef name;
69
70 /* preferences ID */
71 CFStringRef prefsID;
72
73 /* options */
74 CFDictionaryRef options;
75
76 /* configuration file */
77 char *path;
78 char *newPath;
79
80 /* preferences lock, lock file */
81 Boolean locked;
82 int lockFD;
83 char *lockPath;
84 struct timeval lockTime;
85
86 /* configuration file signature */
87 CFDataRef signature;
88
89 /* configd session */
90 SCDynamicStoreRef session;
91 SCDynamicStoreRef sessionNoO_EXLOCK;
92 int sessionRefcnt;
93
94 /* configd session keys */
95 CFStringRef sessionKeyLock;
96 CFStringRef sessionKeyCommit;
97 CFStringRef sessionKeyApply;
98
99 /* run loop source, callout, context, rl scheduling info */
100 Boolean scheduled;
101 CFRunLoopSourceRef rls;
102 SCPreferencesCallBack rlsFunction;
103 SCPreferencesContext rlsContext;
104 CFMutableArrayRef rlList;
105 dispatch_queue_t dispatchQueue; // SCPreferencesSetDispatchQueue
106
107 /* preferences */
108 CFMutableDictionaryRef prefs;
109
110 /* flags */
111 Boolean accessed;
112 Boolean changed;
113 Boolean isRoot;
114 Boolean limit_SCNetworkConfiguration;
115
116 /* authorization, helper */
117 CFDataRef authorizationData;
118 mach_port_t helper_port;
119
120 } SCPreferencesPrivate, *SCPreferencesPrivateRef;
121
122
123 /* Define signature data */
124 typedef struct {
125 int64_t st_dev; /* inode's device */
126 uint64_t st_ino; /* inode's number */
127 uint64_t tv_sec; /* time of last data modification */
128 uint64_t tv_nsec;
129 off_t st_size; /* file size, in bytes */
130 } SCPSignatureData, *SCPSignatureDataRef;
131
132
133 __BEGIN_DECLS
134
135 os_log_t
136 __log_SCPreferences (void);
137
138 Boolean
139 __SCPreferencesCreate_helper (SCPreferencesRef prefs);
140
141 void
142 __SCPreferencesAccess (SCPreferencesRef prefs);
143
144 void
145 __SCPreferencesAddSessionKeys (SCPreferencesRef prefs);
146
147 Boolean
148 __SCPreferencesAddSession (SCPreferencesRef prefs);
149
150 void
151 __SCPreferencesRemoveSession (SCPreferencesRef prefs);
152
153 CF_RETURNS_RETAINED
154 CFDataRef
155 __SCPSignatureFromStatbuf (const struct stat *statBuf);
156
157 char *
158 __SCPreferencesPath (CFAllocatorRef allocator,
159 CFStringRef prefsID,
160 Boolean useNewPrefs);
161
162 CF_RETURNS_RETAINED
163 CFStringRef
164 _SCPNotificationKey (CFAllocatorRef allocator,
165 CFStringRef prefsID,
166 int keyType);
167 Boolean
168 __SCPreferencesGetLimitSCNetworkConfiguration (SCPreferencesRef prefs);
169
170 void
171 __SCPreferencesSetLimitSCNetworkConfiguration
172 (SCPreferencesRef prefs,
173 Boolean limit_SCNetworkConfiguration);
174
175 Boolean
176 __SCPreferencesUsingDefaultPrefs (SCPreferencesRef prefs);
177
178 SCPreferencesRef
179 __SCPreferencesCreateNIPrefsFromPrefs (SCPreferencesRef prefs);
180
181 __END_DECLS
182
183 #endif /* _SCPREFERENCESINTERNAL_H */