1 /***************************************************************************
2  * xml.h                                                                   *
3  ***********************IMPORTANT NMAP LICENSE TERMS************************
4  *                                                                         *
5  * The Nmap Security Scanner is (C) 1996-2019 Insecure.Com LLC ("The Nmap  *
6  * Project"). Nmap is also a registered trademark of the Nmap Project.     *
7  * This program is free software; you may redistribute and/or modify it    *
8  * under the terms of the GNU General Public License as published by the   *
9  * Free Software Foundation; Version 2 ("GPL"), BUT ONLY WITH ALL OF THE   *
10  * CLARIFICATIONS AND EXCEPTIONS DESCRIBED HEREIN.  This guarantees your   *
11  * right to use, modify, and redistribute this software under certain      *
12  * conditions.  If you wish to embed Nmap technology into proprietary      *
13  * software, we sell alternative licenses (contact sales@nmap.com).        *
14  * Dozens of software vendors already license Nmap technology such as      *
15  * host discovery, port scanning, OS detection, version detection, and     *
16  * the Nmap Scripting Engine.                                              *
17  *                                                                         *
18  * Note that the GPL places important restrictions on "derivative works",  *
19  * yet it does not provide a detailed definition of that term.  To avoid   *
20  * misunderstandings, we interpret that term as broadly as copyright law   *
21  * allows.  For example, we consider an application to constitute a        *
22  * derivative work for the purpose of this license if it does any of the   *
23  * following with any software or content covered by this license          *
24  * ("Covered Software"):                                                   *
25  *                                                                         *
26  * o Integrates source code from Covered Software.                         *
27  *                                                                         *
28  * o Reads or includes copyrighted data files, such as Nmap's nmap-os-db   *
29  * or nmap-service-probes.                                                 *
30  *                                                                         *
31  * o Is designed specifically to execute Covered Software and parse the    *
32  * results (as opposed to typical shell or execution-menu apps, which will *
33  * execute anything you tell them to).                                     *
34  *                                                                         *
35  * o Includes Covered Software in a proprietary executable installer.  The *
36  * installers produced by InstallShield are an example of this.  Including *
37  * Nmap with other software in compressed or archival form does not        *
38  * trigger this provision, provided appropriate open source decompression  *
39  * or de-archiving software is widely available for no charge.  For the    *
40  * purposes of this license, an installer is considered to include Covered *
41  * Software even if it actually retrieves a copy of Covered Software from  *
42  * another source during runtime (such as by downloading it from the       *
43  * Internet).                                                              *
44  *                                                                         *
45  * o Links (statically or dynamically) to a library which does any of the  *
46  * above.                                                                  *
47  *                                                                         *
48  * o Executes a helper program, module, or script to do any of the above.  *
49  *                                                                         *
50  * This list is not exclusive, but is meant to clarify our interpretation  *
51  * of derived works with some common examples.  Other people may interpret *
52  * the plain GPL differently, so we consider this a special exception to   *
53  * the GPL that we apply to Covered Software.  Works which meet any of     *
54  * these conditions must conform to all of the terms of this license,      *
55  * particularly including the GPL Section 3 requirements of providing      *
56  * source code and allowing free redistribution of the work as a whole.    *
57  *                                                                         *
58  * As another special exception to the GPL terms, the Nmap Project grants  *
59  * permission to link the code of this program with any version of the     *
60  * OpenSSL library which is distributed under a license identical to that  *
61  * listed in the included docs/licenses/OpenSSL.txt file, and distribute   *
62  * linked combinations including the two.                                  *
63  *                                                                         *
64  * The Nmap Project has permission to redistribute Npcap, a packet         *
65  * capturing driver and library for the Microsoft Windows platform.        *
66  * Npcap is a separate work with it's own license rather than this Nmap    *
67  * license.  Since the Npcap license does not permit redistribution        *
68  * without special permission, our Nmap Windows binary packages which      *
69  * contain Npcap may not be redistributed without special permission.      *
70  *                                                                         *
71  * Any redistribution of Covered Software, including any derived works,    *
72  * must obey and carry forward all of the terms of this license, including *
73  * obeying all GPL rules and restrictions.  For example, source code of    *
74  * the whole work must be provided and free redistribution must be         *
75  * allowed.  All GPL references to "this License", are to be treated as    *
76  * including the terms and conditions of this license text as well.        *
77  *                                                                         *
78  * Because this license imposes special exceptions to the GPL, Covered     *
79  * Work may not be combined (even as part of a larger work) with plain GPL *
80  * software.  The terms, conditions, and exceptions of this license must   *
81  * be included as well.  This license is incompatible with some other open *
82  * source licenses as well.  In some cases we can relicense portions of    *
83  * Nmap or grant special permissions to use it in other open source        *
84  * software.  Please contact fyodor@nmap.org with any such requests.       *
85  * Similarly, we don't incorporate incompatible open source software into  *
86  * Covered Software without special permission from the copyright holders. *
87  *                                                                         *
88  * If you have any questions about the licensing restrictions on using     *
89  * Nmap in other works, we are happy to help.  As mentioned above, we also *
90  * offer an alternative license to integrate Nmap into proprietary         *
91  * applications and appliances.  These contracts have been sold to dozens  *
92  * of software vendors, and generally include a perpetual license as well  *
93  * as providing support and updates.  They also fund the continued         *
94  * development of Nmap.  Please email sales@nmap.com for further           *
95  * information.                                                            *
96  *                                                                         *
97  * If you have received a written license agreement or contract for        *
98  * Covered Software stating terms other than these, you may choose to use  *
99  * and redistribute Covered Software under those terms instead of these.   *
100  *                                                                         *
101  * Source is provided to this software because we believe users have a     *
102  * right to know exactly what a program is going to do before they run it. *
103  * This also allows you to audit the software for security holes.          *
104  *                                                                         *
105  * Source code also allows you to port Nmap to new platforms, fix bugs,    *
106  * and add new features.  You are highly encouraged to send your changes   *
107  * to the dev@nmap.org mailing list for possible incorporation into the    *
108  * main distribution.  By sending these changes to Fyodor or one of the    *
109  * Insecure.Org development mailing lists, or checking them into the Nmap  *
110  * source code repository, it is understood (unless you specify            *
111  * otherwise) that you are offering the Nmap Project the unlimited,        *
112  * non-exclusive right to reuse, modify, and relicense the code.  Nmap     *
113  * will always be available Open Source, but this is important because     *
114  * the inability to relicense code has caused devastating problems for     *
115  * other Free Software projects (such as KDE and NASM).  We also           *
116  * occasionally relicense the code to third parties as discussed above.    *
117  * If you wish to specify special license conditions of your               *
118  * contributions, just say so when you send them.                          *
119  *                                                                         *
120  * This program is distributed in the hope that it will be useful, but     *
121  * WITHOUT ANY WARRANTY; without even the implied warranty of              *
122  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the Nmap      *
123  * license file for more details (it's in a COPYING file included with     *
124  * Nmap, and also available from https://svn.nmap.org/nmap/COPYING)        *
125  *                                                                         *
126  ***************************************************************************/
127 
128 /* $Id: xml.h 15135 2009-08-19 21:05:21Z david $ */
129 
130 #ifndef _XML_H
131 #define _XML_H
132 
133 #include <stdarg.h>
134 
135 int xml_write_raw(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
136 int xml_write_escaped(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
137 int xml_write_escaped_v(const char *fmt, va_list va) __attribute__ ((format (printf, 1, 0)));
138 
139 int xml_start_document(const char *rootnode);
140 
141 int xml_start_comment();
142 int xml_end_comment();
143 
144 int xml_open_pi(const char *name);
145 int xml_close_pi();
146 
147 int xml_open_start_tag(const char *name, const bool write = true);
148 int xml_close_start_tag(const bool write = true);
149 int xml_close_empty_tag();
150 int xml_start_tag(const char *name, const bool write = true);
151 int xml_end_tag();
152 
153 int xml_attribute(const char *name, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
154 
155 int xml_newline();
156 
157 int xml_depth();
158 bool xml_tag_open();
159 bool xml_root_written();
160 
161 
162 char *xml_unescape(const char *str);
163 
164 #endif
165 
166