This file is indexed.

/usr/include/phonenumbers/shortnumberinfo.h is in libphonenumber-dev 7.1.0-5+b1.

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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// Copyright (C) 2012 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Library for obtaining information about international short phone numbers,
// such as short codes and emergency numbers. Note most commercial short
// numbers are not handled here, but by the phonenumberutil.

#ifndef I18N_PHONENUMBERS_SHORTNUMBERINFO_H_
#define I18N_PHONENUMBERS_SHORTNUMBERINFO_H_

#include <list>
#include <map>
#include <set>
#include <string>

#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/memory/scoped_ptr.h"

namespace i18n {
namespace phonenumbers {

using std::list;
using std::map;
using std::set;
using std::string;

class MatcherApi;
class PhoneMetadata;
class PhoneNumber;
class PhoneNumberUtil;

class ShortNumberInfo {
 public:
  ShortNumberInfo();
  ~ShortNumberInfo();

  // Cost categories of short numbers.
  enum ShortNumberCost {
    TOLL_FREE,
    STANDARD_RATE,
    PREMIUM_RATE,
    UNKNOWN_COST
  };

  // DEPRECATED: Anyone who was using it and passing in a string with whitespace
  // (or other formatting characters) would have been getting the wrong result.
  // You should parse the string to PhoneNumber and use the method
  // IsPossibleShortNumberForRegion(PhoneNumber, String). This method will be
  // removed in the next release.
  //
  // Check whether a short number is a possible number when dialled from a
  // region, given the number in the form of a string, and the region where the
  // number is dialed from.  This provides a more lenient check than
  // IsValidShortNumberForRegion.
  bool IsPossibleShortNumberForRegion(
      const string& short_number,
      const string& region_dialing_from) const;

  // Check whether a short number is a possible number when dialled from a
  // region, given the number in the form of a string, and the region where the
  // number is dialed from.  This provides a more lenient check than
  // IsValidShortNumberForRegion.
  bool IsPossibleShortNumberForRegion(
      const PhoneNumber& short_number,
      const string& region_dialing_from) const;

  // Check whether a short number is a possible number. If a country calling
  // code is shared by multiple regions, this returns true if it's possible in
  // any of them. This provides a more lenient check than IsValidShortNumber.
  // See IsPossibleShortNumberForRegion for details.
  bool IsPossibleShortNumber(const PhoneNumber& number) const;

  // DEPRECATED: Anyone who was using it and passing in a string with whitespace
  // (or other formatting characters) would have been getting the wrong result.
  // You should parse the string to PhoneNumber and use the method
  // IsValidShortNumberForRegion(PhoneNumber, String). This method will be
  // removed in the next release.
  //
  // Tests whether a short number matches a valid pattern in a region. Note
  // that this doesn't verify the number is actually in use, which is
  // impossible to tell by just looking at the number itself.
  bool IsValidShortNumberForRegion(
      const string& short_number,
      const string& region_dialing_from) const;

  // Tests whether a short number matches a valid pattern in a region. Note
  // that this doesn't verify the number is actually in use, which is
  // impossible to tell by just looking at the number itself.
  bool IsValidShortNumberForRegion(
      const PhoneNumber& short_number,
      const string& region_dialing_from) const;

  // Tests whether a short number matches a valid pattern. If a country calling
  // code is shared by multiple regions, this returns true if it's valid in any
  // of them. Note that this doesn't verify the number is actually in use,
  // which is impossible to tell by just looking at the number itself. See
  // IsValidShortNumberForRegion for details.
  bool IsValidShortNumber(const PhoneNumber& number) const;

  // DEPRECATED: Anyone who was using it and passing in a string with whitespace
  // (or other formatting characters) would have been getting the wrong result.
  // You should parse the string to PhoneNumber and use the method
  // GetExpectedCostForRegion(PhoneNumber, String). This method will be
  // removed in the next release.
  //
  // Gets the expected cost category of a short number when dialled from a
  // region (however, nothing is implied about its validity). If it is
  // important that the number is valid, then its validity must first be
  // checked using IsValidShortNumberForRegion. Note that emergency numbers are
  // always considered toll-free. Example usage:
  //
  // ShortNumberInfo short_info;
  // string short_number("110");
  // RegionCode region_code = RegionCode::FR();
  // if (short_info.IsValidShortNumberForRegion(short_number, region_code)) {
  //   ShortNumberInfo::ShortNumberCost cost =
  //       short_info.GetExpectedCostForRegion(short_number, region_code);
  //   // Do something with the cost information here.
  // }
  ShortNumberCost GetExpectedCostForRegion(
      const string& short_number,
      const string& region_dialing_from) const;

