예제 #1
0
CString GitRepository::GetRelativePath(const CString& path) const
{
    if(!StartsWith(path, m_root)) {
        throw std::invalid_argument("path is not in the repository");
    }

    return path.Mid(m_root.GetLength() + 1);
}
예제 #2
0
ob::PlannerStatus KrisLibraryOMPLPlanner::solve (const ob::PlannerTerminationCondition &ptc)
{
  if(!planner) {
    //may have had a previous clear() call
    //fprintf(stderr,"KrisLibraryOMPLPlanner::solve(): Warning, setup() not called yet\n");
    setup();
    if(!planner) 
      return ob::PlannerStatus(ob::PlannerStatus::UNKNOWN);
  }
  ob::ProblemDefinitionPtr pdef = this->getProblemDefinition();
  //how much to plan?
  int increment = (StartsWith(factory.type.c_str(),"fmm") ? 1 : 50);
  Real oldBest = Inf;
  bool optimizing = planner->IsOptimizing();
  double desiredCost = 0;
  if(optimizing) {
    if(pdef->getOptimizationObjective() != NULL)
      desiredCost = pdef->getOptimizationObjective()->getCostThreshold().value();
    else 
      OMPL_INFORM("%s: No optimization objective specified. Defaulting to optimizing path length for the allowed planning time.", getName().c_str());
  }
  while(!ptc()) {
    if(planner->IsSolved()) {
      //convert solution to OMPL solution
      MilestonePath path;
      planner->GetSolution(path);
      if(optimizing) {
        //optimizing
        Real cost = path.Length();
        if(cost < oldBest) {
          oldBest = cost;
          if(cost < desiredCost) {
            ob::PathPtr pptr(ToOMPL(si_,path));
            this->getProblemDefinition()->addSolutionPath(pptr);
            return ob::PlannerStatus(true,false);
          }
        }
      }
      else {
        //non-optimizing
        ob::PathPtr pptr(ToOMPL(si_,path));
        this->getProblemDefinition()->addSolutionPath(pptr);
        return ob::PlannerStatus(true,false);        
      }
    }

    planner->PlanMore(increment); 
  }
  if(planner->IsSolved()) {
    //convert solution to OMPL solution
    MilestonePath path;
    planner->GetSolution(path);
    ob::PathPtr pptr(ToOMPL(si_,path));
    this->getProblemDefinition()->addSolutionPath(pptr);
    return ob::PlannerStatus(true,false);
  }
  return ob::PlannerStatus(false,false);
}
예제 #3
0
LRESULT Skype::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
  if (uMsg == WM_COPYDATA) {
    if (hwnd_skype == nullptr ||
        hwnd_skype != reinterpret_cast<HWND>(wParam))
      return FALSE;
    
    auto pCDS = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
    wstring command = ToUTF8(reinterpret_cast<LPCSTR>(pCDS->lpData));
    LOG(LevelDebug, L"Received WM_COPYDATA: " + command);

    wstring profile_command = L"PROFILE RICH_MOOD_TEXT ";
    if (StartsWith(command, profile_command)) {
      wstring mood = command.substr(profile_command.length());
      if (mood != current_mood && mood != previous_mood) {
        LOG(LevelDebug, L"Saved previous mood message: " + mood);
        previous_mood = mood;
      }
    }

    return TRUE;

  } else if (uMsg == wm_attach) {
    hwnd_skype = nullptr;
    
    switch (lParam) {
      case SKYPECONTROLAPI_ATTACH_SUCCESS:
        LOG(LevelDebug, L"Attach succeeded.");
        hwnd_skype = reinterpret_cast<HWND>(wParam);
        GetMoodText();
        if (!current_mood.empty())
          SetMoodText(current_mood);
        break;
      case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
        LOG(LevelDebug, L"Waiting for user confirmation...");
        break;
      case SKYPECONTROLAPI_ATTACH_REFUSED:
        LOG(LevelError, L"User denied access to client.");
        break;
      case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
        LOG(LevelError, L"API is not available.");
        break;
      case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
        LOG(LevelDebug, L"API is now available.");
        Discover();
        break;
      default:
        LOG(LevelDebug, L"Received unknown message.");
        break;
    }

    return TRUE;

  } else if (uMsg == wm_discover) {
    LOG(LevelDebug, L"Received SkypeControlAPIDiscover message.");
  }

  return FALSE;
}
예제 #4
0
파일: time.cpp 프로젝트: IamKenshin/taiga
time_t ConvertRfc822(const std::wstring& datetime) {
  // See: https://tools.ietf.org/html/rfc822#section-5
  static const std::wregex pattern(
      L"(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun), )?"
      L"(\\d{1,2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\\d{2,4}) "
      L"(\\d{2}):(\\d{2})(?::(\\d{2}))? "
      L"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[ZAMNY]|[+-]\\d{4})");

  static const std::vector<std::wstring> months{
    L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", 
    L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
  };

  std::match_results<std::wstring::const_iterator> m;
  time_t result = -1;

  if (std::regex_match(datetime, m, pattern)) {
    tm t = {0};

    t.tm_mday = ToInt(m[2].str());
    t.tm_mon = std::distance(months.begin(),
        std::find(months.begin(), months.end(), m[3].str()));
    t.tm_year = ToInt(m[4].str());
    if (t.tm_year > 1900)
      t.tm_year -= 1900;

    t.tm_hour = ToInt(m[5].str());
    t.tm_min = ToInt(m[6].str());
    if (m[7].matched)
      t.tm_sec = ToInt(m[7].str());

    // TODO: Handle other time zones
    if (StartsWith(m[8].str(), L"+") || StartsWith(m[8].str(), L"-")) {
      int sign = StartsWith(m[8].str(), L"+") ? 1 : -1;
      t.tm_hour += sign * ToInt(m[8].str().substr(1, 3));
      t.tm_min += sign * ToInt(m[8].str().substr(3, 5));
    }
    NeutralizeTimezone(t);
    t.tm_isdst = -1;

    result = std::mktime(&t);
  }

  return result;
}
예제 #5
0
bool
UniString::Equals(const uni_char *buf, size_t length /* = OpDataUnknownLength */) const
{
	if (length == OpDataUnknownLength)
		length = uni_strlen(buf);
	if (length != Length())
		return false;
	return StartsWith(buf, length);
}
예제 #6
0
bool FString::RemoveFromStart(const char* Text)
{
	if (StartsWith(Text))
	{
		RemoveAt(0, strlen(Text));
		return true;
	}
	return false;
}
예제 #7
0
void CSecurity::SetHashMap(CString sURN, BYTE nIndex)
{
	if ( ! nIndex || sURN.GetLength() < 36 )
		return;

	const CString strHash = sURN.Mid( sURN.ReverseFind( _T(':') ) + 1 );

	if ( StartsWith( sURN, _PT("urn:sha1:") ) )
		m_HashMap[urnSHA][ strHash ] = nIndex;
	else if ( StartsWith( sURN, _PT("urn:tree:") ) )
		m_HashMap[urnTiger][ strHash ] = nIndex;
	else if ( StartsWith( sURN, _PT("urn:ed2k:") ) )
		m_HashMap[urnED2K][ strHash ] = nIndex;
	else if ( StartsWith( sURN, _PT("urn:bth:") ) )
		m_HashMap[urnBTH][ strHash ] = nIndex;
	else if ( StartsWith( sURN, _PT("urn:md5:") ) )
		m_HashMap[urnMD5][ strHash ] = nIndex;
}
예제 #8
0
static void AddPluginName(const char *csPluginName, const std::string & csPath)
{
	if (StartsWith(csPluginName, "siscardplugin1") || StartsWith(csPluginName, "libsiscardplugin1"))
	{
		const char *ptr1 = strstr(csPluginName, "__");
		const char *ptr2 = (ptr1 == NULL ? NULL : strstr(ptr1 + 2, "__"));
		if (ptr2 != NULL && ptr2 - ptr1 < 200)
		{
			ptr1 += 2;
			char csReaderName[200];
			memcpy(csReaderName, ptr1, ptr2 - ptr1);
			csReaderName[ptr2 - ptr1] = '\0';
			if (memcmp(csReaderName, "ACS_ACR38U", sizeof("ACS_ACR38U"))==0)	// r269
				memcpy(csReaderName, "ACS ACR38U", sizeof("ACS ACR38U"));
			AddPluginInfo(csPath, csReaderName);
		}
	}
}
예제 #9
0
/** Obtain the SIS-data via the plugin library
*/
CCard * SISPluginReadData(const char *csReader, SCARDHANDLE hCard,
	CContext *poContext, CPinpad *poPinpad,
	CDynamicLib &oCardPluginLib)
{
	CCard *poCard = NULL;

	if (!m_bPluginInfosOK)
		GetPluginInfos();

	for (size_t i = 0; poCard == NULL && i < PlugInCount(); i++)
	{
		if (!StartsWith(csReader, GetPlugInReader(i).c_str()))
			continue;

		std::string csPluginPath = GetPlugInPath(i);
		unsigned long ulErr = oCardPluginLib.Open(csPluginPath);
		if (ulErr != EIDMW_OK)
		{
			MWLOG(LEV_ERROR, MOD_CAL, L"Couldn't load SIS plugin \"%ls\", err = 0x%0x",
				utilStringWiden(csPluginPath).c_str(), ulErr);
			continue;
		}

		SISPLUGINREADCARD pSisPluginReadCard =
				(SISPLUGINREADCARD) oCardPluginLib.GetAddress("SISPluginReadCard");
		if (pSisPluginReadCard == NULL)
		{
			MWLOG(LEV_ERROR, MOD_CAL, L"Function \"SISPluginReadCard\" not found in \"%ls\"",
				utilStringWiden(csPluginPath).c_str(), ulErr);
			continue;
		}

		tPCSCfunctions xPCSCFunctions;
		GetPCSCFunctions(&poContext->m_oPCSC, &xPCSCFunctions);

		unsigned char tucData[500];
		SCARDHANDLE hCrd = hCard;
		long lErr = pSisPluginReadCard(SISPLUGIN_VERSION, &xPCSCFunctions,
			csReader, &hCrd, tucData, 0, NULL);
		hCard = (unsigned long) hCrd;

		if (lErr != 0)
		{
			MWLOG(LEV_ERROR, MOD_CAL, L"Function \"SISPluginReadCard\" in \"%ls\" returned 0x%0x (%d)",
				utilStringWiden(csPluginPath).c_str(), lErr, lErr);
			continue;
		}

		MWLOG(LEV_DEBUG, MOD_CAL, L"Using SIS plugin \"%ls\"",
			utilStringWiden(csPluginPath).c_str());
		poCard = new CSISCard(hCard, poContext, poPinpad, CByteArray(tucData, 404));

		break;
	}

	return poCard;;
}
void testNoCommand() {
    // Help.
    // =====
    {
        std::regex output("OpenSim: musculoskeletal" + RE_ANY +
                          "Pass -h or --help" + RE_ANY);
        testCommand("", EXIT_SUCCESS, output);
        testCommand("-h", EXIT_SUCCESS, output);
        testCommand("-help", EXIT_SUCCESS, output);
    }

    // Version.
    // ========
    {
        std::regex output("OpenSim version (?:.*), build date (?:.*)\n");
        testCommand("-V", EXIT_SUCCESS, output);
        testCommand("--version", EXIT_SUCCESS, output);
    }

    // Library option.
    // ===============
    // Syntax errors.
    testCommand("-L", EXIT_FAILURE, StartsWith("-L requires an argument"));
    testCommand("--library", EXIT_FAILURE, 
            StartsWith("--library requires an argument"));
    // Must specify a command; can't only list a library to load.
    {
        StartsWith output("Arguments did not match expected patterns");
        // All of these are otherwise valid options for specify libraries to
        // load.
        testCommand("-L x", EXIT_FAILURE, output);
        testCommand("--library x", EXIT_FAILURE, output);
        testCommand("-L=x", EXIT_FAILURE, output);
        testCommand("--library=y", EXIT_FAILURE, output);
        testCommand("-L x --library y -L z", EXIT_FAILURE, output);
        testCommand("-L=x --library=y -L=z", EXIT_FAILURE, output);
    }

    // Unrecognized command.
    // =====================
    testCommand("bleepbloop", EXIT_FAILURE, 
            "'bleepbloop' is not an opensim-cmd command. "
            "See 'opensim-cmd --help'.\n");
}
void testPrintXML() {
    // Help.
    // =====
    {
        StartsWith output("Print a template XML file ");
        testCommand("print-xml -h", EXIT_SUCCESS, output);
        testCommand("print-xml -help", EXIT_SUCCESS, output);
    }

    // Error messages.
    // ===============
    testCommand("print-xml", EXIT_FAILURE,
            StartsWith("Arguments did not match expected patterns"));
    testCommand("print-xml x y z", EXIT_FAILURE,
            StartsWith("Unexpected argument: print-xml, x, y, z"));
    testCommand("print-xml bleepbloop", EXIT_FAILURE,
        "There is no tool or registered concrete class named 'bleepbloop'.\n"
        "Did you intend to load a plugin (with --library)?\n");
    testCommand("print-xml bleepbloop y", EXIT_FAILURE,
        "There is no tool or registered concrete class named 'bleepbloop'.\n"
        "Did you intend to load a plugin (with --library)?\n");

    // Successful input.
    // =================
    testCommand("print-xml cmc", EXIT_SUCCESS,
            "Printing 'default_Setup_CMCTool.xml'.\n");
    testCommand("print-xml Millard2012EquilibriumMuscle", EXIT_SUCCESS,
            "Printing 'default_Millard2012EquilibriumMuscle.xml'.\n");
    testCommand("print-xml cmc default_cmc_setup.xml", EXIT_SUCCESS,
            "Printing 'default_cmc_setup.xml'.\n");

    // Tool names are case-insensitive.
    // ================================
    testCommand("print-xml CmC", EXIT_SUCCESS,
            "Printing 'default_Setup_CMCTool.xml'.\n");
    testCommand("print-xml FORwarD", EXIT_SUCCESS,
            "Printing 'default_Setup_ForwardTool.xml'.\n");
    testCommand("print-xml Analyze default_analyze_setup.xml", EXIT_SUCCESS,
            "Printing 'default_analyze_setup.xml'.\n");

    // Library option.
    // ===============
    testLoadPluginLibraries("print-xml");
}
예제 #12
0
파일: SecureRule.cpp 프로젝트: GetEnvy/Envy
BOOL CSecureRule::Match(const CEnvyFile* pFile) const
{
	if ( m_nType == srAddress || m_nType == srContentRegExp || m_nType == srExternal || ! ( pFile && m_pContent ) )
		return FALSE;

	if ( m_nType == srSizeType )
	{
		if ( pFile->m_nSize == 0 || pFile->m_nSize == SIZE_UNKNOWN )
			return FALSE;

		LPCTSTR pszExt = PathFindExtension( (LPCTSTR)pFile->m_sName );
		if ( *pszExt != L'.' )
			return FALSE;
		pszExt++;

		CString strFilter = (LPCTSTR)m_pContent;
		strFilter = strFilter.Mid( 5 );		// "size:"
		if ( ! StartsWith( strFilter, pszExt ) )
			return FALSE;

		strFilter = strFilter.Mid( strFilter.Find( L':' ) + 1 );

		if ( strFilter.Find( L':' ) > 0 )
		{
			QWORD nLower, nUpper, nSize = pFile->m_nSize;
			_stscanf( (LPCTSTR)strFilter, L"%I64i:%I64i", &nLower, &nUpper );
			return nSize >= nLower && nSize <= nUpper;
		}
		if ( strFilter.Find( L'-' ) > 0 )
		{
			QWORD nLower, nUpper, nSize = pFile->m_nSize;
			_stscanf( (LPCTSTR)strFilter, L"%I64i-%I64i", &nLower, &nUpper );
			return nSize >= nLower && nSize <= nUpper;
		}

		CString strCompare;
		strCompare.Format( L"size:%s:%I64i", pszExt, pFile->m_nSize );
		return strCompare == (CString)m_pContent;
	}

	if ( m_nType == srContentHash )
	{
		LPCTSTR pszHash = m_pContent;
		if ( m_nContentLength < 30 || _tcsnicmp( pszHash, L"urn:", 4 ) != 0 )
			return FALSE;

		return
			( pFile->m_oSHA1  && pFile->m_oSHA1.toUrn() == pszHash ) ||		// Not Match( pFile->m_oSHA1.toUrn() )
			( pFile->m_oTiger && pFile->m_oTiger.toUrn() == pszHash ) ||
			( pFile->m_oED2K  && pFile->m_oED2K.toUrn() == pszHash ) ||
			( pFile->m_oBTH   && pFile->m_oBTH.toUrn() == pszHash ) ||
			( pFile->m_oMD5   && pFile->m_oMD5.toUrn() == pszHash );
	}

	return Match( pFile->m_sName );
}
예제 #13
0
파일: String.cpp 프로젝트: kbinani/dxrip
String String::RemovePrefix(const String &StartCandidate) const
{
    Assert(StartsWith(StartCandidate), "Removing invalid prefix");
    String Result = *this;
    for(UINT i = 0; i < StartCandidate._Length; i++)
    {
        Result.PopFront();
    }
    return Result;
}
void testRunTool() {
    // Help.
    // =====
    {
        StartsWith output("Run a tool ");
        testCommand("run-tool -h", EXIT_SUCCESS, output);
        testCommand("run-tool -help", EXIT_SUCCESS, output);
    }

    // Error messages.
    // ===============
    testCommand("run-tool", EXIT_FAILURE,
            StartsWith("Arguments did not match expected patterns"));
    testCommand("run-tool putes.xml", EXIT_FAILURE,
            StartsWith("SimTK Exception thrown at"));
    // We use print-xml to create a setup file that we can try to run.
    // (We are not really trying to test print-xml right now.)
    testCommand("print-xml cmc testruntool_cmc_setup.xml", EXIT_SUCCESS,
            "Printing 'testruntool_cmc_setup.xml'.\n");
    // This fails because this setup file doesn't have much in it.
    testCommand("run-tool testruntool_cmc_setup.xml", EXIT_FAILURE,
            std::regex(RE_ANY + "(No model file was specified)" + RE_ANY));
    // Similar to the previous two commands, except for scaling
    // (since ScaleTool goes through a different branch of the code).
    testCommand("print-xml scale testruntool_scale_setup.xml", EXIT_SUCCESS,
            "Printing 'testruntool_scale_setup.xml'.\n");
    // This fails because this setup file doesn't have much in it.
    testCommand("run-tool testruntool_scale_setup.xml", EXIT_FAILURE,
            std::regex("(Preparing to run ScaleTool.)" + RE_ANY +
                       "(Processing subject default)" + RE_ANY));
    // Now we'll try loading a valid OpenSim XML file that is *not* a Tool
    // setup file, and we get a helpful error.
    // (We are not really trying to test print-xml right now.)
    testCommand("print-xml Model testruntool_Model.xml", EXIT_SUCCESS,
            "Printing 'testruntool_Model.xml'.\n");
    testCommand("run-tool testruntool_Model.xml", EXIT_FAILURE,
            "The provided file 'testruntool_Model.xml' does not define "
            "an OpenSim Tool. Did you intend to load a plugin?\n");

    // Library option.
    // ===============
    testLoadPluginLibraries("run-tool");
}
예제 #15
0
static bool SkipPrefix(const char*& p, const char (&prefix)[N])
{
    if (StartsWith(p, prefix))
    {
        p += N - 1; // skip
        return true;
    }

    return false;
}
예제 #16
0
static bool SkipPrefix(const char*& p, const string& prefix)
{
    if (StartsWith(p, prefix))
    {
        p += prefix.length(); // skip
        return true;
    }

    return false;
}
예제 #17
0
파일: Config.c 프로젝트: punktniklas/NiKom
int handleSystemConfigStatusSection(char *line, BPTR fh) {
  int status;
  char buffer[100];

  for(;;) {
    if(!IzDigit(line[6])) {
      printf("Invalid config line, no digit after 'STATUS': %s\n", line);
      return 0;
    }
    status = atoi(&line[6]);
    if(status < 0 || status > 100) {
      printf("Invalid config file, %d is not a valid status level: %s\n",
             status, line);
      return 0;
    }
    for(;;) {
      if((line = FGets(fh, buffer, 99)) == NULL) {
        printf("Invalid config file, 'ENDSTATUS' not found.\n");
        return 0;
      }
      if(line[0] == '#' || line[0] == '*' || line[0] == '\n') {
        continue;
      }
      if(StartsWith(line, "ENDSTATUS")) {
        return 1;
      } else if(isMatchingConfigLine(line, "MAXTID") || isMatchingConfigLine(line, "MAXTIME")) {
        if(!GetShortCfgValue(line, &Servermem->cfg.maxtid[status])) {
          return 0;
        }
      } else if(isMatchingConfigLine(line, "ULDL")) {
        if(!GetCharCfgValue(line, &Servermem->cfg.uldlratio[status])) {
          return 0;
        }
      } else if(StartsWith(line, "STATUS")) {
        break;
      } else {
        printf("Invalid config line in status section: %s\n", line);
        return 0;
      }
    }
  }
}
예제 #18
0
BYTE CSecurity::GetHashMap(CString sURN)
{
	if ( sURN.GetLength() < 36 || ( sURN[0] != _T('u') && sURN[0] != _T('U') ) )
		return 0;

	const CString strHash = sURN.Mid( sURN.ReverseFind( _T(':') ) + 1 );

	if ( StartsWith( sURN, _PT("urn:sha1:") ) )
		return m_HashMap[urnSHA].count( strHash ) ? m_HashMap[urnSHA][ strHash ] : 0;
	if ( StartsWith( sURN, _PT("urn:tree:") ) )
		return m_HashMap[urnTiger].count( strHash ) ? m_HashMap[urnTiger][ strHash ] : 0;
	if ( StartsWith( sURN, _PT("urn:ed2k:") ) )
		return m_HashMap[urnED2K].count( strHash ) ? m_HashMap[urnED2K][strHash ] : 0;
	if ( StartsWith( sURN, _PT("urn:bth:") ) )
		return m_HashMap[urnBTH].count( strHash ) ? m_HashMap[urnBTH][ strHash ] : 0;
	if ( StartsWith( sURN, _PT("urn:md5:") ) )
		return m_HashMap[urnMD5].count( strHash ) ? m_HashMap[urnMD5][ strHash ] : 0;

	return 0;
}
예제 #19
0
bool
IsVP9CodecString(const nsAString& aCodec)
{
  uint8_t profile = 0;
  uint8_t level = 0;
  uint8_t bitDepth = 0;
  return aCodec.EqualsLiteral("vp9") ||
         aCodec.EqualsLiteral("vp9.0") ||
         (StartsWith(NS_ConvertUTF16toUTF8(aCodec), "vp09") &&
          ExtractVPXCodecDetails(aCodec, profile, level, bitDepth));
}
예제 #20
0
void InitLogging(char* argv[]) {
  if (gInitialized) {
    return;
  }

  gInitialized = true;

  // Stash the command line for later use. We can use /proc/self/cmdline on
  // Linux to recover this, but we don't have that luxury on the Mac/Windows,
  // and there are a couple of argv[0] variants that are commonly used.
  if (argv != nullptr) {
    gProgramInvocationName.reset(new std::string(basename(argv[0])));
  }

  const char* tags = getenv("ANDROID_LOG_TAGS");
  if (tags == nullptr) {
    return;
  }

  std::vector<std::string> specs = Split(tags, " ");
  for (size_t i = 0; i < specs.size(); ++i) {
    // "tag-pattern:[vdiwefs]"
    std::string spec(specs[i]);
    if (spec.size() == 3 && StartsWith(spec, "*:")) {
      switch (spec[2]) {
        case 'v':
          gMinimumLogSeverity = VERBOSE;
          continue;
        case 'd':
          gMinimumLogSeverity = DEBUG;
          continue;
        case 'i':
          gMinimumLogSeverity = INFO;
          continue;
        case 'w':
          gMinimumLogSeverity = WARNING;
          continue;
        case 'e':
          gMinimumLogSeverity = ERROR;
          continue;
        case 'f':
          gMinimumLogSeverity = FATAL;
          continue;
        // liblog will even suppress FATAL if you say 's' for silent, but that's
        // crazy!
        case 's':
          gMinimumLogSeverity = FATAL;
          continue;
      }
    }
    LOG(FATAL) << "unsupported '" << spec << "' in ANDROID_LOG_TAGS (" << tags
               << ")";
  }
}
예제 #21
0
파일: glgen.cpp 프로젝트: MetricPanda/glgen
static inline
int ParseFile(char* Filename, GLArbToken* ArbHash,
               GLToken* FunctionsHash, unsigned int* FunctionCount,
               GLToken* DefinesHash, unsigned int* DefinesCount,
               GLSettings* Settings)
{
  char* Data = ReadEntireFile(Filename);
  int Success = 0;
  if (Data)
  {
    GLTokenizer Tokenizer;
    Tokenizer.At = Data;
    while(*Tokenizer.At)
    {
      GLToken Token = ParseToken(&Tokenizer);
      if (StartsWith(Token.Value, "gl") && IsUpperCase(Token.Value.Chars[2]))
      {
        if (!Contains(FunctionsHash, Token) && IsKnownOrIgnoredToken(ArbHash, &Token, Settings))
        {
          AddToken(FunctionsHash, Token);
          *FunctionCount += 1;
        }
      }
      if (StartsWith(Token.Value, "GL_"))
      {
        if (!Contains(DefinesHash, Token) && IsKnownOrIgnoredToken(ArbHash, &Token, Settings))
        {
          AddToken(DefinesHash, Token);
          *DefinesCount += 1;
        }
      }
    }
    free(Data);
    Success = 1;
  }
  else
  {
    fprintf(stderr, "Couldn't open file %s", Filename);
  }
  return Success;
}
예제 #22
0
파일: string_utils.cpp 프로젝트: whrool/Net
void TrimPrefixSelf(std::string& str, const std::string& strPrefix,
                    bool bIgnoreCase /*= false*/, bool bRecursive /*= false*/)
{
    if (str.empty() || strPrefix.empty())
        return;
    do 
    {
        if (!StartsWith(str, strPrefix, bIgnoreCase))
            break;
        str.erase(0, strPrefix.length());
    } while (bRecursive);
}
	virtual EImageFormat::Type DetectImageFormat( const void* CompressedData, int32 CompressedSize ) override
	{
		EImageFormat::Type Format = EImageFormat::Invalid;
		if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_PNG))
		{
			Format = EImageFormat::PNG;
		}
		else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_JPEG))
		{
			Format = EImageFormat::JPEG; // @Todo: Should we detect grayscale vs non-grayscale?
		}
		else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_BMP))
		{
			Format = EImageFormat::BMP;
		}
		else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_ICO))
		{
			Format = EImageFormat::ICO;
		}
		else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_EXR))
		{
			Format = EImageFormat::EXR;
		}
		else if (StartsWith((uint8*) CompressedData, CompressedSize, IMAGE_MAGIC_ICNS))
		{
			Format = EImageFormat::ICNS;
		}

		return Format;
	}
