1 /* libxml2 - Library for parsing XML documents
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /*
11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is fur-
18 * nished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * THE SOFTWARE.
30 *
31 * Author: Daniel Veillard
32 */
33
34 /*
35 * Summary: Tree debugging APIs
36 * Description: Interfaces to a set of routines used for debugging the tree
37 * produced by the XML parser.
38 */
39
40 #ifndef __DEBUG_XML__
41 #define __DEBUG_XML__
42 #include <stdio.h>
43 #include <libxml/xmlversion.h>
44 #include <libxml/tree.h>
45
46 #ifdef LIBXML_DEBUG_ENABLED
47
48 #include <libxml/xpath.h>
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /*
55 * The standard Dump routines.
56 */
57 XMLPUBFUN void XMLCALL
58 xmlDebugDumpString (FILE *output,
59 const xmlChar *str);
60 XMLPUBFUN void XMLCALL
61 xmlDebugDumpAttr (FILE *output,
62 xmlAttrPtr attr,
63 int depth);
64 XMLPUBFUN void XMLCALL
65 xmlDebugDumpAttrList (FILE *output,
66 xmlAttrPtr attr,
67 int depth);
68 XMLPUBFUN void XMLCALL
69 xmlDebugDumpOneNode (FILE *output,
70 xmlNodePtr node,
71 int depth);
72 XMLPUBFUN void XMLCALL
73 xmlDebugDumpNode (FILE *output,
74 xmlNodePtr node,
75 int depth);
76 XMLPUBFUN void XMLCALL
77 xmlDebugDumpNodeList (FILE *output,
78 xmlNodePtr node,
79 int depth);
80 XMLPUBFUN void XMLCALL
81 xmlDebugDumpDocumentHead(FILE *output,
82 xmlDocPtr doc);
83 XMLPUBFUN void XMLCALL
84 xmlDebugDumpDocument (FILE *output,
85 xmlDocPtr doc);
86 XMLPUBFUN void XMLCALL
87 xmlDebugDumpDTD (FILE *output,
88 xmlDtdPtr dtd);
89 XMLPUBFUN void XMLCALL
90 xmlDebugDumpEntities (FILE *output,
91 xmlDocPtr doc);
92
93 /****************************************************************
94 * *
95 * Checking routines *
96 * *
97 ****************************************************************/
98
99 XMLPUBFUN int XMLCALL
100 xmlDebugCheckDocument (FILE * output,
101 xmlDocPtr doc);
102
103 /****************************************************************
104 * *
105 * XML shell helpers *
106 * *
107 ****************************************************************/
108
109 XMLPUBFUN void XMLCALL
110 xmlLsOneNode (FILE *output, xmlNodePtr node);
111 XMLPUBFUN int XMLCALL
112 xmlLsCountNode (xmlNodePtr node);
113
114 XMLPUBFUN const char * XMLCALL
115 xmlBoolToText (int boolval);
116
117 /****************************************************************
118 * *
119 * The XML shell related structures and functions *
120 * *
121 ****************************************************************/
122
123 #ifdef LIBXML_XPATH_ENABLED
124 /**
125 * xmlShellReadlineFunc:
126 * @prompt: a string prompt
127 *
128 * This is a generic signature for the XML shell input function.
129 *
130 * Returns a string which will be freed by the Shell.
131 */
132 typedef char * (* xmlShellReadlineFunc)(char *prompt);
133
134 /**
135 * xmlShellCtxt:
136 *
137 * A debugging shell context.
138 * TODO: add the defined function tables.
139 */
140 typedef struct _xmlShellCtxt xmlShellCtxt;
141 typedef xmlShellCtxt *xmlShellCtxtPtr;
142 struct _xmlShellCtxt {
143 char *filename;
144 xmlDocPtr doc;
145 xmlNodePtr node;
146 xmlXPathContextPtr pctxt;
147 int loaded;
148 FILE *output;
149 xmlShellReadlineFunc input;
150 };
151
152 /**
153 * xmlShellCmd:
154 * @ctxt: a shell context
155 * @arg: a string argument
156 * @node: a first node
157 * @node2: a second node
158 *
159 * This is a generic signature for the XML shell functions.
160 *
161 * Returns an int, negative returns indicating errors.
162 */
163 typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
164 char *arg,
165 xmlNodePtr node,
166 xmlNodePtr node2);
167
168 XMLPUBFUN void XMLCALL
169 xmlShellPrintXPathError (int errorType,
170 const char *arg);
171 XMLPUBFUN void XMLCALL
172 xmlShellPrintXPathResult(xmlXPathObjectPtr list);
173 XMLPUBFUN int XMLCALL
174 xmlShellList (xmlShellCtxtPtr ctxt,
175 char *arg,
176 xmlNodePtr node,
177 xmlNodePtr node2);
178 XMLPUBFUN int XMLCALL
179 xmlShellBase (xmlShellCtxtPtr ctxt,
180 char *arg,
181 xmlNodePtr node,
182 xmlNodePtr node2);
183 XMLPUBFUN int XMLCALL
184 xmlShellDir (xmlShellCtxtPtr ctxt,
185 char *arg,
186 xmlNodePtr node,
187 xmlNodePtr node2);
188 XMLPUBFUN int XMLCALL
189 xmlShellLoad (xmlShellCtxtPtr ctxt,
190 char *filename,
191 xmlNodePtr node,
192 xmlNodePtr node2);
193 #ifdef LIBXML_OUTPUT_ENABLED
194 XMLPUBFUN void XMLCALL
195 xmlShellPrintNode (xmlNodePtr node);
196 XMLPUBFUN int XMLCALL
197 xmlShellCat (xmlShellCtxtPtr ctxt,
198 char *arg,
199 xmlNodePtr node,
200 xmlNodePtr node2);
201 XMLPUBFUN int XMLCALL
202 xmlShellWrite (xmlShellCtxtPtr ctxt,
203 char *filename,
204 xmlNodePtr node,
205 xmlNodePtr node2);
206 XMLPUBFUN int XMLCALL
207 xmlShellSave (xmlShellCtxtPtr ctxt,
208 char *filename,
209 xmlNodePtr node,
210 xmlNodePtr node2);
211 #endif /* LIBXML_OUTPUT_ENABLED */
212 #ifdef LIBXML_VALID_ENABLED
213 XMLPUBFUN int XMLCALL
214 xmlShellValidate (xmlShellCtxtPtr ctxt,
215 char *dtd,
216 xmlNodePtr node,
217 xmlNodePtr node2);
218 #endif /* LIBXML_VALID_ENABLED */
219 XMLPUBFUN int XMLCALL
220 xmlShellDu (xmlShellCtxtPtr ctxt,
221 char *arg,
222 xmlNodePtr tree,
223 xmlNodePtr node2);
224 XMLPUBFUN int XMLCALL
225 xmlShellPwd (xmlShellCtxtPtr ctxt,
226 char *buffer,
227 xmlNodePtr node,
228 xmlNodePtr node2);
229
230 /*
231 * The Shell interface.
232 */
233 XMLPUBFUN void XMLCALL
234 xmlShell (xmlDocPtr doc,
235 char *filename,
236 xmlShellReadlineFunc input,
237 FILE *output);
238
239 #endif /* LIBXML_XPATH_ENABLED */
240
241 #ifdef __cplusplus
242 }
243 #endif
244
245 #endif /* LIBXML_DEBUG_ENABLED */
246 #endif /* __DEBUG_XML__ */