コード例 #1
0
ファイル: mac.c プロジェクト: pombredanne/Frontier
boolean installgestaltfunction (void) {
	
	Handle hgdef;
	ProcPtr x;
	
	hgdef = GetResource ('GDEF', idgestaltfunction);
	
	if (hgdef == nil) /*didn't find gestalt definition function*/
		return (false);
	
	x = (ProcPtr) *hgdef;
	
	if (NewGestalt (idgestaltselector, x) != noErr) {
		
		if (ReplaceGestalt (idgestaltselector, x, &x) != noErr) {
			
			ReleaseResource (hgdef);
			
			return (false);
			}
		}
	
	DetachResource (hgdef);
	
	return (true);
	} /*installgestaltfunction*/
コード例 #2
0
Handle CreateOpenHandle (OSType theApplicationSignature, short theNumTypes, TypeListPtr theTypeList)
{
	Handle			myHandle = NULL;

	// see if we have an 'open' resource...
	myHandle = Get1Resource('open', 128);
	if ( myHandle != NULL && ResError() == noErr ) {
		DetachResource( myHandle );
		return myHandle;
	} else {
		myHandle = NULL;
	}

	// nope, use the passed in types and dynamically create the NavTypeList
	if (theTypeList == NULL)
		return myHandle;

	if (theNumTypes > 0) {
		myHandle = NewHandle(sizeof(NavTypeList) + (theNumTypes * sizeof(OSType)));
		if (myHandle != NULL) {
			NavTypeListHandle 	myOpenResHandle	= (NavTypeListHandle)myHandle;

			(*myOpenResHandle)->componentSignature = theApplicationSignature;
			(*myOpenResHandle)->osTypeCount = theNumTypes;
			BlockMoveData(theTypeList, (*myOpenResHandle)->osType, theNumTypes * sizeof(OSType));
		}
	}

	return myHandle;
}
コード例 #3
0
ファイル: resinst.c プロジェクト: spippolatore/starcontrol2
SOUND_REF
LoadSoundInstance (DWORD res)
{
	MEM_HANDLE hData;

	hData = GetResource (res);
	if (hData)
		DetachResource (res);

	return ((SOUND_REF)hData);
}
コード例 #4
0
ファイル: resinst.c プロジェクト: spippolatore/starcontrol2
MUSIC_REF
LoadMusicInstance (DWORD res)
{
	MEM_HANDLE hData;

	hData = GetResource (res);
	if (hData)
		DetachResource (res);

	return ((MUSIC_REF)hData);
}
コード例 #5
0
ファイル: Mac-PlugImport.c プロジェクト: mctully/tntbasic
Handle MADGet1Resource( OSType type, short id, MADLibrary* init)
{
	if( init->sysMemory)
	{
		Handle	tH, dH;
		
		tH = Get1Resource( type, id);
		if( tH == NULL) return NULL;
		
		DetachResource( tH);
		HNoPurge( tH);
		
		dH = NewHandle( GetHandleSize( tH));
		if( dH == NULL) MyDebugStr( __LINE__, __FILE__, "");
		if( MemError() != noErr) MyDebugStr( __LINE__, __FILE__, "");
		
		HLock( dH);
		HLock( tH);
		
		BlockMoveData( *tH, *dH, GetHandleSize( tH));
		
		HUnlock( dH);
		HUnlock( tH);
		
		DisposeHandle( tH);
		tH = NULL;
		
		return dH;
	}
	else
	{
		Handle dH = Get1Resource( type, id);
		if( dH == NULL) return NULL;
		
		DetachResource( dH);
		HNoPurge( dH);
		
		return dH;
	}
}
コード例 #6
0
ファイル: tablestructure.c プロジェクト: pombredanne/Frontier
static boolean checktable (hdlhashtable htable, bigstring bs, boolean flcreate, hdlhashtable *hsubtable) {
	
	/*
	locate the table named bs in the htable.  return in hsubtable the table you're 
	looking for.  if flcreate is true we create the table if it doesn't exist.
	
	return false if we couldn't find or create the table.
	
	3/4/91 dmb: if we create a new table, look for a packed hash resource 
	with a matching named, and try to unpack the values
	*/
	
	#ifdef MACVERSION
		Handle hpacked;
	#endif

	register hdlhashtable *ht = hsubtable;
	
	if (findnamedtable (htable, bs, ht)) /*no problem, it exists*/
		goto exit;
	
	*ht = nil;
	
	if (!flcreate)
		return (false);
	
	if (!tablenewsubtable (htable, bs, ht))
		return (false);
	
	#if MACVERSION && !defined (odbengine)
	
	hpacked = filegetresource (filegetapplicationrnum (), 'HASH', 0, bs);
	
	if (hpacked != nil) { /*try unpacking from resource*/
		
		DetachResource (hpacked);
		
		hashunpacktable (hpacked, true, *ht); /*he always disposes of hpackedtable*/
		}
	
	#endif
	
	exit:
	
	#ifdef smartmemory
	
	(***ht).fllocked = true; /*currently only respected by purgetable code in langhash.c*/
	
	#endif
	
	return (true);
	} /*checktable*/
