SCDynamicStoreCopyDHCPInfos.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. {
  2. * Copyright (c) 2001, 2002, 2004, 2005, 2008 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. { Unit name changed to SCDynamicStoreCopyDHCPInfos to avoid conflict with
  25. SCDynamicStoreCopyDHCPInfo function }
  26. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  27. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  28. {
  29. Modified for use with Free Pascal
  30. Version 308
  31. Please report any bugs to <[email protected]>
  32. }
  33. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  34. {$mode macpas}
  35. {$modeswitch cblocks}
  36. {$packenum 1}
  37. {$macro on}
  38. {$inline on}
  39. {$calling mwpascal}
  40. {$IFNDEF FPC_DOTTEDUNITS}
  41. unit SCDynamicStoreCopyDHCPInfos;
  42. {$ENDIF FPC_DOTTEDUNITS}
  43. interface
  44. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  45. {$setc GAP_INTERFACES_VERSION := $0308}
  46. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  47. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  48. {$endc}
  49. {$ifc defined CPUPOWERPC and defined CPUI386}
  50. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  51. {$endc}
  52. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  53. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  54. {$endc}
  55. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  56. {$setc __ppc__ := 1}
  57. {$elsec}
  58. {$setc __ppc__ := 0}
  59. {$endc}
  60. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  61. {$setc __ppc64__ := 1}
  62. {$elsec}
  63. {$setc __ppc64__ := 0}
  64. {$endc}
  65. {$ifc not defined __i386__ and defined CPUI386}
  66. {$setc __i386__ := 1}
  67. {$elsec}
  68. {$setc __i386__ := 0}
  69. {$endc}
  70. {$ifc not defined __x86_64__ and defined CPUX86_64}
  71. {$setc __x86_64__ := 1}
  72. {$elsec}
  73. {$setc __x86_64__ := 0}
  74. {$endc}
  75. {$ifc not defined __arm__ and defined CPUARM}
  76. {$setc __arm__ := 1}
  77. {$elsec}
  78. {$setc __arm__ := 0}
  79. {$endc}
  80. {$ifc not defined __arm64__ and defined CPUAARCH64}
  81. {$setc __arm64__ := 1}
  82. {$elsec}
  83. {$setc __arm64__ := 0}
  84. {$endc}
  85. {$ifc defined cpu64}
  86. {$setc __LP64__ := 1}
  87. {$elsec}
  88. {$setc __LP64__ := 0}
  89. {$endc}
  90. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  91. {$error Conflicting definitions for __ppc__ and __i386__}
  92. {$endc}
  93. {$ifc defined __ppc__ and __ppc__}
  94. {$setc TARGET_CPU_PPC := TRUE}
  95. {$setc TARGET_CPU_PPC64 := FALSE}
  96. {$setc TARGET_CPU_X86 := FALSE}
  97. {$setc TARGET_CPU_X86_64 := FALSE}
  98. {$setc TARGET_CPU_ARM := FALSE}
  99. {$setc TARGET_CPU_ARM64 := FALSE}
  100. {$setc TARGET_OS_MAC := TRUE}
  101. {$setc TARGET_OS_IPHONE := FALSE}
  102. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  103. {$setc TARGET_OS_EMBEDDED := FALSE}
  104. {$elifc defined __ppc64__ and __ppc64__}
  105. {$setc TARGET_CPU_PPC := FALSE}
  106. {$setc TARGET_CPU_PPC64 := TRUE}
  107. {$setc TARGET_CPU_X86 := FALSE}
  108. {$setc TARGET_CPU_X86_64 := FALSE}
  109. {$setc TARGET_CPU_ARM := FALSE}
  110. {$setc TARGET_CPU_ARM64 := FALSE}
  111. {$setc TARGET_OS_MAC := TRUE}
  112. {$setc TARGET_OS_IPHONE := FALSE}
  113. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  114. {$setc TARGET_OS_EMBEDDED := FALSE}
  115. {$elifc defined __i386__ and __i386__}
  116. {$setc TARGET_CPU_PPC := FALSE}
  117. {$setc TARGET_CPU_PPC64 := FALSE}
  118. {$setc TARGET_CPU_X86 := TRUE}
  119. {$setc TARGET_CPU_X86_64 := FALSE}
  120. {$setc TARGET_CPU_ARM := FALSE}
  121. {$setc TARGET_CPU_ARM64 := FALSE}
  122. {$ifc defined iphonesim}
  123. {$setc TARGET_OS_MAC := FALSE}
  124. {$setc TARGET_OS_IPHONE := TRUE}
  125. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  126. {$elsec}
  127. {$setc TARGET_OS_MAC := TRUE}
  128. {$setc TARGET_OS_IPHONE := FALSE}
  129. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  130. {$endc}
  131. {$setc TARGET_OS_EMBEDDED := FALSE}
  132. {$elifc defined __x86_64__ and __x86_64__}
  133. {$setc TARGET_CPU_PPC := FALSE}
  134. {$setc TARGET_CPU_PPC64 := FALSE}
  135. {$setc TARGET_CPU_X86 := FALSE}
  136. {$setc TARGET_CPU_X86_64 := TRUE}
  137. {$setc TARGET_CPU_ARM := FALSE}
  138. {$setc TARGET_CPU_ARM64 := FALSE}
  139. {$ifc defined iphonesim}
  140. {$setc TARGET_OS_MAC := FALSE}
  141. {$setc TARGET_OS_IPHONE := TRUE}
  142. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  143. {$elsec}
  144. {$setc TARGET_OS_MAC := TRUE}
  145. {$setc TARGET_OS_IPHONE := FALSE}
  146. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  147. {$endc}
  148. {$setc TARGET_OS_EMBEDDED := FALSE}
  149. {$elifc defined __arm__ and __arm__}
  150. {$setc TARGET_CPU_PPC := FALSE}
  151. {$setc TARGET_CPU_PPC64 := FALSE}
  152. {$setc TARGET_CPU_X86 := FALSE}
  153. {$setc TARGET_CPU_X86_64 := FALSE}
  154. {$setc TARGET_CPU_ARM := TRUE}
  155. {$setc TARGET_CPU_ARM64 := FALSE}
  156. {$setc TARGET_OS_MAC := FALSE}
  157. {$setc TARGET_OS_IPHONE := TRUE}
  158. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  159. {$setc TARGET_OS_EMBEDDED := TRUE}
  160. {$elifc defined __arm64__ and __arm64__}
  161. {$setc TARGET_CPU_PPC := FALSE}
  162. {$setc TARGET_CPU_PPC64 := FALSE}
  163. {$setc TARGET_CPU_X86 := FALSE}
  164. {$setc TARGET_CPU_X86_64 := FALSE}
  165. {$setc TARGET_CPU_ARM := FALSE}
  166. {$setc TARGET_CPU_ARM64 := TRUE}
  167. {$ifc defined ios}
  168. {$setc TARGET_OS_MAC := FALSE}
  169. {$setc TARGET_OS_IPHONE := TRUE}
  170. {$setc TARGET_OS_EMBEDDED := TRUE}
  171. {$elsec}
  172. {$setc TARGET_OS_MAC := TRUE}
  173. {$setc TARGET_OS_IPHONE := FALSE}
  174. {$setc TARGET_OS_EMBEDDED := FALSE}
  175. {$endc}
  176. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  177. {$elsec}
  178. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  179. {$endc}
  180. {$ifc defined __LP64__ and __LP64__ }
  181. {$setc TARGET_CPU_64 := TRUE}
  182. {$elsec}
  183. {$setc TARGET_CPU_64 := FALSE}
  184. {$endc}
  185. {$ifc defined FPC_BIG_ENDIAN}
  186. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  187. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  188. {$elifc defined FPC_LITTLE_ENDIAN}
  189. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  190. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  191. {$elsec}
  192. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  193. {$endc}
  194. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  195. {$setc CALL_NOT_IN_CARBON := FALSE}
  196. {$setc OLDROUTINENAMES := FALSE}
  197. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  198. {$setc OPAQUE_UPP_TYPES := TRUE}
  199. {$setc OTCARBONAPPLICATION := TRUE}
  200. {$setc OTKERNEL := FALSE}
  201. {$setc PM_USE_SESSION_APIS := TRUE}
  202. {$setc TARGET_API_MAC_CARBON := TRUE}
  203. {$setc TARGET_API_MAC_OS8 := FALSE}
  204. {$setc TARGET_API_MAC_OSX := TRUE}
  205. {$setc TARGET_CARBON := TRUE}
  206. {$setc TARGET_CPU_68K := FALSE}
  207. {$setc TARGET_CPU_MIPS := FALSE}
  208. {$setc TARGET_CPU_SPARC := FALSE}
  209. {$setc TARGET_OS_UNIX := FALSE}
  210. {$setc TARGET_OS_WIN32 := FALSE}
  211. {$setc TARGET_RT_MAC_68881 := FALSE}
  212. {$setc TARGET_RT_MAC_CFM := FALSE}
  213. {$setc TARGET_RT_MAC_MACHO := TRUE}
  214. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  215. {$setc TYPE_BOOL := FALSE}
  216. {$setc TYPE_EXTENDED := FALSE}
  217. {$setc TYPE_LONGLONG := TRUE}
  218. {$IFDEF FPC_DOTTEDUNITS}
  219. uses MacOsApi.MacTypes,MacOsApi.CFBase,MacOsApi.SCDynamicStore,MacOsApi.CFDictionary,MacOsApi.CFData,MacOsApi.CFDate;
  220. {$ELSE FPC_DOTTEDUNITS}
  221. uses MacTypes,CFBase,SCDynamicStore,CFDictionary,CFData,CFDate;
  222. {$ENDIF FPC_DOTTEDUNITS}
  223. {$endc} {not MACOSALLINCLUDE}
  224. {$ALIGN POWER}
  225. { until __IPHONE_NA is automatically translated }
  226. {$ifc TARGET_OS_MAC}
  227. {!
  228. @header SCDynamicStoreCopyDHCPInfo
  229. @discussion The functions of the SCDynamicStoreCopyDHCPInfo API
  230. provide access to information returned by the DHCP or
  231. BOOTP server.
  232. }
  233. {!
  234. @function SCDynamicStoreCopyDHCPInfo
  235. @discussion Copies the DHCP information for the requested serviceID,
  236. or the primary service if serviceID == NULL.
  237. @param store An SCDynamicStoreRef representing the dynamic store session
  238. that should be used for communication with the server.
  239. If NULL, a temporary session will be used.
  240. @param serviceID A CFStringRef containing the requested service.
  241. If NULL, returns information for the primary service.
  242. @result Returns a dictionary containing DHCP information if successful;
  243. NULL otherwise.
  244. Use the DHCPInfoGetOption function to retrieve
  245. individual options from the returned dictionary.
  246. A non-NULL return value must be released using CFRelease().
  247. }
  248. function SCDynamicStoreCopyDHCPInfo( store: SCDynamicStoreRef; serviceID: CFStringRef ): CFDictionaryRef; external name '_SCDynamicStoreCopyDHCPInfo';
  249. (* __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA) *)
  250. {!
  251. @function DHCPInfoGetOptionData
  252. @discussion Returns a non-NULL CFDataRef containing the DHCP
  253. option data, if present.
  254. @param info The non-NULL DHCP information dictionary returned by
  255. calling SCDynamicStoreCopyDHCPInfo.
  256. @param code The DHCP option code (see RFC 2132) to return
  257. data for.
  258. @result Returns a non-NULL CFDataRef containing the option data;
  259. NULL if the requested option data is not present.
  260. The return value must NOT be released.
  261. }
  262. function DHCPInfoGetOptionData( info: CFDictionaryRef; code: UInt8 ): CFDataRef; external name '_DHCPInfoGetOptionData';
  263. (* __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA) *)
  264. {!
  265. @function DHCPInfoGetLeaseStartTime
  266. @discussion Returns a CFDateRef corresponding to the lease start time,
  267. if present.
  268. @param info The non-NULL DHCP information dictionary returned by
  269. calling SCDynamicStoreCopyDHCPInfo.
  270. @result Returns a non-NULL CFDateRef if lease start time information is
  271. present; NULL if the information is not present or if the
  272. configuration method is not DHCP.
  273. The return value must NOT be released.
  274. }
  275. function DHCPInfoGetLeaseStartTime( info: CFDictionaryRef ): CFDateRef; external name '_DHCPInfoGetLeaseStartTime';
  276. (* __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA) *)
  277. {!
  278. @function DHCPInfoGetLeaseExpirationTime
  279. @discussion Returns a CFDateRef corresponding to the lease expiration time,
  280. if present.
  281. @param info The non-NULL DHCP information dictionary returned by
  282. calling SCDynamicStoreCopyDHCPInfo.
  283. @result Returns a non-NULL CFDateRef if the DHCP lease has an expiration;
  284. NULL if the lease is infinite i.e. has no expiration, or the
  285. configuration method is not DHCP. An infinite lease can be determined
  286. by a non-NULL lease start time (see DHCPInfoGetLeaseStartTime above).
  287. The return value must NOT be released.
  288. }
  289. function DHCPInfoGetLeaseExpirationTime( info: CFDictionaryRef ): CFDateRef; external name '_DHCPInfoGetLeaseExpirationTime';
  290. (* __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_NA) *)
  291. {$endc} { TARGET_OS_MAC }
  292. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  293. end.
  294. {$endc} {not MACOSALLINCLUDE}