2001-11-16 02:09:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-11-16 02:09:13 +00:00
|
|
|
|
|
|
|
#ifndef nsURLParsers_h__
|
|
|
|
#define nsURLParsers_h__
|
|
|
|
|
|
|
|
#include "nsIURLParser.h"
|
2012-06-06 03:18:25 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-11-16 02:09:13 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// base class for url parsers
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsBaseURLParser : public nsIURLParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIURLPARSER
|
|
|
|
|
2003-01-08 22:35:09 +00:00
|
|
|
nsBaseURLParser() { }
|
2001-11-16 02:09:13 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// implemented by subclasses
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual void ParseAfterScheme(const char *spec, int32_t specLen,
|
|
|
|
uint32_t *authPos, int32_t *authLen,
|
|
|
|
uint32_t *pathPos, int32_t *pathLen) = 0;
|
2001-11-16 02:09:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that do not have an authority section
|
|
|
|
//
|
|
|
|
// eg. file:foo/bar.txt
|
|
|
|
// file:/foo/bar.txt (treated equivalently)
|
|
|
|
// file:///foo/bar.txt
|
|
|
|
//
|
|
|
|
// eg. file:////foo/bar.txt (UNC-filepath = \\foo\bar.txt)
|
|
|
|
//
|
|
|
|
// XXX except in this case:
|
2009-05-17 03:21:35 +00:00
|
|
|
// file://foo/bar.txt (the authority "foo" is ignored)
|
2001-11-16 02:09:13 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsNoAuthURLParser final : public nsBaseURLParser
|
2001-11-16 02:09:13 +00:00
|
|
|
{
|
2014-06-24 16:36:44 +00:00
|
|
|
~nsNoAuthURLParser() {}
|
|
|
|
|
2012-06-06 03:18:25 +00:00
|
|
|
public:
|
2013-07-19 02:24:13 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-06 03:18:25 +00:00
|
|
|
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_WIN)
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD ParseFilePath(const char *, int32_t,
|
|
|
|
uint32_t *, int32_t *,
|
|
|
|
uint32_t *, int32_t *,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t *, int32_t *) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
|
|
|
uint32_t *passwordPos, int32_t *passwordLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t *port) override;
|
2009-05-17 03:21:35 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen,
|
|
|
|
uint32_t *authPos, int32_t *authLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t *pathPos, int32_t *pathLen) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that must have an authority section
|
|
|
|
//
|
|
|
|
// eg. http:www.foo.com/bar.html
|
|
|
|
// http:/www.foo.com/bar.html
|
|
|
|
// http://www.foo.com/bar.html (treated equivalently)
|
|
|
|
// http:///www.foo.com/bar.html
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsAuthURLParser : public nsBaseURLParser
|
|
|
|
{
|
2014-06-24 16:36:44 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsAuthURLParser() {}
|
|
|
|
|
2012-06-06 03:18:25 +00:00
|
|
|
public:
|
2013-07-19 02:24:13 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-06 03:18:25 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
|
|
|
uint32_t *passwordPos, int32_t *passwordLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t *port) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD ParseUserInfo(const char *userinfo, int32_t userinfoLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t *passwordPos, int32_t *passwordLen) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD ParseServerInfo(const char *serverinfo, int32_t serverinfoLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t *port) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen,
|
|
|
|
uint32_t *authPos, int32_t *authLen,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t *pathPos, int32_t *pathLen) override;
|
2001-11-16 02:09:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that may or may not have an authority section
|
|
|
|
//
|
|
|
|
// eg. http:www.foo.com (www.foo.com is authority)
|
|
|
|
// http:www.foo.com/bar.html (www.foo.com is authority)
|
|
|
|
// http:/www.foo.com/bar.html (www.foo.com is part of file path)
|
|
|
|
// http://www.foo.com/bar.html (www.foo.com is authority)
|
|
|
|
// http:///www.foo.com/bar.html (www.foo.com is part of file path)
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsStdURLParser : public nsAuthURLParser
|
|
|
|
{
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~nsStdURLParser() {}
|
|
|
|
|
2001-11-16 02:09:13 +00:00
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen,
|
|
|
|
uint32_t *authPos, int32_t *authLen,
|
|
|
|
uint32_t *pathPos, int32_t *pathLen);
|
2001-11-16 02:09:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsURLParsers_h__
|