Esempio n. 1
0
/*
 * ColorFind - find string and color it
 */
vi_rc ColorFind( char *data, find_type findfl )
{
    vi_rc       rc;
    int         len;
    char        *buff;
    i_mark      pos;

    /*
     * get search string and flags
     */
    buff = StaticAlloc();
    if( (len = NextWordSlash( data, buff ) ) <= 0 ) {
        StaticFree( buff );
        return( ERR_INVALID_FIND_CMD );
    }

    /*
     * go get the match
     */
    GoToLineNoRelCurs( 1 );
    rc = GetFind( buff, &pos, &len, FINDFL_FORWARD | findfl );
    if( rc == ERR_NO_ERR ) {
        pos.column += 1;
        JumpTo( &pos );
        DCUpdate();
#ifndef __WIN__
        // Windows selects instead
        HiliteAColumnRange( pos.line, pos.column, pos.column + len - 1 );
#endif
        EditFlags.ResetDisplayLine = TRUE;
    }
    StaticFree( buff );
    return( rc );

} /* ColorFind */
Esempio n. 2
0
// Scroll /////////////////////////////////////////////////////////////////2.00
//		スクロール専門の汎用メソッド。
//		スクロールバーは後でクラス化した方が良い。
//		それによりスクロール関数そのものは、単純な構造にしたい。
	int
ClassABrowserView::Scroll(int msg, unsigned short int nLine)
{
	LONG nScrollLine;

	switch(msg)
	{
		case SB_THUMBTRACK:
			return JumpTo((long)(nLine * dblScroll));
		case SB_LINEDOWN:
			nScrollLine =  1;
			break;
		case SB_LINEUP:
			nScrollLine = -1;
			break;
		case SB_PAGEDOWN:
			nScrollLine =  nLineViewPage;
			break;
		case SB_PAGEUP:
			nScrollLine	= -nLineViewPage;
			break;
		default:
			return 0;
	}

	return Scroll(nScrollLine);
}
Esempio n. 3
0
    void LiveDownloadDriver::JumpOrSwitchIfNeeded()
    {
        // 跳跃算法
        // 1. 回放不会跳跃
        // 2. 落后直播点120s
        if (!replay_ && !rest_time_tracker_.IsPaused())
        {
            bool is_jump = false;

            if (playing_position_.GetBlockId() + 90 < GetInstance()->GetCurrentLivePoint().GetBlockId())
            {
                JumpTo(storage::LivePosition(GetInstance()->GetCurrentLivePoint().GetBlockId() - 2 * GetInstance()->GetLiveInterval()));

                is_jump = true;
            }

            if (is_jump)
            {
                jump_times_++;
            }
        }

        // 码流切换算法
        // 1. 当前block的数据必须全部发送完毕
        if (BootStrapGeneralConfig::Inst()->AutoSwitchStream() && (
            data_rate_manager_.SwitchToHigherDataRateIfNeeded(GetRestPlayableTime()) ||
            data_rate_manager_.SwitchToLowerDataRateIfNeeded(GetRestPlayableTime())))
        {
            OnDataRateChanged();
        }
    }
Esempio n. 4
0
/////////////////////////////////////////////////////////////
// Parse EXIF data, typically found in a JPEG's APP1 segment.
/////////////////////////////////////////////////////////////
EXIFData
EXIFParser::ParseEXIF(const uint8_t* aData, const uint32_t aLength)
{
  if (!Initialize(aData, aLength)) {
    return EXIFData();
  }

  if (!ParseEXIFHeader()) {
    return EXIFData();
  }

  uint32_t offsetIFD;
  if (!ParseTIFFHeader(offsetIFD)) {
    return EXIFData();
  }

  JumpTo(offsetIFD);

  Orientation orientation;
  if (!ParseIFD0(orientation)) {
    return EXIFData();
  }

  // We only care about orientation at this point, so we don't bother with the
  // other IFDs. If we got this far we're done.
  return EXIFData(orientation);
}
Esempio n. 5
0
void Cleanhelp(){
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for (int i = 1; i<=12; i++){
    JumpTo(0, 10+i);
    SetConsoleTextAttribute(hConsole,7);
    puts ("                                                                                                       ");
}
}
Esempio n. 6
0
/*
================
rvGameDebug::JumpTo
================
*/
void rvGameDebug::JumpTo ( const char* name ) {
	int index;
	for ( index = 0; index < jumpPoints.Num(); index ++ ) {
		if ( !jumpPoints[index].name.Icmp ( name ) ) {
			JumpTo ( index );
			return;
		}
	}
}
Esempio n. 7
0
double CScript::Goto(const char* CmdStr, char* retStr)
{
    char *str=GetStringParam(CmdStr, 0);
    if (str)
    {
        JumpTo( str );
        M_FREE( str, sizeof(char)*MAX_VAR_LEN );
    }
    return 1;
}
Esempio n. 8
0
/*
 * DoNextFindBackwardsMisc - search again, based on last string (EVENT_MISC)
 */
