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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? xmlprocessor.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
 * 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 <stdlib.h>

#include "base/util/utils.h"
#include "base/util/XMLProcessor.h"
#include "base/util/StringBuffer.h"
#include "base/Log.h"

//--------------------------------------------------------------- Static functions

static const char *findElementContent(const char *xml,
                          const char *openTag, const char *closeTag,
                          unsigned int* pos     ,
                          unsigned int* startPos,
                          unsigned int* endPos  )
{
    const char *p1, *p2, *xmlptr = xml;

    if (pos) {
        *pos = 0;
    }

    do {
        p1 = strstr(xmlptr, openTag);
        p2 = NULL;

        if (!p1) {
            // Tag not found
            //LOG.debug("XMLProcessor: tag %s not found", openTag);
            return 0;
        }

        p1 += strlen(openTag); // move to end of tag

        // Check the tag type
        switch( *p1 ){
            case ' ':   // <tag attr=xxx>
                // Find the end of the tag (TODO: should check for invalid chars?)
                for (p1++; *p1 != '>'; p1++) {
                    if(*p1 == 0 || *p1 == '<'){
                        LOG.info("XMLProcessor: incomplete tag");
                        return 0;
                    }
                }
                if(*(p1-1) == '/'){ // <tag attr=xxx />
                    // Like case '/' below:
                    p1++;
                    p2=p1;
                    closeTag=0;
                    break;
                }
                // The break is not missing!
                // After the for, we are in the same case of the tag
                // without attributes
            case '>':   // <tag>
                p1++;   // this is the beginning of content
                if (!p1[0]) {
                    LOG.info("XMLProcessor: tag at end of file");
                    return 0;
                }
                // Find the closing tag
                p2 = strstr(p1, closeTag);
                break;
            case '/':
                p1++;
                if(*p1 != '>'){
                    LOG.info("XMLProcessor: invalid empty tag");
                    return 0;
                }
                p1++;
                // The tag is already closed, no content: make end = start
                p2=p1;
                // Invalidate closeTag
                closeTag=0;
                break;
            case '\n':
                p1++;
                p2 = strstr(p1, closeTag);
                break;
            default:
                // This is not the searched tag, search again
                //LOG.debug("XMLProcessor: this is not tag %s", openTag);
                xmlptr = p1;
                p1 = 0;
        }
    }
    while (!p1); // If p1 is null and we are here, it means that the 'default'
                 // case was hit.

    // Closing tag not found
    if (!p2) {
        //
        // This is abc<tag>xyz\0
        //
        p1 = NULL;
        return 0;
    }

    // Okay, if we are here, the tag content has been found
    if (startPos) {
        *startPos = p1 - xml;
    }
    if (endPos) {
        *endPos = p2 - xml ;
    }
    if (pos) {
        *pos = p2-xml;
        if (closeTag){
            *pos += strlen(closeTag);
        }
    }

    return p1;
}

const char* XMLProcessor::getElementContent(const char* xml,
                                            const char* tag,
                                            unsigned int* pos,
                                            unsigned int* startPos,
                                            unsigned int* endPos  )
{
    char *openTag = 0;
    char *closeTag = 0;

    if (!xml) {
        return 0;
    }

    size_t l = strlen(tag);

    if(strcmp(tag, "CDATA") == 0) {
        openTag = stringdup("<![CDATA[");
        closeTag = stringdup("]]>");
    }
    else {
        openTag = new char[l+10];
        closeTag = new char[l+10];
        sprintf(openTag, "<%s", tag);
        sprintf(closeTag, "</%s>", tag);
    }

    const char *ret = findElementContent(xml, openTag, closeTag, pos, startPos, endPos);

    if (openTag)
        delete [] openTag;
    if (closeTag)
        delete [] closeTag;

    return ret;
}

