Пример #1
0
static recDevice *HIDBuildDevice (io_object_t hidDevice)
{
	recDevice *pDevice = (recDevice *) NewPtrClear (sizeof (recDevice));
	if (pDevice)
	{
		/* get dictionary for HID properties */
		CFMutableDictionaryRef hidProperties = 0;
		kern_return_t result = IORegistryEntryCreateCFProperties (hidDevice, &hidProperties, kCFAllocatorDefault, kNilOptions);
		if ((result == KERN_SUCCESS) && hidProperties)
		{
			/* create device interface */
			result = HIDCreateOpenDeviceInterface (hidDevice, pDevice);
			if (kIOReturnSuccess == result)
			{
				HIDGetDeviceInfo (hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */
				HIDGetCollectionElements (hidProperties, pDevice);
			}
			else
			{
				DisposePtr((Ptr)pDevice);
				pDevice = NULL;
			}
			CFRelease (hidProperties);
		}
		else
		{
			DisposePtr((Ptr)pDevice);
			pDevice = NULL;
		}
	}
	return pDevice;
}
Пример #2
0
OSErr NetDDPCloseSocket(
    short socketNumber)
{
    OSErr error= noErr;

    if (ddpPacketBuffer)
    {
        MPPPBPtr myMPPPBPtr= (MPPPBPtr) NewPtrClear(sizeof(MPPParamBlock));

        error= MemError();
        if (error==noErr)
        {
            myMPPPBPtr->DDP.socket= socketNumber;

            error= PCloseSkt(myMPPPBPtr, FALSE);

            DisposePtr((Ptr)ddpPacketBuffer);
            ddpPacketBuffer= (DDPPacketBufferPtr) NULL;

            DisposePtr((Ptr)myMPPPBPtr);
        }
    }

    return error;
}
Пример #3
0
int asyncFileClose(AsyncFile *f) {
  /* Close the given asynchronous file. */

	AsyncFileState *state;
	short int volRefNum;
	OSErr err;

	if (!asyncFileValid(f)) return 0;  /* already closed */
	state = f->state;

	err = GetVRefNum(state->refNum, &volRefNum);
	success(err == noErr);

	err = FSClose(state->refNum);
	success(err == noErr);

	if (!interpreterProxy->failed()) err = FlushVol(NULL, volRefNum);
	success(err == noErr);

    if (asyncFileCompletionProc != nil)
        DisposeIOCompletionUPP(asyncFileCompletionProc);
  
	asyncFileCompletionProc = nil;
	if (state->bufferPtr != nil) DisposePtr(state->bufferPtr);
	DisposePtr((void *) f->state);
	f->state = nil;
	f->sessionID = 0;
	return 0;
}
Пример #4
0
/*__________________________________________________________________________*/
Boolean SaveDriverState (short refnum, StringPtr file, OSType creator, OSType type)
{
	FSSpec spec; OSErr err; TDriverInfos dInfos;
	long size, dirID; short vrefNum, ref;
	Ptr ptr;
	
	if (FindMidiShareFolder (true, &vrefNum, &dirID) != noErr) return false;
	if (!MidiGetDriverInfos (refnum, &dInfos)) return false;

	size = Get1DriverStateSize (dInfos.slots);
	if (!size) return true;
	
	ptr = NewPtrSys(size);
	if (!ptr) return false;
		
	Get1DriverState (refnum, dInfos.slots, ptr, size);
	err = FSMakeFSSpec(vrefNum, dirID, file, &spec);
	if (err == fnfErr)
		err = FSpCreate (&spec, creator, type, smSystemScript);
	if (err != noErr) goto err;
		err = FSpOpenDF (&spec, fsWrPerm, &ref);
	if (err != noErr) goto err;
		err = FSWrite (ref, &size, ptr);
	FSClose (ref);
	DisposePtr (ptr);
	return err == noErr;

err:
	DisposePtr (ptr);
	return false;
}
Пример #5
0
Boolean RemoveElement(LinkedList *listPtr,unsigned long num)
{
	ElementHandle	moo=listPtr,last=0L;
	unsigned long	count=0;
	
	while((*moo) && (count!=num))
	{
		count++;
		last=moo;
		moo=(ElementHandle)&((**moo).next);
	}
	
	if (*moo) // if this is 0L then n wasn't in the list
	{
		Ptr		dataPtr=(**moo).data;
		Ptr		entityPtr=(Ptr)*moo;
		
		// got it, delete it
		if (last==0L) // if last==0L then this was the first element in the list
			*listPtr=(ElementPtr)(**moo).next; // the start is the next one (which is null if this was also the last one in the list)
		else
			(**last).next=(**moo).next; // bypass element moo (element n)
		
		// Free up the ram
		DisposePtr(dataPtr);
		DisposePtr(entityPtr);
		return true; // it's gone
	}
	else
		return false;
}
Пример #6
0
OSErr PPMADInfoFile( char	*AlienFile, PPInfoRec	*InfoRec)
{
	MADSpec		*theMAD;
	long			fileSize;
	short			fileID;
	
	theMAD = (MADSpec*) NewPtr( sizeof( MADSpec) + 200);
		
	fileID = iFileOpen( AlienFile);
	if( !fileID)
	{
		DisposePtr( (Ptr) theMAD);
		return -1;
	}
	fileSize = iGetEOF( fileID);
		
	iRead( sizeof( MADSpec), (Ptr) theMAD, fileID);
	iClose( fileID);
		
	strcpy( InfoRec->internalFileName, theMAD->name);
	
	InfoRec->totalPatterns = theMAD->numPat;
	InfoRec->partitionLength = theMAD->numPointers;
	InfoRec->totalTracks = theMAD->numChn;
	InfoRec->signature = 'MADK';
	strcpy( InfoRec->formatDescription, "MADK");
	InfoRec->totalInstruments = theMAD->numInstru;
	InfoRec->fileSize = fileSize;
		
	DisposePtr( (Ptr) theMAD);	
	theMAD = NULL;
		
	return noErr;
}
Пример #7
0
void CleanTemp(void)
{
    OSErr   err = noErr;
    short   vRefNum;
    long    dirID;
    FSSpec  viewerFSp;
    XPISpec *xpiList, *currXPI = 0, *nextXPI = 0;
#ifdef MIW_DEBUG
    Boolean isDir = false;
#endif
    
#ifndef MIW_DEBUG
    /* get "viewer" in "Temporary Items" folder */
    ERR_CHECK(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID));
    err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#else
    /* for DEBUG builds temp is "<currProcessVolume>:Temp NSInstall:" */
    ERR_CHECK(GetCWD(&dirID, &vRefNum));
 	err = FSMakeFSSpec(vRefNum, 0, kTempFolder, &viewerFSp);
	if (err == fnfErr)
	    return; /* no debug temp exists */
	err = FSpGetDirectoryID(&viewerFSp, &dirID, &isDir);
	if (err != noErr || !isDir)
	    return;
    err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#endif
    
    /* whack the viewer folder if it exists */
    if (err == noErr)
    {
        ERR_CHECK(DeleteDirectory(viewerFSp.vRefNum, viewerFSp.parID, viewerFSp.name));
    }
    
    /* clean out the zippies (.xpi's) */
    xpiList = (XPISpec *) NewPtrClear(sizeof(XPISpec));
    if (!xpiList)
        return;
    IterateDirectory(vRefNum, dirID, "\p", 1, CheckIfXPI, (void*)&xpiList);
    
    if (xpiList)
    {
        currXPI = xpiList;
        while(currXPI)
        {
            nextXPI = currXPI->next; /* save nextXPI before we blow away currXPI */
            if (currXPI->FSp)
            {
                FSpDelete(currXPI->FSp);
                DisposePtr((Ptr)currXPI->FSp);
            }
            DisposePtr((Ptr)currXPI);
            currXPI = nextXPI;
        }
    }
}
Пример #8
0
void ottcp_free(OTTCP *x) {
	freeobject(x->o_clock);
	freeobject(x->o_connectedclock);
    if (x->o_tcp_ep != 0) {
		OTCloseProvider(x->o_tcp_ep);
	}
	
	DisposePtr(x->o_ReadBufA);
	DisposePtr(x->o_ReadBufB);
	DisposePtr(x->o_WriteBuf);
}
Пример #9
0
void*
SinkerNew(
	SymbolPtr,
	short		iArgC,
	Atom		iArgV[])
	
	{
	const float kDefVal = 0.0;
	
	short			valCount = (iArgC > 0) ? iArgC : 1;
	objSinker*		me	= NIL;
	tCurPendPair*	vals = (tCurPendPair*) NewPtrClear(valCount * sizeof(tCurPendPair));
	tSampleVector*	inSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
	tSampleVector*	outSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
	
	if (vals == NIL || inSigs == NIL || outSigs == NIL) {
		// Quick punt before any damage can be done
		if (vals != NIL) DisposePtr((Ptr) vals);
		if (inSigs != NIL) DisposePtr((Ptr) inSigs);
		if (outSigs != NIL) DisposePtr((Ptr) outSigs);
		return NIL;	
		}					
	
	// Let Max/MSP allocate us and inlets
	me = (objSinker*) newobject(gObjectClass);
	
	// Add outlets, right to left, and initialize values
	if (iArgC == 0) {
		// Default to two inlets, one outlet
		dsp_setup(&me->coreObject, 2);
		outlet_new(me, "signal");
		// Don't actually need to initialize as long as kDefVal is zero
		// vals[0].current = vals[0].pending = kDefVal;		
		}
	else {
		dsp_setup(&me->coreObject, iArgC + 1);
		while (--iArgC >= 0) {
			outlet_new(me, "signal");
			vals[iArgC].current = vals[iArgC].pending = AtomGetFloat(&iArgV[iArgC]);
			}
		}
	
	// My own initialization. Do this now before we lose the value of iArgCount
	me->lastSync	= 0.0;
	me->valCount	= valCount;
	me->mode		= trigDef;
	me->vals		= vals;
	me->inSigs		= inSigs;
	me->outSigs		= outSigs;
	
punt:
	return me;
	}
