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

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

?? stringutils.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
字號:
/*
 * Copyright (C) 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 <algorithm>
#include "base/Log.h"
#include "base/util/utils.h"
#include "base/stringUtils.h"
#include "spds/DataTransformerFactory.h"
#include "spds/B64Encoder.h"
#include "spds/B64Decoder.h"
#include "spds/DESEncoder.h"
#include "spds/DESDecoder.h"

using namespace std;



/**
 * Converts a string to lower-case.
 * String passed is modified.
 * @param s   [IN-OUT] the string to be converted
 */
void toLowerCase(string& s) {
    transform(s.begin(), s.end(), s.begin(), tolower);
}

/**
 * Converts a string to lower-case (wstring version).
 * String passed is modified.
 * @param s   [IN-OUT] the string to be converted
 */
void toLowerCase(wstring& s) {
    transform(s.begin(), s.end(), s.begin(), tolower);
}


/**
 * Replace all strings 'source' with 'dest' inside string 'dataString'.
 * @param source       the token to search
 * @param dest         the token to replace
 * @param dataString   [IN-OUT] the string to work on
 * @param startPos     [OPTIONAL] tha start position (default = 0)
 */
void replaceAll(const wstring& source, const wstring& dest, wstring& dataString, const int startPos) {

    if (startPos >= (int)dataString.length()) {
        return;
    }
    wstring::size_type pos = startPos;
    pos = dataString.find(source, pos);

    while (pos != wstring::npos) {
        dataString.replace(pos, source.length(), dest);
        pos = dataString.find(source, pos+1);
    }
}





/**
 * Gets the content of <tag>...</tag> inside the string 'xml'.
 * Returns 0 if tag found, 1 if not found.
 *
 * @param xml     : the input string to search inside
 * @param tag     : the tag we are looking for
 * @param content : [OUT] the content of tag (string passed by ref)
 * @param pos     : (optional) the starting position to search inside 'xml' (default = 0)
 * @return          0 if tag found (even if empty content), 1 if errors
 */
int getElementContent(const wstring& xml, const wstring& tag, wstring& content, unsigned int pos) {

    wstring openTag, closeTag, emptyTag;
    wstring::size_type start, end;
    content = L"";

    //
    // First try to find the empty element <tag/>
    //
    emptyTag  = L"<";
    emptyTag += tag;
    emptyTag += L"/>";

    start = xml.find(emptyTag, pos); 
    if (start != wstring::npos) {
        return 0;  // found!
    }

    //
    // Now search for the <tag>Content</tag>
    //
    openTag   = L"<";
    openTag  += tag;
    openTag  += L">";

    closeTag  = L"</";
    closeTag += tag;
    closeTag += L">";

    start = xml.find(openTag, pos); 
    if (start != wstring::npos) {
        start += openTag.length();

        end = xml.find(closeTag, start);
        if (end == wstring::npos) {
            goto not_found;
        }

        content = xml.substr(start, end-start);
    }
    
    else {
        goto not_found;
    }

    return 0;

not_found:

    return 1;
}



/**
 * Gets the content of <tag>...</tag> inside the string 'xml'.
 * Returns 0 if tag found, 1 if not found.
 *
 * @param xml     : the input string to search inside
 * @param tag     : the tag we are looking for
 * @param content : [OUT] the content of tag (string passed by ref)
 * @param pos     : the starting position to search inside 'xml'
 * @param start   : [OUT] the starting position of content found ('wstring::npos' if not found)
 * @param end     : [OUT] the ending position of content found ('wstring::npos' if not found)
 * @return          0 if tag found (even if empty content), 1 if errors
 * @overload        getElementContent(const wstring& xml, const wstring& tag, wstring& content, unsigned int pos)
 */
int getElementContent(const wstring& xml, const wstring& tag, wstring& content, const wstring::size_type pos, wstring::size_type& start, wstring::size_type& end) {

    wstring openTag, closeTag, emptyTag;
    start   = wstring::npos;
    end     = wstring::npos;
    content = L"";

    //
    // First try to find the empty element <tag/>
    //
    emptyTag  = L"<";
    emptyTag += tag;
    emptyTag += L"/>";

    start = xml.find(emptyTag, pos); 
    if (start != wstring::npos) {
        start += emptyTag.length();
        end = start;
        return 0;  // found!
    }

    //
    // Now search for the <tag>Content</tag>
    //
    openTag   = L"<";
    openTag  += tag;
    openTag  += L">";

    closeTag  = L"</";
    closeTag += tag;
    closeTag += L">";

    start = xml.find(openTag, pos); 
    if (start != wstring::npos) {
        start += openTag.length();

        end = xml.find(closeTag, start);
        if (end == wstring::npos) {
            goto not_found;
        }

        content = xml.substr(start, end-start);
    }
    
    else {
        goto not_found;
    }

    return 0;

not_found:

    return 1;
}




