コード例 #1
0
ファイル: url.cpp プロジェクト: Val9/titanium_desktop
	char* PreprocessURLCallback(const char* url, KeyValuePair* headers, char** mimeType)
	{
		Logger* logger = Logger::Get("UI.URL");

		KObjectRef scope = new StaticBoundObject();
		KObjectRef kheaders = new StaticBoundObject();
		while (headers->key)
		{
			kheaders->SetString(headers->key, headers->value);
			headers++;
		}

		try
		{
			AutoPtr<PreprocessData> result = 
				Script::GetInstance()->Preprocess(url, scope);
			*mimeType = strdup(result->mimeType.c_str());
			return strdup(result->data->Pointer());
		}
		catch (ValueException& e)
		{
			logger->Error("Error in preprocessing: %s", e.ToString().c_str());
		}
		catch (...)
		{
			logger->Error("Unknown Error in preprocessing");
		}

		return NULL;
	}
コード例 #2
0
ファイル: php_evaluator.cpp プロジェクト: mital/kroll
	static string GetContextId(KObjectRef global)
	{
		string contextId(global->GetString("__php_module_id__"));
		if (contextId.empty())
		{
			static int nextId = 0;
			contextId.append("__kroll__namespace__");
			contextId.append(KList::IntToChars(++nextId));
			global->SetString("__php_module_id__", contextId);
		}

		return contextId;
	}
コード例 #3
0
ファイル: process.cpp プロジェクト: Val9/titanium_desktop
	/*static*/
	KObjectRef Process::GetCurrentEnvironment()
	{
		KObjectRef kenv = new StaticBoundObject();
		std::map<std::string, std::string> env = EnvironmentUtils::GetEnvironment();

		std::map<std::string, std::string>::iterator i = env.begin();
		while (i != env.end())
		{
			kenv->SetString(i->first.c_str(), i->second.c_str());
			i++;
		}
		return kenv;
	}
コード例 #4
0
 void HttpServerRequest::GetHeaders(const ValueList& args, KValueRef result)
 {
     Poco::Net::HTTPServerRequest::ConstIterator iter = request.begin();
     KObjectRef headers = new StaticBoundObject();
     
     for(; iter != request.end(); iter++)
     {
         std::string name = iter->first;
         std::string value = iter->second;
         headers->SetString(name.c_str(), value.c_str());
     }
     result->SetObject(headers);
 }