char* XMLProcessor::copyContent(const char* xml,
                                unsigned int startPos,
                                unsigned int endPos  ) {

    char * ret = NULL;

    if (!xml) {
        return 0;
    }
    if (endPos < startPos) {
        return 0;
    }
    if (strlen(xml) < endPos - startPos) {
        return 0;
    }

    // figure out whether the text that we are about to copy
    // contains further elements; if not, treat it as a leaf
    // element and decode entities
    BOOL isLeaf = TRUE;
    unsigned int pos = startPos;
    while (pos < endPos) {
        if (xml[pos] == '<') {
            isLeaf = FALSE;
            break;
        }
        pos++;
    }

    const char cdataStart[] = "<![CDATA[";
    const int cdataStartLen = sizeof(cdataStart) - 1;
    const char cdataEnd[] = "]]>";
    const int cdataEndLen = sizeof(cdataEnd) - 1;

    // strip CDATA markers at start and end?
    if (!isLeaf &&
        endPos - pos > cdataStartLen + cdataEndLen &&
        !strncmp(xml + pos, cdataStart, cdataStartLen)) {
        // yep, copy content verbatim;
        // search real end of data first
        pos += cdataStartLen;
        unsigned int cdataEndPos = endPos;
        while (cdataEndPos - cdataEndLen > pos) {
            if (!strncmp(xml + cdataEndPos - cdataEndLen,
                          cdataEnd,
                          cdataEndLen)) {
                // found "]]>"
                cdataEndPos -= cdataEndLen;
                break;
            }
            cdataEndPos--;
        }

        ret = new char[cdataEndPos - pos + 1];
        strncpy(ret, xml + pos, cdataEndPos - pos);
        ret[cdataEndPos - pos] = 0;
    } else if (isLeaf) {
        // Decode content of final element:
        // might contain escaped special characters.
        //
        // This must _not_ be done for tags which contain other
        // tags because then we might destroy the content of e.g.
        // <Add><Data><![CDATA[ literal entity &amp; ]]></Data></Add>
        //
        StringBuffer tmp(xml+startPos, endPos - startPos);
        tmp.replaceAll("&amp;", "&");
        tmp.replaceAll("&lt;", "<");
        ret = stringdup(tmp.c_str());
    } else {
        size_t len = endPos - startPos;
        ret = new char [len + 1];
        memcpy( ret, xml + startPos, len * sizeof(char));
        ret[len] = 0;
    }

    return ret;
}

char* XMLProcessor::copyElementContent(const char* xml,
                                       const char* tag,
                                       unsigned int* pos)
{
    unsigned int start, end;

    if( getElementContent (xml, tag, pos, &start, &end) ) {
        return copyContent(xml, start, end);
    }
    return 0;
}

/*
* It returns the number of the tag in the xml string
*/

int XMLProcessor::countElementTag(const char* xml, const char* tag) {

    unsigned int count = 0, pos = 0, previous = 0;

    while (getElementContent(&xml[pos], tag , &pos, NULL, NULL) != NULL) {
        pos += previous;
        previous = pos;
        count ++;
    }
    return count;
}


/*
* Returns the next tag found in the xml string. It looks at the < and > tags to retrieve
* the name of the token.
* If <tag xmlns...> it returns "tag"
* The "pos" argument will contain the position of the close <tag/>
* The return value is a new char* and must be fred by the caller. If no tag is found, NULL is returned
*/
const char* XMLProcessor::getNextTag(const char*xml, int* pos) {

    const char* p1, *p2, *p4, *p3 = NULL;
    char* ret = NULL;
    p1 = p2 = p4 = xml;
    int i = 0, k = 0, len = 0;
    BOOL found = FALSE;
    len = strlen(xml);

    for (i = 0; i < len; i++) {
        if (found) {
            if (p4[i] != '/' && p4[i] != '!' && p4[i] != '-' ) {
                break; // the element found is right!
            } else {
                found = FALSE;
            }
        }
        if (p4[i] == '<') {
            p1 = &p4[i];
            found = TRUE;
        }
    }

    if (found) {
        p2 = p1;
        for (k = 0; k < len; k++) {
            if (*p1 == 0) {
                break;
            }
            else if (*p1 == ' ') {
                p3 = p1;
            }
            else if (*p1 == '>') {
                *pos = p1 -xml + 1;
                if (p3) {
                    p1 = p3;
                }
                ret = new char[(p1)-(p2)];
                strncpy(ret, p2+1, (p1)-(p2+1));
                ret[(p1)-(p2+1)] = 0;
                return ret;
                break;
            }
            p1 = p1 + 1;
        }
    }
    return ret;

}



/*
* count the number of "&" (passed as a string) in the token.
*/
int XMLProcessor::countAnd(const char* token) {
    return countChar(token, "&");
}