vi_rc DoNextFindBackwardsMisc( void )
{
    range       r;
    vi_rc       rc;

    if( CurrentFile == NULL ) {
        // you cant search if theres no file!
        return( ERR_NO_FILE );
    }
    defaultRange( &r );
    rc = getFindString( &r, FALSE, TRUE, TRUE );
    JumpTo( &r.start );

    return( rc );

} /* DoNextFindBackwardsMisc */
Esempio n. 9
0
void printRect(int x1, int y1, int x2, int y2, char border, int color){
	COORD pos;
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	pos.X = x1;
	pos.Y = y1;
	SetConsoleTextAttribute(hConsole, color);
	for (pos.X; pos.X <= x2; pos.X++){
		for (pos.Y; pos.Y <= y2; pos.Y++){
			JumpTo(pos.X, pos.Y);
			if ((pos.X == x1) || (pos.X == x2) || (pos.Y == y1) || (pos.Y == y2)){
				printf("%c", border);
			}
			else printf(" ");
		}
		pos.Y = y1;
	}
}
Esempio n. 10
0
/*
 * FancyDoFindMisc - an EVENT_MISC version of below
 */
vi_rc FancyDoFindMisc( void )
{
    range   r;
    vi_rc   rc;

    if( CurrentFile == NULL ) {
        // you cant search if theres no file!
        return( ERR_NO_FILE );
    }
    defaultRange( &r );
    rc = FancyDoFind( &r, 1L );
    if( rc != RANGE_REQUEST_CANCELLED ) {
        JumpTo( &r.start );
    }

    return( rc );

} /* FancyDoFindMisc */
Esempio n. 11
0
static BOOL
IsBadExecPtr(uintptr_t ptr)
{
  BOOL ret = false;

#if defined(_MSC_VER) && !defined(__clang__)
  __try {
    JumpTo(ptr);
  } __except (EXCEPTION_EXECUTE_HANDLER) {
    ret = true;
  }
#else
  printf("INFO | exec test not supported on MinGW or clang-cl builds\n");
  // We do our best
  ret = IsBadReadPtr((const void*)ptr, 1);
#endif
  return ret;
}
Esempio n. 12
0
void CleanCons(){
JumpTo(0,10);
puts("                                                                                ");
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_GREEN );
JumpTo(30,3);
puts("                                      ");
JumpTo(30,4);
puts("                                      ");
JumpTo(30,5);
puts("                                      ");
JumpTo(30,6);
puts("                                      ");
JumpTo(30,7);
puts("                                      ");
JumpTo(30,3);
}
Esempio n. 13
0
void start(char *str, char* cmd){
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    JumpTo(30,1);
    SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_GREEN );
    printf("Enter your string:\n");
    JumpTo(30,2);
    gets(str);
    JumpTo(30,1);
    SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_GREEN );
    puts("                                                                            ");
    JumpTo(30,1);
    printf("Your string:\n");
    SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_GREEN );
    JumpTo(30,2);
    puts(str);
    JumpTo(0,9);
    SetConsoleTextAttribute(hConsole,7);
    printf("Enter your command:\n");
    //getcmd(cmd);
}
Esempio n. 14
0
// FindText ///////////////////////////////////////////////////////////////1.00
// pszFindがNULLの時は、継続検索
	int
