BurgerLib
Public Types | Static Public Member Functions | Private Attributes | Static Private Attributes
Burger::Mac Class Reference

Class containing MacOS specific helper functions. More...

#include <maconly.h>

Collaboration diagram for Burger::Mac:
Collaboration graph
[legend]

List of all members.

Public Types

typedef struct OpaqueDialogPtr * DialogRef
 Alias for DialogRef for MacOS.

Static Public Member Functions

static BURGER_INLINE Word IsKeyPressedInKeyMap (const Word8 *pKeyMap, Word uKeyCode)
 Test if a key is pressed in a KeyMap structure.
static Word BURGER_API GetOSVersion (void)
 Return the version of MacOS.
static Word BURGER_API GetSoundManagerVersion (void)
 Return the version of the Sound Manager.
static Word BURGER_API GetAppleShareVersion (void)
 Return the version of AppleShare library.
static Word BURGER_API GetQuickTimeVersion (void)
 Return the version of QuickTime.
static Word BURGER_API GetInputSprocketVersion (void)
 Return the version of InputSprocket.
static Word BURGER_API GetDrawSprocketVersion (void)
 Return the version of DrawSprocket.
static Word BURGER_API IsAltivecPresent (void)
 Detect if Altivec instructions are present.
static Word BURGER_API IsQuickTimePowerPlugAvailable (void)
 Detect if the PowerPC native version of Quicktime is present.
static Word BURGER_API IsTrapAvailable (Word uTrapNum)
 Detect if a MacOS trap number exists.
static Word BURGER_API DialogControlGetValue (DialogRef pDialog, Word uItemNum)
 Return the value of a Mac Dialog Control.
static void BURGER_API DialogControlSetValue (DialogRef pDialog, Word uItemNum, Word uValue)
 Sets the value of a Mac Dialog Control.
static void BURGER_API DialogControlToggleValue (DialogRef pDialog, Word uItemNum)
 Toggles the value of a Mac Dialog Control.
static Word BURGER_API GetPathFromDirID (Burger::Filename *pOutput, long lDirID, short sVolRefNum)
 Convert a Mac DirID and a Volume reference into a Burgerlib path.
static char *BURGER_API GetPathFromFSSpec (char *pOutput, WordPtr uOutputSize, const FSSpec *pInput)
 Convert a MacOS FSSpec into a Burgerlib path.
static WordPtr BURGER_API GetPathFromFSSpecToBuffer (char *pOutput, WordPtr uOutputSize, const FSSpec *pInput)
 Convert a MacOS FSSpec into a Burgerlib path.
static char *BURGER_API GetPathFromFileURL (char *pOutput, WordPtr uOutputSize, const char *pInput)
 Convert a CFURL into a Burgerlib path.
static WordPtr BURGER_API GetPathFromFileURLToBuffer (char *pOutput, WordPtr uOutputSize, const char *pInput)
 Convert a CFURL into a Burgerlib path.

Private Attributes

Word16 m_usOSVersion
 Cached MacOS Version, zero means uninitialized.
Word16 m_usSoundManagerVersion
 Sound manager version in 0x0102 (1.2) format.
Word8 m_bSoundManagerVersionValid
 TRUE if sound manager version is valid
Word8 m_bAppleShareVersionValid
 TRUE if the AppleShare version is valid
Word16 m_usAppleShareVersion
 AppleShare version in 0x0102 (1.2) format.
Word16 m_usInputSprocketVersion
 InputSprocket version in 0x0102 (1.2) format.
Word8 m_bInputSprocketVersionFlag
 TRUE if InputSprocket version was obtained
Word8 m_bDrawSprocketVersionFlag
 TRUE if DrawSprocket version was obtained
Word16 m_usDrawSprocketVersion
 DrawSprocket version in 0x0102 (1.2) format.
Word8 m_bQuickTimePowerPlugPresent
 Bit 0 == TRUE if Quicktime's Power plug is loaded. Bit 7 (0x80) denotes bit 0 is valid.
