This file is indexed.

/usr/include/gnelib/Address.h is in libgnelib-dev 0.75+svn20091130-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef ADDRESS_H_INCLUDED_C446A6BC
#define ADDRESS_H_INCLUDED_C446A6BC

/* GNE - Game Networking Engine, a portable multithreaded networking library.
 * Copyright (C) 2001-2006 Jason Winnebeck 
 * Project website: http://www.gillius.org/gne/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <nl.h>
#include <string>
class ostream;

namespace GNE {

/**
 * @ingroup midlevel
 *
 * A wrapper class for the HawkNL NLaddress.  This class is used many times
 * around GNE and is made for ease of use and cleaner code.
 */
class Address {
public:
  /**
   * Constructs an invalid address.
   */
  Address();

  /**
   * Creates a new Address, resolving the name in address if necessary.  The
   * format is the same as HawkNL's nlGetAddrFromName, for IP this format is
   * xxx.xxx.xxx.xxx:ppppp where ppppp is the optional port and
   * xxx.xxx.xxx.xxx can be a hostname, i.e.:<br>
   * localhost:1678<br>
   * 129.21.138.180:5555<br>
   * www.mozilla.com:80<br>
   * www.hawksoft.com  (when port is empty, resulting port will be 0).
   *
   * If no string is supplied, the default is 0.0.0.0:0.  Note that the name
   * resolution may take some time and this constructor will block.  If the
   * resolution failed, then the Address is not valid (!isValid()).
   *
   * @see isValid()
   */
  Address(std::string address);

  /**
   * Alternate version for better implicit conversion
   */
  Address(const char* address);

  /**
   * Creates a new Address with the HawkNL NLaddress.
   */
  Address(NLaddress address);

  ~Address();

  /**
   * Does the same work as the constructor.
   */
  void setAddressByName(const std::string& address);

  /**
   * Returns the reverse DNS lookup based on this address.  This method will
   * block.  If the name doesn't exist, the IP address will be returned.
   * The port from this address will not be part of the name in either case.
   */
  std::string getNameByAddress() const;

  /** 
   * Returns a copy of the actual HawkNL address struct.
   */
  NLaddress getAddress() const;

  /**
   * Sets the address based on the given HawkNL address.
   */
  void setAddress(NLaddress address);

  /**
   * Returns a string representation of this address in the format
   * xxx.xxx.xxx.xxx:ppppp, but if the port is 0, the colon and port number
   * are empty.
   */
  std::string toString() const;

  /**
   * Returns the port for this address.
   */
  int getPort() const;

  /**
   * Sets the port for this address.  This is a number 0..65535.
   */
  void setPort(int port);

  /**
   * Returns if this address is in a valid state.  And address will become
   * invalid if a name could not be resolved, or a port sent was out of range.
   */
  bool isValid() const;

  /**
   * Another method for testing isValid().
   * @see isValid()
   */
  operator bool() const;

  /**
   * Tests if two addresses are equal based on the HawkNL function
   * nlCompareAddr.  This does not take validity into consideration.
   */
  bool operator ==(const Address& rhs) const;

private:
  NLaddress addr;

};

} // namespace GNE

/**
 * Sends the result of toString to the ostream.
 */
std::ostream& operator << (std::ostream& o, const GNE::Address& addr);

#endif /* ADDRESS_H_INCLUDED_C446A6BC */