Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 andreas 1
/*
2
 * Private definitions for Mini-XML, a small XML file parsing library.
3
 *
4
 * https://www.msweet.org/mxml
5
 *
6
 * Copyright © 2003-2019 by Michael R Sweet.
7
 *
8
 * Licensed under Apache License v2.0.  See the file "LICENSE" for more
9
 * information.
10
 */
11
 
12
#ifndef _mxml_private_h_
13
#  define _mxml_private_h_
14
 
15
/*
16
 * Include necessary headers...
17
 */
18
 
19
#  include "config.h"
20
#  include "mxml.h"
21
 
22
 
23
/*
24
 * Private structures...
25
 */
26
 
27
typedef struct _mxml_attr_s		/**** An XML element attribute value. ****/
28
{
29
  char			*name;		/* Attribute name */
30
  char			*value;		/* Attribute value */
31
} _mxml_attr_t;
32
 
33
typedef struct _mxml_element_s		/**** An XML element value. ****/
34
{
35
  char			*name;		/* Name of element */
36
  int			num_attrs;	/* Number of attributes */
37
  _mxml_attr_t		*attrs;		/* Attributes */
38
} _mxml_element_t;
39
 
40
typedef struct _mxml_text_s		/**** An XML text value. ****/
41
{
42
  int			whitespace;	/* Leading whitespace? */
43
  char			*string;	/* Fragment string */
44
} _mxml_text_t;
45
 
46
typedef struct _mxml_custom_s		/**** An XML custom value. ****/
47
{
48
  void			*data;		/* Pointer to (allocated) custom data */
49
  mxml_custom_destroy_cb_t destroy;	/* Pointer to destructor function */
50
} _mxml_custom_t;
51
 
52
typedef union _mxml_value_u		/**** An XML node value. ****/
53
{
54
  _mxml_element_t	element;	/* Element */
55
  int			integer;	/* Integer number */
56
  char			*opaque;	/* Opaque string */
57
  double		real;		/* Real number */
58
  _mxml_text_t		text;		/* Text fragment */
59
  _mxml_custom_t	custom;		/* Custom data @since Mini-XML 2.1@ */
60
} _mxml_value_t;
61
 
62
struct _mxml_node_s			/**** An XML node. ****/
63
{
64
  mxml_type_t		type;		/* Node type */
65
  struct _mxml_node_s	*next;		/* Next node under same parent */
66
  struct _mxml_node_s	*prev;		/* Previous node under same parent */
67
  struct _mxml_node_s	*parent;	/* Parent node */
68
  struct _mxml_node_s	*child;		/* First child node */
69
  struct _mxml_node_s	*last_child;	/* Last child node */
70
  _mxml_value_t		value;		/* Node value */
71
  int			ref_count;	/* Use count */
72
  void			*user_data;	/* User data */
73
};
74
 
75
struct _mxml_index_s			 /**** An XML node index. ****/
76
{
77
  char			*attr;		/* Attribute used for indexing or NULL */
78
  int			num_nodes;	/* Number of nodes in index */
79
  int			alloc_nodes;	/* Allocated nodes in index */
80
  int			cur_node;	/* Current node */
81
  mxml_node_t		**nodes;	/* Node array */
82
};
83
 
84
typedef struct _mxml_global_s		/**** Global, per-thread data ****/
85
 
86
{
87
  void	(*error_cb)(const char *);
88
  int	num_entity_cbs;
89
  int	(*entity_cbs[100])(const char *name);
90
  int	wrap;
91
  mxml_custom_load_cb_t	custom_load_cb;
92
  mxml_custom_save_cb_t	custom_save_cb;
93
} _mxml_global_t;
94
 
95
 
96
/*
97
 * Functions...
98
 */
99
 
100
extern _mxml_global_t	*_mxml_global(void);
101
extern int		_mxml_entity_cb(const char *name);
102
 
103
#endif /* !_mxml_private_h_ */