int XMLProcessor::countChar(const char* token, const char* element) {

    const char* p1, *p2;
    p1 = p2 = token;
    int i = 0, k = 0, len = 0;

    while (strstr(p1, element) != NULL) {
        len = strlen(p2);
        for (k = 0; k < len; k++) {
            if (*p1 == 0) {
                break;
            }
            else if (*p1 == '&') {
                p1 = p1 + 1;
                i++;
                break;
            }
            p1 = p1 + 1;
        }
    }
    return i;
}


/*
* it's as getElementContent but it doesn't get the content of a tag if the parent match except.
* The parent can be more than one. They have to be separated by &
* i.e.
*
* getElementContentExcept(xmlPtr, "Add", "Sync&Atomic", &post)
*
* The function returns "... to keep ... " content only
*
* <SyncBody>
   <Sync>
     <Add>... to avoid ...</Add>
   </Sync>
   <Add>... to keep ...</Add>
   <Sync>
     <Add>... to avoid ...</Add>
   </Sync>
    <Atomic>
     <Add>... to avoid ...</Add>
   </Atomic>
 </SyncBody>
*/

char* XMLProcessor::copyElementContentExcept(const char*xmlPtr    ,
                                             const char*tag       ,
                                             const char*except    ,
                                             unsigned int* post) {

    char*  ret    = NULL;
    const char*  found  = NULL;
    const char*  xml    = NULL;
    char** array = NULL;
    int*  validElement = NULL;
    int count        = 0, countTag = 0;
    BOOL notValid  = FALSE;

    unsigned int pos      = 0, previous         = 0,
                 position = 0, previousPosition = 0,
                 startPos = 0, endPos           = 0;

    xml = xmlPtr;

    if (xml == NULL) {
        return NULL;
    }

    if (except == NULL) {
        ret = copyElementContent(xml, tag, &pos);
        if (post) {
            *post = pos;
        }
        return ret;
    }
    count = countAnd(except);
    count++;

    array = new char*[count + 1];
	int l;
    for (l = 0; l <= count; l++) {
        array[l] = NULL;
    }

    // represent a element found that can be used properly
    countTag = countElementTag(xml, tag);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看中文字幕不卡| 91在线丨porny丨国产| 国产亚洲精品精华液| 色先锋久久av资源部| 玖玖九九国产精品| 亚洲靠逼com| 精品成人一区二区三区| 欧美在线高清视频| 成人黄动漫网站免费app| 免费成人小视频| 亚洲狠狠丁香婷婷综合久久久| 久久蜜臀精品av| 欧美精品一卡二卡| 91丨porny丨蝌蚪视频| 国产精品影视网| 麻豆久久一区二区| 亚洲va国产va欧美va观看| 国产精品污www在线观看| 欧美变态凌虐bdsm| 欧美人狂配大交3d怪物一区| jiyouzz国产精品久久| 国产精品一二三在| 久久99精品久久久久婷婷| 亚洲成人激情自拍| 亚洲一卡二卡三卡四卡 | 欧美精品一区二区三区久久久 | 日韩电影在线一区二区| 亚洲人123区| 欧美激情在线看| 精品99一区二区| 欧美v日韩v国产v| 91精品国产高清一区二区三区| 欧美最新大片在线看| 色综合天天综合网国产成人综合天| 丁香桃色午夜亚洲一区二区三区| 韩国v欧美v亚洲v日本v| 久久国产剧场电影| 免费亚洲电影在线| 日韩激情一二三区| 美腿丝袜在线亚洲一区| 蜜臀久久99精品久久久久久9| 午夜视频在线观看一区二区 | 在线看一区二区| 色悠悠亚洲一区二区| 美女网站一区二区| 欧美亚洲国产一区二区三区| caoporn国产精品| 成人动漫精品一区二区| 高清在线不卡av| 欧美肥妇bbw| 欧美一级免费大片| 欧美v日韩v国产v| 国产视频一区二区三区在线观看| www久久久久| 久久天堂av综合合色蜜桃网| 日本一区二区三区久久久久久久久不 | 久久久久久电影| 久久精品视频免费观看| 国产农村妇女毛片精品久久麻豆 | 久久精子c满五个校花| 国产亚洲视频系列| 国产精品久久久久久久久图文区 | 久久不见久久见免费视频1| 狠狠色狠狠色综合系列| 国产大陆a不卡| 91在线视频在线| 欧美精品v国产精品v日韩精品| 日韩欧美在线123| 国产日韩欧美精品一区| 亚洲欧美欧美一区二区三区| 午夜欧美视频在线观看| 激情图片小说一区| 97久久人人超碰| 欧美日韩成人一区| 久久免费精品国产久精品久久久久| 中文字幕不卡在线观看| 一区二区三区在线视频观看 | 国产精品免费视频网站| 一区二区久久久久| 美女www一区二区| 成人在线视频一区| 欧美性一级生活| 久久久久久99精品| 亚洲精品中文字幕在线观看| 日韩成人伦理电影在线观看| 国产精品1024| 欧美网站一区二区| 久久亚洲精品小早川怜子| 亚洲欧美国产高清| 久久精品99国产精品| 99国产精品99久久久久久| 777xxx欧美| 亚洲欧美综合色| 久久疯狂做爰流白浆xx| 色天使色偷偷av一区二区| 日韩欧美国产高清| 一区二区三区在线不卡| 欧美日韩大陆在线| 国产精品无圣光一区二区| 日欧美一区二区| eeuss影院一区二区三区 | 日本一区二区不卡视频| 日韩一区精品字幕| 99精品一区二区| 精品欧美乱码久久久久久1区2区| 亚洲麻豆国产自偷在线| 国产一区二区三区免费播放| 欧美亚洲国产bt| 亚洲少妇30p| 国产成人午夜电影网| 欧美一区二区观看视频| 亚洲嫩草精品久久| 成人午夜看片网址| 精品粉嫩超白一线天av| 美女视频黄久久| 9191精品国产综合久久久久久| 亚洲人成网站色在线观看| 国产乱色国产精品免费视频| 日韩一级片在线播放| 亚洲国产日韩精品| 色婷婷精品久久二区二区蜜臀av| 日本一区二区三区高清不卡| 国产精品综合二区| 精品欧美一区二区久久| 麻豆国产欧美一区二区三区| 制服.丝袜.亚洲.另类.中文| 一区二区三区四区视频精品免费 | 亚洲免费av高清| 不卡视频一二三四| 国产精品视频看| 国产馆精品极品| 久久久久久久久久美女| 韩国在线一区二区| 2023国产精品视频| 精品在线一区二区三区| 精品国产在天天线2019| 久久疯狂做爰流白浆xx| 精品国产第一区二区三区观看体验| 毛片av一区二区| 久久人人爽爽爽人久久久| 狠狠色丁香婷综合久久| 久久只精品国产| 国产精华液一区二区三区| 国产精品美女久久久久久2018| 成人免费毛片片v| 亚洲欧美在线视频观看| 91丨porny丨国产| 亚洲国产乱码最新视频| 欧美日韩国产电影| 久久精品国产一区二区| xvideos.蜜桃一区二区| 欧美日韩一区二区三区在线看| 亚洲国产精品一区二区www| 3d动漫精品啪啪一区二区竹菊| 亚洲一区二区三区四区五区黄| 欧美日本在线播放| 蜜臀av在线播放一区二区三区| 精品国产一区二区精华 | 在线成人免费观看| 蜜桃视频一区二区三区| 亚洲精品一区二区三区福利 | 亚洲高清免费在线| 日韩欧美国产综合一区| 国产成人av电影在线观看| 最新欧美精品一区二区三区| 在线亚洲高清视频| 日本aⅴ免费视频一区二区三区| 欧美va在线播放| 成人国产亚洲欧美成人综合网| 亚洲欧美日韩在线| 日韩女优制服丝袜电影| 国产成人在线观看免费网站| 亚洲精选一二三| 日韩精品一区二区三区在线| 丁香激情综合国产| 性欧美大战久久久久久久久| 精品国产乱码久久久久久老虎 | 日日骚欧美日韩| 欧美激情艳妇裸体舞| 欧洲一区二区三区免费视频| 久久精品av麻豆的观看方式| 亚洲人成影院在线观看| 欧美一卡二卡三卡四卡| 成人激情开心网| 日本美女一区二区| 中文字幕一区二区三区视频| 欧美一区二区视频网站| av在线这里只有精品| 美国毛片一区二区| 一区二区三区久久久| 久久这里只有精品6| 欧美性色综合网| 粉嫩高潮美女一区二区三区| 五月天激情综合| 日韩美女视频一区| 精品国产乱码久久久久久免费| 欧美午夜一区二区三区| 暴力调教一区二区三区| 久久精品99国产精品| 亚洲va国产天堂va久久en|