Annotation of XML/uri.c, revision 1.2
1.1 daniel 1: /**
2: * uri.c: set of generic URI related routines
3: *
1.2 ! daniel 4: * Reference: RFC 2396
! 5: *
! 6: * See Copyright for the status of this software.
! 7: *
! 8: * Daniel.Veillard@w3.org
1.1 daniel 9: */
10:
11: #ifdef WIN32
12: #define INCLUDE_WINSOCK
13: #include "win32config.h"
14: #else
15: #include "config.h"
16: #endif
17:
18: #include <stdio.h>
19: #include <string.h>
20:
21: /**
22: * alpha = lowalpha | upalpha
23: */
24: #define IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x))
25:
26:
27: /**
28: * lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" |
29: * "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" |
30: * "u" | "v" | "w" | "x" | "y" | "z"
31: */
32:
33: #define IS_LOWAPHA(x) ((x >= 'a') && (x <= 'z'))
34:
35: /**
36: * upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" |
37: * "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" |
38: * "U" | "V" | "W" | "X" | "Y" | "Z"
39: */
40: #define IS_UPALPHA(x) ((x >= 'A') && (x <= 'Z'))
41:
42: /**
43: * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
44: */
45:
46: #define IS_DIGIT(x) ((x >= '0') && (x <= '9'))
47:
48: /**
49: * alphanum = alpha | digit
50: */
51:
52: #define IS_ALPHANUM(x) (IS_ALPHA(x) || IS_DIGIT(x))
53:
54: /**
55: * hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
56: * "a" | "b" | "c" | "d" | "e" | "f"
57: */
58:
1.2 ! daniel 59: #define IS_HEX(x) ((IS_DIGIT(x)) || ((x >= 'a') && (x <= 'f')) || \
1.1 daniel 60: ((x >= 'A') && (x <= 'F')))
61:
62: /**
63: * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
64: */
65:
66: #define IS_MARK(x) ((x == '-') || (x == '_') || (x == '.') || (x == '!') || \
67: (x == '~') || (x == '*') || (x == ''') || (x == '(') || (x == ')'))
68:
69:
70: /**
71: * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
72: */
73:
74: #define IS_RESERVED(x) ((x == ';') || (x == '/') || (x == '?') || \
75: (x == ':') || (x == '@') || (x == '&') || (x == '=') || \
76: (x == '+') || (x == '$') || (x == ','))
77:
78: /**
79: * unreserved = alphanum | mark
80: */
81:
82: #define IS_UNRESERVED(x) (IS_ALPHANUM(x) || IS_MARK(x))
83:
84:
85: /**
86: *
87: URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
88: absoluteURI = scheme ":" ( hier_part | opaque_part )
89: relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
90:
91: hier_part = ( net_path | abs_path ) [ "?" query ]
92: opaque_part = uric_no_slash *uric
93:
94: net_path = "//" authority [ abs_path ]
95: abs_path = "/" path_segments
96: rel_path = rel_segment [ abs_path ]
97:
98: rel_segment = 1*( unreserved | escaped |
99: ";" | "@" | "&" | "=" | "+" | "$" | "," )
100:
101: scheme = alpha *( alpha | digit | "+" | "-" | "." )
102:
103: authority = server | reg_name
104:
105: reg_name = 1*( unreserved | escaped | "$" | "," |
106: ";" | ":" | "@" | "&" | "=" | "+" )
107:
108: server = [ [ userinfo "@" ] hostport ]
109: userinfo = *( unreserved | escaped |
110: ";" | ":" | "&" | "=" | "+" | "$" | "," )
111:
112: hostport = host [ ":" port ]
113: host = hostname | IPv4address
114: hostname = *( domainlabel "." ) toplabel [ "." ]
115: domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
116: toplabel = alpha | alpha *( alphanum | "-" ) alphanum
117: IPv4address = 1*digit "." 1*digit "." 1*digit "." 1*digit
118: port = *digit
119:
120: path = [ abs_path | opaque_part ]
121: path_segments = segment *( "/" segment )
122: segment = *pchar *( ";" param )
123: param = *pchar
124:
125: query = *uric
126:
127: fragment = *uric
128:
129: Macroifiables
130: =============
131:
132: uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
133: "&" | "=" | "+" | "$" | ","
134:
135: pchar = unreserved | escaped |
136: ":" | "@" | "&" | "=" | "+" | "$" | ","
137: escaped = "%" hex hex
138:
139: */
1.2 ! daniel 140:
! 141: /**
! 142: * xmlBuildURI:
! 143: * @URI: the URI instance found in the document
! 144: * @doc: the document itself
! 145: * @node: the node carrying the instance (optionnal)
! 146: *
! 147: * Computes he final URI of the reference done by checking that
! 148: * the given URI is valid, and getting the base and building the
! 149: * final URI if needed
! 150: *
! 151: * Returns a new URI string (to be freed by the caller)
! 152: */
! 153: xmlChar *
! 154: xmlBuildURI(const xmlChar *URI, xmlDocPtr doc, xmlNodePtr node) {
! 155: }
Webmaster