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

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

?? mxml-index.c

?? 適用于嵌入式系統的XML解析庫, 規模比libxml2小得多.
?? C
字號:
/* * "$Id: mxml-index.c 184 2005-01-29 07:21:44Z mike $" * * Index support code for Mini-XML, a small XML-like file parsing library. * * Copyright 2003-2005 by Michael Sweet. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * Contents: * *   mxmlIndexDelete()   - Delete an index. *   mxmlIndexEnum()     - Return the next node in the index. *   mxmlIndexFind()     - Find the next matching node. *   mxmlIndexNew()      - Create a new index. *   mxmlIndexReset()    - Reset the enumeration/find pointer in the index and *                         return the first node in the index. *   index_compare()     - Compare two nodes. *   index_find()        - Compare a node with index values. *   index_sort()        - Sort the nodes in the index... *//* * Include necessary headers... */#include "config.h"#include "mxml.h"/* * Sort functions... */static int	index_compare(mxml_index_t *ind, mxml_node_t *first,		              mxml_node_t *second);static int	index_find(mxml_index_t *ind, const char *element,		           const char *value, mxml_node_t *node);static void	index_sort(mxml_index_t *ind, int left, int right);/* * 'mxmlIndexDelete()' - Delete an index. */voidmxmlIndexDelete(mxml_index_t *ind)	/* I - Index to delete */{ /*  * Range check input..  */  if (!ind)    return; /*  * Free memory...  */  if (ind->attr)    free(ind->attr);  if (ind->alloc_nodes)    free(ind->nodes);  free(ind);}/* * 'mxmlIndexEnum()' - Return the next node in the index. * * Nodes are returned in the sorted order of the index. */mxml_node_t *				/* O - Next node or NULL if there is none */mxmlIndexEnum(mxml_index_t *ind)	/* I - Index to enumerate */{ /*  * Range check input...  */  if (!ind)    return (NULL); /*  * Return the next node...  */  if (ind->cur_node < ind->num_nodes)    return (ind->nodes[ind->cur_node ++]);  else    return (NULL);}/* * 'mxmlIndexFind()' - Find the next matching node. * * You should call mxmlIndexReset() prior to using this function for * the first time with a particular set of "element" and "value" * strings. Passing NULL for both "element" and "value" is equivalent * to calling mxmlIndexEnum(). */mxml_node_t *				/* O - Node or NULL if none found */mxmlIndexFind(mxml_index_t *ind,	/* I - Index to search */              const char   *element,	/* I - Element name to find, if any */	      const char   *value)	/* I - Attribute value, if any */{  int		diff,			/* Difference between names */		current,		/* Current entity in search */		first,			/* First entity in search */		last;			/* Last entity in search */#ifdef DEBUG  printf("mxmlIndexFind(ind=%p, element=\"%s\", value=\"%s\")\n",         ind, element ? element : "(null)", value ? value : "(null)");#endif /* DEBUG */ /*  * Range check input...  */  if (!ind || (!ind->attr && value))  {#ifdef DEBUG    puts("    returning NULL...");    printf("    ind->attr=\"%s\"\n", ind->attr ? ind->attr : "(null)");#endif /* DEBUG */    return (NULL);  } /*  * If both element and value are NULL, just enumerate the nodes in the  * index...  */  if (!element && !value)    return (mxmlIndexEnum(ind)); /*  * If there are no nodes in the index, return NULL...  */  if (!ind->num_nodes)  {#ifdef DEBUG    puts("    returning NULL...");    puts("    no nodes!");#endif /* DEBUG */    return (NULL);  } /*  * If cur_node == 0, then find the first matching node...  */  if (ind->cur_node == 0)  {   /*    * Find the first node using a modified binary search algorithm...    */    first = 0;    last  = ind->num_nodes - 1;#ifdef DEBUG    printf("    find first time, num_nodes=%d...\n", ind->num_nodes);#endif /* DEBUG */    while ((last - first) > 1)    {      current = (first + last) / 2;#ifdef DEBUG      printf("    first=%d, last=%d, current=%d\n", first, last, current);#endif /* DEBUG */      if ((diff = index_find(ind, element, value, ind->nodes[current])) == 0)      {       /*        * Found a match, move back to find the first...	*/#ifdef DEBUG        puts("    match!");#endif /* DEBUG */        while (current > 0 &&	       !index_find(ind, element, value, ind->nodes[current - 1]))	  current --;#ifdef DEBUG        printf("    returning first match=%d\n", current);#endif /* DEBUG */       /*        * Return the first match and save the index to the next...	*/        ind->cur_node = current + 1;	return (ind->nodes[current]);      }      else if (diff < 0)	last = current;      else	first = current;#ifdef DEBUG      printf("    diff=%d\n", diff);#endif /* DEBUG */    }   /*    * If we get this far, then we found exactly 0 or 1 matches...    */    for (current = first; current <= last; current ++)      if (!index_find(ind, element, value, ind->nodes[current]))      {       /*	* Found exactly one (or possibly two) match...	*/#ifdef DEBUG	printf("    returning only match %d...\n", current);#endif /* DEBUG */	ind->cur_node = current + 1;	return (ind->nodes[current]);      }   /*    * No matches...    */    ind->cur_node = ind->num_nodes;#ifdef DEBUG    puts("    returning NULL...");#endif /* DEBUG */    return (NULL);  }  else if (ind->cur_node < ind->num_nodes &&           !index_find(ind, element, value, ind->nodes[ind->cur_node]))  {   /*    * Return the next matching node...    */#ifdef DEBUG    printf("    returning next match %d...\n", ind->cur_node);#endif /* DEBUG */    return (ind->nodes[ind->cur_node ++]);  } /*  * If we get this far, then we have no matches...  */  ind->cur_node = ind->num_nodes;#ifdef DEBUG  puts("    returning NULL...");#endif /* DEBUG */  return (NULL);}/* * 'mxmlIndexNew()' - Create a new index. * * The index will contain all nodes that contain the named element and/or * attribute. If both "element" and "attr" are NULL, then the index will * contain a sorted list of the elements in the node tree.  Nodes are * sorted by element name and optionally by attribute value if the "attr" * argument is not NULL. */mxml_index_t *				/* O - New index */mxmlIndexNew(mxml_node_t *node,		/* I - XML node tree */             const char  *element,	/* I - Element to index or NULL for all */             const char  *attr)		/* I - Attribute to index or NULL for none */{  mxml_index_t	*ind;			/* New index */  mxml_node_t	*current,		/* Current node in index */  		**temp;			/* Temporary node pointer array */ /*  * Range check input...  */#ifdef DEBUG  printf("mxmlIndexNew(node=%p, element=\"%s\", attr=\"%s\")\n",         node, element ? element : "(null)", attr ? attr : "(null)");#endif /* DEBUG */  if (!node)    return (NULL); /*  * Create a new index...  */  if ((ind = calloc(1, sizeof(mxml_index_t))) == NULL)  {    mxml_error("Unable to allocate %d bytes for index - %s",               sizeof(mxml_index_t), strerror(errno));    return (NULL);  }  if (attr)    ind->attr = strdup(attr);  if (!element && !attr)    current = node;  else    current = mxmlFindElement(node, node, element, attr, NULL, MXML_DESCEND);  while (current)  {    if (ind->num_nodes >= ind->alloc_nodes)    {      if (!ind->alloc_nodes)        temp = malloc(64 * sizeof(mxml_node_t *));      else        temp = realloc(ind->nodes, (ind->alloc_nodes + 64) * sizeof(mxml_node_t *));      if (!temp)      {       /*        * Unable to allocate memory for the index, so abort...	*/        mxml_error("Unable to allocate %d bytes for index: %s",	           (ind->alloc_nodes + 64) * sizeof(mxml_node_t *),		   strerror(errno));        mxmlIndexDelete(ind);	return (NULL);      }      ind->nodes       = temp;      ind->alloc_nodes += 64;    }    ind->nodes[ind->num_nodes ++] = current;    current = mxmlFindElement(current, node, element, attr, NULL, MXML_DESCEND);  } /*  * Sort nodes based upon the search criteria...  */#ifdef DEBUG  {    int i;				/* Looping var */    printf("%d node(s) in index.\n\n", ind->num_nodes);    if (attr)    {      printf("Node      Address   Element         %s\n", attr);      puts("--------  --------  --------------  ------------------------------");      for (i = 0; i < ind->num_nodes; i ++)	printf("%8d  %-8p  %-14.14s  %s\n", i, ind->nodes[i],	       ind->nodes[i]->value.element.name,	       mxmlElementGetAttr(ind->nodes[i], attr));    }    else    {      puts("Node      Address   Element");      puts("--------  --------  --------------");      for (i = 0; i < ind->num_nodes; i ++)	printf("%8d  %-8p  %s\n", i, ind->nodes[i],	       ind->nodes[i]->value.element.name);    }    putchar('\n');  }#endif /* DEBUG */  if (ind->num_nodes > 1)    index_sort(ind, 0, ind->num_nodes - 1);#ifdef DEBUG  {    int i;				/* Looping var */    puts("After sorting:\n");    if (attr)    {      printf("Node      Address   Element         %s\n", attr);      puts("--------  --------  --------------  ------------------------------");      for (i = 0; i < ind->num_nodes; i ++)	printf("%8d  %-8p  %-14.14s  %s\n", i, ind->nodes[i],	       ind->nodes[i]->value.element.name,	       mxmlElementGetAttr(ind->nodes[i], attr));    }    else    {      puts("Node      Address   Element");      puts("--------  --------  --------------");      for (i = 0; i < ind->num_nodes; i ++)	printf("%8d  %-8p  %s\n", i, ind->nodes[i],	       ind->nodes[i]->value.element.name);    }    putchar('\n');  }#endif /* DEBUG */ /*  * Return the new index...  */  return (ind);}/* * 'mxmlIndexReset()' - Reset the enumeration/find pointer in the index and *                      return the first node in the index. * * This function should be called prior to using mxmlIndexEnum() or * mxmlIndexFind() for the first time. */mxml_node_t *				/* O - First node or NULL if there is none */mxmlIndexReset(mxml_index_t *ind)	/* I - Index to reset */{#ifdef DEBUG  printf("mxmlIndexReset(ind=%p)\n", ind);#endif /* DEBUG */ /*  * Range check input...  */  if (!ind)    return (NULL); /*  * Set the index to the first element...  */  ind->cur_node = 0; /*  * Return the first node...  */  if (ind->num_nodes)    return (ind->nodes[0]);  else    return (NULL);}/* * 'index_compare()' - Compare two nodes. */static int				/* O - Result of comparison */index_compare(mxml_index_t *ind,	/* I - Index */              mxml_node_t  *first,	/* I - First node */              mxml_node_t  *second)	/* I - Second node */{  int	diff;				/* Difference */ /*  * Check the element name...  */  if ((diff = strcmp(first->value.element.name,                     second->value.element.name)) != 0)    return (diff); /*  * Check the attribute value...  */  if (ind->attr)  {    if ((diff = strcmp(mxmlElementGetAttr(first, ind->attr),                       mxmlElementGetAttr(second, ind->attr))) != 0)      return (diff);  } /*  * No difference, return 0...  */  return (0);}/* * 'index_find()' - Compare a node with index values. */static int				/* O - Result of comparison */index_find(mxml_index_t *ind,		/* I - Index */           const char   *element,	/* I - Element name or NULL */	   const char   *value,		/* I - Attribute value or NULL */           mxml_node_t  *node)		/* I - Node */{  int	diff;				/* Difference */ /*  * Check the element name...  */  if (element)  {    if ((diff = strcmp(element, node->value.element.name)) != 0)      return (diff);  } /*  * Check the attribute value...  */  if (value)  {    if ((diff = strcmp(value, mxmlElementGetAttr(node, ind->attr))) != 0)      return (diff);  } /*  * No difference, return 0...  */  return (0);}/* * 'index_sort()' - Sort the nodes in the index... * * This function implements the classic quicksort algorithm... */static voidindex_sort(mxml_index_t *ind,		/* I - Index to sort */           int          left,		/* I - Left node in partition */	   int          right)		/* I - Right node in partition */{  mxml_node_t	*pivot,			/* Pivot node */		*temp;			/* Swap node */  int		templ,			/* Temporary left node */		tempr;			/* Temporary right node */ /*  * Loop until we have sorted all the way to the right...  */  do  {   /*    * Sort the pivot in the current partition...    */    pivot = ind->nodes[left];    for (templ = left, tempr = right; templ < tempr;)    {     /*      * Move left while left node <= pivot node...      */      while ((templ < right) &&             index_compare(ind, ind->nodes[templ], pivot) <= 0)	templ ++;     /*      * Move right while right node > pivot node...      */      while ((tempr > left) &&             index_compare(ind, ind->nodes[tempr], pivot) > 0)	tempr --;     /*      * Swap nodes if needed...      */      if (templ < tempr)      {	temp              = ind->nodes[templ];	ind->nodes[templ] = ind->nodes[tempr];	ind->nodes[tempr] = temp;      }    }   /*    * When we get here, the right (tempr) node is the new position for the    * pivot node...    */    if (index_compare(ind, pivot, ind->nodes[tempr]) > 0)    {      ind->nodes[left]  = ind->nodes[tempr];      ind->nodes[tempr] = pivot;    }   /*    * Recursively sort the left partition as needed...    */    if (left < (tempr - 1))      index_sort(ind, left, tempr - 1);  }  while (right > (left = tempr + 1));}/* * End of "$Id: mxml-index.c 184 2005-01-29 07:21:44Z mike $". */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人动漫av| 一区二区在线观看不卡| 亚洲综合在线免费观看| 狠狠色丁香婷综合久久| 欧美色图第一页| 国产精品久久久久影院| 韩国女主播成人在线| 欧美日韩高清影院| 亚洲乱码中文字幕| 大白屁股一区二区视频| 精品少妇一区二区三区日产乱码 | 欧美日韩亚洲国产综合| 国产精品人人做人人爽人人添| 久久99精品国产麻豆婷婷洗澡| 欧美日韩午夜在线视频| 亚洲青青青在线视频| 成人黄页毛片网站| 久久久久97国产精华液好用吗| 蜜臂av日日欢夜夜爽一区| 欧美日韩激情一区二区| 一区二区三区中文在线| 91在线观看地址| 国产清纯白嫩初高生在线观看91 | 日韩欧美国产电影| 亚洲成av人片一区二区梦乃| 91国内精品野花午夜精品 | 亚洲欧洲无码一区二区三区| 美女视频黄a大片欧美| 欧美性xxxxx极品少妇| 亚洲图片你懂的| 成人午夜激情在线| 欧美激情综合网| 国产mv日韩mv欧美| 久久久久久久久久久久久夜| 国模少妇一区二区三区| 日韩欧美国产三级电影视频| 轻轻草成人在线| 91麻豆精品久久久久蜜臀| 亚洲一区在线观看免费 | 在线看国产一区| 亚洲欧美日韩国产手机在线 | 91麻豆免费看| 综合色中文字幕| 99精品视频一区| 亚洲欧美区自拍先锋| 色综合色狠狠综合色| 伊人婷婷欧美激情| 欧美视频三区在线播放| 亚洲r级在线视频| 欧美精品aⅴ在线视频| 日本在线播放一区二区三区| 日韩欧美一区二区三区在线| 国内精品伊人久久久久av影院| 久久精品无码一区二区三区| 丁香激情综合五月| 亚洲美女在线一区| 欧美日本免费一区二区三区| 毛片一区二区三区| 欧美精品一区二区三区久久久| 国产精品一区在线| 国产精品久久久久久久第一福利| 色狠狠综合天天综合综合| 亚洲图片有声小说| 91麻豆精品国产91久久久使用方法| 奇米四色…亚洲| 久久九九99视频| 成人网在线免费视频| 一区二区成人在线视频| 91精品久久久久久久91蜜桃| 国产精品77777竹菊影视小说| 国产精品乱人伦中文| 欧美系列亚洲系列| 精品一二线国产| 国产精品福利一区二区| 欧美色综合网站| 免费成人小视频| 亚洲国产高清aⅴ视频| 91国产丝袜在线播放| 蜜臀av性久久久久蜜臀aⅴ| 久久久久99精品国产片| 91福利视频网站| 精品一区二区三区蜜桃| 国产精品久久久99| 欧美久久久一区| 国产成a人亚洲精品| 亚洲综合一区在线| 久久婷婷综合激情| 在线视频一区二区三| 精品一区二区三区香蕉蜜桃| 亚洲视频小说图片| 日韩欧美区一区二| 色综合天天在线| 蜜桃免费网站一区二区三区| 国产精品女同互慰在线看| 7777精品久久久大香线蕉| 高清成人免费视频| 日本一区中文字幕| 中文字幕在线一区二区三区| 日韩一级免费一区| 91麻豆精品在线观看| 极品尤物av久久免费看| 一区二区三区精品视频在线| 26uuu国产一区二区三区| 日本精品视频一区二区三区| 国产在线国偷精品产拍免费yy| 亚洲免费观看在线观看| 久久综合九色综合欧美98 | 国产精品影音先锋| 天天色综合天天| 国产精品不卡在线| 精品成人免费观看| 欧美日韩高清不卡| 色综合咪咪久久| 国产成人精品午夜视频免费| 热久久久久久久| 亚洲国产一区二区在线播放| 国产欧美日产一区| 精品国产污污免费网站入口 | 欧洲亚洲国产日韩| 成人小视频在线观看| 久久国产福利国产秒拍| 亚洲大片精品永久免费| 中文字幕综合网| 国产网站一区二区| 欧美成人伊人久久综合网| 欧美无人高清视频在线观看| 成人黄色软件下载| 国产精品一色哟哟哟| 美女一区二区在线观看| 石原莉奈在线亚洲二区| 亚洲精品欧美综合四区| 国产精品久久久久久久久搜平片| 久久蜜桃av一区二区天堂 | 日韩一区二区影院| 欧美亚洲综合在线| 色婷婷精品久久二区二区蜜臀av| 国产.欧美.日韩| 国产不卡免费视频| 韩国女主播一区二区三区| 美女视频一区在线观看| 日韩激情视频网站| 日韩专区一卡二卡| 亚洲成av人影院在线观看网| 亚洲一区二区三区爽爽爽爽爽 | 久久久久久电影| 精品久久久久久久人人人人传媒| 91麻豆精品国产91久久久使用方法| 欧美日韩国产一级片| 欧美性做爰猛烈叫床潮| 在线看不卡av| 欧美亚洲综合久久| 欧美在线三级电影| 欧美性videosxxxxx| 欧美丝袜丝交足nylons| 欧美日韩精品一区视频| 精品视频一区 二区 三区| 欧美性三三影院| 欧美日韩高清一区二区| 91精品蜜臀在线一区尤物| 欧美一区二区三区思思人| 日韩女优电影在线观看| 欧美变态口味重另类| 久久综合五月天婷婷伊人| 久久久亚洲欧洲日产国码αv| 久久久久久久久久久99999| 国产欧美精品一区| 中文字幕永久在线不卡| 亚洲人精品一区| 性欧美疯狂xxxxbbbb| 天堂av在线一区| 麻豆国产一区二区| 韩国精品免费视频| 成人av综合一区| 色吧成人激情小说| 欧美日韩美少妇| 精品精品欲导航| 国产色91在线| 1000部国产精品成人观看| 亚洲最新视频在线播放| 亚洲电影一级片| 久久66热re国产| 成人久久久精品乱码一区二区三区| av不卡在线观看| 欧美三级电影网| 2020国产精品| 亚洲色图色小说| 日韩国产精品久久| 国产麻豆视频一区二区| 91猫先生在线| 日韩视频一区二区在线观看| 久久久激情视频| 一卡二卡欧美日韩| 精品在线播放午夜| 成人av第一页| 欧美日韩国产综合久久| 欧美xingq一区二区| 《视频一区视频二区| 午夜久久久久久久久| 国产伦理精品不卡| 在线精品亚洲一区二区不卡|