当前位置: 首页>>代码示例>>C++>>正文


C++ curl_easy_escape函数代码示例

本文整理汇总了C++中curl_easy_escape函数的典型用法代码示例。如果您正苦于以下问题:C++ curl_easy_escape函数的具体用法?C++ curl_easy_escape怎么用?C++ curl_easy_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了curl_easy_escape函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: curl_easy_init

static char *stringify_field(const struct field *field)
{
	char *str, *name, *type, *value, *intermediate;
	CURL *curl;

	curl = curl_easy_init();
	if (!curl)
		return xstrdup("");

	name = curl_easy_escape(curl, field->name, 0);
	type = curl_easy_escape(curl, field->type, 0);
	if (field->value_encrypted)
		value = curl_easy_escape(curl, field->value_encrypted, 0);
	else if (!strcmp(field->type, "checkbox") || !strcmp(field->type, "radio")) {
		xasprintf(&intermediate, "%s-%c", field->value, field->checked ? '1' : '0');
		value = curl_easy_escape(curl, intermediate, 0);
		free(intermediate);
	} else
		value = curl_easy_escape(curl, field->value, 0);

	xasprintf(&str, "0\t%s\t%s\t%s\n", name, value, type);

	curl_free(name);
	curl_free(type);
	curl_free(value);
	curl_easy_cleanup(curl);

	return str;
}
开发者ID:androdev4u,项目名称:lastpass-cli,代码行数:29,代码来源:endpoints.c

示例2: TEST

TEST(FileTransfer, DetectsIncorrectUploadFilePath)
{
    CURL *curl;

    std::string source_file = "/accounts/1000/shared/camera/abcdefg.hij";
    std::string target_url = "http://bojap.com/omg/uploader.php";

    std::string source_escaped(curl_easy_escape(curl, curl_easy_escape(curl, source_file.c_str(), 0), 0));
    std::string target_escaped(curl_easy_escape(curl, curl_easy_escape(curl, target_url.c_str(), 0), 0));

    std::string expected = "upload error 1 " + source_escaped + " " + target_escaped + " 0";

    webworks::FileUploadInfo upload_info;
    upload_info.sourceFile = source_file;
    upload_info.targetURL = target_url;
    upload_info.mimeType = "image/jpeg";
    upload_info.fileKey = "image";
    upload_info.fileName = "new_image.jpg";
    upload_info.chunkedMode = 1;

    webworks::FileTransferCurl file_transfer;
    std::string result = file_transfer.Upload(&upload_info);

    EXPECT_EQ(expected, result);
}
开发者ID:adrianlee,项目名称:BB10-WebWorks-Framework,代码行数:25,代码来源:test_main.cpp

示例3: pcs_http_form_addbuffer

PCS_API PcsBool pcs_http_form_addbuffer(PcsHttp handle, PcsHttpForm *post, const char *param_name,
										const char *buffer, long buffer_size, const char *simulate_filename)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	struct http_post *formpost = (struct http_post *)(*post);
	char *escape_param_name, *escape_simulate_filename;
	PcsBool res = PcsTrue;
	if (!formpost) {
		formpost = (struct http_post *)pcs_malloc(sizeof(struct http_post));
		if (!formpost)
			return PcsFalse;
		memset(formpost, 0, sizeof(struct http_post));
		(*post) = (PcsHttpForm)formpost;
	}
	escape_param_name = curl_easy_escape(http->curl, param_name, 0);
	escape_simulate_filename = simulate_filename ? curl_easy_escape(http->curl, simulate_filename, 0) : NULL;
	if (curl_formadd(&(formpost->formpost), &(formpost->lastptr), 
		CURLFORM_COPYNAME, escape_param_name,
		CURLFORM_BUFFER, escape_simulate_filename ? escape_simulate_filename : "part",
		CURLFORM_BUFFERPTR, buffer,
		CURLFORM_BUFFERLENGTH, buffer_size,
		CURLFORM_END))
		res = PcsFalse;
	curl_free((void *)escape_param_name);
	if (escape_simulate_filename) curl_free((void *)escape_simulate_filename);
	return res;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:27,代码来源:pcs_http.c

示例4: pcs_http_form_addbufferfile