Word8 m_bPowerPCFlags
 Bit field returned by Gestalt(gestaltPowerPCProcessorFeatures)&0x3F. Bit 7 (0x80) denotes if the rest of the bits are valid.
Word16 m_usQuickTimeVersion
 QuickTime's version in 0x0102 (1.2) format.
Word8 m_bQuickTimeVersionValid
 TRUE if Quicktime's version is valid.

Static Private Attributes

static Burger::Mac s_Singleton

Detailed Description

Class containing MacOS specific helper functions.

Code to simply common MacOS 9 (Classic) operations for MacOS specific code.

Note:
This class only exists on the BURGER_MAC build target due to the specific nature of these calls. Do not attempt to use these functions on non BURGER_MAC targets.

Member Typedef Documentation

typedef struct OpaqueDialogPtr* Burger::Mac::DialogRef

Alias for DialogRef for MacOS.


Member Function Documentation

Word BURGER_API Burger::Mac::DialogControlGetValue ( DialogRef  pDialog,
Word  uItemNum 
) [static]

Return the value of a Mac Dialog Control.

Given a DialogRef and an Item number, query the item and return the value associated with it. If the item is invalid or an error occurs, return 0.

Parameters:
pDialogA valid MacOS DialogRef.
uItemNumA valid item number associated with the dialog.
Returns:
The value from the control in the range of 0 to 65535 inclusive.
void BURGER_API Burger::Mac::DialogControlSetValue ( DialogRef  pDialog,
Word  uItemNum,
Word  uValue 
) [static]

Sets the value of a Mac Dialog Control.

Given a DialogRef, an Item number and a new value to use, select the item and set the passed value to it. If the item is invalid or an error occurs, do nothing.

Parameters:
pDialogA valid MacOS DialogRef.
uItemNumA valid item number associated with the dialog.
uValueA new value to associate with the item in the range of 0 to 65535 inclusive.
void BURGER_API Burger::Mac::DialogControlToggleValue ( DialogRef  pDialog,
Word  uItemNum 
) [static]

Toggles the value of a Mac Dialog Control.

Given a DialogRef and an Item number, query the item's value and toggle it with the != truth statement so only TRUE or FALSE are the resulting values. Useful for toggling checkboxes.

Parameters:
pDialogA valid MacOS DialogRef.
uItemNumA valid item number associated with the dialog.
Note:
If the item's current value is non-zero, it's set to zero, else one.

Return the version of AppleShare library.

Ask the AppleShare library what version it is and return that value. The function caches the value so subsequent calls do not ask AppleShare for the version again.

Returns:
Version in the format of 0x0102 -> 1.2
Note:
If the AppleShare library is not installed, it will return 0.

Return the version of DrawSprocket.

Detect if DrawSprocket is available, and if so, query it for the version present. If DrawSprocket is not available, the version returned is zero.

This function is written so it only asks for the version once from DrawSprocket. It will cache the version and return the cached value on subsequent calls.

DSpGetVersion() only appeared in version 1.7 or later and as a result, to get the version from earlier versions the version resource found in the library itself must be opened and read. Because of this, the first call to this function may take some time.

Returns:
Version in the format of 0x0102 -> 1.2
Note:
This code only works on CFM versions of Mac Classic applications. Non-CFM 68k targets will always return 0.

Return the version of InputSprocket.

Detect if InputSprocket is available, and if so, query it for the version present. If InputSprocket is not available, the version returned is zero.

This function is written so it only asks for the version once from InputSprocket. It will cache the version and return the cached value on subsequent calls.

Returns:
Version in the format of 0x0102 -> 1.2
Note:
This code only works on CFM versions of Mac Classic applications. Non-CFM 68k targets will always return 0.

Return the version of MacOS.

Ask MacOS what version it is and return that value. The function caches the value so subsequent calls do not ask the OS for the version again.

Returns:
Version in the format of 0x0102 -> 1.2
Word BURGER_API Burger::Mac::GetPathFromDirID ( Burger::Filename pOutput,
long  lDirID,
short  sVolRefNum 
) [static]

