version 1.26, 2000/10/02 23:01:41
|
version 1.27, 2000/10/25 19:26:53
|
Line 20
|
Line 20
|
|
|
#include <libxml/xmlmemory.h> |
#include <libxml/xmlmemory.h> |
#include <libxml/uri.h> |
#include <libxml/uri.h> |
|
#include <libxml/xmlerror.h> |
|
|
/* |
/* |
* alpha = lowalpha | upalpha |
* alpha = lowalpha | upalpha |
Line 181 xmlCreateURI(void) {
|
Line 182 xmlCreateURI(void) {
|
|
|
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI)); |
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlCreateURI: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlCreateURI: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
memset(ret, 0, sizeof(xmlURI)); |
memset(ret, 0, sizeof(xmlURI)); |
Line 209 xmlSaveUri(xmlURIPtr uri) {
|
Line 211 xmlSaveUri(xmlURIPtr uri) {
|
max = 80; |
max = 80; |
ret = (xmlChar *) xmlMalloc((max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlMalloc((max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
len = 0; |
len = 0; |
Line 221 xmlSaveUri(xmlURIPtr uri) {
|
Line 224 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 231 xmlSaveUri(xmlURIPtr uri) {
|
Line 235 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 244 xmlSaveUri(xmlURIPtr uri) {
|
Line 249 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 265 xmlSaveUri(xmlURIPtr uri) {
|
Line 271 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 276 xmlSaveUri(xmlURIPtr uri) {
|
Line 283 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 287 xmlSaveUri(xmlURIPtr uri) {
|
Line 295 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
if ((IS_UNRESERVED(*(p))) || |
if ((IS_UNRESERVED(*(p))) || |
((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) || |
((*(p) == ';')) || ((*(p) == ':')) || |
((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || |
((*(p) == '&')) || ((*(p) == '=')) || |
|
((*(p) == '+')) || ((*(p) == '$')) || |
((*(p) == ','))) |
((*(p) == ','))) |
ret[len++] = *p++; |
ret[len++] = *p++; |
else { |
else { |
Line 308 xmlSaveUri(xmlURIPtr uri) {
|
Line 319 xmlSaveUri(xmlURIPtr uri) {
|
} |
} |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 320 xmlSaveUri(xmlURIPtr uri) {
|
Line 333 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len >= max) { |
if (len >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 331 xmlSaveUri(xmlURIPtr uri) {
|
Line 346 xmlSaveUri(xmlURIPtr uri) {
|
if (uri->port > 0) { |
if (uri->port > 0) { |
if (len + 10 >= max) { |
if (len + 10 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 342 xmlSaveUri(xmlURIPtr uri) {
|
Line 359 xmlSaveUri(xmlURIPtr uri) {
|
} else if (uri->authority != NULL) { |
} else if (uri->authority != NULL) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 354 xmlSaveUri(xmlURIPtr uri) {
|
Line 373 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 376 xmlSaveUri(xmlURIPtr uri) {
|
Line 397 xmlSaveUri(xmlURIPtr uri) {
|
} else if (uri->scheme != NULL) { |
} else if (uri->scheme != NULL) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 390 xmlSaveUri(xmlURIPtr uri) {
|
Line 413 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 413 xmlSaveUri(xmlURIPtr uri) {
|
Line 438 xmlSaveUri(xmlURIPtr uri) {
|
if (uri->query != NULL) { |
if (uri->query != NULL) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 424 xmlSaveUri(xmlURIPtr uri) {
|
Line 451 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 444 xmlSaveUri(xmlURIPtr uri) {
|
Line 473 xmlSaveUri(xmlURIPtr uri) {
|
if (uri->fragment != NULL) { |
if (uri->fragment != NULL) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 455 xmlSaveUri(xmlURIPtr uri) {
|
Line 486 xmlSaveUri(xmlURIPtr uri) {
|
while (*p != 0) { |
while (*p != 0) { |
if (len + 3 >= max) { |
if (len + 3 >= max) { |
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, |
|
(max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 476 xmlSaveUri(xmlURIPtr uri) {
|
Line 509 xmlSaveUri(xmlURIPtr uri) {
|
max *= 2; |
max *= 2; |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar)); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlSaveUri: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlSaveUri: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} |
} |
Line 577 xmlURIUnescapeString(const char *str, in
|
Line 611 xmlURIUnescapeString(const char *str, in
|
if (target == NULL) { |
if (target == NULL) { |
ret = (char *) xmlMalloc(len + 1); |
ret = (char *) xmlMalloc(len + 1); |
if (ret == NULL) { |
if (ret == NULL) { |
fprintf(stderr, "xmlURIUnescapeString: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlURIUnescapeString: out of memory\n"); |
return(NULL); |
return(NULL); |
} |
} |
} else |
} else |
Line 691 xmlParseURIScheme(xmlURIPtr uri, const c
|
Line 726 xmlParseURIScheme(xmlURIPtr uri, const c
|
while (IS_SCHEME(*cur)) cur++; |
while (IS_SCHEME(*cur)) cur++; |
if (uri != NULL) { |
if (uri != NULL) { |
if (uri->scheme != NULL) xmlFree(uri->scheme); |
if (uri->scheme != NULL) xmlFree(uri->scheme); |
uri->scheme = xmlURIUnescapeString(*str, cur - *str, NULL); /* !!! strndup */ |
/* !!! strndup */ |
|
uri->scheme = xmlURIUnescapeString(*str, cur - *str, NULL); |
} |
} |
*str = cur; |
*str = cur; |
return(0); |
return(0); |
Line 954 xmlParseURIPathSegments(xmlURIPtr uri, c
|
Line 990 xmlParseURIPathSegments(xmlURIPtr uri, c
|
} |
} |
path = (char *) xmlMalloc(len + 1); |
path = (char *) xmlMalloc(len + 1); |
if (path == NULL) { |
if (path == NULL) { |
fprintf(stderr, "xmlParseURIPathSegments: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlParseURIPathSegments: out of memory\n"); |
*str = cur; |
*str = cur; |
return(-1); |
return(-1); |
} |
} |
Line 1557 xmlBuildURI(const xmlChar *URI, const xm
|
Line 1594 xmlBuildURI(const xmlChar *URI, const xm
|
len += strlen(bas->path); |
len += strlen(bas->path); |
res->path = (char *) xmlMalloc(len); |
res->path = (char *) xmlMalloc(len); |
if (res->path == NULL) { |
if (res->path == NULL) { |
fprintf(stderr, "xmlBuildURI: out of memory\n"); |
xmlGenericError(xmlGenericErrorContext, |
|
"xmlBuildURI: out of memory\n"); |
goto done; |
goto done; |
} |
} |
res->path[0] = 0; |
res->path[0] = 0; |