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: unfinished XLink detection module
36  * Description: unfinished XLink detection module
37  */
38 
39 #ifndef __XML_XLINK_H__
40 #define __XML_XLINK_H__
41 
42 #include <libxml/xmlversion.h>
43 #include <libxml/tree.h>
44 
45 #ifdef LIBXML_XPTR_ENABLED
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**
52  * Various defines for the various Link properties.
53  *
54  * NOTE: the link detection layer will try to resolve QName expansion
55  *       of namespaces. If "foo" is the prefix for "http://foo.com/"
56  *       then the link detection layer will expand role="foo:myrole"
57  *       to "http://foo.com/:myrole".
58  * NOTE: the link detection layer will expand URI-Refences found on
59  *       href attributes by using the base mechanism if found.
60  */
61 typedef xmlChar *xlinkHRef;
62 typedef xmlChar *xlinkRole;
63 typedef xmlChar *xlinkTitle;
64 
65 typedef enum {
66     XLINK_TYPE_NONE = 0,
67     XLINK_TYPE_SIMPLE,
68     XLINK_TYPE_EXTENDED,
69     XLINK_TYPE_EXTENDED_SET
70 } xlinkType;
71 
72 typedef enum {
73     XLINK_SHOW_NONE = 0,
74     XLINK_SHOW_NEW,
75     XLINK_SHOW_EMBED,
76     XLINK_SHOW_REPLACE
77 } xlinkShow;
78 
79 typedef enum {
80     XLINK_ACTUATE_NONE = 0,
81     XLINK_ACTUATE_AUTO,
82     XLINK_ACTUATE_ONREQUEST
83 } xlinkActuate;
84 
85 /**
86  * xlinkNodeDetectFunc:
87  * @ctx:  user data pointer
88  * @node:  the node to check
89  *
90  * This is the prototype for the link detection routine.
91  * It calls the default link detection callbacks upon link detection.
92  */
93 typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
94 
95 /*
96  * The link detection module interact with the upper layers using
97  * a set of callback registered at parsing time.
98  */
99 
100 /**
101  * xlinkSimpleLinkFunk:
102  * @ctx:  user data pointer
103  * @node:  the node carrying the link
104  * @href:  the target of the link
105  * @role:  the role string
106  * @title:  the link title
107  *
108  * This is the prototype for a simple link detection callback.
109  */
110 typedef void
111 (*xlinkSimpleLinkFunk)	(void *ctx,
112 			 xmlNodePtr node,
113 			 const xlinkHRef href,
114 			 const xlinkRole role,
115 			 const xlinkTitle title);
116 
117 /**
118  * xlinkExtendedLinkFunk:
119  * @ctx:  user data pointer
120  * @node:  the node carrying the link
121  * @nbLocators: the number of locators detected on the link
122  * @hrefs:  pointer to the array of locator hrefs
123  * @roles:  pointer to the array of locator roles
124  * @nbArcs: the number of arcs detected on the link
125  * @from:  pointer to the array of source roles found on the arcs
126  * @to:  pointer to the array of target roles found on the arcs
127  * @show:  array of values for the show attributes found on the arcs
128  * @actuate:  array of values for the actuate attributes found on the arcs
129  * @nbTitles: the number of titles detected on the link
130  * @title:  array of titles detected on the link
131  * @langs:  array of xml:lang values for the titles
132  *
133  * This is the prototype for a extended link detection callback.
134  */
135 typedef void
136 (*xlinkExtendedLinkFunk)(void *ctx,
137 			 xmlNodePtr node,
138 			 int nbLocators,
139 			 const xlinkHRef *hrefs,
140 			 const xlinkRole *roles,
141 			 int nbArcs,
142 			 const xlinkRole *from,
143 			 const xlinkRole *to,
144 			 xlinkShow *show,
145 			 xlinkActuate *actuate,
146 			 int nbTitles,
147 			 const xlinkTitle *titles,
148 			 const xmlChar **langs);
149 
150 /**
151  * xlinkExtendedLinkSetFunk:
152  * @ctx:  user data pointer
153  * @node:  the node carrying the link
154  * @nbLocators: the number of locators detected on the link
155  * @hrefs:  pointer to the array of locator hrefs
156  * @roles:  pointer to the array of locator roles
157  * @nbTitles: the number of titles detected on the link
158  * @title:  array of titles detected on the link
159  * @langs:  array of xml:lang values for the titles
160  *
161  * This is the prototype for a extended link set detection callback.
162  */
163 typedef void
164 (*xlinkExtendedLinkSetFunk)	(void *ctx,
165 				 xmlNodePtr node,
166 				 int nbLocators,
167 				 const xlinkHRef *hrefs,
168 				 const xlinkRole *roles,
169 				 int nbTitles,
170 				 const xlinkTitle *titles,
171 				 const xmlChar **langs);
172 
173 /**
174  * This is the structure containing a set of Links detection callbacks.
175  *
176  * There is no default xlink callbacks, if one want to get link
177  * recognition activated, those call backs must be provided before parsing.
178  */
179 typedef struct _xlinkHandler xlinkHandler;
180 typedef xlinkHandler *xlinkHandlerPtr;
181 struct _xlinkHandler {
182     xlinkSimpleLinkFunk simple;
183     xlinkExtendedLinkFunk extended;
184     xlinkExtendedLinkSetFunk set;
185 };
186 
187 /*
188  * The default detection routine, can be overridden, they call the default
189  * detection callbacks.
190  */
191 
192 XMLPUBFUN xlinkNodeDetectFunc XMLCALL
193 		xlinkGetDefaultDetect	(void);
194 XMLPUBFUN void XMLCALL
195 		xlinkSetDefaultDetect	(xlinkNodeDetectFunc func);
196 
197 /*
198  * Routines to set/get the default handlers.
199  */
200 XMLPUBFUN xlinkHandlerPtr XMLCALL
201 		xlinkGetDefaultHandler	(void);
202 XMLPUBFUN void XMLCALL
203 		xlinkSetDefaultHandler	(xlinkHandlerPtr handler);
204 
205 /*
206  * Link detection module itself.
207  */
208 XMLPUBFUN xlinkType XMLCALL
209 		xlinkIsLink		(xmlDocPtr doc,
210 					 xmlNodePtr node);
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif /* LIBXML_XPTR_ENABLED */
217 
218 #endif /* __XML_XLINK_H__ */
219