Esempio n. 1
0
void TestSubstringF( void )
{
    char            buf[] = "The quick brown fox jumped over the lazy dogs.";
    int             status;
    char __far      *ptr;

    status = _fstrcspn( "abcdefghij", "bca" );  /* should be zero chars */
    VERIFY( status == 0 );

    status = _fstrcspn( "123456", "cab" );      /* should be whole string */
    VERIFY( status == 6 );

    status = _fstrcspn( "!x,y:zfoo", "t.7of" ); /* should be 6 chars */
    VERIFY( status == 6 );

    ptr = _fstrpbrk( "aBcDeFgHiJ", "1234567" ); /* should be NULL */
    VERIFY( ptr == NULL );

    ptr = _fstrpbrk( "Foo", "" );               /* should be NULL */
    VERIFY( ptr == NULL );

    ptr = _fstrpbrk( buf, "t!q-");              /* find the 'q' */
    VERIFY( ptr == buf+4 );

    status = _fstrspn( buf, "!1@2#3$4%5^6&7" ); /* should be zero */
    VERIFY( status == 0 );

    status = _fstrspn( buf, "kciuq ehT" );      /* should be 10 */
    VERIFY( status == 10);

    ptr = _fstrstr( buf, "foo" );               /* should be NULL */
    VERIFY( ptr == NULL );

    ptr = _fstrstr( buf, "ck br" );             /* find "ck br" */
    VERIFY( ptr == buf+7 );
}
Esempio n. 2
0
/******************************************************************************
 *  int WinMain(
 *      HINSTANCE hinstCurrent,
 *      HINSTANCE hinstPrevious,
 *      LPSTR     lpszCmdLine,
 *      int       nCmdShow);
 * 
 *  windows initialization and exit
 *
 *  parameters:
 *      hinstCurrent - handle to this instance of minerva
 *      hinstPrevious - handle to previous instance of minerva. If hinstPrevious is
 *          NULL, no other instance is active (this is the first and only instance).
 *      lpszCmdLine - command line parameters to this instance
 *      nCmdShow - see ShowWindow() documentation
 *
 *  returns:  
 *      value to be set as exit code for application
 *
 *  notes:
 *      WinMain is called as the application is starting up.  When WinMain returns,
 *      the application is terminated.
 ******************************************************************************/
int PASCAL WinMain(
    HINSTANCE hinstCurrent,     /* handle to this instance */
    HINSTANCE hinstPrevious,    /* handle to previous instance or NULL */
    LPSTR     lpszCmdLine,      /* command line */
    int       nCmdShow)         /* see ShowWindow() documentation */
{
    MSG msg;
	LPCSTR psz;
    
    NOREFERENCE(lpszCmdLine);

    /* make SURE that (LPBITMAPINFO)&PIC_PARM.Head is valid */
    assert(offsetof(PIC_PARM,   ColorTable) - offsetof(PIC_PARM,   Head) ==
           offsetof(BITMAPINFO, bmiColors)  - offsetof(BITMAPINFO, bmiHeader));
    
    hinstThis = hinstCurrent;   /* instance handle is globally accessible */

    /* allow ctl3d to hook us */
    Ctl3dRegister(hinstThis);
    /* dialogs and controls are automatically 3d */
    Ctl3dAutoSubclass(hinstThis);
    
    if ( hinstPrevious == NULL )
        {
        /* register window classes for first instance only
            hinstPrevious == NULL if and only if this is the only active
            instance of minerva */
        if ( !RegisterWindowClasses() )
            {
            Ctl3dUnregister(hinstCurrent);
            return ( 0 );
            }
        }

    /* keyboard accelerators for menu commands */
    hAcceleratorTable = LoadAccelerators(hinstThis, "MinervaAccelerators");
    if ( hAcceleratorTable == NULL )
        {
        ErrorMessage(STYLE_FATAL, IDS_LOADACCELERATORS);
        /* "An unexpected LoadAccelerators error occurred. Minerva cannot continue." */
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    if ( !CreateFrameWindow(nCmdShow) )
        {
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    /* load MRU file list from minerva.ini and update File menu */
    if ( !MruLoadList(hwndFrame, APPLICATION_INIFILENAME) )
        {
        DestroyWindow(hwndFrame);
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    hWaitCursor  = LoadCursor(NULL, IDC_WAIT);
    hArrowCursor = LoadCursor(NULL, IDC_ARROW);
    hHandCursor  = LoadCursor(hinstThis, MAKEINTRESOURCE(IDC_HAND));
    assert(hWaitCursor != NULL && hArrowCursor != NULL && hHandCursor != NULL);
    
    /* load PIC opcode DLL's */
    InitOpList();

    bDisableRDTSC = GetPrivateProfileInt("Settings", "DisableRDTSC", 0, APPLICATION_INIFILENAME);
	psz = lpszCmdLine + _fstrspn(lpszCmdLine, " ");
	while ( psz != 0 && ( *psz == '-' || *psz == '/' || *psz == '+' ) )
	{
		if ( _fstrnicmp(psz + 1, "RDTSC", sizeof("RDTSC") - 1) == 0 && psz[sizeof("RDTSC")] <= ' ' )
			bDisableRDTSC = *psz != '+';
		psz = _fstrpbrk(psz, " ");
		if ( psz != 0 )
			psz += _fstrspn(psz, " ");
	}
	if ( !bDisableRDTSC )
		MiscTickCount();	// calibrate the RDTSC ticks

    while ( GetMessage(&msg, NULL, 0, 0) )
        {
        if ( !TranslateMDISysAccel(hwndMDIClient, &msg) &&
             !TranslateAccelerator(hwndFrame, hAcceleratorTable, &msg) )
            {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            }
        }
        
    DestroyCursor(hHandCursor);
    /* unload PIC opcode DLL's */
    CleanupOpList();

    /* save MRU file list to minerva.ini */
    MruSaveList(APPLICATION_INIFILENAME);

    Ctl3dUnregister(hinstCurrent);

    return ( msg.wParam );
}