コード例 #1
0
ファイル: fourchan_parser.cpp プロジェクト: klampworks/mammon
std::string fourchan_parser::parse_post_text(const pugi::xml_node &node) 
{
	auto nn = parse_post_node(node);
	pugi::xpath_node quote = nn.select_single_node("blockquote");

	//Flatten the subtree of html nodes into a single string.
	return flatten(quote.node());
}
コード例 #2
0
ファイル: fourchan_parser.cpp プロジェクト: klampworks/mammon
std::string fourchan_parser::parse_post_img_name(const pugi::xml_node &node) 
{
	auto nn = parse_post_node(node);
	pugi::xpath_node res = nn.select_single_node(
		"div[@class='file']/div[@class='fileText']/a");

	return res.node().text().get();
}
コード例 #3
0
ファイル: client.cpp プロジェクト: mbcslava/webdav-client-cpp
	unsigned long long
	Client::free_size() noexcept
	{
		Header header = {
				"Accept: */*",
				"Depth: 0",
				"Content-Type: text/xml"
		};

		pugi::xml_document document;
		auto propfind = document.append_child("D:propfind");
		propfind.append_attribute("xmlns:D") = "DAV:";

		auto prop = propfind.append_child("D:prop");
		prop.append_child("D:quokta-available-bytes");
		prop.append_child("D:quota-used-bytes");

		auto document_print = pugi::node_to_string(document);
		size_t size = document_print.length() * sizeof((document_print.c_str())[0]);

		Data data = { 0, 0, 0 };

		Request request(GetImpl(this)->options());

		request.set(CURLOPT_CUSTOMREQUEST, "PROPFIND");
		request.set(CURLOPT_HTTPHEADER, (struct curl_slist *)header.handle);
		request.set(CURLOPT_POSTFIELDS, document_print.c_str());
		request.set(CURLOPT_POSTFIELDSIZE, (long)size);
		request.set(CURLOPT_HEADER, 0);
		request.set(CURLOPT_WRITEDATA, (size_t)&data);
		request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Append::buffer);

		auto is_performed = request.perform();
		if (!is_performed) return 0;

		document.load_buffer(data.buffer, (size_t)data.size);

		pugi::xml_node multistatus = document.select_single_node("d:multistatus").node();
		pugi::xml_node response = multistatus.select_single_node("d:response").node();
		pugi::xml_node propstat = response.select_single_node("d:propstat").node();
		prop = propstat.select_single_node("d:prop").node();
		pugi::xml_node quota_available_bytes = prop.select_single_node("d:quota-available-bytes").node();
		std::string free_size_text = quota_available_bytes.first_child().value();

		auto free_size = atol(free_size_text.c_str());
		return free_size;
	}