  // Gets the expected cost category of a short number when dialled from a
  // region (however, nothing is implied about its validity). If it is
  // important that the number is valid, then its validity must first be
  // checked using IsValidShortNumberForRegion. Note that emergency numbers are
  // always considered toll-free. Example usage:
  //
  // PhoneNumber number;
  // phone_util.Parse("110", "US", &number);
  // ...
  // string region_code("CA");
  // ShortNumberInfo short_info;
  // if (short_info.IsValidShortNumberForRegion(number, region_code)) {
  //   ShortNumberInfo::ShortNumberCost cost =
  //       short_info.GetExpectedCostForRegion(number, region_code);
  //   // Do something with the cost information here.
  // }
  ShortNumberCost GetExpectedCostForRegion(
      const PhoneNumber& short_number,
      const string& region_dialing_from) const;

  // Gets the expected cost category of a short number (however, nothing is
  // implied about its validity). If the country calling code is unique to a
  // region, this method behaves exactly the same as GetExpectedCostForRegion.
  // However, if the country calling code is shared by multiple regions, then
  // it returns the highest cost in the sequence PREMIUM_RATE, UNKNOWN_COST,
  // STANDARD_RATE, TOLL_FREE. The reason for the position of UNKNOWN_COST in
  // this order is that if a number is UNKNOWN_COST in one region but
  // STANDARD_RATE or TOLL_FREE in another, its expected cost cannot be
  // estimated as one of the latter since it might be a PREMIUM_RATE number.
  //
  // For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in
  // Canada, the expected cost returned by this method will be STANDARD_RATE,
  // since the NANPA countries share the same country calling code.
  //
  // Note: If the region from which the number is dialed is known, it is highly
  // preferable to call GetExpectedCostForRegion instead.
  ShortNumberCost GetExpectedCost(const PhoneNumber& number) const;

  // Gets a valid short number for the specified region.
  string GetExampleShortNumber(const string& region_code) const;

  // Gets a valid short number for the specified cost category.
  string GetExampleShortNumberForCost(const string& region_code,
                                      ShortNumberCost cost) const;

  // Returns true if the number might be used to connect to an emergency service
  // in the given region.
  //
  // This method takes into account cases where the number might contain
  // formatting, or might have additional digits appended (when it is okay to do
  // that in the region specified).
  bool ConnectsToEmergencyNumber(const string& number,
                                 const string& region_code) const;

  // Returns true if the number exactly matches an emergency service number in
  // the given region.
  //
  // This method takes into account cases where the number might contain
  // formatting, but doesn't allow additional digits to be appended.
  bool IsEmergencyNumber(const string& number,
                         const string& region_code) const;

  // Given a valid short number, determines whether it is carrier-specific
  // (however, nothing is implied about its validity). If it is important that
  // the number is valid, then its validity must first be checked using
  // IsValidShortNumber or IsValidShortNumberForRegion.
  bool IsCarrierSpecific(const PhoneNumber& number) const;

 private:
  const PhoneNumberUtil& phone_util_;
  const scoped_ptr<const MatcherApi> matcher_api_;

  // A mapping from a RegionCode to the PhoneMetadata for that region.
  scoped_ptr<map<string, PhoneMetadata> >
      region_to_short_metadata_map_;

  // In these countries, if extra digits are added to an emergency number, it no
  // longer connects to the emergency service.
  scoped_ptr<set<string> >
      regions_where_emergency_numbers_must_be_exact_;

  const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegion(
      const string& region_code) const;

  bool RegionDialingFromMatchesNumber(const PhoneNumber& number,
      const string& region_dialing_from) const;

  // Helper method to get the region code for a given phone number, from a list
  // of possible region codes. If the list contains more than one region, the
  // first region for which the number is valid is returned.
  void GetRegionCodeForShortNumberFromRegionList(
      const PhoneNumber& number,
      const list<string>& region_codes,
      string* region_code) const;

  bool MatchesEmergencyNumberHelper(const string& number,
                                    const string& region_code,
                                    bool allow_prefix_match) const;

  DISALLOW_COPY_AND_ASSIGN(ShortNumberInfo);
};

}  // namespace phonenumbers
}  // namespace i18n

#endif  // I18N_PHONENUMBERS_SHORTNUMBERINFO_H_