void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
{
    if (!isLocal())
        addSubresourceURL(urls, styleSheet->completeURL(m_resource));
}
Beispiel #2
0
void SecurityOrigin::enforceFilePathSeparation()
{
    ASSERT(isLocal());
    m_enforceFilePathSeparation = true;
}
bool VariableTable::isLocal(const string &name) const {
  return isLocal(getSymbol(name));
}
Beispiel #4
0
const char *DebuggerProxy::getThreadType() const {
  TRACE(2, "DebuggerProxy::getThreadType\n");
  return isLocal() ? "Command Line Script" : "Dummy Sandbox";
}
Beispiel #5
0
void
Node::nfdRegisterPrefix
  (uint64_t registeredPrefixId, const ptr_lib::shared_ptr<const Name>& prefix,
   const OnInterestCallback& onInterest, const OnRegisterFailed& onRegisterFailed,
   const ForwardingFlags& flags, KeyChain& commandKeyChain,
   const Name& commandCertificateName, WireFormat& wireFormat, Face* face)
{
  if (!&commandKeyChain)
    throw runtime_error
      ("registerPrefix: The command KeyChain has not been set. You must call setCommandSigningInfo.");
  if (commandCertificateName.size() == 0)
    throw runtime_error
      ("registerPrefix: The command certificate name has not been set. You must call setCommandSigningInfo.");

  ControlParameters controlParameters;
  controlParameters.setName(*prefix);
  controlParameters.setForwardingFlags(flags);

  ptr_lib::shared_ptr<Interest> commandInterest(new Interest());
  if (isLocal()) {
    commandInterest->setName(Name("/localhost/nfd/rib/register"));
    // The interest is answered by the local host, so set a short timeout.
    commandInterest->setInterestLifetimeMilliseconds(2000.0);
  }
  else {
    commandInterest->setName(Name("/localhop/nfd/rib/register"));
    // The host is remote, so set a longer timeout.
    commandInterest->setInterestLifetimeMilliseconds(4000.0);
  }
  // NFD only accepts TlvWireFormat packets.
  commandInterest->getName().append
    (controlParameters.wireEncode(*TlvWireFormat::get()));
  makeCommandInterest
    (*commandInterest, commandKeyChain, commandCertificateName,
     *TlvWireFormat::get());

  if (registeredPrefixId != 0) {
    uint64_t interestFilterId = 0;
    if (onInterest) {
      // registerPrefix was called with the "combined" form that includes the
      // callback, so add an InterestFilterEntry.
      interestFilterId = getNextEntryId();
      setInterestFilter
        (interestFilterId, ptr_lib::make_shared<const InterestFilter>(*prefix),
         onInterest, face);
    }

    registeredPrefixTable_.push_back
      (ptr_lib::shared_ptr<RegisteredPrefix>(new RegisteredPrefix
        (registeredPrefixId, prefix, interestFilterId)));
  }

  // Send the registration interest.
  RegisterResponse response
    (ptr_lib::shared_ptr<RegisterResponse::Info>(new RegisterResponse::Info
     (this, prefix, onInterest, onRegisterFailed, flags, wireFormat, face)));
  // It is OK for func_lib::function make a copy of the function object because
  //   the Info is in a ptr_lib::shared_ptr.
  expressInterest
    (getNextEntryId(), commandInterest, response, response, wireFormat, face);
}
Beispiel #6
0
Browser::Browser()
{	
	string input, destination, newpath;
	path = "/";
	vector<string> params;
	
	// pass buffer
	manager.setBuffer(&buffer);
	
	string command;
	pwd = Folder(0, 0, "root");

	// WELCOME
	//printw("%s", "## Welcome in Rapidshare Manager \n");
	//printw("%s", "rs#~/ ");
	
	//refresh();
	//move(linenum,6);
	//cout << "## Welcome in Rapidshare Manager" << endl;
	//cout << "rs#~/ ";
	
	while(true) {
		
		input = buffer.getCommand();
		//getline(cin, input);
		//printw("---- %s -----", input.c_str());
		trim(input);
		split(params, input, is_any_of(" "));

		command = params[0];
	
		if(command == "ls"){
			manager.listFolder(pwd);
		}
		if(command == "help"){
			showHelp();
		}
		if(command == "mv"){
			
			params = processParams(input, command, 2);
			
			mv(getCurrentPath(params[0]), getCurrentPath(params[1]));
			
		}
		if(command == "cd"){
			
			params = processParams(input, "cd", 1);
					
			if(params[0] == ".."){
				if(!pwd.isRoot()){
					pwd = manager.getFolder(pwd.parent);
					path = pwd.path;
				}else{
					path = "/";
				}
					
			}else{		
				
				if(pwd.isRoot()){
					path = pwd.path + params[0];
				}else{
					path = pwd.path + "/" + params[0];
				}
				
				if(manager.getFolder(path).notFound()) {
					cout << "not found" << endl;
				}else{
					pwd = manager.getFolder(path);
				}			
			}
			
		}
		if(command == "cp"){	
			
			params = processParams(input, "cp", 2);		
			if(params.size() == 2){
				bool local = isLocal(params[0]);
				string destination;
				
				if(local){
					destination = getCurrentPath(params[1]);
					path = params[0];
					
				}else{				
					path = getCurrentPath(params[0]);
					destination = params[1];
				
				}
				copy(path, destination, local);				
			}
			
		}
		if(command == "pwd"){
			cout << pwd.path << endl;
		}
		if(command == "play"){
			
			
			params = processParams(input, command, 1);	
			/*if(params.size() == 1){
				
				bool isNumber = true;
				// jedna se o cislo?
				for(int i = 0; i < (int)params.size();i++){
					if(!isdigit(params[0][i])){
						isNumber = false;
					}
				}
				
				if(isNumber){
					play(pwd.path, lexical_cast<int>(params[0]));
				}else{
					play(getCurrentPath(params[0]));
				}
				
			}else{
				cout << "Wrond number of params" << endl;
			}*/

			
			
			
		}
		if(command == "clear"){
			system("clear");
		}
		if(command == "mkdir")
		{
			params = processParams(input, command, 1);
			mkdir(pwd.path, params[0]);
		}
		if(command == "rename"){
			
			params = processParams(input, "rename", 2);
			path = getCurrentPath(params[0]);
			rename(path, params[1]);
		}
		if(command == "rm")
		{
			
			params = processParams(input, command, 1);
			path = getCurrentPath(params[0]);
			rm(path);
			
		}
		if(command == "exit"){
			
			// ukoncime ncurses
			endwin();
			exit(1);
		}
		
		//cout  << "rs#~" << pwd.path << " ";
		buffer.changeStart("rs#~" + pwd.path + " ");
		buffer.writeStart();
		
	};
	
	cout << endl;
}
Beispiel #7
0
void NounShip::removeIncoming( NounProjectile * a_pProj )
{
	if ( userId() == 0 && isLocal() )
		m_Incoming.removeSearchSwap( a_pProj );
}
Beispiel #8
0
bool Branch::isRemote()
{
    return !isLocal();
}
void PlayerController::update(const GameTime& gameTime)
{
	if (!isLocal())
		return;

	Vector3 forward = leprechaun->getForward();
	Vector3 right = leprechaun->getRight();

	Vector3 direction;

	if (Keyboard::isKeyDown(buttonMoveForward))
		direction += forward;

	if (Keyboard::isKeyDown(buttonMoveBackward))
		direction -= forward;

	if (Keyboard::isKeyDown(buttonMoveRight))
		direction += right;

	if (Keyboard::isKeyDown(buttonMoveLeft))
		direction -= right;

	leprechaun->setMoving(Vector3::normalize(direction));

	if (Keyboard::isKeyPress(buttonJump))
		leprechaun->jump();
	else if (Keyboard::isKeyPress(buttonDodgeLeft))
		leprechaun->dodgeLeft();
	else if (Keyboard::isKeyPress(buttonDodgeRight))
		leprechaun->dodgeRight();

	if (Keyboard::isKeyPress(buttonItemSlot1))
		leprechaun->useItem(0);
	else if (Keyboard::isKeyPress(buttonItemSlot2))
		leprechaun->useItem(1);
	else if (Keyboard::isKeyPress(buttonItemSlot3))
		leprechaun->useItem(2);

	int mouseWheelDelta = Mouse::getMouseWheelDelta();

	if (mouseWheelDelta)
	{
		int attack = leprechaun->getAttack() + ((mouseWheelDelta > 0) ? 1 : -1);
		leprechaun->setAttack((attack + LeprechaunAttack::count) % LeprechaunAttack::count);
	}

	if (Mouse::isLeftButtonClick())
	{
		if (leprechaun->isCarryingPig())
			leprechaun->throwPig();
		else
		{
			switch (leprechaun->getAttack())
			{
				case LeprechaunAttack::kick: leprechaun->kick(); break;
				case LeprechaunAttack::cane: leprechaun->throwCane(); break;
				case LeprechaunAttack::hat: clickStart = gameTime.total; break;
			}
		}
	}

	if (Mouse::isLeftButtonClickEnd() && clickStart != 0)
	{
		switch (leprechaun->getAttack())
		{
 			case LeprechaunAttack::hat: leprechaun->throwHat((gameTime.total - clickStart) / hatMaxChargingTime); clickStart = 0; break;
		}
	}
}
	void NameServiceRecord::increaseProxyCount()
	{
		if (!isLocal())
			++proxyCount_;
	}
