Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/source/fitz/xml-imp.h @ 3:2c135c81b16c
MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:44:09 +0200 |
| parents | b50eed0cc0ef |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6015a75abc2d | 3:2c135c81b16c |
|---|---|
| 1 // Copyright (C) 2022-2025 Artifex Software, Inc. | |
| 2 // | |
| 3 // This file is part of MuPDF. | |
| 4 // | |
| 5 // MuPDF is free software: you can redistribute it and/or modify it under the | |
| 6 // terms of the GNU Affero General Public License as published by the Free | |
| 7 // Software Foundation, either version 3 of the License, or (at your option) | |
| 8 // any later version. | |
| 9 // | |
| 10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | |
| 13 // details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU Affero General Public License | |
| 16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html> | |
| 17 // | |
| 18 // Alternative licensing terms are available from the licensor. | |
| 19 // For commercial licensing, see <https://www.artifex.com/> or contact | |
| 20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, | |
| 21 // CA 94129, USA, for further information. | |
| 22 | |
| 23 #ifndef XML_IMP_H | |
| 24 | |
| 25 #define XML_IMP_H | |
| 26 | |
| 27 #include "mupdf/fitz.h" | |
| 28 | |
| 29 /* These types are required for basic XML operation. */ | |
| 30 | |
| 31 struct attribute | |
| 32 { | |
| 33 char *value; | |
| 34 struct attribute *next; | |
| 35 char name[FZ_FLEXIBLE_ARRAY]; | |
| 36 }; | |
| 37 | |
| 38 /** | |
| 39 We use a slightly grotty representation for an XML tree. | |
| 40 | |
| 41 The topmost element of the tree is an fz_xml with up == NULL. | |
| 42 This signifies that we are a 'doc', rather than a 'node'. | |
| 43 | |
| 44 We only ever get a 'doc' node at the root, and this contains | |
| 45 a reference count for the entire tree, together with the | |
| 46 fz_pool pointer used to allocate nodes. | |
| 47 | |
| 48 All other structures are 'nodes'. If down is MAGIC_TEXT then | |
| 49 they are text nodes (with no children or attributes). | |
| 50 Otherwise, they are standard XML nodes with attributes | |
| 51 and children. | |
| 52 */ | |
| 53 | |
| 54 struct fz_xml | |
| 55 { | |
| 56 fz_xml *up, *down; | |
| 57 union | |
| 58 { | |
| 59 struct /* up != NULL */ | |
| 60 { | |
| 61 fz_xml *prev, *next; | |
| 62 #ifdef FZ_XML_SEQ | |
| 63 int seq; | |
| 64 #endif | |
| 65 union | |
| 66 { | |
| 67 char text[1]; /* down == MAGIC_TEXT */ | |
| 68 struct /* down != MAGIC_TEXT */ | |
| 69 { | |
| 70 struct attribute *atts; | |
| 71 char name[FZ_FLEXIBLE_ARRAY]; | |
| 72 } d; | |
| 73 } u; | |
| 74 } node; | |
| 75 struct /* up == NULL */ | |
| 76 { | |
| 77 int refs; | |
| 78 fz_pool *pool; | |
| 79 } doc; | |
| 80 } u; | |
| 81 }; | |
| 82 | |
| 83 #define MAGIC_TEXT ((fz_xml *)1) | |
| 84 | |
| 85 #define FZ_TEXT_ITEM(item) (item && item->down == MAGIC_TEXT) | |
| 86 #define FZ_DOCUMENT_ITEM(item) (item && item->up == NULL) | |
| 87 | |
| 88 size_t xml_parse_entity(int *c, const char *a); | |
| 89 | |
| 90 #endif |