PCS_API PcsBool pcs_http_form_addbufferfile(PcsHttp handle, PcsHttpForm *post, const char *param_name, const char *simulate_filename,
	size_t(*read_func)(void *ptr, size_t size, size_t nmemb, void *userdata), void *userdata, size_t content_size)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	struct http_post *formpost = (struct http_post *)(*post);
	char *escape_param_name, *escape_simulate_filename;
	PcsBool res = PcsTrue;
	if (!formpost) {
		formpost = (struct http_post *)pcs_malloc(sizeof(struct http_post));
		if (!formpost)
			return PcsFalse;
		memset(formpost, 0, sizeof(struct http_post));
		(*post) = (PcsHttpForm)formpost;
	}
	escape_param_name = curl_easy_escape(http->curl, param_name, 0);
	escape_simulate_filename = simulate_filename ? curl_easy_escape(http->curl, simulate_filename, 0) : NULL;
	if (curl_formadd(&(formpost->formpost), &(formpost->lastptr),
		CURLFORM_COPYNAME, escape_param_name,
		CURLFORM_STREAM, userdata,
		CURLFORM_CONTENTSLENGTH, (long) content_size,
		CURLFORM_FILENAME, escape_simulate_filename ? escape_simulate_filename : "part",
		CURLFORM_END)) {
		res = PcsFalse;
	}
	curl_free((void *)escape_param_name);
	if (escape_simulate_filename) curl_free((void *)escape_simulate_filename);
	formpost->read_func = read_func;
	formpost->read_func_data = userdata;
	return res;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:30,代码来源:pcs_http.c

示例5: pcs_http_form_addfile

PCS_API PcsBool pcs_http_form_addfile(PcsHttp handle, PcsHttpForm *post, const char *param_name, 
									  const char *filename, const char *simulate_filename)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	struct http_post *formpost = (struct http_post *)(*post);
	char *escape_param_name, *escape_simulate_filename;
	PcsBool res = PcsTrue;
	if (!formpost) {
		formpost = (struct http_post *)pcs_malloc(sizeof(struct http_post));
		if (!formpost)
			return PcsFalse;
		memset(formpost, 0, sizeof(struct http_post));
		(*post) = (PcsHttpForm)formpost;
	}
	escape_param_name = curl_easy_escape(http->curl, param_name, 0);//pcs_http_escape(handle, param_name);
	escape_simulate_filename = curl_easy_escape(http->curl, simulate_filename, 0);//pcs_http_escape(handle, simulate_filename);
	if (curl_formadd(&(formpost->formpost), &(formpost->lastptr), 
		CURLFORM_COPYNAME, escape_param_name,
		CURLFORM_FILE, filename,
		CURLFORM_FILENAME, escape_simulate_filename,
		CURLFORM_END)) {
		res = PcsFalse;
	}
	curl_free((void *)escape_param_name);//pcs_free(escape_param_name);
	curl_free((void *)escape_simulate_filename);//pcs_free(escape_simulate_filename);
	return res;
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:27,代码来源:pcs_http.c

示例6: influxdb_client_get_url_with_credential

/**
 * Forge real URL to the API using given client config and parameters
 */
int
influxdb_client_get_url_with_credential(s_influxdb_client *client,
                                        char (*buffer)[],
                                        size_t size,
                                        char *path,
                                        char *username,
                                        char *password)
{
    char *username_enc = curl_easy_escape(NULL, username, 0);
    char *password_enc = curl_easy_escape(NULL, password, 0);

    (*buffer)[0] = '\0';
    strncat(*buffer, client->schema, size);
    strncat(*buffer, "://", size);
    strncat(*buffer, client->host, size);
    strncat(*buffer, path, size);

    if (strchr(path, '?'))
        strncat(*buffer, "&", size);
    else
        strncat(*buffer, "?", size);

    strncat(*buffer, "u=", size);
    strncat(*buffer, username_enc, size);
    strncat(*buffer, "&p=", size);
    strncat(*buffer, password_enc, size);

    free(username_enc);
    free(password_enc);

    return strlen(*buffer);
}
开发者ID:Mike-nour3,项目名称:influxdb-c,代码行数:35,代码来源:client.c