Convert a Mac DirID and a Volume reference into a Burgerlib path.

Given a 32 bit directory ID and a 16 bit volume number, determine the full Burgerlib pathname that is its equivalent.

What is returned is either NULL for an error condition, pOutput if the user supplied buffer was large enough to contain the requested data or a newly allocated pointer to a larger buffer to hold the requested data.

Note:
If the returned pointer is not the pointer passed in via pOutput, dispose of it with a called to DeallocAPointer(void *) when done.
Parameters:
pOutputPointer to a buffer to accept the output string
lDirID32-bit directory ID supplied by MacOS
sVolRefNum16-bit volume reference number supplied by MacOS
Returns:
Zero if no error, non zero if there was an error
char *BURGER_API Burger::Mac::GetPathFromFileURL ( char *  pOutput,
WordPtr  uOutputSize,
const char *  pInput 
) [static]

Convert a CFURL into a Burgerlib path.

Given a valid MacOSX style CFURL, convert it into a full Burgerlib format pathname and return it.

If the string is not a valid CFURL, it's considered an error condition and the output string will be set to an empty string.

What is returned is either NULL for an error condition, pOutput if the user supplied buffer was large enough to contain the requested data or a newly allocated pointer to a larger buffer to hold the requested data.

Note:
If the returned pointer is not the pointer passed in via pOutput, dispose of it with a called to DeallocAPointer(void *) when done.
Parameters:
pOutputPointer to a user supplied buffer for storing the results, or NULL to force a buffer to be allocated
uOutputSizeLength in bytes of the user supplied buffer or the size of the initial buffer to allocate if pOutput is NULL. if pOutput is NULL and this paramater is zero, this function will determine the optimimum initial buffer size.
pInputPointer to a valid CFURL.
Returns:
A pointer to a "C" string of the Burgerlib path or NULL if an error occurred.
WordPtr BURGER_API Burger::Mac::GetPathFromFileURLToBuffer ( char *  pOutput,
WordPtr  uOutputSize,
const char *  pInput 
) [static]

Convert a CFURL into a Burgerlib path.

Given a valid MacOSX style CFURL, convert it into a full Burgerlib format pathname and return it.

If the string is not a valid CFURL, it's considered an error condition and the function will return zero and leave the output buffer untouched.

Parameters:
pOutputPointer to a buffer to receive the burgerlib path
uOutputSizeSize of the buffer to receive the burgerlib path
pInputPointer to a valid CFURL.
Returns:
Length of the string created. Zero if error or no string is possible.
Note:
A CFURL is a string of the format file://localhost/xxxx/xxxx/xxxx where xxxx/xxxx/xxxx is the actual filename. file://localhost is replaced with the boot volume name in Burgerlib format.
char *BURGER_API Burger::Mac::GetPathFromFSSpec ( char *  pOutput,
WordPtr  uOutputSize,
const FSSpec *  pInput 
) [static]

Convert a MacOS FSSpec into a Burgerlib path.

Given a valid MacOS9 style FSSpec record, determine the full Burgerlib format pathname and return it.

What is returned is either NULL for an error condition, pOutput if the user supplied buffer was large enough to contain the requested data or a newly allocated pointer to a larger buffer to hold the requested data.

Note:
If the returned pointer is not the pointer passed in via pOutput, dispose of it with a called to DeallocAPointer(void *) when done.
Parameters:
pOutputPointer to a user supplied buffer for storing the results, or NULL to force a buffer to be allocated
uOutputSizeLength in bytes of the user supplied buffer or the size of the initial buffer to allocate if pOutput is NULL. if pOutput is NULL and this paramater is zero, this function will determine the optimimum initial buffer size.
pInputPointer to a valid FSSpec.
Returns:
A pointer to a "C" string of the Burgerlib path or NULL if an error occurred.
WordPtr BURGER_API Burger::Mac::GetPathFromFSSpecToBuffer ( char *  pOutput,
WordPtr  uOutputSize,
const FSSpec *  pInput 
) [static]

