|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 /** |
|
9 * nsIURLParser specifies the interface to an URL parser that attempts to |
|
10 * follow the definitions of RFC 2396. |
|
11 */ |
|
12 [scriptable, uuid(78c5d19f-f5d2-4732-8d3d-d5a7d7133bc0)] |
|
13 interface nsIURLParser : nsISupports |
|
14 { |
|
15 /** |
|
16 * The string to parse in the following methods may be given as a null |
|
17 * terminated string, in which case the length argument should be -1. |
|
18 * |
|
19 * Out parameters of the following methods are all optional (ie. the caller |
|
20 * may pass-in a NULL value if the corresponding results are not needed). |
|
21 * Signed out parameters may hold a value of -1 if the corresponding result |
|
22 * is not part of the string being parsed. |
|
23 * |
|
24 * The parsing routines attempt to be as forgiving as possible. |
|
25 */ |
|
26 |
|
27 /** |
|
28 * ParseSpec breaks the URL string up into its 3 major components: a scheme, |
|
29 * an authority section (hostname, etc.), and a path. |
|
30 * |
|
31 * spec = <scheme>://<authority><path> |
|
32 */ |
|
33 void parseURL (in string spec, in long specLen, |
|
34 out unsigned long schemePos, out long schemeLen, |
|
35 out unsigned long authorityPos, out long authorityLen, |
|
36 out unsigned long pathPos, out long pathLen); |
|
37 |
|
38 /** |
|
39 * ParseAuthority breaks the authority string up into its 4 components: |
|
40 * username, password, hostname, and hostport. |
|
41 * |
|
42 * auth = <username>:<password>@<hostname>:<port> |
|
43 */ |
|
44 void parseAuthority (in string authority, in long authorityLen, |
|
45 out unsigned long usernamePos, out long usernameLen, |
|
46 out unsigned long passwordPos, out long passwordLen, |
|
47 out unsigned long hostnamePos, out long hostnameLen, |
|
48 out long port); |
|
49 |
|
50 /** |
|
51 * userinfo = <username>:<password> |
|
52 */ |
|
53 void parseUserInfo (in string userinfo, in long userinfoLen, |
|
54 out unsigned long usernamePos, out long usernameLen, |
|
55 out unsigned long passwordPos, out long passwordLen); |
|
56 |
|
57 /** |
|
58 * serverinfo = <hostname>:<port> |
|
59 */ |
|
60 void parseServerInfo (in string serverinfo, in long serverinfoLen, |
|
61 out unsigned long hostnamePos, out long hostnameLen, |
|
62 out long port); |
|
63 |
|
64 /** |
|
65 * ParsePath breaks the path string up into its 3 major components: a file path, |
|
66 * a query string, and a reference string. |
|
67 * |
|
68 * path = <filepath>?<query>#<ref> |
|
69 */ |
|
70 void parsePath (in string path, in long pathLen, |
|
71 out unsigned long filepathPos, out long filepathLen, |
|
72 out unsigned long queryPos, out long queryLen, |
|
73 out unsigned long refPos, out long refLen); |
|
74 |
|
75 /** |
|
76 * ParseFilePath breaks the file path string up into: the directory portion, |
|
77 * file base name, and file extension. |
|
78 * |
|
79 * filepath = <directory><basename>.<extension> |
|
80 */ |
|
81 void parseFilePath (in string filepath, in long filepathLen, |
|
82 out unsigned long directoryPos, out long directoryLen, |
|
83 out unsigned long basenamePos, out long basenameLen, |
|
84 out unsigned long extensionPos, out long extensionLen); |
|
85 |
|
86 /** |
|
87 * filename = <basename>.<extension> |
|
88 */ |
|
89 void parseFileName (in string filename, in long filenameLen, |
|
90 out unsigned long basenamePos, out long basenameLen, |
|
91 out unsigned long extensionPos, out long extensionLen); |
|
92 }; |
|
93 |
|
94 %{C++ |
|
95 // url parser key for use with the category manager |
|
96 // mapping from scheme to url parser. |
|
97 #define NS_IURLPARSER_KEY "@mozilla.org/urlparser;1" |
|
98 %} |