uxml.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _PRO_UXML_H_
  2. #define _PRO_UXML_H_
  3. /*
  4. * Copyright (C) 2008-2013 by egnite GmbH.
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. *
  36. */
  37. /*!
  38. * \file pro/uxml.h
  39. * \brief Micro XML stream parser.
  40. *
  41. * \verbatim
  42. * $Id: uxml.h 4917 2013-01-03 17:22:17Z haraldkipp $
  43. * \endverbatim
  44. */
  45. #include <stdio.h>
  46. /*!
  47. * \brief Linked list of XML attributes.
  48. */
  49. typedef struct _UXML_ATTRIB {
  50. struct _UXML_ATTRIB *xmla_next; /*!< \brief Links the next attribute. */
  51. char *xmla_name; /*!< \brief Name of the attribute. */
  52. char *xmla_value; /*!< \brief Value of the attribute. */
  53. } UXML_ATTRIB;
  54. /*!
  55. * \brief Linked list of XML nodes.
  56. */
  57. typedef struct _UXML_NODE {
  58. struct _UXML_NODE *xmln_next; /*!< \brief Pointer to the next sibling node. */
  59. struct _UXML_NODE *xmln_child; /*!< \brief Pointer to the first child node. */
  60. struct _UXML_NODE *xmln_parent; /*!< \brief Pointer to the parent node. */
  61. char *xmln_name; /*!< \brief Name of the tag. */
  62. #ifndef UXML_IGNORE_CONTENT
  63. char *xmln_content; /*!< \brief Content of the tag. */
  64. #endif
  65. UXML_ATTRIB *xmln_attribs; /*!< \brief Pointer to the linked list of attributes. */
  66. } UXML_NODE;
  67. extern UXML_NODE *UxmlParseStream(FILE * stream, char **f_tags, char **f_attribs);
  68. extern char *UxmlParseTag(char *data, char *tkn, size_t size);
  69. extern UXML_NODE *UxmlTreeAddSibling(UXML_NODE * node, UXML_NODE * sibling);
  70. extern UXML_NODE *UxmlTreeAddChild(UXML_NODE * node, UXML_NODE * child);
  71. extern void UxmlTreeDestroy(UXML_NODE * node);
  72. extern UXML_NODE *UxmlNodeCreate(char *name);
  73. extern int UxmlNodeAddAttrib(UXML_NODE * node, char *name, char *value);
  74. extern int UxmlFilterMatch(char *name, char **filt);
  75. #endif