Ejemplo n.º 1
0
FlickrGlobals* PrvLockGlobals(UInt16 refNum)
{
    SysLibTblEntryType* libEntry = SysLibTblEntry(refNum);
    ErrFatalDisplayIf(libEntry == NULL, "invalid InfoMan Flickr Uploader refNum");

    MemHandle handle = (MemHandle)libEntry->globalsP;
    if (NULL == handle)
        return NULL;

    return (FlickrGlobals*)MemHandleLock(handle);
}
Ejemplo n.º 2
0
static ZDicFontGlobalsType * PrvLockGlobals(UInt16 refNum)
{
	ZDicFontGlobalsType * gP = NULL;
	MemHandle gH;
	SysLibTblEntryType * libEntryP;

	libEntryP = SysLibTblEntry(refNum);
	if ( libEntryP )
		gH = (MemHandle)(libEntryP->globalsP);
	if ( gH )
		gP = (ZDicFontGlobalsType *)MemHandleLock(gH);

	return( gP );
}
Ejemplo n.º 3
0
void PrvFreeGlobals(UInt16 refNum)
{
    SysLibTblEntryType* libEntry = SysLibTblEntry(refNum);
    ErrFatalDisplayIf(libEntry == NULL, "invalid InfoMan Flickr Uploader refNum");
    MemHandle handle = (MemHandle)libEntry->globalsP;
    if (NULL != handle)
    {
        FlickrGlobals* globals = (FlickrGlobals*)MemHandleLock(handle);
        if (NULL != globals)
        {
            globals->Dispose();
            MemPtrUnlock(globals);
        }
        libEntry->globalsP = NULL;
        MemHandleFree(handle);
    }
}
Ejemplo n.º 4
0
static ZDicFontGlobalsType * PrvMakeGlobals(UInt16 refNum)
{
	ZDicFontGlobalsType * gP = NULL;
	MemHandle gH;
	SysLibTblEntryType * libEntryP;

	/* Get library globals */
	libEntryP = SysLibTblEntry(refNum);
	ErrFatalDisplayIf(libEntryP == NULL, "invalid ZDicFont refNum");

	/* Error check to make sure the globals don't already exist */
	ErrFatalDisplayIf(libEntryP->globalsP, "ZDicFont globals already exist");

	/* Allocate and initialize our library globals. */
	gH = MemHandleNew(sizeof(ZDicFontGlobalsType));
	if ( !gH )
		return( NULL );

	/* Save the handle of our library globals in the system library table  */
	/* entry so we can later retrieve it using SysLibTblEntry(). */
	libEntryP->globalsP = (void*)gH;

	/* Lock our globals (should not fail) */
	gP = PrvLockGlobals(refNum);
	ErrFatalDisplayIf(gP == NULL, "failed to lock ZDicFont globals");

	/* Set the owner of our globals memory chunk to "system" (zero), so it won't get
	 * freed automatically by Memory Manager when the first application to call
	 * ZDicFontOpen exits.  This is important if the library is going to stay open
	 * between apps. */
	MemPtrSetOwner(gP, 0);

	/* Initialize our library globals */
	MemSet(gP, sizeof(ZDicFontGlobalsType), 0);

	/* for convenience and debugging, save ref in globals structure */
	gP->thisLibRefNum = refNum;

	/* initial open count */
	gP->openCount = 0;

	/* return a pointer to our *locked* globals */
	return( gP );
}
Ejemplo n.º 5
0
static void PrvFreeGlobals(UInt16 refNum)
{
	MemHandle gH;
	SysLibTblEntryType * libEntryP;

	/* Get our library globals handle */
	libEntryP = SysLibTblEntry(refNum);
	ErrFatalDisplayIf(libEntryP == NULL, "invalid ZDicFont refNum");

	gH = (MemHandle)(libEntryP->globalsP);

	/* Free our library globals */
	if ( gH )
	{
		/* clear our globals reference */
		libEntryP->globalsP = NULL;

		/* free our globals */
		MemHandleFree(gH);
	}
}
Ejemplo n.º 6
0
/*
 * FUNCTION: PrvMakeGlobals
 *
 * DESCRIPTION: Create our library globals.
 *
 * PARAMETERS:
 *
 * refNum
 *		Library reference number returned by SysLibLoad() or SysLibFind().
 *
 * CALLED BY: internal
 *
 * RETURNS:
 *
 *		pointer to our *locked* library globals
 *		NULL if our globals	could not be created.
 */
FlickrGlobals* PrvMakeGlobals(UInt16 refNum)
{
    SysLibTblEntryType* libEntry = SysLibTblEntry(refNum);
    ErrFatalDisplayIf(libEntry == NULL, "invalid InfoMan Flickr Uploader refNum");

    /* Error check to make sure the globals don't already exist */
    ErrFatalDisplayIf(libEntry->globalsP != NULL, "InfoMan Flickr Uploader globals already exist");

    /* Allocate and initialize our library globals. */
    MemHandle handle = MemHandleNew(sizeof(FlickrGlobals));
    if (NULL == handle)
        return NULL;

    FlickrGlobals* globals = (FlickrGlobals*)MemHandleLock(handle);
    if (NULL == globals)
    {
        MemHandleFree(handle);
        return NULL;
    }

    Err err = globals->Init(refNum);
    if (errNone != err)
    {
        MemPtrUnlock(globals);
        MemHandleFree(handle);
        return NULL;
    }

    /* Set the owner of our globals memory chunk to "system" (zero), so it won't get
     * freed automatically by Memory Manager when the first application to call
     * FlickrOpen exits.  This is important if the library is going to stay open
     * between apps. */
    MemPtrSetOwner(globals, 0);
    libEntry->globalsP = (MemPtr)handle;
    return globals;
}