コード例 #7
0
ファイル: IPIconSupport.c プロジェクト: amatubu/iconparty
/* convert IPIcon to IconFamily */
OSErr	IPIconToIconFamily(const IPIconRec *ipIcon,IconFamilyHandle *iconFamily)
{
	OSErr	err=noErr;
	short	curRefNum = CurResFile();
	
	if (ipIcon->iconSuite == NULL)
	{
		UseResFile(gApplRefNum);
		*iconFamily=(IconFamilyHandle)Get1Resource(kXIconClipType,2002);
		DetachResource((Handle)*iconFamily);
		HUnlock((Handle)*iconFamily);
		UseResFile(curRefNum);
	}
	else
	{
		err=IconSuiteToIconFamily(ipIcon->iconSuite,kSelectorMy32Data,iconFamily);
		if (err==memFullErr)
		{
			UseResFile(gApplRefNum);
			*iconFamily=(IconFamilyHandle)Get1Resource(kXIconClipType,2002);
			DetachResource((Handle)*iconFamily);
			HUnlock((Handle)*iconFamily);
			err=noErr;
			UseResFile(curRefNum);
		}
	}
	if (err==noErr && isThumbnailIconsAvailable)
	{
		/* thumbnail */
		if (ipIcon->it32Data != NULL)
			err=SetIconFamilyData(*iconFamily,kThumbnail32BitData,ipIcon->it32Data);
		if (ipIcon->t8mkData != NULL)
			err=SetIconFamilyData(*iconFamily,kThumbnail8BitMask,ipIcon->t8mkData);
	}
	
	return err;
}
コード例 #8
0
ファイル: macstore.c プロジェクト: sdottaka/cvsnt-sjis
/* Copy a resource into the current resource file */
static OSErr copy_resource(ResType restype, short resid)
{
    Handle h;
    Str255 resname;

    h = GetResource(restype, resid);
    if (h != NULL) {
	GetResInfo(h, &resid, &restype, resname);
	DetachResource(h);
	AddResource(h, restype, resid, resname);
	if (ResError() == noErr)
	    WriteResource(h);
    }
    return ResError();
}
コード例 #9
0
ファイル: macros.c プロジェクト: macssh/macssh
// RAB BetterTelnet 2.0b5 - added GetDefaultMacros
// note that we ASSUME the resource fork has new-style macros - don't even think
// about putting the old format there. it would be useless anyway given that the
// purpose of having defaults in the resource fork is to make sure the arrows et al. work
// right from the get-go.
void GetDefaultMacros(void)
{
	Handle resHandle;

	UseResFile(TelInfo->ApplicationFile);
	resHandle = Get1Resource('Mcro', 128);
	UseResFile(TelInfo->SettingsFile);
	if (!resHandle) {		// RAB 2.0b5 - get the blank macros, then
		setupNewMacros(&TelInfo->newMacros); // ignore the error, and let the lusers learn on their own
		return;								// not to use ResEdit unless they know what they're doing :-)
	}
	DetachResource(resHandle);
	HLock(resHandle);
	disposemacros(&TelInfo->newMacros); // we are replacing, not merging
	ParseMacrosFromHandle(&TelInfo->newMacros, resHandle);
}
コード例 #10
0
static ASBool SafeGetIconSuitePart(IconSuiteRef theIconSuite, short theResID, ResType theType)
{
	ASBool foundAnIcon = false;
	
	Handle h = SafeGet1Resource(theType, theResID);
	if (h)
	{
		DetachResource(h);
		
		AddIconToSuite(h, theIconSuite, theType);
		
		foundAnIcon = true;
	}
	
	return foundAnIcon;
}
コード例 #11
0
extern pascal MenuRef GetNewSystemMenu(SInt16 menuResourceID)
	// See comment in interface part.
{
	MenuRef result;
	THz oldZone;
	
	oldZone = SetSystemZone();
	result = GetMenu(menuResourceID);
	if (result != NULL) {
		DetachResource( (Handle) result );
		assert(ResError() == noErr);
		
		assert(ValidateSystemMenuRef(result));
	}
	SetZone(oldZone);
	return result;
}
コード例 #12
0
ファイル: _Resmodule.c プロジェクト: 0xcc/python-read
static PyObject *ResObj_DetachResource(ResourceObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
#ifndef DetachResource
    PyMac_PRECHECK(DetachResource);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    DetachResource(_self->ob_itself);
    {
        OSErr _err = ResError();
        if (_err != noErr) return PyMac_Error(_err);
    }
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
コード例 #13
0
static pascal OSErr DetachIconAction(ResType theType, Handle *theIcon, void *yourDataPtr)
	// GetDetachedIconSuite passes this routine to
	// ForEachIconDo to detach each icon icon in the
	// suite from the resource file from which it came.
{
	assert(theIcon != NULL);
	#pragma unused(theType)
	#pragma unused(yourDataPtr)
	
	if (*theIcon != NULL) {
		DetachResource(*theIcon);

		// Errors from DetachResource probably aren't fatal
		// (it probably means that the icon handle isn't a resource),
		// but we certainly want to know about them.

		assert(ResError() == noErr);
	}
	
	return noErr;
}
コード例 #14
0
OSErr SpriteUtils_AddPICTImageToKeyFrameSample (QTAtomContainer theKeySample, short thePictID, RGBColor *theKeyColor, QTAtomID theID, FixedPoint *theRegistrationPoint, StringPtr theImageName)
{
	PicHandle				myPicture = NULL;
	Handle					myCompressedPicture = NULL;
	ImageDescriptionHandle	myImageDesc = NULL;
	OSErr					myErr = noErr;
	
	// get picture from resource
	myPicture = (PicHandle)GetPicture(thePictID);
	if (myPicture == NULL)
		myErr = resNotFound;

	if (myErr != noErr)
		goto bail;
	
	DetachResource((Handle)myPicture);
	
	// convert it to image data compressed by the animation compressor
	myErr = ICUtils_RecompressPictureWithTransparency(myPicture, theKeyColor, NULL, &myImageDesc, &myCompressedPicture);
	if (myErr != noErr)
		goto bail;

	// add it to the key sample
	HLock(myCompressedPicture);
	myErr = SpriteUtils_AddCompressedImageToKeyFrameSample(theKeySample, myImageDesc, GetHandleSize(myCompressedPicture), *myCompressedPicture, theID, theRegistrationPoint, theImageName);
	
bail:
	if (myPicture != NULL)
		KillPicture(myPicture);
		
	if (myCompressedPicture != NULL)
		DisposeHandle(myCompressedPicture);
		
	if (myImageDesc != NULL)
		DisposeHandle((Handle)myImageDesc);
		
	return(myErr);
}
コード例 #15
0
ファイル: RLDisplayMachO.cpp プロジェクト: mctully/tntbasic
// MT : this is a compatibility routine to do stuff that used to be done in the cfm initialiser of rezlib
static Handle LoadDITL()
{
	//Load the dialog item list for our AskIfNewResolutionWorks() function dialog box
	static Handle		s_ditl=NULL;
	if (!s_ditl)
	{
		//Load our DITL
		s_ditl = Get1Resource( 'DITL', 27398 );
		if( s_ditl )
		{
			DEBUGMESSAGE( "\"AskIfNewResolutionWorks\" DITL loaded." );
			DetachResource( s_ditl );
		}
		else
			DEBUGMESSAGE( "Error: Failed to load DITL." );
		
		OSStatus err = ResError();
		CHECKERR( err );
		if( err )
			DEBUGMESSAGE( "Found Resource Manager error # " << err << " after attempting to load the \"AskIfNewResolutionWorks\" DITL. " );	
	}
	return s_ditl;
}
コード例 #16
0
ファイル: fontda.c プロジェクト: LarBob/executor
OSErr AddToMasterFile(INTEGER from_file_rn, INTEGER master_file_rn)
{
  OSErr err;
  mapping_t mapping;
  INTEGER type_num, type_num_max;
  ResType type;
  Handle h;
  Str255 name;
  BOOLEAN save_resload;

  err = setup_map (from_file_rn, master_file_rn, &mapping);
  if (err == noEErr)
    {
      type_num_max = CountTypesRN (from_file_rn);
      save_resload = ResLoad;
      SetResLoad (false);
      for (type_num = 1; type_num <= type_num_max; ++type_num)
	{
	  GetIndTypeRN (from_file_rn, &type, type_num);
	  res_num_max = CountResourcesRN (from_file_rn, type);
	  for (res_num = 1; res_num <= res_num_max; ++res_num)
	    {
	      h = GetIndResourceRN (from_file_rn, type, res_num);
	      GetResInfo (h, &id, &t, name);
	      if (map_id (&id, from_file_rn, master_file_rn, &mapping))
		{
		  LoadResource(h);
		  DetachResource(h);
		  map_data (h, &mapping);
		  AddResourceRN (master_file_rn, h, type, id, name);
		}
	    }
	}
      SetResLoad (save_resload);
    }
}
コード例 #17
0
ファイル: su_pas.c プロジェクト: binoc-software/mozilla-cvs
OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest)
{
	long 			idIndex;
	
	
	Handle			resToCopy;
	long			handleLength;
	
	PASResource		pasResource;
	long			pasResLen;
	
	OSErr			err;
	
	for (idIndex=0; idIndex < count; idIndex++)
	{
		if( (type == 'SIZE') && ( ids[idIndex] == 1 || ids[idIndex] == 0  ) )
		{
			/* 	
				We do not want to encode/flatten SIZE 0 or 1 because this
				is the resource that the user can modify.  Most applications
				will not be affected if we remove these resources
			*/
		}
		else
		{	
			resToCopy=Get1Resource(type,ids[idIndex]);
					
			if(!resToCopy)	
			{
				return resNotFound;
			}	
				
			memset(&pasResource, 0, sizeof(PASResource));	
				
			GetResInfo(	resToCopy, 	
						&pasResource.attrID, 
						&pasResource.attrType, 
						pasResource.attrName);	
			
			pasResource.attr = GetResAttrs(resToCopy);
			
			DetachResource(resToCopy);	
			HLock(resToCopy);
			
			pasResource.length 	= GetHandleSize(resToCopy);
			handleLength 		= pasResource.length;
			
			pasResLen			=	sizeof(PASResource);
			
			err = FSWrite(dest, &pasResLen, &pasResource);
			
			if(err != noErr) 
			{
				return err;
			}
			
			err = FSWrite(dest, &handleLength, &(**resToCopy));

			if(err != noErr) 
			{
				return err;
			}
			
			HUnlock(resToCopy);
			DisposeHandle(resToCopy);		
		}
	}
	
	
	return noErr;
}
コード例 #18
0
ファイル: vsthost.cpp プロジェクト: Angeldude/pd
// hdll, pluginmain and audiomaster are set here
// must be NULL beforehand!
bool VSTPlugin::NewPlugin(const char *plugname)
{
    FLEXT_ASSERT(!pluginmain && !audiomaster);

    dllname = plugname;

#if FLEXT_OS == FLEXT_OS_WIN
    hdll = LoadLibraryEx(dllname.c_str(),NULL,0 /*DONT_RESOLVE_DLL_REFERENCES*/);
/*
    char buf[255],*c;
    strcpy(buf,dllname.c_str());
    for(c = buf; *c; ++c) 
        if(*c == '/') 
            *c = '\\';
    char *sl = strrchr(buf,'\\');
    if(sl) *sl = 0;
    SetCurrentDirectory(buf);
    hdll = LoadLibrary(dllname.c_str());
*/
    if(hdll) pluginmain = (PVSTMAIN)GetProcAddress(hdll,"main");
    audiomaster = Master;  

#elif FLEXT_OS == FLEXT_OS_MAC

#if 1
	CFStringRef fileNameString = CFStringCreateWithCString(NULL, fileName, kCFStringEncodingUTF8);
	if(fileNameString == 0) goto bail;
	CFURLRef url = CFURLCreateWithFileSystemPath(NULL, fileNameString, kCFURLPOSIXPathStyle, false);
	CFRelease(fileNameString);
	if(url == 0) goto bail;
	hdll = CFBundleCreate(NULL, url);
	CFRelease (url);
	if(hdll && !CFBundleLoadExecutable(hdll)) goto bail;

    PVSTMAIN mainaddr = PluginEntryProc)CFBundleGetFunctionPointerForName(hdll, CFSTR("VSTPluginMain"));
	if(!mainaddr)
		mainaddr = (PluginEntryProc)CFBundleGetFunctionPointerForName(hdll, CFSTR("main_macho"));