/**
 * Used to encrypt private data (username/password) using 'B64(DES(data))'.
 * @param data   the data to encrypt
 * @return       the data encrypted (new buffer: must be deleted by caller)
 */
char* encryptData(const char* data) {
    
    if (!data) return NULL;
    char*   desData = NULL;
    char*   b64Data = NULL;
    char* data1 = (char*)data;

    //
    // 1. DES encryption
    //
    DataTransformer* dt = new DESEncoder();
    TransformationInfo info;
    if (dt == NULL) {
        goto error;
    }
    info.size = strlen(data1);
    info.password = "SettimioSevero";
    desData = dt->transform(data1, info);
    if (!desData || info.newReturnedData == FALSE) {
        goto error;
    }
    if (dt) delete dt;

    //
    // 2. B64 encoding
    //
    dt = new B64Encoder();
    // info.size is already correct :)
    info.password = NULL;
    b64Data = dt->transform(desData, info);
    goto exit;


error:
    LOG.error(ERR_ENCRYPT_DATA);
    b64Data = stringdup(data);

exit:
    if (desData) delete [] desData;
    if (dt)      delete dt;
    return b64Data;
}



/**
 * Used to decrypt private data (username/password) using 'dec_DES(dec_B64(b64Data))'.
 * @param b64Data   the data to decrypt
 * @return          the data decrypted (new buffer: must be deleted by caller)
 */
