]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferencesInternal.h
b86c07b97877efca0427757450ccc1a577380e7f
[apple/configd.git] / SystemConfiguration.fproj / SCPreferencesInternal.h
1 /*
2 * Copyright (c) 2000, 2001, 2003-2005, 2007-2009 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 <sys/types.h>
28 #include <sys/stat.h>
29 #include <sys/time.h>
30 #include <CoreFoundation/CoreFoundation.h>
31 #include <CoreFoundation/CFRuntime.h>
32 #include <SystemConfiguration/SCPreferences.h>
33 #include <SystemConfiguration/SCDynamicStore.h>
34 #if !TARGET_OS_IPHONE
35 #include <dispatch/dispatch.h>
36 #endif // !TARGET_OS_IPHONE
37
38
39 #define PREFS_DEFAULT_DIR CFSTR("/Library/Preferences/SystemConfiguration")
40 #define PREFS_DEFAULT_CONFIG CFSTR("preferences.plist")
41
42 #define PREFS_DEFAULT_DIR_OLD CFSTR("/var/db/SystemConfiguration")
43 #define PREFS_DEFAULT_CONFIG_OLD CFSTR("preferences.xml")
44
45 #define PREFS_DEFAULT_USER_DIR CFSTR("Library/Preferences")
46
47
48 /* Define the per-preference-handle structure */
49 typedef struct {
50
51 /* base CFType information */
52 CFRuntimeBase cfBase;
53
54 /* lock */
55 pthread_mutex_t lock;
56
57 /* session name */
58 CFStringRef name;
59
60 /* preferences ID */
61 CFStringRef prefsID;
62
63 /* configuration file */
64 char *path;
65 char *newPath;
66
67 /* preferences lock, lock file */
68 Boolean locked;
69 int lockFD;
70 char *lockPath;
71 struct timeval lockTime;
72
73 /* configuration file signature */
74 CFDataRef signature;
75
76 /* configd session */
77 SCDynamicStoreRef session;
78
79 /* configd session keys */
80 CFStringRef sessionKeyCommit;
81 CFStringRef sessionKeyApply;
82
83 /* run loop source, callout, context, rl scheduling info */
84 Boolean scheduled;
85 CFRunLoopSourceRef rls;
86 SCPreferencesCallBack rlsFunction;
87 SCPreferencesContext rlsContext;
88 CFMutableArrayRef rlList;
89 #if !TARGET_OS_IPHONE
90 dispatch_queue_t dispatchQueue; // SCPreferencesSetDispatchQueue
91 #endif // !TARGET_OS_IPHONE
92
93 /* preferences */
94 CFMutableDictionaryRef prefs;
95
96 /* flags */
97 Boolean accessed;
98 Boolean changed;
99 Boolean isRoot;
100
101 /* authorization, helper */
102 CFDataRef authorizationData;
103 int helper;
104
105 } SCPreferencesPrivate, *SCPreferencesPrivateRef;
106
107
108 /* Define signature data */
109 typedef struct {
110 int64_t st_dev; /* inode's device */
111 uint64_t st_ino; /* inode's number */
112 uint64_t tv_sec; /* time of last data modification */
113 uint64_t tv_nsec;
114 off_t st_size; /* file size, in bytes */
115 } SCPSignatureData, *SCPSignatureDataRef;
116
117
118 __BEGIN_DECLS
119
120 Boolean
121 __SCPreferencesCreate_helper (SCPreferencesRef prefs);
122
123 void
124 __SCPreferencesAccess (SCPreferencesRef prefs);
125
126 Boolean
127 __SCPreferencesAddSession (SCPreferencesRef prefs);
128
129 CFDataRef
130 __SCPSignatureFromStatbuf (const struct stat *statBuf);
131
132 char *
133 __SCPreferencesPath (CFAllocatorRef allocator,
134 CFStringRef prefsID,
135 Boolean useNewPrefs);
136
137 CFStringRef
138 _SCPNotificationKey (CFAllocatorRef allocator,
139 CFStringRef prefsID,
140 int keyType);
141
142 __END_DECLS
143
144 #endif /* _SCPREFERENCESINTERNAL_H */