Mac OS 9
URLAccess.h
Go to the documentation of this file.
1 
19 #ifndef __URLACCESS__
20 #define __URLACCESS__
21 
22 #ifndef __MACTYPES__
23 #include <MacTypes.h>
24 #endif
25 
26 #ifndef __FILES__
27 #include <Files.h>
28 #endif
29 
30 #ifndef __CODEFRAGMENTS__
31 #include <CodeFragments.h>
32 #endif
33 
34 #ifndef __MACERRORS__
35 #include <MacErrors.h>
36 #endif
37 
38 #ifndef __EVENTS__
39 #include <Events.h>
40 #endif
41 
42 #if PRAGMA_ONCE
43 #pragma once
44 #endif
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50 
51 #if PRAGMA_IMPORT
52 #pragma import on
53 #endif
54 
55 #if PRAGMA_STRUCT_ALIGN
56 #pragma options align = mac68k
57 #elif PRAGMA_STRUCT_PACKPUSH
58 #pragma pack(push, 2)
59 #elif PRAGMA_STRUCT_PACK
60 #pragma pack(2)
61 #endif
62 
64  typedef struct OpaqueURLReference *URLReference;
65  typedef UInt32 URLOpenFlags;
66  enum
67  {
68  kURLReplaceExistingFlag = 1 << 0,
69  kURLBinHexFileFlag = 1 << 1,
71  1 << 2,
73  kURLDisplayAuthFlag =
74  1 << 4,
75  kURLUploadFlag = 1 << 5,
78  1 << 7,
80  1 << 8,
82  1 << 9,
84  << 10,
86  1 << 11,
92  1
93  << 13,
97  (unsigned long)(1 << 31)
98  };
99 
100  typedef UInt32 URLState;
101  enum
102  {
103  kURLNullState = 0,
104  kURLInitiatingState = 1,
105  kURLLookingUpHostState = 2,
106  kURLConnectingState = 3,
107  kURLResourceFoundState = 4,
108  kURLDownloadingState = 5,
109  kURLDataAvailableState = 0x10 + kURLDownloadingState,
110  kURLTransactionCompleteState = 6,
111  kURLErrorOccurredState = 7,
112  kURLAbortingState = 8,
113  kURLCompletedState = 9,
114  kURLUploadingState = 10
115  };
116 
117  typedef UInt32 URLEvent;
118  enum
119  {
120  kURLInitiatedEvent = kURLInitiatingState,
121  kURLResourceFoundEvent = kURLResourceFoundState,
122  kURLDownloadingEvent = kURLDownloadingState,
123  kURLAbortInitiatedEvent = kURLAbortingState,
124  kURLCompletedEvent = kURLCompletedState,
125  kURLErrorOccurredEvent = kURLErrorOccurredState,
126  kURLDataAvailableEvent = kURLDataAvailableState,
127  kURLTransactionCompleteEvent = kURLTransactionCompleteState,
128  kURLUploadingEvent = kURLUploadingState,
129  kURLSystemEvent = 29,
130  kURLPercentEvent = 30,
131  kURLPeriodicEvent = 31,
132  kURLPropertyChangedEvent = 32
133  };
134 
135  typedef unsigned long URLEventMask;
136  enum
137  {
138  kURLInitiatedEventMask = 1 << (kURLInitiatedEvent - 1),
139  kURLResourceFoundEventMask = 1 << (kURLResourceFoundEvent - 1),
140  kURLDownloadingMask = 1 << (kURLDownloadingEvent - 1),
141  kURLUploadingMask = 1 << (kURLUploadingEvent - 1),
142  kURLAbortInitiatedMask = 1 << (kURLAbortInitiatedEvent - 1),
143  kURLCompletedEventMask = 1 << (kURLCompletedEvent - 1),
144  kURLErrorOccurredEventMask = 1 << (kURLErrorOccurredEvent - 1),
145  kURLDataAvailableEventMask = 1 << (kURLDataAvailableEvent - 1),
146  kURLTransactionCompleteEventMask = 1 << (kURLTransactionCompleteEvent - 1),
147  kURLSystemEventMask = 1 << (kURLSystemEvent - 1),
148  kURLPercentEventMask = 1 << (kURLPercentEvent - 1),
149  kURLPeriodicEventMask = 1 << (kURLPeriodicEvent - 1),
150  kURLPropertyChangedEventMask = 1 << (kURLPropertyChangedEvent - 1),
151  kURLAllBufferEventsMask =
152  kURLDataAvailableEventMask + kURLTransactionCompleteEventMask,
153  kURLAllNonBufferEventsMask =
154  kURLInitiatedEventMask + kURLDownloadingMask + kURLUploadingMask +
155  kURLAbortInitiatedMask + kURLCompletedEventMask +
156  kURLErrorOccurredEventMask + kURLPercentEventMask +
157  kURLPeriodicEventMask + kURLPropertyChangedEventMask,
158  kURLAllEventsMask = (long)0xFFFFFFFF
159  };
160 
162  {
163  UInt32 version;
164  URLReference urlRef;
165  const char *property;
166  UInt32 currentSize;
167  EventRecord *systemEvent;
168  };
169  typedef struct URLCallbackInfo URLCallbackInfo;
170 
172  enum
173  {
174  kUserNameAndPasswordFlag = 0x00000001
175  };
176 
177 #define kURLURL "URLString"
178 #define kURLResourceSize "URLResourceSize"
179 #define kURLLastModifiedTime "URLLastModifiedTime"
180 #define kURLMIMEType "URLMIMEType"
181 #define kURLFileType "URLFileType"
182 #define kURLFileCreator "URLFileCreator"
183 #define kURLCharacterSet "URLCharacterSet"
184 #define kURLResourceName "URLResourceName"
185 #define kURLHost "URLHost"
186 #define kURLAuthType "URLAuthType"
187 #define kURLUserName "URLUserName"
188 #define kURLPassword "URLPassword"
189 #define kURLStatusString "URLStatusString"
190 #define kURLIsSecure "URLIsSecure"
191 #define kURLCertificate "URLCertificate"
192 #define kURLTotalItems "URLTotalItems"
193 #define kURLConnectTimeout "URLConnectTimeout"
195 #define kURLHTTPRequestMethod "URLHTTPRequestMethod"
196 #define kURLHTTPRequestHeader "URLHTTPRequestHeader"
197 #define kURLHTTPRequestBody "URLHTTPRequestBody"
198 #define kURLHTTPRespHeader "URLHTTPRespHeader"
199 #define kURLHTTPUserAgent "URLHTTPUserAgent"
200 #define kURLHTTPRedirectedURL "URLHTTPRedirectedURL"
201 #define kURLSSLCipherSuite "URLSSLCipherSuite"
202 
211  OSStatus
212  URLGetURLAccessVersion(UInt32 *returnVers);
213 
214 #if TARGET_RT_MAC_CFM
215 #ifdef __cplusplus
216  inline pascal Boolean URLAccessAvailable()
217  {
218  return ((URLGetURLAccessVersion != (void *)kUnresolvedCFragSymbolAddress));
219  }
220 #else
221 #define URLAccessAvailable() \
222  ((URLGetURLAccessVersion != (void *)kUnresolvedCFragSymbolAddress))
223 #endif
224 #elif TARGET_RT_MAC_MACHO
226 #ifdef __cplusplus
227 inline pascal Boolean URLAccessAvailable() { return true; }
228 #else
229 #define URLAccessAvailable() (true)
230 #endif
231 #endif
233  typedef CALLBACK_API(OSStatus, URLNotifyProcPtr)(void *userContext,
234  URLEvent event,
235  URLCallbackInfo *callbackInfo);
236  typedef CALLBACK_API(OSStatus, URLSystemEventProcPtr)(void *userContext,
237  EventRecord *event);
238  typedef TVECTOR_UPP_TYPE(URLNotifyProcPtr) URLNotifyUPP;
239  typedef TVECTOR_UPP_TYPE(URLSystemEventProcPtr) URLSystemEventUPP;
248  URLNotifyUPP
249  NewURLNotifyUPP(URLNotifyProcPtr userRoutine);
250 #if !OPAQUE_UPP_TYPES
251  enum
252  {
253  uppURLNotifyProcInfo = 0x00000FF0
254  };
255 #ifdef __cplusplus
256  inline URLNotifyUPP NewURLNotifyUPP(URLNotifyProcPtr userRoutine)
257  {
258  return userRoutine;
259  }
260 #else
261 #define NewURLNotifyUPP(userRoutine) (userRoutine)
262 #endif
263 #endif
264 
273  URLSystemEventUPP
274  NewURLSystemEventUPP(URLSystemEventProcPtr userRoutine);
275 #if !OPAQUE_UPP_TYPES
276  enum
277  {
278  uppURLSystemEventProcInfo = 0x000003F0
279  };
280 #ifdef __cplusplus
281  inline URLSystemEventUPP
282  NewURLSystemEventUPP(URLSystemEventProcPtr userRoutine)
283  {
284  return userRoutine;
285  }
286 #else
287 #define NewURLSystemEventUPP(userRoutine) (userRoutine)
288 #endif
289 #endif
290 
299  void
300  DisposeURLNotifyUPP(URLNotifyUPP userUPP);
301 #if !OPAQUE_UPP_TYPES
302 #ifdef __cplusplus
303  inline void DisposeURLNotifyUPP(URLNotifyUPP) {}
304 #else
305 #define DisposeURLNotifyUPP(userUPP)
306 #endif
307 #endif
308 
317  void
318  DisposeURLSystemEventUPP(URLSystemEventUPP userUPP);
319 #if !OPAQUE_UPP_TYPES
320 #ifdef __cplusplus
321  inline void DisposeURLSystemEventUPP(URLSystemEventUPP) {}
322 #else
323 #define DisposeURLSystemEventUPP(userUPP)
324 #endif
325 #endif
326 
335  OSStatus
336  InvokeURLNotifyUPP(void *userContext, URLEvent event,
337  URLCallbackInfo *callbackInfo, URLNotifyUPP userUPP);
338 #if !OPAQUE_UPP_TYPES
339 #ifdef __cplusplus
340  inline OSStatus InvokeURLNotifyUPP(void *userContext, URLEvent event,
341  URLCallbackInfo *callbackInfo,
342  URLNotifyUPP userUPP)
343  {
344  return (*userUPP)(userContext, event, callbackInfo);
345  }
346 #else
347 #define InvokeURLNotifyUPP(userContext, event, callbackInfo, userUPP) \
348  (*userUPP)(userContext, event, callbackInfo)
349 #endif
350 #endif
351 
360  OSStatus
362  URLSystemEventUPP userUPP);
363 #if !OPAQUE_UPP_TYPES
364 #ifdef __cplusplus
365  inline OSStatus InvokeURLSystemEventUPP(void *userContext, EventRecord *event,
366  URLSystemEventUPP userUPP)
367  {
368  return (*userUPP)(userContext, event);
369  }
370 #else
371 #define InvokeURLSystemEventUPP(userContext, event, userUPP) \
372  (*userUPP)(userContext, event)
373 #endif
374 #endif
375 
384  OSStatus
385  URLSimpleDownload(const char *url, FSSpec *destination,
386  Handle destinationHandle,
387  URLOpenFlags openFlags,
388  URLSystemEventUPP eventProc,
389  void *userContext);
399  OSStatus
400  URLDownload(URLReference urlRef, FSSpec *destination,
401  Handle destinationHandle,
402  URLOpenFlags openFlags,
403  URLSystemEventUPP eventProc,
404  void *userContext);
414  OSStatus
415  URLSimpleUpload(const char *url, const FSSpec *source, URLOpenFlags openFlags,
416  URLSystemEventUPP eventProc,
417  void *userContext);
427  OSStatus
428  URLUpload(URLReference urlRef, const FSSpec *source, URLOpenFlags openFlags,
429  URLSystemEventUPP eventProc,
430  void *userContext);
440  OSStatus
441  URLNewReference(const char *url, URLReference *urlRef);
442 
451  OSStatus
453 
462  OSStatus
463  URLOpen(URLReference urlRef, FSSpec *fileSpec,
464  URLOpenFlags openFlags, URLNotifyUPP notifyProc,
465  URLEventMask eventRegister, void *userContext);
475  OSStatus
477 
486  OSStatus
487  URLGetDataAvailable(URLReference urlRef, Size *dataSize);
488 
497  OSStatus
498  URLGetBuffer(URLReference urlRef, void **buffer, Size *bufferSize);
499 
508  OSStatus
509  URLReleaseBuffer(URLReference urlRef, void *buffer);
510 
519  OSStatus
520  URLGetProperty(URLReference urlRef, const char *property, void *propertyBuffer,
521  Size bufferSize);
522 
531  OSStatus
532  URLGetPropertySize(URLReference urlRef, const char *property,
533  Size *propertySize);
534 
543  OSStatus
544  URLSetProperty(URLReference urlRef, const char *property, void *propertyBuffer,
545  Size bufferSize);
546 
555  OSStatus
556  URLGetCurrentState(URLReference urlRef, URLState *state);
557 
566  OSStatus
567  URLGetError(URLReference urlRef, OSStatus *urlError);
568 
577  OSStatus
578  URLIdle(void);
579 
588  OSStatus
589  URLGetFileInfo(StringPtr fName, OSType *fType, OSType *fCreator);
590 
591 #if PRAGMA_STRUCT_ALIGN
592 #pragma options align = reset
593 #elif PRAGMA_STRUCT_PACKPUSH
594 #pragma pack(pop)
595 #elif PRAGMA_STRUCT_PACK
596 #pragma pack()
597 #endif
598 
599 #ifdef PRAGMA_IMPORT_OFF
600 #pragma import off
601 #elif PRAGMA_IMPORT
602 #pragma import reset
603 #endif
604 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif
Public Code Fragment Manager Interfaces.
Event Manager Interfaces.
File Manager (MFS, HFS, and HFS+) Interfaces.
OSErr codes.
Basic Macintosh data types.
unsigned char * StringPtr
Definition: MacTypes.h:477
unsigned char Boolean
Definition: MacTypes.h:318
OSStatus InvokeURLNotifyUPP(void *userContext, URLEvent event, URLCallbackInfo *callbackInfo, URLNotifyUPP userUPP)
OSStatus URLIdle(void)
#define NewURLSystemEventUPP(userRoutine)
Definition: URLAccess.h:287
OSStatus URLNewReference(const char *url, URLReference *urlRef)
OSStatus InvokeURLSystemEventUPP(void *userContext, EventRecord *event, URLSystemEventUPP userUPP)
OSStatus URLGetURLAccessVersion(UInt32 *returnVers)
OSStatus URLGetBuffer(URLReference urlRef, void **buffer, Size *bufferSize)
OSStatus URLDownload(URLReference urlRef, FSSpec *destination, Handle destinationHandle, URLOpenFlags openFlags, URLSystemEventUPP eventProc, void *userContext)
void DisposeURLNotifyUPP(URLNotifyUPP userUPP)
struct OpaqueURLReference * URLReference
Definition: URLAccess.h:64
OSStatus URLSimpleDownload(const char *url, FSSpec *destination, Handle destinationHandle, URLOpenFlags openFlags, URLSystemEventUPP eventProc, void *userContext)
OSStatus URLGetPropertySize(URLReference urlRef, const char *property, Size *propertySize)
OSStatus URLGetError(URLReference urlRef, OSStatus *urlError)
OSStatus URLGetDataAvailable(URLReference urlRef, Size *dataSize)
OSStatus URLReleaseBuffer(URLReference urlRef, void *buffer)
OSStatus URLUpload(URLReference urlRef, const FSSpec *source, URLOpenFlags openFlags, URLSystemEventUPP eventProc, void *userContext)
OSStatus URLAbort(URLReference urlRef)
OSStatus URLSetProperty(URLReference urlRef, const char *property, void *propertyBuffer, Size bufferSize)
OSStatus URLGetFileInfo(StringPtr fName, OSType *fType, OSType *fCreator)
void DisposeURLSystemEventUPP(URLSystemEventUPP userUPP)
OSStatus URLGetProperty(URLReference urlRef, const char *property, void *propertyBuffer, Size bufferSize)
@ kURLDebinhexOnlyFlag
Definition: URLAccess.h:85
@ kURLExpandAndVerifyFlag
Definition: URLAccess.h:81
@ kURLDisplayProgressFlag
Definition: URLAccess.h:72
@ kURLDirectoryListingFlag
Definition: URLAccess.h:79
@ kURLIsDirectoryHintFlag
Definition: URLAccess.h:76
@ kURLExpandFileFlag
Definition: URLAccess.h:70
@ kURLNoAutoRedirectFlag
Definition: URLAccess.h:83
@ kURLUploadFlag
Definition: URLAccess.h:75
@ kURLDoNotDeleteOnErrorFlag
Definition: URLAccess.h:87
@ kURLResumeDownloadFlag
Definition: URLAccess.h:91
@ kURLReservedFlag
Definition: URLAccess.h:96
@ kURLDoNotTryAnonymousFlag
Definition: URLAccess.h:77
OSStatus URLDisposeReference(URLReference urlRef)
OSStatus URLGetCurrentState(URLReference urlRef, URLState *state)
OSStatus URLSimpleUpload(const char *url, const FSSpec *source, URLOpenFlags openFlags, URLSystemEventUPP eventProc, void *userContext)
#define NewURLNotifyUPP(userRoutine)
Definition: URLAccess.h:261
OSStatus URLOpen(URLReference urlRef, FSSpec *fileSpec, URLOpenFlags openFlags, URLNotifyUPP notifyProc, URLEventMask eventRegister, void *userContext)
Definition: Events.h:224
Definition: URLAccess.h:162