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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Resources.h
  3.  
  4.      Contains:   Resource Manager Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8.1
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-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 __RESOURCES__
  18. #define __RESOURCES__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __MIXEDMODE__
  23. #include "MixedMode.h"
  24. #endif
  25. #ifndef __FILES__
  26. #include "Files.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=mac68k
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. enum {
  45.     resSysHeap                  = 64,                           /*System or application heap?*/
  46.     resPurgeable                = 32,                           /*Purgeable resource?*/
  47.     resLocked                   = 16,                           /*Load it in locked?*/
  48.     resProtected                = 8,                            /*Protected?*/
  49.     resPreload                  = 4,                            /*Load in on OpenResFile?*/
  50.     resChanged                  = 2,                            /*Resource changed?*/
  51.     mapReadOnly                 = 128,                          /*Resource file read-only*/
  52.     mapCompact                  = 64,                           /*Compact resource file*/
  53.     mapChanged                  = 32                            /*Write map out at update*/
  54. };
  55. enum {
  56.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  57.     resSysHeapBit               = 6,                            /*In system/in application heap*/
  58.     resPurgeableBit             = 5,                            /*Purgeable/not purgeable*/
  59.     resLockedBit                = 4,                            /*Locked/not locked*/
  60.     resProtectedBit             = 3,                            /*Protected/not protected*/
  61.     resPreloadBit               = 2,                            /*Read in at OpenResource?*/
  62.     resChangedBit               = 1,                            /*Existing resource changed since last update*/
  63.     mapReadOnlyBit              = 7,                            /*is this file read-only?*/
  64.     mapCompactBit               = 6,                            /*Is a compact necessary?*/
  65.     mapChangedBit               = 5                             /*Is it necessary to write map?*/
  66. };
  67. enum {
  68.     kResFileNotOpened           = -1,                           /*ref num return as error when opening a resource file*/
  69.     kSystemResFile              = 0                             /*this is the default ref num to the system file*/
  70. };
  71. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  72. /*
  73.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  74.              and cannot be written in a high-level language without 
  75.              the help of mixed mode or assembly glue.
  76. */
  77. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                        ResErrUPP;
  78. #if OPAQUE_UPP_TYPES
  79.     EXTERN_API(ResErrUPP)
  80.     NewResErrUPP                   (ResErrProcPtr           userRoutine);
  81.     EXTERN_API(void)
  82.     DisposeResErrUPP               (ResErrUPP               userUPP);
  83.     EXTERN_API(void)
  84.     InvokeResErrUPP                (OSErr                   thErr,
  85.                                     ResErrUPP               userUPP);
  86. #else
  87.     enum { uppResErrProcInfo = 0x00001002 };                        /* register no_return_value Func(2_bytes:D0) */
  88.     #define NewResErrUPP(userRoutine)                               (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  89.     #define DisposeResErrUPP(userUPP)                               DisposeRoutineDescriptor(userUPP)
  90.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  91.     #pragma parameter InvokeResErrUPP(__D0, __A0)
  92.     void InvokeResErrUPP(OSErr thErr, ResErrUPP userUPP) = 0x4E90;
  93.     #else
  94.         #define InvokeResErrUPP(thErr, userUPP)                         CALL_ONE_PARAMETER_UPP((userUPP), uppResErrProcInfo, (thErr))
  95.     #endif
  96. #endif
  97. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  98. #define NewResErrProc(userRoutine)                              NewResErrUPP(userRoutine)
  99. #define CallResErrProc(userRoutine, thErr)                      InvokeResErrUPP(thErr, userRoutine)
  100. #if !TARGET_OS_MAC
  101. /* QuickTime 3.0*/
  102. typedef CALLBACK_API( OSErr , ResourceEndianFilterPtr )(Handle theResource, Boolean currentlyNativeEndian);
  103. #endif  /* !TARGET_OS_MAC */
  104. #if CALL_NOT_IN_CARBON
  105. EXTERN_API( short )
  106. InitResources                   (void)                                                      ONEWORDINLINE(0xA995);
  107. EXTERN_API( void )
  108. RsrcZoneInit                    (void)                                                      ONEWORDINLINE(0xA996);
  109. #endif  /* CALL_NOT_IN_CARBON */
  110. EXTERN_API( void )
  111. CloseResFile                    (short                  refNum)                             ONEWORDINLINE(0xA99A);
  112. EXTERN_API( OSErr )
  113. ResError                        (void)                                                      ONEWORDINLINE(0xA9AF);
  114. EXTERN_API( short )
  115. CurResFile                      (void)                                                      ONEWORDINLINE(0xA994);
  116. EXTERN_API( short )
  117. HomeResFile                     (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  118. #if CALL_NOT_IN_CARBON
  119. EXTERN_API( void )
  120. CreateResFile                   (ConstStr255Param       fileName)                           ONEWORDINLINE(0xA9B1);
  121. EXTERN_API( short )
  122. OpenResFile                     (ConstStr255Param       fileName)                           ONEWORDINLINE(0xA997);
  123. #endif  /* CALL_NOT_IN_CARBON */
  124. EXTERN_API( void )
  125. UseResFile                      (short                  refNum)                             ONEWORDINLINE(0xA998);
  126. EXTERN_API( short )
  127. CountTypes                      (void)                                                      ONEWORDINLINE(0xA99E);
  128. EXTERN_API( short )
  129. Count1Types                     (void)                                                      ONEWORDINLINE(0xA81C);
  130. EXTERN_API( void )
  131. GetIndType                      (ResType *              theType,
  132.                                  short                  index)                              ONEWORDINLINE(0xA99F);
  133. EXTERN_API( void )
  134. Get1IndType                     (ResType *              theType,
  135.                                  short                  index)                              ONEWORDINLINE(0xA80F);
  136. EXTERN_API( void )
  137. SetResLoad                      (Boolean                load)                               ONEWORDINLINE(0xA99B);
  138. EXTERN_API( short )
  139. CountResources                  (ResType                theType)                            ONEWORDINLINE(0xA99C);
  140. EXTERN_API( short )
  141. Count1Resources                 (ResType                theType)                            ONEWORDINLINE(0xA80D);
  142. EXTERN_API( Handle )
  143. GetIndResource                  (ResType                theType,
  144.                                  short                  index)                              ONEWORDINLINE(0xA99D);
  145. EXTERN_API( Handle )
  146. Get1IndResource                 (ResType                theType,
  147.                                  short                  index)                              ONEWORDINLINE(0xA80E);
  148. EXTERN_API( Handle )
  149. GetResource                     (ResType                theType,
  150.                                  short                  theID)                              ONEWORDINLINE(0xA9A0);
  151. EXTERN_API( Handle )
  152. Get1Resource                    (ResType                theType,
  153.                                  short                  theID)                              ONEWORDINLINE(0xA81F);
  154. EXTERN_API( Handle )
  155. GetNamedResource                (ResType                theType,
  156.                                  ConstStr255Param       name)                               ONEWORDINLINE(0xA9A1);
  157. EXTERN_API( Handle )
  158. Get1NamedResource               (ResType                theType,
  159.                                  ConstStr255Param       name)                               ONEWORDINLINE(0xA820);
  160. #if TARGET_OS_MAC
  161.     #define MacLoadResource LoadResource
  162. #endif
  163. EXTERN_API( void )
  164. MacLoadResource                 (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  165. EXTERN_API( void )
  166. ReleaseResource                 (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  167. EXTERN_API( void )
  168. DetachResource                  (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  169. EXTERN_API( short )
  170. UniqueID                        (ResType                theType)                            ONEWORDINLINE(0xA9C1);
  171. EXTERN_API( short )
  172. Unique1ID                       (ResType                theType)                            ONEWORDINLINE(0xA810);
  173. EXTERN_API( short )
  174. GetResAttrs                     (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  175. EXTERN_API( void )
  176. GetResInfo                      (Handle                 theResource,
  177.                                  short *                theID,
  178.                                  ResType *              theType,
  179.                                  Str255                 name)                               ONEWORDINLINE(0xA9A8);
  180. EXTERN_API( void )
  181. SetResInfo                      (Handle                 theResource,
  182.                                  short                  theID,
  183.                                  ConstStr255Param       name)                               ONEWORDINLINE(0xA9A9);
  184. EXTERN_API( void )
  185. AddResource                     (Handle                 theData,
  186.                                  ResType                theType,
  187.                                  short                  theID,
  188.                                  ConstStr255Param       name)                               ONEWORDINLINE(0xA9AB);
  189. EXTERN_API( long )
  190. GetResourceSizeOnDisk           (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  191. EXTERN_API( long )
  192. GetMaxResourceSize              (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  193. #if CALL_NOT_IN_CARBON
  194. EXTERN_API( long )
  195. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  196. #endif  /* CALL_NOT_IN_CARBON */
  197. EXTERN_API( void )
  198. SetResAttrs                     (Handle                 theResource,
  199.                                  short                  attrs)                              ONEWORDINLINE(0xA9A7);
  200. EXTERN_API( void )
  201. ChangedResource                 (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  202. EXTERN_API( void )
  203. RemoveResource                  (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  204. EXTERN_API( void )
  205. UpdateResFile                   (short                  refNum)                             ONEWORDINLINE(0xA999);
  206. EXTERN_API( void )
  207. WriteResource                   (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  208. EXTERN_API( void )
  209. SetResPurge                     (Boolean                install)                            ONEWORDINLINE(0xA993);
  210. EXTERN_API( short )
  211. GetResFileAttrs                 (short                  refNum)                             ONEWORDINLINE(0xA9F6);
  212. EXTERN_API( void )
  213. SetResFileAttrs                 (short                  refNum,
  214.                                  short                  attrs)                              ONEWORDINLINE(0xA9F7);
  215. EXTERN_API( short )
  216. OpenRFPerm                      (ConstStr255Param       fileName,
  217.                                  short                  vRefNum,
  218.                                  SInt8                  permission)                         ONEWORDINLINE(0xA9C4);
  219. #if CALL_NOT_IN_CARBON
  220. EXTERN_API( Handle )
  221. RGetResource                    (ResType                theType,
  222.                                  short                  theID)                              ONEWORDINLINE(0xA80C);
  223. #endif  /* CALL_NOT_IN_CARBON */
  224. EXTERN_API( short )
  225. HOpenResFile                    (short                  vRefNum,
  226.                                  long                   dirID,
  227.                                  ConstStr255Param       fileName,
  228.                                  SInt8                  permission)                         ONEWORDINLINE(0xA81A);
  229. EXTERN_API( void )
  230. HCreateResFile                  (short                  vRefNum,
  231.                                  long                   dirID,
  232.                                  ConstStr255Param       fileName)                           ONEWORDINLINE(0xA81B);
  233. EXTERN_API( short )
  234. FSpOpenResFile                  (const FSSpec *         spec,
  235.                                  SignedByte             permission)                         TWOWORDINLINE(0x700D, 0xAA52);
  236. EXTERN_API( void )
  237. FSpCreateResFile                (const FSSpec *         spec,
  238.                                  OSType                 creator,
  239.                                  OSType                 fileType,
  240.                                  ScriptCode             scriptTag)                          TWOWORDINLINE(0x700E, 0xAA52);
  241. EXTERN_API( void )
  242. ReadPartialResource             (Handle                 theResource,
  243.                                  long                   offset,
  244.                                  void *                 buffer,
  245.                                  long                   count)                              TWOWORDINLINE(0x7001, 0xA822);
  246. EXTERN_API( void )
  247. WritePartialResource            (Handle                 theResource,
  248.                                  long                   offset,
  249.                                  const void *           buffer,
  250.                                  long                   count)                              TWOWORDINLINE(0x7002, 0xA822);
  251. EXTERN_API( void )
  252. SetResourceSize                 (Handle                 theResource,
  253.                                  long                   newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  254. EXTERN_API( Handle )
  255. GetNextFOND                     (Handle                 fondHandle)                         TWOWORDINLINE(0x700A, 0xA822);
  256. #if !TARGET_OS_MAC
  257. /* QuickTime 3.0*/
  258. #if CALL_NOT_IN_CARBON
  259. EXTERN_API_C( OSErr )
  260. RegisterResourceEndianFilter    (ResType                theType,
  261.                                  ResourceEndianFilterPtr  theFilterProc);
  262. #endif  /* CALL_NOT_IN_CARBON */
  263. #endif  /* !TARGET_OS_MAC */
  264. /* Use TempInsertROMMap to force the ROM resource map to be
  265.    inserted into the chain in front of the system. Note that
  266.    this call is only temporary - the modified resource chain
  267.    is only used for the next call to the resource manager.
  268.    See IM IV 19 for more information. 
  269. */
  270. #if CALL_NOT_IN_CARBON
  271. EXTERN_API( void )
  272. TempInsertROMMap                (Boolean                tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  273. /*
  274.   _________________________________________________________________________________________________________
  275.       
  276.    o RESOURCE CHAIN LOCATION - for use with the Resource Manager chain manipulation routines under Carbon.
  277.   _________________________________________________________________________________________________________
  278. */
  279. #endif  /* CALL_NOT_IN_CARBON */
  280. typedef SInt16                          RsrcChainLocation;
  281. enum {
  282.     kRsrcChainBelowSystemMap    = 0,                            /* Below the system's resource map*/
  283.     kRsrcChainBelowApplicationMap = 1,                          /* Below the application's resource map*/
  284.     kRsrcChainAboveApplicationMap = 2                           /* Above the application's resource map*/
  285. };
  286. /*
  287.    If the file is already in the resource chain, it is removed and re-inserted at the specified location
  288.    If the file has been detached, it is added to the resource chain at the specified location
  289.    Returns resFNotFound if it's not currently open.
  290. */
  291. EXTERN_API( OSErr )
  292. InsertResourceFile              (SInt16                 refNum,
  293.                                  RsrcChainLocation      where);
  294. /*
  295.    If the file is not currently in the resource chain, this returns resNotFound
  296.    Otherwise, the resource file is removed from the resource chain.
  297. */
  298. EXTERN_API( OSErr )
  299. DetachResourceFile              (SInt16                 refNum);
  300. /*
  301.    Returns true if the resource file is already open and known by the Resource Manager (i.e., it is
  302.    either in the current resource chain or it's a detached resource file.)  If it's in the resource 
  303.    chain, the inChain Boolean is set to true on exit and true is returned.  If it's an open file, but
  304.    the file is currently detached, inChain is set to false and true is returned.  If the file is open,
  305.    the refNum to the file is returned.
  306. */
  307. EXTERN_API( Boolean )
  308. FSpResourceFileAlreadyOpen      (const FSSpec *         resourceFile,
  309.                                  Boolean *              inChain,
  310.                                  SInt16 *               refNum)                             TWOWORDINLINE(0x7010, 0xA822);
  311. /*
  312.    FSpOpenOrphanResFile should be used to open a resource file that is persistent across all contexts,
  313.    because using OpenResFile normally loads a map and all preloaded resources into the application
  314.    context.  FSpOpenOrphanResFile loads everything into the system context and detaches the file 
  315.    from the context in which it was opened.  If the file is already in the resource chain and a new
  316.    instance is not opened, FSpOpenOrphanResFile will return a paramErr.
  317.    Use with care, as can and will fail if the map is very large or a lot of preload
  318.    resources exist.
  319. */
  320. EXTERN_API( OSErr )
  321. FSpOpenOrphanResFile            (const FSSpec *         spec,
  322.                                  SignedByte             permission,
  323.                                  SInt16 *               refNum);
  324. #if CALL_NOT_IN_CARBON
  325. EXTERN_API_C( Handle )
  326. getnamedresource                (ResType                theType,
  327.                                  const char *           name);
  328. EXTERN_API_C( Handle )
  329. get1namedresource               (ResType                theType,
  330.                                  const char *           name);
  331. EXTERN_API_C( short )
  332. openrfperm                      (const char *           fileName,
  333.                                  short                  vRefNum,
  334.                                  char                   permission);
  335. EXTERN_API_C( short )
  336. openresfile                     (const char *           fileName);
  337. EXTERN_API_C( void )
  338. createresfile                   (const char *           fileName);
  339. EXTERN_API_C( void )
  340. getresinfo                      (Handle                 theResource,
  341.                                  short *                theID,
  342.                                  ResType *              theType,
  343.                                  char *                 name);
  344. EXTERN_API_C( void )
  345. setresinfo                      (Handle                 theResource,
  346.                                  short                  theID,
  347.                                  const char *           name);
  348. EXTERN_API_C( void )
  349. addresource                     (Handle                 theResource,
  350.                                  ResType                theType,
  351.                                  short                  theID,
  352.                                  const char *           name);
  353. #endif  /* CALL_NOT_IN_CARBON */
  354. #if OLDROUTINENAMES
  355. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  356. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  357. #define RmveResource(theResource) RemoveResource(theResource)
  358. #endif  /* OLDROUTINENAMES */
  359. /*
  360.     These typedefs were originally created for the Copland Resource Mangager
  361. */
  362. typedef short                           ResFileRefNum;
  363. typedef short                           ResID;
  364. typedef short                           ResAttributes;
  365. typedef short                           ResFileAttributes;
  366. #if PRAGMA_STRUCT_ALIGN
  367.     #pragma options align=reset
  368. #elif PRAGMA_STRUCT_PACKPUSH
  369.     #pragma pack(pop)
  370. #elif PRAGMA_STRUCT_PACK
  371.     #pragma pack()
  372. #endif
  373. #ifdef PRAGMA_IMPORT_OFF
  374. #pragma import off
  375. #elif PRAGMA_IMPORT
  376. #pragma import reset
  377. #endif
  378. #ifdef __cplusplus
  379. }
  380. #endif
  381. #endif /* __RESOURCES__ */