Ejemplo n.º 1
0
LLUserAuth::UserAuthcode LLUserAuth::parseResponse()
{
	// The job of this function is to parse sCurlDownloadArea and
	// extract every member into either the mResponses or
	// mOptions. For now, we will only be looking at mResponses, which
	// will all be string => string pairs.
	UserAuthcode rv = E_UNHANDLED_ERROR;
	XMLRPC_REQUEST response = mResponder->response();
	if(!response)
	{
		U32 status = mResponder->getStatus();
		// Is it an HTTP error?
		if (!(200 <= status && status < 400))
		{
			rv = E_HTTP_SERVER_ERROR;
		}
		return rv;
	}

	// clear out any old parsing
	mResponses.clear();

	// Now, parse everything
    XMLRPC_VALUE param = XMLRPC_RequestGetData(response);
    if (! param)
	{
		lldebugs << "Response contains no data" << LL_ENDL;
		return rv;
	}

	// Now, parse everything
	mResponses = parseValues(rv, "", param);
	return rv;
}
        api::DirectionData DirectionReader::getDirectionData()
        {
            myOutDirectionData = initializeData();
            updateTimeForOffset();
            parsePlacement();
            parseValues();

            // need to make sure all the MarkData item times match the DirectionData time
            fixTimes();
            return returnData();
        }
void SVGAnimationElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value)
{
    if (name == SVGNames::valuesAttr) {
        if (!parseValues(value, m_values)) {
            reportAttributeParsingError(ParsingAttributeFailedError, name, value);
            return;
        }
        updateAnimationMode();
        return;
    }

    if (name == SVGNames::keyTimesAttr) {
        if (!parseKeyTimes(value, m_keyTimes, true))
            reportAttributeParsingError(ParsingAttributeFailedError, name, value);
        return;
    }

    if (name == SVGNames::keyPointsAttr) {
        if (isSVGAnimateMotionElement(*this)) {
            // This is specified to be an animateMotion attribute only but it is simpler to put it here
            // where the other timing calculatations are.
            if (!parseKeyTimes(value, m_keyPoints, false))
                reportAttributeParsingError(ParsingAttributeFailedError, name, value);
        }
        return;
    }

    if (name == SVGNames::keySplinesAttr) {
        if (!parseKeySplines(value, m_keySplines))
            reportAttributeParsingError(ParsingAttributeFailedError, name, value);
        return;
    }

    if (name == SVGNames::attributeTypeAttr) {
        setAttributeType(value);
        return;
    }

    if (name == SVGNames::calcModeAttr) {
        setCalcMode(value);
        return;
    }

    if (name == SVGNames::fromAttr || name == SVGNames::toAttr || name == SVGNames::byAttr) {
        updateAnimationMode();
        return;
    }

    SVGSMILElement::parseAttribute(name, oldValue, value);
}
bool SVGAnimateElement::isSVGAnimationAttributeSettingJavaScriptURL(const Attribute& attribute) const
{
    if ((attribute.name() == SVGNames::fromAttr || attribute.name() == SVGNames::toAttr) && attributeValueIsJavaScriptURL(attribute))
        return true;

    if (attribute.name() == SVGNames::valuesAttr) {
        Vector<String> parts;
        if (!parseValues(attribute.value(), parts)) {
            // Assume the worst.
            return true;
        }
        for (const auto& part : parts) {
            if (protocolIsJavaScript(part))
                return true;
        }
    }

    return SVGSMILElement::isSVGAnimationAttributeSettingJavaScriptURL(attribute);
}
Ejemplo n.º 5
0
void StringComposer::parseCharacterLine(const std::string & line, float textureSize)
{
    std::list<std::string> parsedValues;
    parseValues(line, parsedValues);
    auto i = parsedValues.begin();

    unsigned int id = std::stoi(*(i++));
    
    float x = std::stof(*(i++));
    float y = std::stof(*(i++));
    float width = std::stof(*(i++));
    float height = std::stof(*(i++));
    float xOffset = std::stof(*(i++));
    float yOffset = std::stof(*(i++));
    
    float xAdvance = std::stof(*(i++)) / textureSize;
    
    glm::vec2 position = glm::vec2(x, textureSize - (y + height)) / textureSize;
    glm::vec2 size = glm::vec2(width, height) / textureSize;
    glm::vec2 offset = glm::vec2(xOffset, yOffset - height) / textureSize;
    
    auto specifics = new CharacterSpecifics { position, size, offset, xAdvance };
    m_characterSpecifics.emplace(id, specifics);
}
Ejemplo n.º 6
0
LLSD LLUserAuth::parseValues(UserAuthcode &auth_code, const std::string& key_pfx, XMLRPC_VALUE param)
{
	auth_code = E_OK;
	LLSD responses;
	for(XMLRPC_VALUE current = XMLRPC_VectorRewind(param); current;
		current = XMLRPC_VectorNext(param))
	{
		std::string key(XMLRPC_GetValueID(current));
		lldebugs << "key: " << key_pfx << key << llendl;
		XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(current);
		if(xmlrpc_type_string == type)
		{
			LLSD::String val(XMLRPC_GetValueString(current));
			lldebugs << "val: " << val << llendl;
			responses.insert(key,val);
		}
		else if(xmlrpc_type_int == type)
		{
			LLSD::Integer val(XMLRPC_GetValueInt(current));
			lldebugs << "val: " << val << llendl;
			responses.insert(key,val);
		}
		else if (xmlrpc_type_double == type)
        {
			LLSD::Real val(XMLRPC_GetValueDouble(current));
            lldebugs << "val: " << val << llendl;
			responses.insert(key,val);
		}
		else if(xmlrpc_type_array == type)
		{
			// We expect this to be an array of submaps. Walk the array,
			// recursively parsing each submap and collecting them.
			LLSD array;
			int i = 0;          // for descriptive purposes
			for (XMLRPC_VALUE row = XMLRPC_VectorRewind(current); row;
				row = XMLRPC_VectorNext(current), ++i)
			{
				// Recursive call. For the lower-level key_pfx, if 'key'
				// is "foo", pass "foo[0]:", then "foo[1]:", etc. In the
				// nested call, a subkey "bar" will then be logged as
				// "foo[0]:bar", and so forth.
				// Parse the scalar subkey/value pairs from this array
				// entry into a temp submap. Collect such submaps in 'array'.
				std::string key_prefix = key_pfx;
				array.append(parseValues(auth_code,
									STRINGIZE(key_pfx << key << '[' << i << "]:"),
									row));
			}
			// Having collected an 'array' of 'submap's, insert that whole
			// 'array' as the value of this 'key'.
			responses.insert(key, array);
		}
		else if (xmlrpc_type_struct == type)
    	{
    		LLSD submap = parseValues(auth_code,
            						STRINGIZE(key_pfx << key << ':'),
            						current);
            responses.insert(key, submap);
        }
        else
        {
        	// whoops - unrecognized type
            llwarns << "Unhandled xmlrpc type " << type << " for key "
                                        << key_pfx << key << LL_ENDL;
            responses.insert(key, STRINGIZE("<bad XMLRPC type " << type << '>'));
            auth_code = E_UNHANDLED_ERROR;
        }
    }
    return responses;
}
Ejemplo n.º 7
0
int initializeCoreCLR(const char* exePath,
            const char* appDomainFriendlyName,
            int propertyCount,
            const char* mergedPropertyKeys,
            const char* mergedPropertyValues,
            const char* managedAssemblyAbsolutePath,
            const char* clrFilesAbsolutePath) {
  printf("initializeCoreCLR()\n");

  std::string coreClrDllPath(clrFilesAbsolutePath);
  coreClrDllPath.append("/");
  coreClrDllPath.append(coreClrDll);

  if (coreClrDllPath.length() >= PATH_MAX)
  {
      fprintf(stderr, "Absolute path to libcoreclr.so too long\n");
  }

  std::string appPath;

  if( managedAssemblyAbsolutePath[0] == '\0' ) {
    printf("Expecting to run a standard .exe\n");
  } else {
    printf("Expecting to load an assembly and invoke arbitrary methods.\n");
    GetDirectory(managedAssemblyAbsolutePath, appPath);
  };

  // Construct native search directory paths
  std::string nativeDllSearchDirs(appPath);
  char *coreLibraries = getenv("CORE_LIBRARIES");
  if (coreLibraries)
  {
      nativeDllSearchDirs.append(":");
      nativeDllSearchDirs.append(coreLibraries);
  }
  nativeDllSearchDirs.append(":");
  nativeDllSearchDirs.append(clrFilesAbsolutePath);

  std::string tpaList;
  AddFilesFromDirectoryToTpaList(clrFilesAbsolutePath, tpaList);

  coreclrLib = dlopen(coreClrDllPath.c_str(), RTLD_NOW | RTLD_LOCAL);
  if (coreclrLib != nullptr)
  {
      initialize_core_clr = (coreclr_initialize_ptr)dlsym(coreclrLib, "coreclr_initialize");
      execute_assembly = (coreclr_execute_assembly_ptr)dlsym(coreclrLib, "coreclr_execute_assembly");
      shutdown_core_clr= (coreclr_shutdown_ptr)dlsym(coreclrLib, "coreclr_shutdown");
      create_delegate = (coreclr_create_delegate_ptr)dlsym(coreclrLib, "coreclr_create_delegate");

      if (initialize_core_clr == nullptr)
      {
          fprintf(stderr, "Function coreclr_initialize not found in the libcoreclr.so\n");
          return -1;
      }
      else if (execute_assembly == nullptr)
      {
          fprintf(stderr, "Function coreclr_execute_assembly not found in the libcoreclr.so\n");
          return -1;
      }
      else if (shutdown_core_clr == nullptr)
      {
          fprintf(stderr, "Function coreclr_shutdown not found in the libcoreclr.so\n");
          return -1;
      } else {
        if(useServerGc == NULL) {
          std::getenv(serverGcVar);
          if (useServerGc == nullptr) {
              useServerGc = "0";
          }
        }

        useServerGc = std::strcmp(useServerGc, "1") == 0 ? "true" : "false";

        char *keys[propertyCount];
        char *values[propertyCount];

        parseValues(mergedPropertyKeys, keys, propertyCount);
        parseValues(mergedPropertyValues, values, propertyCount);

        int st = initialize_core_clr(
                    exePath,
                    appDomainFriendlyName,
                    propertyCount,
                    (const char**)keys,
                    (const char**)values,
                    &hostHandle,
                    &domainId);

        if (SUCCEEDED(st)) {
          printf("coreclr_initialize ok\n");
        } else {
          fprintf(stderr, "coreclr_initialize failed - status: 0x%08x\n", st);
        };

      }
    }

    return 0;

}
int CmdOptionBasic::parse (int cur_arg_index, int argc, const char** argv)
{
    // Parse option name first, then rely on inherited classes
    // to parse value(s)

    if(cur_arg_index >= argc)
    {
        // out of command line arguments array
        return cur_arg_index;
    }

    string cur_arg_value = argv[cur_arg_index];

    if(cur_arg_value.length() <= 1)
    {
        // option name cannot be one symbol or empty;
        // it must contain at least two symbols (for example, -h)
        return cur_arg_index;
    }

    if(
        // check for short name
        m_short_name != 0 &&
        cur_arg_value[0] == '-' &&
        cur_arg_value[1] == m_short_name ||
        // check for long name
        cur_arg_value == "--" + m_long_name
    )
    {
        if(m_parsed)
        {
            // option duplication is not allowed
            throw CmdParser::Error(
                "Option duplication: " + cur_arg_value
            );
        }

        m_parsed = true;
        // OK, we found option name, for example -o or --option
        // now determine if a value is splitted or not, for example -o value or -ovalue
        if(
            cur_arg_value.length() == 2 ||  // two symbols, for example it is only -o
            cur_arg_value == "--" + m_long_name // long name is always splitted --option value
        )
        {
            // it is splitted, move to next command line argument in the list
            return parseValues(
                cur_arg_index + 1,
                cur_arg_index + 1 == argc ? "" : argv[cur_arg_index + 1],
                argc,
                argv
            );
        }
        else
        {
            // it sticks with option name, -ovalue
            return parseValues(
                cur_arg_index,
                cur_arg_value.substr(2),
                argc,
                argv
            );
        }
    }

    // cannot recognize this option
    return cur_arg_index;
}