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


C++ curl_free函数代码示例

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


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

示例1: curl_easy_init

	/**
	 * URL encodes the input string.
	 * @param QString input
	 * @returns QString
	 * @author John M. Harris, Jr.
	 */
	QString HttpService::UrlEncode(QString input){
		CURL* curl;

		curl = curl_easy_init();
		if(curl){
			char* encoded = curl_easy_escape(curl, input.toStdString().c_str(), 0);

			size_t thingLen = strlen(encoded) + 1;
			char* newGuy = new char[thingLen];
			strcpy(newGuy, encoded);
			//newGuy[thingLen] = '\0';

			curl_free(encoded);
			curl_easy_cleanup(curl);

			return QString(newGuy);
		}
		return "";
	}
开发者ID:RobloxLabs,项目名称:OpenBlox,代码行数:25,代码来源:HttpService.cpp

示例2: test

int test(char *URL)
{
  unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
                       0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
  CURLcode res;
  CURL *curl;
  int asize;
  char *str = NULL;

  (void)URL;

  res = curl_global_init_mem(CURL_GLOBAL_ALL,
                             custom_malloc,
                             custom_free,
                             custom_realloc,
                             custom_strdup,
                             custom_calloc);
  if (res != CURLE_OK) {
    fprintf(stderr, "curl_global_init_mem() failed\n");
    return TEST_ERR_MAJOR_BAD;
  }

  if ((curl = curl_easy_init()) == NULL) {
    fprintf(stderr, "curl_easy_init() failed\n");
    curl_global_cleanup();
    return TEST_ERR_MAJOR_BAD;
  }

  test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */

  asize = (int)sizeof(a);
  str = curl_easy_escape(curl, (char *)a, asize); /* uses realloc() */

test_cleanup:

  if(str)
    curl_free(str);

  curl_easy_cleanup(curl);
  curl_global_cleanup();

  return (int)res;
}
开发者ID:08142008,项目名称:curl,代码行数:43,代码来源:lib509.c

示例3: http_post

bool
http_post(const char *url, http_response_t *resp, int pairs, ...)
{
    CURL *curl;
    CURLcode res;

    int i, len=0;
    char *k[pairs], *v[pairs], *vv[pairs];
    va_list params;
    va_start(params, pairs);
    for (i=0; i<pairs; i++) {
        k[i] = va_arg(params, char *);
        v[i] = va_arg(params, char *);
        vv[i]= curl_easy_escape(curl, v[i], 0);
        tlog(DEBUG, "http post: %s = %s(%s)", k[i], v[i], vv[i]);
        len += 4+strlen(k[i])+strlen(vv[i]);
    }
    va_end(params);

    char data[len];
    memset(data, 0, len);
    for (i=0; i<pairs; i++) {
        strcat(data, "&");
        strcat(data, k[i]);
        strcat(data, "=");
        strcat(data, vv[i]);
        curl_free(vv[i]);
    }
    tlog(DEBUG, "http post: data = %s", data);

    curl = curl_easy_init();
    if (curl != NULL) {
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_POST, 1);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_memory_cb);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)resp);
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        return res==CURLE_OK;
    }
    return false;
}
开发者ID:tanec,项目名称:fcache,代码行数:43,代码来源:http-api.c

示例4: SDMD5

void CPushPlayerInfoHttpCMD::EscapeUrl(CHAR szUrl[], UINT16 wLen)
{
    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);
    }

    char *szEscapeHex = curl_easy_escape(m_pEasyHandle, szHexDigest, 0);;
    SDSnprintf(szUrl, wLen, "%s?_sig=%s", m_strUrl.c_str(), szEscapeHex);

    curl_free(szEscapeHex);
}
开发者ID:mildrock,项目名称:dummy,代码行数:19,代码来源:pushplayerinfohttpcmd.cpp

示例5: get_url_file_name

/* Extracts the name portion of the URL.
 * Returns a pointer to a heap-allocated string or NULL if
 * no name part, at location indicated by first argument.
 */
CURLcode get_url_file_name(char **filename, const char *url)
{
  const char *pc;

  *filename = NULL;

  /* Find and get the remote file name */
  pc = strstr(url, "://");
  if(pc)
    pc += 3;
  else
    pc = url;
  pc = strrchr(pc, '/');

  if(pc) {
    /* duplicate the string beyond the slash */
    pc++;
    if(*pc) {
      *filename = strdup(pc);
      if(!*filename)
        return CURLE_OUT_OF_MEMORY;
    }
  }

  /* in case we built debug enabled, we allow an environment variable
   * named CURL_TESTDIR to prefix the given file name to put it into a
   * specific directory
   */
#ifdef DEBUGBUILD
  {
    char *tdir = curlx_getenv("CURL_TESTDIR");
    if(tdir) {
      char buffer[512]; /* suitably large */
      snprintf(buffer, sizeof(buffer), "%s/%s", tdir, *filename);
      Curl_safefree(*filename);
      *filename = strdup(buffer); /* clone the buffer */
      curl_free(tdir);
    }
  }
#endif

  return CURLE_OK;
}
开发者ID:4Second2None,项目名称:curl,代码行数:47,代码来源:tool_operhlp.c

