• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ curl_easy_unescape函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: decode_url

static gchar *
decode_url(const gchar *url)
{
	int col = 0;
	int row;
	int x;
	int len;
	int i, j, k;
	gchar *array;
	gchar *decode_url = NULL;
	gchar *p;

	if (url == NULL)
		return NULL;

	row = *url - '0';
	len = strlen(url + 1);
	col = len / row;
	x = len % row;

	if (x != 0)
	col += 1;

	array = (char *)calloc(len + sizeof(char), sizeof(char));

	k = 1;
	for(i=0; i<row; i++)
	{
		for(j=0; j<col; j++, k++)
			array[i + row * j] = url[k];

		if (x > 0)
		{
			x--;
			if(x == 0)
			 col -= 1;
		}
	}

	decode_url = curl_easy_unescape(NULL, array, 0, NULL);
	p = decode_url;

	while(*p)
	{
		if (*p == '^')
			*p = '0';
		p++;
	}
	free(array);

	return decode_url;
}
开发者ID:EmbolismSoil,项目名称:xmradio,代码行数:52,代码来源:xmsearch.c


示例2: debug1

cString cSatipRtsp::RtspUnescapeString(const char *strP)
{
  debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, strP, tunerM.GetId());
  if (handleM) {
     char *p = curl_easy_unescape(handleM, strP, 0, NULL);
     cString s = p;
     curl_free(p);

     return s;
     }

  return cString(strP);
}
开发者ID:nafets227,项目名称:vdr-plugin-satip,代码行数:13,代码来源:rtsp.c


示例3: pop3_parse_url_path

/***********************************************************************
 *
 * pop3_parse_url_path()
 *
 * Parse the URL path into separate path components.
 *
 */
static CURLcode pop3_parse_url_path(struct connectdata *conn)
{
  /* the pop3 struct is already inited in pop3_connect() */
  struct pop3_conn *pop3c = &conn->proto.pop3c;
  struct SessionHandle *data = conn->data;
  const char *path = data->state.path;
  int len;

  /* url decode the path and use this mailbox */
  pop3c->mailbox = curl_easy_unescape(data, path, 0, &len);

  return CURLE_OK;
}
开发者ID:sherpya,项目名称:naitool,代码行数:20,代码来源:pop3.c


示例4: unescape_elements

/*
 * Unescape the LDAP-URL components
 */
static bool unescape_elements(void *data, LDAPURLDesc *ludp)
{
    int i;

    if (ludp->lud_filter)
    {
        ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL);
        if (!ludp->lud_filter)
            return (FALSE);
    }

    for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++)
    {
        ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
        if (!ludp->lud_attrs[i])
            return (FALSE);
    }

    for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++)
    {
        ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
        if (!ludp->lud_exts[i])
            return (FALSE);
    }

    if (ludp->lud_dn)
    {
        char *dn     = ludp->lud_dn;
        char *new_dn = curl_easy_unescape(data, dn, 0, NULL);

        free(dn);
        ludp->lud_dn = new_dn;
        if (!new_dn)
            return (FALSE);
    }

    return (TRUE);
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:41,代码来源:ldap.c


示例5: curl_easy_unescape

std::string curl::unescape(const std::string& encoded)
{
    int len = 0;
    char* rstr = curl_easy_unescape(m_curl, encoded.c_str(), encoded.size(), &len);

    if (!rstr)
    {
        throw std::bad_alloc();
    }

    boost::shared_ptr<char> str(rstr, curl_free);

    return std::string(str.get(), static_cast<size_t>(len));
}
开发者ID:reaper,项目名称:libfreelan,代码行数:14,代码来源:curl.cpp


示例6: curl_easy_unescape

char* LmcCom::unescape(char* buf)
{
   int len = 0;
   char* res;

   res = curl_easy_unescape(curl , buf, strlen(buf), &len);

   if (res)
      strcpy(buf, res);

   free(res);

   return buf;
}
开发者ID:horchi,项目名称:vdr-plugin-squeezebox,代码行数:14,代码来源:lmccom.c


