version 1.22, 2000/04/07 13:17:40
|
version 1.23, 2000/04/07 16:32:11
|
Line 61 typedef struct _xmlInputCallback {
|
Line 61 typedef struct _xmlInputCallback {
|
xmlInputCloseCallback closecallback; |
xmlInputCloseCallback closecallback; |
} xmlInputCallback; |
} xmlInputCallback; |
|
|
extern xmlInputCallback fileInputCallback; |
#define MAX_INPUT_CALLBACK 15 |
extern xmlInputCallback fdInputCallback; |
|
|
|
extern xmlInputCallback *xmlInputCallbackTable; |
xmlInputCallback xmlInputCallbackTable[MAX_INPUT_CALLBACK]; |
|
int xmlInputCallbackNr = 0; |
|
int xmlInputCallbackInitialized = 0; |
|
|
|
/************************************************************************ |
|
* * |
|
* Standard I/O for file accesses * |
|
* * |
|
************************************************************************/ |
|
|
/** |
/** |
* fdMatch: |
* xmlFdMatch: |
* @filename: the URI for matching |
* @filename: the URI for matching |
* |
* |
* input from file descriptor |
* input from file descriptor |
* |
* |
* Returns 1 if matches, 0 otherwise |
* Returns 1 if matches, 0 otherwise |
*/ |
*/ |
static int fdMatch (const char *filename) { |
int |
|
xmlFdMatch (const char *filename) { |
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlFdOpen: |
|
* @filename: the URI for matching |
|
* |
|
* input from file descriptor, supports compressed input |
|
* if @filename is " " then the standard input is used |
|
* |
|
* Returns an I/O context or NULL in case of error |
|
*/ |
|
void * |
|
xmlFdOpen (const char *filename) { |
|
const char *path = NULL; |
|
int fd; |
|
|
|
if (!strcmp(filename, "-")) { |
|
fd = 0; |
|
return((void *) fd); |
|
} |
|
|
if (!strncmp(filename, "file://localhost", 16)) |
if (!strncmp(filename, "file://localhost", 16)) |
return(1); |
path = &filename[16]; |
if (!strncmp(filename, "file:///", 8)) |
else if (!strncmp(filename, "file:///", 8)) |
return(1); |
path = &filename[8]; |
if (filename[0] = '/') |
else if (filename[0] == '/') |
return(1); |
path = filename; |
return(0); |
if (path == NULL) |
|
return(NULL); |
|
|
|
#ifdef WIN32 |
|
fd = _open (filename, O_RDONLY | _O_BINARY); |
|
#else |
|
fd = open (filename, O_RDONLY); |
|
#endif |
|
|
|
return((void *) fd); |
} |
} |
|
|
/** |
/** |
* fdOpen: |
* xmlFdRead: |
|
* @context: the I/O context |
|
* @buffer: where to drop data |
|
* @len: number of bytes to write |
|
* |
|
* Read @len bytes to @buffer from the I/O channel. |
|
* |
|
* Returns the number of bytes written |
|
*/ |
|
int |
|
xmlFdRead (void * context, char * buffer, int len) { |
|
return(read((int) context, &buffer[0], len)); |
|
} |
|
|
|
/** |
|
* xmlFdClose: |
|
* @context: the I/O context |
|
* |
|
* Close an I/O channel |
|
*/ |
|
void |
|
xmlFdClose (void * context) { |
|
close((int) context); |
|
} |
|
|
|
/** |
|
* xmlFileMatch: |
* @filename: the URI for matching |
* @filename: the URI for matching |
* |
* |
* input from file descriptor |
* input from FILE * |
* |
* |
* Returns 1 if matches, 0 otherwise |
* Returns 1 if matches, 0 otherwise |
*/ |
*/ |
static void * fdOpen (const char *filename) { |
int |
int fd = -1; |
xmlFileMatch (const char *filename) { |
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlFileOpen: |
|
* @filename: the URI for matching |
|
* |
|
* input from FILE *, supports compressed input |
|
* if @filename is " " then the standard input is used |
|
* |
|
* Returns an I/O context or NULL in case of error |
|
*/ |
|
void * |
|
xmlFileOpen (const char *filename) { |
const char *path = NULL; |
const char *path = NULL; |
|
FILE *fd; |
|
|
|
if (!strcmp(filename, "-")) { |
|
fd = stdin; |
|
return((void *) fd); |
|
} |
|
|
if (!strncmp(filename, "file://localhost", 16)) |
if (!strncmp(filename, "file://localhost", 16)) |
path = &filename[16]; |
path = &filename[16]; |
else if (!strncmp(filename, "file:///", 8)) |
else if (!strncmp(filename, "file:///", 8)) |
path = &filename[16]; |
path = &filename[8]; |
else if (filename[0] = '/') |
else |
path = filename; |
path = filename; |
if (path == NULL) |
if (path == NULL) |
return(NULL |
return(NULL); |
|
|
#ifdef WIN32 |
#ifdef WIN32 |
fd = _open (path, O_RDONLY | _O_BINARY); |
fd = fopen(path, "rb"); |
#else |
#else |
fd = open (path, O_RDONLY); |
fd = fopen(path, "r"); |
#endif |
#endif /* WIN32 */ |
return (void *) fd; |
return((void *) fd); |
} |
} |
|
|
int fdRead (void * context, char * buffer, int len) { |
/** |
int fd = (int) context; |
* xmlFileRead: |
return read (fd, &buffer[0], len); |
* @context: the I/O context |
|
* @buffer: where to drop data |
|
* @len: number of bytes to write |
|
* |
|
* Read @len bytes to @buffer from the I/O channel. |
|
* |
|
* Returns the number of bytes written |
|
*/ |
|
int |
|
xmlFileRead (void * context, char * buffer, int len) { |
|
return(fread(&buffer[0], 1, len, (FILE *) context)); |
} |
} |
void fdClose (void * context) { |
|
int fd = (int) context; |
/** |
close (fd); |
* xmlFileClose: |
|
* @context: the I/O context |
|
* |
|
* Close an I/O channel |
|
*/ |
|
void |
|
xmlFileClose (void * context) { |
|
fclose((FILE *) context); |
|
} |
|
|
|
#ifdef HAVE_ZLIB_H |
|
/************************************************************************ |
|
* * |
|
* I/O for compressed file accesses * |
|
* * |
|
************************************************************************/ |
|
/** |
|
* xmlGzfileMatch: |
|
* @filename: the URI for matching |
|
* |
|
* input from compressed file test |
|
* |
|
* Returns 1 if matches, 0 otherwise |
|
*/ |
|
int |
|
xmlGzfileMatch (const char *filename) { |
|
return(1); |
|
} |
|
|
|
/** |
|
* xmlGzfileOpen: |
|
* @filename: the URI for matching |
|
* |
|
* input from compressed file open |
|
* if @filename is " " then the standard input is used |
|
* |
|
* Returns an I/O context or NULL in case of error |
|
*/ |
|
void * |
|
xmlGzfileOpen (const char *filename) { |
|
const char *path = NULL; |
|
gzFile fd; |
|
|
|
if (!strcmp(filename, "-")) { |
|
fd = gzdopen (fileno(stdin), "r"); |
|
return((void *) fd); |
|
} |
|
|
|
if (!strncmp(filename, "file://localhost", 16)) |
|
path = &filename[16]; |
|
else if (!strncmp(filename, "file:///", 8)) |
|
path = &filename[8]; |
|
else |
|
path = filename; |
|
|
|
fd = gzopen(filename, "r"); |
|
return((void *) fd); |
} |
} |
xmlInputCallback fdInputCallback = {fdMatch, fdOpen, fdRead, fdClose}; |
|
|
|
/* input from file descriptor */ |
/** |
int fileMatch (const char *filename) { |
* xmlGzfileRead: |
return strstr (filename, ":") == 0; |
* @context: the I/O context |
|
* @buffer: where to drop data |
|
* @len: number of bytes to write |
|
* |
|
* Read @len bytes to @buffer from the compressed I/O channel. |
|
* |
|
* Returns the number of bytes written |
|
*/ |
|
int |
|
xmlGzfileRead (void * context, char * buffer, int len) { |
|
return(gzread((gzFile) context, &buffer[0], len)); |
} |
} |
void * fileOpen (const char *filename) { |
|
FILE *file = fopen (filename, "r"); |
/** |
return file; |
* xmlGzfileClose: |
|
* @context: the I/O context |
|
* |
|
* Close a compressed I/O channel |
|
*/ |
|
void |
|
xmlGzfileClose (void * context) { |
|
gzclose((gzFile) context); |
} |
} |
int fileRead (void * context, char * buffer, int len) { |
#endif /* HAVE_ZLIB_H */ |
FILE *file = context; |
|
return fread(&buffer[0], 1, len, file); |
#ifdef LIBXML_HTTP_ENABLED |
|
/************************************************************************ |
|
* * |
|
* I/O for HTTP file accesses * |
|
* * |
|
************************************************************************/ |
|
/** |
|
* xmlIOHTTPMatch: |
|
* @filename: the URI for matching |
|
* |
|
* check if the URI matches an HTTP one |
|
* |
|
* Returns 1 if matches, 0 otherwise |
|
*/ |
|
int |
|
xmlIOHTTPMatch (const char *filename) { |
|
if (!strncmp(filename, "http://", 7)) |
|
return(1); |
|
return(0); |
} |
} |
void fileClose (void * context) { |
|
FILE *file = context; |
/** |
fclose (file); |
* xmlIOHTTPOpen: |
|
* @filename: the URI for matching |
|
* |
|
* open an HTTP I/O channel |
|
* |
|
* Returns an I/O context or NULL in case of error |
|
*/ |
|
void * |
|
xmlIOHTTPOpen (const char *filename) { |
|
return(xmlNanoHTTPOpen(filename, NULL)); |
} |
} |
xmlInputCallback fileInputCallback = {fileMatch, fileOpen, fdRead, fileClose}; |
|
|
|
/* default input method table */ |
/** |
xmlInputCallback defaultInputCallbackTable [] = { |
* xmlIOHTTPRead: |
{fdMatch, fdOpen, fdRead, fdClose}, |
* @context: the I/O context |
{fileMatch, fileOpen, fdRead, fileClose}, |
* @buffer: where to drop data |
{0, 0, 0, 0} |
* @len: number of bytes to write |
}; |
* |
xmlInputCallback *xmlInputCallbackTable = defaultInputCallbackTable; |
* Read @len bytes to @buffer from the I/O channel. |
|
* |
|
* Returns the number of bytes written |
|
*/ |
|
int |
|
xmlIOHTTPRead(void * context, char * buffer, int len) { |
|
return(xmlNanoHTTPRead(context, &buffer[0], len)); |
|
} |
|
|
|
/** |
|
* xmlIOHTTPClose: |
|
* @context: the I/O context |
|
* |
|
* Close an HTTP I/O channel |
|
*/ |
|
void |
|
xmlIOHTTPClose (void * context) { |
|
xmlNanoHTTPClose(context); |
|
} |
|
#endif /* LIBXML_HTTP_ENABLED */ |
|
|
|
#ifdef LIBXML_FTP_ENABLED |
|
/************************************************************************ |
|
* * |
|
* I/O for FTP file accesses * |
|
* * |
|
************************************************************************/ |
|
/** |
|
* xmlIOFTPMatch: |
|
* @filename: the URI for matching |
|
* |
|
* check if the URI matches an FTP one |
|
* |
|
* Returns 1 if matches, 0 otherwise |
|
*/ |
|
int |
|
xmlIOFTPMatch (const char *filename) { |
|
if (!strncmp(filename, "ftp://", 6)) |
|
return(1); |
|
return(0); |
|
} |
|
|
|
/** |
|
* xmlIOFTPOpen: |
|
* @filename: the URI for matching |
|
* |
|
* open an FTP I/O channel |
|
* |
|
* Returns an I/O context or NULL in case of error |
|
*/ |
|
void * |
|
xmlIOFTPOpen (const char *filename) { |
|
return(xmlNanoFTPOpen(filename)); |
|
} |
|
|
|
/** |
|
* xmlIOFTPRead: |
|
* @context: the I/O context |
|
* @buffer: where to drop data |
|
* @len: number of bytes to write |
|
* |
|
* Read @len bytes to @buffer from the I/O channel. |
|
* |
|
* Returns the number of bytes written |
|
*/ |
|
int |
|
xmlIOFTPRead(void * context, char * buffer, int len) { |
|
return(xmlNanoFTPRead(context, &buffer[0], len)); |
|
} |
|
|
|
/** |
|
* xmlIOFTPClose: |
|
* @context: the I/O context |
|
* |
|
* Close an FTP I/O channel |
|
*/ |
|
void |
|
xmlIOFTPClose (void * context) { |
|
xmlNanoFTPClose(context); |
|
} |
|
#endif /* LIBXML_FTP_ENABLED */ |
|
|
|
|
|
/** |
|
* xmlRegisterInputCallbacks: |
|
* @match: the xmlInputMatchCallback |
|
* @open: the xmlInputOpenCallback |
|
* @read: the xmlInputReadCallback |
|
* @close: the xmlInputCloseCallback |
|
* |
|
* Register a new set of I/O callback for handling parser input. |
|
* |
|
* Returns the registered handler number or -1 in case of error |
|
*/ |
|
int |
|
xmlRegisterInputCallbacks(xmlInputMatchCallback match, |
|
xmlInputOpenCallback open, xmlInputReadCallback read, |
|
xmlInputCloseCallback close) { |
|
if (xmlInputCallbackNr >= MAX_INPUT_CALLBACK) { |
|
return(-1); |
|
} |
|
xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = match; |
|
xmlInputCallbackTable[xmlInputCallbackNr].opencallback = open; |
|
xmlInputCallbackTable[xmlInputCallbackNr].readcallback = read; |
|
xmlInputCallbackTable[xmlInputCallbackNr].closecallback = close; |
|
return(xmlInputCallbackNr++); |
|
} |
|
|
|
/** |
|
* xmlRegisterDefaultInputCallbacks: |
|
* |
|
* Registers the default compiled-in I/O handlers. |
|
*/ |
|
void |
|
xmlRegisterDefaultInputCallbacks(void) { |
|
xmlRegisterInputCallbacks(xmlFileMatch, xmlFileOpen, |
|
xmlFileRead, xmlFileClose); |
|
#ifdef HAVE_ZLIB_H |
|
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen, |
|
xmlGzfileRead, xmlGzfileClose); |
|
#endif /* HAVE_ZLIB_H */ |
|
|
|
#ifdef LIBXML_HTTP_ENABLED |
|
xmlRegisterInputCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen, |
|
xmlIOHTTPRead, xmlIOHTTPClose); |
|
#endif /* LIBXML_HTTP_ENABLED */ |
|
|
|
#ifdef LIBXML_FTP_ENABLED |
|
xmlRegisterInputCallbacks(xmlIOFTPMatch, xmlIOFTPOpen, |
|
xmlIOFTPRead, xmlIOFTPClose); |
|
#endif /* LIBXML_FTP_ENABLED */ |
|
} |
|
|
/** |
/** |
* xmlAllocParserInputBuffer: |
* xmlAllocParserInputBuffer: |
Line 172 xmlAllocParserInputBuffer(xmlCharEncodin
|
Line 498 xmlAllocParserInputBuffer(xmlCharEncodin
|
} |
} |
ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT; |
ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT; |
ret->encoder = xmlGetCharEncodingHandler(enc); |
ret->encoder = xmlGetCharEncodingHandler(enc); |
ret->fd = -1; |
ret->readcallback = NULL; |
ret->httpIO = NULL; |
ret->closecallback = NULL; |
ret->ftpIO = NULL; |
ret->context = NULL; |
|
|
return(ret); |
return(ret); |
} |
} |
Line 191 xmlFreeParserInputBuffer(xmlParserInputB
|
Line 517 xmlFreeParserInputBuffer(xmlParserInputB
|
xmlBufferFree(in->buffer); |
xmlBufferFree(in->buffer); |
in->buffer = NULL; |
in->buffer = NULL; |
} |
} |
#ifdef HAVE_ZLIB_H |
if (in->closecallback != NULL) { |
if (in->gzfile != NULL) |
in->closecallback(in->context); |
gzclose(in->gzfile); |
} |
#endif |
|
#ifdef LIBXML_HTTP_ENABLED |
|
if (in->httpIO != NULL) |
|
xmlNanoHTTPClose(in->httpIO); |
|
#endif |
|
#ifdef LIBXML_FTP_ENABLED |
|
if (in->ftpIO != NULL) |
|
xmlNanoFTPClose(in->ftpIO); |
|
#endif |
|
if (in->fd >= 0) |
|
close(in->fd); |
|
memset(in, 0xbe, (size_t) sizeof(xmlParserInputBuffer)); |
memset(in, 0xbe, (size_t) sizeof(xmlParserInputBuffer)); |
xmlFree(in); |
xmlFree(in); |
} |
} |
|
|
/** |
/** |
* xmlParserInputBufferCreateFilename: |
* xmlParserInputBufferCreateFilename: |
* @filename: a C string containing the filename |
* @URI: a C string containing the URI or filename |
* @enc: the charset encoding if known |
* @enc: the charset encoding if known |
* |
* |
* Create a buffered parser input for the progressive parsing of a file |
* Create a buffered parser input for the progressive parsing of a file |
Line 223 xmlFreeParserInputBuffer(xmlParserInputB
|
Line 539 xmlFreeParserInputBuffer(xmlParserInputB
|
* Returns the new parser input or NULL |
* Returns the new parser input or NULL |
*/ |
*/ |
xmlParserInputBufferPtr |
xmlParserInputBufferPtr |
xmlParserInputBufferCreateFilename(const char *filename, xmlCharEncoding enc) { |
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { |
xmlParserInputBufferPtr ret; |
xmlParserInputBufferPtr ret; |
#ifdef HAVE_ZLIB_H |
int i; |
gzFile input = 0; |
void *context = NULL; |
#else |
|
int input = -1; |
|
#endif |
|
void *httpIO = NULL; |
|
void *ftpIO = NULL; |
|
|
|
if (filename == NULL) return(NULL); |
if (xmlInputCallbackInitialized == 0) |
|
xmlRegisterDefaultInputCallbacks(); |
|
|
#ifdef LIBXML_HTTP_ENABLED |
if (URI == NULL) return(NULL); |
if (!strncmp(filename, "http://", 7)) { |
|
httpIO = xmlNanoHTTPOpen(filename, NULL); |
/* |
if (httpIO == NULL) { |
* Try to find one of the input accept method accepting taht scheme |
#ifdef VERBOSE_FAILURE |
* Go in reverse to give precedence to user defined handlers. |
fprintf (stderr, "Cannot read URL %s\n", filename); |
*/ |
perror ("xmlNanoHTTPOpen failed"); |
for (i = xmlInputCallbackNr - 1;i >= 0;i--) { |
#endif |
if ((xmlInputCallbackTable[i].matchcallback != NULL) && |
return(NULL); |
(xmlInputCallbackTable[i].matchcallback(URI) != 0)) { |
} |
context = xmlInputCallbackTable[i].opencallback(URI); |
} else |
if (context != NULL) |
#endif /* LIBXML_HTTP_ENABLED */ |
break; |
#ifdef LIBXML_FTP_ENABLED |
|
if (!strncmp(filename, "ftp://", 6)) { |
|
ftpIO = xmlNanoFTPOpen(filename); |
|
if (ftpIO == NULL) { |
|
#ifdef VERBOSE_FAILURE |
|
fprintf (stderr, "Cannot read URL %s\n", filename); |
|
perror ("xmlNanoFTPOpen failed"); |
|
#endif |
|
return(NULL); |
|
} |
|
} else |
|
#endif /* LIBXML_FTP_ENABLED */ |
|
if (!strcmp(filename, "-")) { |
|
#ifdef HAVE_ZLIB_H |
|
input = gzdopen (fileno(stdin), "r"); |
|
if (input == NULL) { |
|
#ifdef VERBOSE_FAILURE |
|
fprintf (stderr, "Cannot read from stdin\n"); |
|
perror ("gzdopen failed"); |
|
#endif |
|
return(NULL); |
|
} |
|
#else |
|
#ifdef WIN32 |
|
input = -1; |
|
#else |
|
input = fileno(stdin); |
|
#endif |
|
if (input < 0) { |
|
#ifdef VERBOSE_FAILURE |
|
fprintf (stderr, "Cannot read from stdin\n"); |
|
perror ("open failed"); |
|
#endif |
|
return(NULL); |
|
} |
|
#endif |
|
} else { |
|
#ifdef HAVE_ZLIB_H |
|
input = gzopen (filename, "r"); |
|
if (input == NULL) { |
|
#ifdef VERBOSE_FAILURE |
|
fprintf (stderr, "Cannot read file %s :\n", filename); |
|
perror ("gzopen failed"); |
|
#endif |
|
return(NULL); |
|
} |
|
#else |
|
#ifdef WIN32 |
|
input = _open (filename, O_RDONLY | _O_BINARY); |
|
#else |
|
input = open (filename, O_RDONLY); |
|
#endif |
|
if (input < 0) { |
|
#ifdef VERBOSE_FAILURE |
|
fprintf (stderr, "Cannot read file %s :\n", filename); |
|
perror ("open failed"); |
|
#endif |
|
return(NULL); |
|
} |
} |
|
} |
|
if (context == NULL) { |
|
#ifdef DEBUG_INPUT |
|
fprintf(stderr, "No input filter matching \"%s\"\n", URI); |
#endif |
#endif |
|
return(NULL); |
} |
} |
|
|
/* |
/* |
Line 314 xmlParserInputBufferCreateFilename(const
|
Line 573 xmlParserInputBufferCreateFilename(const
|
*/ |
*/ |
ret = xmlAllocParserInputBuffer(enc); |
ret = xmlAllocParserInputBuffer(enc); |
if (ret != NULL) { |
if (ret != NULL) { |
#ifdef HAVE_ZLIB_H |
ret->context = context; |
ret->gzfile = input; |
ret->readcallback = xmlInputCallbackTable[i].readcallback; |
#else |
ret->closecallback = xmlInputCallbackTable[i].closecallback; |
ret->fd = input; |
|
#endif |
|
ret->httpIO = httpIO; |
|
ret->ftpIO = ftpIO; |
|
} |
} |
|
|
return(ret); |
return(ret); |
} |
} |
|
|
Line 340 xmlParserInputBufferPtr
|
Line 594 xmlParserInputBufferPtr
|
xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc) { |
xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc) { |
xmlParserInputBufferPtr ret; |
xmlParserInputBufferPtr ret; |
|
|
|
if (xmlInputCallbackInitialized == 0) |
|
xmlRegisterDefaultInputCallbacks(); |
|
|
if (file == NULL) return(NULL); |
if (file == NULL) return(NULL); |
|
|
ret = xmlAllocParserInputBuffer(enc); |
ret = xmlAllocParserInputBuffer(enc); |
if (ret != NULL) |
if (ret != NULL) { |
ret->file = file; |
ret->context = file; |
|
ret->readcallback = xmlFileRead; |
|
ret->closecallback = xmlFileClose; |
|
} |
|
|
return(ret); |
return(ret); |
} |
} |
Line 366 xmlParserInputBufferCreateFd(int fd, xml
|
Line 626 xmlParserInputBufferCreateFd(int fd, xml
|
if (fd < 0) return(NULL); |
if (fd < 0) return(NULL); |
|
|
ret = xmlAllocParserInputBuffer(enc); |
ret = xmlAllocParserInputBuffer(enc); |
if (ret != NULL) |
if (ret != NULL) { |
ret->fd = fd; |
ret->context = (void *) fd; |
|
ret->readcallback = xmlFdRead; |
|
ret->closecallback = xmlFdClose; |
|
} |
|
|
return(ret); |
return(ret); |
} |
} |
Line 446 xmlParserInputBufferPush(xmlParserInputB
|
Line 709 xmlParserInputBufferPush(xmlParserInputB
|
int |
int |
xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { |
xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { |
char *buffer = NULL; |
char *buffer = NULL; |
#ifdef HAVE_ZLIB_H |
|
gzFile input = (gzFile) in->gzfile; |
|
#endif |
|
int res = 0; |
int res = 0; |
int nbchars = 0; |
int nbchars = 0; |
int buffree; |
int buffree; |
Line 468 xmlParserInputBufferGrow(xmlParserInputB
|
Line 728 xmlParserInputBufferGrow(xmlParserInputB
|
fprintf(stderr, "xmlParserInputBufferGrow : out of memory !\n"); |
fprintf(stderr, "xmlParserInputBufferGrow : out of memory !\n"); |
return(-1); |
return(-1); |
} |
} |
#ifdef LIBXML_HTTP_ENABLED |
|
if (in->httpIO != NULL) { |
/* |
res = xmlNanoHTTPRead(in->httpIO, &buffer[0], len); |
* Call the read method for this I/O type. |
} else |
*/ |
#endif |
if (in->readcallback != NULL) { |
#ifdef LIBXML_FTP_ENABLED |
res = in->readcallback(in->context, &buffer[0], len); |
if (in->ftpIO != NULL) { |
|
res = xmlNanoFTPRead(in->ftpIO, &buffer[0], len); |
|
} else |
|
#endif |
|
if (in->file != NULL) { |
|
res = fread(&buffer[0], 1, len, in->file); |
|
#ifdef HAVE_ZLIB_H |
|
} else if (in->gzfile != NULL) { |
|
res = gzread(input, &buffer[0], len); |
|
#endif |
|
} else if (in->fd >= 0) { |
|
res = read(in->fd, &buffer[0], len); |
|
} else { |
} else { |
fprintf(stderr, "xmlParserInputBufferGrow : no input !\n"); |
fprintf(stderr, "xmlParserInputBufferGrow : no input !\n"); |
xmlFree(buffer); |
xmlFree(buffer); |
return(-1); |
return(-1); |
} |
} |
|
|
if (res == 0) { |
if (res == 0) { |
xmlFree(buffer); |
xmlFree(buffer); |
return(0); |
return(0); |
Line 557 xmlParserInputBufferGrow(xmlParserInputB
|
Line 806 xmlParserInputBufferGrow(xmlParserInputB
|
int |
int |
xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) { |
xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) { |
/* xmlBufferEmpty(in->buffer); */ |
/* xmlBufferEmpty(in->buffer); */ |
if ((in->httpIO != NULL) || (in->ftpIO != NULL) || (in->file != NULL) || |
if (in->readcallback != NULL) |
#ifdef HAVE_ZLIB_H |
|
(in->gzfile != NULL) || |
|
#endif |
|
(in->fd >= 0)) |
|
return(xmlParserInputBufferGrow(in, len)); |
return(xmlParserInputBufferGrow(in, len)); |
else |
else |
return(0); |
return(0); |
Line 582 xmlParserGetDirectory(const char *filena
|
Line 827 xmlParserGetDirectory(const char *filena
|
char *cur; |
char *cur; |
char sep = '/'; |
char sep = '/'; |
|
|
|
if (xmlInputCallbackInitialized == 0) |
|
xmlRegisterDefaultInputCallbacks(); |
|
|
if (filename == NULL) return(NULL); |
if (filename == NULL) return(NULL); |
#ifdef WIN32 |
#ifdef WIN32 |
sep = '\\'; |
sep = '\\'; |