ClassABrowserView::Find(char *pszFind, bool reverse)
{
	// ファイルが無ければ終了
	if (!dwFileSize)
		return 0;

	// 新規かどうかの判定・処理
	if (pszFind)
	{
		// 新規検索の場合
		nFindLine		= nLineView;
		nFindColumn		= reverse ? -1 : 0;
		if (lstrlen(pszFind) < CAV_FINDTEXT_MAX)
			lstrcpy(szFindText, pszFind);
	}
	long	nWordLength = lstrlen(szFindText);
	if (!nWordLength)
		return 0;

	long nLine		= (nFindLine < 0) ? nTextLine + nFindLine : nFindLine;
	long nColumn	= nFindColumn;
	int		fFind		= 0;

	if (reverse)
	{
		nColumn -= nWordLength + 1;
		if (nColumn < 0)
			--nLine;
	}
	while (!fFind && (0 <= nLine && nLine < nTextLine))
	{
		GenerateLine(nLine);
		char* psz = (char*) cmOutline->GetPointer();
		long	nLength = lstrlen(psz);
		nColumn = (nColumn < 0) ? nLength - nWordLength + nColumn : nColumn;

		while (!fFind &&
				(0 <= nColumn && nColumn <= nLength - nWordLength))
		{
			if (CompareString(LOCALE_USER_DEFAULT, 0, psz + nColumn,
							nWordLength, szFindText, nWordLength)
					== CSTR_EQUAL)
			{
				fFind = -1;
				fQueryOn = 0;

				SetOrigin(nLine, nColumn);
				fQueryMode = CTQ_MODE_NORMAL;
				SetConclusion(nLine, nColumn + nWordLength);
				QueryGenerate();
				InvalidateRect(hWnd ,NULL, FALSE);

				JumpTo(nLine);
				nFindLine		= nLine;
				nFindColumn		= nColumn + nWordLength;
			}
			if (reverse)
			{
				int i;
				--nColumn;
				for (i = 0; i < nColumn; ++i)
					if (IsDBCSLeadByte(psz[i]))
						++i;
				nColumn -= i - nColumn;
			}
			else
			{
				if (IsDBCSLeadByte(*(psz + nColumn)))
					nColumn++;
				nColumn++;
			}
		}

		// 行送り
		if (!reverse)
		{
			nColumn = 0;
			++nLine;
		}
		else
		{
			nColumn = -1;
			--nLine;
		}
	}

	if (!fFind)
	{
		if (reverse)
		{
			nFindLine = -1;
			nFindColumn = -1;
		}
		else
		{
			nFindLine		= 0;
			nFindColumn		= 0;
		}
		SetOrigin(0, 0);
		fQueryMode = CTQ_MODE_NORMAL;
		QueryGenerate();
		InvalidateRect(hWnd, NULL, FALSE);

		char msg[256], title[64];
		LoadString(g_hInstance, IDS_FINDERR_TITLE, title, sizeof(title) - 1);
		LoadString(g_hInstance,
				(reverse ? IDS_FINDERR_TOP : IDS_FINDERR_BOTTOM),
				msg, sizeof(msg) - 1);
		MessageBox(hWnd, msg, title, MB_OK | MB_ICONINFORMATION);
	}

	return 1;
}
Esempio n. 15
0
//------------------------------------------------------------------------------
//
//  Function:  OEMLaunch
//
//  This function is the last one called by the boot framework and it is
//  responsible for to launching the image.
//
VOID
OEMLaunch(
   ULONG start, 
   ULONG size, 
   ULONG launch, 
   const ROMHDR *pRomHeader
    )
{
    BSP_ARGS *pArgs = OALCAtoUA(IMAGE_SHARE_ARGS_CA);

	UNREFERENCED_PARAMETER(size);
	UNREFERENCED_PARAMETER(pRomHeader);

    OALMSG(OAL_FUNC, (
        L"+OEMLaunch(0x%08x, 0x%08x, 0x%08x, 0x%08x - %d/%d)\r\n", start, size,
        launch, pRomHeader, g_eboot.bootDeviceType, g_eboot.type
        ));

    // Depending on protocol there can be some action required
    switch (g_eboot.bootDeviceType)
        {
#if BUILDING_EBOOT_SD
        case BOOT_SDCARD_TYPE:            
            switch (g_eboot.type)
                {
#if 0
/*
                case DOWNLOAD_TYPE_FLASHRAM:
                    if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP)
                        {
                        OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: "
                            L"Image load from flash memory failed\r\n"
                            ));
                        goto cleanUp;
                        }
                    launch = g_eboot.launchAddress;
                    break;
*/
#endif
                case DOWNLOAD_TYPE_RAM:
                    launch = (UINT32)OEMMapMemAddr(start, launch);
                    break;
					
                case DOWNLOAD_TYPE_FLASHNAND:
                    if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP)
                        {
                        OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: "
                            L"Image load from flash memory failed\r\n"
                            ));
                        goto cleanUp;
                        }
                    launch = g_eboot.launchAddress;
                    break;
					
