Exemplo n.º 1
0
char *__PHYSFS_platformGetUserName(void)
{
    char *retval = NULL;
    StringHandle strHandle;
    short origResourceFile = CurResFile();

    /* use the System resource file. */
    UseResFile(0);
    /* apparently, -16096 specifies the username. */
    strHandle = GetString(-16096);
    UseResFile(origResourceFile);
    BAIL_IF_MACRO(strHandle == NULL, NULL, NULL);

    HLock((Handle) strHandle);
    retval = (char *) malloc((*strHandle)[0] + 1);
    if (retval == NULL)
    {
        HUnlock((Handle) strHandle);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
    } /* if */
    memcpy(retval, &(*strHandle)[1], (*strHandle)[0]);
    retval[(*strHandle)[0]] = '\0';  /* null-terminate it. */
    HUnlock((Handle) strHandle);

    return(retval);
} /* __PHYSFS_platformGetUserName */
Exemplo n.º 2
0
void CAUGuiGraphic::loadImagePNG ( char* pngFileName )
{
	
	CFBundleRef bundleRef = CFBundleGetBundleWithIdentifier(CFSTR( AU_BUNDLE_IDENTIFIER ));
	CGDataProviderRef	provider;
	
	if ( bundleRef )
	{
		SInt16 tmp = CurResFile();
	
		CFStringRef fileName = ::CFStringCreateWithCString( NULL, pngFileName, kCFStringEncodingASCII );
		if ( fileName != NULL )
		{
			CFURLRef url = ::CFBundleCopyResourceURL( bundleRef, fileName, NULL, NULL );
			
			provider = CGDataProviderCreateWithURL( url );

			Image = CGImageCreateWithPNGDataProvider( provider, NULL, false,  kCGRenderingIntentDefault );
			
			CGDataProviderRelease( provider );
			CFRelease( url );
			CFRelease( fileName );
		}
		else
		{
			Image = NULL;
		}
		
		 UseResFile(tmp);
	}
	
}
extern void main(void)
{
    OSStatus err;
    FCBPBRec fcbPB;
    FSSpec fss;

    // 1. Show our "icon march" icon
    ShowInitIcon(128, true);

    // 2. Find our FSSpec
    fss.name[0] = 0;
    fcbPB.ioNamePtr = fss.name;
    fcbPB.ioVRefNum = 0;
    fcbPB.ioRefNum = (short)CurResFile();
    fcbPB.ioFCBIndx = 0;
    err = PBGetFCBInfoSync(&fcbPB);

    // 3. Tell CFM that we're a CFM library container file
    fss.vRefNum = fcbPB.ioFCBVRefNum;
    fss.parID = fcbPB.ioFCBParID;
    if (err == noErr) err = FragRegisterFileLibs(&fss, false);

    // 4. Now that CFM knows we're a library container, tell it to go and get our library
    if (err == noErr)
    {
        CFragConnectionID c;
        Ptr m;
        Str255 e;
        THz oldZone = GetZone();
        SetZone(SystemZone());
        err = GetSharedLibrary("\pDarwin;mDNS", kPowerPCCFragArch, kLoadCFrag, &c, &m, e);
        SetZone(oldZone);
    }
Exemplo n.º 4
0
bool NetscapePluginModule::tryLoad()
{
    m_module = std::make_unique<Module>(m_pluginPath);
    if (!m_module->load())
        return false;

    NP_InitializeFuncPtr initializeFuncPtr = m_module->functionPointer<NP_InitializeFuncPtr>("NP_Initialize");
    if (!initializeFuncPtr)
        return false;

#if !PLUGIN_ARCHITECTURE(X11)
    NP_GetEntryPointsFuncPtr getEntryPointsFuncPtr = m_module->functionPointer<NP_GetEntryPointsFuncPtr>("NP_GetEntryPoints");
    if (!getEntryPointsFuncPtr)
        return false;
#endif

    m_shutdownProcPtr = m_module->functionPointer<NPP_ShutdownProcPtr>("NP_Shutdown");
    if (!m_shutdownProcPtr)
        return false;

    m_pluginFuncs.size = sizeof(NPPluginFuncs);
    m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;

    // On Mac, NP_Initialize must be called first, then NP_GetEntryPoints. On Windows, the order is
    // reversed. Failing to follow this order results in crashes (e.g., in Silverlight on Mac and
    // in Flash and QuickTime on Windows).
#if PLUGIN_ARCHITECTURE(MAC)
#ifndef NP_NO_CARBON

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

    // Plugins (at least QT) require that you call UseResFile on the resource file before loading it.
    ResFileRefNum currentResourceFile = CurResFile();
    
    ResFileRefNum pluginResourceFile = m_module->bundleResourceMap();
    UseResFile(pluginResourceFile);

#endif
    bool result = initializeFuncPtr(netscapeBrowserFuncs()) == NPERR_NO_ERROR && getEntryPointsFuncPtr(&m_pluginFuncs) == NPERR_NO_ERROR;

#ifndef NP_NO_CARBON
    // Restore the resource file.
    UseResFile(currentResourceFile);

#pragma clang diagnostic pop

#endif

    return result;
#elif PLUGIN_ARCHITECTURE(WIN)
    if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR)
        return false;
#elif PLUGIN_ARCHITECTURE(X11)
    if (initializeFuncPtr(netscapeBrowserFuncs(), &m_pluginFuncs) != NPERR_NO_ERROR)
        return false;
#endif

    return true;
}
Exemplo n.º 5
0
void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count)
{
	short				oldRef;
	short				typeIndex;
	short				numberOfTypes;
		
	*count	=	-1;
	
	oldRef = CurResFile();
		
	UseResFile(sourceRefNum);

	numberOfTypes = Count1Types();
	
	*resTypePtr	=	(ResType*) NewPtrClear( numberOfTypes * sizeof(OSType) );
	
	for (typeIndex=1; typeIndex <= numberOfTypes; typeIndex++)
	{
		Get1IndType(&(*resTypePtr)[typeIndex-1], typeIndex);
	}
	
	UseResFile(oldRef);
	
	PAS_bubbleSortResType(*resTypePtr, numberOfTypes);
	
	*count = numberOfTypes;
}	
// --------------------------------------------------------------------------------------
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;
}
Exemplo n.º 7
0
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count)
{
	short				oldRef;
	Handle				theHandle;
	short				resCount;
	short				resIndex;
	
	*count	=	-1;
	
	oldRef = CurResFile();
		
	UseResFile(sourceRefNum);

	resCount = Count1Resources(theType);
	
	*IdPtr	=	(short*) NewPtrClear( resCount * sizeof(short) );
	
	for (resIndex=1; resIndex <= resCount; resIndex++)
	{
		theHandle = Get1IndResource(theType, resIndex);
		
		if(theHandle == NULL) return;
	
		(*IdPtr)[resIndex-1] = PAS_getResourceID(theHandle);
		
		ReleaseResource(theHandle);
	}
	
	UseResFile(oldRef);
	
	PAS_bubbleSortIDS(*IdPtr, resCount);
	
	
	*count = resCount;
}
Exemplo n.º 8
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Name:	MyPDEInitialize

	Input Parameters:
		context				:	The plugins context
		parentUserPane		:	the user pane to your your controls into
		ref					:	the reference to this PDE
		printSession		:	this holds the PM tickets

	Output Parameters:
		flags				:	feature flags that are supported by this PDE
		err					:	returns the error status

	Description:
		Initializes client interface. Creates controls and sets initial values



	Change History (most recent first):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static