#ifdef __CFM__
    pluginmain = (PVSTMAIN)NewMachOFromCFM(mainaddr);
    audiomaster = NewCFMFromMachO(Master);
#else
    pluginmain = (PVSTMAIN)mainaddr;
    audiomaster = Master;
#endif

#else
    short   resFileID;
    FSSpec  spec;
    OSErr err;

    err = FSPathMakeFSSpec(dllname.c_str(),&spec,NULL);
    resFileID = FSpOpenResFile(&spec, fsRdPerm);
    short cResCB = Count1Resources('aEff');

    for(int i = 0; i < cResCB; i++) {
        Handle             codeH;
        CFragConnectionID  connID;
        Ptr                mainAddr;
        Str255             errName;
        Str255             fragName;
        char               fragNameCStr[256];
        short              resID;
        OSType             resType;

        codeH = Get1IndResource('aEff', short(i+1));
        if(!codeH) continue;

        GetResInfo(codeH, &resID, &resType, fragName);
        DetachResource(codeH);
        HLock(codeH);

        err = GetMemFragment(*codeH,
                             GetHandleSize(codeH),
                             fragName,
                             kPrivateCFragCopy,
                             &connID, (Ptr *) & mainAddr, errName);

        if(!err) {
           #ifdef __CFM__
           pluginmain = (PVSTMAIN)NewMachOFromCFM(mainAddr);
           #else
           pluginmain = (PVSTMAIN)mainAddr;
           #endif
        }
    }
    CloseResFile(resFileID);

    audiomaster = 
