MagickCore 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
xml-tree-private.h
1/*
2 Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License. You may
6 obtain a copy of the License at
7
8 https://imagemagick.org/script/license.php
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 MagickCore private xml-tree methods.
17*/
18#ifndef MAGICKCORE_XML_TREE_PRIVATE_H
19#define MAGICKCORE_XML_TREE_PRIVATE_H
20
21#include "MagickCore/locale_.h"
22#include "MagickCore/memory_.h"
23#include "MagickCore/string_.h"
24#include "MagickCore/splay-tree.h"
25#include "MagickCore/xml-tree.h"
26
27#if defined(__cplusplus) || defined(c_plusplus)
28extern "C" {
29#endif
30
31static inline char *SubstituteXMLEntities(const char *content,
32 const MagickBooleanType pedantic)
33{
34 char
35 *canonical_content;
36
37 const char
38 *p;
39
40 size_t
41 extent;
42
43 ssize_t
44 i;
45
46 /*
47 Substitute predefined entities.
48 */
49 i=0;
50 canonical_content=AcquireString((char *) NULL);
51 extent=MagickPathExtent;
52 for (p=content; *p != '\0'; p++)
53 {
54 if ((i+MagickPathExtent) > (ssize_t) extent)
55 {
56 extent+=MagickPathExtent;
57 canonical_content=(char *) ResizeQuantumMemory(canonical_content,extent,
58 sizeof(*canonical_content));
59 if (canonical_content == (char *) NULL)
60 return(canonical_content);
61 }
62 switch (*p)
63 {
64 case '&':
65 {
66 i+=FormatLocaleString(canonical_content+i,extent,"&");
67 break;
68 }
69 case '<':
70 {
71 i+=FormatLocaleString(canonical_content+i,extent,"&lt;");
72 break;
73 }
74 case '>':
75 {
76 i+=FormatLocaleString(canonical_content+i,extent,"&gt;");
77 break;
78 }
79 case '"':
80 {
81 i+=FormatLocaleString(canonical_content+i,extent,"&quot;");
82 break;
83 }
84 case '\n':
85 {
86 if (pedantic == MagickFalse)
87 {
88 canonical_content[i++]=(char) (*p);
89 break;
90 }
91 i+=FormatLocaleString(canonical_content+i,extent,"&#xA;");
92 break;
93 }
94 case '\t':
95 {
96 if (pedantic == MagickFalse)
97 {
98 canonical_content[i++]=(char) (*p);
99 break;
100 }
101 i+=FormatLocaleString(canonical_content+i,extent,"&#x9;");
102 break;
103 }
104 case '\r':
105 {
106 i+=FormatLocaleString(canonical_content+i,extent,"&#xD;");
107 break;
108 }
109 default:
110 {
111 canonical_content[i++]=(char) (*p);
112 break;
113 }
114 }
115 }
116 canonical_content[i]='\0';
117 return(canonical_content);
118}
119
120extern MagickPrivate char
121 *CanonicalXMLContent(const char *,const MagickBooleanType),
122 *FileToXML(const char *,const size_t);
123
124extern MagickPrivate const char
125 **GetXMLTreeProcessingInstructions(XMLTreeInfo *,const char *);
126
127extern MagickPrivate MagickBooleanType
128 GetXMLTreeAttributes(const XMLTreeInfo *,SplayTreeInfo *);
129
130extern MagickPrivate XMLTreeInfo
131 *AddPathToXMLTree(XMLTreeInfo *,const char *,const size_t),
132 *GetXMLTreeOrdered(XMLTreeInfo *),
133 *GetXMLTreePath(XMLTreeInfo *,const char *),
134 *InsertTagIntoXMLTree(XMLTreeInfo *,XMLTreeInfo *,const size_t),
135 *ParseTagFromXMLTree(XMLTreeInfo *),
136 *PruneTagFromXMLTree(XMLTreeInfo *),
137 *SetXMLTreeAttribute(XMLTreeInfo *,const char *,const char *);
138
139#if defined(__cplusplus) || defined(c_plusplus)
140}
141#endif
142
143#endif