MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlBuildRelativeURISafe

Function xmlBuildRelativeURISafe

ThirdParty/libxml2/vtklibxml2/uri.c:2526–2741  ·  view source on GitHub ↗

* xmlBuildRelativeURISafe: * @URI: the URI reference under consideration * @base: the base value * @valPtr: pointer to result URI * * Expresses the URI of the reference in terms relative to the * base. Some examples of this operation include: * base = "http://site1.com/docs/book1.html" * URI input URI returned * docs/pic1.gif pi

Source from the content-addressed store, hash-verified

2524 * code if URI or base are invalid.
2525 */
2526int
2527xmlBuildRelativeURISafe(const xmlChar * URI, const xmlChar * base,
2528 xmlChar **valPtr)
2529{
2530 xmlChar *val = NULL;
2531 int ret = 0;
2532 int ix;
2533 int nbslash = 0;
2534 int len;
2535 xmlURIPtr ref = NULL;
2536 xmlURIPtr bas = NULL;
2537 const xmlChar *bptr, *uptr, *rptr;
2538 xmlChar *vptr;
2539 int remove_path = 0;
2540 int refDrive, baseDrive;
2541
2542 if (valPtr == NULL)
2543 return(1);
2544 *valPtr = NULL;
2545 if ((URI == NULL) || (*URI == 0))
2546 return(1);
2547
2548 ret = xmlParseUriOrPath((char *) URI, &ref, &refDrive);
2549 if (ret < 0)
2550 goto done;
2551 if (ret != 0) {
2552 /* Return URI if URI is invalid */
2553 ret = 0;
2554 val = xmlStrdup(URI);
2555 if (val == NULL)
2556 ret = -1;
2557 goto done;
2558 }
2559
2560 /* Return URI if base is empty */
2561 if ((base == NULL) || (*base == 0))
2562 goto done;
2563
2564 ret = xmlParseUriOrPath((char *) base, &bas, &baseDrive);
2565 if (ret < 0)
2566 goto done;
2567 if (ret != 0) {
2568 /* Return URI if base is invalid */
2569 ret = 0;
2570 goto done;
2571 }
2572
2573 /*
2574 * If the scheme / server on the URI differs from the base,
2575 * just return the URI
2576 */
2577 if ((xmlStrcmp ((xmlChar *)bas->scheme, (xmlChar *)ref->scheme)) ||
2578 (xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)) ||
2579 (bas->port != ref->port) ||
2580 (baseDrive != refDrive)) {
2581 goto done;
2582 }
2583 if (xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path)) {

Callers 2

xmlXIncludeBaseFixupFunction · 0.85
xmlBuildRelativeURIFunction · 0.85

Calls 8

xmlParseUriOrPathFunction · 0.85
xmlStrdupFunction · 0.85
xmlStrcmpFunction · 0.85
xmlStrEqualFunction · 0.85
xmlStrlenFunction · 0.85
xmlURIEscapeStrFunction · 0.85
xmlSaveUriFunction · 0.85
xmlFreeURIFunction · 0.85

Tested by

no test coverage detected