亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? curltransportagent.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

#include "base/Log.h"
#include "base/messages.h"
#include "http/constants.h"
#include "http/errors.h"
#include "http/CurlTransportAgent.h"

/*
 * This is the libcurl implementation of the TransportAgent object
 */

/*
 * Singleton: initialize libcurl once per program
 */
class CurlInit {
    static CURLcode initres;
    static CurlInit singleton;

    CurlInit() { initres = curl_global_init(CURL_GLOBAL_ALL); }
    ~CurlInit() { curl_global_cleanup(); initres = CURLE_FAILED_INIT; }

public:
    static CURL *easy_init() { return !initres ? curl_easy_init() : NULL; }
};

CURLcode CurlInit::initres;
CurlInit CurlInit::singleton;


/*
 * Constructor.
 * In this implementation newProxy is ignored, since proxy configuration
 * is taken from the WinInet subsystem.
 *
 * @param url the url where messages will be sent with sendMessage()
 * @param proxy proxy information or NULL if no proxy should be used
 */
CurlTransportAgent::CurlTransportAgent(URL& newURL, Proxy& newProxy, unsigned int maxResponseTimeout) : TransportAgent(newURL, newProxy, maxResponseTimeout){
    easyhandle = CurlInit::easy_init();
    if (easyhandle) {
        curl_easy_setopt(easyhandle, CURLOPT_DEBUGFUNCTION, debugCallback);
        curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, LOG.getLevel() ? TRUE : FALSE);
        curl_easy_setopt(easyhandle, CURLOPT_NOPROGRESS, TRUE);
        curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, receiveData);
        curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, this);
        curl_easy_setopt(easyhandle, CURLOPT_READFUNCTION, sendData);
        curl_easy_setopt(easyhandle, CURLOPT_READDATA, this);
        curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, this->curlerrortxt );
        curl_easy_setopt(easyhandle, CURLOPT_AUTOREFERER, TRUE);
        curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, TRUE);
        if (proxy.host[0]) {
            curl_easy_setopt(easyhandle, CURLOPT_PROXY, proxy.host);
            if (proxy.port) {
                curl_easy_setopt(easyhandle, CURLOPT_PROXYPORT, proxy.port);
            }
            if (proxy.user) {
                sprintf(proxyauth, "%s:%s", proxy.user, proxy.password);
                curl_easy_setopt(easyhandle, CURLOPT_PROXYUSERPWD, proxyauth);
            }
        }
    }
    setUserAgent("Funambol POSIX SyncML client");
}

void CurlTransportAgent::setUserAgent(const char*ua) {
    if (ua) {
        TransportAgent::setUserAgent(ua);
        if (easyhandle) {
            curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, userAgent);
        }
    }
}


CurlTransportAgent::~CurlTransportAgent() {
    if (easyhandle) {
        curl_easy_cleanup(easyhandle);
    }
}

size_t CurlTransportAgent::receiveData(void *buffer, size_t size, size_t nmemb, void *stream) {
    CurlTransportAgent *agent = (CurlTransportAgent *)stream;
    size_t curr = size * nmemb;

    if (agent->received + curr + 1 > agent->responsebuffersize) {
        size_t newbuffersize = agent->responsebuffersize + max(10 * 1024, (curr + 1 + 1024) / 1024 * 1024);
        char *newbuffer = new char[newbuffersize];
        memcpy(newbuffer, agent->responsebuffer, agent->received);
        delete [] agent->responsebuffer;
        agent->responsebuffer = newbuffer;
        agent->responsebuffersize = newbuffersize;
    }
    memcpy(agent->responsebuffer + agent->received,
           buffer,
           curr);
    agent->received += curr;
    agent->responsebuffer[agent->received] = 0;
    return curr;
}

size_t CurlTransportAgent::sendData(void *buffer, size_t size, size_t nmemb, void *stream) {
    CurlTransportAgent *agent = (CurlTransportAgent *)stream;
    size_t curr = min(size * nmemb, agent->sendbuffersize - agent->sent);

    memcpy(buffer, agent->sendbuffer + agent->sent, curr);
    agent->sent += curr;
    return curr;
}