예제 #24
0
파일: fileinfo.c 프로젝트: bailey27/dokany
VOID FlushAllCachedFcb(__in PDokanFCB fcbRelatedTo,
                       __in_opt PFILE_OBJECT fileObject) {
  PLIST_ENTRY thisEntry, nextEntry, listHead;
  PDokanFCB fcb = NULL;

  if (fcbRelatedTo == NULL) {
    return;
  }

  DDbgPrint("  FlushAllCachedFcb\n");

  if (!DokanFCBFlagsIsSet(fcbRelatedTo, DOKAN_FILE_DIRECTORY)) {
    DDbgPrint("  FlushAllCachedFcb file passed in. Flush only this file %wZ.\n", &fcbRelatedTo->FileName);
    FlushFcb(fcbRelatedTo, fileObject);
    return;
  }

  KeEnterCriticalRegion();
  ExAcquireResourceExclusiveLite(&fcbRelatedTo->Vcb->Resource, TRUE);

  listHead = &fcbRelatedTo->Vcb->NextFCB;

  for (thisEntry = listHead->Flink; thisEntry != listHead;
       thisEntry = nextEntry) {

    nextEntry = thisEntry->Flink;

    fcb = CONTAINING_RECORD(thisEntry, DokanFCB, NextFCB);

    if (DokanFCBFlagsIsSet(fcb, DOKAN_FILE_DIRECTORY)) {
      DDbgPrint("  FlushAllCachedFcb %wZ is directory so skip it.\n",
                &fcb->FileName);
      continue;
    }

    DDbgPrint("  FlushAllCachedFcb check %wZ if is related to %wZ\n",
              &fcb->FileName, &fcbRelatedTo->FileName);

    if (StartsWith(&fcb->FileName, &fcbRelatedTo->FileName)) {
      DDbgPrint("  FlushAllCachedFcb flush %wZ if flush is possible.\n",
                &fcb->FileName);
      FlushFcb(fcb, NULL);
    }

    fcb = NULL;
  }

  ExReleaseResourceLite(&fcbRelatedTo->Vcb->Resource);
  KeLeaveCriticalRegion();

  DDbgPrint("  FlushAllCachedFcb finished\n");
}
예제 #25
0
    bool Tokenizer::isOperatorSubstring(string chp)
    {
        unsigned int i = 0;
        for (i = 0; i < mOperators.size(); ++i)
        {
            if (StartsWith(mOperators[i], chp))
            {
                return true;
            }
        }

        return false;
    }
