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

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

?? xmlprocessor.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久99精品免费观看不卡| 国产午夜精品福利| 久久免费看少妇高潮| 亚洲精品日韩一| 国产又黄又大久久| 欧美日韩在线播放一区| 国产欧美精品一区二区三区四区 | 亚洲1区2区3区视频| 国产高清久久久| 日韩一区二区三区免费观看| 亚洲精品成a人| 国产99久久久国产精品| 日韩精品中文字幕在线一区| 亚洲一区二区三区四区中文字幕| 懂色av一区二区三区蜜臀| 日韩精品综合一本久道在线视频| 一区二区在线电影| 91在线观看成人| 国产精品日韩成人| 成人做爰69片免费看网站| 日韩一区和二区| 亚洲成人av一区二区三区| 色综合视频一区二区三区高清| 久久精品欧美一区二区三区不卡| 奇米精品一区二区三区四区 | 亚洲色图在线播放| 成人午夜免费av| 欧美国产日韩一二三区| 国产一区美女在线| 精品三级在线观看| 久久精品久久综合| 日韩欧美成人激情| 国内外精品视频| 欧美精品一区二| 极品美女销魂一区二区三区| 精品理论电影在线观看| 国产一区二区三区综合| 国产亚洲成aⅴ人片在线观看| 国产一区二区三区免费看 | 国产成人精品一区二区三区四区| 精品免费视频.| 狠狠色狠狠色合久久伊人| 精品国产乱子伦一区| 国产精品一区二区在线观看不卡| 2020国产精品自拍| 国产成人精品三级| 国产精品伦理一区二区| 色菇凉天天综合网| 婷婷夜色潮精品综合在线| 日韩视频一区二区三区在线播放| 久草在线在线精品观看| 中文字幕的久久| 欧美在线小视频| 男男视频亚洲欧美| 久久久高清一区二区三区| 91在线精品一区二区三区| 亚洲成精国产精品女| 日韩免费观看高清完整版 | 麻豆国产精品一区二区三区| 亚洲精品在线网站| 99久久婷婷国产综合精品| 欧美在线三级电影| 一区二区三区日韩欧美精品| 欧美日本一道本| 国产成人免费在线| 日韩中文欧美在线| 国产欧美一区二区三区在线看蜜臀| 91网站视频在线观看| 日本成人在线不卡视频| 中文字幕乱码亚洲精品一区| 欧美影片第一页| 国产精品一区二区三区四区| 夜夜夜精品看看| 国产午夜精品一区二区三区四区 | 亚洲精品高清视频在线观看| 日韩欧美一卡二卡| 99在线精品观看| 久久99精品久久久久久| 伊人性伊人情综合网| 久久女同性恋中文字幕| 欧美三级日韩在线| 粉嫩av一区二区三区粉嫩| 日韩精品免费专区| 国产精品久久久久久久久免费相片| 欧美日韩国产美女| 91碰在线视频| 成人免费视频免费观看| 免费一区二区视频| 亚洲一卡二卡三卡四卡| 中文字幕中文字幕中文字幕亚洲无线| 日韩一区二区在线观看视频播放| 91热门视频在线观看| 成人午夜av在线| 国产一区二区三区日韩| 美女视频黄 久久| 亚洲va在线va天堂| 亚洲黄色片在线观看| 99国产精品久| 亚洲妇女屁股眼交7| 国产精品污网站| 久久久亚洲精品石原莉奈| 欧美一级生活片| 欧美人牲a欧美精品| 欧美综合欧美视频| 色婷婷综合久久久久中文| 成人av网址在线观看| 国产成人福利片| 国产69精品久久99不卡| 国产一区不卡精品| 国产伦精品一区二区三区视频青涩 | 久久婷婷久久一区二区三区| 3d成人h动漫网站入口| 欧美日韩国产另类一区| 欧美老年两性高潮| 欧美一区二区在线免费观看| 欧美性色欧美a在线播放| 在线观看日韩高清av| 91美女在线看| 欧美三日本三级三级在线播放| 91国产成人在线| 91官网在线免费观看| 在线观看视频一区二区欧美日韩| 色老汉av一区二区三区| 欧美亚洲一区二区三区四区| 91久久精品国产91性色tv| 色琪琪一区二区三区亚洲区| 色婷婷久久99综合精品jk白丝 | 国产一区二区91| 成人一区二区三区中文字幕| 国产成人av电影在线观看| 成人永久免费视频| 色婷婷久久综合| 欧美不卡一二三| 国产精品乱码妇女bbbb| 亚洲欧美激情插| 日韩精品欧美成人高清一区二区| 麻豆91在线观看| 成人精品高清在线| 色999日韩国产欧美一区二区| 欧美日韩在线观看一区二区| 日韩欧美在线影院| 中文字幕欧美国产| 亚洲精品视频在线看| 日本大胆欧美人术艺术动态| 国产精品白丝jk白祙喷水网站 | 国产真实乱子伦精品视频| 成人免费视频网站在线观看| 欧美日韩免费观看一区三区| 欧美成人精精品一区二区频| 国产精品美女视频| 午夜精品久久久久影视| 国产精品综合久久| 色香蕉成人二区免费| 日韩欧美成人一区| 亚洲免费在线电影| 久久99久久99| 欧美午夜在线观看| 国产欧美日韩精品a在线观看| 亚洲成人黄色小说| 成人精品一区二区三区中文字幕| 欧美高清精品3d| 亚洲日本欧美天堂| 国产乱色国产精品免费视频| 欧美亚洲综合一区| 欧美韩日一区二区三区四区| 日韩成人精品在线观看| 9l国产精品久久久久麻豆| 日韩一区二区三区电影在线观看| 亚洲日本一区二区| 国产99久久久久久免费看农村| 欧美日韩国产不卡| 亚洲欧美日韩久久精品| 成人性视频免费网站| 久久久久一区二区三区四区| 日韩va欧美va亚洲va久久| 91亚洲资源网| 日本一区二区三级电影在线观看 | 97精品超碰一区二区三区| 日韩精品一区二区三区蜜臀 | 亚洲色大成网站www久久九九| 久久不见久久见中文字幕免费| 欧美性猛交xxxxxxxx| 亚洲品质自拍视频网站| 国产大陆a不卡| 久久综合九色综合久久久精品综合| 亚洲午夜在线视频| 91麻豆免费看片| 国产精品久久影院| 99久久99久久久精品齐齐| 国产精品无圣光一区二区| 国产成人午夜电影网| 久久午夜免费电影| 国产一区二区三区免费在线观看 | 国产福利不卡视频| 久久先锋影音av鲁色资源| 激情深爱一区二区| www激情久久| 国产不卡一区视频| 日本一区二区三区国色天香| 成人高清在线视频|