示例6: http_client_uri_escape

char *
http_client_uri_escape(const char *src)
{
#if GLIB_CHECK_VERSION(2,16,0)
	/* if GLib is recent enough, prefer that over CURL
	   functions */
	return g_uri_escape_string(src, NULL, false);
#else
	/* curl_escape() is deprecated, but for some reason,
	   curl_easy_escape() wants to have a CURL object, which we
	   don't have right now */
	char *tmp = curl_escape(src, 0);
	/* call g_strdup(), because the caller expects a pointer which
	   can be freed with g_free() */
	char *dest = g_strdup(tmp == NULL ? src : tmp);
	curl_free(tmp);
	return dest;
#endif
}
开发者ID:L0op,项目名称:RuneAudioNext,代码行数:19,代码来源:http_client_curl.c

示例7: apr_psprintf

static const char *make_url(const request_rec *r, const crowd_config *config, CURL *curl_easy, const char *user,
    const char *format) {
    char *url;
    if (user == NULL) {
        url = apr_psprintf(r->pool, format, config->crowd_url);
    } else {
        char *encoded_user = log_ralloc(r, curl_easy_escape(curl_easy, user, 0));
        if (encoded_user == NULL) {
            return NULL;
        }
        url = apr_psprintf(r->pool, format, config->crowd_url, encoded_user);
        curl_free(encoded_user);
    }
    log_ralloc(r, url);
    if (url == NULL) {
        return NULL;
    }
    return url;
}
开发者ID:CoreMedia,项目名称:cwdapache,代码行数:19,代码来源:crowd_client.c

示例8: while

PCS_API char *pcs_http_build_post_data_v(PcsHttp handle, va_list args)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	char *name, *val, 
		*escapval, *res = NULL, *p;
	int ressz;

	while((name = va_arg(args, char *)) != NULL) {
		val = va_arg(args, char *);
		if (name[0] == '\0') continue;
		escapval = curl_easy_escape(http->curl, val, 0);

		if (!res) {
			ressz = strlen(name) + strlen(escapval) + 1;
			res = (char *)pcs_malloc(ressz + 1);
			if (!res) {
				return NULL;
			}
			strcpy(res, name);
			strcat(res, "=");
			strcat(res, escapval);
		}
		else {
			ressz += strlen(name) + strlen(escapval) + 2;
			p = (char *)pcs_malloc(ressz + 1);
			if (!p) {
				pcs_free(res);
				return NULL;
			}
			strcpy(p, res);
			pcs_free(res);
			res = p;
			strcat(res, "&");
			strcat(res, name);
			strcat(res, "=");
			strcat(res, escapval);
		}
		curl_free((void *)escapval);
	}

	return res;
}
开发者ID:hipboi,项目名称:BaiduPCS,代码行数:42,代码来源:pcs_http.c

示例9: while

bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_disk)
{
	// remove from param list
	std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name);
	if(mIt != mParamList.end()) 
	{
		mParamList.erase(mIt);
	}

	F32 key;

	// remove all references
	bool stat = true;
	do 
	{
		// get it
		stat = mDay.getKey(name, key);
		if(stat == false) 
		{
			break;
		}

		// and remove
		stat = mDay.removeKey(key);

	} while(stat == true);
	
	if(delete_from_disk)
	{
		std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
		
		// use full curl escaped name
		char * curl_str = curl_escape(name.c_str(), name.size());
		std::string escaped_name(curl_str);
		curl_free(curl_str);
		curl_str = NULL;
		
		gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml");
	}

	return true;
}
开发者ID:Nora28,项目名称:imprudence,代码行数:42,代码来源:llwlparammanager.cpp

示例10: http_escape

bool
http_escape(const char *in, char *out)
{
    char *res = NULL;
    CURL *curl;
    bool ret = false;

    curl = curl_easy_init();
    if (curl != NULL) {
        res = curl_easy_escape(curl, in, 0);
        if (res != NULL) {
            memcpy(out, res, strlen(res)+1);
            ret = true;
            curl_free(res);
        }
        curl_easy_cleanup(curl);
        return ret;
    }
    return false;
}
开发者ID:tanec,项目名称:fcache,代码行数:20,代码来源:http-api.c

示例11: url_unescape

/* exported interface documented in utils/url.h */
nserror url_unescape(const char *str, int length, char **result)
{
	char *curlstr;
	char *retstr;

	curlstr = curl_unescape(str, length);
	if (curlstr == NULL) {
		return NSERROR_NOMEM;
	}

	retstr = strdup(curlstr);
	curl_free(curlstr);

	if (retstr == NULL) {
		return NSERROR_NOMEM;
	}

	*result = retstr;
	return NSERROR_OK;
}
开发者ID:janrinze,项目名称:netsurf,代码行数:21,代码来源:url.c