Пример #10
0
void
TclMacExitHandler()
{
    ExitToShellUPPListPtr curProc;

    /*
     * Loop through all installed Exit handlers
     * and call them.  Always make sure we are in
     * a clean state in case we are recursivly called.
     */
    if ((gExitToShellData) != NULL && (gExitToShellData->userProcs != NULL)){
    
	/*
	 * Call the installed exit to shell routines.
	 */
	curProc = gExitToShellData->userProcs;
	do {
	    gExitToShellData->userProcs = curProc->nextProc;
	    CallExitToShellProc(curProc->userProc);
	    DisposeExitToShellProc(curProc->userProc);
	    DisposePtr((Ptr) curProc);
	    curProc = gExitToShellData->userProcs;
	} while (curProc != (ExitToShellUPPListPtr) NULL);
    }

    return;
}
Пример #11
0
char * CreateRedefString(char *str, char *ref)
{
    char *newstr;

    int newlen = strlen(str) + 1;
    int reflen;

    // New strings don't have a previous reference, so create new

    if (!ref)
    {
        newstr = NewPtr(strlen(str) + 1);

        // if we could'nt allocate return the old ref

        if (!newstr)
        {
            Error(Error_Fatal, "Could'nt allocate string");
            return ref;
        }

        strcpy(newstr, str);
        return newstr;
    }

    // Must be an existing ref

    reflen = strlen(ref) + 1;		// get the current allocated length

    // Do we have a large enough string already ?

    if (reflen >= newlen)
    {
        // We don't need to reallocate becuase the existing
        // space is big enough

        strcpy(ref, str);
        return ref;
    }

    // ok, we need to reallocate

    newstr = NewPtr(strlen(str) + 1);

    // if we could'nt allocate return the old ref

    if (!newstr)
    {
        Error(Error_Fatal, "Could'nt allocate string");
        return ref;
    }

    strcpy(newstr, str);

    // Delete the old ref

    DisposePtr(ref);

    return newstr;
}
Пример #12
0
/* Do a gamma fade to the color provided over the time period desired	*/
OSStatus FadeToColorMultiple( 	ScreenRef *screens, 
								unsigned int count, 
								const RGBColor *color, 
								float seconds )
{
	RLGammaTable	*newGammas = (RLGammaTable*) NewPtr( count * sizeof( RLGammaTable ) );
	if( NULL == newGammas )
		return rlOutOfMemory;
	
	//Generate new gamma tables from the provided color
	float red = float( color->red ) / 65535.0;
	float green = float( color->green ) / 65535.0;
	float blue = float( color->blue ) / 65535.0;

	for( int i = 0; i < count; i++ )
	{
		for( int j = 0; j < kGammaTableEntryCount; j++ )
		{
			newGammas[i].red[j] = red;
			newGammas[i].green[j] = green;
			newGammas[i].blue[j] = blue;	
		}
	}
	
	OSStatus err = FadeToGammaMultiple( screens, count, newGammas, seconds );

	DisposePtr( (Ptr) newGammas );

	return err;
}
Пример #13
0
ALAPI ALvoid ALAPIENTRY alSourceStop (ALuint source)
{
	QueueEntry *pQE;
	
#ifndef MAC_OS_X
	smSourceFlushAndQuiet(source);
#endif
	
	gSource[source].state = AL_STOPPED;
	gSource[source].readOffset = 0;
        if (gSource[source].pCompHdr != NULL) {
#ifdef MAC_OS_X
            free(gSource[source].pCompHdr);
#else
            DisposePtr(gSource[source].pCompHdr);
#endif
            gSource[source].pCompHdr = NULL;
        }
        gSource[source].uncompressedReadOffset = 0;
#ifdef MAC_OS_X
        gSource[source].uncompressedBufferOffset = 0;
#endif
	
	pQE = gSource[source].ptrQueue; // reset all processed flags
	while (pQE != NULL)
	{
	    gSource[source].srcBufferNum = 0; // will play the null-buffer, then process queue...
	 	pQE->processed = AL_FALSE;
	 	pQE = pQE->pNext;
	}
}
Пример #14
0
OSErr BigSendAppleEvent(TargetID *targ,AEEventClass aeClass,AEEventID aeID,Ptr *data,short dataLen,DescType dataType,Boolean returnData,Boolean checkForHandlerErr)
{
	AEAddressDesc	targDesc={typeNull, nil};	// Desc for target
	AppleEvent		appOut={typeNull, nil},appIn={typeNull, nil};
	short			sendMode=kAENeverInteract;
	OSErr			err;
									
	if (returnData || checkForHandlerErr)
		sendMode+=kAEWaitReply;
	else
		sendMode+=kAENoReply;
									
	// Create the address desriptor
	err=AECreateDesc(typeTargetID,(Ptr)targ,sizeof(TargetID), &targDesc);
	if (err)
		return err;
		
	// now create the apple event which will be sent
	err=AECreateAppleEvent(aeClass,aeID,&targDesc,kAutoGenerateReturnID,kAnyTransactionID,&appOut);	
	if (err)
	{
		AEDisposeDesc(&targDesc);
		return err;
	}
	
	if (data && *data)
	{
		err=AEPutParamPtr(&appOut,keyDirectObject,typeChar,*data,dataLen);
		DisposePtr(*data);
		*data=0L;
		if (err)
		{
			AEDisposeDesc(&appOut);
			AEDisposeDesc(&targDesc);
		}
	}
		
	// Send the apple event	
	err=AESend(&appOut,&appIn,sendMode,kAENormalPriority,kAEDefaultTimeout,0L,0L);		
	if (err)
	{
		AEDisposeDesc(&appOut); 		// get rid of the apple events
		AEDisposeDesc(&appIn);
		AEDisposeDesc(&targDesc);	// and the address descriptor
	}
		
	if (returnData) // get info from reply event
		err=FetchParamAnySize(keyDirectObject,&appIn,data,dataType);
	
	// Get the error returned if any
	if (!err && checkForHandlerErr)
		err=FetchAEErr(&appIn);
	
	// The apple event has been sent, dispose of descriptors
	AEDisposeDesc(&appOut); 		// get rid of the apple events
	AEDisposeDesc(&appIn);
	AEDisposeDesc(&targDesc);	// and the address descriptor
	
	return err;
}
Пример #15
0
ALAPI void alcCloseDevice( ALCdevice *dev )
{
	if (dev != 0)
	{
		DisposePtr((char *)pOpenDevice);
	}
}
Пример #16
0
void NetDDPDisposeFrame(
    DDPFramePtr frame)
{
    DisposePtr((Ptr)frame);

    return;
}
Пример #17
0
/*	KillPopMenus(theDialog)

 	Call when exiting the dialog, before calling DisposeXOPDialog.
 	
 	The menu handles associated with popup controls are automatically deleted
 	by the controls because we use SetControlData(...kControlPopupButtonOwnedMenuRefTag...).
 	However, we need to do some bookkeeping here to keep track of which menu IDs are
 	free for use in popup menus. This bookkeeping is complicated by the possibility
 	of subdialogs.

	Thread Safety: KillPopMenus is not thread-safe.
*/
void
KillPopMenus(DialogPtr theDialog)
{
	int i;
	
	if (gPopMenuInfoP == NULL)
		return;								// Would happen if you did not create any popup menus.
	
	// Mark menu IDs used for this dialog as free so they can be reused for another dialog.
	for(i=0; i<MAX_POPUP_MENUS; i++) {
		if (gPopMenuInfoP[i].theDialog == theDialog) {	// This is the dialog for which the menu was created?
			gPopMenuInfoP[i].theDialog = NULL;
			gPopMenuInfoP[i].menuID = 0;
		}
	}

	/*	Now see if gPopMenuInfoP is no longer needed. If we just disposed a subdialog,
		it is still needed for the parent dialog.
	*/
	{
		int infoStillNeeded;
		infoStillNeeded = 0;
		for(i=0; i<MAX_POPUP_MENUS; i++) {
			if (gPopMenuInfoP[i].menuID != 0) {
				infoStillNeeded = 1;
				break;		
			}
		}
		if (!infoStillNeeded) {
			DisposePtr((Ptr)gPopMenuInfoP);
			gPopMenuInfoP = NULL;
		}
	}
}
Пример #18
0
static recDevice *
HIDDisposeDevice(recDevice ** ppDevice)
{
    kern_return_t result = KERN_SUCCESS;
    recDevice *pDeviceNext = NULL;
    if (*ppDevice) {
        /* save next device prior to disposing of this device */
        pDeviceNext = (*ppDevice)->pNext;

        /* free posible io_service_t */
        if ((*ppDevice)->ffservice) {
            IOObjectRelease((*ppDevice)->ffservice);
            (*ppDevice)->ffservice = 0;
        }

        /* free element lists */
        HIDDisposeElementList(&(*ppDevice)->firstAxis);
        HIDDisposeElementList(&(*ppDevice)->firstButton);
        HIDDisposeElementList(&(*ppDevice)->firstHat);

        result = HIDCloseReleaseInterface(*ppDevice);   /* function sanity checks interface value (now application does not own device) */
        if (kIOReturnSuccess != result)
            HIDReportErrorNum
                ("HIDCloseReleaseInterface failed when trying to dipose device.",
                 result);
        DisposePtr((Ptr) * ppDevice);
        *ppDevice = NULL;
    }
    return pDeviceNext;
}
Пример #19
0
static pascal void
ExitToShellPatchRoutine()
{
    ExitToShellUPP oldETS;
    long oldA5;

    /*
     * Set up our A5 world.  This allows us to have
     * access to our global variables in the 68k world.
     */
    oldA5 = SetCurrentA5();
    SetA5(gExitToShellData->a5);

    /*
     * Call the function that invokes all
     * of the handlers.
     */
    TclMacExitHandler();

    /*
     * Call the origional ExitToShell routine.
     */
    oldETS = gExitToShellData->oldProc;
    DisposePtr((Ptr) gExitToShellData);
    SetA5(oldA5);
    CallExitToShellProc(oldETS);
    return;
}
Пример #20
0
void __cdecl _heap_free_region (
	REG1 int index
	)
{
	struct _heap_region_ *pHeapRegions;

	/*
	 * Give the memory back to the OS
	 */

	pHeapRegions = (struct _heap_region_ *)(*hHeapRegions);
	if ((pHeapRegions + index)->_regbase)
		{
		DisposePtr((pHeapRegions + index)->_regbaseCopy);
		}

	/*
	 * Zero out the heap region entry
	 */

	pHeapRegions = (struct _heap_region_ *)(*hHeapRegions);
	(pHeapRegions + index)->_regbase = NULL;
	(pHeapRegions + index)->_currsize = 0;
	(pHeapRegions + index)->_totalsize = 0;

}
Пример #21
0
// --------------------------------------------------------------------------------------
static OSErr getCurrentResourceFSSpec(FSSpec *curResSpec)
{
	OSErr error;
	FCBPBPtr fileInfo;		// file control block parameter block pointer
	StrFileName fileName;
	
		/* In the age of application packages and bundles, it's less likely that the 
		   current resource file is the application file itself.  It's more likely to be 
		   a flattened resource file in a bundle so we need a generic method instead of 
		   the traditional Process Manager method of getting the current application's 
		   FSSpec of it's executable file */
	fileInfo = (FCBPBPtr)NewPtr(sizeof(FCBPBRec));
	
	fileInfo->ioNamePtr = fileName;		// to hold the resource file's name
	fileInfo->ioVRefNum = 0;			// 0 to search through all open files on all volumes
	fileInfo->ioRefNum = CurResFile();	// get info about the main resource file 
										// by using its reference number
	fileInfo->ioFCBIndx = 0;			// 0 to ignore this parameter and use the 
										// ioRefNum parameter instead
	
	error = PBGetFCBInfoSync(fileInfo);	// synchronous because we don't have 
						// anything else to do while we're waiting on the filesystem
	
	if (error == noErr)		// if we got the necessary file info, make an FSSpec out of it
		FSMakeFSSpec(fileInfo->ioFCBVRefNum, fileInfo->ioFCBParID, fileName, curResSpec);
						
	DisposePtr((Ptr)fileInfo);
	
	return error;
}
Пример #22
0
void QTDR_CloseDownHandlers (void)
{
	if (gDataReader != NULL) {
		DataHCloseForRead(gDataReader);
		CloseComponent(gDataReader);
		gDataReader = NULL;
	}

	if (gDataWriter != NULL) {
		DataHCloseForWrite(gDataWriter);
		CloseComponent(gDataWriter);
		gDataWriter = NULL;
	}
	
	// dispose of the data buffer
	if (gDataBuffer != NULL)
		DisposePtr(gDataBuffer);
		
	// dispose of the routine descriptors
	if (gReadDataHCompletionUPP != NULL)
		DisposeDataHCompletionUPP(gReadDataHCompletionUPP);
		
	if (gWriteDataHCompletionUPP != NULL)
		DisposeDataHCompletionUPP(gWriteDataHCompletionUPP);
	
	gDoneTransferring = false;
	
#if TARGET_OS_WIN32
	// kill the timer that tasks the data handlers
	KillTimer(NULL, gTimerID);
#endif
}
Пример #23
0
OSErr grow_buffer(Theora_Globals glob, UInt32 min_size) {
    /* increase the size of the packet buffer, in
       kPacketBufferAllocIncrement blocks, preserving the content of
       the used part of the buffer */
    OSErr err = noErr;
    UInt32 new_size = glob->p_buffer_len;

    dbg_printf("--:Theora:-  _grow_buffer(%08lx, %ld)\n", (long)glob, min_size);

    while (new_size < min_size)
        new_size += kPacketBufferAllocIncrement;

    /* first try to resize in-place */
    SetPtrSize((Ptr) glob->p_buffer, new_size);

    if (err = MemError()) {
        /* resizing failed: allocate new block, memcpy, release the old block */
        Ptr p = NewPtr(new_size);
        if (err = MemError()) goto bail;

        BlockMoveData(glob->p_buffer, p, glob->p_buffer_used);

        DisposePtr((Ptr) glob->p_buffer);
        glob->p_buffer = (UInt8 *) p;
    }

    glob->p_buffer_len = new_size;

 bail:
    if (err)
        dbg_printf("--:Theora:-  _grow_buffer(%08lx, %ld) failed = %d\n", (long)glob, min_size, err);

    return err;
}
Пример #24
0
pascal OSErr MoreFESetComment(const FSSpecPtr pFSSpecPtr, const Str255 pCommentStr, const AEIdleUPP pIdleProcUPP){
	AppleEvent tAppleEvent = {
		typeNull, nil
	};                                              // If you always init AEDescs, it's always safe to dispose of them.
	AEBuildError tAEBuildError;
	AEDesc tAEDesc = {
		typeNull, nil
	};
	OSErr anErr = noErr;

	anErr = MoreAEOCreateObjSpecifierFromFSSpec(pFSSpecPtr, &tAEDesc);
	if (noErr == anErr) {
		char *dataPtr = NewPtr(pCommentStr[ 0 ]);

		CopyPascalStringToC(pCommentStr, dataPtr);
		anErr = AEBuildAppleEvent(
		        kAECoreSuite, kAESetData,
		        typeApplSignature, &gFinderSignature, sizeof( OSType ),
		        kAutoGenerateReturnID, kAnyTransactionID,
		        &tAppleEvent, &tAEBuildError,
		        "'----':obj {form:prop,want:type(prop),seld:type(comt),from:(@)},data:'TEXT'(@)",
		        &tAEDesc, dataPtr);

		DisposePtr(dataPtr);

		if (noErr == anErr) {
			// Send the event. In this case we don't care about the reply
			anErr = MoreAESendEventNoReturnValue(pIdleProcUPP, &tAppleEvent);
			(void) MoreAEDisposeDesc(&tAppleEvent); // always dispose of AEDescs when you are finished with them
		}
	}
	return anErr;
}
Пример #25
0
pascal OSErr MoreAEGetCFStringFromDescriptor(const AEDesc* pAEDesc, CFStringRef* pCFStringRef)
{
  AEDesc    uniAEDesc = {typeNull, NULL};
  OSErr    anErr;

  if (NULL == pCFStringRef)
    return paramErr;

  anErr = AECoerceDesc(pAEDesc, typeUnicodeText, &uniAEDesc);
  if (noErr == anErr)
  {
    if (typeUnicodeText == uniAEDesc.descriptorType)
    {
          Size bufSize = AEGetDescDataSize(&uniAEDesc);
          Ptr buf = NewPtr(bufSize);

          if ((noErr == (anErr = MemError())) && (NULL != buf))
          {
              anErr = AEGetDescData(&uniAEDesc, buf, bufSize);
              if (noErr == anErr)
                  *pCFStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, (UniChar*) buf, bufSize / (Size) sizeof(UniChar));

              DisposePtr(buf);
          }
    }
    MoreAEDisposeDesc(&uniAEDesc);
  }
  return (anErr);
}//end MoreAEGetCFStringFromDescriptor
Пример #26
0
// Removes a ListElement from the end of the list, copying data if wanted
Boolean RemoveLastElement(LinkedList *listPtr)
{
	ElementHandle	moo=listPtr; // address of linked list

	if (!*moo) // if the list is empty
		return false;
	
	while((**moo).next) // go through list until found second to last element
		moo=(ElementHandle)&((**moo).next);
		
	DisposePtr((**moo).data);
	DisposePtr((Ptr)*moo);
	*moo=0L;
	
	return true;
}
Пример #27
0
boolean openabout (boolean flzoom, long ctreservebytes) {
	
	/*
	2.1b5 dmb: added ctreservebytes parameter. of non-zero, caller wants us to 
	reserve space in the heap below the dialog record (during initialization)
	*/
	
	hdlwindowinfo hinfo;
	
#ifdef MACVERSION
	Ptr ptemp = nil;
	
	if (ctreservebytes > 0)
		ptemp = NewPtr (ctreservebytes); /*force about window to load high*/
#endif

	aboutstart ();
	
	shellpatchnilroutines ();
	
//	aboutwindow = newmodaldialog (128, -1);
	newaboutwindow (true);
	
	if (findaboutwindow (&hinfo))
		shellupdatenow ((**hinfo).macwindow);
	
#ifdef MACVERSION
	if (ptemp != nil)
		DisposePtr (ptemp); /*restore heap space for remaining code segments*/
#endif
	
	aboutopenticks = gettickcount ();
	
	return (true);
	} /*openabout*/
