patch from Igor for the default catalog path on Windows Daniel

* catalog.c: patch from Igor for the default catalog path on Windows
Daniel
This commit is contained in:
Daniel Veillard 2004-06-14 12:13:12 +00:00
parent 306e33ce20
commit fb382b8990
3 changed files with 45 additions and 63 deletions

View File

@ -1,3 +1,7 @@
Mon Jun 14 14:11:52 CEST 2004 Daniel Veillard <daniel@veillard.com>
* catalog.c: patch from Igor for the default catalog path on Windows
Sat Jun 12 09:03:57 HKT 2004 William Brack <wbrack@mmm.com.hk>
* configure.in: apparently wasn't updated last time

View File

@ -68,6 +68,13 @@
#define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog"
#endif
#if defined(_WIN32) && defined(_MSC_VER)
#undef XML_XML_DEFAULT_CATALOG
static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog";
void* __stdcall GetModuleHandleA(const char*);
unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long);
#endif
static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename);
/************************************************************************
@ -2925,7 +2932,35 @@ xmlInitializeCatalog(void) {
catalogs = (const char *) getenv("XML_CATALOG_FILES");
if (catalogs == NULL)
#if defined(_WIN32) && defined(_MSC_VER)
{
void* hmodule;
hmodule = GetModuleHandleA("libxml2.dll");
if (hmodule == NULL)
hmodule = GetModuleHandleA(NULL);
if (hmodule != NULL) {
char buf[256];
unsigned long len = GetModuleFileNameA(hmodule, buf, 255);
if (len != 0) {
char* p = &(buf[len]);
while (*p != '\\' && p > buf)
p--;
if (p != buf) {
xmlChar* uri;
strncpy(p, "\\..\\etc\\catalog", 255 - (p - buf));
uri = xmlCanonicPath(buf);
if (uri != NULL) {
strncpy(XML_XML_DEFAULT_CATALOG, uri, 255);
xmlFree(uri);
}
}
}
}
catalogs = XML_XML_DEFAULT_CATALOG;
}
#else
catalogs = XML_XML_DEFAULT_CATALOG;
#endif
catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE,
xmlCatalogDefaultPrefer);
@ -3509,37 +3544,7 @@ xmlCatalogLocalResolveURI(void *catalogs, const xmlChar *URI) {
*/
const xmlChar *
xmlCatalogGetSystem(const xmlChar *sysID) {
xmlChar *ret;
static xmlChar result[1000];
static int msg = 0;
if (!xmlCatalogInitialized)
xmlInitializeCatalog();
if (msg == 0) {
xmlGenericError(xmlGenericErrorContext,
"Use of deprecated xmlCatalogGetSystem() call\n");
msg++;
}
if (sysID == NULL)
return(NULL);
/*
* Check first the XML catalogs
*/
if (xmlDefaultCatalog != NULL) {
ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, NULL, sysID);
if ((ret != NULL) && (ret != XML_CATAL_BREAK)) {
snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret);
result[sizeof(result) - 1] = 0;
return(result);
}
}
if (xmlDefaultCatalog != NULL)
return(xmlCatalogGetSGMLSystem(xmlDefaultCatalog->sgml, sysID));
return(NULL);
return xmlCatalogResolveSystem(sysID);
}
/**
@ -3553,37 +3558,7 @@ xmlCatalogGetSystem(const xmlChar *sysID) {
*/
const xmlChar *
xmlCatalogGetPublic(const xmlChar *pubID) {
xmlChar *ret;
static xmlChar result[1000];
static int msg = 0;
if (!xmlCatalogInitialized)
xmlInitializeCatalog();
if (msg == 0) {
xmlGenericError(xmlGenericErrorContext,
"Use of deprecated xmlCatalogGetPublic() call\n");
msg++;
}
if (pubID == NULL)
return(NULL);
/*
* Check first the XML catalogs
*/
if (xmlDefaultCatalog != NULL) {
ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, pubID, NULL);
if ((ret != NULL) && (ret != XML_CATAL_BREAK)) {
snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret);
result[sizeof(result) - 1] = 0;
return(result);
}
}
if (xmlDefaultCatalog != NULL)
return(xmlCatalogGetSGMLPublic(xmlDefaultCatalog->sgml, pubID));
return(NULL);
return xmlCatalogResolvePublic(pubID);
}
#endif /* LIBXML_CATALOG_ENABLED */

View File

@ -256,7 +256,7 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define if compiler has function prototypes */
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
/* Determine what socket length (socklen_t) data type is */
@ -274,6 +274,9 @@
/* Using the Win32 Socket implementation */
#undef _WINSOCKAPI_
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
/* Win32 Std C name mangling work-around */
#undef snprintf