示例7: new_curl_handle

 bool DumbRelayConsumer::check_authentication(const std::multimap<std::string, std::string> &params) {
     // Construct the data for the post.
     std::ostringstream data;
     CURL *curl = new_curl_handle();
     data << "openid.mode=check_authentication";
     for(std::multimap<std::string, std::string>::const_iterator iter = params.begin();
         iter != params.end();
         ++iter) {
         if(iter->first.compare("openid.mode") == 0) continue;
         
         char *tmp;
         tmp = curl_easy_escape(curl, iter->first.c_str(), iter->first.size());
         data << "&" << tmp << "=";
         curl_free(tmp);
         
         tmp = curl_easy_escape(curl, iter->second.c_str(), iter->second.size());
         data << tmp;
         curl_free(tmp);
     }
     // Clean up after curl.
     curl_easy_cleanup(curl);
     
     // Prepare the curl handle.
     std::string content = contact_openid_provider(data.str());
     
     // Check to see if we can find the is_valid:true response.
     return content.find("\nis_valid:true\n") != content.npos;
 }
开发者ID:ibd1279,项目名称:logjammin,代码行数:28,代码来源:OpenID.cpp

示例8: t3net_add_argument

int t3net_add_argument(T3NET_ARGUMENTS * arguments, const char * key, const char * val)
{
	CURL * curl;

	if(arguments->count < T3NET_MAX_ARGUMENTS)
	{
		curl = curl_easy_init();
		if(!curl)
		{
			return 0;
		}
		arguments->key[arguments->count] = curl_easy_escape(curl, key, 0);
		if(!arguments->key[arguments->count])
		{
			return 0;
		}
		arguments->val[arguments->count] = curl_easy_escape(curl, val, 0);
		if(!arguments->val[arguments->count])
		{
			curl_free(arguments->key[arguments->count]);
			return 0;
		}
		arguments->count++;
		return 1;
	}
	return 0;
}
开发者ID:NewCreature,项目名称:Paintball-Party-2,代码行数:27,代码来源:t3net.c

示例9: get_string_envs

static int get_string_envs(CURL *curl, const char *required_env, char *querystring)
{
	char *data = NULL;
	char *escaped_key = NULL;
	char *escaped_val = NULL;
	char *env_string = NULL;

	char *params_key[MAXPARAMSNUM];
	char *env_names[MAXPARAMSNUM];
	char *env_value[MAXPARAMSNUM];
	int i, num = 0;

	//_log(LOG_DEBUG, "sys_envs=%s", sys_envs);

	env_string = (char *)malloc( strlen(required_env) + 20);
	if (env_string == NULL) {
		_fatal("ENOMEM");
		return (-1);
	}
	sprintf(env_string, "%s", required_env);

	//_log(LOG_DEBUG, "env_string=%s", env_string);

	num = get_sys_envs(env_string, ",", "=", params_key, env_names, env_value);
	//sprintf(querystring, "");
	for( i = 0; i < num; i++ ){
		escaped_key = curl_easy_escape(curl, params_key[i], 0);
		escaped_val = curl_easy_escape(curl, env_value[i], 0);

		//_log(LOG_DEBUG, "key=%s", params_key[i]);
		//_log(LOG_DEBUG, "escaped_key=%s", escaped_key);
		//_log(LOG_DEBUG, "escaped_val=%s", escaped_envvalue);

		data = (char *)malloc(strlen(escaped_key) + strlen(escaped_val) + 1);
		if ( data == NULL ) {
			_fatal("ENOMEM");
			return (-1);
		}
		sprintf(data, "%s=%s&", escaped_key, escaped_val);
		if ( i == 0 ) {
			sprintf(querystring, "%s", data);
		} else {
			strcat(querystring, data);
		}
	}

	if (data) free(data);
	if (escaped_key) free(escaped_key);
	if (escaped_val) free(escaped_val);
	free(env_string);
	return (num);
}
开发者ID:Mecabot,项目名称:mosquitto-auth-plug,代码行数:52,代码来源:be-jwt.c

示例10: curl_post

void curl_post(std::string &sURL, std::string &postData){

			CURL *curl;
	CURLcode res;
 
	curl_global_init(CURL_GLOBAL_DEFAULT);
 
	curl = curl_easy_init();
	if(curl) {

		/* to keep the response */
		std::stringstream responseData;
		char* safeurl = curl_easy_escape(curl, sURL.c_str(), 0);
	//hostname, api key, machine id, validShare, shareValue, rejectReason
		curl_easy_setopt(curl, CURLOPT_URL, safeurl);
		
	//	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
	 //   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
 
		curl_easy_setopt(curl, CURLOPT_POST, 1);
		char* safepostData = curl_easy_escape(curl, postData.c_str(), 0);
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS,  safepostData);
		/* setting a callback function to return the data */
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_callback_func);

		/* passing the pointer to the response as the callback parameter */
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseData);


		//curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
		
		/* Perform the request, res will get the return code */ 
		res = curl_easy_perform(curl);
		/* Check for errors */ 
		//if(res != CURLE_OK)
		//	fprintf(stderr, "curl_easy_perform() failed: %s\n",
		//		curl_easy_strerror(res));

		/* always cleanup */ 
		curl_free(safeurl);
		curl_free(safepostData);
		curl_easy_cleanup(curl);

		std::cout << std::endl << "Reponse from server: " << responseData.str() << std::endl;

			}
 
	curl_global_cleanup();

}
开发者ID:SN4T14,项目名称:jhPrimeminer,代码行数:50,代码来源:stats.cpp

