Package Name: resources

Return to: Package List


with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Types; use Types;
with Files; use Files;

package Resources is
   --  
   --  File:       Resources.h
   --  
   --  Contains:   Resource Manager Interfaces.
   --  
   --  Version:    Technology: System 7.5
   --              Package:    Universal Interfaces 2.1 in ÒMPW LatestÓ on ETO #18
   --  
   --  Copyright:  © 1984-1995 by Apple Computer, Inc.
   --              All rights reserved.

   --  
	resSysHeap      : constant := 64; -- System or application heap?
	resPurgeable    : constant := 32; -- Purgeable resource?
	resLocked       : constant := 16; -- Load it in locked?
	resProtected    : constant := 8; -- Protected?
	resPreload      : constant := 4; -- Load in on OpenResFile?
	resChanged      : constant := 2; -- Resource changed?
	mapReadOnly     : constant := 128; -- Resource file read-only
	mapCompact      : constant := 64; -- Compact resource file
	mapChanged      : constant := 32; -- Write map out at update
	resSysRefBit    : constant := 7; -- reference to system/local reference
	resSysHeapBit   : constant := 6; -- In system/in application heap
	resPurgeableBit : constant := 5; -- Purgeable/not purgeable
	resLockedBit    : constant := 4; -- Locked/not locked
	resProtectedBit : constant := 3; -- Protected/not protected
	resPreloadBit   : constant := 2; -- Read in at OpenResource?
	resChangedBit   : constant := 1; -- Existing resource changed since last update
	mapReadOnlyBit  : constant := 7; -- is this file read-only?
	mapCompactBit   : constant := 6; -- Is a compact necessary?
	mapChangedBit   : constant := 5; -- Is it necessary to write map?
	kSystemResFile   : constant := 0; -- this is the default ref num to the system file

	kResFileNotOpened : constant := -1; -- ref num return as error when opening a resource file
   subtype ResErrUPP is UniversalProcPtr;

	uppResErrProcInfo : constant := 16#00001002#; -- Register PROCEDURE (2 bytes in D0);
   function InitResources
      return                      Short_Integer;
   pragma Import (C, InitResources, "InitResources", "InitResources");
   
   procedure RsrcZoneInit;

   pragma Import (C, RsrcZoneInit, "RsrcZoneInit", "RsrcZoneInit");
   procedure CloseResFile
     (refNum             : in     Short_Integer);

   pragma Import (C, CloseResFile, "CloseResFile", "CloseResFile");
   function ResError
      return                      Short_Integer;

   pragma Import (C, ResError, "ResError", "ResError");
   function CurResFile
      return                      Short_Integer;

   pragma Import (C, CurResFile, "CurResFile", "CurResFile");
   function HomeResFile
     (theResource        : in     Handle)
      return                      Short_Integer;

   pragma Import (C, HomeResFile, "HomeResFile", "HomeResFile");
   procedure CreateResFile
     (fileName           : access Str255);

   pragma Import (C, CreateResFile, "CreateResFile", "CreateResFile");
   function OpenResFile
     (fileName           : access Str255)
      return                      Short_Integer;

   pragma Import (C, OpenResFile, "OpenResFile", "OpenResFile");
   procedure UseResFile
     (refNum             : in     Short_Integer);

   pragma Import (C, UseResFile, "UseResFile", "UseResFile");
   function CountTypes
      return                      Short_Integer;

   pragma Import (C, CountTypes, "CountTypes", "CountTypes");
   function Count1Types
      return                      Short_Integer;

   pragma Import (C, Count1Types, "Count1Types", "Count1Types");
   procedure GetIndType
     (theType            : access ResType;
      index              : in     Short_Integer);

   pragma Import (C, GetIndType, "GetIndType", "GetIndType");
   procedure Get1IndType
     (theType            : access ResType;
      index              : in     Short_Integer);

   pragma Import (C, Get1IndType, "Get1IndType", "Get1IndType");
   procedure SetResLoad
     (load               : in     Boolean);

   pragma Import (C, SetResLoad, "SetResLoad", "SetResLoad");
   function CountResources
     (theType            : in     ResType)
      return                      Short_Integer;

   pragma Import (C, CountResources, "CountResources", "CountResources");
   function Count1Resources
     (theType            : in     ResType)
      return                      Short_Integer;

   pragma Import (C, Count1Resources, "Count1Resources", "Count1Resources");
   function GetIndResource
     (theType            : in     ResType;
      index              : in     Short_Integer)
      return                      Handle;

   pragma Import (C, GetIndResource, "GetIndResource", "GetIndResource");
   function Get1IndResource
     (theType            : in     ResType;
      index              : in     Short_Integer)
      return                      Handle;

   pragma Import (C, Get1IndResource, "Get1IndResource", "Get1IndResource");
   function GetResource
     (theType            : in     ResType;
      theID              : in     Short_Integer)
      return                      Handle;

   pragma Import (C, GetResource, "GetResource", "GetResource");
   function Get1Resource
     (theType            : in     ResType;
      theID              : in     Short_Integer)
      return                      Handle;

   pragma Import (C, Get1Resource, "Get1Resource", "Get1Resource");
   function GetNamedResource
     (theType            : in     ResType;
      name               : access Str255)
      return                      Handle;

   pragma Import (C, GetNamedResource, "GetNamedResource", "GetNamedResource");
   function Get1NamedResource
     (theType            : in     ResType;
      name               : access Str255)
      return                      Handle;

   pragma Import (C, Get1NamedResource, "Get1NamedResource", "Get1NamedResource");
   procedure LoadResource
     (theResource        : in     Handle);

   pragma Import (C, LoadResource, "LoadResource", "LoadResource");
   procedure ReleaseResource
     (theResource        : in     Handle);

   pragma Import (C, ReleaseResource, "ReleaseResource", "ReleaseResource");
   procedure DetachResource
     (theResource        : in     Handle);

   pragma Import (C, DetachResource, "DetachResource", "DetachResource");
   function UniqueID
     (theType            : in     ResType)
      return                      Short_Integer;

   pragma Import (C, UniqueID, "UniqueID", "UniqueID");
   function Unique1ID
     (theType            : in     ResType)
      return                      Short_Integer;

   pragma Import (C, Unique1ID, "Unique1ID", "Unique1ID");
   function GetResAttrs
     (theResource        : in     Handle)
      return                      Short_Integer;

   pragma Import (C, GetResAttrs, "GetResAttrs", "GetResAttrs");
   procedure GetResInfo
     (theResource        : in     Handle;
      theID              : access Short_Integer;
      theType            : access ResType;
      name               : access Str255);

   pragma Import (C, GetResInfo, "GetResInfo", "GetResInfo");
   procedure SetResInfo
     (theResource        : in     Handle;
      theID              : in     Short_Integer;
      name               : access Str255);

   pragma Import (C, SetResInfo, "SetResInfo", "SetResInfo");
   procedure AddResource
     (theData            : in     Handle;
      theType            : in     ResType;
      theID              : in     Short_Integer;
      name               : access Str255);

   pragma Import (C, AddResource, "AddResource", "AddResource");
   function GetResourceSizeOnDisk
     (theResource        : in     Handle)
      return                      Long_Integer;

   pragma Import (C, GetResourceSizeOnDisk, "GetResourceSizeOnDisk", "GetResourceSizeOnDisk");
   function GetMaxResourceSize
     (theResource        : in     Handle)
      return                      Long_Integer;

   pragma Import (C, GetMaxResourceSize, "GetMaxResourceSize", "GetMaxResourceSize");
   function RsrcMapEntry
     (theResource        : in     Handle)
      return                      Long_Integer;

   pragma Import (C, RsrcMapEntry, "RsrcMapEntry", "RsrcMapEntry");
   procedure SetResAttrs
     (theResource        : in     Handle;
      attrs              : in     Short_Integer);

   pragma Import (C, SetResAttrs, "SetResAttrs", "SetResAttrs");
   procedure ChangedResource
     (theResource        : in     Handle);

   pragma Import (C, ChangedResource, "ChangedResource", "ChangedResource");
   procedure RemoveResource
     (theResource        : in     Handle);

   pragma Import (C, RemoveResource, "RemoveResource", "RemoveResource");
   procedure UpdateResFile
     (refNum             : in     Short_Integer);

   pragma Import (C, UpdateResFile, "UpdateResFile", "UpdateResFile");
   procedure WriteResource
     (theResource        : in     Handle);

   pragma Import (C, WriteResource, "WriteResource", "WriteResource");
   procedure SetResPurge
     (install            : in     Boolean);

   pragma Import (C, SetResPurge, "SetResPurge", "SetResPurge");
   function GetResFileAttrs
     (refNum             : in     Short_Integer)
      return                      Short_Integer;

   pragma Import (C, GetResFileAttrs, "GetResFileAttrs", "GetResFileAttrs");
   procedure SetResFileAttrs
     (refNum             : in     Short_Integer;
      attrs              : in     Short_Integer);

   pragma Import (C, SetResFileAttrs, "SetResFileAttrs", "SetResFileAttrs");
   function OpenRFPerm
     (fileName           : access Str255;
      vRefNum            : in     Short_Integer;
      permission         : in     SInt8)
      return                      Short_Integer;

   pragma Import (C, OpenRFPerm, "OpenRFPerm", "OpenRFPerm");
   function RGetResource
     (theType            : in     ResType;
      theID              : in     Short_Integer)
      return                      Handle;

   pragma Import (C, RGetResource, "RGetResource", "RGetResource");
   function HOpenResFile
     (vRefNum            : in     Short_Integer;
      dirID              : in     Long_Integer;
      fileName           : access Str255;
      permission         : in     SInt8)
      return                      Short_Integer;

   pragma Import (C, HOpenResFile, "HOpenResFile", "HOpenResFile");
   procedure HCreateResFile
     (vRefNum            : in     Short_Integer;
      dirID              : in     Long_Integer;
      fileName           : access Str255);

   pragma Import (C, HCreateResFile, "HCreateResFile", "HCreateResFile");
   function FSpOpenResFile
     (spec               : access FSSpec;
      permission         : in     SignedByte)
      return                      Short_Integer;

   pragma Import (C, FSpOpenResFile, "FSpOpenResFile", "FSpOpenResFile");
   procedure FSpCreateResFile
     (spec               : access FSSpec;
      creator            : in     OSType;
      fileType           : in     OSType;
      scriptTag          : in     ScriptCode);

   pragma Import (C, FSpCreateResFile, "FSpCreateResFile", "FSpCreateResFile");
   procedure ReadPartialResource
     (theResource        : in     Handle;
      offset             : in     Long_Integer;
      buffer             : in     Void_Ptr;
      count              : in     Long_Integer);

   pragma Import (C, ReadPartialResource, "ReadPartialResource", "ReadPartialResource");
   procedure WritePartialResource
     (theResource        : in     Handle;
      offset             : in     Long_Integer;
      buffer             : in     Void_Ptr;
      count              : in     Long_Integer);

   pragma Import (C, WritePartialResource, "WritePartialResource", "WritePartialResource");
   procedure SetResourceSize
     (theResource        : in     Handle;
      newSize            : in     Long_Integer);

   pragma Import (C, SetResourceSize, "SetResourceSize", "SetResourceSize");
   function GetNextFOND
     (fondHandle         : in     Handle)
      return                      Handle;

   pragma Import (C, GetNextFOND, "GetNextFOND", "GetNextFOND");
   --  Use TempInsertROMMap to force the ROM resource map to be
   --  inserted into the chain in front of the system. Note that
   --  this call is only temporary - the modified resource chain
   --  is only used for the next call to the resource manager.
   procedure TempInsertROMMap
     (tempResLoad        : in     Boolean);

   pragma Import (C, TempInsertROMMap, "TempInsertROMMap", "TempInsertROMMap");
   function getnamedresourceC
     (theType            : in     ResType;
      name               : in     Chars_Ptr)
      return                      Handle;

   pragma Import (C, getnamedresourceC, "getnamedresource", "getnamedresource");
   function getnamedresource
     (theType            : in     ResType;
      name               : in     Chars_Ptr)
      return                      Handle

   renames getnamedresourceC;
   function getnamedresource
     (theType            : in     ResType;
      name               : in     String)

      return                      Handle;
   function get1namedresourceC
     (theType            : in     ResType;
      name               : in     Chars_Ptr)
      return                      Handle;

   pragma Import (C, get1namedresourceC, "get1namedresource", "get1namedresource");
   function get1namedresource
     (theType            : in     ResType;
      name               : in     Chars_Ptr)
      return                      Handle

   renames get1namedresourceC;
   function get1namedresource
     (theType            : in     ResType;
      name               : in     String)

      return                      Handle;
   function openrfpermC
     (fileName           : in     Chars_Ptr;
      vRefNum            : in     Short_Integer;
      permission         : in     char)
      return                      Short_Integer;

   pragma Import (C, openrfpermC, "openrfperm", "openrfperm");
   function openrfperm
     (fileName           : in     Chars_Ptr;
      vRefNum            : in     Short_Integer;
      permission         : in     char)
      return                      Short_Integer

   renames openrfpermC;
   function openrfperm
     (fileName           : in     String;
      vRefNum            : in     Short_Integer;
      permission         : in     char)

      return                      Short_Integer;
   function openresfileC
     (fileName           : in     Chars_Ptr)
      return                      Short_Integer;

   pragma Import (C, openresfileC, "openresfile", "openresfile");
   function openresfile
     (fileName           : in     Chars_Ptr)
      return                      Short_Integer

   renames openresfileC;
   function openresfile
     (fileName           : in     String)

      return                      Short_Integer;
   procedure createresfileC
     (fileName           : in     Chars_Ptr);

   pragma Import (C, createresfileC, "createresfile", "createresfile");
   procedure createresfile
     (fileName           : in     Chars_Ptr)

  renames createresfileC;
   procedure createresfile

     (fileName           : in     String);
   procedure getresinfoC
     (theResource        : in     Handle;
      theID              : access Short_Integer;
      theType            : access ResType;
      name               : in     Chars_Ptr);

   pragma Import (C, getresinfoC, "getresinfo", "getresinfo");
   procedure getresinfo
     (theResource        : in     Handle;
      theID              : access Short_Integer;
      theType            : access ResType;
      name               : in     Chars_Ptr)

   renames getresinfoC;
   procedure setresinfoC
     (theResource        : in     Handle;
      theID              : in     Short_Integer;
      name               : in     Chars_Ptr);

   pragma Import (C, setresinfoC, "setresinfo", "setresinfo");
   procedure setresinfo
     (theResource        : in     Handle;
      theID              : in     Short_Integer;
      name               : in     Chars_Ptr)

   renames setresinfoC;
   procedure setresinfo
     (theResource        : in     Handle;
      theID              : in     Short_Integer;

      name               : in     String);
   procedure addresourceC
     (theResource        : in     Handle;
      theType            : in     ResType;
      theID              : in     Short_Integer;
      name               : in     Chars_Ptr);

   pragma Import (C, addresourceC, "addresource", "addresource");
   procedure addresource
     (theResource        : in     Handle;
      theType            : in     ResType;
      theID              : in     Short_Integer;
      name               : in     Chars_Ptr)

   renames addresourceC;
   procedure addresource
     (theResource        : in     Handle;
      theType            : in     ResType;
      theID              : in     Short_Integer;

      name               : in     String);
end Resources;