File: xml-imp.h

package info (click to toggle)
mupdf 1.25.1%2Bds1-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 21,620 kB
  • sloc: ansic: 270,929; python: 20,709; java: 6,916; javascript: 1,865; makefile: 1,130; xml: 550; sh: 430; cpp: 325; cs: 313; awk: 10; sed: 7; lisp: 3
file content (90 lines) | stat: -rw-r--r-- 2,333 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (C) 2022 Artifex Software, Inc.
//
// This file is part of MuPDF.
//
// MuPDF is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// MuPDF 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 Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
//
// Alternative licensing terms are available from the licensor.
// For commercial licensing, see <https://www.artifex.com/> or contact
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
// CA 94129, USA, for further information.

#ifndef XML_IMP_H

#define XML_IMP_H

#include "mupdf/fitz.h"

/* These types are required for basic XML operation. */

struct attribute
{
	char *value;
	struct attribute *next;
	char name[1];
};

/**
	We use a slightly grotty representation for an XML tree.

	The topmost element of the tree is an fz_xml with up == NULL.
	This signifies that we are a 'doc', rather than a 'node'.

	We only ever get a 'doc' node at the root, and this contains
	a reference count for the entire tree, together with the
	fz_pool pointer used to allocate nodes.

	All other structures are 'nodes'. If down is MAGIC_TEXT then
	they are text nodes (with no children or attributes).
	Otherwise, they are standard XML nodes with attributes
	and children.
*/

struct fz_xml
{
	fz_xml *up, *down;
	union
	{
		struct /* up != NULL */
		{
			fz_xml *prev, *next;
#ifdef FZ_XML_SEQ
			int seq;
#endif
			union
			{
				char text[1]; /* down == MAGIC_TEXT */
				struct /* down != MAGIC_TEXT */
				{
					struct attribute *atts;
					char name[1];
				} d;
			} u;
		} node;
		struct /* up == NULL */
		{
			int refs;
			fz_pool *pool;
		} doc;
	} u;
};

#define MAGIC_TEXT ((fz_xml *)1)

#define FZ_TEXT_ITEM(item) (item && item->down == MAGIC_TEXT)
#define FZ_DOCUMENT_ITEM(item) (item && item->up == NULL)

size_t xml_parse_entity(int *c, const char *a);

#endif