示例7: main

int main()
{
	CURL *curl = curl_easy_init( );

	printf("Content-Type: text/html;charset=us-ascii\n\n");
	char *q = getenv("QUERY_STRING");
	if(q == NULL || strlen(q) <= 0)
	{
		printf("<p>You must pass in some source code.</p>");
		return 1;
	}
	if(strlen(q) > 1024)
	{
		printf("<p>The source code is too long.</p>");
		return 1;
	}

	q = curl_easy_unescape(curl, q, strlen(q), NULL);

	FILE * log = fopen(HOME "/tmp/build.log", "w+");
	char * filename = tempnam("/tmp", "gcc_");
	fprintf(log, "%d IP: %s Output: %s\n", time(0), getenv("REMOTE_ADDR"), filename);
	fflush(log);
	
	chdir(HOME "/root");
	chroot(HOME "/root");

	struct passwd *passwd = getpwnam(USER);
	if(passwd == NULL)
	{
		printf("<p>User does not exist.</p>");
		return 1;
	}

	if(setuid(passwd->pw_uid) < 0)
		return 1;

	char buffer[2048];
	sprintf(buffer, "echo -n '%s' | gcc -x c -o %s -", q, filename);

	printf("Starting build...\n");

	int pid = safe_system(buffer);
	
	fprintf(log, "%d %s done.\n", time(0), filename);
	fclose(log);

	sleep_kill(pid);
	return 0;
}
开发者ID:0xBU,项目名称:ctfs,代码行数:50,代码来源:15-An_innocent_CGI_script-compile.c


示例8: curl_easy_unescape

bool YoutubeCrawler::getMaxQualityURI(CURL *handle, std::string &content, std::vector<std::string> &results){
	size_t startPos = content.find("url_encoded_fmt_stream_map=");
	if(startPos == std::string::npos){
		return false;
	}
	startPos += 27;
	size_t endPos = content.find("&amp;", startPos);
	if(endPos == std::string::npos){
		endPos = content.find("\"", startPos);
		if(endPos == std::string::npos){
			return false;
		}
	}
	int cstringLen = 0;
	char *decodeContent = curl_easy_unescape(handle, content.c_str() + startPos, endPos - startPos, &cstringLen);
	content.assign(decodeContent, cstringLen);
	curl_free(decodeContent);
	startPos = content.find("url=");
	std::string tmpURI;
	while(startPos != std::string::npos){
		startPos += 4;
		endPos = content.find(",", startPos);
		if(endPos == std::string::npos){
			endPos = content.size();
		}
		decodeContent = curl_easy_unescape(handle, content.c_str() + startPos, endPos - startPos, &cstringLen);
		tmpURI.assign(decodeContent, cstringLen);
		tmpURI = tmpURI.substr(0, tmpURI.find(";"));
		curl_free(decodeContent);
		results.push_back(tmpURI);
		startPos = content.find("url=", endPos + 1);
	}
	if(results.size() == 0){
		return false;
	}
	return true;
}
开发者ID:flachesis,项目名称:youtube-video-fetch,代码行数:37,代码来源:YoutubeCrawler.cpp


示例9: session_unescape

// Unescapes the provided string.
VALUE session_unescape(VALUE self, VALUE value) {
  struct curl_state *state;
  Data_Get_Struct(self, struct curl_state, state);

  VALUE string = StringValue(value);
  char* unescaped = curl_easy_unescape(state->handle,
                                       RSTRING_PTR(string),
                                       RSTRING_LEN(string),
                                       NULL);

  VALUE retval = rb_str_new2(unescaped);
  curl_free(unescaped);

  return retval;
}
开发者ID:tmm1,项目名称:patron,代码行数:16,代码来源:session_ext.c


示例10: session_unescape

/*
 * Unescapes the provided string using libCURL URL escaping functions.
 *
 * @param [String] value URL-encoded String to unescape
*  @return [String] unescaped (decoded) string
 */