OSStatus MyPDEInitialize(	PMPDEContext	context,
                            PMPDEFlags*		flags,
                            PMPDERef		ref,
                            ControlRef		parentUserPane,
                            PMPrintSession	printSession)
{
    OSStatus err = noErr;
    PrintDialogPDEOnlyContextPtr myContext = NULL;	// Pointer to our context data.

    DebugMessage("PrintDialogPDE MyPDEInitialize called\n");

    myContext = (PrintDialogPDEOnlyContextPtr) context;

    if ((myContext != NULL) && (printSession != NULL))
    {
        WindowRef theWindow = NULL;
        short savedResFile = CurResFile();
        UseResFile(myContext->theResFile);
        theWindow = GetControlOwner(parentUserPane);	// get the windowref from the user pane

        // the user panes rect is the rect we should use to draw our
        // controls into. The printing system calculates the user pane
        // size based on the maxh and maxv sizes returned from the
        // Prologue function

        // Note that we are using the AutoToggleProc variant of the Radio Button control
        // This allows a hit on this control to be automatically processed by the ControlMgr

        // get controls
        myContext->thePrintSelTextOnlyControlRef = GetNewControl(kPrintDialogPDEControlID, theWindow);

        // embed controls
        EmbedControl(myContext->thePrintSelTextOnlyControlRef, parentUserPane);

        // set controls as visible
        SetControlVisibility(myContext->thePrintSelTextOnlyControlRef, true, false);

        // Set default value
        SetControlValue(myContext->thePrintSelTextOnlyControlRef, 0);

        // Set flags
        *flags = kPMPDENoFlags;

        // Initialize this plugins controls based on the information in the
        // PageSetup or PrintSettings ticket.
        err = MyPDESync(context, printSession, kSyncDirectionSetUserInterface);
        if (err == kPMKeyNotFound)
            err = noErr;

        UseResFile(savedResFile);
    }
    else
        err = kPMInvalidPDEContext;

    DebugPrintErr(err, "PrintDialogPDE Error from MyPDEInitialize returned %d\n");

    return (err);
}
Exemplo n.º 9
0
StAcroResourceContext::StAcroResourceContext(short resFile)
	: mCurResFile(resFile)
{
	mOldResFile = CurResFile();

	if( mCurResFile )
		UseResFile(mCurResFile);
}
Exemplo n.º 10
0
void GetIndTypeRN ( INTEGER rn, ResType *typep, INTEGER type_num)
{
  INTEGER savern;

  savern = CurResFile();
  UseResFile(rn);
  Get1IndType (typep, type_num);
  UseResFile(savern);
}
Exemplo n.º 11
0
OSStatus		CAComponent::GetResourceVersion (UInt32 &outVersion) const
{
	bool versionFound = false;
	ResFileRefNum componentResFileID = kResFileNotOpened;
	OSStatus result;
	short thngResourceCount;
	
	short curRes = CurResFile();
	require_noerr (result = OpenAComponentResFile( mComp, &componentResFileID), home);
	require_noerr (result = componentResFileID <= 0, home);
	
	UseResFile(componentResFileID);

	thngResourceCount = Count1Resources(kComponentResourceType);
	
	require_noerr (result = ResError(), home);
			// only go on if we successfully found at least 1 thng resource
	require_noerr (thngResourceCount <= 0 ? -1 : 0, home);

	// loop through all of the Component thng resources trying to 
	// find one that matches this Component description
	for (short i = 0; i < thngResourceCount && (!versionFound); i++)
	{
		// try to get a handle to this code resource
		Handle thngResourceHandle = Get1IndResource(kComponentResourceType, i+1);
		if (thngResourceHandle != NULL && ((*thngResourceHandle) != NULL))
		{
			if (UInt32(GetHandleSize(thngResourceHandle)) >= sizeof(ExtComponentResource))
			{
				ExtComponentResource * componentThng = (ExtComponentResource*) (*thngResourceHandle);

				// check to see if this is the thng resource for the particular Component that we are looking at
				// (there often is more than one Component described in the resource)
				if ((componentThng->cd.componentType == mDesc.Type()) 
						&& (componentThng->cd.componentSubType == mDesc.SubType()) 
						&& (componentThng->cd.componentManufacturer == mDesc.Manu()))
				{
					outVersion = componentThng->componentVersion;
					versionFound = true;
				}
			}
			ReleaseResource(thngResourceHandle);
		}
	}

	if (!versionFound)
		result = resNotFound;
		
	UseResFile(curRes);	// revert
	
	if ( componentResFileID != kResFileNotOpened )
		CloseComponentResFile(componentResFileID);
		
home:
	return result;
}
Exemplo n.º 12
0
void AddResourceRN ( INTEGER rn, Handle h, ResType type, INTEGER id,
		    Str255 name)
{
  INTEGER savern;

  savern = CurResFile();
  UseResFile(rn);
  AddResource (h, type, id, name);
  UseResFile(savern);
}
Exemplo n.º 13
0
INTEGER CountResourcesRN (INTEGER rn, ResType type)
{
  INTEGER savern, retval;

  savern = CurResFile();
  UseResFile(rn);
  retval = Count1Resources(type);
  UseResFile(savern);
  return retval;
}
Exemplo n.º 14
0
INTEGER CountTypesRN (INTEGER rn)
{
  INTEGER savern, retval;

  savern = CurResFile();
  UseResFile(rn);
  retval = Count1Types();
  UseResFile(savern);
  return retval;
}
Exemplo n.º 15
0
void SetUpQD(void)
{
    ProcessSerialNumber PSN;
    FSSpec              myFSSpec;
    Str63               name;
    ProcessInfoRec      infoRec;
    OSErr               result = noErr;
    CFragConnectionID   connID;
    Str255              errName;

    // Memorize the plugin¹s resource file refnum for later use.
    gResFile = CurResFile();

#if !TARGET_API_MAC_CARBON
    // Ask the system if CFM is available.
    long response;
    OSErr err = Gestalt(gestaltCFMAttr, &response);
    Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);

    if (hasCFM) {
        // GetProcessInformation takes a process serial number and
        // will give us back the name and FSSpec of the application.
        // See the Process Manager in IM.
        infoRec.processInfoLength = sizeof(ProcessInfoRec);
        infoRec.processName = name;
        infoRec.processAppSpec = &myFSSpec;

        PSN.highLongOfPSN = 0;
        PSN.lowLongOfPSN = kCurrentProcess;

        result = GetProcessInformation(&PSN, &infoRec);
    } else {
        // If no CFM installed, assume it must be a 68K app.
        result = -1;
    }

    if (result == noErr) {
        // Now that we know the app name and FSSpec, we can call
        // GetDiskFragmentto get a connID to use in a subsequent call
        // to FindSymbol (it will also return the address of ³main² in
        // app, which we ignore). If GetDiskFragment returns an
        // error, we assume the app must be 68K.
        Ptr mainAddr;
        result =  GetDiskFragment(infoRec.processAppSpec, 0L, 0L,
                                  infoRec.processName, kReferenceCFrag,
                                  &connID, (Ptr*)&mainAddr, errName);
    }

    if (result == noErr) {
        // The app is a PPC code fragment, so call FindSymbol
        // to get the exported ³qd² symbol so we can access its
        // QuickDraw globals.
        CFragSymbolClass symClass;
        result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
    } else {
Exemplo n.º 16
0
short PreCarbonSetupResourceChain()
{
	short oldResFile = 0;		// Save the current res file and return
	oldResFile = CurResFile();		// Save the current res file and return
											// to caller
	UseResFile( gResFile );					// Push plugin file onto resource chain
	if( gLocaleResFile )					// If there is a locale file, make sure
		UseResFile( gLocaleResFile );		// it is above the plugin on the chain.
		
	return oldResFile;		
}
Exemplo n.º 17
0
StAcroResourceContext::StAcroResourceContext()
	: mCurResFile(GetAcroPluginResourceMap())
{
	mOldResFile = CurResFile();
	
	if( mCurResFile )
		UseResFile(mCurResFile);
	
	if( gLocaleResFile )
		UseResFile(gLocaleResFile);
}
Exemplo n.º 18
0
void dump_colors(
	struct rgb_color_value *colors, 
	short color_count)
{
	CTabHandle new_table;
	Handle old_bad_clut;
	struct rgb_color_value *color;
	short loop;
	FSSpec file;
	short refnum;
	
	file.vRefNum= -1;
	file.parID= 2;
	strcpy((char *)file.name, (const char *)"\pMarathon2 Clut\0");

	FSpCreateResFile(&file, 'RSED', 'rsrc', smSystemScript);
	refnum= FSpOpenResFile(&file, fsWrPerm);
	if(refnum>=0)
	{
		new_table= (CTabHandle) NewHandleClear(sizeof(ColorTable)+color_count*sizeof(ColorSpec));
		HLock((Handle) new_table);
		(*new_table)->ctSeed= GetCTSeed();
		(*new_table)->ctFlags= 0;
		(*new_table)->ctSize= color_count-1;
		
		/* Slam the colors.. */
		color= colors;
		for(loop=0; loop<=color_count; ++loop)
		{
			(*new_table)->ctTable[loop].rgb.red= color->red;
			(*new_table)->ctTable[loop].rgb.green= color->green;
			(*new_table)->ctTable[loop].rgb.blue= color->blue;
			(*new_table)->ctTable[loop].value= loop;
			color++;
		}
		HUnlock((Handle) new_table);
	
		old_bad_clut= GetResource('clut', 5454);
		if (old_bad_clut)
		{
			RmveResource((Handle) old_bad_clut);
			DisposeHandle((Handle) old_bad_clut);
			UpdateResFile(CurResFile());
		}
		
		AddResource((Handle) new_table, 'clut', 5454, "\pMarathon2 Color Table");
		if(ResError()) dprintf("Err adding it: %d", ResError());
		WriteResource((Handle) new_table);
		ReleaseResource((Handle) new_table);
		
		CloseResFile(refnum);
	}
Exemplo n.º 19
0
cBitmapFontEditable::cBitmapFontEditable(const CRect &size, CControlListener *listener, long tag,
                                         CBitmap *background, int spacing, int characters) :
cBitmapFont(size, listener, tag, background, spacing, characters) {
  setWantsFocus(true);
#ifdef MAC
  pluginResID = CurResFile();
#endif
  setMouseEnabled(true);
  setMouseableArea(size);
  memset(m_edit_buffer, 0x0, sizeof(char) * MAX_EDIT_CHARS);
  m_editing = false;
  m_edit_index = 0;
}
Exemplo n.º 20
0
static void DrawVersion()
{
	static Str255 versionString = "\p";
	if (not versionString[0]) {
		// Get version string from 'vers' resource
		short oldResFile = CurResFile();
		UseResFile(MyApp::cAppResFile);
		Handle h = GetResource('vers', 1);
		unsigned char *p = (unsigned char *)*h;
		BlockMoveData(p+6, &versionString[0], p[6]+1);
		ReleaseResource(h);
		UseResFile(oldResFile);
	}
void QTTarg_ShowStringToUser (StringPtr theString)
{
	short 		mySavedResFile;

	// get the current resource file and set the application's resource file
	mySavedResFile = CurResFile();
	UseResFile(gAppResFile);

	ParamText(theString, NULL, NULL, NULL);
	Alert(kQTTargAlertID, NULL);
	
	// restore the original resource file
	UseResFile(mySavedResFile);
}
Exemplo n.º 22
0
StAcroResourceContext::StAcroResourceContext(short resFile)
	: mCurResFile(resFile)
{
#if TARGET_API_MAC_CARBON
	mOldResFile = CurResFile();

	if( mCurResFile )
		UseResFile(mCurResFile);
			
#else

	mOldResFile = PreCarbonSetupResourceChain( );
	
#endif
}
Exemplo n.º 23
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;
}
Exemplo n.º 24
0
static PyObject *Res_CurResFile(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    short _rv;
#ifndef CurResFile
    PyMac_PRECHECK(CurResFile);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = CurResFile();
    {
        OSErr _err = ResError();
        if (_err != noErr) return PyMac_Error(_err);
    }
    _res = Py_BuildValue("h",
                         _rv);
    return _res;
}
Exemplo n.º 25
0
/*	GetXOPDialog(dialogID)

	This routine is implemented on Macintosh only.
	
	Thread Safety: GetXOPDialog is not thread-safe.
*/
DialogPtr
GetXOPDialog(int dialogID)
{
	DialogPtr theDialog;
	int saveResFile;
	
	saveResFile = CurResFile();
	UseResFile(XOPRefNum());
	theDialog = GetNewDialog(dialogID, NULL, (WindowPtr)-1);
	UseResFile(saveResFile);

	if (theDialog == NULL)
		return NULL;

	gXOPDialogFilterUPP = NewModalFilterUPP(XOPDialogFilter);
	
	return theDialog;
}
Exemplo n.º 26
0
NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
{
	NPError rv = NPERR_NO_ERROR;

	if (!aUnloadUpp)
		rv = NPERR_INVALID_FUNCTABLE_ERROR;

	if (rv == NPERR_NO_ERROR)
		rv = fillNetscapeFunctionTable(aNPNFuncs);

	if (rv == NPERR_NO_ERROR) {
		// defer static constructors until the global functions are initialized.
		__InitCode__();
		rv = fillPluginFunctionTable(aNPPFuncs);
	}

	*aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
	gResFile = CurResFile();
	rv = Private_Initialize();

	return rv;
}
Exemplo n.º 27
0
static char *
GetUserName()
{
    static char buf[33];
    short refnum;
    Handle h;

    refnum = CurResFile();
    UseResFile(0);
    h = GetResource('STR ', -16096);
    UseResFile(refnum);
    if (h == NULL) {
        return NULL;
    }

    HLock(h);
    strncpy(buf, (*h)+1, **h);
    buf[**h] = '\0';
    HUnlock(h);
    ReleaseResource(h);
    return(buf[0] ? buf : NULL);
}
Exemplo n.º 28
0
//_______________________________________________________________________________
OSErr WriteRsrc	(Handle rsrc, ResType type, short ID, short	resFile)
{
	OSErr err; Handle h;
	short saved;
	
	saved = CurResFile();
	UseResFile( resFile);
	if ((err= ResError())!=noErr)	return err;
	
	h= GetResource (type, ID);
	if (h) RemoveResource (h);
	HLock (rsrc);
	AddResource( rsrc, type, ID, "\p");
	err= ResError();
	if( err== noErr) {
		UpdateResFile( resFile);
		err= ResError();
	}
	HUnlock( rsrc);
	UseResFile( saved);
	return err;
}
Exemplo n.º 29
0
pascal Handle SafeGet1Resource(ResType type, short resNum)
{
#if TARGET_API_MAC_CARBON
	Handle result = NULL;
	
	if (gLocaleResFile)
	{
		StAcroResourceContext resContext(gLocaleResFile);
		result = Get1Resource(type, resNum);
	}
	if (result == NULL && gResFile)
	{
		StAcroResourceContext resContext(gResFile);
		result = Get1Resource(type, resNum);
	}
	return result;
#else

	Handle result;
	short oldResFile = CurResFile();

	if( gLocaleResFile ) {					// Look in the Locale file first

		UseResFile( gLocaleResFile );
		result = Get1Resource(type, resNum);
		if( result ) {						// If the resource was there, then
			UseResFile( oldResFile );		// restore the chain and exit
			return result;
		}
	}

	UseResFile( gResFile );					// Default to base resource file
	result = Get1Resource(type, resNum);	// and get resource.

	UseResFile(oldResFile);					// restore and return
	return result;
#endif
}
Exemplo n.º 30
0
/* 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;
}