示例11: curl_easy_escape

BOOL  CUnBindDeviceHttpCMD::Init()
{
    CNGString strTemp;
    char *efc = NULL;
    m_strfields.append("_ch=");
    strTemp = AUTH_TYPE_MAXNET;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    m_strfields.append(efc);
    curl_free(efc);

    m_strfields.append("&deviceid=");
    strTemp = stReq.aszDeviceID;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    m_strfields.append(efc);
    curl_free(efc);

    m_strfields.append("&username=");
    strTemp = stReq.aszUserName;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    m_strfields.append(efc);
    curl_free(efc);


    //临时路径打包上签名
    string	strTempUrl = m_strUrl;
    UINT8	abyDigest[16] = {0};
    string	strInput = m_strfields;
    strInput.append(CENTER_SIGN);
    SDMD5(abyDigest, (UINT8*)strInput.c_str(), strInput.length());
    CHAR szTemp[32] = {0};
    CHAR szHexDigest[256] = {0};
    for (UINT8 byIdx = 0; byIdx < 16; byIdx++)
    {
        sprintf(szTemp, "%02x", (UINT8)abyDigest[byIdx]);
        strcat(szHexDigest, szTemp);
    }
    strTempUrl.append("?_sig=");
    strTemp = szHexDigest;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    strTempUrl.append(efc);
    curl_free(efc);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_URL, strTempUrl.c_str());
    curl_easy_setopt(m_pEasyHandle, CURLOPT_ERRORBUFFER, m_szErrorBuff);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_POST, 1 );
    curl_easy_setopt(m_pEasyHandle, CURLOPT_TIMEOUT, 2);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_POSTFIELDS, m_strfields.c_str());
    return TRUE;
}
开发者ID:mildrock,项目名称:dummy,代码行数:49,代码来源:unbinddevicehttpcmd.cpp

示例12: pb_getUserSessionKey

pb_status pb_getUserSessionKey( pastebin* _pb, char* _username, char* _password )
{
    // note that we don't store the username or password; just the key after it completes successfully. 
    debugf( "Entering function with argument %s: %s, %s: %s\n", stringify( _username ), _username, stringify( _password ), _password );

    if( !_username )
    {
        debugf( "username is NULL!\n" );
        return STATUS_USERNAME_IS_NULL;
    }
    if( !_password )
    {
        debugf( "password is NULL!\n" );
        return STATUS_PASSWORD_IS_NULL;
    }

    
    char* argu = (char*)malloc( sizeof(char)*1024 ); // 1kb should suffice. If it doesn't, your password is too long, bro
    char* user = (char*)malloc( sizeof(char)*strlen(_username)*3 );
    char* pass = (char*)malloc( sizeof(char)*strlen(_password)*3 );
    CURL* curl = curl_easy_init();
    user = curl_easy_escape( curl, _username, strlen( _username ) );
    pass = curl_easy_escape( curl, _password, strlen( _password ) );
    struct pb_memblock chunk;

    chunk.memory = malloc(1);
    chunk.size   = 0;

    curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, pb_memcopy );
    curl_easy_setopt( curl, CURLOPT_WRITEDATA, (void*)&chunk );

    curl_easy_setopt( curl, CURLOPT_URL, PB_API_LOGIN_URL );
    curl_easy_setopt( curl, CURLOPT_POST, 1 );

    sprintf( argu, "api_dev_key=%s&api_user_name=%s&api_user_password=%s", _pb->devkey, user, pass );
    debugf( "Curl postfields:\n%s\n", argu );

    curl_easy_setopt( curl, CURLOPT_POSTFIELDS, argu );
    curl_easy_setopt( curl, CURLOPT_NOBODY, 0 );

    curl_easy_perform( curl );
    debugf( "user key is:\n%s\n", chunk.memory );
    _pb->userkey = chunk.memory;

    debugf( "Exiting function\n" );

    return STATUS_OKAY;
}
开发者ID:camilaespia,项目名称:libpastebin,代码行数:48,代码来源:pastebin.c