static VALUE session_unescape(VALUE self, VALUE value) {
  VALUE string = StringValue(value);
  char* unescaped = NULL;
  VALUE retval = Qnil;

  struct curl_state* state = curl_easy_init();
  unescaped = curl_easy_unescape(state->handle,
                                 RSTRING_PTR(string),
                                 (int) RSTRING_LEN(string),
                                 NULL);

  retval = rb_str_new2(unescaped);
  curl_free(unescaped);
  curl_easy_cleanup(state);

  return retval;
}
开发者ID:mmoll,项目名称:patron,代码行数:23,代码来源:session_ext.c


示例11: SogouParsePinyin

char* SogouParsePinyin(FcitxCloudPinyin* cloudpinyin, CurlQueue* queue)
{
    char *start = NULL, *end = NULL;
    if ((start = strchr(queue->str, '"')) != NULL && (end = strstr(queue->str, "%EF%BC%9A")) != NULL)
    {
        start ++;
        if (start < end)
        {
            size_t length = end - start;
            int conv_length;
            char *unescapedstring = curl_easy_unescape(queue->curl, start, length, &conv_length);
            char *realstring = strdup(unescapedstring);
            curl_free(unescapedstring);
            return realstring;
        }
    }
    return NULL;
}
开发者ID:pkg-ime,项目名称:fcitx-cloudpinyin,代码行数:18,代码来源:cloudpinyin.c


示例12: imap_parse_url_path

/***********************************************************************
 *
 * imap_parse_url_path()
 *
 * Parse the URL path into separate path components.
 *
 */
static CURLcode imap_parse_url_path(struct connectdata *conn)
{
  /* the imap struct is already inited in imap_connect() */
  struct imap_conn *imapc = &conn->proto.imapc;
  struct SessionHandle *data = conn->data;
  const char *path = data->state.path;
  int len;

  if(!*path)
    path = "INBOX";

  /* url decode the path and use this mailbox */
  imapc->mailbox = curl_easy_unescape(data, path, 0, &len);
  if(!imapc->mailbox)
    return CURLE_OUT_OF_MEMORY;

  return CURLE_OK;
}
开发者ID:1833183060,项目名称:wke,代码行数:25,代码来源:imap.c


