int fifo::access_cache(string url, string &response)
{
	cout<<"url_exists(url)"<<url_exists(url);
	if(url_exists(url)){
		response = url_to_node[url]->data;
		return 1;
	}
	return 0;
}
Ejemplo n.º 2
0
static void
xxx_to_url( fields *f, int n, char *http_prefix, char *urltag, newstr *xxx_url )
{
	newstr_empty( xxx_url );
	construct_url( http_prefix, fields_value( f, n, FIELDS_STRP ), xxx_url );
	if ( url_exists( f, urltag, xxx_url ) )
		newstr_empty( xxx_url );
}
Ejemplo n.º 3
0
bool WebTools::UrlExists(const ssi_char_t *url, const ssi_char_t *pathToCertificate)
{	
	bool result = false;
	init_curl();

	CURL* curl = curl_easy_init();
	result = url_exists(curl, url, pathToCertificate);
	curl_easy_cleanup(curl);

	return result;
}
Ejemplo n.º 4
0
 void 
   advertdirectory_cpi_impl::sync_exists (bool      & ret, 
                                          saga::url   entry)
 {
     if(url_exists(*client_, entry)) {
        ret = true;
     }
     else {
        ret = false;
     }
     //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 5
0
bool WebTools::DownloadFile(const ssi_char_t *url, const ssi_char_t *pathOnDisk, const ssi_char_t *pathToCertificate, bool showProgress)
{
	bool result = false;
	init_curl();

	CURL *curl = curl_easy_init();

	if (url_exists(curl, url, pathToCertificate))
	{
		curl_easy_reset(curl);

		init_request(curl, url, pathToCertificate, showProgress);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);

		FILE *file = fopen(pathOnDisk, "wb");
		if (file) {

			curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
			CURLcode code = curl_easy_perform(curl);
			fclose(file);

			if (code != CURLE_OK)
			{
				ssi_wrn(curl_easy_strerror(code));
				ssi_remove(pathOnDisk);
			}
			else
			{
				result = true;
			}
		}
		else
		{
			ssi_wrn("could not create file '%s'", pathOnDisk);
		}
	}
	else
	{
		ssi_wrn("url does not exist '%s'", url);
	}

	curl_easy_cleanup(curl);

	return result;
}
Ejemplo n.º 6
0
 ////////////////////////////////////////////////////////////////////////
 //  constructor
 advertdirectory_cpi_impl::advertdirectory_cpi_impl (proxy                           * p, 
                                                     cpi_info const                  & info,
                                                     saga::ini::ini const            & glob_ini, 
                                                     saga::ini::ini const            & adap_ini,
                                                     TR1::shared_ptr <saga::adaptor>   adaptor)
   : saga::adaptors::v1_0::advert_directory_cpi <advertdirectory_cpi_impl> (p, info, adaptor, cpi::Noflags) 
 {
     saga::url advert_url;
     instance_data data (this);
     advert_url = data->location_.clone();
     std::string path;
     int port;
     path = advert_url.get_path();
     if (path.empty())
         path = "/"; // root only
     std::string host(advert_url.get_host());
     if (host.empty()) {
        SAGA_OSSTREAM strm;
        strm << "advert::advert_cpi_impl::init: "
                "cannot handle advert entry name: " 
             << advert_url.get_url();
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::IncorrectURL);
     }
     std::string scheme(advert_url.get_scheme());
     if (!scheme.empty() && scheme != "hbase" && scheme != "any") {
        SAGA_OSSTREAM strm;
        strm << "advert::advert_cpi_impl::init: "
                "cannot handle advert entry name: " << advert_url.get_url();
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::IncorrectURL);
     }
     port = advert_url.get_port();
     boost::shared_ptr<TTransport> socket(new TSocket(host, port));
     transport_ = boost::shared_ptr<TTransport>(new TBufferedTransport(socket));
     boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport_));
     client_ = new HbaseClient(protocol);
     transport_->open();
     saga::advert::flags mode = (saga::advert::flags)data->mode_;
     if(path == "/") {
     }
     else if (((mode & saga::advert::Create) || (mode & saga::advert::CreateParents)) && 
         (mode & saga::advert::Exclusive)) {
         if(!url_exists(*client_, advert_url.get_url())) {
            SAGA_OSSTREAM strm;
            strm << "advert::advert_cpi_impl::init: "
                    "advert already exists: " << advert_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::AlreadyExists);
         }
     }
     else if ((mode & saga::advert::Create) || (mode & saga::advert::CreateParents)) {
         if(!url_exists(*client_, advert_url.get_url())) {
            if(!create_url(*client_, advert_url.get_url(), true)) {
               // failed to create url
               SAGA_OSSTREAM strm;
               strm << "advert::advert_cpi_impl::init: "
                       "advert couldn't create url: " << advert_url.get_url();
               SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::AlreadyExists);
            }
         }
        // no need to create this entry twice
        data->mode_ &= ~(saga::advert::Create | saga::advert::CreateParents);
     }
     /*if(!url_exists(*client_, advert_url.get_url())) {
        //here is where I am
        SAGA_OSSTREAM strm;
        strm << "advert::advert_cpi_impl::init: "
                "advert does not exist: " << advert_url.get_url();
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);
     }*/
     //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }