Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

623 lines
18 KiB

  1. /*
  2. File: URLAccess.h
  3. Contains: URL Access Interfaces.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1994-2000 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __URLACCESS__
  11. #define __URLACCESS__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __FILES__
  16. #include <Files.h>
  17. #endif
  18. #ifndef __CODEFRAGMENTS__
  19. #include <CodeFragments.h>
  20. #endif
  21. #ifndef __MACERRORS__
  22. #include <MacErrors.h>
  23. #endif
  24. #ifndef __EVENTS__
  25. #include <Events.h>
  26. #endif
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #if PRAGMA_IMPORT
  34. #pragma import on
  35. #endif
  36. #if PRAGMA_STRUCT_ALIGN
  37. #pragma options align=mac68k
  38. #elif PRAGMA_STRUCT_PACKPUSH
  39. #pragma pack(push, 2)
  40. #elif PRAGMA_STRUCT_PACK
  41. #pragma pack(2)
  42. #endif
  43. /* Data structures and types */
  44. typedef struct OpaqueURLReference* URLReference;
  45. typedef UInt32 URLOpenFlags;
  46. enum {
  47. kURLReplaceExistingFlag = 1 << 0,
  48. kURLBinHexFileFlag = 1 << 1, /* Binhex before uploading if necessary*/
  49. kURLExpandFileFlag = 1 << 2, /* Use StuffIt engine to expand file if necessary*/
  50. kURLDisplayProgressFlag = 1 << 3,
  51. kURLDisplayAuthFlag = 1 << 4, /* Display auth dialog if guest connection fails*/
  52. kURLUploadFlag = 1 << 5, /* Do an upload instead of a download*/
  53. kURLIsDirectoryHintFlag = 1 << 6, /* Hint: the URL is a directory*/
  54. kURLDoNotTryAnonymousFlag = 1 << 7, /* Don't try to connect anonymously before getting logon info*/
  55. kURLDirectoryListingFlag = 1 << 8, /* Download the directory listing, not the whole directory*/
  56. kURLExpandAndVerifyFlag = 1 << 9, /* Expand file and then verify using signature resource*/
  57. kURLNoAutoRedirectFlag = 1 << 10, /* Do not automatically redirect to new URL*/
  58. kURLDebinhexOnlyFlag = 1 << 11, /* Do not use Stuffit Expander - just internal debinhex engine*/
  59. kURLDoNotDeleteOnErrorFlag = 1 << 12, /* Do not delete the downloaded file if an error or abort occurs.*/
  60. /* This flag applies to downloading only and should be used if*/
  61. /* interested in later resuming the download.*/
  62. kURLResumeDownloadFlag = 1 << 13, /* The passed in file is partially downloaded, attempt to resume*/
  63. /* it. Currently works for HTTP only. If no FSSpec passed in,*/
  64. /* this flag will be ignored. Overriden by kURLReplaceExistingFlag. */
  65. kURLReservedFlag = (unsigned long)(1 << 31) /* reserved for Apple internal use*/
  66. };
  67. typedef UInt32 URLState;
  68. enum {
  69. kURLNullState = 0,
  70. kURLInitiatingState = 1,
  71. kURLLookingUpHostState = 2,
  72. kURLConnectingState = 3,
  73. kURLResourceFoundState = 4,
  74. kURLDownloadingState = 5,
  75. kURLDataAvailableState = 0x10 + kURLDownloadingState,
  76. kURLTransactionCompleteState = 6,
  77. kURLErrorOccurredState = 7,
  78. kURLAbortingState = 8,
  79. kURLCompletedState = 9,
  80. kURLUploadingState = 10
  81. };
  82. typedef UInt32 URLEvent;
  83. enum {
  84. kURLInitiatedEvent = kURLInitiatingState,
  85. kURLResourceFoundEvent = kURLResourceFoundState,
  86. kURLDownloadingEvent = kURLDownloadingState,
  87. kURLAbortInitiatedEvent = kURLAbortingState,
  88. kURLCompletedEvent = kURLCompletedState,
  89. kURLErrorOccurredEvent = kURLErrorOccurredState,
  90. kURLDataAvailableEvent = kURLDataAvailableState,
  91. kURLTransactionCompleteEvent = kURLTransactionCompleteState,
  92. kURLUploadingEvent = kURLUploadingState,
  93. kURLSystemEvent = 29,
  94. kURLPercentEvent = 30,
  95. kURLPeriodicEvent = 31,
  96. kURLPropertyChangedEvent = 32
  97. };
  98. typedef unsigned long URLEventMask;
  99. enum {
  100. kURLInitiatedEventMask = 1 << (kURLInitiatedEvent - 1),
  101. kURLResourceFoundEventMask = 1 << (kURLResourceFoundEvent - 1),
  102. kURLDownloadingMask = 1 << (kURLDownloadingEvent - 1),
  103. kURLUploadingMask = 1 << (kURLUploadingEvent - 1),
  104. kURLAbortInitiatedMask = 1 << (kURLAbortInitiatedEvent - 1),
  105. kURLCompletedEventMask = 1 << (kURLCompletedEvent - 1),
  106. kURLErrorOccurredEventMask = 1 << (kURLErrorOccurredEvent - 1),
  107. kURLDataAvailableEventMask = 1 << (kURLDataAvailableEvent - 1),
  108. kURLTransactionCompleteEventMask = 1 << (kURLTransactionCompleteEvent - 1),
  109. kURLSystemEventMask = 1 << (kURLSystemEvent - 1),
  110. kURLPercentEventMask = 1 << (kURLPercentEvent - 1),
  111. kURLPeriodicEventMask = 1 << (kURLPeriodicEvent - 1),
  112. kURLPropertyChangedEventMask = 1 << (kURLPropertyChangedEvent - 1),
  113. kURLAllBufferEventsMask = kURLDataAvailableEventMask + kURLTransactionCompleteEventMask,
  114. kURLAllNonBufferEventsMask = kURLInitiatedEventMask + kURLDownloadingMask + kURLUploadingMask + kURLAbortInitiatedMask + kURLCompletedEventMask + kURLErrorOccurredEventMask + kURLPercentEventMask + kURLPeriodicEventMask + kURLPropertyChangedEventMask,
  115. kURLAllEventsMask = (long)0xFFFFFFFF
  116. };
  117. struct URLCallbackInfo {
  118. UInt32 version;
  119. URLReference urlRef;
  120. const char * property;
  121. UInt32 currentSize;
  122. EventRecord * systemEvent;
  123. };
  124. typedef struct URLCallbackInfo URLCallbackInfo;
  125. /* authentication type flags*/
  126. enum {
  127. kUserNameAndPasswordFlag = 0x00000001
  128. };
  129. #define kURLURL "URLString"
  130. #define kURLResourceSize "URLResourceSize"
  131. #define kURLLastModifiedTime "URLLastModifiedTime"
  132. #define kURLMIMEType "URLMIMEType"
  133. #define kURLFileType "URLFileType"
  134. #define kURLFileCreator "URLFileCreator"
  135. #define kURLCharacterSet "URLCharacterSet"
  136. #define kURLResourceName "URLResourceName"
  137. #define kURLHost "URLHost"
  138. #define kURLAuthType "URLAuthType"
  139. #define kURLUserName "URLUserName"
  140. #define kURLPassword "URLPassword"
  141. #define kURLStatusString "URLStatusString"
  142. #define kURLIsSecure "URLIsSecure"
  143. #define kURLCertificate "URLCertificate"
  144. #define kURLTotalItems "URLTotalItems"
  145. #define kURLConnectTimeout "URLConnectTimeout"
  146. /* http and https properties*/
  147. #define kURLHTTPRequestMethod "URLHTTPRequestMethod"
  148. #define kURLHTTPRequestHeader "URLHTTPRequestHeader"
  149. #define kURLHTTPRequestBody "URLHTTPRequestBody"
  150. #define kURLHTTPRespHeader "URLHTTPRespHeader"
  151. #define kURLHTTPUserAgent "URLHTTPUserAgent"
  152. #define kURLHTTPRedirectedURL "URLHTTPRedirectedURL"
  153. #define kURLSSLCipherSuite "URLSSLCipherSuite"
  154. /*
  155. * URLGetURLAccessVersion()
  156. *
  157. * Availability:
  158. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  159. * CarbonLib: in CarbonLib 1.0 and later
  160. * Mac OS X: in version 10.0 and later
  161. */
  162. EXTERN_API( OSStatus )
  163. URLGetURLAccessVersion(UInt32 * returnVers);
  164. #if TARGET_RT_MAC_CFM
  165. #ifdef __cplusplus
  166. inline pascal Boolean URLAccessAvailable() { return ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) ); }
  167. #else
  168. #define URLAccessAvailable() ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) )
  169. #endif
  170. #elif TARGET_RT_MAC_MACHO
  171. /* URL Access is always available on OS X */
  172. #ifdef __cplusplus
  173. inline pascal Boolean URLAccessAvailable() { return true; }
  174. #else
  175. #define URLAccessAvailable() (true)
  176. #endif
  177. #endif /* */
  178. typedef CALLBACK_API( OSStatus , URLNotifyProcPtr )(void *userContext, URLEvent event, URLCallbackInfo *callbackInfo);
  179. typedef CALLBACK_API( OSStatus , URLSystemEventProcPtr )(void *userContext, EventRecord *event);
  180. typedef TVECTOR_UPP_TYPE(URLNotifyProcPtr) URLNotifyUPP;
  181. typedef TVECTOR_UPP_TYPE(URLSystemEventProcPtr) URLSystemEventUPP;
  182. /*
  183. * NewURLNotifyUPP()
  184. *
  185. * Availability:
  186. * Non-Carbon CFM: available as macro/inline
  187. * CarbonLib: in CarbonLib 1.0 and later
  188. * Mac OS X: in version 10.0 and later
  189. */
  190. EXTERN_API_C( URLNotifyUPP )
  191. NewURLNotifyUPP(URLNotifyProcPtr userRoutine);
  192. #if !OPAQUE_UPP_TYPES
  193. enum { uppURLNotifyProcInfo = 0x00000FF0 }; /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  194. #ifdef __cplusplus
  195. inline DEFINE_API_C(URLNotifyUPP) NewURLNotifyUPP(URLNotifyProcPtr userRoutine) { return userRoutine; }
  196. #else
  197. #define NewURLNotifyUPP(userRoutine) (userRoutine)
  198. #endif
  199. #endif
  200. /*
  201. * NewURLSystemEventUPP()
  202. *
  203. * Availability:
  204. * Non-Carbon CFM: available as macro/inline
  205. * CarbonLib: in CarbonLib 1.0 and later
  206. * Mac OS X: in version 10.0 and later
  207. */
  208. EXTERN_API_C( URLSystemEventUPP )
  209. NewURLSystemEventUPP(URLSystemEventProcPtr userRoutine);
  210. #if !OPAQUE_UPP_TYPES
  211. enum { uppURLSystemEventProcInfo = 0x000003F0 }; /* pascal 4_bytes Func(4_bytes, 4_bytes) */
  212. #ifdef __cplusplus
  213. inline DEFINE_API_C(URLSystemEventUPP) NewURLSystemEventUPP(URLSystemEventProcPtr userRoutine) { return userRoutine; }
  214. #else
  215. #define NewURLSystemEventUPP(userRoutine) (userRoutine)
  216. #endif
  217. #endif
  218. /*
  219. * DisposeURLNotifyUPP()
  220. *
  221. * Availability:
  222. * Non-Carbon CFM: available as macro/inline
  223. * CarbonLib: in CarbonLib 1.0 and later
  224. * Mac OS X: in version 10.0 and later
  225. */
  226. EXTERN_API_C( void )
  227. DisposeURLNotifyUPP(URLNotifyUPP userUPP);
  228. #if !OPAQUE_UPP_TYPES
  229. #ifdef __cplusplus
  230. inline DEFINE_API_C(void) DisposeURLNotifyUPP(URLNotifyUPP) {}
  231. #else
  232. #define DisposeURLNotifyUPP(userUPP)
  233. #endif
  234. #endif
  235. /*
  236. * DisposeURLSystemEventUPP()
  237. *
  238. * Availability:
  239. * Non-Carbon CFM: available as macro/inline
  240. * CarbonLib: in CarbonLib 1.0 and later
  241. * Mac OS X: in version 10.0 and later
  242. */
  243. EXTERN_API_C( void )
  244. DisposeURLSystemEventUPP(URLSystemEventUPP userUPP);
  245. #if !OPAQUE_UPP_TYPES
  246. #ifdef __cplusplus
  247. inline DEFINE_API_C(void) DisposeURLSystemEventUPP(URLSystemEventUPP) {}
  248. #else
  249. #define DisposeURLSystemEventUPP(userUPP)
  250. #endif
  251. #endif
  252. /*
  253. * InvokeURLNotifyUPP()
  254. *
  255. * Availability:
  256. * Non-Carbon CFM: available as macro/inline
  257. * CarbonLib: in CarbonLib 1.0 and later
  258. * Mac OS X: in version 10.0 and later
  259. */
  260. EXTERN_API_C( OSStatus )
  261. InvokeURLNotifyUPP(
  262. void * userContext,
  263. URLEvent event,
  264. URLCallbackInfo * callbackInfo,
  265. URLNotifyUPP userUPP);
  266. #if !OPAQUE_UPP_TYPES
  267. #ifdef __cplusplus
  268. inline DEFINE_API_C(OSStatus) InvokeURLNotifyUPP(void * userContext, URLEvent event, URLCallbackInfo * callbackInfo, URLNotifyUPP userUPP) { return (*userUPP)(userContext, event, callbackInfo); }
  269. #else
  270. #define InvokeURLNotifyUPP(userContext, event, callbackInfo, userUPP) (*userUPP)(userContext, event, callbackInfo)
  271. #endif
  272. #endif
  273. /*
  274. * InvokeURLSystemEventUPP()
  275. *
  276. * Availability:
  277. * Non-Carbon CFM: available as macro/inline
  278. * CarbonLib: in CarbonLib 1.0 and later
  279. * Mac OS X: in version 10.0 and later
  280. */
  281. EXTERN_API_C( OSStatus )
  282. InvokeURLSystemEventUPP(
  283. void * userContext,
  284. EventRecord * event,
  285. URLSystemEventUPP userUPP);
  286. #if !OPAQUE_UPP_TYPES
  287. #ifdef __cplusplus
  288. inline DEFINE_API_C(OSStatus) InvokeURLSystemEventUPP(void * userContext, EventRecord * event, URLSystemEventUPP userUPP) { return (*userUPP)(userContext, event); }
  289. #else
  290. #define InvokeURLSystemEventUPP(userContext, event, userUPP) (*userUPP)(userContext, event)
  291. #endif
  292. #endif
  293. /*
  294. * URLSimpleDownload()
  295. *
  296. * Availability:
  297. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  298. * CarbonLib: in CarbonLib 1.0 and later
  299. * Mac OS X: in version 10.0 and later
  300. */
  301. EXTERN_API( OSStatus )
  302. URLSimpleDownload(
  303. const char * url,
  304. FSSpec * destination, /* can be NULL */
  305. Handle destinationHandle, /* can be NULL */
  306. URLOpenFlags openFlags,
  307. URLSystemEventUPP eventProc, /* can be NULL */
  308. void * userContext); /* can be NULL */
  309. /*
  310. * URLDownload()
  311. *
  312. * Availability:
  313. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  314. * CarbonLib: in CarbonLib 1.0 and later
  315. * Mac OS X: in version 10.0 and later
  316. */
  317. EXTERN_API( OSStatus )
  318. URLDownload(
  319. URLReference urlRef,
  320. FSSpec * destination, /* can be NULL */
  321. Handle destinationHandle, /* can be NULL */
  322. URLOpenFlags openFlags,
  323. URLSystemEventUPP eventProc, /* can be NULL */
  324. void * userContext); /* can be NULL */
  325. /*
  326. * URLSimpleUpload()
  327. *
  328. * Availability:
  329. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  330. * CarbonLib: in CarbonLib 1.0 and later
  331. * Mac OS X: in version 10.0 and later
  332. */
  333. EXTERN_API( OSStatus )
  334. URLSimpleUpload(
  335. const char * url,
  336. const FSSpec * source,
  337. URLOpenFlags openFlags,
  338. URLSystemEventUPP eventProc, /* can be NULL */
  339. void * userContext); /* can be NULL */
  340. /*
  341. * URLUpload()
  342. *
  343. * Availability:
  344. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  345. * CarbonLib: in CarbonLib 1.0 and later
  346. * Mac OS X: in version 10.0 and later
  347. */
  348. EXTERN_API( OSStatus )
  349. URLUpload(
  350. URLReference urlRef,
  351. const FSSpec * source,
  352. URLOpenFlags openFlags,
  353. URLSystemEventUPP eventProc, /* can be NULL */
  354. void * userContext); /* can be NULL */
  355. /*
  356. * URLNewReference()
  357. *
  358. * Availability:
  359. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  360. * CarbonLib: in CarbonLib 1.0 and later
  361. * Mac OS X: in version 10.0 and later
  362. */
  363. EXTERN_API( OSStatus )
  364. URLNewReference(
  365. const char * url,
  366. URLReference * urlRef);
  367. /*
  368. * URLDisposeReference()
  369. *
  370. * Availability:
  371. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  372. * CarbonLib: in CarbonLib 1.0 and later
  373. * Mac OS X: in version 10.0 and later
  374. */
  375. EXTERN_API( OSStatus )
  376. URLDisposeReference(URLReference urlRef);
  377. /*
  378. * URLOpen()
  379. *
  380. * Availability:
  381. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  382. * CarbonLib: in CarbonLib 1.0 and later
  383. * Mac OS X: in version 10.0 and later
  384. */
  385. EXTERN_API( OSStatus )
  386. URLOpen(
  387. URLReference urlRef,
  388. FSSpec * fileSpec, /* can be NULL */
  389. URLOpenFlags openFlags,
  390. URLNotifyUPP notifyProc, /* can be NULL */
  391. URLEventMask eventRegister,
  392. void * userContext); /* can be NULL */
  393. /*
  394. * URLAbort()
  395. *
  396. * Availability:
  397. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  398. * CarbonLib: in CarbonLib 1.0 and later
  399. * Mac OS X: in version 10.0 and later
  400. */
  401. EXTERN_API( OSStatus )
  402. URLAbort(URLReference urlRef);
  403. /*
  404. * URLGetDataAvailable()
  405. *
  406. * Availability:
  407. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  408. * CarbonLib: in CarbonLib 1.0 and later
  409. * Mac OS X: in version 10.0 and later
  410. */
  411. EXTERN_API( OSStatus )
  412. URLGetDataAvailable(
  413. URLReference urlRef,
  414. Size * dataSize);
  415. /*
  416. * URLGetBuffer()
  417. *
  418. * Availability:
  419. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  420. * CarbonLib: in CarbonLib 1.0 and later
  421. * Mac OS X: in version 10.0 and later
  422. */
  423. EXTERN_API( OSStatus )
  424. URLGetBuffer(
  425. URLReference urlRef,
  426. void ** buffer,
  427. Size * bufferSize);
  428. /*
  429. * URLReleaseBuffer()
  430. *
  431. * Availability:
  432. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  433. * CarbonLib: in CarbonLib 1.0 and later
  434. * Mac OS X: in version 10.0 and later
  435. */
  436. EXTERN_API( OSStatus )
  437. URLReleaseBuffer(
  438. URLReference urlRef,
  439. void * buffer);
  440. /*
  441. * URLGetProperty()
  442. *
  443. * Availability:
  444. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  445. * CarbonLib: in CarbonLib 1.0 and later
  446. * Mac OS X: in version 10.0 and later
  447. */
  448. EXTERN_API( OSStatus )
  449. URLGetProperty(
  450. URLReference urlRef,
  451. const char * property,
  452. void * propertyBuffer,
  453. Size bufferSize);
  454. /*
  455. * URLGetPropertySize()
  456. *
  457. * Availability:
  458. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  459. * CarbonLib: in CarbonLib 1.0 and later
  460. * Mac OS X: in version 10.0 and later
  461. */
  462. EXTERN_API( OSStatus )
  463. URLGetPropertySize(
  464. URLReference urlRef,
  465. const char * property,
  466. Size * propertySize);
  467. /*
  468. * URLSetProperty()
  469. *
  470. * Availability:
  471. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  472. * CarbonLib: in CarbonLib 1.0 and later
  473. * Mac OS X: in version 10.0 and later
  474. */
  475. EXTERN_API( OSStatus )
  476. URLSetProperty(
  477. URLReference urlRef,
  478. const char * property,
  479. void * propertyBuffer,
  480. Size bufferSize);
  481. /*
  482. * URLGetCurrentState()
  483. *
  484. * Availability:
  485. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  486. * CarbonLib: in CarbonLib 1.0 and later
  487. * Mac OS X: in version 10.0 and later
  488. */
  489. EXTERN_API( OSStatus )
  490. URLGetCurrentState(
  491. URLReference urlRef,
  492. URLState * state);
  493. /*
  494. * URLGetError()
  495. *
  496. * Availability:
  497. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  498. * CarbonLib: in CarbonLib 1.0 and later
  499. * Mac OS X: in version 10.0 and later
  500. */
  501. EXTERN_API( OSStatus )
  502. URLGetError(
  503. URLReference urlRef,
  504. OSStatus * urlError);
  505. /*
  506. * URLIdle()
  507. *
  508. * Availability:
  509. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  510. * CarbonLib: in CarbonLib 1.0 and later
  511. * Mac OS X: in version 10.0 and later
  512. */
  513. EXTERN_API( OSStatus )
  514. URLIdle(void);
  515. /*
  516. * URLGetFileInfo()
  517. *
  518. * Availability:
  519. * Non-Carbon CFM: in URLAccessLib 1.0 and later
  520. * CarbonLib: in CarbonLib 1.0 and later
  521. * Mac OS X: in version 10.0 and later
  522. */
  523. EXTERN_API( OSStatus )
  524. URLGetFileInfo(
  525. StringPtr fName,
  526. OSType * fType,
  527. OSType * fCreator);
  528. #if PRAGMA_STRUCT_ALIGN
  529. #pragma options align=reset
  530. #elif PRAGMA_STRUCT_PACKPUSH
  531. #pragma pack(pop)
  532. #elif PRAGMA_STRUCT_PACK
  533. #pragma pack()
  534. #endif
  535. #ifdef PRAGMA_IMPORT_OFF
  536. #pragma import off
  537. #elif PRAGMA_IMPORT
  538. #pragma import reset
  539. #endif
  540. #ifdef __cplusplus
  541. }
  542. #endif
  543. #endif /* __URLACCESS__ */