コード例 #4
0
ファイル: SJView.cpp プロジェクト: finite-difference/ESFEA
void SJView::OnLButtonDown(UINT nFlags, CPoint point) 
{	
	CWnd::OnLButtonDown(nFlags, point);

	CESFEA2DApp* pSejikaApp = (CESFEA2DApp*)AfxGetApp();
	int mode = pSejikaApp->get_mode();

	switch(mode) 
	{	
		case IDM_SELECT_ND:
			select_single_node(point);
		break;
		case IDM_CREATE_EL:
			select_element_node(point);
		break;
	}
	Invalidate();
}
コード例 #5
0
ファイル: version.cpp プロジェクト: Azpidatziak/mkvtoolnix
mtx_release_version_t
get_latest_release_version() {
  bool debug      = debugging_requested("version_check|curl");
  std::string url = MTX_VERSION_CHECK_URL;
  debugging_requested("version_check_url", &url);

  mxdebug_if(debug, boost::format("Update check started with URL %1%\n") % url);

  mtx_release_version_t release;

  auto doc = retrieve_and_parse_xml(url + ".gz");
#if defined(HAVE_BZLIB_H)
  if (!doc)
    doc = retrieve_and_parse_xml(url + ".bz2");
#endif  // HAVE_BZLIB_H
  if (!doc)
    doc = retrieve_and_parse_xml(url);
  if (!doc)
    return release;

  release.latest_source                   = version_number_t(doc->select_single_node("/mkvtoolnix-releases/latest-source/version").node().child_value());
  release.latest_windows_build            = version_number_t((boost::format("%1% build %2%")
                                                             % doc->select_single_node("/mkvtoolnix-releases/latest-windows-pre/version").node().child_value()
                                                             % doc->select_single_node("/mkvtoolnix-releases/latest-windows-pre/build").node().child_value()).str());
  release.valid                           = release.latest_source.valid;
  release.urls["general"]                 = doc->select_single_node("/mkvtoolnix-releases/latest-source/url").node().child_value();
  release.urls["source_code"]             = doc->select_single_node("/mkvtoolnix-releases/latest-source/source-code-url").node().child_value();
  release.urls["windows_pre_build"]       = doc->select_single_node("/mkvtoolnix-releases/latest-windows-pre/url").node().child_value();
  for (auto arch : std::vector<std::string>{ "x86", "amd64" })
    for (auto package : std::vector<std::string>{ "installer", "portable" })
      release.urls[std::string{"windows_"} + arch + "_" + package] = doc->select_single_node((std::string{"/mkvtoolnix-releases/latest-windows-binary/"} + package + "-url/" + arch).c_str()).node().child_value();

  if (debug) {
    std::stringstream urls;
    brng::for_each(release.urls, [&](std::pair<std::string, std::string> const &kv) { urls << " " << kv.first << ":" << kv.second; });
    mxdebug(boost::format("update check: current %1% latest source %2% latest winpre %3% URLs%4%\n")
            % release.current_version.to_string() % release.latest_source.to_string() % release.latest_windows_build.to_string() % urls);
  }

  return release;
}
コード例 #6
0
ファイル: client.cpp プロジェクト: mbcslava/webdav-client-cpp
	dict_t
	Client::info(std::string remote_resource) noexcept
	{
		auto clientImpl = GetImpl(this);
		auto root_urn = Urn(clientImpl->webdav_root, true);
		auto target_urn = root_urn + remote_resource;

		Header header = {
				"Accept: */*",
				"Depth: 1"
		};

		Data data = { 0, 0, 0 };

		Request request(clientImpl->options());

		auto url = clientImpl->webdav_hostname + target_urn.quote(request.handle);

		request.set(CURLOPT_CUSTOMREQUEST, "PROPFIND");
		request.set(CURLOPT_URL, url.c_str());
		request.set(CURLOPT_HTTPHEADER, (struct curl_slist *)header.handle);
		request.set(CURLOPT_WRITEDATA, (size_t)&data);
		request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Append::buffer);

		bool is_performed = request.perform();

		if (!is_performed) return dict_t();

		pugi::xml_document document;
		document.load_buffer(data.buffer, (size_t)data.size);
		auto multistatus = document.select_single_node("d:multistatus").node();
		auto responses = multistatus.select_nodes("d:response");
		for (auto response : responses)
		{
			pugi::xml_node href = response.node().select_single_node("d:href").node();
			std::string encode_file_name = href.first_child().value();
			std::string resource_path = curl_unescape(encode_file_name.c_str(), (int)encode_file_name.length());
			auto target_path = target_urn.path();
			auto target_path_without_sep = std::string(target_path, 0, target_path.rfind("/")+1);
			auto resource_path_without_sep = std::string(resource_path, 0, resource_path.rfind("/")+1);
			if (resource_path_without_sep.compare(target_path_without_sep) == 0) {
				auto propstat = response.node().select_single_node("d:propstat").node();
				auto prop = propstat.select_single_node("d:prop").node();
				auto creation_date = prop.select_single_node("d:creationdate").node();
				auto display_name = prop.select_single_node("d:displayname").node();
				auto content_length = prop.select_single_node("d:getcontentlength").node();
				auto modified_date = prop.select_single_node("d:getlastmodified").node();
				auto resource_type = prop.select_single_node("d:resourcetype").node();

				dict_t information = {
						{"created", creation_date.first_child().value()},
						{"name", display_name.first_child().value()},
						{"size", content_length.first_child().value()},
						{"modified", modified_date.first_child().value()},
						{"type", resource_type.first_child().name()}
				};

				return information;
			}
		}

		return dict_t();
	}