#ifdef __CFM__
        NewCFMFromMachO(Master);
#else
        Master;
#endif

#endif

#else
#error Platform not supported
#endif    

bail:
    if(pluginmain && audiomaster)
        return true;
    else {
        FreePlugin();
        return false;
    }
}
コード例 #19
0
// will need to read from text file instead
YEARDATAHDL GetYearData(short year)
{
	// IMPORTANT: The calling function should NOT dispose the handle it gets
	YEARDATAHDL		yrHdl=nil;
	short yearMinus1990 = year-1990;
	long i,n,resSize=0;
	
	if(0<= yearMinus1990 && yearMinus1990 <kMAXNUMSAVEDYEARS)
	{
		if(gYearDataHdl1990Plus[yearMinus1990]) return gYearDataHdl1990Plus[yearMinus1990];
	}
	
#ifdef MAC
	Handle r = nil;
	r=GetResource('YEAR',(long)year);
#ifdef SWAP_BINARY	
	resSize = GetMaxResourceSize(r);
	if(resSize > 0 && r) 
	{
		yrHdl = (YEARDATAHDL)_NewHandle(resSize);
		if(yrHdl)
		{
			_HLock(r); // so it can't be purged !!!
			YEARDATAHDL rHdl = (YEARDATAHDL)_NewHandle(resSize);
			DetachResource(r);
			rHdl = (YEARDATAHDL) r;
			// copy and swap the bytes
			n = resSize/sizeof(YEARDATA);
			for(i = 0; i< n; i++)
			{
				YEARDATA yrd  = (YEARDATA)INDEXH(rHdl,i);
				SwapFloat(&yrd.XODE);
				SwapFloat(&yrd.VPU);
				INDEXH(yrHdl,i) = yrd;
			}
			// I don't think we free something gotten from a resource
		}
		ReleaseResource(r);// don't dispose of a resource handle !!!
		r = 0;
	}
#else
	if(r) 
	{
		DetachResource(r);
		yrHdl = (YEARDATAHDL) r;
	}
#endif
#else
	char numStr[32];
	HRSRC hResInfo =0;
	HGLOBAL r = 0;
	sprintf(numStr,"#%ld",year);
	hResInfo = FindResource(hInst,numStr,"YEAR");
	if(hResInfo) 
	{
		// copy the handle so we can be
		// just like the mac
		//
		//also we need to swap the bytes
		//
		// be careful r is a HGLOBAL, not one of our special fake handles
		resSize = SizeofResource(hInst,hResInfo);
		if(resSize > 0) r = LoadResource(hInst,hResInfo);
		if(resSize > 0 && r) 
		{
			yrHdl = (YEARDATAHDL)_NewHandle(resSize);
			if(yrHdl)
			{
				YEARDATAPTR rPtr = (YEARDATAPTR) LockResource(r);
				// copy and swap the bytes
				n = resSize/sizeof(YEARDATA);
				for(i = 0; i< n; i++)
				{
					YEARDATA yrd  = rPtr[i];
					SwapFloat(&yrd.XODE);
					SwapFloat(&yrd.VPU);
					INDEXH(yrHdl,i) = yrd;
				}
				// WIN32 applications do not have to unlock resources locked by LockResource
				// I don't think we free something gotten from a resource
			}
		}
	}
#endif
	
	if(yrHdl && 0<= yearMinus1990 && yearMinus1990 <kMAXNUMSAVEDYEARS)
	{
		gYearDataHdl1990Plus[yearMinus1990] = yrHdl;
	}
	
	return(yrHdl);
}
コード例 #20
0
ファイル: LoadVSTMac.cpp プロジェクト: Kirushanr/audacity
   void LoadVSTPlugins()
   {
#ifdef __MACOSX__
      audioMasterCallback audioMasterFPtr =
         (audioMasterCallback)NewCFMFromMachO(audioMaster);
#else
      // What is the corrct way of creating an audioMasterCallback
      // in OS 9/Carbon???
      // audioMasterCallback audioMasterFPtr = NULL; 
      audioMasterCallback audioMasterFPtr = audioMaster;
#endif      

      wxArrayString audacityPathList = wxGetApp().audacityPathList;
      wxArrayString pathList;
      wxArrayString files;
      unsigned int i;
      
      for(i=0; i<audacityPathList.GetCount(); i++) {
         wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
         wxGetApp().AddUniquePathToPathList(prefix + "VST",
                                            pathList);
         wxGetApp().AddUniquePathToPathList(prefix + "Plugins",
                                            pathList);
         wxGetApp().AddUniquePathToPathList(prefix + "Plug-Ins",
                                            pathList);
      }

      #ifdef __MACOSX__
      wxGetApp().AddUniquePathToPathList("/Library/Audio/Plug-Ins/VST",
                              pathList);
      wxString vstPath;
      vstPath.Printf("/Users/%s/Library/Audio/Plug-Ins/VST",
                     wxGetenv("USER"));
      wxGetApp().AddUniquePathToPathList(vstPath,
                                         pathList);
      #endif

      wxGetApp().FindFilesInPathList("*", pathList, wxFILE, files);
      
      for(i=0; i<files.GetCount(); i++) {
         short   resFileID;
         FSSpec  spec;
         
         wxMacFilename2FSSpec(FILENAME(files[i]), &spec);
         resFileID = FSpOpenResFile(&spec, fsRdPerm);
         short cResCB = Count1Resources('aEff');

         for (int i = 0; i < cResCB; i++) {
            Handle             codeH;
            CFragConnectionID  connID;
            Ptr                mainAddr;
            Str255             errName;
            Str255             fragName;
            char               fragNameCStr[256];
            short              resID;
            OSType             resType;
            OSErr              err;

            codeH = Get1IndResource('aEff', short(i+1));
            if (!codeH)
               continue;

            GetResInfo(codeH, &resID, &resType, fragName);
            DetachResource(codeH);
            HLock(codeH);

            err = GetMemFragment(*codeH,
                                 GetHandleSize(codeH),
                                 fragName,
                                 kPrivateCFragCopy,
                                 &connID, (Ptr *) & mainAddr, errName);

            if (!err) {
               vstPluginMain   pluginMain;
               AEffect        *theEffect;

               #ifdef __MACOSX__
               pluginMain = (vstPluginMain)NewMachOFromCFM(mainAddr);
               #else
               pluginMain = (vstPluginMain)mainAddr;
               #endif

               theEffect = pluginMain(audioMasterFPtr);

               if (theEffect->magic == kEffectMagic) {
                  
                  memcpy(fragNameCStr, &fragName[1], fragName[0]);
                  fragNameCStr[fragName[0]] = 0;
                  
                  VSTEffect *vst =
                     new VSTEffect(wxString(fragNameCStr), theEffect);
                  Effect::RegisterEffect(vst);
               }

               #ifdef __MACOSX__
               DisposeMachOFromCFM(pluginMain);
               #endif
               
               audacityVSTID++;
            }
         }
         
         CloseResFile(resFileID);

      }
         
#ifdef __MACOSX__
      DisposeCFMFromMachO(audioMasterFPtr);
#endif  //   __MACOSX__
   }
