Re: [xml] "opening" default protocol callbacks from xmlIO.c



Ok, added the change strncmp() -> xmlStrncasecmp() in xmlIO.c
Please find diff attached.

Aleksey.

Daniel Veillard wrote:

On Tue, Apr 30, 2002 at 01:45:17PM -0400, Daniel Veillard wrote:

On Tue, Apr 30, 2002 at 10:25:12AM -0700, Aleksey Sanin wrote:

Well, you'll need to change it to strncasecmp() and it is not a default ANSI C function.


   use xmlStrcasecmp() that will do it !


 err rather xmlStrncasecmp(),

Daniel


? diff.txt
? testAutomata
? testC14N
? testRegexp
? testSchemas
? testThreads
? python/Makefile
? python/Makefile.in
? python/setup.py
? python/tests/Makefile
? python/tests/Makefile.in
Index: xmlIO.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlIO.c,v
retrieving revision 1.80
diff -c -r1.80 xmlIO.c
*** xmlIO.c     26 Mar 2002 12:44:39 -0000      1.80
--- xmlIO.c     30 Apr 2002 18:57:27 -0000
***************
*** 268,274 ****
   *
   * Returns 1 if matches, 0 otherwise
   */
! static int
  xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
      return(1);
  }
--- 268,274 ----
   *
   * Returns 1 if matches, 0 otherwise
   */
! int
  xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
      return(1);
  }
***************
*** 282,288 ****
   *
   * Returns an I/O context or NULL in case of error
   */
