exported default 'file:', 'http:' and 'ftp:' protocols input handlers and

* include/libxml/xmlIO.h win32/dsp/libxml2.def.src
win32/libxml2.def.src xmlIO.c: exported default
'file:', 'http:' and 'ftp:' protocols input handlers
and maked protocols comparisson case insensitive
This commit is contained in:
Aleksey Sanin 2002-05-01 18:32:28 +00:00
parent 34de97f149
commit 5aac8b85dd
4 changed files with 97 additions and 30 deletions

View File

@ -1,3 +1,10 @@
Wed 01 May 2002 11:29:27 AM PDT Aleksey Sanin <aleksey@aleksey.com>
* include/libxml/xmlIO.h win32/dsp/libxml2.def.src
win32/libxml2.def.src xmlIO.c: exported default
'file:', 'http:' and 'ftp:' protocols input handlers
and maked protocols comparisson case insensitive
Tue Apr 30 16:29:05 CEST 2002 Daniel Veillard <daniel@veillard.com>
* configure.in: Neven Has detected a typo

View File

@ -252,6 +252,41 @@ xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL,
const char *ID,
xmlParserCtxtPtr ctxt);
/**
* Default 'file://' protocol callbacks
*/
int xmlFileMatch (const char *filename);
void * xmlFileOpen (const char *filename);
int xmlFileRead (void * context,
char * buffer,
int len);
int xmlFileClose (void * context);
/**
* Default 'http://' protocol callbacks
*/
#ifdef LIBXML_HTTP_ENABLED
int xmlIOHTTPMatch (const char *filename);
void * xmlIOHTTPOpen (const char *filename);
int xmlIOHTTPRead (void * context,
char * buffer,
int len);
int xmlIOHTTPClose (void * context);
#endif /* LIBXML_HTTP_ENABLED */
/**
* Default 'ftp://' protocol callbacks
*/
#ifdef LIBXML_FTP_ENABLED
int xmlIOFTPMatch (const char *filename);
void * xmlIOFTPOpen (const char *filename);
int xmlIOFTPRead (void * context,
char * buffer,
int len);
int xmlIOFTPClose (void * context);
#endif /* LIBXML_FTP_ENABLED */
#ifdef __cplusplus
}
#endif

View File

@ -1081,6 +1081,33 @@ xmlCleanupPredefinedEntities
#endif /* LIBXML_HTTP_ENABLED */
xmlNoNetExternalEntityLoader
/**
* Default 'file://' protocol callbacks
*/
xmlFileMatch
xmlFileOpen
xmlFileRead
xmlFileClose
/**
* Default 'http://' protocol callbacks
*/
#ifdef LIBXML_HTTP_ENABLED
xmlIOHTTPMatch
xmlIOHTTPOpen
xmlIOHTTPRead
xmlIOHTTPClose
#endif /* LIBXML_HTTP_ENABLED */
/**
* Default 'ftp://' protocol callbacks
*/
#ifdef LIBXML_FTP_ENABLED
xmlIOFTPMatch
xmlIOFTPOpen
xmlIOFTPRead
xmlIOFTPClose
#endif /* LIBXML_FTP_ENABLED */
/* xmlmemory.h
--------------------------------------------------------------------- */

58
xmlIO.c
View File