コード例 #21
0
ファイル: LicenseWin.c プロジェクト: rn10950/RetroZilla
void
InitLicTxt(void)
{
	Rect	destRect, viewRect;
	FSSpec	licFile;
	long 	dirID, dataSize;
	short 	vRefNum, dataRef, resRef;
	unsigned char* 	cLicFName;
	Str255			pLicFName;
	OSErr	err;
	Handle 	text, stylHdl;
	
	ERR_CHECK(GetCWD(&dirID, &vRefNum));
	
	/* open and read license file */
	HLock(gControls->cfg->licFileName);
	if(**gControls->cfg->licFileName != nil)
	{
		cLicFName = CToPascal(*gControls->cfg->licFileName);
		
		ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, cLicFName, &licFile));
		if (cLicFName)
			DisposePtr((char*)cLicFName);
	}
	else /* assume default license filename from str rsrc */
	{	
		GetResourcedString(pLicFName, rInstList, sLicenseFName);
		ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, pLicFName, &licFile));
	}
	HUnlock(gControls->cfg->licFileName);
	
	/* read license text */
	ERR_CHECK(FSpOpenDF( &licFile, fsRdPerm, &dataRef));
	ERR_CHECK(GetEOF(dataRef, &dataSize));

	if (dataSize > 0)
	{
		if (!(text = NewHandle(dataSize)))
		{
			ErrorHandler(eMem, nil);
			return;
		}
		ERR_CHECK(FSRead(dataRef, &dataSize, *text));
	}
	else
		text = nil;
	ERR_CHECK(FSClose(dataRef));

	/* get 'styl' if license is multistyled */
	resRef = FSpOpenResFile( &licFile, fsRdPerm);
	ERR_CHECK(ResError());

	UseResFile(resRef);
	stylHdl = RGetResource('styl', 128);
	ERR_CHECK(ResError());
	
	if(stylHdl)
		DetachResource(stylHdl);
	else
		stylHdl = nil;
	CloseResFile(resRef);
	
	/* TE specific init */
	HLock( (Handle) gControls->lw->licBox);
	SetRect(&viewRect, 	(*(gControls->lw->licBox))->contrlRect.left, 
						(*(gControls->lw->licBox))->contrlRect.top, 
						(*(gControls->lw->licBox))->contrlRect.right, 
						(*(gControls->lw->licBox))->contrlRect.bottom);
	HUnlock( (Handle) gControls->lw->licBox);

	destRect.left = viewRect.left;
		viewRect.right = (*(gControls->lw->scrollBar))->contrlRect.left; 
	destRect.right = viewRect.right;
	destRect.top = viewRect.top;
	destRect.bottom = viewRect.bottom * kNumLicScrns;
	
	// gControls->lw->licTxt = (TEHandle) NewPtrClear(sizeof(TEPtr));
	
	TextFont(applFont);
	TextFace(normal);
	TextSize(9);
	
	HLock(text);
	if (stylHdl)
	{
		gControls->lw->licTxt = TEStyleNew( &destRect, &viewRect );
		TEStyleInsert( *text, dataSize, (StScrpRec ** )stylHdl, 
						gControls->lw->licTxt);
	}
	else
	{
		gControls->lw->licTxt = TENew( &destRect, &viewRect);
		TEInsert( *text, dataSize, gControls->lw->licTxt);
	}
	HUnlock(text);
	
	TextFont(systemFont);
	TextSize(12);
	
	TESetAlignment(teFlushDefault, gControls->lw->licTxt);
}
コード例 #22
0
void CreateSprites (void)
{
	long				lIndex;
	PicHandle			hpicImage;
	OSErr				nErr;
	RGBColor			rgbcKeyColor;
	
	SetRect(&gDestRects[0], 132, 132, 132 + kSpaceShipWidth, 
		132 + kSpaceShipHeight);
	SetRect(&gDestRects[1], 50, 50, 50 + kSpaceShipWidth, 
		50 + kSpaceShipHeight);
	SetRect(&gDestRects[2], 100, 100, 100 + kSpaceShipWidth, 
		100 + kSpaceShipHeight);
	SetRect(&gDestRects[3], 130, 130, 130 + kSpaceShipWidth, 
		130 + kSpaceShipHeight);

	gDeltas[0].h = -3;
	gDeltas[0].v = 0;
	gDeltas[1].h = -5;
	gDeltas[1].v = 3;
	gDeltas[2].h = 4;
	gDeltas[2].v = -6;
	gDeltas[3].h = 6;
	gDeltas[3].v = 4;
	
	gCurrentImages[0] = 0;
	gCurrentImages[1] = kNumSpaceShipImages / 4;
	gCurrentImages[2] = kNumSpaceShipImages / 2;
	gCurrentImages[3] = kNumSpaceShipImages * 4 / 3;
	
	rgbcKeyColor.red = 0;
	rgbcKeyColor.green = 0;
	rgbcKeyColor.blue = 0;
	
	// recompress PICT images to make them transparent
	for (lIndex = 0; lIndex < kNumSpaceShipImages; lIndex++) 
	{

		hpicImage = (PicHandle)GetPicture(lIndex +
											kFirstSpaceShipPictID);
		DetachResource((Handle)hpicImage);

		nErr = RecompressPictureWithTransparency(hpicImage,
												&rgbcKeyColor, 
												nil,
												&gImageDescriptions[lIndex],
												&gCompressedPictures[lIndex]);
		KillPicture(hpicImage);
	}

	// create the sprites for the sprite world
	for (lIndex = 0; lIndex < kNumSprites; lIndex++) {
		MatrixRecord	matrix;

		SetIdentityMatrix(&matrix);
		
		matrix.matrix[2][0] = ((long)gDestRects[lIndex].left << 16);
		matrix.matrix[2][1] = ((long)gDestRects[lIndex].top << 16);

		nErr = NewSprite(&(gSprites[lIndex]),			/* on return, the ID of the new sprite */
						gSpriteWorld,					/* the sprite world for this sprite */
						gImageDescriptions[lIndex],		/* image description of the spriteÕs image. */
						*gCompressedPictures[lIndex], 	/* sprite image data */
						&matrix,						/* sprite matrix */
						true,							/* is sprite visible? */
						lIndex); 						/* sprite layer */

	}
}
コード例 #23
0
ファイル: LoadVSTMac.cpp プロジェクト: ruthmagnus/audacity
   void LoadVSTPlugins() {
      wxString home = DirManager::GetHomeDir();
      wxString pathChar = DirManager::GetPathChar();
      wxString vstDirPath = home + pathChar + "vst";
      wxString fname;

      fname =
          wxFindFirstFile((const char *) (vstDirPath + pathChar + "*"));

      while (fname != "") {
         short resID;
         FSSpec spec;

         wxMacFilename2FSSpec(fname, &spec);
         resID = FSpOpenResFile(&spec, fsRdPerm);
         Handle codeH;

         int count = Count1Resources('aEff');
         for (int i = 0; i < count; i++) {
            CFragConnectionID connID;
            Ptr mainAddr;
            Str255 errName;
            Str255 fragName;
            char fragNameCStr[256];
            short resID;
            OSType resType;
            OSErr err;

            codeH = Get1IndResource('aEff', count);
            GetResInfo(codeH, &resID, &resType, fragName);
            DetachResource(codeH);
            HLock(codeH);

            err = GetMemFragment(*codeH,
                                 GetHandleSize(codeH),
                                 fragName,
                                 kPrivateCFragCopy,
                                 &connID, (Ptr *) & mainAddr, errName);

            if (err >= 0) {

               Ptr symbolAddress;
               CFragSymbolClass symbolClass;

               err =
                   FindSymbol(connID, "\pmain", &symbolAddress,
                              &symbolClass);
               if (!err) {
                  vstPluginMain pluginMain = (vstPluginMain) symbolAddress;

                  AEffect *theEffect;

                  theEffect = pluginMain(audioMaster);

                  if (theEffect->magic == kEffectMagic) {

                     memcpy(fragNameCStr, &fragName[1], fragName[0]);
                     fragNameCStr[fragName[0]] = 0;

                     VSTEffect *vst =
                         new VSTEffect(wxString(fragNameCStr), theEffect);
                     Effect::RegisterEffect(vst);
                  }
               }
            } else {
               HUnlock(codeH);
            }

            audacityVSTID++;

            // Don't HUnlock unless you don't want to keep it in memory
         }

         CloseResFile(resID);
         fname = wxFindNextFile();
      }
   }