! static void *
  xmlFileOpen (const char *filename) {
      const char *path = NULL;
      FILE *fd;
--- 282,288 ----
   *
   * Returns an I/O context or NULL in case of error
   */
! void *
  xmlFileOpen (const char *filename) {
      const char *path = NULL;
      FILE *fd;
***************
*** 292,300 ****
        return((void *) fd);
      }
  
!     if (!strncmp(filename, "file://localhost", 16))
        path = &filename[16];
!     else if (!strncmp(filename, "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
--- 292,300 ----
        return((void *) fd);
      }
  
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
        path = &filename[16];
!     else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
***************
*** 335,343 ****
        return((void *) fd);
      }
  
!     if (!strncmp(filename, "file://localhost", 16))
        path = &filename[16];
!     else if (!strncmp(filename, "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
--- 335,343 ----
        return((void *) fd);
      }
  
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
        path = &filename[16];
!     else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
***************
*** 363,369 ****
   *
   * Returns the number of bytes written
   */
! static int
  xmlFileRead (void * context, char * buffer, int len) {
      return(fread(&buffer[0], 1,  len, (FILE *) context));
  }
--- 363,369 ----
   *
   * Returns the number of bytes written
   */
! int
  xmlFileRead (void * context, char * buffer, int len) {
      return(fread(&buffer[0], 1,  len, (FILE *) context));
  }
***************
*** 389,395 ****
   *
   * Close an I/O channel
   */
! static int
  xmlFileClose (void * context) {
      FILE *fil;
  
--- 389,395 ----
   *
   * Close an I/O channel
   */
! int
  xmlFileClose (void * context) {
      FILE *fil;
  
***************
*** 452,460 ****
        return((void *) fd);
      }
  
!     if (!strncmp(filename, "file://localhost", 16))
        path = &filename[16];
!     else if (!strncmp(filename, "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
--- 452,460 ----
        return((void *) fd);
      }
  
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
        path = &filename[16];
!     else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
***************
*** 494,502 ****
        return((void *) fd);
      }
  
!     if (!strncmp(filename, "file://localhost", 16))
        path = &filename[16];
!     else if (!strncmp(filename, "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
--- 494,502 ----
        return((void *) fd);
      }
  
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost", 16))
        path = &filename[16];
!     else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &filename[8];
  #else
***************
*** 931,939 ****
   *
   * Returns 1 if matches, 0 otherwise
   */
! static int
  xmlIOHTTPMatch (const char *filename) {
!     if (!strncmp(filename, "http://";, 7))
        return(1);
      return(0);
  }
--- 931,939 ----
   *
   * Returns 1 if matches, 0 otherwise
   */
! int
  xmlIOHTTPMatch (const char *filename) {
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "http://";, 7))
        return(1);
      return(0);
  }
***************
*** 946,952 ****
   *
   * Returns an I/O context or NULL in case of error
   */
! static void *
  xmlIOHTTPOpen (const char *filename) {
      return(xmlNanoHTTPOpen(filename, NULL));
  }
--- 946,952 ----
   *
   * Returns an I/O context or NULL in case of error
   */
! void *
  xmlIOHTTPOpen (const char *filename) {
      return(xmlNanoHTTPOpen(filename, NULL));
  }
***************
*** 1040,1046 ****
   *
   * Returns the number of bytes written
   */
! static int 
  xmlIOHTTPRead(void * context, char * buffer, int len) {
      return(xmlNanoHTTPRead(context, &buffer[0], len));
  }
--- 1040,1046 ----
   *
   * Returns the number of bytes written
   */
! int 
  xmlIOHTTPRead(void * context, char * buffer, int len) {
      return(xmlNanoHTTPRead(context, &buffer[0], len));
  }
***************
*** 1096,1102 ****
   *
   * Close an HTTP I/O channel
   */
! static int
  xmlIOHTTPClose (void * context) {
      xmlNanoHTTPClose(context);
      return 0;
--- 1096,1102 ----
   *
   * Close an HTTP I/O channel
   */
! int
  xmlIOHTTPClose (void * context) {
      xmlNanoHTTPClose(context);
      return 0;
***************
*** 1275,1283 ****
   *
   * Returns 1 if matches, 0 otherwise
   */
! static int
  xmlIOFTPMatch (const char *filename) {
!     if (!strncmp(filename, "ftp://";, 6))
        return(1);
      return(0);
  }
--- 1275,1283 ----
   *
   * Returns 1 if matches, 0 otherwise
   */
! int
  xmlIOFTPMatch (const char *filename) {
!     if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "ftp://";, 6))
        return(1);
      return(0);
  }
***************
*** 1290,1296 ****
   *
   * Returns an I/O context or NULL in case of error
   */
! static void *
  xmlIOFTPOpen (const char *filename) {
      return(xmlNanoFTPOpen(filename));
  }
--- 1290,1296 ----
   *
   * Returns an I/O context or NULL in case of error
   */
! void *
  xmlIOFTPOpen (const char *filename) {
      return(xmlNanoFTPOpen(filename));
  }
***************
*** 1305,1311 ****
   *
   * Returns the number of bytes written
   */
! static int 
  xmlIOFTPRead(void * context, char * buffer, int len) {
      return(xmlNanoFTPRead(context, &buffer[0], len));
  }
--- 1305,1311 ----
   *
   * Returns the number of bytes written
   */
! int 
  xmlIOFTPRead(void * context, char * buffer, int len) {
      return(xmlNanoFTPRead(context, &buffer[0], len));
  }
***************
*** 1316,1322 ****
   *
   * Close an FTP I/O channel
   */
! static int
  xmlIOFTPClose (void * context) {
      return ( xmlNanoFTPClose(context) );
  }
--- 1316,1322 ----
   *
   * Close an FTP I/O channel
   */
! int
  xmlIOFTPClose (void * context) {
      return ( xmlNanoFTPClose(context) );
  }
***************
*** 2442,2450 ****
      if (URL == NULL)
        return(0);
  
!     if (!strncmp(URL, "file://localhost", 16))
        path = &URL[16];
!     else if (!strncmp(URL, "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &URL[8];
  #else
--- 2442,2450 ----
      if (URL == NULL)
        return(0);
  
!     if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
        path = &URL[16];
!     else if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
        path = &URL[8];
  #else
***************
*** 2631,2639 ****
      if (URL == NULL)
          return (0);
  
!     if (!xmlStrncmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
          path = &URL[16];
!     else if (!xmlStrncmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
          path = &URL[8];
  #else
--- 2631,2639 ----
      if (URL == NULL)
          return (0);
  
!     if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file://localhost", 16))
          path = &URL[16];
!     else if (!xmlStrncasecmp(BAD_CAST URL, BAD_CAST "file:///", 8)) {
  #if defined (_WIN32) && !defined(__CYGWIN__)
          path = &URL[8];
  #else
***************
*** 2726,2735 ****
        resource = (xmlChar *) URL;
  
      if (resource != NULL) {
!         if ((!xmlStrncasecmp((const xmlChar *) resource,
!                           (const xmlChar *) "ftp://";, 6)) ||
!             (!xmlStrncasecmp((const xmlChar *) resource,
!                           (const xmlChar *) "http://";, 7))) {
            xmlGenericError(xmlGenericErrorContext,
                    "Attempt to load network entity %s \n", resource);
  
--- 2726,2733 ----
        resource = (xmlChar *) URL;
  
      if (resource != NULL) {
!         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);
  
Index: include/libxml/xmlIO.h
===================================================================
RCS file: /cvs/gnome/gnome-xml/include/libxml/xmlIO.h,v
retrieving revision 1.35
diff -c -r1.35 xmlIO.h
*** include/libxml/xmlIO.h      12 Apr 2002 21:03:34 -0000      1.35
--- include/libxml/xmlIO.h      30 Apr 2002 18:57:27 -0000
***************
*** 252,257 ****
--- 252,292 ----
                                         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
Index: win32/libxml2.def.src
===================================================================
RCS file: /cvs/gnome/gnome-xml/win32/libxml2.def.src,v
retrieving revision 1.2
diff -c -r1.2 libxml2.def.src
*** win32/libxml2.def.src       16 Apr 2002 17:47:01 -0000      1.2
--- win32/libxml2.def.src       30 Apr 2002 18:57:27 -0000
***************
*** 1081,1086 ****
--- 1081,1113 ----
        #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 
     --------------------------------------------------------------------- */
Index: win32/dsp/libxml2.def.src
===================================================================
RCS file: /cvs/gnome/gnome-xml/win32/dsp/libxml2.def.src,v
retrieving revision 1.10
diff -c -r1.10 libxml2.def.src
*** win32/dsp/libxml2.def.src   24 Mar 2002 20:56:09 -0000      1.10
--- win32/dsp/libxml2.def.src   30 Apr 2002 18:57:28 -0000
***************
*** 1062,1067 ****
--- 1062,1095 ----
        #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 
     --------------------------------------------------------------------- */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]