@ -268,7 +268,7 @@ xmlFdClose (void * context) {
*
* Returns 1 if matches, 0 otherwise
*/
static int
int
xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
return(1);
}
@ -282,7 +282,7 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
*
* Returns an I/O context or NULL in case of error
*/
static void *
void *
xmlFileOpen (const char *filename) {
const char *path = NULL;
FILE *fd;
@ -292,9 +292,9 @@ xmlFileOpen (const char *filename) {
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &filename[8];
#else
@ -335,9 +335,9 @@ xmlFileOpenW (const char *filename) {
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &filename[8];
#else
@ -363,7 +363,7 @@ xmlFileOpenW (const char *filename) {
*
* Returns the number of bytes written
*/
static int
int
xmlFileRead (void * context, char * buffer, int len) {
return(fread(&buffer[0], 1, len, (FILE *) context));
}
@ -389,7 +389,7 @@ xmlFileWrite (void * context, const char * buffer, int len) {
*
* Close an I/O channel
*/
static int
int
xmlFileClose (void * context) {
FILE *fil;
@ -452,9 +452,9 @@ xmlGzfileOpen (const char *filename) {
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &filename[8];
#else
@ -494,9 +494,9 @@ xmlGzfileOpenW (const char *filename, int compression) {
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &filename[8];
#else
@ -931,9 +931,9 @@ xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
*
* Returns 1 if matches, 0 otherwise
*/
static int
int
xmlIOHTTPMatch (const char *filename) {
if (!strncmp(filename, "http://", 7))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "http://", 7))
return(1);
return(0);
}
@ -946,7 +946,7 @@ xmlIOHTTPMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
static void *
void *
xmlIOHTTPOpen (const char *filename) {
return(xmlNanoHTTPOpen(filename, NULL));
}
@ -1040,7 +1040,7 @@ xmlIOHTTPDfltOpenW( const char * post_uri ) {
*
* Returns the number of bytes written
*/
static int
int
xmlIOHTTPRead(void * context, char * buffer, int len) {
return(xmlNanoHTTPRead(context, &buffer[0], len));
}
@ -1096,7 +1096,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
*
* Close an HTTP I/O channel
*/
static int
int
xmlIOHTTPClose (void * context) {
xmlNanoHTTPClose(context);
return 0;
@ -1275,9 +1275,9 @@ xmlIOHTTPClosePost( void * ctxt ) {
*
* Returns 1 if matches, 0 otherwise
*/
static int
int
xmlIOFTPMatch (const char *filename) {
if (!strncmp(filename, "ftp://", 6))
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "ftp://", 6))
return(1);
return(0);
}
@ -1290,7 +1290,7 @@ xmlIOFTPMatch (const char *filename) {
*
* Returns an I/O context or NULL in case of error
*/
static void *
void *
xmlIOFTPOpen (const char *filename) {
return(xmlNanoFTPOpen(filename));
}
@ -1305,7 +1305,7 @@ xmlIOFTPOpen (const char *filename) {
*
* Returns the number of bytes written
*/
static int
int
xmlIOFTPRead(void * context, char * buffer, int len) {
return(xmlNanoFTPRead(context, &buffer[0], len));
}
@ -1316,7 +1316,7 @@ xmlIOFTPRead(void * context, char * buffer, int len) {
*
* Close an FTP I/O channel
*/
static int
int
xmlIOFTPClose (void * context) {
return ( xmlNanoFTPClose(context) );
}
@ -2442,9 +2442,9 @@ static int xmlSysIDExists(const char *URL) {
if (URL == NULL)
return(0);
if (!strncmp(URL, "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
path = &URL[16];
else if (!strncmp(URL, "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &URL[8];
#else
@ -2631,9 +2631,9 @@ xmlNoNetExists(const char *URL)
if (URL == NULL)
return (0);
if (!xmlStrncmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
path = &URL[16];
else if (!xmlStrncmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
else if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) && !defined(__CYGWIN__)
path = &URL[8];
#else
@ -2726,10 +2726,8 @@ xmlNoNetExternalEntityLoader(const char *URL, const char *ID,
resource = (xmlChar *) URL;
if (resource != NULL) {
if ((!xmlStrncasecmp((const xmlChar *) resource,
(const xmlChar *) "ftp://", 6)) ||
(!xmlStrncasecmp((const xmlChar *) resource,
(const xmlChar *) "http://", 7))) {
if ((!xmlStrncasecmp(BAD_CAST resource, BAD_CAST "ftp://", 6)) ||
(!xmlStrncasecmp(BAD_CAST resource, BAD_CAST "http://", 7))) {
xmlGenericError(xmlGenericErrorContext,
"Attempt to load network entity %s \n", resource);