Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenxlink.c
Go to the documentation of this file.
00001 /* 00002 * xlink.c : implementation of the hyperlinks detection module 00003 * This version supports both XML XLinks and HTML simple links 00004 * 00005 * See Copyright for the status of this software. 00006 * 00007 * daniel@veillard.com 00008 */ 00009 00010 00011 #define IN_LIBXML 00012 #include "libxml.h" 00013 00014 #ifdef LIBXML_XPTR_ENABLED 00015 #include <string.h> /* for memset() only */ 00016 #ifdef HAVE_CTYPE_H 00017 #include <ctype.h> 00018 #endif 00019 #ifdef HAVE_STDLIB_H 00020 #include <stdlib.h> 00021 #endif 00022 #ifdef HAVE_SYS_STAT_H 00023 #include <sys/stat.h> 00024 #endif 00025 #ifdef HAVE_FCNTL_H 00026 #include <fcntl.h> 00027 #endif 00028 #ifdef HAVE_UNISTD_H 00029 #include <unistd.h> 00030 #endif 00031 #ifdef HAVE_ZLIB_H 00032 #include <zlib.h> 00033 #endif 00034 00035 #include <libxml/xmlmemory.h> 00036 #include <libxml/tree.h> 00037 #include <libxml/parser.h> 00038 #include <libxml/valid.h> 00039 #include <libxml/xlink.h> 00040 #include <libxml/globals.h> 00041 00042 #define XLINK_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xlink/namespace/") 00043 #define XHTML_NAMESPACE (BAD_CAST "http://www.w3.org/1999/xhtml/") 00044 00045 /**************************************************************** 00046 * * 00047 * Default setting and related functions * 00048 * * 00049 ****************************************************************/ 00050 00051 static xlinkHandlerPtr xlinkDefaultHandler = NULL; 00052 static xlinkNodeDetectFunc xlinkDefaultDetect = NULL; 00053 00061 xlinkHandlerPtr 00062 xlinkGetDefaultHandler(void) { 00063 return(xlinkDefaultHandler); 00064 } 00065 00066 00073 void 00074 xlinkSetDefaultHandler(xlinkHandlerPtr handler) { 00075 xlinkDefaultHandler = handler; 00076 } 00077 00085 xlinkNodeDetectFunc 00086 xlinkGetDefaultDetect (void) { 00087 return(xlinkDefaultDetect); 00088 } 00089 00096 void 00097 xlinkSetDefaultDetect (xlinkNodeDetectFunc func) { 00098 xlinkDefaultDetect = func; 00099 } 00100 00101 /**************************************************************** 00102 * * 00103 * The detection routines * 00104 * * 00105 ****************************************************************/ 00106 00107 00122 xlinkType 00123 xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) { 00124 xmlChar *type = NULL, *role = NULL; 00125 xlinkType ret = XLINK_TYPE_NONE; 00126 00127 if (node == NULL) return(XLINK_TYPE_NONE); 00128 if (doc == NULL) doc = node->doc; 00129 if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { 00130 /* 00131 * This is an HTML document. 00132 */ 00133 } else if ((node->ns != NULL) && 00134 (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) { 00135 /* 00136 * !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@ 00137 */ 00138 /* 00139 * This is an XHTML element within an XML document 00140 * Check whether it's one of the element able to carry links 00141 * and in that case if it holds the attributes. 00142 */ 00143 } 00144 00145 /* 00146 * We don't prevent a-priori having XML Linking constructs on 00147 * XHTML elements 00148 */ 00149 type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE); 00150 if (type != NULL) { 00151 if (xmlStrEqual(type, BAD_CAST "simple")) { 00152 ret = XLINK_TYPE_SIMPLE; 00153 } if (xmlStrEqual(type, BAD_CAST "extended")) { 00154 role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE); 00155 if (role != NULL) { 00156 xmlNsPtr xlink; 00157 xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE); 00158 if (xlink == NULL) { 00159 /* Humm, fallback method */ 00160 if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) 00161 ret = XLINK_TYPE_EXTENDED_SET; 00162 } else { 00163 xmlChar buf[200]; 00164 snprintf((char *) buf, sizeof(buf), "%s:external-linkset", 00165 (char *) xlink->prefix); 00166 buf[sizeof(buf) - 1] = 0; 00167 if (xmlStrEqual(role, buf)) 00168 ret = XLINK_TYPE_EXTENDED_SET; 00169 00170 } 00171 00172 } 00173 ret = XLINK_TYPE_EXTENDED; 00174 } 00175 } 00176 00177 if (type != NULL) xmlFree(type); 00178 if (role != NULL) xmlFree(role); 00179 return(ret); 00180 } 00181 #endif /* LIBXML_XPTR_ENABLED */ 00182 #define bottom_xlink 00183 #include "elfgcchack.h" Generated on Sat May 26 2012 04:33:35 for ReactOS by
1.7.6.1
|