示例13: curl_easy_init

	/**
	 * Decodes a URL encoded string and returns it.
	 * @param QString input
	 * @returns QString
	 * @author John M. Harris, Jr.
	 */
	QString HttpService::UrlDecode(QString input){
		CURL* curl;

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

			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


示例14: http_unescape

// out should be enough to hold result
bool
http_unescape(const char *in, char *out)
{
    int   len = -1;
    char *res = NULL;
    CURL *curl;
    bool ret = false;

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


示例15: unescape_word

static char* unescape_word(struct SessionHandle *data, const char *inputbuff)
{
    char *newp;
    char *dictp;
    char *ptr;
    int  len;
    char byte;
    int  olen = 0;

    newp = curl_easy_unescape(data, inputbuff, 0, &len);
    if (!newp)
        return NULL;

    dictp = malloc(((size_t)len) * 2 + 1); /* add one for terminating zero */
    if (dictp)
    {
        /* According to RFC2229 section 2.2, these letters need to be escaped with
         \[letter] */
        for (ptr = newp;
             (byte = *ptr) != 0;
             ptr++)
        {
            if ((byte <= 32) || (byte == 127) ||
                (byte == '\'') || (byte == '\"') || (byte == '\\'))
            {
                dictp[olen++] = '\\';
            }

            dictp[olen++] = byte;
        }

        dictp[olen] = 0;

        free(newp);
    }

    return dictp;
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:38,代码来源:dict.c


示例16: strstr

char *url_to_path(const char *url)
{
	char *tmps, *unesc;
	CURL *curl;

	tmps = strstr(url, "///localhost/") + 13;

	if(tmps < url) tmps = strstr(url,"///") + 3;

	if(tmps >= url)
	{
		if(curl = curl_easy_init())
		{
			unesc = curl_easy_unescape(curl,tmps,0,NULL);
			tmps = strdup(unesc);
			curl_free(unesc);
			curl_easy_cleanup(curl);
			return tmps;
		}
	}

	return strdup((char *)url);
}
开发者ID:MarkieMark,项目名称:netsurf-git-svn,代码行数:23,代码来源:misc.c


示例17: uim_curl_url_unescape_internal

static void *
uim_curl_url_unescape_internal(void *url_)
{
  uim_lisp unescaped_url_;
  const char *escaped_url = REFER_C_STR((uim_lisp)url_);
  char *unescaped_url;
  int len; /* curl_easy_unescape uses int, not size_t */
  CURL *curl;

  curl = curl_easy_init();

  if(curl == NULL)
    return uim_scm_f();

  unescaped_url = curl_easy_unescape(curl, escaped_url,
				     strlen(escaped_url), &len);
  unescaped_url_ = (len > 0) ? MAKE_STR(unescaped_url) : uim_scm_f();

  curl_free(unescaped_url);
  curl_easy_cleanup(curl);
  curl_global_cleanup();

  return (void *)unescaped_url_;
}
开发者ID:NgoHuy,项目名称:uim,代码行数:24,代码来源:curl.c


示例18: wswcurl_urldecode

size_t wswcurl_urldecode( const char *src, char *dst, size_t size )
{
	int unesc_len;
	char *curl_unesc;

	assert( src );
	assert( dst );

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

	// 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_unesc = curl_easy_unescape( curldummy, src, 0, &unesc_len );
	Q_strncpyz( dst, curl_unesc, size );
	curl_free( curl_unesc );

	return (size_t)unesc_len;
}
开发者ID:ewirch,项目名称:qfusion,代码行数:24,代码来源:wswcurl.c


示例19: smtp_connect

/*
 * smtp_connect() should do everything that is to be considered a part of
 * the connection phase.
 *
 * The variable 'done' points to will be TRUE if the protocol-layer connect
 * phase is done when this function returns, or FALSE is not. When called as
 * a part of the easy interface, it will always be TRUE.
 */
static CURLcode smtp_connect(struct connectdata *conn,
                             bool *done) /* see description above */
{
    CURLcode result;
    struct smtp_conn *smtpc = &conn->proto.smtpc;
    struct SessionHandle *data=conn->data;
    struct pingpong *pp=&smtpc->pp;
    const char *path = conn->data->state.path;
    int len;
    char localhost[1024 + 1];

    *done = FALSE; /* default to not done yet */

    /* If there already is a protocol-specific struct allocated for this
       sessionhandle, deal with it */
    Curl_reset_reqproto(conn);

    result = smtp_init(conn);
    if(CURLE_OK != result)
        return result;

    /* We always support persistant connections on smtp */
    conn->bits.close = FALSE;

    pp->response_time = RESP_TIMEOUT; /* set default response time-out */
    pp->statemach_act = smtp_statemach_act;
    pp->endofresp = smtp_endofresp;
    pp->conn = conn;

#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_PROXY)
    if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
        /* for SMTP over HTTP proxy */
        struct HTTP http_proxy;
        struct FTP *smtp_save;

        /* BLOCKING */
        /* We want "seamless" SMTP operations through HTTP proxy tunnel */

        /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the member
         * conn->proto.http; we want SMTP through HTTP and we have to change the
         * member temporarily for connecting to the HTTP proxy. After
         * Curl_proxyCONNECT we have to set back the member to the original struct
         * SMTP pointer
         */
        smtp_save = data->state.proto.smtp;
        memset(&http_proxy, 0, sizeof(http_proxy));
        data->state.proto.http = &http_proxy;

        result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
                                   conn->host.name, conn->remote_port);

        data->state.proto.smtp = smtp_save;

        if(CURLE_OK != result)
            return result;
    }
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_PROXY */

    if(conn->protocol & PROT_SMTPS) {
        /* BLOCKING */
        /* SMTPS is simply smtp with SSL for the control channel */
        /* now, perform the SSL initialization for this socket */
        result = Curl_ssl_connect(conn, FIRSTSOCKET);
        if(result)
            return result;
    }

    Curl_pp_init(pp); /* init the response reader stuff */

    pp->response_time = RESP_TIMEOUT; /* set default response time-out */
    pp->statemach_act = smtp_statemach_act;
    pp->endofresp = smtp_endofresp;
    pp->conn = conn;

    if(!*path) {
        if(!Curl_gethostname(localhost, sizeof localhost))
            path = localhost;
        else
            path = "localhost";
    }

    /* url decode the path and use it as domain with EHLO */
    smtpc->domain = curl_easy_unescape(conn->data, path, 0, &len);
    if(!smtpc->domain)
        return CURLE_OUT_OF_MEMORY;

    /* When we connect, we start in the state where we await the server greeting
     */
    state(conn, SMTP_SERVERGREET);

    if(data->state.used_interface == Curl_if_multi)
        result = smtp_multi_statemach(conn, done);
//.........这里部分代码省略.........
开发者ID:wnpllrzodiac,项目名称:transmission,代码行数:101,代码来源:smtp.c


示例20: file_connect

/*
 * file_connect() gets called from Curl_protocol_connect() to allow us to
 * do protocol-specific actions at connect-time.  We emulate a
 * connect-then-transfer protocol and "connect" to the file here
 */
static CURLcode file_connect(struct connectdata *conn, bool *done)
{
  struct SessionHandle *data = conn->data;
  char *real_path = curl_easy_unescape(data, data->state.path, 0, NULL);
  struct FILEPROTO *file;
  int fd;
#ifdef DOS_FILESYSTEM
  int i;
  char *actual_path;
#endif

  if(!real_path)
    return CURLE_OUT_OF_MEMORY;

  /* If there already is a protocol-specific struct allocated for this
     sessionhandle, deal with it */
  Curl_reset_reqproto(conn);

  if(!data->state.proto.file) {
    file = calloc(sizeof(struct FILEPROTO), 1);
    if(!file) {
      free(real_path);
      return CURLE_OUT_OF_MEMORY;
    }
    data->state.proto.file = file;
  }
  else {
    /* file is not a protocol that can deal with "persistancy" */
    file = data->state.proto.file;
    Curl_safefree(file->freepath);
    if(file->fd != -1)
      close(file->fd);
    file->path = NULL;
    file->freepath = NULL;
    file->fd = -1;
  }

#ifdef DOS_FILESYSTEM
  /* If the first character is a slash, and there's
     something that looks like a drive at the beginning of
     the path, skip the slash.  If we remove the initial
     slash in all cases, paths without drive letters end up
     relative to the current directory which isn't how
     browsers work.

     Some browsers accept | instead of : as the drive letter
     separator, so we do too.

     On other platforms, we need the slash to indicate an
     absolute pathname.  On Windows, absolute paths start
     with a drive letter.
  */
  actual_path = real_path;
  if((actual_path[0] == '/') &&
      actual_path[1] &&
      (actual_path[2] == ':' || actual_path[2] == '|'))
  {
    actual_path[2] = ':';
    actual_path++;
  }

  /* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
  for (i=0; actual_path[i] != '\0'; ++i)
    if(actual_path[i] == '/')
      actual_path[i] = '\\';

  fd = open_readonly(actual_path, O_RDONLY|O_BINARY); /* no CR/LF translation */
  file->path = actual_path;
#else
  fd = open_readonly(real_path, O_RDONLY);
  file->path = real_path;
#endif
  file->freepath = real_path; /* free this when done */

  file->fd = fd;
  if(!data->set.upload && (fd == -1)) {
    failf(data, "Couldn't open file %s", data->state.path);
    file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE);
    return CURLE_FILE_COULDNT_READ_FILE;
  }
  *done = TRUE;

  return CURLE_OK;
}
开发者ID:0w,项目名称:moai-dev,代码行数:89,代码来源:file.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ curl_formadd函数代码示例发布时间:2022-05-30
下一篇:
C++ curl_easy_strerror函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap