Boolean PrvIsLibOpen(UInt16 refNum) { Boolean isOpen = false; FlickrGlobals* globals = PrvLockGlobals(refNum); if (NULL != globals) { isOpen = true; PrvUnlockGlobals(globals); } return isOpen; }
Err ZDicFontClose(UInt16 refNum, UInt32 clientContext) { ZDicFontGlobalsType * gP; Int16 openCount; Int16 contextCount; Err err = errNone; gP = PrvLockGlobals(refNum); /* If not open, return */ if (!gP) { /* MUST return zero here to get around a bug in system v1.x that * would cause SysLibRemove to fail. */ return errNone; } /* Destroy the client context (we ignore the return code in this implementation) */ PrvDestroyClientContext(gP, clientContext); /* Decrement our library open count */ gP->openCount--; /* Error check for open count underflow */ ErrFatalDisplayIf(gP->openCount < 0, "ZDicFont open count underflow"); /* Save the new open count and the context count */ openCount = gP->openCount; contextCount = gP->contextCount; PrvUnlockGlobals(gP); /* If open count reached zero, free our library globals */ if ( openCount <= 0 ) { /* Error check to make sure that all client contexts were destroyed */ ErrFatalDisplayIf(contextCount != 0, "not all client contexts were destroyed"); /* Free our library globals */ PrvFreeGlobals(refNum); } else { /* return this error code to inform the caller * that others are still using this library */ err = ZDicFontErrStillOpen; } return err; }
static Boolean PrvIsLibOpen(UInt16 refNum) { ZDicFontGlobalsType * gP; Boolean isOpen = false; gP = PrvLockGlobals(refNum); if ( gP ) { isOpen = true; PrvUnlockGlobals(gP); } return( isOpen ); }
Err ZDicFontOpen(UInt16 refNum, UInt32 *clientContextP) { ZDicFontGlobalsType *gP; Err err = errNone; Int16 originalOpenCount = 0; /* Error-check our parameters */ ErrFatalDisplayIf( clientContextP == NULL, "null context variable pointer"); /* Initialize return variable */ *clientContextP = 0; /* Get library globals */ gP = PrvLockGlobals(refNum); /* Check if already open */ if (!gP) { /* Allocate and initialize our library globals. */ gP = PrvMakeGlobals(refNum); if ( !gP ) err = memErrNotEnoughSpace; } /* If we have globals, create a client context, increment open * count, and unlock our globals */ if ( gP ) { originalOpenCount = gP->openCount; err = PrvCreateClientContext(gP, clientContextP); if ( !err ) gP->openCount++; PrvUnlockGlobals(gP); /* If there was an error creating a client context and there */ /* are no other clients, free our globals */ if ( err && (originalOpenCount == 0) ) PrvFreeGlobals(refNum); } return( err ); }
Err FlickrClose(UInt16 refNum) { FlickrGlobals * gP; Int16 openCount; Err err = errNone; DMSG("FlickrClose() enter\n"); gP = PrvLockGlobals(refNum); /* If not open, return */ if (!gP) { /* MUST return zero here to get around a bug in system v1.x that * would cause SysLibRemove to fail. */ return errNone; } /* Decrement our library open count */ gP->openCount--; /* Error check for open count underflow */ ErrFatalDisplayIf(gP->openCount < 0, "InfoMan Flickr Uploader open count underflow"); /* Save the new open count and the context count */ openCount = gP->openCount; PrvUnlockGlobals(gP); /* If open count reached zero, free our library globals */ if ( openCount <= 0 ) { /* Free our library globals */ PrvFreeGlobals(refNum); } else { /* return this error code to inform the caller * that others are still using this library */ err = flickrErrStillOpen; } DMSG("FlickrClose() exit\n"); return err; }
Err FlickrOpen(UInt16 refNum) { FlickrGlobals *gP; Err err = errNone; Int16 originalOpenCount = 0; DMSG("FlickrOpen() enter\n"); /* Get library globals */ gP = PrvLockGlobals(refNum); /* Check if already open */ if (!gP) { /* Allocate and initialize our library globals. */ gP = PrvMakeGlobals(refNum); if ( !gP ) err = memErrNotEnoughSpace; } /* If we have globals, create a client context, increment open * count, and unlock our globals */ if ( gP ) { originalOpenCount = gP->openCount; if ( !err ) gP->openCount++; PrvUnlockGlobals(gP); /* If there was an error creating a client context and there */ /* are no other clients, free our globals */ if ( err && (originalOpenCount == 0) ) PrvFreeGlobals(refNum); } DMSG("FlickrOpen() exit\n"); return err; }