URLAccess.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:14k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       URLAccess.h
  3.  
  4.      Contains:   URL Access Interfaces.
  5.  
  6.      Version:    Technology: URLAccess 2.0
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1994-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __URLACCESS__
  18. #define __URLACCESS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __FILES__
  23. #include "Files.h"
  24. #endif
  25. #ifndef __CODEFRAGMENTS__
  26. #include "CodeFragments.h"
  27. #endif
  28. #ifndef __FILESIGNING__
  29. #include "FileSigning.h"
  30. #endif
  31. #ifndef __MACERRORS__
  32. #include "MacErrors.h"
  33. #endif
  34. #if PRAGMA_ONCE
  35. #pragma once
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50. /* Data structures and types */
  51. typedef struct OpaqueURLReference*      URLReference;
  52. typedef UInt32 URLOpenFlags;
  53. enum {
  54.     kURLReplaceExistingFlag     = 1 << 0,
  55.     kURLBinHexFileFlag          = 1 << 1,                       /* Binhex before uploading if necessary*/
  56.     kURLExpandFileFlag          = 1 << 2,                       /* Use StuffIt engine to expand file if necessary*/
  57.     kURLDisplayProgressFlag     = 1 << 3,
  58.     kURLDisplayAuthFlag         = 1 << 4,                       /* Display auth dialog if guest connection fails*/
  59.     kURLUploadFlag              = 1 << 5,                       /* Do an upload instead of a download*/
  60.     kURLIsDirectoryHintFlag     = 1 << 6,                       /* Hint: the URL is a directory*/
  61.     kURLDoNotTryAnonymousFlag   = 1 << 7,                       /* Don't try to connect anonymously before getting logon info*/
  62.     kURLDirectoryListingFlag    = 1 << 8,                       /* Download the directory listing, not the whole directory*/
  63.     kURLExpandAndVerifyFlag     = 1 << 9,                       /* Expand file and then verify using signature resource*/
  64.     kURLNoAutoRedirectFlag      = 1 << 10,                      /* Do not automatically redirect to new URL*/
  65.     kURLDebinhexOnlyFlag        = 1 << 11,                      /* Do not use Stuffit Expander - just internal debinhex engine*/
  66.     kURLReservedFlag            = (unsigned long)(1 << 31)      /* reserved for Apple internal use*/
  67. };
  68. typedef UInt32 URLState;
  69. enum {
  70.     kURLNullState               = 0,
  71.     kURLInitiatingState         = 1,
  72.     kURLLookingUpHostState      = 2,
  73.     kURLConnectingState         = 3,
  74.     kURLResourceFoundState      = 4,
  75.     kURLDownloadingState        = 5,
  76.     kURLDataAvailableState      = 0x10 + kURLDownloadingState,
  77.     kURLTransactionCompleteState = 6,
  78.     kURLErrorOccurredState      = 7,
  79.     kURLAbortingState           = 8,
  80.     kURLCompletedState          = 9,
  81.     kURLUploadingState          = 10
  82. };
  83. typedef UInt32 URLEvent;
  84. enum {
  85.     kURLInitiatedEvent          = kURLInitiatingState,
  86.     kURLResourceFoundEvent      = kURLResourceFoundState,
  87.     kURLDownloadingEvent        = kURLDownloadingState,
  88.     kURLAbortInitiatedEvent     = kURLAbortingState,
  89.     kURLCompletedEvent          = kURLCompletedState,
  90.     kURLErrorOccurredEvent      = kURLErrorOccurredState,
  91.     kURLDataAvailableEvent      = kURLDataAvailableState,
  92.     kURLTransactionCompleteEvent = kURLTransactionCompleteState,
  93.     kURLUploadingEvent          = kURLUploadingState,
  94.     kURLSystemEvent             = 29,
  95.     kURLPercentEvent            = 30,
  96.     kURLPeriodicEvent           = 31,
  97.     kURLPropertyChangedEvent    = 32
  98. };
  99. typedef unsigned long                   URLEventMask;
  100. enum {
  101.     kURLInitiatedEventMask      = 1 << (kURLInitiatedEvent - 1),
  102.     kURLResourceFoundEventMask  = 1 << (kURLResourceFoundEvent - 1),
  103.     kURLDownloadingMask         = 1 << (kURLDownloadingEvent - 1),
  104.     kURLUploadingMask           = 1 << (kURLUploadingEvent - 1),
  105.     kURLAbortInitiatedMask      = 1 << (kURLAbortInitiatedEvent - 1),
  106.     kURLCompletedEventMask      = 1 << (kURLCompletedEvent - 1),
  107.     kURLErrorOccurredEventMask  = 1 << (kURLErrorOccurredEvent - 1),
  108.     kURLDataAvailableEventMask  = 1 << (kURLDataAvailableEvent - 1),
  109.     kURLTransactionCompleteEventMask = 1 << (kURLTransactionCompleteEvent - 1),
  110.     kURLSystemEventMask         = 1 << (kURLSystemEvent - 1),
  111.     kURLPercentEventMask        = 1 << (kURLPercentEvent - 1),
  112.     kURLPeriodicEventMask       = 1 << (kURLPeriodicEvent - 1),
  113.     kURLPropertyChangedEventMask = 1 << (kURLPropertyChangedEvent - 1),
  114.     kURLAllBufferEventsMask     = kURLDataAvailableEventMask + kURLTransactionCompleteEventMask,
  115.     kURLAllNonBufferEventsMask  = kURLInitiatedEventMask + kURLDownloadingMask + kURLUploadingMask + kURLAbortInitiatedMask + kURLCompletedEventMask + kURLErrorOccurredEventMask + kURLPercentEventMask + kURLPeriodicEventMask + kURLPropertyChangedEventMask,
  116.     kURLAllEventsMask           = (long)0xFFFFFFFF
  117. };
  118. struct URLCallbackInfo {
  119.     UInt32                          version;
  120.     URLReference                    urlRef;
  121.     const char *                    property;
  122.     UInt32                          currentSize;
  123.     EventRecord *                   systemEvent;
  124. };
  125. typedef struct URLCallbackInfo          URLCallbackInfo;
  126. static const char* kURLURL                      = "URLString";
  127. static const char* kURLResourceSize             = "URLResourceSize";
  128. static const char* kURLLastModifiedTime         = "URLLastModifiedTime";
  129. static const char* kURLMIMEType                 = "URLMIMEType";
  130. static const char* kURLFileType                 = "URLFileType";
  131. static const char* kURLFileCreator              = "URLFileCreator";
  132. static const char* kURLCharacterSet             = "URLCharacterSet";
  133. static const char* kURLResourceName             = "URLResourceName";
  134. static const char* kURLHost                     = "URLHost";
  135. static const char* kURLAuthType                 = "URLAuthType";
  136. static const char* kURLUserName                 = "URLUserName";
  137. static const char* kURLPassword                 = "URLPassword";
  138. static const char* kURLStatusString             = "URLStatusString";
  139. static const char* kURLIsSecure                 = "URLIsSecure";
  140. static const char* kURLCertificate              = "URLCertificate";
  141. static const char* kURLTotalItems               = "URLTotalItems";
  142. /* http and https properties*/
  143. static const char* kURLHTTPRequestMethod        = "URLHTTPRequestMethod";
  144. static const char* kURLHTTPRequestHeader        = "URLHTTPRequestHeader";
  145. static const char* kURLHTTPRequestBody          = "URLHTTPRequestBody";
  146. static const char* kURLHTTPRespHeader           = "URLHTTPRespHeader";
  147. static const char* kURLHTTPUserAgent            = "URLHTTPUserAgent";
  148. static const char* kURLHTTPRedirectedURL        = "URLHTTPRedirectedURL";
  149. /* authentication type flags*/
  150. enum {
  151.     kUserNameAndPasswordFlag    = 0x00000001
  152. };
  153. EXTERN_API( OSStatus )
  154. URLGetURLAccessVersion          (UInt32 *               returnVers);
  155. #if TARGET_RT_MAC_CFM
  156. #ifdef __cplusplus
  157.     inline pascal Boolean URLAccessAvailable() { return ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) ); }
  158. #else
  159.     #define URLAccessAvailable()    ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) )
  160. #endif
  161. #elif TARGET_RT_MAC_MACHO
  162. /* URL Access is always available on OS X */
  163. #ifdef __cplusplus
  164.     inline pascal Boolean URLAccessAvailable() { return true; }
  165. #else
  166.     #define URLAccessAvailable()    (true)
  167. #endif
  168. #endif  /*  */
  169. typedef CALLBACK_API( OSStatus , URLNotifyProcPtr )(void *userContext, URLEvent event, URLCallbackInfo *callbackInfo);
  170. typedef CALLBACK_API( OSStatus , URLSystemEventProcPtr )(void *userContext, EventRecord *event);
  171. typedef TVECTOR_UPP_TYPE(URLNotifyProcPtr)                      URLNotifyUPP;
  172. typedef TVECTOR_UPP_TYPE(URLSystemEventProcPtr)                 URLSystemEventUPP;
  173. #if OPAQUE_UPP_TYPES
  174.     EXTERN_API(URLNotifyUPP)
  175.     NewURLNotifyUPP                (URLNotifyProcPtr        userRoutine);
  176.     EXTERN_API(URLSystemEventUPP)
  177.     NewURLSystemEventUPP           (URLSystemEventProcPtr   userRoutine);
  178.     EXTERN_API(void)
  179.     DisposeURLNotifyUPP            (URLNotifyUPP            userUPP);
  180.     EXTERN_API(void)
  181.     DisposeURLSystemEventUPP       (URLSystemEventUPP       userUPP);
  182.     EXTERN_API(OSStatus)
  183.     InvokeURLNotifyUPP             (void *                  userContext,
  184.                                     URLEvent                event,
  185.                                     URLCallbackInfo *       callbackInfo,
  186.                                     URLNotifyUPP            userUPP);
  187.     EXTERN_API(OSStatus)
  188.     InvokeURLSystemEventUPP        (void *                  userContext,
  189.                                     EventRecord *           event,
  190.                                     URLSystemEventUPP       userUPP);
  191. #else
  192.     #define NewURLNotifyUPP(userRoutine)                            (userRoutine)
  193.     #define NewURLSystemEventUPP(userRoutine)                       (userRoutine)
  194.     #define DisposeURLNotifyUPP(userUPP)                            
  195.     #define DisposeURLSystemEventUPP(userUPP)                       
  196.     #define InvokeURLNotifyUPP(userContext, event, callbackInfo, userUPP)  (*userUPP)(userContext, event, callbackInfo)
  197.     #define InvokeURLSystemEventUPP(userContext, event, userUPP)    (*userUPP)(userContext, event)
  198. #endif
  199. EXTERN_API( OSStatus )
  200. URLSimpleDownload               (const char *           url,
  201.                                  FSSpec *               destination,
  202.                                  Handle                 destinationHandle,
  203.                                  URLOpenFlags           openFlags,
  204.                                  URLSystemEventUPP      eventProc,
  205.                                  void *                 userContext);
  206. EXTERN_API( OSStatus )
  207. URLDownload                     (URLReference           urlRef,
  208.                                  FSSpec *               destination,
  209.                                  Handle                 destinationHandle,
  210.                                  URLOpenFlags           openFlags,
  211.                                  URLSystemEventUPP      eventProc,
  212.                                  void *                 userContext);
  213. EXTERN_API( OSStatus )
  214. URLSimpleUpload                 (const char *           url,
  215.                                  const FSSpec *         source,
  216.                                  URLOpenFlags           openFlags,
  217.                                  URLSystemEventUPP      eventProc,
  218.                                  void *                 userContext);
  219. EXTERN_API( OSStatus )
  220. URLUpload                       (URLReference           urlRef,
  221.                                  const FSSpec *         source,
  222.                                  URLOpenFlags           openFlags,
  223.                                  URLSystemEventUPP      eventProc,
  224.                                  void *                 userContext);
  225. EXTERN_API( OSStatus )
  226. URLNewReference                 (const char *           url,
  227.                                  URLReference *         urlRef);
  228. EXTERN_API( OSStatus )
  229. URLDisposeReference             (URLReference           urlRef);
  230. EXTERN_API( OSStatus )
  231. URLOpen                         (URLReference           urlRef,
  232.                                  FSSpec *               fileSpec,
  233.                                  URLOpenFlags           openFlags,
  234.                                  URLNotifyUPP           notifyProc,
  235.                                  URLEventMask           eventRegister,
  236.                                  void *                 userContext);
  237. EXTERN_API( OSStatus )
  238. URLAbort                        (URLReference           urlRef);
  239. EXTERN_API( OSStatus )
  240. URLGetDataAvailable             (URLReference           urlRef,
  241.                                  Size *                 dataSize);
  242. EXTERN_API( OSStatus )
  243. URLGetBuffer                    (URLReference           urlRef,
  244.                                  void **                buffer,
  245.                                  Size *                 bufferSize);
  246. EXTERN_API( OSStatus )
  247. URLReleaseBuffer                (URLReference           urlRef,
  248.                                  void *                 buffer);
  249. EXTERN_API( OSStatus )
  250. URLGetProperty                  (URLReference           urlRef,
  251.                                  const char *           property,
  252.                                  void *                 propertyBuffer,
  253.                                  Size                   bufferSize);
  254. EXTERN_API( OSStatus )
  255. URLGetPropertySize              (URLReference           urlRef,
  256.                                  const char *           property,
  257.                                  Size *                 propertySize);
  258. EXTERN_API( OSStatus )
  259. URLSetProperty                  (URLReference           urlRef,
  260.                                  const char *           property,
  261.                                  void *                 propertyBuffer,
  262.                                  Size                   bufferSize);
  263. EXTERN_API( OSStatus )
  264. URLGetCurrentState              (URLReference           urlRef,
  265.                                  URLState *             state);
  266. EXTERN_API( OSStatus )
  267. URLGetError                     (URLReference           urlRef,
  268.                                  OSStatus *             urlError);
  269. EXTERN_API( OSStatus )
  270. URLIdle                         (void);
  271. EXTERN_API( OSStatus )
  272. URLGetFileInfo                  (StringPtr              fName,
  273.                                  OSType *               fType,
  274.                                  OSType *               fCreator);
  275. #if PRAGMA_STRUCT_ALIGN
  276.     #pragma options align=reset
  277. #elif PRAGMA_STRUCT_PACKPUSH
  278.     #pragma pack(pop)
  279. #elif PRAGMA_STRUCT_PACK
  280.     #pragma pack()
  281. #endif
  282. #ifdef PRAGMA_IMPORT_OFF
  283. #pragma import off
  284. #elif PRAGMA_IMPORT
  285. #pragma import reset
  286. #endif
  287. #ifdef __cplusplus
  288. }
  289. #endif
  290. #endif /* __URLACCESS__ */