FragmentStuff.h

/*
    File:       FragmentStuff.h
 
    Contains:   Data structures which define the 'cfrg' resource format
                and a our own independent data structure containing the
                information we need, in a simple format.
 
    Written by: Chris White 
 
    Copyright:  Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/5/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
 
#ifndef __FRAGMENTSTUFF__
#define __FRAGMENTSTUFF__
 
 
 
#ifndef __TYPES__
    #include <Types.h>
#endif
 
 
 
 
// The format of the 'cfrg' on disk. This is defined in <CodeFragmentTypes.r>
#ifdef powerc
    #pragma options align=mac68k
#endif
 
 
struct cfrgHeader
{
    long    res1;
    long    res2;
    long    version;
    long    res3;
    long    res4;
    long    filler1;
    long    filler2;
    long    itemCount;
    char    arrayStart; // Array of externalItems begins here
};
typedef struct cfrgHeader cfrgHeader, *hdrPtr, **hdrHand;
 
struct cfrgItem
{
    OSType  archType;
    long    updateLevel;
    long    currVersion;
    long    oldDefVersion;
    long    appStackSize;
    short   appSubFolder;
    char    usage;
    char    location;
    long    codeOffset;
    long    codeLength;
    long    res1;
    long    res2;
    short   itemSize; // %4 == 0
    Str255  name;
    // Only make the final p-string as long as needed, then align to
    // a longword boundary
};
typedef struct cfrgItem cfrgItem;
#ifdef powerc
    #pragma options align=reset
#endif
 
 
struct TempFileRec
{
    int     usageCount;
    FSSpec  fileSpec;
};
 
typedef struct TempFileRec tTempFileRec, *tTempFilePtr;
 
 
/* Record for each fragment. Includes simplified version of the 'cfrg' data */
struct internalItem
{
    /* Data used for the application */
    Boolean         bDeleted;
    Boolean         bExistsInDocument;
    tTempFilePtr    tempFilePtr;
    
    /* Data included in the 'cfrg' resource */
    OSType  archType;
    long    updateLevel;
    long    currVersion;
    long    oldDefVersion;
    long    appStackSize;
    short   appSubFolder;
    short   usage;
    short   location;
    long    codeOffset;
    long    codeLength;
    Str255  name;
};
typedef struct internalItem tItem, *tItemPtr;
 
struct internalResource {
    long            version;
    long            itemCount;
    tItem           itemList[1];
};
typedef struct internalResource tHeader, *tHeaderPtr, **tHeaderHan;
 
/* ===== Prototypes ===== */
OSErr ParseResource (Handle theResource, tHeaderHan internalCopy);
OSErr BuildResource (tHeaderHan internalCopy, Handle theResource);
 
 
 
 
#endif // define __FRAGMENTS__