]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCPreferencesInternal.h
configd-395.6.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / SCPreferencesInternal.h
1 /*
2 * Copyright (c) 2000, 2001, 2003-2005, 2007-2011 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 #include <dispatch/dispatch.h>
35
36
37 #define PREFS_DEFAULT_DIR CFSTR("/Library/Preferences/SystemConfiguration")
38 #define PREFS_DEFAULT_CONFIG CFSTR("preferences.plist")
39
40 #define PREFS_DEFAULT_DIR_OLD CFSTR("/var/db/SystemConfiguration")
41 #define PREFS_DEFAULT_CONFIG_OLD CFSTR("preferences.xml")
42
43 #define PREFS_DEFAULT_USER_DIR CFSTR("Library/Preferences")
44
45
46 /* Define the per-preference-handle structure */
47 typedef struct {
48
49 /* base CFType information */
50 CFRuntimeBase cfBase;
51
52 /* lock */
53 pthread_mutex_t lock;
54
55 /* session name */
56 CFStringRef name;
57
58 /* preferences ID */
59 CFStringRef prefsID;
60
61 /* options */
62 CFDictionaryRef options;
63
64 /* configuration file */
65 char *path;
66 char *newPath;
67
68 /* preferences lock, lock file */
69 Boolean locked;
70 int lockFD;
71 char *lockPath;
72 struct timeval lockTime;
73
74 /* configuration file signature */
75 CFDataRef signature;
76
77 /* configd session */
78 SCDynamicStoreRef session;
79
80 /* configd session keys */
81 CFStringRef sessionKeyLock;
82 CFStringRef sessionKeyCommit;
83 CFStringRef sessionKeyApply;
84
85 /* run loop source, callout, context, rl scheduling info */
86 Boolean scheduled;
87 CFRunLoopSourceRef rls;
88 SCPreferencesCallBack rlsFunction;
89 SCPreferencesContext rlsContext;
90 CFMutableArrayRef rlList;
91 dispatch_queue_t dispatchQueue; // SCPreferencesSetDispatchQueue
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 mach_port_t helper_port;
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 */