char* decryptData(const char* b64Data) {
    
    if (!b64Data) return NULL;
    char* desData = NULL;
    char* data = NULL;

    // MUST copy, this buffer will be modified and 
    // it's the one returned from this function.
    char* b64Data1 = stringdup(b64Data);

    //
    // 1. B64 decoding
    //
    DataTransformer* dt = new B64Decoder();
    TransformationInfo info;
    if (dt == NULL) {
        goto error;
    }
    info.size = strlen(b64Data1);
    info.password = NULL;
    desData = dt->transform(b64Data1, info);
    if (dt) delete dt;


    //
    // 2. DES decryption
    //
    dt = new DESDecoder();
    // info.size is already correct :)
    info.password = "SettimioSevero";
    data = dt->transform(desData, info);
    if (!data) {
        goto error;
    }
    data[info.size] = 0;
    goto exit;

error:
    LOG.error(ERR_DECRYPT_DATA);
    data = stringdup("");

exit:
    // NO! buffer used is the same passed to both decoder!!
    // if (desData) delete [] desData;
    // if (b64Data1) delete [] b64Data1;
    if (dt)       delete dt;
    return data;
}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美福利视频一区| 97精品国产露脸对白| 午夜精品免费在线| 亚洲美女偷拍久久| 一区二区三区四区高清精品免费观看| 国产欧美一区二区三区网站| 中文字幕巨乱亚洲| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 色av一区二区| 色婷婷激情久久| 91成人国产精品| 99re热这里只有精品视频| 91偷拍与自偷拍精品| 在线亚洲高清视频| 欧美高清视频在线高清观看mv色露露十八| 欧美无砖砖区免费| 日韩欧美自拍偷拍| 国产农村妇女精品| 亚洲人成影院在线观看| 肉色丝袜一区二区| 国产伦精品一区二区三区免费迷| 国产电影一区二区三区| 色综合色狠狠天天综合色| 欧美日韩精品久久久| 日韩亚洲欧美中文三级| 国产欧美一区二区三区网站| 亚洲一区二区精品视频| 香蕉乱码成人久久天堂爱免费| 三级久久三级久久久| 狠狠色丁香久久婷婷综合_中| 99久久精品免费精品国产| 欧美午夜寂寞影院| 久久精品一区八戒影视| 亚洲色图丝袜美腿| 精品一区二区久久久| aaa亚洲精品一二三区| 欧美疯狂做受xxxx富婆| 久久久国产精华| 五月天久久比比资源色| 国产成人精品aa毛片| 欧美日韩一区二区三区高清| 日韩欧美色综合| 日韩伦理免费电影| 国产一区二区福利视频| 在线免费一区三区| 国产精品视频看| 男人的天堂亚洲一区| 日本大香伊一区二区三区| 26uuu久久综合| 午夜不卡在线视频| 日本高清无吗v一区| 久久久www免费人成精品| 亚洲高清视频的网址| 成人黄色小视频| 亚洲精品在线三区| 日本欧美一区二区在线观看| 在线亚洲欧美专区二区| 亚洲精选一二三| 成人不卡免费av| 久久九九影视网| 精品无人码麻豆乱码1区2区 | 成人深夜在线观看| 日韩视频一区二区| 秋霞电影网一区二区| 欧美肥大bbwbbw高潮| 亚洲激情在线激情| 91在线观看一区二区| 中文一区一区三区高中清不卡| 久久精品噜噜噜成人88aⅴ| 欧美日韩激情一区二区| 亚洲一区二区三区爽爽爽爽爽| 91在线视频在线| 一区二区视频在线| 色综合天天综合色综合av | **网站欧美大片在线观看| 国产在线不卡视频| 欧美精品一区二区三区很污很色的 | 午夜欧美一区二区三区在线播放| 丰满少妇在线播放bd日韩电影| 久久久久国产精品免费免费搜索| 麻豆国产91在线播放| 欧美不卡在线视频| 狠狠网亚洲精品| 久久九九久久九九| 97se亚洲国产综合自在线不卡| 日韩理论片在线| 色婷婷久久久综合中文字幕 | 美女视频免费一区| 欧美刺激脚交jootjob| 国产一区二区三区在线观看精品 | 午夜国产不卡在线观看视频| 欧美日韩成人在线一区| 麻豆视频观看网址久久| 久久综合九色综合久久久精品综合| 极品销魂美女一区二区三区| 久久精品视频一区二区三区| 99久久久免费精品国产一区二区| 亚洲黄色小视频| 日韩欧美久久久| 成人免费看的视频| 一区二区三区精品久久久| 日韩美女在线视频 | 欧美日本韩国一区二区三区视频| 日韩精品1区2区3区| 国产亚洲一区二区三区四区| 色综合久久久久久久| 蜜臀精品久久久久久蜜臀| 国产亚洲人成网站| 欧美日韩久久久久久| 国产成人免费网站| 亚洲午夜一区二区三区| 久久久精品国产免大香伊| 欧美综合一区二区三区| 激情图区综合网| 亚洲国产精品久久人人爱| 久久只精品国产| 欧美婷婷六月丁香综合色| 国产一区二三区| 亚洲gay无套男同| 中文字幕的久久| 日韩无一区二区| 91国模大尺度私拍在线视频| 国产激情91久久精品导航| 图片区日韩欧美亚洲| 国产精品灌醉下药二区| 精品粉嫩aⅴ一区二区三区四区| 一本久久a久久免费精品不卡| 精品亚洲国内自在自线福利| 亚洲国产精品久久久久婷婷884| 中文字幕精品三区| 久久久久亚洲蜜桃| 欧美一区二区美女| 欧美日韩一区国产| 99久精品国产| www.亚洲国产| 懂色av一区二区三区免费观看| 免费观看一级欧美片| 亚洲第四色夜色| 亚洲国产色一区| 亚洲一区二区三区四区在线| 亚洲欧美日韩在线| 中文字幕亚洲一区二区av在线| 久久综合九色综合欧美就去吻 | 亚洲精品高清在线| 国产精品久久久久aaaa樱花| 26uuu国产在线精品一区二区| 这里只有精品99re| 欧美一区二区视频在线观看| 欧美三级中文字| 欧美色视频一区| 欧美亚洲国产bt| 欧美日韩成人在线| 91精品久久久久久久99蜜桃| 欧美人与性动xxxx| 欧美精品v日韩精品v韩国精品v| 欧美三级日韩三级国产三级| 欧美日免费三级在线| 欧美三级电影在线看| 欧美日韩在线一区二区| 91精品国产免费久久综合| 69堂亚洲精品首页| 91精品国产综合久久久久| 日韩精品一区国产麻豆| 久久嫩草精品久久久久| 日本一区二区三级电影在线观看| 中文字幕不卡三区| 亚洲永久免费视频| 日韩av在线免费观看不卡| 蜜桃免费网站一区二区三区| 狠狠狠色丁香婷婷综合久久五月| 韩国中文字幕2020精品| 成人精品免费看| 欧美在线不卡一区| 日韩一级二级三级| 久久久99精品久久| 夜夜精品视频一区二区| 青青草伊人久久| 粉嫩嫩av羞羞动漫久久久 | 日韩精品久久理论片| 国产激情一区二区三区| 99久久国产免费看| 日韩欧美亚洲国产精品字幕久久久| 国产婷婷精品av在线| 亚洲精品五月天| 久草精品在线观看| 一本大道综合伊人精品热热| 91精品蜜臀在线一区尤物| 国产精品系列在线| 日韩制服丝袜av| 成人综合日日夜夜| 91精品国产一区二区| 日本一区二区电影| 人人超碰91尤物精品国产| 99久久伊人网影院| 欧美电影免费观看高清完整版在| 成人免费在线观看入口| 久久精品国产亚洲5555| 在线免费观看视频一区| 日本一区二区三区高清不卡| 日本美女视频一区二区|