static UInt32 PealCall86(void* Module,void* Func,void* Param)
{
	return PceNativeCall((NativeFuncType*)Func,Param);
}
UInt32 PilotMain(UInt16 launchCode, MemPtr launchParameters, UInt16 launchFlags)
{
	UInt32 Value;
	UInt32 Result = errNone;
	UInt32 CPU;
	launch Launch;
	Launch.launchParameters = launchParameters;
	Launch.launchCode = launchCode;
	Launch.launchFlags = launchFlags;

	if ((launchCode == sysAppLaunchCmdNormalLaunch ||
		launchCode == sysAppLaunchCmdOpenDB ||
		launchCode == sysAppLaunchCmdCustomBase) && !RomVersionCheck(launchFlags))
	{
		FtrGet(sysFileCSystem, sysFtrNumProcessorID, &CPU);
		if (CPU == sysFtrNumProcessorx86)
		{
			Module = PealLoadFromResources('armc', 1000, NULL, PROJECT_FOURCC,32,0,0,0); // just for testing

			Launch.FreeModule = PealUnload;
			Launch.LoadModule = LoadModule;
			Launch.GetSymbol = LookupSymbol86;
			Launch.PealCall = PealCall86;
			Launch.Module = Module;
			PceNativeCall(PALMOS_IX86_FUNC(PROJECT_OUTPUT,PaceMain86),&Launch);

			if (Module)
				PealUnload(Module);
		}
		else
		if (sysFtrNumProcessorIsARM(CPU))
		{
			UInt32 Version;
			Boolean MemSema;

			FtrGet(sysFtrCreator, sysFtrNumROMVersion, &Version);
			MemSema = Version < sysMakeROMVersion(6,0,0,sysROMStageDevelopment,0);

			Module = PealLoadFromResources('armc', 1000, NULL, PROJECT_FOURCC,32,0,0,MemSema);
			if (Module)
			{
				PaceMain = PealLookupSymbol(Module, "PaceMain");
				if (PaceMain)
				{
					Launch.FreeModule = PealUnload;
					Launch.LoadModule = LoadModule;
					Launch.GetSymbol = PealLookupSymbol;
					Launch.PealCall = PealCall;
					Launch.Module = Module;

					Result = PealCall(Module,PaceMain,&Launch);
				}
				PealUnload(Module);
				MemHeapCompact(GetHeapId()); 
			}
		}
		else
			FrmCustomAlert(WarningOKAlert, "ARM processor is required to run this application!", " ", " ");

		if (FtrGet(PROJECT_FOURCC,20,&Value)==errNone)
			FtrPtrFree(PROJECT_FOURCC,20);
	}
	else
	if (launchCode == sysAppLaunchCmdNotify && (launchFlags & sysAppLaunchFlagSubCall)!=0)
	{
		FtrGet(sysFileCSystem, sysFtrNumProcessorID, &CPU);
		if (CPU == sysFtrNumProcessorx86)
			Result = PceNativeCall(PALMOS_IX86_FUNC(PROJECT_OUTPUT,PaceMain86),&Launch);
		else
		if (sysFtrNumProcessorIsARM(CPU) && Module && PaceMain)
			Result = PealCall(Module,PaceMain,&Launch);
	}
	return Result;
}
示例#3
0
/* Find pattern in text string */
static Boolean DoSearch
    (
    Char*   text,           /* text string */
    UInt16  size,           /* size of text */
    Char*   pattern,        /* pattern to search for */
    UInt8   matchMode,      /* indicates if the search should be
                               case-sensitive or not */
    UInt16  xlitMode,       /* how should we transliterate? */
    UInt16* pos,            /* start position, will contain the position
                               of the pattern if found */
    UInt16* endFound,       /* end of position where pattern is found */
    Int16   depth           /* depth of this page */
    )
{
    Int16   startPos;
    Int16   charsize;
    Int16   topcharsize;
    UInt16  patternLen;
    UInt16  wplen;
    Int16   i;
    Int16   j;
    Int16   top;
    WChar   ch;
    WChar   wpattern[ 2 * ( MAX_PATTERN_LEN+1 ) ];
    Boolean guaranteed8Bits;
#ifdef BUILD_ARMLETS
    Boolean        useArmlet;
    void*          DoSearchArmlet;
    ArmSearchType  armData;
    MemHandle      armChunkH = NULL;
#endif
    static UInt8   lastMatchMode = SEARCH_UNINITIALIZED;
    static UInt16  lastXlitMode  = 0;
    static Char    xlat[ 256 ];
    static Boolean multibyteCharFix;
    static WChar   multibyteCharFixTo;
#ifdef SUPPORT_TRANSLITERATION
    static Boolean symmetricXlit;
#endif

    multibyteCharFix = false;
    if ( lastMatchMode != matchMode || xlitMode != lastXlitMode ) {
#ifdef SUPPORT_TRANSLITERATION
        symmetricXlit = SetTransliteration( xlitMode, xlat, &multibyteCharFix, 
                            &multibyteCharFixTo );
#else
        for ( i = 0 ; i < 256 ; i++ ) {
            xlat[ i ] = i;
        }
#endif
        if ( ! ( matchMode & SEARCH_CASESENSITIVE ) ) {
            for ( i = 0; i < 256; i++ )
                xlat[ i ] = TxtGlueLowerChar( ( UInt8 )xlat[ i ] );
        }
        lastMatchMode = matchMode;
    }

    startPos    = *pos;
    charsize    = 1;
    patternLen  = StrLen( pattern );

    /* expand wchar string in advance*/
    i = wplen = 0;
    while ( i < patternLen ) {
        charsize = TxtGlueGetNextChar( pattern, i, &ch );
        if ( charsize == 1 ) {
#ifdef SUPPORT_TRANSLITERATION
            if ( symmetricXlit ) {
#endif
                ch = xlat[ (UInt8) ch ];
#ifdef SUPPORT_TRANSLITERATION
            }
            else if ( ! ( matchMode & SEARCH_CASESENSITIVE ) ) {
                ch = TxtGlueLowerChar( (UInt8) ch );
            }
#endif
        }
        else if ( multibyteCharFix )
            ch = multibyteCharFixTo;

        wpattern[ wplen ] = ch;

        i       += charsize;
        wplen   += 1;
    }

    guaranteed8Bits = DeviceUses8BitChars();
#ifdef BUILD_ARMLETS
    useArmlet       = false;
    DoSearchArmlet  = NULL;

    if ( SupportArmlets() && guaranteed8Bits ) {
        armChunkH = DmGetResource( ArmletResourceType, armDoSearch );
        if ( armChunkH != NULL ) {
            DoSearchArmlet = MemHandleLock( armChunkH );

            armData.size     = size;
            armData.depth    = depth;
            armData.text     = text;
            armData.wpattern = wpattern;
            armData.wplen    = wplen;
            armData.xlat     = xlat;

            useArmlet = true;
        }
    }
#endif

    i           = top = *pos;
    j           = 0;
    topcharsize = 0;
    while ( j < wplen && i < size ) {
#ifdef BUILD_ARMLETS
        if ( useArmlet ) {
            armData.i     = i;
            armData.j     = j;
            armData.top   = top;

            ch    = (WChar) PceNativeCall( DoSearchArmlet, &armData );

            i     = armData.i;
            j     = armData.j;
            top   = armData.top;

            if ( wplen <= j || size <= i )
                break;
            charsize = topcharsize = 1;
        }
        else
#endif
        if ( guaranteed8Bits ) {
            ch = DoSearch8BitText( text, size, wpattern, wplen, xlat,
                     &i, &j, &top, 0 < depth );
            if ( wplen <= j || size <= i )
                break;
            charsize = topcharsize = 1;
        }
        else
            charsize = TxtGlueGetNextChar( text, i, &ch );

        if ( j == 0 )
            topcharsize = charsize;

        if ( ch == '\0' ) {
            if ( 0 < depth ) {
                /* if function is anchor, store it to queue */
                if ( text[ i + 1 ] == 0x0A /* ANCHOR_START */ ){
                    UInt16 reference;
                    Int16  q;
                    Int16  listSize;

                    reference = 256 * (UInt8)text[ i + 2 ] +
                        (UInt8)text[ i + 3 ];

                    listSize = ListSize( searchQueue );
                    for ( q = 0; q < listSize; q ++ ){
                        /*look up in queue, append if not exist*/
                        QueueNode *node;
                        node = ListGet( searchQueue, q + 1 );
                        if ( node->reference == reference )
                            break;
                    }
                    if ( q == listSize )
                        AddReference( reference, depth );

                }
            }
            i  += 2 + ( text[ i + 1 ] & 0x07 );
            top = i;
            j   = 0;
            continue;
        }
        if ( charsize == 1 )
            ch = xlat[ (UInt8) ch ];
        else if ( multibyteCharFix )
            ch = multibyteCharFixTo;
        if ( ch != wpattern[ j ] ) {
            top += topcharsize;
            i    = top;
            j    = 0;
            continue;
        }
        i += charsize;
        j += 1;
    }
#ifdef BUILD_ARMLETS
    if ( armChunkH != NULL ) {
        MemHandleUnlock( armChunkH );
        DmReleaseResource( armChunkH );
    }
#endif
    if ( j == wplen ) {
        *pos      = top;
        *endFound = i;
        return true;
    }
    else {
        return false;
    }
}