SystemConfiguration.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. {
  2. * Copyright (c) 2000-2004, 2006, 2008-2010 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. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  24. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  25. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  26. {
  27. Modified for use with Free Pascal
  28. Version 308
  29. Please report any bugs to <[email protected]>
  30. }
  31. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  32. {$mode macpas}
  33. {$modeswitch cblocks}
  34. {$packenum 1}
  35. {$macro on}
  36. {$inline on}
  37. {$calling mwpascal}
  38. {$IFNDEF FPC_DOTTEDUNITS}
  39. unit SystemConfiguration;
  40. {$ENDIF FPC_DOTTEDUNITS}
  41. interface
  42. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  43. {$setc GAP_INTERFACES_VERSION := $0308}
  44. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  45. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  46. {$endc}
  47. {$ifc defined CPUPOWERPC and defined CPUI386}
  48. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  49. {$endc}
  50. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  51. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  52. {$endc}
  53. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  54. {$setc __ppc__ := 1}
  55. {$elsec}
  56. {$setc __ppc__ := 0}
  57. {$endc}
  58. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  59. {$setc __ppc64__ := 1}
  60. {$elsec}
  61. {$setc __ppc64__ := 0}
  62. {$endc}
  63. {$ifc not defined __i386__ and defined CPUI386}
  64. {$setc __i386__ := 1}
  65. {$elsec}
  66. {$setc __i386__ := 0}
  67. {$endc}
  68. {$ifc not defined __x86_64__ and defined CPUX86_64}
  69. {$setc __x86_64__ := 1}
  70. {$elsec}
  71. {$setc __x86_64__ := 0}
  72. {$endc}
  73. {$ifc not defined __arm__ and defined CPUARM}
  74. {$setc __arm__ := 1}
  75. {$elsec}
  76. {$setc __arm__ := 0}
  77. {$endc}
  78. {$ifc not defined __arm64__ and defined CPUAARCH64}
  79. {$setc __arm64__ := 1}
  80. {$elsec}
  81. {$setc __arm64__ := 0}
  82. {$endc}
  83. {$ifc defined cpu64}
  84. {$setc __LP64__ := 1}
  85. {$elsec}
  86. {$setc __LP64__ := 0}
  87. {$endc}
  88. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  89. {$error Conflicting definitions for __ppc__ and __i386__}
  90. {$endc}
  91. {$ifc defined __ppc__ and __ppc__}
  92. {$setc TARGET_CPU_PPC := TRUE}
  93. {$setc TARGET_CPU_PPC64 := FALSE}
  94. {$setc TARGET_CPU_X86 := FALSE}
  95. {$setc TARGET_CPU_X86_64 := FALSE}
  96. {$setc TARGET_CPU_ARM := FALSE}
  97. {$setc TARGET_CPU_ARM64 := FALSE}
  98. {$setc TARGET_OS_MAC := TRUE}
  99. {$setc TARGET_OS_IPHONE := FALSE}
  100. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  101. {$setc TARGET_OS_EMBEDDED := FALSE}
  102. {$elifc defined __ppc64__ and __ppc64__}
  103. {$setc TARGET_CPU_PPC := FALSE}
  104. {$setc TARGET_CPU_PPC64 := TRUE}
  105. {$setc TARGET_CPU_X86 := FALSE}
  106. {$setc TARGET_CPU_X86_64 := FALSE}
  107. {$setc TARGET_CPU_ARM := FALSE}
  108. {$setc TARGET_CPU_ARM64 := FALSE}
  109. {$setc TARGET_OS_MAC := TRUE}
  110. {$setc TARGET_OS_IPHONE := FALSE}
  111. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  112. {$setc TARGET_OS_EMBEDDED := FALSE}
  113. {$elifc defined __i386__ and __i386__}
  114. {$setc TARGET_CPU_PPC := FALSE}
  115. {$setc TARGET_CPU_PPC64 := FALSE}
  116. {$setc TARGET_CPU_X86 := TRUE}
  117. {$setc TARGET_CPU_X86_64 := FALSE}
  118. {$setc TARGET_CPU_ARM := FALSE}
  119. {$setc TARGET_CPU_ARM64 := FALSE}
  120. {$ifc defined iphonesim}
  121. {$setc TARGET_OS_MAC := FALSE}
  122. {$setc TARGET_OS_IPHONE := TRUE}
  123. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  124. {$elsec}
  125. {$setc TARGET_OS_MAC := TRUE}
  126. {$setc TARGET_OS_IPHONE := FALSE}
  127. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  128. {$endc}
  129. {$setc TARGET_OS_EMBEDDED := FALSE}
  130. {$elifc defined __x86_64__ and __x86_64__}
  131. {$setc TARGET_CPU_PPC := FALSE}
  132. {$setc TARGET_CPU_PPC64 := FALSE}
  133. {$setc TARGET_CPU_X86 := FALSE}
  134. {$setc TARGET_CPU_X86_64 := TRUE}
  135. {$setc TARGET_CPU_ARM := FALSE}
  136. {$setc TARGET_CPU_ARM64 := FALSE}
  137. {$ifc defined iphonesim}
  138. {$setc TARGET_OS_MAC := FALSE}
  139. {$setc TARGET_OS_IPHONE := TRUE}
  140. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  141. {$elsec}
  142. {$setc TARGET_OS_MAC := TRUE}
  143. {$setc TARGET_OS_IPHONE := FALSE}
  144. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  145. {$endc}
  146. {$setc TARGET_OS_EMBEDDED := FALSE}
  147. {$elifc defined __arm__ and __arm__}
  148. {$setc TARGET_CPU_PPC := FALSE}
  149. {$setc TARGET_CPU_PPC64 := FALSE}
  150. {$setc TARGET_CPU_X86 := FALSE}
  151. {$setc TARGET_CPU_X86_64 := FALSE}
  152. {$setc TARGET_CPU_ARM := TRUE}
  153. {$setc TARGET_CPU_ARM64 := FALSE}
  154. {$setc TARGET_OS_MAC := FALSE}
  155. {$setc TARGET_OS_IPHONE := TRUE}
  156. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  157. {$setc TARGET_OS_EMBEDDED := TRUE}
  158. {$elifc defined __arm64__ and __arm64__}
  159. {$setc TARGET_CPU_PPC := FALSE}
  160. {$setc TARGET_CPU_PPC64 := FALSE}
  161. {$setc TARGET_CPU_X86 := FALSE}
  162. {$setc TARGET_CPU_X86_64 := FALSE}
  163. {$setc TARGET_CPU_ARM := FALSE}
  164. {$setc TARGET_CPU_ARM64 := TRUE}
  165. {$ifc defined ios}
  166. {$setc TARGET_OS_MAC := FALSE}
  167. {$setc TARGET_OS_IPHONE := TRUE}
  168. {$setc TARGET_OS_EMBEDDED := TRUE}
  169. {$elsec}
  170. {$setc TARGET_OS_MAC := TRUE}
  171. {$setc TARGET_OS_IPHONE := FALSE}
  172. {$setc TARGET_OS_EMBEDDED := FALSE}
  173. {$endc}
  174. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  175. {$elsec}
  176. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  177. {$endc}
  178. {$ifc defined __LP64__ and __LP64__ }
  179. {$setc TARGET_CPU_64 := TRUE}
  180. {$elsec}
  181. {$setc TARGET_CPU_64 := FALSE}
  182. {$endc}
  183. {$ifc defined FPC_BIG_ENDIAN}
  184. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  185. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  186. {$elifc defined FPC_LITTLE_ENDIAN}
  187. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  188. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  189. {$elsec}
  190. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  191. {$endc}
  192. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  193. {$setc CALL_NOT_IN_CARBON := FALSE}
  194. {$setc OLDROUTINENAMES := FALSE}
  195. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  196. {$setc OPAQUE_UPP_TYPES := TRUE}
  197. {$setc OTCARBONAPPLICATION := TRUE}
  198. {$setc OTKERNEL := FALSE}
  199. {$setc PM_USE_SESSION_APIS := TRUE}
  200. {$setc TARGET_API_MAC_CARBON := TRUE}
  201. {$setc TARGET_API_MAC_OS8 := FALSE}
  202. {$setc TARGET_API_MAC_OSX := TRUE}
  203. {$setc TARGET_CARBON := TRUE}
  204. {$setc TARGET_CPU_68K := FALSE}
  205. {$setc TARGET_CPU_MIPS := FALSE}
  206. {$setc TARGET_CPU_SPARC := FALSE}
  207. {$setc TARGET_OS_UNIX := FALSE}
  208. {$setc TARGET_OS_WIN32 := FALSE}
  209. {$setc TARGET_RT_MAC_68881 := FALSE}
  210. {$setc TARGET_RT_MAC_CFM := FALSE}
  211. {$setc TARGET_RT_MAC_MACHO := TRUE}
  212. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  213. {$setc TYPE_BOOL := FALSE}
  214. {$setc TYPE_EXTENDED := FALSE}
  215. {$setc TYPE_LONGLONG := TRUE}
  216. {$IFDEF FPC_DOTTEDUNITS}
  217. uses MacOsApi.MacTypes,MacOsApi.CFBase,MacOsApi.CFError;
  218. {$ELSE FPC_DOTTEDUNITS}
  219. uses MacTypes,CFBase,CFError;
  220. {$ENDIF FPC_DOTTEDUNITS}
  221. {$endc} {not MACOSALLINCLUDE}
  222. {$ALIGN POWER}
  223. {!
  224. @header SystemConfiguration
  225. @discussion The System Configuration framework provides access to the
  226. data used to configure a running system. The APIs provided
  227. by this framework communicate with the configd daemon.
  228. The configd daemon manages a dynamic store reflecting the
  229. desired configuration settings as well as the current state
  230. of the system. The daemon provides a notification mechanism
  231. for processes that need to be aware of changes made to the
  232. data. Lastly, the daemon loads a number of bundles (or
  233. plug-ins) that monitor low-level kernel events and, through
  234. a set of policy modules, keep the state data up to date.
  235. }
  236. {!
  237. @enum Error codes
  238. @discussion Returned error codes.
  239. @constant kSCStatusOK Success
  240. @constant kSCStatusFailed Non-specific Failure
  241. @constant kSCStatusInvalidArgument Invalid argument
  242. @constant kSCStatusAccessError Permission denied
  243. @constant kSCStatusNoKey No such key
  244. @constant kSCStatusKeyExists Data associated with key already defined
  245. @constant kSCStatusLocked Lock already held
  246. @constant kSCStatusNeedLock Lock required for this operation
  247. @constant kSCStatusNoStoreSession Configuration daemon session not active
  248. @constant kSCStatusNoStoreServer Configuration daemon not (or no longer) available
  249. @constant kSCStatusNotifierActive Notifier is currently active
  250. @constant kSCStatusNoPrefsSession Preferences session not active
  251. @constant kSCStatusPrefsBusy Preferences update currently in progress
  252. @constant kSCStatusNoConfigFile Configuration file not found
  253. @constant kSCStatusNoLink No such link
  254. @constant kSCStatusStale Write attempted on stale version of object
  255. @constant kSCStatusMaxLink Maximum link count exceeded
  256. @constant kSCStatusReachabilityUnknown
  257. A determination could not be made regarding the reachability
  258. of the specified nodename or address.
  259. @constant kSCStatusConnectionNoService Network service for connection not available
  260. }
  261. const
  262. {
  263. * Generic error codes
  264. }
  265. kSCStatusOK = 0; { Success }
  266. kSCStatusFailed = 1001; { Non-specific failure }
  267. kSCStatusInvalidArgument = 1002; { Invalid argument }
  268. kSCStatusAccessError = 1003; { Permission denied
  269. - must be root to obtain lock
  270. - could not create access/create preferences
  271. }
  272. kSCStatusNoKey = 1004; { No such key }
  273. kSCStatusKeyExists = 1005; { Key already defined }
  274. kSCStatusLocked = 1006; { Lock already held }
  275. kSCStatusNeedLock = 1007; { Lock required for this operation }
  276. {
  277. * SCDynamicStore error codes
  278. }
  279. kSCStatusNoStoreSession = 2001; { Configuration daemon session not active }
  280. kSCStatusNoStoreServer = 2002; { Configuration daemon not (no longer) available }
  281. kSCStatusNotifierActive = 2003; { Notifier is currently active }
  282. {
  283. * SCPreferences error codes
  284. }
  285. kSCStatusNoPrefsSession = 3001; { Preference session not active }
  286. kSCStatusPrefsBusy = 3002; { Preferences update currently in progress }
  287. kSCStatusNoConfigFile = 3003; { Configuration file not found }
  288. kSCStatusNoLink = 3004; { No such link }
  289. kSCStatusStale = 3005; { Write attempted on stale version of object }
  290. kSCStatusMaxLink = 3006; { Maximum link count exceeded }
  291. {
  292. * SCNetwork error codes
  293. }
  294. kSCStatusReachabilityUnknown = 4001; { Network reachability cannot be determined }
  295. {
  296. * SCNetworkConnection error codes
  297. }
  298. //#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) || (__IPHONE_OS_VERSION_MIN_REQUIRED >= 20000)
  299. kSCStatusConnectionNoService = 5001; { Network service for connection not available }
  300. //#endif
  301. { SCDynamicStore APIs }
  302. { SCPreferences APIs }
  303. { Schema Definitions (for SCDynamicStore and SCPreferences) }
  304. { SCNetworkConfiguration APIs }
  305. { SCNetworkReachability and SCNetworkConnection APIs }
  306. {!
  307. @const kCFErrorDomainSystemConfiguration
  308. @discussion CFError domain associated with errors reported by
  309. the SystemConfiguration.framework.
  310. }
  311. var kCFErrorDomainSystemConfiguration: CFStringRef; external name '_kCFErrorDomainSystemConfiguration'; (* attribute const *)
  312. (* __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0) *)
  313. {!
  314. @function SCCopyLastError
  315. @discussion Returns the most recent status or error code generated
  316. as the result of calling a System Configuration framework API.
  317. @result Returns the last error encountered.
  318. }
  319. function SCCopyLastError: CFErrorRef; external name '_SCCopyLastError';
  320. (* __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0) *)
  321. {!
  322. @function SCError
  323. @discussion Returns the most recent status or error code generated
  324. as the result of calling a System Configuration framework API.
  325. @result Returns the last error encountered.
  326. }
  327. function SCError: SInt32; external name '_SCError';
  328. (* __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0) *)
  329. {!
  330. @function SCErrorString
  331. @discussion Returns a pointer to the message string
  332. associated with the specified status or error.
  333. @param status The SCDynamicStoreStatus to be returned.
  334. @result Returns a pointer to the error message string.
  335. }
  336. function SCErrorString( status: SInt32 ): ConstCStringPtr; external name '_SCErrorString';
  337. (* __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0) *)
  338. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  339. end.
  340. {$endc} {not MACOSALLINCLUDE}