示例12: curl_escape

void LLWLDayCycle::saveDayCycle(const std::string & fileName)
{
	
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(fileName.c_str(), fileName.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", escaped_filename));
	llinfos << "Saving Day Cycle preset from " << pathName << llendl;

	llofstream day_cycle_xml;
	day_cycle_xml.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!day_cycle_xml)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename);
		llinfos << "Saving User Day Cycle preset from " << pathName << llendl;
		day_cycle_xml.open(pathName.c_str());
	}

	LLSD day_data(LLSD::emptyArray());

	for(std::map<F32, std::string>::const_iterator mIt = mTimeMap.begin();
		mIt != mTimeMap.end();
		++mIt) 
	{
		LLSD key(LLSD::emptyArray());
		key.append(mIt->first);
		key.append(mIt->second);
		day_data.append(key);
	}

	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY);
	day_cycle_xml.close();
}
开发者ID:Beeks,项目名称:Ascent,代码行数:41,代码来源:llwldaycycle.cpp

示例13: curl_url_encoding

int
curl_url_encoding(CURL *curl, char *input, char *output, size_t size)
{
  ol_log_func ();
  char *escp;
  int flag = 0;
  if(curl == NULL) {
    curl = curl_easy_init();
    flag = 1;
  }

  /* 
   * convert to GBK, this should be done before this function called
   *
   char buf[BUFSZ];
   iconv_t icv;
   if(charset != NULL)
   icv = iconv_open("GBK", charset);
   else
   icv = iconv_open("GBK", "UTF-8");
	
   convert_icv(&icv, input, strlen(input), buf, BUFSZ);
   iconv_close(icv);
  */

  escp = curl_easy_escape(curl, input, 0);
  if(escp == NULL) {
    ol_errorf ("curl_easy_escape error.\n");
    return -1;
  }
  if(strlen(escp) > size) {
    errno = E2BIG; /* identify that buffer storing the result is too small */
    return -1;
  }
  strcpy(output, escp);
  curl_free(escp);

  if(flag == 1)
    curl_easy_cleanup(curl);
  return 0;
}
开发者ID:AhmadMAlam,项目名称:osd-lyrics,代码行数:41,代码来源:ol_lrc_fetch_utils.c

示例14: viprinet_status_connect

int viprinet_status_connect(viprinet_status_t *status)
{
    char *password_encoded;
    char uri[MAX_URI_LEN];
    int rc;

    pthread_attr_t ptattr;

    if (status == NULL) {
        return -1;
    }
    if (status->close != -1) {
        return -1;
    }
    
    password_encoded = curl_easy_escape(status->curl, status->password, 0);
    snprintf(uri, MAX_URI_LEN,
             "http://%s/exec?module=interfacestats&action=data&group=ModuleSlots&nick=root&pass=%s",
             status->hostname,
             password_encoded);
    curl_free(password_encoded);
    
    status->close = 0;
    
    curl_easy_setopt(status->curl, CURLOPT_URL, uri);
    curl_easy_setopt(status->curl, CURLOPT_NOPROGRESS, 0);
    curl_easy_setopt(status->curl, CURLOPT_PROGRESSDATA, status);
    curl_easy_setopt(status->curl, CURLOPT_PROGRESSFUNCTION, &progress_callback);
    curl_easy_setopt(status->curl, CURLOPT_WRITEFUNCTION, &write_callback);
    curl_easy_setopt(status->curl, CURLOPT_WRITEDATA, status);
   
    pthread_attr_init(&ptattr);
    pthread_attr_setdetachstate(&ptattr, PTHREAD_CREATE_JOINABLE);
    rc = pthread_create(status->thread, &ptattr, &perform, (void *)status);
    pthread_attr_destroy(&ptattr);

    if (rc) {
        return -2;
    }
    return 0;
}
开发者ID:endlernet,项目名称:viprinet,代码行数:41,代码来源:viprinet_status.c

示例15: wswcurl_urlencode

void wswcurl_urlencode( const char *src, char *dst, size_t size )
{
	char *curl_esc;

	assert( src );
	assert( dst );

	if( !src || !dst ) {
		return;
	}

	// libcurl needs a curl pointer to be passed to a function that
	// should clearly be "static", how inconvenient...
	if( !curldummy ) {
		curldummy = curl_easy_init();
	}

	curl_esc = curl_easy_escape( curldummy, src, 0 );
	Q_strncpyz( dst, curl_esc, size );
	curl_free( curl_esc );
}
开发者ID:ewirch,项目名称:qfusion,代码行数:21,代码来源:wswcurl.c


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