Eneboo - Documentación para desarrolladores
'defines' | Funciones
Referencia del Archivo src/libdigidoc/libxml2/uri.c
#include "libxml.h"
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/uri.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include "elfgcchack.h"

'defines'

#define IN_LIBXML
#define IS_ALPHA(x)   (IS_LOWALPHA(x) || IS_UPALPHA(x))
#define IS_LOWALPHA(x)   (((x) >= 'a') && ((x) <= 'z'))
#define IS_UPALPHA(x)   (((x) >= 'A') && ((x) <= 'Z'))
#define IS_DIGIT(x)   (((x) >= '0') && ((x) <= '9'))
#define IS_ALPHANUM(x)   (IS_ALPHA(x) || IS_DIGIT(x))
#define IS_MARK(x)
#define IS_UNWISE(p)
#define IS_RESERVED(x)
#define IS_UNRESERVED(x)   (IS_ALPHANUM(x) || IS_MARK(x))
#define NEXT(p)   ((*p == '%')? p += 3 : p++)
#define STRNDUP(s, n)   (char *) xmlStrndup((const xmlChar *)(s), (n))
#define ISA_DIGIT(p)   ((*(p) >= '0') && (*(p) <= '9'))
#define ISA_ALPHA(p)
#define ISA_HEXDIG(p)
#define ISA_SUB_DELIM(p)
#define ISA_GEN_DELIM(p)
#define ISA_RESERVED(p)   (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p)))
#define ISA_UNRESERVED(p)
#define ISA_PCT_ENCODED(p)   ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
#define ISA_PCHAR(p)
#define NULLCHK(p)
#define IS_WINDOWS_PATH(p)
#define bottom_uri

Funciones

xmlURIPtr xmlParseURI (const char *str)
int xmlParseURIReference (xmlURIPtr uri, const char *str)
xmlURIPtr xmlParseURIRaw (const char *str, int raw)
xmlURIPtr xmlCreateURI (void)
xmlCharxmlSaveUri (xmlURIPtr uri)
void xmlPrintURI (FILE *stream, xmlURIPtr uri)
void xmlFreeURI (xmlURIPtr uri)
int xmlNormalizeURIPath (char *path)
char * xmlURIUnescapeString (const char *str, int len, char *target)
xmlCharxmlURIEscapeStr (const xmlChar *str, const xmlChar *list)
xmlCharxmlURIEscape (const xmlChar *str)
xmlCharxmlBuildURI (const xmlChar *URI, const xmlChar *base)
xmlCharxmlBuildRelativeURI (const xmlChar *URI, const xmlChar *base)
xmlCharxmlCanonicPath (const xmlChar *path)
xmlCharxmlPathToURI (const xmlChar *path)

Documentación de los 'defines'

#define bottom_uri
#define IN_LIBXML

uri.c: set of generic URI related routines

Reference: RFCs 3986, 2732 and 2373

See Copyright for the status of this software.

daniel@veillard.com

#define IS_ALPHA (   x)    (IS_LOWALPHA(x) || IS_UPALPHA(x))
#define IS_ALPHANUM (   x)    (IS_ALPHA(x) || IS_DIGIT(x))
#define IS_DIGIT (   x)    (((x) >= '0') && ((x) <= '9'))
#define IS_LOWALPHA (   x)    (((x) >= 'a') && ((x) <= 'z'))
#define IS_MARK (   x)
Valor:
(((x) == '-') || ((x) == '_') || ((x) == '.') ||     \
    ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') ||    \
    ((x) == '(') || ((x) == ')'))
#define IS_RESERVED (   x)
Valor:
(((x) == ';') || ((x) == '/') || ((x) == '?') || \
        ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \
        ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \
        ((x) == ']'))
#define IS_UNRESERVED (   x)    (IS_ALPHANUM(x) || IS_MARK(x))
#define IS_UNWISE (   p)
Valor:
(((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) ||         \
       ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) ||        \
       ((*(p) == ']')) || ((*(p) == '`')))
#define IS_UPALPHA (   x)    (((x) >= 'A') && ((x) <= 'Z'))
#define IS_WINDOWS_PATH (   p)
Valor:
((p != NULL) &&                                         \
         (((p[0] >= 'a') && (p[0] <= 'z')) ||                   \
          ((p[0] >= 'A') && (p[0] <= 'Z'))) &&                  \
         (p[1] == ':') && ((p[2] == '/') || (p[2] == '\\')))

xmlCanonicPath: : the resource locator in a filesystem notation

Constructs a canonic path from the specified path.

Returns a new canonic path, or a duplicate of the path parameter if the construction fails. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.

#define ISA_ALPHA (   p)
Valor:
(((*(p) >= 'a') && (*(p) <= 'z')) ||            \
                      ((*(p) >= 'A') && (*(p) <= 'Z')))
#define ISA_DIGIT (   p)    ((*(p) >= '0') && (*(p) <= '9'))
#define ISA_GEN_DELIM (   p)
Valor:
(((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) ||         \
       ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) ||         \
       ((*(p) == '@')))
#define ISA_HEXDIG (   p)
Valor:
(ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) ||            \
        ((*(p) >= 'A') && (*(p) <= 'F')))
#define ISA_PCHAR (   p)
Valor:
(ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) || \
      ((*(p) == ':')) || ((*(p) == '@')))
#define ISA_PCT_ENCODED (   p)    ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
#define ISA_RESERVED (   p)    (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p)))
#define ISA_SUB_DELIM (   p)
Valor:
(((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) ||               \
       ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) ||         \
       ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||         \
       ((*(p) == '=')))
#define ISA_UNRESERVED (   p)
Valor:
((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) ||         \
       ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
#define NEXT (   p)    ((*p == '%')? p += 3 : p++)
#define NULLCHK (   p)
Valor:
if(!p) { \
                   xmlGenericError(xmlGenericErrorContext, \
                        "xmlURIEscape: out of memory\n"); \
                        xmlFreeURI(uri); \
                        return NULL; } \
#define STRNDUP (   s,
 
)    (char *) xmlStrndup((const xmlChar *)(s), (n))

Documentación de las funciones

xmlChar* xmlBuildRelativeURI ( const xmlChar URI,
const xmlChar base 
)

xmlBuildRelativeURI: : the URI reference under consideration : the base value

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 pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif

base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif

Note: if the URI reference is really wierd or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation.

Returns a new URI string (to be freed by the caller) or NULL in case error.

xmlChar* xmlBuildURI ( const xmlChar URI,
const xmlChar base 
)

xmlBuildURI: : the URI instance found in the document : the base value

Computes he final URI of the reference done by checking that the given URI is valid, and building the final URI using the base URI. This is processed according to section 5.2 of the RFC 2396

5.2. Resolving Relative References to Absolute Form

Returns a new URI string (to be freed by the caller) or NULL in case of error.

xmlChar* xmlCanonicPath ( const xmlChar path)
xmlURIPtr xmlCreateURI ( void  )

xmlCreateURI:

Simply creates an empty xmlURI

Returns the new structure or NULL in case of error

void xmlFreeURI ( xmlURIPtr  uri)

xmlFreeURI: : pointer to an xmlURI

Free up the xmlURI struct

int xmlNormalizeURIPath ( char *  path)

xmlNormalizeURIPath: : pointer to the path string

Applies the 5 normalization steps to a path string--that is, RFC 2396 Section 5.2, steps 6.c through 6.g.

Normalization occurs directly on the string, no new allocation is done

Returns 0 or an error code

xmlURIPtr xmlParseURI ( const char *  str)

xmlParseURI: : the URI string to analyze

Parse an URI based on RFC 3986

URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]

Returns a newly built xmlURIPtr or NULL in case of error

xmlURIPtr xmlParseURIRaw ( const char *  str,
int  raw 
)

xmlParseURIRaw: : the URI string to analyze : if 1 unescaping of URI pieces are disabled

Parse an URI but allows to keep intact the original fragments.

URI-reference = URI / relative-ref

Returns a newly built xmlURIPtr or NULL in case of error

int xmlParseURIReference ( xmlURIPtr  uri,
const char *  str 
)

xmlParseURIReference: : pointer to an URI structure : the string to analyze

Parse an URI reference string based on RFC 3986 and fills in the appropriate fields of the structure

URI-reference = URI / relative-ref

Returns 0 or the error code

xmlChar* xmlPathToURI ( const xmlChar path)

xmlPathToURI: : the resource locator in a filesystem notation

Constructs an URI expressing the existing path

Returns a new URI, or a duplicate of the path parameter if the construction fails. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.

void xmlPrintURI ( FILE *  stream,
xmlURIPtr  uri 
)

xmlPrintURI: : a FILE* for the output : pointer to an xmlURI

Prints the URI in the stream .

xmlChar* xmlSaveUri ( xmlURIPtr  uri)

xmlSaveUri: : pointer to an xmlURI

Save the URI as an escaped string

Returns a new string (to be deallocated by caller)

xmlChar* xmlURIEscape ( const xmlChar str)

xmlURIEscape: : the string of the URI to escape

Escaping routine, does not do validity checks ! It will try to escape the chars needing this, but this is heuristic based it's impossible to be sure.

Returns an copy of the string, but escaped

25 May 2001 Uses xmlParseURI and xmlURIEscapeStr to try to escape correctly according to RFC2396.

  • Carl Douglas
xmlChar* xmlURIEscapeStr ( const xmlChar str,
const xmlChar list 
)

xmlURIEscapeStr: : string to escape : exception list string of chars not to escape

This routine escapes a string to hex, ignoring reserved characters (a-z) and the characters in the exception list.

Returns a new escaped string or NULL in case of error.

char* xmlURIUnescapeString ( const char *  str,
int  len,
char *  target 
)

xmlURIUnescapeString: : the string to unescape : the length in bytes to unescape (or <= 0 to indicate full string) : optional destination buffer

Unescaping routine, but does not check that the string is an URI. The output is a direct unsigned char translation of XX values (no encoding) Note that the length of the result can only be smaller or same size as the input string.

Returns a copy of the string, but unescaped, will return NULL only in case of error

 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'