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

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

?? mxml-index.c

?? MINIXml 具有 解析、查找、生成、遍歷 功能,一般不是太復雜的應用足夠了。可貴的是全部實現是標準c,移植很容易。
?? 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欧美精品.com| 亚洲色图19p| 国产中文一区二区三区| 日韩一级视频免费观看在线| 久久99精品国产麻豆不卡| 欧美大片一区二区| 喷白浆一区二区| 欧美麻豆精品久久久久久| 日韩专区一卡二卡| 欧美成人bangbros| 国产激情视频一区二区三区欧美 | 国产传媒日韩欧美成人| 欧洲国内综合视频| 日本成人中文字幕| 精品对白一区国产伦| 国产一区在线不卡| 五月开心婷婷久久| 日韩欧美在线综合网| 国产乱码一区二区三区| 亚洲天天做日日做天天谢日日欢| 亚洲123区在线观看| 欧美成人性福生活免费看| 不卡大黄网站免费看| 一区二区三区免费在线观看| 3atv一区二区三区| 国产精品一区二区在线观看不卡| 国产精品久久久久四虎| 欧美群妇大交群的观看方式| 国产一区91精品张津瑜| 日本一二三不卡| 欧美日韩一区在线| 大美女一区二区三区| 一区二区三区成人在线视频| 337p日本欧洲亚洲大胆色噜噜| 99国产精品99久久久久久| 免费三级欧美电影| 亚洲男女一区二区三区| 日韩免费看的电影| 狠狠色2019综合网| 一区二区视频在线| 欧美一级久久久久久久大片| 成人av中文字幕| 日韩中文字幕一区二区三区| 中文字幕一区二区5566日韩| 亚洲欧洲色图综合| 中文字幕亚洲一区二区av在线| 国产精品全国免费观看高清 | 亚洲国产中文字幕| 亚洲国产一区在线观看| 亚洲成av人片在线| 秋霞国产午夜精品免费视频| 六月丁香婷婷色狠狠久久| 毛片av一区二区| 韩国毛片一区二区三区| 国产高清久久久久| 99久久亚洲一区二区三区青草| 99久久er热在这里只有精品66| 一本久久精品一区二区| 欧美最猛性xxxxx直播| 欧美欧美欧美欧美首页| 精品福利视频一区二区三区| 日本一区二区在线不卡| 亚洲日本在线a| 日本色综合中文字幕| 国产做a爰片久久毛片| 国产成人亚洲精品青草天美| 色综合天天综合网天天看片| 欧美日韩三级视频| 日韩免费观看2025年上映的电影| 久久久精品免费网站| 国产精品看片你懂得| 亚洲一区二区三区爽爽爽爽爽| 青青草伊人久久| 国产成人鲁色资源国产91色综| 97se亚洲国产综合自在线不卡| 日本一区二区三区四区| 日韩毛片一二三区| 日本午夜精品视频在线观看| 粉嫩欧美一区二区三区高清影视| 91免费看片在线观看| 日韩美女一区二区三区四区| 国产精品狼人久久影院观看方式| 亚洲不卡av一区二区三区| 国产美女在线观看一区| 日本精品视频一区二区三区| 日韩免费电影网站| 亚洲精品一二三| 精东粉嫩av免费一区二区三区| 94-欧美-setu| 亚洲精品一区二区三区精华液| 椎名由奈av一区二区三区| 午夜免费久久看| 国产激情精品久久久第一区二区| 欧美日韩精品三区| 成人欧美一区二区三区视频网页| 毛片av中文字幕一区二区| 91丨九色porny丨蝌蚪| 精品美女在线观看| 亚洲成精国产精品女| 懂色av中文字幕一区二区三区 | 国产成人夜色高潮福利影视| 欧美色爱综合网| 国产亚洲一二三区| 日韩国产精品久久久久久亚洲| 99精品视频在线播放观看| 91精品国产aⅴ一区二区| 国产精品免费视频网站| 国产一区二区三区免费看| 欧美精品免费视频| 亚洲精品免费在线观看| 成人午夜在线免费| 久久久久久久久久久黄色| 日本成人在线视频网站| 欧美丝袜第三区| 亚洲精品写真福利| 不卡视频免费播放| 久久午夜色播影院免费高清 | 天天综合日日夜夜精品| 91视视频在线观看入口直接观看www | 欧美做爰猛烈大尺度电影无法无天| 国产亚洲精品aa午夜观看| 麻豆国产精品一区二区三区 | 国产一区二区伦理| 8v天堂国产在线一区二区| 亚洲一区二区综合| 欧洲精品视频在线观看| 亚洲自拍都市欧美小说| 91精品福利在线| 一区二区欧美视频| 欧美性色欧美a在线播放| 91 com成人网| 国内国产精品久久| 亚洲国产精品ⅴa在线观看| 亚洲国产毛片aaaaa无费看| 色欲综合视频天天天| 亚洲一区二区偷拍精品| 日本高清成人免费播放| 中文字幕日韩一区| 色综合天天综合| 国产在线精品一区二区夜色| 国产精品人人做人人爽人人添| www.久久精品| 精品一区二区三区免费视频| 国产视频一区二区在线观看| 成人免费视频网站在线观看| 亚洲成人激情社区| 久久精品亚洲精品国产欧美 | 欧美精品一区二区三区久久久| 精品亚洲国产成人av制服丝袜 | 在线观看日韩高清av| 香蕉久久夜色精品国产使用方法 | 乱一区二区av| 欧美激情在线一区二区| 欧美日韩成人高清| 不卡电影一区二区三区| 国产成人免费视频一区| 色呦呦网站一区| 欧美三级日韩三级| 6080日韩午夜伦伦午夜伦| 日韩欧美在线观看一区二区三区| 国产精品久久久久久久蜜臀| 亚洲三级在线看| 最新高清无码专区| 久久久一区二区| 欧美性大战xxxxx久久久| 国产成+人+日韩+欧美+亚洲| 全国精品久久少妇| 五月激情综合色| 国产精品亚洲а∨天堂免在线| 精品处破学生在线二十三| 日本中文一区二区三区| 中文字幕在线视频一区| 欧洲人成人精品| 久久精品国产精品亚洲精品| 久久久久久夜精品精品免费| 色综合一个色综合亚洲| 久久精品国产一区二区| 亚洲电影中文字幕在线观看| 精品久久久久一区| 色婷婷综合在线| 极品少妇xxxx精品少妇偷拍| 国产精品激情偷乱一区二区∴| 欧美综合亚洲图片综合区| 另类的小说在线视频另类成人小视频在线| 久久久国产午夜精品| 欧美色网一区二区| 国产激情偷乱视频一区二区三区| 亚洲精品中文字幕乱码三区| 日韩欧美国产三级| 欧日韩精品视频| 精品剧情在线观看| 国产精品视频免费| 亚洲成av人片一区二区梦乃| 久国产精品韩国三级视频| 成人激情免费电影网址| 日本高清不卡视频| 精品国产露脸精彩对白| 国产精品三级在线观看| 青青草一区二区三区| 97精品电影院|