netwerk/base/src/nsURLParsers.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsURLParsers_h__
michael@0 7 #define nsURLParsers_h__
michael@0 8
michael@0 9 #include "nsIURLParser.h"
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11
michael@0 12 //----------------------------------------------------------------------------
michael@0 13 // base class for url parsers
michael@0 14 //----------------------------------------------------------------------------
michael@0 15
michael@0 16 class nsBaseURLParser : public nsIURLParser
michael@0 17 {
michael@0 18 public:
michael@0 19 NS_DECL_NSIURLPARSER
michael@0 20
michael@0 21 nsBaseURLParser() { }
michael@0 22
michael@0 23 protected:
michael@0 24 // implemented by subclasses
michael@0 25 virtual void ParseAfterScheme(const char *spec, int32_t specLen,
michael@0 26 uint32_t *authPos, int32_t *authLen,
michael@0 27 uint32_t *pathPos, int32_t *pathLen) = 0;
michael@0 28 };
michael@0 29
michael@0 30 //----------------------------------------------------------------------------
michael@0 31 // an url parser for urls that do not have an authority section
michael@0 32 //
michael@0 33 // eg. file:foo/bar.txt
michael@0 34 // file:/foo/bar.txt (treated equivalently)
michael@0 35 // file:///foo/bar.txt
michael@0 36 //
michael@0 37 // eg. file:////foo/bar.txt (UNC-filepath = \\foo\bar.txt)
michael@0 38 //
michael@0 39 // XXX except in this case:
michael@0 40 // file://foo/bar.txt (the authority "foo" is ignored)
michael@0 41 //----------------------------------------------------------------------------
michael@0 42
michael@0 43 class nsNoAuthURLParser MOZ_FINAL : public nsBaseURLParser
michael@0 44 {
michael@0 45 public:
michael@0 46 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 47
michael@0 48 #if defined(XP_WIN)
michael@0 49 NS_IMETHOD ParseFilePath(const char *, int32_t,
michael@0 50 uint32_t *, int32_t *,
michael@0 51 uint32_t *, int32_t *,
michael@0 52 uint32_t *, int32_t *);
michael@0 53 #endif
michael@0 54
michael@0 55 NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
michael@0 56 uint32_t *usernamePos, int32_t *usernameLen,
michael@0 57 uint32_t *passwordPos, int32_t *passwordLen,
michael@0 58 uint32_t *hostnamePos, int32_t *hostnameLen,
michael@0 59 int32_t *port);
michael@0 60
michael@0 61 void ParseAfterScheme(const char *spec, int32_t specLen,
michael@0 62 uint32_t *authPos, int32_t *authLen,
michael@0 63 uint32_t *pathPos, int32_t *pathLen);
michael@0 64 };
michael@0 65
michael@0 66 //----------------------------------------------------------------------------
michael@0 67 // an url parser for urls that must have an authority section
michael@0 68 //
michael@0 69 // eg. http:www.foo.com/bar.html
michael@0 70 // http:/www.foo.com/bar.html
michael@0 71 // http://www.foo.com/bar.html (treated equivalently)
michael@0 72 // http:///www.foo.com/bar.html
michael@0 73 //----------------------------------------------------------------------------
michael@0 74
michael@0 75 class nsAuthURLParser : public nsBaseURLParser
michael@0 76 {
michael@0 77 public:
michael@0 78 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 79
michael@0 80 virtual ~nsAuthURLParser() {}
michael@0 81
michael@0 82 NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
michael@0 83 uint32_t *usernamePos, int32_t *usernameLen,
michael@0 84 uint32_t *passwordPos, int32_t *passwordLen,
michael@0 85 uint32_t *hostnamePos, int32_t *hostnameLen,
michael@0 86 int32_t *port);
michael@0 87
michael@0 88 NS_IMETHOD ParseUserInfo(const char *userinfo, int32_t userinfoLen,
michael@0 89 uint32_t *usernamePos, int32_t *usernameLen,
michael@0 90 uint32_t *passwordPos, int32_t *passwordLen);
michael@0 91
michael@0 92 NS_IMETHOD ParseServerInfo(const char *serverinfo, int32_t serverinfoLen,
michael@0 93 uint32_t *hostnamePos, int32_t *hostnameLen,
michael@0 94 int32_t *port);
michael@0 95
michael@0 96 void ParseAfterScheme(const char *spec, int32_t specLen,
michael@0 97 uint32_t *authPos, int32_t *authLen,
michael@0 98 uint32_t *pathPos, int32_t *pathLen);
michael@0 99 };
michael@0 100
michael@0 101 //----------------------------------------------------------------------------
michael@0 102 // an url parser for urls that may or may not have an authority section
michael@0 103 //
michael@0 104 // eg. http:www.foo.com (www.foo.com is authority)
michael@0 105 // http:www.foo.com/bar.html (www.foo.com is authority)
michael@0 106 // http:/www.foo.com/bar.html (www.foo.com is part of file path)
michael@0 107 // http://www.foo.com/bar.html (www.foo.com is authority)
michael@0 108 // http:///www.foo.com/bar.html (www.foo.com is part of file path)
michael@0 109 //----------------------------------------------------------------------------
michael@0 110
michael@0 111 class nsStdURLParser : public nsAuthURLParser
michael@0 112 {
michael@0 113 public:
michael@0 114 void ParseAfterScheme(const char *spec, int32_t specLen,
michael@0 115 uint32_t *authPos, int32_t *authLen,
michael@0 116 uint32_t *pathPos, int32_t *pathLen);
michael@0 117 };
michael@0 118
michael@0 119 #endif // nsURLParsers_h__

mercurial