예제 #26
0
void CTorrentTrackersPage::UpdateInterface()
{
	int nItem = m_wndTrackers.GetNextItem( -1, LVNI_SELECTED );
	m_wndDel.EnableWindow( ( nItem != -1 ) );
//	m_wndRename.EnableWindow( ( nItem != -1 ) );

	// Find item with current tracker...
	LVFINDINFO fi =
	{
		LVFI_STRING,
		m_sOriginalTracker
	};
	int nCurrentItem = m_wndTrackers.FindItem( &fi );

	// ...and mark it
	LVITEM lvi =
	{
		LVIF_PARAM | LVIF_IMAGE
	};
	int nCount = m_wndTrackers.GetItemCount();
	for ( int i = 0 ; i < nCount ; ++i )
	{
		CString strTracker = m_wndTrackers.GetItemText( i, 0 );
		const UINT nIconID = ( i == nCurrentItem ) ? ID_MEDIA_SELECT :
			( StartsWith( strTracker, _PT("http://") ) || StartsWith( strTracker, _PT("udp://") ) ) ? ID_DOWNLOADS_URI : ID_DISCOVERY_BLOCKED;
		lvi.iItem = i;
		lvi.iImage = CoolInterface.ImageForID( nIconID );
		lvi.lParam = ( i == nCurrentItem ) ? TRUE : FALSE;
		m_wndTrackers.SetItem( &lvi );
	}

	if ( nCount == 0 )
		m_wndTrackerMode.SetCurSel( CBTInfo::tNull );
	else if ( nCount == 1 )
		m_wndTrackerMode.SetCurSel( CBTInfo::tSingle );
	m_wndTrackerMode.EnableWindow( nCount > 1 );

	UpdateWindow();
}
예제 #27
0
void
fgStringTest(const FgArgs &)
{
    Construct();
    Copy();
    Assign();
    Append();
    Comparisons();
    Encoding();
    Replace();
    Compare();
    Split();
    StartsWith();
}
예제 #28
0
		const char* GetNext(bool* isDirectory){
			if (!HasNext())
				return "";

			if (!pack) {
				boost::filesystem::path path;
				if (mRecursive) {
					auto entity = *mRecursiveIterator;
					mRecursiveIterator++;
					path = entity.path();
				}
				else {
					auto entity = *mIterator;
					mIterator++;
					path = entity.path();
				}

				if (path.empty())
					return "";

				mLastFile = path._tgeneric_string();
				if (isDirectory)
					*isDirectory = boost::filesystem::is_directory(path);
				return mLastFile.c_str();
			}
			else {
				for (unsigned i = current_pack_index; i < pack->headers.size(); ++i) {
					auto& h = pack->headers[i];
					// pack path = Data/actors.fba
					// pack_parent_path = Data/
					// file_path = actors/something.lua
					// output_path = pack_parent_path + file_path = Data/actors/something.lua
					auto output_path = pack_parent_path + h.path;
					if (StartsWith(output_path, path)) {
						if (!mRecursive) {
							auto file = output_path.substr(path.size());
							if (file.find('/') != std::string::npos) {
								continue;
							}
						}
						current_pack_index = i+1;
						mLastFile = output_path;
						if (isDirectory)
							*isDirectory = false;
						return mLastFile.c_str();
					}
				}
				return "";
			}
		}