#if 0
/*
                case DOWNLOAD_TYPE_EBOOT:
                case DOWNLOAD_TYPE_XLDR:
                    OALMSG(OAL_INFO, (L"INFO: "
                        L"XLDR/EBOOT/IPL downloaded, spin forever\r\n"
                        ));
                    while (TRUE);
                    break;
*/
#endif
                default:
                    OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: Unknown download type, spin forever\r\n"));
                    for(;;);
                    break;
                }
            break;

#endif

        case OAL_KITL_TYPE_ETH:
            BLEthConfig(pArgs);
            switch (g_eboot.type)
                {
                case DOWNLOAD_TYPE_FLASHNAND:
				case DOWNLOAD_TYPE_FLASHNOR:
                    if (BLFlashDownload(&g_bootCfg, g_kitlDevices) != BL_JUMP)
                        {
                        OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: "
                            L"Image load from flash memory failed\r\n"
                            ));
                        goto cleanUp;
                        }
                    launch = g_eboot.launchAddress;
                    break;

                case DOWNLOAD_TYPE_RAM:
                    launch = (UINT32)OEMMapMemAddr(start, launch);
                    break;

                case DOWNLOAD_TYPE_EBOOT:
                case DOWNLOAD_TYPE_XLDR:
                    OALMSG(OAL_INFO, (L"INFO: "
                        L"XLDR/EBOOT/IPL downloaded, spin forever\r\n"
                        ));
                    for(;;);
                    break;

				case DOWNLOAD_TYPE_LOGO:
                    OALMSG(OAL_INFO, (L"INFO: "
                        L"Splashcreen logo downloaded, spin forever\r\n"
                        ));
                    for(;;);
                    break;

                default:
                    OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: Unknown download type, spin forever\r\n"));
                    for(;;);
                    break;
                }
            break;

        default:        
            launch = g_eboot.launchAddress;
            break;
        }

#ifndef BSP_NO_NAND_IN_SDBOOT
    if ((g_bootCfg.flashNKFlags & ENABLE_FLASH_NK) &&       
        /* if loading from NAND then do not need to flash NAND again */      
        (g_eboot.bootDeviceType != OAL_KITL_TYPE_FLASH) && 
	    (start != (IMAGE_WINCE_CODE_CA + NAND_ROMOFFSET)) &&
	    (start != (IMAGE_WINCE_CODE_CA + NOR_ROMOFFSET))) {
            if( !WriteFlashNK(start, size))
	            OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: "
	                L"Flash NK.bin failed, start=%x\r\n", start
	                ));
    	}
#endif

    // Check if we get launch address
    if (launch == (UINT32)INVALID_HANDLE_VALUE)
        {
        OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: "
            L"Unknown image launch address, spin forever\r\n"
            ));
        for(;;);
        }        

    // Print message, flush caches and jump to image
    OALLog(
        L"Launch Windows CE image by jumping to 0x%08x...\r\n\r\n", launch
        );

	OEMDeinitDebugSerial();
    OEMPlatformDeinit();
    JumpTo(OALVAtoPA((UCHAR*)launch));

cleanUp:
    return;
}
Esempio n. 16
0
/*
================
rvGameDebug::JumpNext
================
*/
void rvGameDebug::JumpNext ( void ) {
	if ( !jumpPoints.Num() ) {
		return;
	}
	JumpTo ( ( jumpIndex + 1 ) % jumpPoints.Num() );
}
Esempio n. 17
0
/* Test each page.  */
static bool
TestPage(const char *pagelabel, uintptr_t pageaddr, int should_succeed)
{
  const char *oplabel;
  uintptr_t opaddr;

  bool failed = false;
  for (unsigned int test = 0; test < 3; test++) {
    switch (test) {
      // The execute test must be done before the write test, because the
      // write test will clobber memory at the target address.
    case 0: oplabel = "reading"; opaddr = pageaddr + PAGESIZE/2 - 1; break;
    case 1: oplabel = "executing"; opaddr = pageaddr + PAGESIZE/2; break;
    case 2: oplabel = "writing"; opaddr = pageaddr + PAGESIZE/2 - 1; break;
    default: abort();
    }

#ifdef _WIN32
    BOOL badptr;

    switch (test) {
    case 0: badptr = IsBadReadPtr((const void*)opaddr, 1); break;
    case 1: badptr = IsBadExecPtr(opaddr); break;
    case 2: badptr = IsBadWritePtr((void*)opaddr, 1); break;
    default: abort();
    }

    if (badptr) {
      if (should_succeed) {
        printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, pagelabel);
        failed = true;
      } else {
        printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
      }
    } else {
      // if control reaches this point the probe succeeded
      if (should_succeed) {
        printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
      } else {
        printf("TEST-UNEXPECTED-FAIL | %s %s\n", oplabel, pagelabel);
        failed = true;
      }
    }
#else
    pid_t pid = fork();
    if (pid == -1) {
      printf("ERROR | %s %s | fork=%s\n", oplabel, pagelabel,
             LastErrMsg());
      exit(2);
    } else if (pid == 0) {
      volatile unsigned char scratch;
      switch (test) {
      case 0: scratch = *(volatile unsigned char *)opaddr; break;
      case 1: JumpTo(opaddr); break;
      case 2: *(volatile unsigned char *)opaddr = 0; break;
      default: abort();
      }
      (void)scratch;
      _exit(0);
    } else {
      int status;
      if (waitpid(pid, &status, 0) != pid) {
        printf("ERROR | %s %s | wait=%s\n", oplabel, pagelabel,
               LastErrMsg());
        exit(2);
      }

      if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
        if (should_succeed) {
          printf("TEST-PASS | %s %s\n", oplabel, pagelabel);
        } else {
          printf("TEST-UNEXPECTED-FAIL | %s %s | unexpected successful exit\n",
                 oplabel, pagelabel);
          failed = true;
        }
      } else if (WIFEXITED(status)) {
        printf("ERROR | %s %s | unexpected exit code %d\n",
               oplabel, pagelabel, WEXITSTATUS(status));
        exit(2);
      } else if (WIFSIGNALED(status)) {
        if (should_succeed) {
          printf("TEST-UNEXPECTED-FAIL | %s %s | unexpected signal %d\n",
                 oplabel, pagelabel, WTERMSIG(status));
          failed = true;
        } else {
          printf("TEST-PASS | %s %s | signal %d (as expected)\n",
                 oplabel, pagelabel, WTERMSIG(status));
        }
      } else {
        printf("ERROR | %s %s | unexpected exit status %d\n",
               oplabel, pagelabel, status);
        exit(2);
      }
    }
#endif
  }
  return failed;
}
Esempio n. 18
0
/*
================
rvGameDebug::JumpPrev
================
*/
void rvGameDebug::JumpPrev ( void ) {
	if ( !jumpPoints.Num() ) {
		return;
	}
	JumpTo ( ( jumpIndex + jumpPoints.Num() - 1 ) % jumpPoints.Num() );
}