Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 /*
7 ** Base class definitions for network access functions (ref: prnetdb.h)
8 */
10 #if defined(_RCNETDB_H)
11 #else
12 #define _RCNETDB_H
14 #include "rclock.h"
15 #include "rcbase.h"
17 #include <prnetdb.h>
19 class PR_IMPLEMENT(RCNetAddr): public RCBase
20 {
21 public:
22 typedef enum {
23 any = PR_IpAddrAny, /* assign logical INADDR_ANY */
24 loopback = PR_IpAddrLoopback /* assign logical INADDR_LOOPBACK */
25 } HostValue;
27 RCNetAddr(); /* default constructor is unit'd object */
28 RCNetAddr(const RCNetAddr&); /* copy constructor */
29 RCNetAddr(HostValue, PRUint16 port);/* init'd w/ 'special' assignments */
30 RCNetAddr(const RCNetAddr&, PRUint16 port);
31 /* copy w/ port reassigment */
33 virtual ~RCNetAddr();
35 void operator=(const RCNetAddr&);
37 virtual PRBool operator==(const RCNetAddr&) const;
38 /* compare of all relavent fields */
39 virtual PRBool EqualHost(const RCNetAddr&) const;
40 /* compare of just host field */
43 public:
45 void operator=(const PRNetAddr*); /* construction from more primitive data */
46 operator const PRNetAddr*() const; /* extraction of underlying representation */
47 virtual PRStatus FromString(const char* string);
48 /* initialization from an ASCII string */
49 virtual PRStatus ToString(char *string, PRSize size) const;
50 /* convert internal fromat to a string */
52 private:
54 PRNetAddr address;
56 }; /* RCNetAddr */
58 /*
59 ** Class: RCHostLookup
60 **
61 ** Abstractions to look up host names and addresses.
62 **
63 ** This is a stateful class. One looks up the host by name or by
64 ** address, then enumerates over a possibly empty array of network
65 ** addresses. The storage for the addresses is owned by the class.
66 */
68 class RCHostLookup: public RCBase
69 {
70 public:
71 virtual ~RCHostLookup();
73 RCHostLookup();
75 virtual PRStatus ByName(const char* name);
76 virtual PRStatus ByAddress(const RCNetAddr&);
78 virtual const RCNetAddr* operator[](PRUintn);
80 private:
81 RCLock ml;
82 PRIntn max_index;
83 RCNetAddr* address;
85 RCHostLookup(const RCHostLookup&);
86 RCHostLookup& operator=(const RCHostLookup&);
87 };
89 inline RCNetAddr::RCNetAddr(): RCBase() { }
90 inline RCNetAddr::operator const PRNetAddr*() const { return &address; }
93 #endif /* defined(_RCNETDB_H) */
95 /* RCNetdb.h */