예제 #29
0
BOOL CSecurity::IsDenied(LPCTSTR pszContent)
{
	if ( CString(pszContent).GetLength() > 30 && StartsWith( pszContent, _PT("urn:") ) )
	{
		if ( BYTE nIndex = GetHashMap( pszContent ) )
		{
			if ( CSecureRule* pRule = GetRuleByIndex( nIndex ) )
			{
				pRule->m_nToday ++;
				pRule->m_nEver ++;
				if ( pRule->m_nAction == CSecureRule::srDeny )   return TRUE;
				if ( pRule->m_nAction == CSecureRule::srAccept ) return FALSE;
			}
		}

		return m_bDenyPolicy;
	}

	const DWORD tNow = static_cast< DWORD >( time( NULL ) );

	CQuickLock oLock( m_pSection );

	for ( POSITION pos = GetIterator() ; pos ; )
	{
		POSITION posLast = pos;
		CSecureRule* pRule = GetNext( pos );

		if ( pRule->IsExpired( tNow ) )
		{
			m_pRules.RemoveAt( posLast );
			delete pRule;
		}
		else if ( pRule->Match( pszContent ) )
		{
			pRule->m_nToday ++;
			pRule->m_nEver ++;

			// Add 5 min penalty for early access
			if ( pRule->m_nExpire > CSecureRule::srSession &&
				pRule->m_nExpire < tNow + 300 )
				pRule->m_nExpire = tNow + 300;

			if ( pRule->m_nAction == CSecureRule::srDeny )   return TRUE;
			if ( pRule->m_nAction == CSecureRule::srAccept ) return FALSE;
		}
	}

	return m_bDenyPolicy;
}
예제 #30
0
파일: Playlist.c 프로젝트: suborb/reelvdr
bool cPlaylist::RemoveDirTree(const std::string& fullpath)
{
    unsigned int i = 0;
    bool found = false;

    for ( ; i < Size(); ++i)
        if (StartsWith(At(i)->FullPath(), fullpath)) 
        {
            At(i)->SetNotInPlaylist();
            list_.erase( list_.begin() + i);
            SetChanged();
            found = true;
        }// if

    return found;
}