本文整理汇总了C++中curl_easy_unescape函数的典型用法代码示例。如果您正苦于以下问题:C++ curl_easy_unescape函数的具体用法?C++ curl_easy_unescape怎么用?C++ curl_easy_unescape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curl_easy_unescape函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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("&", 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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 "";
}
示例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;
}
示例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;
}