コード例 #1
0
ファイル: string_utils.cpp プロジェクト: FarGroup/FarManager
const string& GetSpacesAndEols()
{
	static const auto SpacesOrEols = GetSpaces() + GetEols();
	return SpacesOrEols;
}
コード例 #2
0
ファイル: enum.c プロジェクト: jaykrell/j
void
DumpResourceDirectoryEntry(
    BYTE* MappedFile,
    size_t Depth,
    IMAGE_RESOURCE_DIRECTORY* TopDirectory,
    IMAGE_RESOURCE_DIRECTORY* ContainingDirectory,
    IMAGE_RESOURCE_DIRECTORY_ENTRY* Entry,
    size_t Index
    )
{
    WCHAR Buffer[20];
    IMAGE_RESOURCE_DIR_STRING_U* String = { 0 };
    size_t Length = { 0 };
    PCWSTR Chars = { 0 };
    ULONG OffsetToDirectory = { 0 };
    ULONG DataIsDirectory = { 0 };

    if (Entry->Name > INT_MAX)
    {
        String = (IMAGE_RESOURCE_DIR_STRING_U*) ((Entry->Name & INT_MAX) + (BYTE*) TopDirectory);
        Chars = String->NameString;
        Length = String->Length;
    }
    else
    {
        Length = _snwprintf(Buffer, NUMBER_OF(Buffer), L"#%hx", Entry->Name);
        Chars = Buffer;
    }
    if (Length > INT_MAX)
        Length = INT_MAX;

    DataIsDirectory = (Entry->OffsetToData > INT_MAX);
    OffsetToDirectory = (Entry->OffsetToData & INT_MAX);

#if 0 // more verbose
    wprintf(
        L"%ls[%lx]:%p:%.*ls IsDirectory:%lx Offset:%lx\n",
        ((Depth != 0) ? GetSpaces(Depth * INDENT) : L"\n"),
        ((ULONG) Index),
        Entry,
        ((int) Length),
        Chars,
        (!! DataIsDirectory),
        OffsetToDirectory
        );
#else
    wprintf(
        L"%ls%.*ls\n",
        GetSpaces(Depth * INDENT),
        ((int) Length),
        Chars
        );
#endif
    if (DataIsDirectory)
    {
        DumpResourceDirectory(
            MappedFile,
            (Depth + 1),
            TopDirectory,
            (IMAGE_RESOURCE_DIRECTORY*) (OffsetToDirectory + (BYTE*) TopDirectory)
            );
    }
}
コード例 #3
0
ファイル: enum.c プロジェクト: jaykrell/j
void
DumpResourceDirectory(
    BYTE* MappedFile,
    size_t Depth,
    IMAGE_RESOURCE_DIRECTORY* TopDirectory,
    IMAGE_RESOURCE_DIRECTORY* Directory
    )
{
    size_t const NumberOfNamedEntries = Directory->NumberOfNamedEntries;
    size_t const NumberOfIdEntries = Directory->NumberOfIdEntries;
    IMAGE_RESOURCE_DIRECTORY_ENTRY* Entries = (IMAGE_RESOURCE_DIRECTORY_ENTRY*) (1 + Directory);
    size_t i = { 0 };

    if (Directory->Characteristics
        | Directory->TimeDateStamp
        | (Directory->MajorVersion & ~4)
        | Directory->MinorVersion)
    { // more verbose
        wprintf(
            L"%lsDirectory:%p Characteristics:%x TimeDateStamp:%x MajorVersion:%x MinorVersion:%x Names:%x Ids:%x\n",
            GetSpaces(Depth * INDENT),
            Directory,
            Directory->Characteristics,
            Directory->TimeDateStamp,
            Directory->MajorVersion,
            Directory->MinorVersion,
            Directory->NumberOfNamedEntries,
            Directory->NumberOfIdEntries
            );
    }
    else
    {
#if 0 // more verbose
        wprintf(
            L"%lsDirectory:%p Names:%x Ids:%x\n",
            GetSpaces(Depth * INDENT),
            Directory,
            Directory->NumberOfNamedEntries,
            Directory->NumberOfIdEntries
            );
#endif
    }
    //Depth += 1;
    if (NumberOfNamedEntries != 0)
    {
#if 0 // more verbose
        if (NumberOfIdEntries != 0)
            wprintf(L"%lsNames\n", GetSpaces(Depth * INDENT));
#endif
        for (i = 0 ; i != NumberOfNamedEntries ; ++i)
        {
            DumpResourceDirectoryEntry(MappedFile, Depth, TopDirectory, Directory, &Entries[i], i);
        }
    }
    if (NumberOfIdEntries != 0)
    {
#if 0 // more verbose
        if (NumberOfNamedEntries != 0)
            wprintf(L"%lsIds\n", GetSpaces(Depth * INDENT));
#endif
        for (i = 0 ; i != NumberOfIdEntries ; ++i)
        {
            DumpResourceDirectoryEntry(MappedFile, Depth, TopDirectory, Directory, &Entries[i + NumberOfNamedEntries], i);
        }
    }
}
コード例 #4
0
void FuncStatsPlugin::Destroy()
{
  //Get the frame count
  uint frameNumber = gliCallBacks->GetFrameNumber();
  uint averageCalls = 0;

  //If two frames have passed, get the average excluding the first frame
  if(frameNumber > 1)
  {
    averageCalls = (uint)((double)(numGLFunctionCalls - numGLCallsFirstFrame) / (double)(frameNumber-1));
  }

  //Handle unlikely event of exceeding 2^32 number of calls (can happen if left running for hours)
  char numFuncCallsStr[100];
  
#ifdef GLI_BUILD_WINDOWS
  _i64toa(numGLFunctionCalls, numFuncCallsStr, 10);
#endif //GLI_BUILD_WINDOWS

#ifdef GLI_BUILD_LINUX
  //DT_TODO: Test this
  sprintf(numFuncCallsStr, "%lld", numGLFunctionCalls);
#endif //GLI_BUILD_LINUX

  //Dump the total call count and average per frame (excluding first frame of xxx calls)
  LOGERR(("\n======= OpenGL function call statistics =========="));
  LOGERR((" Total GL calls: %s", numFuncCallsStr));
  LOGERR((" Number of frames: %u  Average: %u calls/frame (excluding first frame count of %u)",frameNumber, averageCalls, (uint)numGLCallsFirstFrame));

  //If dumping by call number
  if(functionsCountSort)
  {
    //Sort the array based on function call count
    sort(functionDataArray.begin(), functionDataArray.end(), FunctionCallData::SortByCount);
    
    LOGERR(("\n======= OpenGL function calls by call count =========="));

    //Loop and dump the function data 
    for(uint i=0; i<functionDataArray.size(); i++)
    {
      //Only dump functions that have been called
      if(functionDataArray[i].funcCallCount > 0)
      {
        LOGERR(("%s %s %u",functionDataArray[i].functionName.c_str(), 
                           GetSpaces(functionDataArray[i].functionName).c_str(),
                           functionDataArray[i].funcCallCount)); 
      }
    }
  }

  //If dumping stats by function name
  if(functionsNameSort)
  {
    //Sort the array based on function name
    sort(functionDataArray.begin(), functionDataArray.end(), FunctionCallData::SortByName);
    
    LOGERR(("\n======= OpenGL function calls by name =========="));

    //Loop and dump the function data 
    for(uint i=0; i<functionDataArray.size(); i++)
    {
      //Only dump functions that have been called
      if(functionDataArray[i].funcCallCount > 0)
      {
        LOGERR(("%s %s %u",functionDataArray[i].functionName.c_str(), 
                           GetSpaces(functionDataArray[i].functionName).c_str(),
                           functionDataArray[i].funcCallCount)); 
      }
    }
  }

  //Destroy this plugin
  delete this;
}