示例13: SetStatus

wxThread::ExitCode PastebinTask::TaskStart()
{
    SetStatus(_("Sending to pastebin..."));

    // Create handle
    CURL *curl = curl_easy_init();
    char errBuffer[CURL_ERROR_SIZE];

    // URL encode
    wxCharBuffer contentBuf = m_content.ToUTF8();
    char *content = curl_easy_escape(curl, contentBuf.data(), strlen(contentBuf));

    wxCharBuffer posterBuf = m_author.ToUTF8();
    char *poster = curl_easy_escape(curl, posterBuf.data(), strlen(posterBuf));

    wxString postFields;
    postFields << "poster=" << poster << "&syntax=text&content=" << content;

    curl_easy_setopt(curl, CURLOPT_URL, "http://paste.ubuntu.com/");
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlLambdaCallback);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cStr(postFields));
    curl_easy_setopt(curl, CURLOPT_HEADER, true);
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &errBuffer);

    wxString outString;
    wxStringOutputStream outStream(&outString);
    CurlLambdaCallbackFunction curlWrite = [&] (void *buffer, size_t size) -> size_t
    {
        outStream.Write(buffer, size);
        return outStream.LastWrite();
    };
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlWrite);

    int status = curl_easy_perform(curl);

    if (status == 0)
    {
        // Parse the response header for the redirect location.
        m_pasteURL = outString.Mid(outString.Find("Location: ") + 10);
        m_pasteURL = m_pasteURL.Mid(0, m_pasteURL.Find('\n'));
        return (ExitCode)1;
    }
    else
    {
        EmitErrorMessage(wxString::Format("Pastebin failed: %s", errBuffer));
        return (ExitCode)0;
    }
}
开发者ID:Glought,项目名称:MultiMC4,代码行数:48,代码来源:pastebintask.cpp

示例14: curl_easy_escape

BOOL CNameHttpCMD::Init()
{
    CNGString strTemp;
    char *efc = NULL;
    m_strfields.append("playerid=");
    strTemp = stNameInfo.dwPlayerID;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    m_strfields.append(efc);
    curl_free(efc);

    m_strfields.append("&name=");
    strTemp = stNameInfo.strName;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    m_strfields.append(efc);
    curl_free(efc);

	m_strfields.append("&_ch=");
	strTemp = stNameInfo.byAuthType;
	efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
	m_strfields.append(efc);
	curl_free(efc);

    //地址
    string	strTempUrl = m_strUrl;
    UINT8	abyDigest[16] = {0};
    string	strInput = m_strfields;
    strInput.append(CENTER_SIGN);
    SDMD5(abyDigest, (UINT8*)strInput.c_str(), strInput.length());
    CHAR szTemp[32] = {0};
    CHAR szHexDigest[256] = {0};
    for (UINT8 byIdx = 0; byIdx < 16; byIdx++)
    {
        sprintf(szTemp, "%02x", (UINT8)abyDigest[byIdx]);
        strcat(szHexDigest, szTemp);
    }
    strTempUrl.append("?_sig=");
    strTemp = szHexDigest;
    efc = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0);
    strTempUrl.append(efc);
    curl_free(efc);

    curl_easy_setopt(m_pEasyHandle, CURLOPT_URL, strTempUrl.c_str());
    curl_easy_setopt(m_pEasyHandle, CURLOPT_ERRORBUFFER, m_szErrorBuff);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(m_pEasyHandle, CURLOPT_POST, 1 );
    curl_easy_setopt(m_pEasyHandle, CURLOPT_POSTFIELDS, m_strfields.c_str());
    return TRUE;
}
开发者ID:mildrock,项目名称:dummy,代码行数:48,代码来源:namehttpcmd.cpp

示例15: urlEncode

inline std::string urlEncode(CURL* curl, const std::string text)
{
    char* enc = curl_easy_escape(curl, text.c_str(), text.size());
    std::string res(enc);
    curl_free(enc);
    return res;
}
开发者ID:4Enjoy,项目名称:ADLib,代码行数:7,代码来源:ADHttp_CURL.hpp


注:本文中的curl_easy_escape函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。