1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Darin Fisher (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsURLParsers_h__
40 #define nsURLParsers_h__
42 #include "nsIURLParser.h"
44 //----------------------------------------------------------------------------
45 // base class for url parsers
46 //----------------------------------------------------------------------------
48 class nsBaseURLParser
: public nsIURLParser
57 // implemented by subclasses
58 virtual void ParseAfterScheme(const char *spec
, PRInt32 specLen
,
59 PRUint32
*authPos
, PRInt32
*authLen
,
60 PRUint32
*pathPos
, PRInt32
*pathLen
) = 0;
63 //----------------------------------------------------------------------------
64 // an url parser for urls that do not have an authority section
66 // eg. file:foo/bar.txt
67 // file:/foo/bar.txt (treated equivalently)
68 // file:///foo/bar.txt
70 // eg. file:////foo/bar.txt (UNC-filepath = \\foo\bar.txt)
72 // XXX except in this case:
73 // file://foo/bar.txt (foo is authority)
74 //----------------------------------------------------------------------------
76 class nsNoAuthURLParser
: public nsBaseURLParser
79 #if defined(XP_WIN) || defined(XP_OS2)
80 NS_IMETHOD
ParseFilePath(const char *, PRInt32
,
81 PRUint32
*, PRInt32
*,
82 PRUint32
*, PRInt32
*,
83 PRUint32
*, PRInt32
*);
86 void ParseAfterScheme(const char *spec
, PRInt32 specLen
,
87 PRUint32
*authPos
, PRInt32
*authLen
,
88 PRUint32
*pathPos
, PRInt32
*pathLen
);
91 //----------------------------------------------------------------------------
92 // an url parser for urls that must have an authority section
94 // eg. http:www.foo.com/bar.html
95 // http:/www.foo.com/bar.html
96 // http://www.foo.com/bar.html (treated equivalently)
97 // http:///www.foo.com/bar.html
98 //----------------------------------------------------------------------------
100 class nsAuthURLParser
: public nsBaseURLParser
103 NS_IMETHOD
ParseAuthority(const char *auth
, PRInt32 authLen
,
104 PRUint32
*usernamePos
, PRInt32
*usernameLen
,
105 PRUint32
*passwordPos
, PRInt32
*passwordLen
,
106 PRUint32
*hostnamePos
, PRInt32
*hostnameLen
,
109 NS_IMETHOD
ParseUserInfo(const char *userinfo
, PRInt32 userinfoLen
,
110 PRUint32
*usernamePos
, PRInt32
*usernameLen
,
111 PRUint32
*passwordPos
, PRInt32
*passwordLen
);
113 NS_IMETHOD
ParseServerInfo(const char *serverinfo
, PRInt32 serverinfoLen
,
114 PRUint32
*hostnamePos
, PRInt32
*hostnameLen
,
117 void ParseAfterScheme(const char *spec
, PRInt32 specLen
,
118 PRUint32
*authPos
, PRInt32
*authLen
,
119 PRUint32
*pathPos
, PRInt32
*pathLen
);
122 //----------------------------------------------------------------------------
123 // an url parser for urls that may or may not have an authority section
125 // eg. http:www.foo.com (www.foo.com is authority)
126 // http:www.foo.com/bar.html (www.foo.com is authority)
127 // http:/www.foo.com/bar.html (www.foo.com is part of file path)
128 // http://www.foo.com/bar.html (www.foo.com is authority)
129 // http:///www.foo.com/bar.html (www.foo.com is part of file path)
130 //----------------------------------------------------------------------------
132 class nsStdURLParser
: public nsAuthURLParser
135 void ParseAfterScheme(const char *spec
, PRInt32 specLen
,
136 PRUint32
*authPos
, PRInt32
*authLen
,
137 PRUint32
*pathPos
, PRInt32
*pathLen
);
140 #endif // nsURLParsers_h__