Пример #28
0
OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
{
	OSErr 		err;	
	short		inRefNum;
	Ptr 		buffer;
	SInt32 		currentRead = 	PAS_BUFFER_SIZE;
		
	buffer	=	NewPtr(currentRead);

	err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
	if (err != noErr)	return err;
	
	while ( currentRead > 0 )
    {
		err	= FSRead( inRefNum, &currentRead, buffer);
		if (err != noErr && err != eofErr)	return err;
		
		err = FSWrite(outRefNum, &currentRead, buffer);
		if (err != noErr)	return err;
	}
	
	FSClose(inRefNum);
	
	DisposePtr(buffer);
	
	return noErr;
}
Пример #29
0
int sqCopyFilesizetosize(char *srcNameIndex, int srcNameSize, char *dstNameIndex, int dstNameSize) {

	OSErr error;
	FSSpec	srcSpec,dstFileSpec,dstSpec;
	char *pointer;
	const int desiredBufferSize = 64*1024;

	FSpLocationFromFullPath(srcNameSize,srcNameIndex,&srcSpec);
	FSpLocationFromFullPath(dstNameSize,dstNameIndex,&dstFileSpec);
	FSMakeFSSpecCompat(dstFileSpec.vRefNum, dstFileSpec.parID, "\p:", &dstSpec);
#if TARGET_API_MAC_CARBON
		pointer = NewPtr(desiredBufferSize);
#else
	    pointer = NewPtr(desiredBufferSize);
	    if (pointer == NULL) 
		    pointer = NewPtrSys(desiredBufferSize);
	    if (pointer == NULL) 
  			return false;
 #endif
	error = FSpFileCopy(&srcSpec,
						&dstSpec,
						dstFileSpec.name,
						pointer,
						desiredBufferSize,
						false);
	DisposePtr((void *)pointer);
	return error;
} 
Пример #30
0
OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
{
	OSErr 			err;	
	short			inRefNum;
	PASResFork		resInfo;
	SInt32			currentWrite;
	
	ResType 		*resTypes;
	long			typeCount;
	
	short			*ids;
	long			idCount;
	
	short			oldResFile;
	
	oldResFile=CurResFile();
	inRefNum = FSpOpenResFile(inFile, fsRdPerm);
	if (inRefNum < noErr)	return inRefNum;

	UseResFile(inRefNum);
		
	memset(&resInfo, 0, sizeof(PASResFork));   
	
	PAS_sortTypes(inRefNum, &resTypes, &typeCount);

	resInfo.NumberOfTypes	=	typeCount;
	
	currentWrite	= sizeof(PASResFork);
	
	err = FSWrite(outRefNum, &currentWrite, &resInfo);
	if (err != noErr)	return err;
	
	for (typeCount = 0; ((typeCount < resInfo.NumberOfTypes) && (err == noErr)); typeCount++)
	{
		PAS_sortIDs(inRefNum, resTypes[typeCount], &ids, &idCount);
		err = PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
		DisposePtr((Ptr)ids);
	}
	
	DisposePtr((Ptr)resTypes);
	
	
	UseResFile(oldResFile);		
	CloseResFile(inRefNum);
	
	return err;
}