Convert a MacOS FSSpec into a Burgerlib path.

Given a valid MacOS9 style FSSpec record, determine the full Burgerlib format pathname and return it.

Parameters:
pOutputPointer to a buffer to receive the burgerlib path
uOutputSizeSize of the buffer to receive the burgerlib path
pInputPointer to a valid FSSpec.
Returns:
The number of bytes needed to hold the output (Can be larger than uOutputSize or 0 on error)

Return the version of QuickTime.

Detect if QuickTime is available, and if so, query it for the version present. If QuickTime is not available, the version returned is zero.

This function is written so it only asks for the version once from QuickTime. It will cache the version and return the cached value on subsequent calls.

Returns:
Version in the format of 0x0102 -> 1.2

Return the version of the Sound Manager.

Ask the MacOS Sound Manager what version it is and return that value. The function caches the value so subsequent calls do not ask the Sound Manager for the version again.

Returns:
Version in the format of 0x0102 -> 1.2
Note:
If the sound manager is not installed (Very old mac models), it will return 0.

Detect if Altivec instructions are present.

Detect if the Altivec instruction set is present and return TRUE if so.

This function is written so it only does the detection once and it caches the result. The cached value is returned on subsequent calls.

Returns:
TRUE if Altivec is present, FALSE if not.
Note:
This code always returns FALSE on non-PowerPC targets.
Burger::Mac::IsKeyPressedInKeyMap ( const Word8 pKeyMap,
Word  uKeyCode 
) [inline, static]

Test if a key is pressed in a KeyMap structure.

This MacOS function will take a KeyMap and a MacOS scancode and return a non-zero value if that key is currently held down. Zero is returned if not.

Parameters:
pKeyMapPointer to a KeyMap structure, filled in by GetKeys();
uKeyCodeMac OS keyboard scan code from 0 to 127 inclusive.
Returns:
A non zero value if the key is held down, zero if not.
Note:
This function returns a non-zero value for true. Don't test against TRUE.

Detect if the PowerPC native version of Quicktime is present.

Detect if the PowerPC native extension of Quicktime is loaded and available. This is only for Quicktime version 2.5 during the initial transition from 680x0 to PowerPC. It's almost certainly going to return TRUE on PowerPC systems. Only in very rare cases of Quicktime 2.5 where it's emulated in 680x0 code (And therefore a performance bottleneck) in which this matters.

This function is written so it only does the detection once and it caches the result. The cached value is returned on subsequent calls.

Returns:
TRUE if Quicktime is running in PowerPC code, FALSE if emulated 680x0.
Note:
This code always returns FALSE on non-PowerPC targets.

Detect if a MacOS trap number exists.

Detect if a specific 680x0 trap instruction is present.

Due to the nature of this function, caching in impractical and it is not performed. This function is considered a performance bottleneck and should be called sparingly.

Parameters:
uTrapNumA valid MacOS 680x0 trap number from Traps.h.
Returns:
TRUE if the requested trap index is present, FALSE if not.
Note:
This is a MacOS Classic function. It always returns FALSE on Carbon targets.

Member Data Documentation

TRUE if the AppleShare version is valid

TRUE if DrawSprocket version was obtained

TRUE if InputSprocket version was obtained

Bit field returned by Gestalt(gestaltPowerPCProcessorFeatures)&0x3F. Bit 7 (0x80) denotes if the rest of the bits are valid.

Bit 0 == TRUE if Quicktime's Power plug is loaded. Bit 7 (0x80) denotes bit 0 is valid.

TRUE if Quicktime's version is valid.

TRUE if sound manager version is valid

AppleShare version in 0x0102 (1.2) format.

DrawSprocket version in 0x0102 (1.2) format.

InputSprocket version in 0x0102 (1.2) format.

Cached MacOS Version, zero means uninitialized.

QuickTime's version in 0x0102 (1.2) format.

Sound manager version in 0x0102 (1.2) format.