bool CSSFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescription)
{
    if (!isLocal())
        return false;
    return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, m_string);
}
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

    if (isLocal()) {
        // We're local. Just return a SimpleFontData from the normal cache.
        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
        RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fontDescription, m_string, true);
        m_histograms.recordLocalFont(fontData);
        return fontData;
    }

    // See if we have a mapping in our FontData cache.
    AtomicString emptyFontFamily = "";
    FontCacheKey key = fontDescription.cacheKey(emptyFontFamily);

    RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).storedValue->value;
    if (fontData)
        return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_hasExternalSVGFont) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement) {
                    String fragmentIdentifier;
                    size_t start = m_string.find('#');
                    if (start != kNotFound)
                        fragmentIdentifier = m_string.string().substring(start + 1);
                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
                }

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = toSVGFontFaceElement(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData = SimpleFontData::create(
                        SVGFontData::create(fontFaceElement),
                        fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(),
                        fontDescription.isSyntheticItalic());
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData = SimpleFontData::create(
                    m_font->platformDataFromCustomData(fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(), fontDescription.isSyntheticItalic(),
                        fontDescription.orientation(), fontDescription.widthVariant()), CustomFontData::create(false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement) {
                fontData = SimpleFontData::create(
                    SVGFontData::create(m_svgFontFaceElement.get()),
                    fontDescription.effectiveFontSize(),
                    fontDescription.isSyntheticBold(),
                    fontDescription.isSyntheticItalic());
            }
#endif
        }
    } else {
        // This temporary font is not retained and should not be returned.
        FontCachePurgePreventer fontCachePurgePreventer;
        SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
        if (!temporaryFont) {
            ASSERT_NOT_REACHED();
            return 0;
        }
        RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true);
        cssFontData->setCSSFontFaceSource(this);
        fontData = SimpleFontData::create(temporaryFont->platformData(), cssFontData);
    }

    return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
}
bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const
{
    ASSERT(isLocal() && other->isLocal());

    return !m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation;
}
bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const
{
    ASSERT(isLocal() && other->isLocal());

    return !m_blockLocalAccessFromLocalOrigin && !other->m_blockLocalAccessFromLocalOrigin;
}
Beispiel #15
0
// New, very very fast function. The only one who should be used, if fact
int mpkgSys::requestInstall(vector<string> package_name, vector<string> package_version, vector<string> package_build, mpkgDatabase *db, DependencyTracker *DepTracker, vector<string> *eList) {
	
	// First of all, check for local packages
	
	vector<int> localPackages;
	vector<bool> isLocal(package_name.size(), false);
	LocalPackage *_p;
	string pkgType;
	for (size_t i=0; i<package_name.size(); i++) {
		pkgType=getExtension(package_name[i]);
		if (pkgType=="txz" || pkgType == "tbz" || pkgType == "tlz" || pkgType=="tgz" || pkgType == "spkg") {
		       if (FileExists(package_name[i])) {
				_p = new LocalPackage(package_name[i]);
				_p->injectFile();
				db->emerge_to_db(&_p->data);
				package_name[i] = _p->data.get_name();
				package_version[i] = _p->data.get_version();
				package_build[i] = _p->data.get_build();
				isLocal[i]=true;
				//printf("\nDetected local package\nFilename: %s\nName:%s\nVersion:%s\n", _p->data.get_filename().c_str(), _p->data.get_name().c_str(), _p->data.get_version().c_str());
				localPackages.push_back(_p->data.get_id());
				delete _p;
			}
		}
	}
	vector<string> errorList;
	//printf("using error list\n");
	// Creating DB cache
	// 1. Creating a request for all packages which are in package_name vector.
	SQLRecord sqlSearch;
	sqlSearch.setSearchMode(SEARCH_IN);
	for (size_t i=0; i<package_name.size(); i++) {
		if (isLocal[i]) {
			continue;
		}
		sqlSearch.addField("package_name", package_name[i]);
	}
	// 2. Requesting database by search array
	PACKAGE_LIST pCache;
	//printf("SLOW GET_PACKAGELIST CALL: %s %d\n", __func__, __LINE__);
	int query_ret = db->get_packagelist(sqlSearch, &pCache, true, false);
	if (query_ret != 0) {
		errorList.push_back(mError("Error querying database"));
		if (eList) *eList = errorList;
		return MPKGERROR_SQLQUERYERROR;
	}
	// 3. Temporary matrix, temporary list (for each package), and result list
	vector<PACKAGE_LIST> tmpMatrix;
	PACKAGE_LIST *tmpList=new PACKAGE_LIST;
	PACKAGE_LIST resultList;
	PACKAGE_LIST uninstallList;
	// 4. Search by cache for installed ones, check for availability and select the appropriate versions
	// 4.1 Building matrix: one vector per list of packages with same name
	for (size_t i=0; i<package_name.size(); i++) {
		delete tmpList;
		tmpList = new PACKAGE_LIST;
		for (size_t t=0; t<pCache.size(); t++) {
			if (pCache.at(t).get_name() == package_name[i]) {
				if (isLocal[i] && pCache[t].get_id()!=localPackages[i]) continue;
				tmpList->add(pCache.at(t));
			}
		}
		tmpMatrix.push_back(*tmpList);
	}
	//printf("tmpMatrix[0] size = %d\n", tmpMatrix[0].size());
	// So, the matrix has been created.
	// In case of any error, collect all of them, and return MPKGERROR_IMPOSSIBLE
	
	// Sizes of tmpMatrix and input vectors are the same, so we can use any of them
	PACKAGE *outPackage = NULL, *installedOne = NULL;
	for (size_t i=0; i<tmpMatrix.size(); i++) {
		delete tmpList;
		tmpList = new PACKAGE_LIST;
		for (size_t t=0; t<tmpMatrix[i].size(); t++) {
			// Filling the tmpList with reachable (=installed or available) ones for each package
			if (tmpMatrix[i].at(t).available(true) || tmpMatrix[i].at(t).installed()) {
				if (package_version[i].empty() || tmpMatrix[i].at(t).get_version() == package_version[i]) {
					if (package_build[i].empty() || package_build[i]==tmpMatrix[i].at(t).get_build()) tmpList->add(tmpMatrix[i][t]);
				}
			}
		}
		// Now, we have a list of all good candidates. We will filter already installed ones separately for better UI output.
		tmpList->initVersioning();
		outPackage = tmpList->getMaxVersion();
		//if (outPackage) printf("outPackage VERSION: %s\n", outPackage->get_fullversion().c_str());
		installedOne = (PACKAGE *) tmpMatrix[i].getInstalledOne();
		if (outPackage == NULL) {
			string errorText = _("Requested package ") + package_name[i];
		       	if (!package_version[i].empty()) errorText += "-" + package_version[i];
			if (!package_build[i].empty()) errorText += "-" + package_build[i];
			if (!installedOne) errorList.push_back(mError(errorText + _(" cannot be found")));
			else errorList.push_back(mError(errorText + _(" is already installed")));
		}
		else {
			//printf("____________________________CHECK FOR UPDATE, installedOne: %p_____________________________\n", installedOne);
			// Check for update
			if (installedOne && outPackage->get_id() != installedOne->get_id()) {
				// This is update
				//printf("added to uninstall: %d\n", installedOne->get_id());
				uninstallList.add(*installedOne);
			}
			resultList.add(*outPackage);
		}
	}
	delete tmpList;
	// Special addition for local packages installed using -z key: check for installed one
	for (size_t i=0; i<isLocal.size(); ++i) {
		if (!isLocal[i]) continue;
		for (size_t t=0; t<pCache.size(); ++t) {
			if (pCache[t].installed() && pCache[t].get_id()!=localPackages[i] && pCache[t].get_name()==package_name[i]) {
				requestUninstall(pCache.get_package_ptr(t), db, DepTracker);
			}
		}
	}
	// Now, check resultList for installed ones and unavailable ones
	for (size_t i=0; i<resultList.size(); i++) {
		if (resultList[i].installed()) {
			mWarning(_("Package ") + resultList[i].get_name() + "-" + resultList[i].get_fullversion() + _(" is already installed"));
		} 
		else {
			if (!resultList[i].available(true)) {
				errorList.push_back(mError(_("Package ") + resultList[i].get_name() + "-" + resultList[i].get_fullversion() + _(" is unavailable")));
			}
		}
	}
	// NEW: ignore already installed packages
	tmpList = new PACKAGE_LIST;
	for (size_t i=0; i<resultList.size(); ++i) {
		if (!resultList[i].installed()) {
			tmpList->add(resultList[i]);
		}
	}
	resultList = *tmpList;
	delete tmpList;
	

	//printf("resultList size = %d\n", resultList.size());
	if (errorList.empty())	{
		// Push to database
		__requestInstallPkgList(&resultList, db, DepTracker);
		for (size_t i=0; i<uninstallList.size(); i++) requestUninstall(uninstallList.get_package_ptr(i), db, DepTracker);

	}
	else {
		mError(_("Errors detected, cannot continue"));
		if (eList) *eList = errorList;
		return MPKGERROR_IMPOSSIBLE;
	}

	if (eList) *eList = errorList;
	return 0;
}
void SecurityOrigin::blockLocalAccessFromLocalOrigin()
{
    ASSERT(isLocal());
    m_blockLocalAccessFromLocalOrigin = true;
}
static int
markFastSafeFn(FnSymbol *fn, int recurse, std::set<FnSymbol*>& visited) {

  // First, handle functions we've already visited.
  if (visited.count(fn) != 0) {
    if (fn->hasFlag(FLAG_FAST_ON))
      return FAST_AND_LOCAL;
    if (fn->hasFlag(FLAG_LOCAL_FN))
      return LOCAL_NOT_FAST;
    return NOT_FAST_NOT_LOCAL;
  }

  // Now, add fn to the set of visited functions,
  // since we will categorize it now.
  visited.insert(fn);

  // Next, classify extern functions
  if (fn->hasFlag(FLAG_EXTERN)) {
    if (fn->hasFlag(FLAG_FAST_ON_SAFE_EXTERN)) {
      // Make sure the FAST_ON and LOCAL_FN flags are set.
      fn->addFlag(FLAG_FAST_ON);
      fn->addFlag(FLAG_LOCAL_FN);
      return FAST_AND_LOCAL;
    } else if(fn->hasFlag(FLAG_LOCAL_FN)) {
      return LOCAL_NOT_FAST;
    } else {
      // Other extern functions are not fast or local.
      return NOT_FAST_NOT_LOCAL;
    }
  }

  // Next, go through function bodies.
  // We will set maybefast=false if we see something in the function
  //  that is local but not suitable for a signal handler
  //  (mostly allocation or locking).
  // We will return NOT_FAST_NOT_LOCAL immediately if we see something
  // in the function that is not local.
  bool maybefast = true;

  if (fn->hasFlag(FLAG_NON_BLOCKING))
    maybefast = false;

  std::vector<CallExpr*> calls;

  collectCallExprs(fn, calls);

  for_vector(CallExpr, call, calls) {
    bool inLocal = fn->hasFlag(FLAG_LOCAL_FN) || inLocalBlock(call);

    if (call->primitive) {
      int is = classifyPrimitive(call, inLocal);

      if (!isLocal(is)) {
        // FAST_NOT_LOCAL or NOT_FAST_NOT_LOCAL
        return NOT_FAST_NOT_LOCAL;
      }

      // is == FAST_AND_LOCAL requires no action
      if (is == LOCAL_NOT_FAST) {
        maybefast = false;
      }

    } else {
      if (recurse<=0 || !call->isResolved()) {
        // didn't resolve or past too much recursion.
        // No function calls allowed
        return NOT_FAST_NOT_LOCAL;

      } else {
        // Handle nested 'on' statements
        if (call->resolvedFunction()->hasFlag(FLAG_ON_BLOCK)) {
          if (inLocal) {
            maybefast = false;
          } else {
            return NOT_FAST_NOT_LOCAL;
          }
        }

        // is the call to a fast/local function?
        int is = markFastSafeFn(call->resolvedFunction(),
                                recurse - 1,
                                visited);

        // Remove NOT_LOCAL parts if it's in a local block
        is = setLocal(is, inLocal);

        if (!isLocal(is)) {
          return NOT_FAST_NOT_LOCAL;
        }

        if (is == LOCAL_NOT_FAST) {
          maybefast = false;
        }
        // otherwise, possibly still fast.
      }
    }
  }