CFURL.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. { CFURL.h
  2. Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, November 2005 }
  5. {
  6. Modified for use with Free Pascal
  7. Version 200
  8. Please report any bugs to <[email protected]>
  9. }
  10. {$mode macpas}
  11. {$packenum 1}
  12. {$macro on}
  13. {$inline on}
  14. {$CALLING MWPASCAL}
  15. unit CFURL;
  16. interface
  17. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  18. {$setc GAP_INTERFACES_VERSION := $0200}
  19. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  20. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  21. {$endc}
  22. {$ifc defined CPUPOWERPC and defined CPUI386}
  23. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  24. {$endc}
  25. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  26. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  27. {$endc}
  28. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  29. {$setc __ppc__ := 1}
  30. {$elsec}
  31. {$setc __ppc__ := 0}
  32. {$endc}
  33. {$ifc not defined __i386__ and defined CPUI386}
  34. {$setc __i386__ := 1}
  35. {$elsec}
  36. {$setc __i386__ := 0}
  37. {$endc}
  38. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  39. {$error Conflicting definitions for __ppc__ and __i386__}
  40. {$endc}
  41. {$ifc defined __ppc__ and __ppc__}
  42. {$setc TARGET_CPU_PPC := TRUE}
  43. {$setc TARGET_CPU_X86 := FALSE}
  44. {$elifc defined __i386__ and __i386__}
  45. {$setc TARGET_CPU_PPC := FALSE}
  46. {$setc TARGET_CPU_X86 := TRUE}
  47. {$elsec}
  48. {$error Neither __ppc__ nor __i386__ is defined.}
  49. {$endc}
  50. {$setc TARGET_CPU_PPC_64 := FALSE}
  51. {$ifc defined FPC_BIG_ENDIAN}
  52. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  53. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  54. {$elifc defined FPC_LITTLE_ENDIAN}
  55. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  56. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  57. {$elsec}
  58. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  59. {$endc}
  60. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  61. {$setc CALL_NOT_IN_CARBON := FALSE}
  62. {$setc OLDROUTINENAMES := FALSE}
  63. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  64. {$setc OPAQUE_UPP_TYPES := TRUE}
  65. {$setc OTCARBONAPPLICATION := TRUE}
  66. {$setc OTKERNEL := FALSE}
  67. {$setc PM_USE_SESSION_APIS := TRUE}
  68. {$setc TARGET_API_MAC_CARBON := TRUE}
  69. {$setc TARGET_API_MAC_OS8 := FALSE}
  70. {$setc TARGET_API_MAC_OSX := TRUE}
  71. {$setc TARGET_CARBON := TRUE}
  72. {$setc TARGET_CPU_68K := FALSE}
  73. {$setc TARGET_CPU_MIPS := FALSE}
  74. {$setc TARGET_CPU_SPARC := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_UNIX := FALSE}
  77. {$setc TARGET_OS_WIN32 := FALSE}
  78. {$setc TARGET_RT_MAC_68881 := FALSE}
  79. {$setc TARGET_RT_MAC_CFM := FALSE}
  80. {$setc TARGET_RT_MAC_MACHO := TRUE}
  81. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  82. {$setc TYPE_BOOL := FALSE}
  83. {$setc TYPE_EXTENDED := FALSE}
  84. {$setc TYPE_LONGLONG := TRUE}
  85. uses MacTypes,CFBase,CFData,CFString,Files;
  86. {$ALIGN POWER}
  87. type
  88. CFURLPathStyle = SInt32;
  89. const
  90. kCFURLPOSIXPathStyle = 0;
  91. kCFURLHFSPathStyle = 1;
  92. kCFURLWindowsPathStyle = 2;
  93. type
  94. CFURLRef = ^SInt32; { an opaque 32-bit type }
  95. CFURLRefPtr = ^CFURLRef;
  96. { CFURLs are composed of two fundamental pieces - their string, and a }
  97. { (possibly NULL) base URL. A relative URL is one in which the string }
  98. { by itself does not fully specify the URL (for instance "myDir/image.tiff"); }
  99. { an absolute URL is one in which the string does fully specify the URL }
  100. { ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL }
  101. { base URLs; however, it is possible for a URL to have a NULL base, and still }
  102. { not be absolute. Such a URL has only a relative string, and cannot be }
  103. { resolved. Two CFURLs are considered equal if and only if their strings }
  104. { are equal and their bases are equal. In other words, }
  105. { "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative }
  106. { string "myDir/image.tiff" and base URL "file://localhost/". Clients that }
  107. { need these less strict form of equality should convert all URLs to their }
  108. { absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. }
  109. function CFURLGetTypeID: CFTypeID; external name '_CFURLGetTypeID';
  110. { encoding will be used both to interpret the bytes of URLBytes, and to }
  111. { interpret any percent-escapes within the bytes. }
  112. function CFURLCreateWithBytes( allocator: CFAllocatorRef; URLBytes: UInt8Ptr; length: CFIndex; encoding: CFStringEncoding; baseURL: CFURLRef ): CFURLRef; external name '_CFURLCreateWithBytes';
  113. { Escapes any character that is not 7-bit ASCII with the byte-code }
  114. { for the given encoding. If escapeWhitespace is true, whitespace }
  115. { characters (' ', '\t', '\r', '\n') will be escaped also (desirable }
  116. { if embedding the URL into a larger text stream like HTML) }
  117. function CFURLCreateData( allocator: CFAllocatorRef; url: CFURLRef; encoding: CFStringEncoding; escapeWhitespace: Boolean ): CFDataRef; external name '_CFURLCreateData';
  118. { Any escape sequences in URLString will be interpreted via UTF-8. }
  119. function CFURLCreateWithString( allocator: CFAllocatorRef; URLString: CFStringRef; baseURL: CFURLRef ): CFURLRef; external name '_CFURLCreateWithString';
  120. {#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  121. { Create an absolute URL directly, without requiring the extra step }
  122. { of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is }
  123. { true, the rules historically used on the web are used to resolve }
  124. { relativeString against baseURL - these rules are generally listed }
  125. { in the RFC as optional or alternate interpretations. Otherwise, }
  126. { the strict rules from the RFC are used. The major differences are }
  127. { that in compatibility mode, we are lenient of the scheme appearing }
  128. { in relative portion, leading "../" components are removed from the }
  129. { final URL's path, and if the relative portion contains only }
  130. { resource specifier pieces (query, parameters, and fragment), then }
  131. { the last path component of the base URL will not be deleted }
  132. function CFURLCreateAbsoluteURLWithBytes( alloc: CFAllocatorRef; relativeURLBytes: UInt8Ptr; length: CFIndex; encoding: CFStringEncoding; baseURL: CFURLRef; useCompatibilityMode: Boolean ): CFURLRef; external name '_CFURLCreateAbsoluteURLWithBytes';
  133. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  134. {#endif}
  135. { filePath should be the URL's path expressed as a path of the type }
  136. { fsType. If filePath is not absolute, the resulting URL will be }
  137. { considered relative to the current working directory (evaluated }
  138. { at creation time). isDirectory determines whether filePath is }
  139. { treated as a directory path when resolving against relative path }
  140. { components }
  141. function CFURLCreateWithFileSystemPath( allocator: CFAllocatorRef; filePath: CFStringRef; pathStyle: CFURLPathStyle; isDirectory: Boolean ): CFURLRef; external name '_CFURLCreateWithFileSystemPath';
  142. function CFURLCreateFromFileSystemRepresentation( allocator: CFAllocatorRef; buffer: CStringPtr; bufLen: CFIndex; isDirectory: Boolean ): CFURLRef; external name '_CFURLCreateFromFileSystemRepresentation';
  143. function CFURLCreateWithFileSystemPathRelativeToBase( allocator: CFAllocatorRef; filePath: CFStringRef; pathStyle: CFURLPathStyle; isDirectory: Boolean; baseURL: CFURLRef ): CFURLRef; external name '_CFURLCreateWithFileSystemPathRelativeToBase';
  144. function CFURLCreateFromFileSystemRepresentationRelativeToBase( allocator: CFAllocatorRef; buffer: CStringPtr; bufLen: CFIndex; isDirectory: Boolean; baseURL: CFURLRef ): CFURLRef; external name '_CFURLCreateFromFileSystemRepresentationRelativeToBase';
  145. { Fills buffer with the file system's native representation of }
  146. { url's path. No more than maxBufLen bytes are written to buffer. }
  147. { The buffer should be at least the maximum path length for }
  148. { the file system in question to avoid failures for insufficiently }
  149. { large buffers. If resolveAgainstBase is true, the url's relative }
  150. { portion is resolved against its base before the path is computed. }
  151. { Returns success or failure. }
  152. function CFURLGetFileSystemRepresentation( url: CFURLRef; resolveAgainstBase: Boolean; buffer: CStringPtr; maxBufLen: CFIndex ): Boolean; external name '_CFURLGetFileSystemRepresentation';
  153. { Creates a new URL by resolving the relative portion of relativeURL against its base. }
  154. function CFURLCopyAbsoluteURL( relativeURL: CFURLRef ): CFURLRef; external name '_CFURLCopyAbsoluteURL';
  155. { Returns the URL's string. }
  156. function CFURLGetString( anURL: CFURLRef ): CFStringRef; external name '_CFURLGetString';
  157. { Returns the base URL if it exists }
  158. function CFURLGetBaseURL( anURL: CFURLRef ): CFURLRef; external name '_CFURLGetBaseURL';
  159. {
  160. All URLs can be broken into two pieces - the scheme (preceding the
  161. first colon) and the resource specifier (following the first colon).
  162. Most URLs are also "standard" URLs conforming to RFC 1808 (available
  163. from www.w3c.org). This category includes URLs of the file, http,
  164. https, and ftp schemes, to name a few. Standard URLs start the
  165. resource specifier with two slashes ("//"), and can be broken into
  166. four distinct pieces - the scheme, the net location, the path, and
  167. further resource specifiers (typically an optional parameter, query,
  168. and/or fragment). The net location appears immediately following
  169. the two slashes and goes up to the next slash; it's format is
  170. scheme-specific, but is usually composed of some or all of a username,
  171. password, host name, and port. The path is a series of path components
  172. separated by slashes; if the net location is present, the path always
  173. begins with a slash. Standard URLs can be relative to another URL,
  174. in which case at least the scheme and possibly other pieces as well
  175. come from the base URL (see RFC 1808 for precise details when resolving
  176. a relative URL against its base). The full URL is therefore
  177. <scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
  178. If a given CFURL can be decomposed (that is, conforms to RFC 1808), you
  179. can ask for each of the four basic pieces (scheme, net location, path,
  180. and resource specifer) separately, as well as for its base URL. The
  181. basic pieces are returned with any percent escape sequences still in
  182. place (although note that the scheme may not legally include any
  183. percent escapes); this is to allow the caller to distinguish between
  184. percent sequences that may have syntactic meaning if replaced by the
  185. character being escaped (for instance, a '/' in a path component).
  186. Since only the individual schemes know which characters are
  187. syntactically significant, CFURL cannot safely replace any percent
  188. escape sequences. However, you can use
  189. CFURLCreateStringByReplacingPercentEscapes() to create a new string with
  190. the percent escapes removed; see below.
  191. If a given CFURL can not be decomposed, you can ask for its scheme and its
  192. resource specifier; asking it for its net location or path will return NULL.
  193. To get more refined information about the components of a decomposable
  194. CFURL, you may ask for more specific pieces of the URL, expressed with
  195. the percent escapes removed. The available functions are CFURLCopyHostName(),
  196. CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(),
  197. CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and
  198. CFURLCopyFragment(). Because the parameters, query, and fragment of an
  199. URL may contain scheme-specific syntaxes, these methods take a second
  200. argument, giving a list of characters which should NOT be replaced if
  201. percent escaped. For instance, the ftp parameter syntax gives simple
  202. key-value pairs as "<key>=<value>;" Clearly if a key or value includes
  203. either '=' or ';', it must be escaped to avoid corrupting the meaning of
  204. the parameters, so the caller may request the parameter string as
  205. CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
  206. requesting that all percent escape sequences be replaced by the represented
  207. characters, except for escaped '=', '%' or ';' characters. Pass the empty
  208. string (CFSTR("")) to request that all percent escapes be replaced, or NULL
  209. to request that none be.
  210. }
  211. { Returns true if anURL conforms to RFC 1808 }
  212. function CFURLCanBeDecomposed( anURL: CFURLRef ): Boolean; external name '_CFURLCanBeDecomposed';
  213. { The next several methods leave any percent escape sequences intact }
  214. function CFURLCopyScheme( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyScheme';
  215. { NULL if CFURLCanBeDecomposed(anURL) is false }
  216. function CFURLCopyNetLocation( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyNetLocation';
  217. { NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL }
  218. { against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly }
  219. { speaking, any leading '/' is not considered part of the URL's path, although }
  220. { its presence or absence determines whether the path is absolute. }
  221. { CFURLCopyPath()'s return value includes any leading slash (giving the path }
  222. { the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any }
  223. { leading slash, and uses isAbsolute to report whether the URL's path is absolute. }
  224. { CFURLCopyFileSystemPath() returns the URL's path as a file system path for the }
  225. { given path style. All percent escape sequences are replaced. The URL is not }
  226. { resolved against its base before computing the path. }
  227. function CFURLCopyPath( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyPath';
  228. function CFURLCopyStrictPath( anURL: CFURLRef; var isAbsolute: Boolean ): CFStringRef; external name '_CFURLCopyStrictPath';
  229. function CFURLCopyFileSystemPath( anURL: CFURLRef; pathStyle: CFURLPathStyle ): CFStringRef; external name '_CFURLCopyFileSystemPath';
  230. { Returns whether anURL's path represents a directory }
  231. { (true returned) or a simple file (false returned) }
  232. function CFURLHasDirectoryPath( anURL: CFURLRef ): Boolean; external name '_CFURLHasDirectoryPath';
  233. { Any additional resource specifiers after the path. For URLs }
  234. { that cannot be decomposed, this is everything except the scheme itself. }
  235. function CFURLCopyResourceSpecifier( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyResourceSpecifier';
  236. function CFURLCopyHostName( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyHostName';
  237. function CFURLGetPortNumber( anURL: CFURLRef ): SInt32; external name '_CFURLGetPortNumber'; { Returns -1 if no port number is specified }
  238. function CFURLCopyUserName( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyUserName';
  239. function CFURLCopyPassword( anURL: CFURLRef ): CFStringRef; external name '_CFURLCopyPassword';
  240. { These remove all percent escape sequences except those for }
  241. { characters in charactersToLeaveEscaped. If charactersToLeaveEscaped }
  242. { is empty (""), all percent escape sequences are replaced by their }
  243. { corresponding characters. If charactersToLeaveEscaped is NULL, }
  244. { then no escape sequences are removed at all }
  245. function CFURLCopyParameterString( anURL: CFURLRef; charactersToLeaveEscaped: CFStringRef ): CFStringRef; external name '_CFURLCopyParameterString';
  246. function CFURLCopyQueryString( anURL: CFURLRef; charactersToLeaveEscaped: CFStringRef ): CFStringRef; external name '_CFURLCopyQueryString';
  247. function CFURLCopyFragment( anURL: CFURLRef; charactersToLeaveEscaped: CFStringRef ): CFStringRef; external name '_CFURLCopyFragment';
  248. function CFURLCopyLastPathComponent( url: CFURLRef ): CFStringRef; external name '_CFURLCopyLastPathComponent';
  249. function CFURLCopyPathExtension( url: CFURLRef ): CFStringRef; external name '_CFURLCopyPathExtension';
  250. { These functions all treat the base URL of the supplied url as }
  251. { invariant. In other words, the URL returned will always have }
  252. { the same base as the URL supplied as an argument. }
  253. function CFURLCreateCopyAppendingPathComponent( allocator: CFAllocatorRef; url: CFURLRef; pathComponent: CFStringRef; isDirectory: Boolean ): CFURLRef; external name '_CFURLCreateCopyAppendingPathComponent';
  254. function CFURLCreateCopyDeletingLastPathComponent( allocator: CFAllocatorRef; url: CFURLRef ): CFURLRef; external name '_CFURLCreateCopyDeletingLastPathComponent';
  255. function CFURLCreateCopyAppendingPathExtension( allocator: CFAllocatorRef; url: CFURLRef; extension: CFStringRef ): CFURLRef; external name '_CFURLCreateCopyAppendingPathExtension';
  256. function CFURLCreateCopyDeletingPathExtension( allocator: CFAllocatorRef; url: CFURLRef ): CFURLRef; external name '_CFURLCreateCopyDeletingPathExtension';
  257. {#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  258. { Fills buffer with the bytes for url, returning the number of bytes }
  259. { filled. If buffer is of insufficient size, returns -1 and no bytes }
  260. { are placed in buffer. If buffer is NULL, the needed length is }
  261. { computed and returned. The returned bytes are the original bytes }
  262. { from which the URL was created; if the URL was created from a }
  263. { string, the bytes will be the bytes of the string encoded via UTF-8 }
  264. function CFURLGetBytes( url: CFURLRef; buffer: CStringPtr; bufferLength: CFIndex ): CFIndex; external name '_CFURLGetBytes';
  265. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  266. type
  267. CFURLComponentType = SInt32;
  268. const
  269. kCFURLComponentScheme = 1;
  270. kCFURLComponentNetLocation = 2;
  271. kCFURLComponentPath = 3;
  272. kCFURLComponentResourceSpecifier = 4;
  273. kCFURLComponentUser = 5;
  274. kCFURLComponentPassword = 6;
  275. kCFURLComponentUserInfo = 7;
  276. kCFURLComponentHost = 8;
  277. kCFURLComponentPort = 9;
  278. kCFURLComponentParameterString = 10;
  279. kCFURLComponentQuery = 11;
  280. kCFURLComponentFragment = 12;
  281. {
  282. Gets the range of the requested component in the bytes of url, as
  283. returned by CFURLGetBytes(). This range is only good for use in the
  284. bytes returned by CFURLGetBytes!
  285. If non-NULL, rangeIncludingSeparators gives the range of component
  286. including the sequences that separate component from the previous and
  287. next components. If there is no previous or next component, that end of
  288. rangeIncludingSeparators will match the range of the component itself.
  289. If url does not contain the given component type, (kCFNotFound, 0) is
  290. returned, and rangeIncludingSeparators is set to the location where the
  291. component would be inserted. Some examples -
  292. For the URL http://www.apple.com/hotnews/
  293. Component returned range rangeIncludingSeparators
  294. scheme (0, 4) (0, 7)
  295. net location (7, 13) (4, 16)
  296. path (20, 9) (20, 9)
  297. resource specifier (kCFNotFound, 0) (29, 0)
  298. user (kCFNotFound, 0) (7, 0)
  299. password (kCFNotFound, 0) (7, 0)
  300. user info (kCFNotFound, 0) (7, 0)
  301. host (7, 13) (4, 16)
  302. port (kCFNotFound, 0) (20, 0)
  303. parameter (kCFNotFound, 0) (29, 0)
  304. query (kCFNotFound, 0) (29, 0)
  305. fragment (kCFNotFound, 0) (29, 0)
  306. For the URL ./relPath/file.html#fragment
  307. Component returned range rangeIncludingSeparators
  308. scheme (kCFNotFound, 0) (0, 0)
  309. net location (kCFNotFound, 0) (0, 0)
  310. path (0, 19) (0, 20)
  311. resource specifier (20, 8) (19, 9)
  312. user (kCFNotFound, 0) (0, 0)
  313. password (kCFNotFound, 0) (0, 0)
  314. user info (kCFNotFound, 0) (0, 0)
  315. host (kCFNotFound, 0) (0, 0)
  316. port (kCFNotFound, 0) (0, 0)
  317. parameter (kCFNotFound, 0) (19, 0)
  318. query (kCFNotFound, 0) (19, 0)
  319. fragment (20, 8) (19, 9)
  320. For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
  321. Component returned range rangeIncludingSeparators
  322. scheme (0, 6) (0, 9)
  323. net location (9, 16) (6, 19)
  324. path (25, 21) (25, 22)
  325. resource specifier (47, 21) (46, 22)
  326. user (9, 4) (6, 8)
  327. password (14, 4) (13, 6)
  328. user info (9, 9) (6, 13)
  329. host (19, 4) (18, 6)
  330. port (24, 1) (23, 2)
  331. parameter (47, 6) (46, 8)
  332. query (54, 5) (53, 7)
  333. fragment (60, 8) (59, 9)
  334. }
  335. function CFURLGetByteRangeForComponent( url: CFURLRef; component: CFURLComponentType; var rangeIncludingSeparators: CFRange ): CFRange; external name '_CFURLGetByteRangeForComponent';
  336. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  337. {#endif}
  338. { Returns a string with any percent escape sequences that do NOT }
  339. { correspond to characters in charactersToLeaveEscaped with their }
  340. { equivalent. Returns NULL on failure (if an invalid percent sequence }
  341. { is encountered), or the original string (retained) if no characters }
  342. { need to be replaced. Pass NULL to request that no percent escapes be }
  343. { replaced, or the empty string (CFSTR("")) to request that all percent }
  344. { escapes be replaced. Uses UTF8 to interpret percent escapes. }
  345. function CFURLCreateStringByReplacingPercentEscapes( allocator: CFAllocatorRef; originalString: CFStringRef; charactersToLeaveEscaped: CFStringRef ): CFStringRef; external name '_CFURLCreateStringByReplacingPercentEscapes';
  346. {#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  347. { As above, but allows you to specify the encoding to use when interpreting percent escapes }
  348. function CFURLCreateStringByReplacingPercentEscapesUsingEncoding( allocator: CFAllocatorRef; origString: CFStringRef; charsToLeaveEscaped: CFStringRef; encoding: CFStringEncoding ): CFStringRef; external name '_CFURLCreateStringByReplacingPercentEscapesUsingEncoding';
  349. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  350. {#endif}
  351. { Creates a copy or originalString, replacing certain characters with }
  352. { the equivalent percent escape sequence based on the encoding specified. }
  353. { If the originalString does not need to be modified (no percent escape }
  354. { sequences are missing), may retain and return originalString. }
  355. { If you are uncertain of the correct encoding, you should use UTF-8, }
  356. { which is the encoding designated by RFC 2396 as the correct encoding }
  357. { for use in URLs. The characters so escaped are all characters that }
  358. { are not legal URL characters (based on RFC 2396), plus any characters }
  359. { in legalURLCharactersToBeEscaped, less any characters in }
  360. { charactersToLeaveUnescaped. To simply correct any non-URL characters }
  361. { in an otherwise correct URL string, do: }
  362. { newString = CFURLCreateStringByAddingPercentEscapes(NULL, origString, NULL, NULL, kCFStringEncodingUTF8); }
  363. function CFURLCreateStringByAddingPercentEscapes( allocator: CFAllocatorRef; originalString: CFStringRef; charactersToLeaveUnescaped: CFStringRef; legalURLCharactersToBeEscaped: CFStringRef; encoding: CFStringEncoding ): CFStringRef; external name '_CFURLCreateStringByAddingPercentEscapes';
  364. {#ifndef CF_OPEN_SOURCE}
  365. function CFURLCreateFromFSRef( allocator: CFAllocatorRef; const (*var*) fsRef_: FSRef ): CFURLRef; external name '_CFURLCreateFromFSRef';
  366. function CFURLGetFSRef( url: CFURLRef; var fsRef_: FSRef ): Boolean; external name '_CFURLGetFSRef';
  367. {#endif} // !CF_OPEN_SOURCE
  368. end.