int CurlTransportAgent::debugCallback(CURL *easyhandle, curl_infotype type, char *data, size_t size, void *unused)
{
    BOOL isData = type == CURLINFO_DATA_IN || type == CURLINFO_DATA_OUT;

    if (LOG.getLevel() >= LOG_LEVEL_DEBUG && !isData ||
        LOG.getLevel() > LOG_LEVEL_DEBUG) {
        char *buffer = new char[30 + size];
        sprintf(buffer, "libcurl %s%.*s",
                type == CURLINFO_TEXT ? "info: " :
                type == CURLINFO_HEADER_IN ? "header in: " :
                type == CURLINFO_HEADER_OUT ? "header out:\n" :
                type == CURLINFO_DATA_IN ? "data in:\n" :
                type == CURLINFO_DATA_OUT ? "data out:\n" :
                "???",
                (size > 0 && data[size-1] == '\n') ? (int)size - 1 : (int)size,
                data);
        LOG.debug(buffer);
        delete [] buffer;
    }
}

/*
 * Sends the given SyncML message to the server specified
 * by the instal property 'url'. Returns the response status code or -1
 * if it was not possible initialize the connection.
 *
 * Use getResponse() to get the server response.
 */
char* CurlTransportAgent::sendMessage(const char* msg) {
    if (!easyhandle) {
        lastErrorCode = ERR_NETWORK_INIT;
        strcpy(lastErrorMsg, "libcurl error init error");
        return NULL;
    }

    LOG.debug("Requesting resource %s at %s:%d", url.resource, url.host, url.port);

    curl_slist *slist=NULL;
    char *response = NULL;
    CURLcode code;
    char contenttype[256];
    sprintf(contenttype, "Content-Type: %s", SYNCML_CONTENT_TYPE);
    slist = curl_slist_append(slist, contenttype);
    responsebuffersize = 64 * 1024;
    responsebuffer = new char[responsebuffersize];
    received = 0;
    responsebuffer[0] = 0;
    // todo? url.resource
    if ((code = curl_easy_setopt(easyhandle, CURLOPT_POST, TRUE)) ||
        (code = curl_easy_setopt(easyhandle, CURLOPT_URL, url.fullURL)) ||
        (code = curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, msg)) ||
        (code = curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDSIZE, strlen(msg))) ||
        (code = curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, slist)) ||
        (code = curl_easy_perform(easyhandle))) {
        delete [] responsebuffer;
        lastErrorCode = ERR_HTTP;
        sprintf(lastErrorMsg, "libcurl error %d, %.250s", code, curlerrortxt);
    } else {
        response = responsebuffer;
        LOG.debug(response);
        LOG.debug("Response read");
    }
    responsebuffer = NULL;
    responsebuffersize = 0;

    if (slist) {
        curl_slist_free_all(slist);
    }

    return response;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久婷婷久久一区二区三区| 欧美性大战久久久久久久| 亚洲天堂福利av| 欧美一级片免费看| 99亚偷拍自图区亚洲| 毛片av中文字幕一区二区| 亚洲精品网站在线观看| 欧美精品一区二区在线观看| 日本韩国精品在线| 成人永久免费视频| 奇米影视在线99精品| 亚洲视频中文字幕| 久久久久99精品一区| 91精品国产综合久久久久久久 | 亚洲一区免费视频| 国产偷国产偷亚洲高清人白洁| 欧美三级视频在线| 91欧美激情一区二区三区成人| 国产一区二区精品久久91| 免费高清在线视频一区·| 亚洲国产精品一区二区久久| 国产精品激情偷乱一区二区∴| 日韩精品一区在线| 777色狠狠一区二区三区| 一本色道久久加勒比精品| 成人一区在线观看| 国产精品原创巨作av| 麻豆视频一区二区| 日韩精品每日更新| 午夜久久久影院| 一区二区三区精密机械公司| 综合久久久久综合| 亚洲欧美中日韩| 中文字幕一区日韩精品欧美| 国产精品蜜臀av| 欧美精品一区二区三区久久久| 91精品国产综合久久蜜臀| 欧美疯狂做受xxxx富婆| 欧美日韩精品一区二区| 欧美色网站导航| 欧美日韩视频在线第一区 | 精品久久人人做人人爰| 欧美一区二区成人| 欧美女孩性生活视频| 欧美巨大另类极品videosbest | 久久99国内精品| 国内精品自线一区二区三区视频| 麻豆精品在线播放| 国产精品亚洲第一| 成人激情黄色小说| 91亚洲永久精品| 99精品一区二区| 欧美色电影在线| 这里只有精品电影| 精品国产1区二区| 国产日韩综合av| 亚洲啪啪综合av一区二区三区| 亚洲精品免费在线| 日韩精品一二三区| 国产精品自拍在线| 91伊人久久大香线蕉| 欧美另类一区二区三区| 精品国产不卡一区二区三区| 国产亚洲人成网站| 亚洲激情欧美激情| 美女视频黄久久| 成人少妇影院yyyy| 欧美日韩一区二区三区四区 | 欧美大片在线观看一区| 国产午夜精品久久| 依依成人精品视频| 欧美aaaaa成人免费观看视频| 国产成人午夜视频| 欧美主播一区二区三区| 欧美va亚洲va香蕉在线| 亚洲视频在线一区观看| 日本一道高清亚洲日美韩| 国产成人免费xxxxxxxx| 欧美综合天天夜夜久久| 日韩精品专区在线影院观看| 中文字幕一区二区三区av| 日韩av电影免费观看高清完整版在线观看 | 美女一区二区在线观看| 成人精品视频一区二区三区尤物| 欧美日韩久久不卡| 中文幕一区二区三区久久蜜桃| 亚洲成av人片一区二区三区| 国产一区二区免费视频| 欧美日韩精品一区二区在线播放| 国产人伦精品一区二区| 日韩福利电影在线| 91免费版在线看| 日韩欧美在线影院| 亚洲视频一区在线| 国产精品77777| 91精品国产美女浴室洗澡无遮挡| 国产精品欧美一级免费| 久久精品国产精品青草| 欧美丝袜丝交足nylons图片| 亚洲国产成人午夜在线一区| 免费高清在线一区| 欧美日韩一二三区| 亚洲人成电影网站色mp4| 国产精品亚洲一区二区三区在线| 欧美一区二区三区不卡| 一区二区三区在线影院| 成人网页在线观看| 久久久精品免费网站| 免费看日韩a级影片| 欧美日韩一区在线观看| 亚洲色图欧洲色图| 99在线热播精品免费| 中文字幕第一区| 国产精品一线二线三线精华| 精品乱人伦一区二区三区| 日韩国产精品久久| 欧美日韩国产123区| 亚洲成人高清在线| 一本色道久久综合狠狠躁的推荐| 国产精品久久午夜夜伦鲁鲁| 国产二区国产一区在线观看 | 一区二区三区精品在线| www.激情成人| 中文字幕欧美激情| 国产精品亚洲а∨天堂免在线| 精品捆绑美女sm三区| 久久精品国产免费看久久精品| 欧美老年两性高潮| 五月婷婷激情综合| 欧美高清激情brazzers| 天天做天天摸天天爽国产一区| 欧美视频在线一区| 亚洲va欧美va天堂v国产综合| 在线观看一区二区精品视频| 亚洲精品成人精品456| 欧美性猛交xxxxxxxx| 亚洲国产一二三| 欧美日韩国产a| 美女爽到高潮91| 欧美精品一区二区久久久| 国产又黄又大久久| 国产免费成人在线视频| 99精品热视频| 亚洲国产精品久久艾草纯爱| 欧美日韩精品二区第二页| 日韩高清在线不卡| 亚洲精品在线观看视频| 狠狠久久亚洲欧美| 中文字幕巨乱亚洲| 日本韩国一区二区| 日韩成人免费看| 久久综合中文字幕| 成人激情小说乱人伦| 亚洲日本va午夜在线影院| 欧美午夜精品久久久| 日产欧产美韩系列久久99| 精品国产91洋老外米糕| 成人黄动漫网站免费app| 亚洲精品日韩一| 欧美一区二区免费视频| 国产成人精品免费网站| 亚洲欧美成aⅴ人在线观看| 欧美美女喷水视频| 韩国欧美国产1区| 亚洲人妖av一区二区| 欧美精品粉嫩高潮一区二区| 国产又粗又猛又爽又黄91精品| 国产精品久久久久影视| 欧美日韩一级二级三级| 国产美女在线观看一区| 国内成+人亚洲+欧美+综合在线 | 国产精品三级av在线播放| 色8久久人人97超碰香蕉987| 青青草精品视频| 中文字幕综合网| 日韩精品在线一区二区| 99久久精品免费精品国产| 天天操天天色综合| 欧美激情一区在线观看| 欧美一区二区在线观看| 成人手机电影网| 日本成人在线视频网站| 国产精品电影一区二区| 日韩三级视频在线观看| 91在线国内视频| 国模无码大尺度一区二区三区| 亚洲乱码日产精品bd| 欧美精品一区二区精品网| 日本黄色一区二区| 国产高清不卡二三区| 亚洲成人av资源| 中文字幕在线观看不卡视频| 日韩免费电影网站| 欧美色图第一页| 99精品欧美一区二区蜜桃免费| 国模一区二区三区白浆| 视频精品一区二区| 亚洲人成电影网站色mp4| 国产婷婷色一区二区三区在线| 制服丝袜av成人在线看|