summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-07-28 16:05:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-07-28 16:05:40 +0000
commitf2634ca980bbd18a2bc0793d25a6cee70413b846 (patch)
tree7049356b06fcdcdaf9dbae476f55a43942e7c25f
parentInitial commit. (diff)
downloadgeoip-f2634ca980bbd18a2bc0793d25a6cee70413b846.tar.xz
geoip-f2634ca980bbd18a2bc0793d25a6cee70413b846.zip
Adding upstream version 1.6.12.upstream/1.6.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.clang-format5
-rw-r--r--.gitignore49
-rw-r--r--.travis.yml36
-rw-r--r--AUTHORS1
-rw-r--r--COPYING504
-rw-r--r--ChangeLog973
-rw-r--r--GeoIP.spec.in76
-rw-r--r--INSTALL370
-rw-r--r--LICENSE28
-rw-r--r--Makefile.am15
-rw-r--r--Makefile.vc84
-rw-r--r--NEWS.md50
-rw-r--r--README.OSX53
-rw-r--r--README.dev.md35
-rw-r--r--README.md248
-rw-r--r--apps/Makefile.am18
-rw-r--r--apps/Makefile.vc25
-rw-r--r--apps/geoiplookup.c375
-rw-r--r--apps/geoiplookup6.c195
-rw-r--r--appveyor.yml20
-rwxr-xr-xbootstrap19
-rw-r--r--configure.ac77
-rw-r--r--data/GeoIP.datbin0 -> 3960 bytes
-rwxr-xr-xdev-bin/clang-format-all.sh15
-rwxr-xr-xdev-bin/release.sh61
-rw-r--r--geoip.icobin0 -> 3062 bytes
-rw-r--r--geoip.pc.in12
-rw-r--r--get_ver.awk14
-rw-r--r--libGeoIP/GeoIP.c2766
-rw-r--r--libGeoIP/GeoIP.h444
-rw-r--r--libGeoIP/GeoIPCity.c330
-rw-r--r--libGeoIP/GeoIPCity.h72
-rw-r--r--libGeoIP/GeoIP_deprecated.c248
-rw-r--r--libGeoIP/GeoIP_internal.h23
-rw-r--r--libGeoIP/Makefile.am19
-rw-r--r--libGeoIP/Makefile.vc47
-rw-r--r--libGeoIP/pread.c97
-rw-r--r--libGeoIP/pread.h27
-rw-r--r--libGeoIP/regionName.c10197
-rw-r--r--libGeoIP/timeZone.c1775
-rw-r--r--m4/.placeholder0
-rw-r--r--man/Makefile.am26
-rw-r--r--man/geoiplookup.1.in37
-rw-r--r--man/geoiplookup6.1.in42
-rwxr-xr-xregioncode/generate_regionName.pl176
-rw-r--r--regioncode/region_codes.csv4108
-rw-r--r--test/Makefile.am38
-rw-r--r--test/Makefile.vc29
-rw-r--r--test/benchmark.c183
-rw-r--r--test/city_test.txt2
-rw-r--r--test/country_test.txt61
-rw-r--r--test/country_test2.txt61
-rw-r--r--test/country_test_name.txt1
-rw-r--r--test/fail_test.txt1
-rw-r--r--test/proxy_test.txt17
-rw-r--r--test/region_test.txt24
-rw-r--r--test/test-geoip-asnum.c56
-rw-r--r--test/test-geoip-city.c77
-rw-r--r--test/test-geoip-domain.c67
-rw-r--r--test/test-geoip-invalid-file.c29
-rw-r--r--test/test-geoip-isp.c58
-rw-r--r--test/test-geoip-netspeed.c59
-rw-r--r--test/test-geoip-org.c67
-rw-r--r--test/test-geoip-region.c118
-rw-r--r--test/test-geoip.c146
-rwxr-xr-xtimezone/generate_timeZone.pl75
-rw-r--r--timezone/timezone.txt717
67 files changed, 25678 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a72e2df
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,5 @@
+BasedOnStyle: LLVM
+IndentWidth: 4
+BinPackArguments: false
+BinPackParameters: false
+IndentCaseLabels: true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..67550b8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,49 @@
+*.la
+*.lo
+*.o
+*.swp
+*~
+.DS_Store
+.deps
+.libs
+/m4
+GeoIP-*.tar.gz
+GeoIP.spec
+Makefile
+Makefile.in
+aclocal.m4
+apps/geoiplookup
+apps/geoiplookup6
+apps/geoipupdate
+autom4te.cache
+compile
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+geoip.pc
+install-sh
+libtool
+ltmain.sh
+man/geoiplookup.1
+man/geoiplookup6.1
+man/geoipupdate.1
+missing
+test-driver
+test/benchmark
+test/test-geoip
+test/test-geoip-asnum
+test/test-geoip-city
+test/test-geoip-domain
+test/test-geoip-invalid-file
+test/test-geoip-invalid-file.log
+test/test-geoip-invalid-file.trs
+test/test-geoip-isp
+test/test-geoip-netspeed
+test/test-geoip-org
+test/test-geoip-region
+test/test-geoip.log
+test/test-geoip.trs
+test/test-suite.log
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..305b113
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,36 @@
+---
+sudo: false
+addons:
+ coverity_scan:
+ project:
+ description: Build submitted via Travis CI
+ name: maxmind/geoip-api-c
+ notification_email: dev-ci@maxmind.com
+ build_command_prepend: ./configure; make clean
+ build_command: make -j 4
+ branch_pattern: .*coverity.*
+language: c
+compiler:
+ - clang
+ - gcc
+env:
+ global:
+ secure: |-
+ bMDurejTvGTXwVcD/fTij5xkhqOzwHSFQHxP1tLGBfemvRQ/FgX2E2M8rWaD
+ KbgKCgTSNB7fKtAvkFP+uteJ3/RY4HrQxlkY4/lG6tqlYJDCyLjxC0LLU5GE
+ hfW0iiu9ozNtJzQ2A2O3mgTUmN4+ay25VMTfoAYALvT67qpW+NM=
+before_script:
+ - ./bootstrap
+ - CFLAGS="-Wall -Wextra -Werror -Wno-unused-parameter" ./configure
+ - make
+script:
+ - make check
+notifications:
+ email:
+ on_failure: always
+ on_success: change
+ recipients:
+ - dev-ci@maxmind.com
+ slack:
+ rooms:
+ secure: "WfyHKjt7GkS4U1tFmleDAwXEcs99LW33Gp0p8OwIPaV8ZI7WXZTw1ClJwr+Bpa9TDgfl26HX6IBcgX4ef/SAGvfLkYdEK8czYA2iT7VRudNQb/2oXdlwFz3hgY7yaROohkUgjo+IMq2efWFix7Z149ynex2k78Qp5g4GdZOLz48=\n"
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..539a706
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+T.J. Mather <geoipapi@maxmind.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..602bfc9
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..b6b2ca0
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,973 @@
+1.6.12 2018-01-17
+
+* Populate metro and area code when performing lookups in IPv6 City databases.
+ Previously this was only done when using IPv4 City databases.
+
+1.6.11 2017-05-15
+
+* Fix use of a NULL pointer when opening a corrupt database with
+ `GeoIP_open`. Reported by Stephan Zeisberg. GitHub #87.
+
+1.6.10 2017-03-29
+
+* GeoIP_database_info now returns the full version string rather than
+ incorrectly truncating it. GitHub #79.
+* This API is now distributed with a small test copy of GeoIP.dat rather than
+ a full copy.
+* Fix issue where Visual Studio 2015 was optimizing out initialization code.
+ Reported and fixed by Scott Godin. GitHub #81.
+* Fix test/benchmark on Windows. Gisle Vanem. GitHub #75.
+
+1.6.9 2016-01-11
+
+* Fix a regression introduced in version 1.6.8, which caused
+ GeoIP_database_info to erroneously return NULL.
+
+1.6.8 2016-01-11
+
+* Allow compilation on older systems by relaxing the autoconf and automake
+ minimum versions. Thank you, Jose Rubio!
+* Avoid potential problems in multi-threaded environments by consistently using
+ pread() rather than read().
+* Fix various small issues reported by clang's static analyser.
+
+1.6.7 2015-10-30
+
+* Fixed a MSVC parser stack overflow when parsing `regionName.c` and
+ `timeZone.c`. Fix by elliotlo. GitHub #64.
+* Updated region codes and timezones.
+* When using `GEOIP_MEMORY_CACHE` with an invalid database file, the search
+ tree traversal could attempt to read memory outside of the memory allocated
+ for the memory cache, resulting in a segmentation fault. A check was added
+ to ensure that the traversal code does not try to read beyond the end of the
+ file, whether in memory, memory mapped, or on disk.
+* Previously the return values from file reads were ignored. We now check
+ these values to ensure that there were no errors.
+
+
+1.6.6 2015-07-28
+
+* Replaced usage of deprecated fileno, read, and lseek on Visual Studio 2005+
+ with their ISO C++ conformant replacements. (Fix by ClaudiuHKS. GitHub #55.)
+* A warning about using a double as a float was fixed. (Fix by ClaudiuHKS.
+ GitHub #56.)
+* Fixed segfault when doing a lookup on an empty database. (Fix by NesoK.
+ GitHub #62.)
+* Fixed a memcheck error from valgrind in the `_check_mtime`
+ function. (Reported by yurivct. GitHub #60.)
+* Fixed `_check_mtime` to check the return value of `gettimeofday` rather than
+ just assuming it worked.
+
+
+1.6.5 2015-02-25
+
+* A segmentation fault in `geoiplookup` was fixed when the utility was passed
+ an invalid database. (Reported in Red Hat bug #1180874.)
+* Additional validation was added for validation of the size used in the
+ creation of the index cache. (Based on discussion in Red Hat bug #832913.)
+* Changed the code to only look up country codes by using functions which
+ ensure that we do not try to look past the end of an array. (Reported by
+ Ivan Sorokin. GitHub #53)
+
+
+1.6.4 2015-01-12
+
+* Update Fips codes (Boris Zentner)
+* Several issues with the MinGW build were fixed. (Thomas Pöchtrager. Github
+ #46.)
+* Use a constructor in pread.c to ensure the critical section is always
+ initialized. (Thomas Pöchtrager. Github #47.)
+* Added missing include of `io.h` on Windows. (Thomas Pöchtrager. Github #49.)
+* Fixed `configure` warning that `'missing' script is too old or missing`.
+ (Reported by Floren Munteanu. Github #33.)
+* Previously `nmake /f Makefile.vc clean` would fail on Windows. This was
+ fixed.
+* Obsolete win32 and NetWare make files were removed.
+* Numerous documentation updates. (Reported by Thomas Pöchtrager. GitHub #48.)
+
+
+1.6.3 2014-10-29
+
+* Added a GEOIP_SILENCE flag. Include this flag when calling GeoIP_open to
+ prevent any messages from being written to stderr. (Philip Prindeville
+ and Boris Zentner)
+* Mitigate a possible race condition when running under threads in the
+ GeoIP_cleanup function. (Anthon Pang)
+* Added some recommendations to the docs on using this library in a
+ threaded application. (Boriz Zentner)
+* Fixed some bugs discovered by coverity, including failure to check some
+ system call return values and making sure all strings are
+ null-terminated. (Boris Zentner)
+
+
+1.6.2 2014-07-08
+
+* Two files required for building on Win32 were missing from the 1.6.1
+ release. These files were added. There are no changes affecting other
+ platforms. (Boris Zentner)
+
+
+1.6.1 2014-06-26
+
+* Improve Win32 support (Evan Hunt)
+* Update FIPS codes (Boris Zentner)
+
+
+1.6.0 2013-10-29
+
+* Remove geoipupdate (Boris Zentner)
+
+
+1.5.2 2013-10-29
+
+* Update region and time zones (Boris Zentner)
+* Fix benchmark script (Boris Zentner)
+* Remove autogenerated files ltmain.sh, man/geoip*.1 (Boris Zentner)
+* Explain how to download free geolite databases in the README.md and
+ GeoIP.conf.default (Boris Zentner)
+* geoipupdate returns 1 on error 0 on success instead of the error code
+ (Boris Zentner)
+* README is replaced by README.md (Gregory Oschwald)
+* Add support for OS X Mavericks (Boris Zentner)
+
+
+1.5.1 2013-05-14
+
+* Update time_zone for Ontario, Canada (Boris Zentner)
+* geoiplookup and geoiplookup6 exit code is 0 when user asked for help
+ (Jan Safranek)
+* Added -h option to geoiplookup6 (Jan Safranek)
+* Do not load the database file if nodes and file size do not make
+ sense. (Boris Zentner)
+* Keep README and man pages in pure ascii. (Boris Zentner)
+* It doesn't make sense to use GEOIP_INDEX_MODE with small databases
+ like GEOIP_COUNTRY_EDITION. Instead of undefined behaviour we handle
+ it silently as GEOIP_MEMORY_MODE (Boris Zentner)
+* Update FIPS codes for Greece (Boris Zentner)
+
+
+1.5.0 2013-02-21
+
+* Rename custom_directory to GeoIP_custom_directory. (Boris Zentner)
+* Make sure the database match the requested type. This is helpful for
+ Databases with the same default name and the general geoiplookup form
+ (geoiplookup without a specific database) (Boris Zentner)
+* apps/geoiplookup6.c use the ipnum instead of the hostname for lookups.
+ (Boris Zentner)
+* Use configure.ac instead of configure.in (Boris Zentner)
+* Region lookup is a bit faster (Boris Zentner)
+* Add pkg-config file (Bastien Nocera)
+* Updates required to build a Windows DLL under MinGW (Gerald Combs)
+* Make API thread safe (Boris Zentner)
+* geoiplookup's default charset is UTF8
+ -l change the charset back to iso8859-1 (Boris Zentner)
+* geoipupdate skips \r otherwise it might be part of the last
+ product_id (Boris Zentner)
+* Update time zones (Boris Zentner)
+* Update Region codes (Boris Zentner)
+* Remove the unused CITYCONFIDENCE* database types (Boris Zentner)
+* bootstrap rebuilds ltmain.sh (Boris Zentner)
+* Update README.OSX for Lion (Boris Zentner)
+* Change Macedonia to Macedonia, The Former Yugoslav Republic of
+ (Boris Zentner)
+* Add region_name to geoiplookup GEOIP_CITY_EDITION_REV1 (Boris Zentner)
+* Add region_name to geoiplookup GEOIP_CITY_EDITION_REV0 (Chris Johnson)
+* Add a --disable-data-files option. This allows you to build and install
+ the library without having a data/GeoIP.dat file. This is useful when
+ building the library from a checkout of the source tree, rather than a
+ tarball (Dave Rolsky)
+* Add GEOIP_ACCURACYRADIUS_EDITION and GEOIP_ACCURACYRADIUS_EDITION_V6
+ (Boris Zentner)
+* Add more database types GEOIP_COUNTRYCONF_EDITION,
+ GEOIP_CITYCONF_EDITION, GEOIP_REGIONCONF_EDITION and
+ GEOIP_POSTALCONF_EDITION (Boris Zentner)
+* Fix default filenames for GEOIP_NETSPEED_EDITION_REV1 and
+ GEOIP_NETSPEED_EDITION_REV1_V6 (Boris Zentner)
+
+
+1.4.8
+
+* Fix GEOIP_DOMAIN_EDITION_V6 (Boris Zentner)
+* Add new Datatypes GEOIP_NETSPEED_EDITION_REV1_V6 and
+ GEOIP_NETSPEED_EDITION_REV1 (Boris Zentner)
+* Fix possible directory traversal weakness in geoipupdate-pureperl.pl with
+ malicious update server (Boris Zentner)
+* Fix GEOIP_ORG_EDITION_V6 and GEOIP_ISP_EDITION_V6 (Boris Zentner)
+
+
+1.4.7 2011-12-19
+
+* Upd timezone.c Add SX, BQ and CW remove AN and FX (Boris Zentner)
+* Add support for the new types in geoiplookup6 (Boris Zentner)
+* Add new database types GEOIP_CITY_EDITION_REV0_V6,
+ GEOIP_CITY_EDITION_REV1_V6, GEOIP_DOMAIN_EDITION_V6,
+ GEOIP_ORG_EDITION_V6 and GEOIP_ISP_EDITION_V6 (Boris Zentner)
+* Remove AN and FX. Add SX, BQ and CW (Boris Zentner)
+* Fix possible segfault in geoipupdate if the connection disappear
+ unexpected. (Boris Zentner)
+* Add sanity check for geoipupdate-pureperl.pl (Boris Zentner)
+* Add GEOIP_USERTYPE_EDITION and GEOIP_USERTYPE_EDITION_V6
+ datatypes (Boris Zentner)
+* Add new functions GeoIP_is_private_ipnum_v4 and GeoIP_is_private_v4
+ (Boris Zentner)
+* Add new functions GeoIP_teredo and GeoIP_enable_teredo.
+ teredo is enabled by default (Boris Zentner)
+* Fix output of geoiplookup for unknown or private regions.
+ (Boris Zentner)
+* Fix geoipupdate-pureperl.pl to accept more product codes.
+ (Boris Zentner)
+* Fix minor output issue in geoipupdate -v (Boris Zentner)
+* Add support for various databases. (Boris Zentner)
+* Add experimental teredo support (Boris Zentner)
+* Fix possible buffer overflow in conjunction with
+ http_proxies (Elso Andras)
+* Remove memcpy/bcopy macro for BSD (Boris Zentner)
+* Add GeoIP_lib_version and GeoIP_cleanup (Ladar Levison)
+* Upd Makefile.vc (Thomas Winzig)
+* Fix typo in DK,18,Midtjylland (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes 20100810 (Boris Zentner)
+* Fix continent codes (Boris Zentner)
+* Fix 3letter country codes for ATA, BVT, IOT, CXR, CCK, ATF, HMD,
+ MYT, SGS and UMI (Boris Zentner)
+* Fix typo/segfault in GeoIP_id_by_name_v6 (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes 20100529 (Boris Zentner)
+* Remove buffered IO functions, to fix issues with dup'ed file
+ descriptors (Boris Zentner)
+* Fix very minor memleak in geoipupdate (Boris Zentner)
+* Add GEOIP_CITYCONFIDENCEDIST_EDITION, GEOIP_LARGE_COUNTRY_EDITION
+ and GEOIP_LARGE_COUNTRY_EDITION_V6 database types (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes 20100422 (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes 20100420 (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes 20100221 (Boris Zentner)
+* Add missing timezones (Boris Zentner)
+* Add missing include for Windows 2000 (Jaap Keute)
+* 'GeoIP Database up to date' and 'Updated database' prints to stdout
+ instead of stderr (Boris Zentner)
+* Add missing GeoIPRecord_delete to geoiplookup.c (Piotr Kaczuba)
+* Add some IPv4 helper functions
+ unsigned long GeoIP_addr_to_num(const char *addr);
+ char * GeoIP_num_to_addr(unsigned long ipnum); (Boris Zentner)
+* Fix default name for the accuracy radius database to GeoIPDistance.dat (Boris Zentner)
+* Add GEOIP_CITYCONFIDENCE_EDITION database type. (Boris Zentner)
+* geoiplookup use GeoIPDistance.dat files if avail (Boris Zentner)
+* Fix geoiplookup/geoiplookup6 output, when the databaseinfo string is
+ not avail. (Boris Zentner)
+* Change continent code for RU from AS to EU (Boris Zentner)
+* Add GEOIP_ACCURACYRADIUS_EDITION database type. (Boris Zentner)
+* Add GEOIP_LOCATIONA_EDITION the database to map back from binary to
+ the csv database (Boris Zentner)
+* Change Turkey's continent code from Asia to Europe (Boris Zentner)
+* Rename _iso_8859_1__utf8 to _GeoIP_iso_8859_1__utf8 (Boris Zentner)
+* GEOIP_ORG_EDITION, GEOIP_ISP_EDITION, GEOIP_DOMAIN_EDITION and
+ GEOIP_ASNUM_EDITION databases return UTF8 results, if gi->charset is set
+ to GEOIP_CHARSET_UTF8 (Boris Zentner)
+* Avoid unnecesary call to gettimeofday when GEOIP_CHECK_CACHE is not set (John Douglass)
+* Delayed loading of changed database files for 60 seconds. To avoid
+ reading halve written databases (Boris Zentner)
+* Update README.OSX for Leopard and Snow Leopard (Boris Zentner)
+* Add more IPv6 functions (Boris Zentner)
+ const char *GeoIP_country_code_by_addr_v6 (GeoIP* gi, const char *addr);
+ const char *GeoIP_country_code_by_name_v6 (GeoIP* gi, const char *host);
+ const char *GeoIP_country_code3_by_addr_v6 (GeoIP* gi, const char *addr);
+ const char *GeoIP_country_code3_by_name_v6 (GeoIP* gi, const char *host);
+ const char *GeoIP_country_name_by_addr_v6 (GeoIP* gi, const char *addr);
+ const char *GeoIP_country_name_by_name_v6 (GeoIP* gi, const char *host);
+* Make sure that GeoIP_*_v6 functions refuse GEOIP_PROXY_EDITION and
+ GEOIP_NETSPEED_EDITION databases (Boris Zentner)
+* Update libGeoIP/regionName.c with FIPS codes from 20090723 (Boris Zentner)
+* Fix geoipupdate's -v option to not change the license filename (Thom May)
+* Fix geoipupdate's exit code (Thom May)
+* Add support for ASNUM_EDITION (Boris Zentner)
+* Fix -i output for larger values, sign issue (Boris Zentner)
+* Add -i flag for more information on netmask, range_by_ip and the current network range (Boris Zentner)
+* Add support for DOMAIN_EDITION database type (Boris Zentner)
+* Fix apps/geoipupdate-pureperl.pl output layer on W32 (Boris Zentner)
+
+
+1.4.6 2009-02-25
+
+* Fix geoipupdate's my_printf function (Boris Zentner)
+* Fix typo in apps/geoipupdate-pureperl.pl replace PerlIO::Gzip with PerlIO::gzip (Boris Zentner)
+* Update region codes in libGeoIP/regionName.c (Boris Zentner)
+* Fix regioncode/generate_regionName.pl to handle regioncodes with ',' correct (Boris Zentner)
+* Update fips codes 20090201 (Boris Zentner)
+* Fix unicode builds on WIN32 and eliminate some warnings (Stu Redman)
+* Fix sign error in _iso_8859_1__utf8 for PPC64 (Boris Zentner)
+* Change WIN32 to _WIN32, since _WIN32 is defined by default. _WIN32 is also defined for WIN64 machines (Boris Zentner)
+! Remove the WSAStartup call from GeoIP_open. All Applications need to call WSAStartup and WSACleanup to initialize the Windows Socket library. Before they use any of the GeoIP_*_by_name functions. (Boris Zentner)
+* geoiplookup and test-geoip-* output N/A instead of (null) (Boris Zentner)
+* Silence various warnings. (Boris Zentner)
+* Add more timezone region's for Australia
+* Fix possible segfault in apps/geoiplookup with null pointers in non gnu printf implementations for example solaris (Boris Zentner)
+* Add README.OSX to build fat binaries easy (Boris Zentner)
+* Silence vasprintf warning via AC_GNU_SOURCE (Boris Zentner)
+* Add several Makefiles to build a static GeoIP.lib for w32 (Stanislaw Pusep and Randy Kobes)
+* Silence signedness warnings (Peter Volkov)
+* Remove --with-city configure option. (Boris Zentner)
+* Remove configure's --with-dbdir option. Use the similar --datadir instead (Peter Volkov)
+* Various autotools improvements and cleanups. Including parallel
+ build fix (Peter Volkov)
+* Fix libGeoIP/timeZone.c (Martin Haller)
+* Fix timezone/generate_timeZone.pl (Boris Zenter)
+* Sync FIPS codes again Jan 14th, 2009 (Boris Zentner)
+* Fix CA,NL regioncode. (Boris Zentner)
+* Change logic in generate_regionName.pl and GeoIP_region_name_by_code to handle any mixture of two letter fips codes matching [A-Z0-9]{2} the change allow GZ and WE region codes (Boris Zentner)
+* Sync regionName.c with http://www.maxmind.com/app/fips10_4 from Dec 17th, 2008 (Boris Zentner)
+* Fix _GeoIP_lookupaddress for 64bit big endian systems like ppc64 (Peter Volkov)
+* Add proper WIN32/64 support (Gerald Combs)
+* Escape - in all manpages (Patrick Matthäi)
+* Add manpage for geoiplookup6 (Boris Zentner)
+* Fix -d command line option (Klaus Heinz)
+* GeoIPUpdate.c use vasprintf if avail, otherwise try vsnprintf and sprintf (Boris Zentner)
+* avoid pre/postincrement and assignment on the same variable (Boris Zentner)
+
+
+1.4.5 2008-09-16
+
+* metro_code replace the depreciated dma_code field (Boris Zentner)
+* Add new function GeoIP_range_by_ip_delete
+ r = GeoIP_range_by_ip(gi, '24.24.24.24');
+ ...
+ GeoIP_range_by_ip_delete(r); (Boris Zentner)
+* Fix small memoryleak and wrap around in GeoIP_range_by_ip (Boris Zentner)
+* CHECK_CACHE stat the database file not faster than once a second anymore (Patrick McManus)
+* Fixed a typo in the geoipupdate(1) manpage and also an non-existent path on Debian (Patrick Matthäi)
+* Fixes two little format errors (hyphen used as minus sign) in both manpages (Patrick Matthäi)
+* Sync regionName.c with a recent fips code list (Boris Zentner)
+* Fix segfault when open failed for a custom file (-f) (Boris Zentner)
+* Fix sync geoiplookup's man page with the code (Klaus Heinz)
+* remove unused code from GeoIP_country_name_by_addr and GeoIP_country_code3_by_addr (Boris Zentner)
+* Fix geoiplookup and geoiplookup6 to distinguish between failed namelookups and unknown ips (Boris Zentner)
+* add geoiplookup6 that can handle the new database type GEOIP_COUNTRY_EDITION_V6 (Boris Zentner)
+* add new functions to handle ipv6:
+ GEOIP_API const char *GeoIP_country_name_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API const char *GeoIP_country_code_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API const char *GeoIP_country_code3_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API char *GeoIP_org_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API char *GeoIP_org_by_addr_v6 (GeoIP* gi, const char *addr);
+ GEOIP_API char *GeoIP_org_by_name_v6 (GeoIP* gi, const char *name);
+ GEOIP_API int GeoIP_id_by_addr_v6 (GeoIP* gi, const char *addr);
+ GEOIP_API int GeoIP_id_by_name_v6 (GeoIP* gi, const char *host);
+ GEOIP_API int GeoIP_id_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API GeoIPRegion * GeoIP_region_by_addr_v6 (GeoIP* gi, const char *addr);
+ GEOIP_API GeoIPRegion * GeoIP_region_by_name_v6 (GeoIP* gi, const char *host);
+ GEOIP_API GeoIPRegion * GeoIP_region_by_ipnum_v6 (GeoIP *gi, geoipv6_t ipnum);
+ GEOIP_API void GeoIP_assign_region_by_inetaddr_v6(GeoIP* gi, geoipv6_t inetaddr, GeoIPRegion *gir);
+ GEOIP_API char *GeoIP_name_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
+ GEOIP_API char *GeoIP_name_by_addr_v6 (GeoIP* gi, const char *addr);
+ GEOIP_API char *GeoIP_name_by_name_v6 (GeoIP* gi, const char *name);
+
+ # allowed input for addr
+ 2001:4860:0:1001::68
+ ::85.8.93.71
+ ::1
+ ::5508::5d47
+ ::ffff:5508::5d47
+
+ # allowed input for host
+ ipv6.google.com
+ 2001:4860:0:1001::68
+ ::85.8.93.71
+ ::1
+ ::5508::5d47
+ ::ffff:5508::5d47
+ (Boris Zentner)
+* Fix geoiplookup usage string (add -d -f) (Boris Zentner)
+* Added GeoIP_range_by_ip, returns the start and end IP address for the range containing the IP address.
+ This range has a constant value in the GeoIP database.
+* Add geoipupdate-pureperl.pl a alternative geoipupdate version. with Proxy Server support via via the "http_proxy" environment variable. Easy to customize. (Boris Zentner)
+* Add WIN64 since WIN32 is not defined on WIN64 Systems (Boris Zentner)
+* Fix WIN32 compilation by encircle all MMAP functions with #ifdef WIN32 #endif pairs. MMAP is not avail in W32 (Boris Zentner)
+* Update timezone/generate_timeZone.pl (Boris Zentner)
+* Update libGeoIP/timeZone.c (Boris Zentner)
+* Added GeoIP_printf and GeoIP_fprintf as a experimental feature to
+ libGeoIPUpdate. (Boris Zentner, Andrew Droffner)
+* Added cast in _iso_8859_1__utf8 function to fix NetWare/Win32 compilation issue (Guenter Knauf)
+* Add HTTP Proxy Server support for geoipupdate via the "http_proxy"
+ environment variable.
+ ie: export http_proxy="http://proxy-hostname:port"
+ (Andrew Droffner, Derek Nicol)
+* Notice, that __YOU__ need to free the results of
+
+ GeoIP_database_info
+ GeoIP_name_by_ipnum
+ GeoIP_name_by_addr
+ GeoIP_name_by_name
+ GeoIP_org_by_ipnum
+ GeoIP_org_by_addr
+ GeoIP_org_by_name
+
+ not libgeoip
+ (Boris Zentner, Andrew Cheung)
+* Fixed segfault with geoiplookup, if used with a custom_file database, that
+ could not be opened. (Boris Zentner)
+* Add Usage info for options -f and -d in geoipupdate (Boris Zentner)
+* Fixed segfault with geoipupdate when called with a illformed license file
+ (Boris Zentner)
+* Update add more timezones to GeoIP_time_zone_by_country_and_region
+ (Boris Zentner)
+* Add array access functions so programs can avoid accessing the
+ arrays directly which whould break binary compatability (Ludwig Nussel at SUSE)
+* Updated README to state API is only thread-safe if GEOIP_CHECK_CACHE is not used
+
+
+1.4.4 2008-1-21
+
+* Updated original geoipupdate to return "Invalid product ID or subscription expired"
+* Added BL/Saint Barthelemy, MF/Saint Martin (ISO-3166-1 additions)
+* Check for illegal IP strings, return 0 if IP is not well formed IPv4 e.g. 1.2.3.4.5 and 1.2.3
+* Clarified that while core GeoIP library is LGPL, libGeoIPUpdate depends on md5.c and types.h which are GPL.
+* speedup the conversion from ipstring to ipnum in _GeoIP_addr_to_num. Doubles the speed of GEOIP_MEMORY_CACHE and GEOIP_MMAP_CACHE
+* Added new mmap shared memory caching option, GEOIP_MMAP_CACHE (Peter Shipley, LookSmart)
+ - mmaps: our maps are shared, but we need only private readonly pages
+
+
+1.4.3 2007-8-30
+
+! CHANGE with geoiplookup facility: -v flag now returns database info for all databases, not just GeoIP Country
+* Added ability to get netmask of network block from last lookup using GeoIP_last_netmask
+* Fixed GeoIP_database_info bug with GeoLite City
+* Replaced 4 with sizeof(char*) to fix issues with geoipupdate on 64 Bit machines
+* Added GeoIP_set_charset function - enables UTF8 output of city name if GEOIP_CHARSET_UTF8 flag is passed
+to GeoIP_set_charset
+* Fixed segfault issue if calling GeoIP_db_avail before opening a database
+* Added continent_code to GeoIP City's record struct (Frank Mather)
+
+
+1.4.2 2007-2-8
+
+* Added -d flag to enable custom path for geoipupdate utility program (Frank Mather)
+* Replaced _WIN32 with WIN32 since WIN32 is already set by compilers
+* Moved var definitions to top of code, defined size_t (Guenter Knauf)
+* Added Makefile.win32, Makefile.netware, get_ver.awk, geoip.ico to EXTRA_DIST in Makefile.am (Guenter Knauf)
+
+
+1.4.1 2007-1-2
+
+* Replaced CS/Serbia and Montenegro with RS/Serbia, removed ZR/Zaire, added ME/Montenegro
+* Added AX/Aland Islands, GG/Guernsey, IM/Isle of Man, JE/Jersey (ISO-3166-1 changes)
+* Added GeoIP_time_zone_by_country_and_region, to lookup zoneinfo timezone by country and region (Frank Mather)
+* Added GeoIP_region_name_by_code, to lookup region name from region code (Frank Mather)
+* added -f and -d flags to enable custom paths for geoiplookup utility program (Frank Mather)
+* Added benchmarks for GeoIP Region and City in test/benchmark.c (Frank Mather)
+* Fixed build issue when using --as-needed flag (Diego 'Flameeyes' Pettenò)
+* Add sanity checking for filename returned by MaxMind.com server for geoipupdate filename
+ (Dean Gaudet, arctic.org)
+* Fixed memory leaks under error conditions, buffer overflow using sprintf,
+ and issue where a corrupted cache file could core dump the file
+ (Nick Galbreath, Right Media Inc)
+
+
+1.4.0 2006-8-7
+
+* Changed license from GPL to LGPL, so that PHP Extension can be included in PECL (Olivier Hill)
+* Rewrote GEOIP_CHECK_CACHE code, fixed numerous bugs
+ - CheckCache now works if GeoIP file is overwriten by mv command
+ - Fixed bug where CheckCache kept reloading in GEOIP_STANDARD_MODE
+ - Fixed segfault issue in GEOIP_MEMORY_CACHE mode
+ - Fixed garbage data appearing in GEOIP_INDEX_CACHE mode
+ - Fixed realloc in case realloc returns new memory block (Andre Morozov of Stone Steps)
+* Updated geoipupdate to print status messages for each database instead of just last database
+* Check that gi is not null before running code in GeoIP_delete
+* Fixed alpha-3 codes ordering, replaced TLS,TKM,TUN,TON with TKM,TUN,TON,TLS
+* TP/East Timor changed to TL/Timor-Leste, reflecting changes in ISO-3166
+
+* Added Netware and Windows makefiles (Guenter Knauf)
+* Fixed NetWare compiler issue with char block[block_size] declaration (Guenter Knauf)
+* Updated geoipupdate example to run weekly
+
+
+1.3.17 2006-5-14
+
+* Fixed headers for Windows/Netware compilation (Guenter Knauf)
+* Fixed Received Error -21 (Sanity check database_info string failed)
+ when running geoipupdate with GeoIP Country when UserId and
+ productIds were not specified. Bug was introduced in 1.3.15.
+
+
+1.3.16 2006-4-17
+
+* Fixed compliation error in GeoIPUpdate.c
+
+
+1.3.15 2006-4-14
+
+* Updated README documentation
+* Updated geoipupdate so that it writes file as it is uncompressed instead
+of storing entire GeoIP.dat file in memory (Frank Mather)
+* Updated geoiplookup so that it returns GeoIP Domain Name if available
+ (Frank Mather)
+* Updated geoipupdate so that it reports whether databases are updated
+in non-verbose mode (Frank Mather)
+
+
+1.3.14 2005-9-7
+
+* Check if byte, ushort, ulong, u16, u32 are defined in configure
+ script. Fixes compilation issue on FreeBSD systems.
+* Check for Big Endian byte order (needed for MD5 code in geoipupdate
+ to work properly on Mac OS X and other Big Endian processors)
+* Fixed GEOIP_CHECK_CACHE mode when used with GEOIP_STANDARD to
+ only refresh upon file change
+* Fixed memory leak when refreshing file in GEOIP_CHECK_CACHE mode
+* Updated ltmain.sh to support Debian GNU/k*BSD bug #315425 (Marek Habersack)
+* Added lookup functions using IP numeric representation as input (Frank Mather)
+* Removed geoipexport
+* Replaced Yugoslavia with Serbia and Montenegro
+* Updated geoiplookup to only perform country lookup once instead of twice by
+ using GeoIP_id_by_name
+
+
+1.3.13 2005-8-1
+
+* Fixed autoconf weirdness that resulted in libraries being
+ installed without .so suffix
+
+
+1.3.12 2005-7-19
+
+* Removed -lGeoIP from libGeoIPUpdate_la_LIBADD - fixes compilation error
+ if GeoIP isn't already installed (Thomas Steudten)
+
+
+1.3.11 2005-7-7
+
+* Fixed gcc warnings and bug. Use int
+ instead of char for checking the return value of getopt in geoipupdate.c.
+ Moved the internal functions to GeoIP_internal.h to get rid
+ of those 'implicit declaration' warnings. (Ludwig Nussel/SUSE)
+* Cleaned up name space by prefixing internal functions with
+ _GeoIP* (Ludwig Nussel/SUSE)
+* Memory Leak fix for GeoIP City if fread error
+* Added more verbose error messages for geoipupdate (Frank Mather)
+* Added check for zlib.h to configure.in
+
+
+1.3.10 2005-4-17
+
+* Added types.h to Makefile.am - fixes compilation error
+
+
+1.3.9 2005-4-14
+
+* fixed bug with GEOIP_INDEX_CACHE (Frank Mather)
+* fixed segfault issue if GeoIP.dat not found (Frank Mather)
+* Updated MD5 checksum code to use GnuPG code which works
+ on 64bit machines (Frank Mather)
+* Fixed memory leak in test-geoip-isp.c and test-geoip-org.c
+* Added support for GeoIP Domain Names in geoipupdate
+
+
+1.3.8 2004-11-7
+
+* Updated geoipupdate to report invalid userID and productID errors
+* Check if gethostbyname_r is version that returns int or is other version
+ - should fix compile errors on Solaris and FreeBSD
+* Updated URL to get license key, userId, and product Ids in conf/GeoIP.conf.default
+* Updated test case, removed www.asahi.com
+* Added support for GEOIP_INDEX_CACHE - which just caches
+ the most frequently access index portion of the database, resulting
+ in faster lookups than GEOIP_STANDARD, but less memory usage than
+ GEOIP_MEMORY_CACHE (Frank Mather)
+
+
+1.3.7 2004-10-5
+
+* Updated test case, removed www.bundesregierung.de added www.asahi.com
+
+
+1.3.6 2004-8-8
+
+* Check for gethostbyname_r support in configure (Mac OS X doesn't support gethostbyname_r)
+* Made GeoIP City code thread safe
+* Fixed bug with geoipupdate reading in product ids
+* Added support for GeoIP Netspeed geoipupdate
+* Fix memleak in lookupaddress (Ludwig Nussel/SUSE)
+* Add prototype for _full_path_to to make 64bit clean
+ (Ludwig Nussel/SUSE)
+* Add return values to test programs (Ludwig Nussel/SUSE)
+
+
+1.3.5 2004-7-5
+
+* Added more documentation to README file
+* Made GEOIP_CHECK_CACHE work with GEOIP_STANDARD mode - reloads filehandle
+ in case file changes.
+* Added GeoIP_country_code_by_ipnum and GeoIP_id_by_ipnum to use
+ existing ulong IP Address in numeric form instead of having to
+ convert it to string (Boris Hajduk)
+* Made code thread safe by replacing gethostbyname with gethostbyname_r
+
+
+1.3.4 2004-6-4
+
+* Fixed bug where *.gz file(s) didn't get removed after geoipupdate
+
+
+1.3.3 2004-6-2
+
+* Added support for NetSpeed lookup to geoiplookup
+* inet_addr patch for 64 bit systems (Thomas Steudten)
+* Added Support for automated downloads of GeoIP Region, City, ISP and
+ Organization databases (Frank Mather)
+* INADDR_NONE Patch for Solaris 9 (John Young)
+
+
+1.3.2 2004-4-20
+
+* Added support for Maxmind NetSpeed
+
+* MinGW patch from Stanislaw Pusep
+
+ I was re-compiling Geolizer (http://sysd.org/log.php#glzr) on Win32 so I
+ firstly needed to put up-to-date Win32 compatibility of libGeoIP itself.
+ Fortunately MinGW plataform evolved a lot since last time I used it to
+ compile libGeoIP. I'm sending you the patch with changes required for
+ libGeoIP to work on both Win32 and UN*X. UN*X behavior is unaffected. Now,
+ detailed explanation of what I did at all:
+
+ 1) Made correct header imports for both Win32 and UN*X. UN*X imports netdb.h
+ & netinet/in.h and Win32 imports windows.h & winsock.h
+ 2) Win32 gethostbyname() is only able to resolve hostnames, it can't convert
+ "127.0.0.1" string to 32-bit IP address. Thus I added lookupaddress()
+ function that safely resolves any string to IP address and replaced all
+ gethostbyname() calls by it.
+ 3) Database files were referenced by pre-compiled static strings. I
+ malloc()ed buffers for file names so they can be changed "on fly". Thus,
+ on Win32 version GeoIP.dat & other files are being seeked in the same
+ directory as executable file or library.
+ 4) Added README.MinGW file with brief explanation on how to get GeoIP
+ working under MinGW system.
+
+
+1.3.1 2003-11-11
+
+* Check for stdint.h in autoconf (Sean Chittenden)
+* prevent the geoipupdate man page from trying to install itself directly in
+ the system directory (Gyepi Sam)
+
+
+1.3.0 2003-09-29
+
+* Fixed includes to compile on Windows (Fabrice Colin)
+* Removed the _addr_to_num() calls from GeoIP_*_by_name()
+* _seek_record() optimizations (Maurice Cinquini)
+ 1) Use a single buf ptr inside the loops.
+ Set to the stack buffer or the cached memory the start of the function.
+ 2) Unroll the i=0,1 loop to allow constant folding.
+ 3) Unroll the j loop for the common case of j = STANDARD_RECORD_LENGTH
+ (I've already done the above changes see attached function.)
+ With gcc -O2 calculating x[0] and x[1] for STANDARD_RECORD_LENGTH now
+ only takes 15 (was > 100) i80x86 instructions with 6 byte accesses of RAM.
+ 4) only calculate x[0], x[1] when needed, may be a bigger win
+ than the above since all the other optimizations above only reduced
+ CPU instructions operating on CPU cached RAM.
+! IMPORTANT API Change: Changed GeoIPRegion to have region in structure. Saves space and a malloc.
+ Since GeoIPRegion.region is no longer a pointer but an in-structure
+ array so test the first byte of region == 0 rather testing if the region
+ pointer is NULL. (Maurice Cinquini)
+* Added GeoIP_assign_region_by_inetaddr which doesn't do any mallocs and made all other region APIs go thru it (Maurice Cinquini)
+* Replaced _h_addr_to_num() with ntohl() and removed _h_addr_to_num() (Maurice Cinquini)
+* Fixed bug when IP address not found in region rev1 database (Jason Linhart)
+* Added added extern "C" to GeoIPCity.h fixes problems when included in C++ library
+
+
+1.2.2 2003-08-10
+
+* Added support for GeoIP ISP Edition identifier
+* Fixed bug in GeoIP_database_info (Jason Linhart)
+* Added support for GeoIP AS Number Edition
+! renamed GeoIP_org_by_* functions to GeoIP_name_by_* to reduce confusion
+ since these functions are used by GeoIP ISP and GeoIP ASNum as well
+ as GeoIP Organization
+* Added support for GeoIP Proxy Edition
+! renamed GeoIP_country_id_by_* functions to GeoIP_id_by_*
+
+
+1.2.1 2003-07-12
+
+* Added GeoIP_record_id_by_addr and GeoIP_next_record functions
+* Added support for new GeoIP Region format, including Canadian Provinces
+
+
+1.2.0 2003-04-26
+
+* Added support for GeoIP City format revision 1, including dma code and area code
+* geoiplookup returns results from GeoIP Region, City, ISP and Organization databases
+* Standardized location for GeoIP Region, City, ISP and Organization databases
+* Added GeoIP_open_type to open database from default location for other dbs besides country
+* Added check to make sure that the appropriate database is loaded for each lookup method
+* Updated update code to check for first 12 characters of license key
+* Added GeoIP_country_continent array to lookup continent by country ID
+
+
+1.1.9 2003-03-10
+
+* merged windows patch into main code base (Kenneth R. Robinette)
+* Changed const int to #define for windows compatibility
+
+
+1.1.8 2003-03-04
+
+* Fixed bug with city database introduced in 1.1.6
+
+
+1.1.7 2003-03-04
+
+* Fixed bug introduced in 1.1.6 when run in GEOIP_STANDARD mode
+* Added test to test GEOIP_STANDARD
+
+
+1.1.6 2003-03-03
+
+* Added spec for building RPMs (Ryan Weaver)
+* Added support for 4byte records for Organization database
+* Changed Taiwan, Province of China to Taiwan
+
+
+1.1.5 2003-02-10
+
+* Added support for GeoIP Organization database
+
+
+1.1.4 2002-12-30
+
+* Cast number to int in _num_to_addr in geoipexport (Ralf S. Engelschall)
+* Removed printf debug statements from geoipexport
+* correct library build ordering (Ralf S. Engelschall)
+* ulong -> unsigned long (Sean Chittenden)
+
+
+1.1.3 2002-12-24
+
+* Added GeoIPUpdate.h to EXTRA_DISTS
+* Compile fixes for Solaris, FreeBSD (Michael McClennen, Corris Randall)
+* Handle NULL in printf in test-geoip-region
+
+
+1.1.2 2002-12-16
+
+* Added support for postal codes
+* Added geoipexport, program to export bit binary file to
+ binary tree format and csv format
+* Split update code into separate library, GeoIPUpdate.la
+* Allow passing NULL callback to GeoIP_update_database function
+ (Sean Chittenden)
+* Added geoipexport program, exports to CSV file
+* Added GeoIP_database_edition method
+* Changed DATADIR to GEOIPDATADIR
+
+
+1.1.1 2002-11-07
+
+* Fixed segfault issue with GeoIPRegion_delete
+* Handle test failures where lookup returns NULL more gracefully
+
+
+1.1.0 2002-11-06
+
+* Perform sanity checking before installing datebase using geoipupdate
+* Removed file locking, since we install file by renaming instead of writing to it.
+* Fixed geoipupdate to check for NULL return value
+* Added constants for different editions
+* Added O1 code for "Other country", used in per-country city editions
+* fixed multi-line string literals warning in test-geoip.c
+* Use enum constants for GeoIP_update_database values
+* Added GEOIP_CHECK_CACHE option (not working yet)
+
+
+1.0.10 2002-10-28
+
+* IMPORTANT API Change - Return NULL instead of '--' and 'N/A'
+ Be sure to check the return value for NULL to avoid segmentation faults!!!!
+* Added callback to print messages from GeoIP_update_database
+* Moved GeoIPConfFile to geoipupdate.c
+* Changed databaseSegments to unsigned int (Chris Gibbs)
+* Fixed compiler warnings (Chris Gibbs)
+* API Change - GeoIPRegion region member set to NULL when no region available
+* Change short int to int (Chris Gibbs)
+* Added write/read file locking for GeoIPUpdate.c/GeoIP.c
+
+
+1.0.9 2002-10-16
+
+* removed -ansi from Makefile.am to avoid compile error on Solaris 8
+* Compile fix for FreeBSD Stable (Kimura Fuyuki)
+
+
+1.0.8 2002-10-05
+
+* Included header required for *BSD (Akinori Musha)
+
+
+1.0.7 2002-10-05
+
+* Fixed compilation error with GeoIPUpdate.c
+
+
+1.0.6 2002-10-04
+
+* Moved update code into separate file
+* Added md5 checksums to update code
+* Fixed memory leak when running geoiplookup -v
+* Moved const RECORD_LENGTH to #define RECORD_LENGTH for Windows compatibility
+ (Randy Kobes)
+* Cleaned up GeoIP_new code
+
+
+1.0.5 2002-09-23
+
+* Supports GeoIP Regional Edition
+* Macau is now "Macao" per ISO 3166-1 change
+* Romania "ROM" is now "ROU" per ISO 3166-1 change
+* Added #define for memcpy -> BSD's bcopy (Chris Gibbs)
+* Removed "private" functions from GeoIP.h
+
+
+1.0.4 2002-08-27
+
+* rewrote _seek_country to use loop instead of recursion for faster performance
+* Removed "orphan" nodes from demo database resulting in smaller size (Jason Linhart)
+* Moved changes for building windows DLL into separate patch
+* Fixed segfaults when passed malformed IP addresses
+
+
+1.0.3 2002-08-26
+
+* Added more changes for windows compatibility
+ (Stanislaw Pusep)
+* Added benchmark program
+
+
+1.0.2 2002-08-21
+
+* Open database using "rb" for windows compatibility
+ (Stanislaw Pusep)
+* Removed superfluous inet_ntop command (Stanislaw Pusep)
+
+
+1.0.1 2002-08-20
+
+* Fixed bug with resolving hostnames
+* More fixes for compiler warnings (Chris Gibbs)
+* Changed int to unsigned int in _is_ipaddr (Chris Gibbs)
+
+
+1.0.0 2002-08-12
+
+* Changed license to GPL
+* Don't perform Reverse DNS lookups on IP addresses
+* Only include getopt.h on Linux (OpenPKG patch)
+* Avoid the_license_key_str warning (OpenPKG patch)
+* Added license for March 2002 database
+
+
+0.3.0 2002-08-04
+
+* Added support for 'A2', Satellite Providers
+
+
+0.2.8 2002-07-30
+
+* Handle malformed input gracefully
+* Added section to README on Solaris workarounds
+* Added geoipupdate man page
+
+
+0.2.7 2002-07-27
+
+* Added section to README on automatic updates
+* link to socket library on solaris
+
+
+0.2.6 2002-07-25
+
+* optimized GeoIP_open (Chris Gibbs)
+* check for partial file read in GeoIP_open (Chris Gibbs)
+* optimized _addr_to_num() (Chris Gibbs)
+* changed write and read to send and recv for sockets
+* Only install GeoIP.conf and GeoIP.dat if not already installed
+
+
+0.2.5 2002-07-22
+
+* Added verbose option to GeoIP_update_database
+
+
+0.2.4 2002-07-22
+
+* Fix for GeoIP_update_database
+
+
+0.2.3 2002-07-22
+
+* Fixes for FreeBSD
+* All calls to malloc are checked for NULL pointer (Chris Gibbs)
+* Fixed spelling of "Kazakhstan" (Chris Gibbs)
+* Initialize cache_buf to NULL (Chris Gibbs)
+* More memory leak fixes (Chris Gibbs)
+
+
+0.2.2 2002-07-18
+
+* Added update database function
+* Fixed memory leak in GeoIP_new (Chris Gibbs)
+
+
+0.2.1 2002-07-03
+
+* Added support for anonymous proxies
+
+
+0.2.0 2002-06-23
+
+* Added new memory caching option for improved performance
+
+
+0.1.7 2002-05-29
+
+* Only add -lnsl for systems that support libnsl
+* Added decl for 3 letter country code array to GeoIP.h
+
+
+0.1.6 2002-05-25
+
+* Added 3 letter country code
+
+
+0.1.5 2002-05-23
+
+* Added -lnsl fixed compile errors
+
+
+0.1.4 2002-05-11
+
+* Fixed bugs in demo March 2002 database
+
+
+0.1.3 2002-04-21
+
+* Fixed bug related to signed int (Brian Grossman)
+* Better error handling when hostname not found
+* Fixed bug when netmask=32 for netblock
+
+
+0.1.2 2002-04-20
+
+* Added two new functions, GeoIP_country_id_by_addr
+ and GeoIP_country_id_by_name.
+* Made GeoIP_country_code and GeoIP_country_name
+ viewable outside of library, to be with with
+ GeoIP_country_id_by_* functions.
+
+
+0.1.1 2002-04-07
+
+* GeoIP.h is now installed to includedir
+* constructor and destructor are now provided by
+ GeoIP_new, GeoIP_open, and GeoIP_delete
+
+
+0.1.0 2002-04-07
+
+* Initial release
diff --git a/GeoIP.spec.in b/GeoIP.spec.in
new file mode 100644
index 0000000..9405b6e
--- /dev/null
+++ b/GeoIP.spec.in
@@ -0,0 +1,76 @@
+Name: @PACKAGE@
+Version: @VERSION@
+Summary: GeoIP is a C library finds the location of an IP address.
+Release: 1
+Group: System Environment/Libraries
+URL: http://dev.maxmind.com/geoip/downloadable
+Vendor: MaxMind, Inc.
+Source0: http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz
+License: LGPLv2.1+
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+GeoIP is a C library that enables the user to find geographical and
+network information of an IP address.
+Included is a free GeoLite Country database
+that is updated at the beginning of every month.
+To download the latest free GeoLite databases, go to:
+http://dev.maxmind.com/geoip/geolite
+
+%package devel
+Summary: GeoIP headers, libraries
+Group: Development/Libraries
+Requires: %name = %{version}
+
+%description devel
+This package contain the devel files for GeoIP.
+
+%prep
+%setup -q
+
+%build
+%configure
+make
+make check
+
+%install
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+%makeinstall
+# Fixup permissions on shared libraries so that findreqs will work right.
+chmod 755 $RPM_BUILD_ROOT/%{_libdir}/*
+
+%clean
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS COPYING ChangeLog README.md TODO
+%attr(0755,root,root) %{_libdir}/*.so.*.*
+%{_bindir}/*
+%{_sysconfdir}/*
+%dir %{_datadir}/GeoIP
+%{_datadir}/GeoIP/*
+%{_libdir}/*.so
+%{_mandir}/*/*
+
+%files devel
+%{_includedir}/*
+%{_libdir}/*.a
+%{_libdir}/*.la
+
+%changelog
+* Fri Apr 14 2006 Thomas Mather <support@maxmind.com>
+- Updated description to reference free GeoLite City database
+
+* Thu Jul 7 2005 Thomas Mather <support@maxmind.com>
+- Updated description to reflect monthly updates for free country database.
+
+* Mon Sep 8 2003 Dr. Peter Bieringer
+- Fix for RHL 9, created a new devel package definition.
+
+* Thu Feb 27 2003 Ryan Weaver <ryanw@falsehope.com>
+- Initial RPM Build
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..a1e89e1
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,370 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved. Use GNU `make'
+instead.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..06b048b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,28 @@
+There are two licenses, one for the C library software, and one for
+the GeoLite Country database.
+
+SOFTWARE LICENSE
+
+Copyright (C) 2015 MaxMind, Inc.
+
+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.
+
+For a copy of the LGPL License, see the COPYING file.
+
+DATA LICENSE (GeoLite Country and City Databases)
+
+The GeoLite databases are distributed under the Creative Commons
+Attribution-ShareAlike 3.0 Unported License. The attribution
+requirement may be met by including the following in all advertising
+and documentation mentioning features of or use of this database:
+
+ This product includes GeoLite data created by MaxMind, available from
+ <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..ad9b1ea
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,15 @@
+AM_CPPFLAGS = -Wall -ansi
+ACLOCAL_AMFLAGS = -I m4
+
+AUTOMAKE_OPTIONS = foreign
+
+SUBDIRS = \
+ libGeoIP \
+ apps \
+ test \
+ man
+
+pkgconfigdir = $(libdir)/pkgconfig/
+nodist_pkgconfig_DATA = geoip.pc
+
+EXTRA_DIST = LICENSE NEWS.md README.md README.OSX bootstrap GeoIP.spec GeoIP.spec.in Makefile.vc get_ver.awk geoip.ico geoip.pc.in data/GeoIP.dat
diff --git a/Makefile.vc b/Makefile.vc
new file mode 100644
index 0000000..fde3e48
--- /dev/null
+++ b/Makefile.vc
@@ -0,0 +1,84 @@
+#NMAKE makefile for Windows developers.
+#Produces a static library (GeoIP.lib).
+
+#################################################################
+# configuration section
+################################################################
+
+# place to put the GeoIP.dat database file
+# !!! Please keep the 2 \\ as directory separators !!!
+#
+GEOIPDATADIR="C:\\Windows\\SYSTEM32"
+#
+# System inc, lib, and bin directories
+!ifndef INSTDIR
+INSTDIR="C:\GeoIP"
+!endif
+
+# Location where GeoIP.lib should be installed my "make install"
+INSTALL_LIB=$(INSTDIR)\Lib
+
+#Location where .h files should be installed by "make install".
+INSTALL_INC=$(INSTDIR)\Include
+
+#Location where programs should be installed by "make install".
+INSTALL_BIN=$(INSTDIR)\Bin
+
+################################################################
+# end configuration section
+################################################################
+
+DATA_DIR=data
+
+DATA_FILE=GeoIP.dat
+
+LIB_DIR = libGeoIP
+
+TEST_DIR=test
+
+APP_DIR=apps
+
+GEOIP_LIB = GeoIP.lib
+
+APP_PROGRAMS = geoiplookup.exe
+
+TEST_PROGRAMS = benchmark.exe test-geoip.exe
+
+all: GeoIP.lib test_progs app_progs
+
+$(GEOIP_LIB):
+ cd $(LIB_DIR)
+ $(MAKE) -nologo -f Makefile.vc GEOIPDATADIR=$(GEOIPDATADIR)
+ cd ..
+
+test_progs:
+ cd $(TEST_DIR)
+ $(MAKE) -nologo -f Makefile.vc
+ cd ..
+
+app_progs:
+ cd $(APP_DIR)
+ $(MAKE) -nologo -f Makefile.vc
+ cd ..
+
+test: $(GEOIP_LIB) test_progs
+ cd $(TEST_DIR)
+ benchmark.exe
+ test-geoip.exe
+ cd ..
+
+install: $(GEOIP_LIB) app_progs
+ cd $(LIB_DIR)
+ copy $(GEOIP_LIB) $(INSTALL_LIB)
+ copy *.h $(INSTALL_INC)
+ cd ..\$(APP_DIR)
+ copy $(APP_PROGRAMS) $(INSTALL_BIN)
+ cd ..\$(DATA_DIR)
+ copy $(DATA_FILE) $(GEOIPDATADIR)
+ cd ..
+
+clean:
+ del $(LIB_DIR)\*.obj $(LIB_DIR)\*.lib $(LIB_DIR)\*.dll
+ del $(APP_DIR)\*.obj $(APP_DIR)\*.exe
+ del $(TEST_DIR)\*.obj $(TEST_DIR)\*.exe
+
diff --git a/NEWS.md b/NEWS.md
new file mode 100644
index 0000000..d9716d3
--- /dev/null
+++ b/NEWS.md
@@ -0,0 +1,50 @@
+## Important Changes ##
+
+### 1.6.0 ###
+
+`geoipupdate` is removed from the GeoIP C library.
+
+Please use the seperate tool [geoipupdate](https://github.com/maxmind/geoipupdate) to download your subscriptions or our
+free databases.
+
+### 1.5.0 ###
+
+Geoipupdate may be used to download our free databases.
+
+Put this into the config file /usr/local/etc/GeoIP.conf
+to download the free GeoLite databases GeoLiteCountry, GeoLiteCity and GeoLiteASNum
+
+```
+LicenseKey 000000000000
+UserId 999999
+ProductIds 506 533 517
+```
+
+Free users should create symlinks for the GeoIP databases.
+For example:
+
+```
+cd /usr/local/share/GeoIP
+ln -s GeoLiteCity.dat GeoIPCity.dat
+ln -s GeoLiteCountry.dat GeoIPCountry.dat
+ln -s GeoLiteASNum.dat GeoIPASNum.dat
+```
+
+The lookup functions are thread safe.
+
+### 1.3.6 ###
+
+As of version 1.3.6, the GeoIP C library is thread safe, as long as
+`GEOIP_CHECK_CACHE` is not used.
+
+### 1.3.0 ###
+
+The GeoIP Region database is no longer a pointer but an in-structure array so
+test the first byte of region == 0 rather than testing if the region pointer
+is `NULL`.
+
+### 1.1.0 ###
+
+As of GeoIP 1.1.0 the GeoIP_country_xxx_by_xxx functions return NULL if a
+country can not be found. It previously returned `--` or `N/A`. To avoid
+segmentation faults, check the return value for `NULL`.
diff --git a/README.OSX b/README.OSX
new file mode 100644
index 0000000..2cf30a7
--- /dev/null
+++ b/README.OSX
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Building OSX fat binaries is easy.
+#
+# - start in a clean directory.
+# - copy the shell script below to a file and edit the file to your needs.
+#
+# 1.) modify export GEOIP_ARCH='-arch i386 -arch x86_64 -arch ppc -arch ppc64'
+# to include all architectures you need.
+# 2.) add whatever you want to the ./configure line.
+# 3.) execute the script.
+# 4.) do a 'make install'
+#
+#
+# make clean or make distclean before building this
+#
+# tell systems before leopard that we like to build for 10.5 or higher
+# with MACOSX_DEPLOYMENT_TARGET=10.5
+# starting with leopard we have to add -mmacosx-version-min=10.5
+# to the CFLAGS and export MACOSX_DEPLOYMENT_TARGET!?
+
+## for tiger, leopard and snow leopard you might use this
+## export GEOIP_ARCH='-arch i386 -arch x86_64 -arch ppc -arch ppc64'
+## export MACOSX_DEPLOYMENT_TARGET=10.4
+## export LDFLAGS=$GEOIP_ARCH
+## export CFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk $GEOIP_ARCH"
+
+# here we go for leopard and snow leopard
+#export GEOIP_ARCH='-arch i386 -arch x86_64 -arch ppc'
+#export MACOSX_DEPLOYMENT_TARGET=10.5
+#export LDFLAGS=$GEOIP_ARCH
+#export CFLAGS="-g -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk $GEOIP_ARCH"
+#./configure --disable-dependency-tracking
+#perl -i.bak -pe'/^archive_cmds=/ and !/\bGEOIP_ARCH\b/ and s/-dynamiclib\b/-dynamiclib \\\$(GEOIP_ARCH)/' ./libtool
+#make
+
+# and this is lion with the new xcode
+#P=`xcode-select -print-path`
+#export GEOIP_ARCH='-arch i386 -arch x86_64'
+#export MACOSX_DEPLOYMENT_TARGET=10.7
+#export LDFLAGS=$GEOIP_ARCH
+#export CFLAGS="-g -mmacosx-version-min=10.7 -isysroot $P/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk $GEOIP_ARCH"
+#./configure --disable-dependency-tracking
+#make
+
+# and this is lion with the new xcode
+P=`xcode-select -print-path`
+export GEOIP_ARCH='-arch x86_64'
+export MACOSX_DEPLOYMENT_TARGET=10.9
+export LDFLAGS=$GEOIP_ARCH
+export CFLAGS="-g -mmacosx-version-min=10.9 -isysroot $P/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk $GEOIP_ARCH"
+./configure --disable-dependency-tracking
+make
diff --git a/README.dev.md b/README.dev.md
new file mode 100644
index 0000000..67deef8
--- /dev/null
+++ b/README.dev.md
@@ -0,0 +1,35 @@
+## Releasing
+
+* Make sure https://github.com/github/hub is installed and configured.
+* Make sure the `ChangeLog` is up to date.
+* Run `dev-bin/release.sh`
+
+## Ubuntu PPA packages
+
+0. Switch to the `ubuntu-ppa` branch and merge the release tag from above.
+
+Release script:
+
+1. run `dev-bin/ppa-release.sh`
+
+Manual PPA process:
+
+1. Type `dch -i` and add the appropriate `debian/changelog` entry.
+2. Move tarball created above to a temp directory and
+ name it `geoip_1.?.?.orig.tar.gz`.
+3. Unpack tarball.
+4. Copy `debian` directory from Git. (We intentionally do not include it in
+ the tarball so that we don't interfere with Debian's packaging.)
+5. Update `debian/changelog` for the dist you are releasing to, e.g.,
+ precise, trusty, vivid, and prefix the version with the a `~` followed
+ by the dist name, e.g., `1.6.3-1+maxmind1~trusty`.
+6. Run `debuild -S -sa -rfakeroot -k<KEY>`. (The key may not be necessary
+ if your .bashrc is appropriately )
+7. Run `lintian` to make sure everything looks sane.
+8. Run `dput ppa:maxmind/ppa ../<source.changes files created above>` to
+ upload.
+9. Repeat 4-8 for remaining distributions.
+
+## Homebrew
+
+* Update the [Homebrew formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/geoip.rb).
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..debdfb1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,248 @@
+# GeoIP Legacy C Library #
+
+## Important Note ##
+
+This library is for the GeoIP Legacy format (dat). To read the MaxMind DB
+format (mmdb) used by GeoIP2, please see
+[libmaxminddb](https://github.com/maxmind/libmaxminddb).
+
+## Description ##
+
+The GeoIP Legacy C library enables the user to find geographical and network
+information of an IP address. To use this library, you may download our free
+GeoLite Legacy Country or City databases. These are updated at the beginning
+of every month. The latest versions are available at:
+
+https://dev.maxmind.com/geoip/legacy/geolite
+
+We also offer commercial GeoIP Legacy databases with greater accuracy and
+additional network information. For more details, see:
+
+https://www.maxmind.com/en/geolocation_landing
+
+If you use GeoIP Legacy to block access from high risk countries, you may wish
+to use our proxy detection service to block access from known proxy servers to
+reduce fraud and abuse. For more details, see:
+
+https://www.maxmind.com/en/proxy
+
+## IP Geolocation Usage ##
+
+IP geolocation is inherently imprecise. Locations are often near the center of
+the population. Any location provided by a GeoIP database should not be used to
+identify a particular address or household.
+
+## Installation ##
+
+### On Ubuntu Using PPA ###
+
+MaxMind provides a PPA for recent version of Ubuntu. To add the PPA to your
+APT sources, run:
+
+ $ sudo add-apt-repository ppa:maxmind/ppa
+
+Then install the packages by running:
+
+ $ sudo apt update
+ $ sudo apt install libgeoip1 libgeoip-dev geoip-bin
+
+### From Source on Unix/Linux ###
+
+To install, run:
+
+```
+./configure
+make
+make check
+make install
+```
+
+If you are using a GitHub checkout, please run the `bootstrap` script first
+to set up the build environment.
+
+The GeoIP Legacy C library relies on GNU make, not on BSD make
+
+### From Source with Visual Studio (nmake) ###
+
+To make a static GeoIP.lib, edit the top level Makefile.vc to reflect where
+the GeoIP.dat database file should be placed, as well as the locations of the
+lib, include, and bin directories for installation.
+
+To build and install, issue the following commands from a developer console:
+
+```
+nmake /f Makefile.vc
+nmake /f Makefile.vc test
+nmake /f Makefile.vc install
+```
+
+### From Source with MinGW ###
+
+```
+./configure
+make
+cp data/GeoIP.dat test/
+make check
+```
+
+Note that GeoIP.dat file should be placed in the same place as GeoIP-enabled
+executable modules.
+
+## Memory Caching and Other Options ##
+
+There are five options available:
+
+* `GEOIP_STANDARD` - Read database from file system. This uses the least
+ memory.
+* `GEOIP_MEMORY_CACHE` - Load database into memory. Provides faster
+ performance but uses more memory.
+* `GEOIP_CHECK_CACHE` - Check for updated database. If database has been
+ updated, reload file handle and/or memory cache.
+* `GEOIP_INDEX_CACHE` - Cache only the the most frequently accessed index
+ portion of the database, resulting in faster lookups than `GEOIP_STANDARD`,
+ but less memory usage than `GEOIP_MEMORY_CACHE`. This is useful for larger
+ databases such as GeoIP Legacy Organization and GeoIP Legacy City. Note: for
+ GeoIP Legacy Country, Region and Netspeed databases, `GEOIP_INDEX_CACHE` is
+ equivalent to `GEOIP_MEMORY_CACHE`.
+* `GEOIP_MMAP_CACHE` - Load database into mmap shared memory. MMAP is not
+ available for 32bit Windows.
+* `GEOIP_SILENCE` - Disables diagnostic messages to stderr in the library;
+ error conditions are detectable via the return values.
+
+These options can be combined using bit operators. For example you can
+use both `GEOIP_MEMORY_CACHE` and `GEOIP_CHECK_CACHE by calling`:
+
+```c
+GeoIP_open("/path/to/GeoIP.dat", GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE);
+```
+
+By default, the city name is returned in the ISO-8859-1 charset. To obtain
+the city name in UTF-8 instead, run:
+
+```c
+GeoIP_set_charset(gi, GEOIP_CHARSET_UTF8);
+```
+
+To get the netmask of the netblock of the last lookup, use
+`GeoIP_last_netmask(gi)`.
+
+## Examples ##
+
+See the following files for examples of how to use the API:
+
+```
+test/
+ test-geoip.c
+ test-geoip-region.c
+ test-geoip-city.c
+ test-geoip-isp.c
+ test-geoip-org.c
+ test-geoip-netspeed.c
+```
+
+The test-geoip.c program works with both the GeoLite Legacy and GeoIP Legacy
+Country databases. The test-geoip-city.c program works with both the GeoLite
+Legacy and GeoIP Legacy City databases. The other example programs require the
+paid databases available (https://www.maxmind.com/en/geolocation_landing).
+
+## Troubleshooting ##
+
+### Autotool Issues ###
+In case of trouble building from source with libtool or autotools, update
+the generated configuration files by running:
+
+```
+./bootstrap
+```
+or
+
+```
+autoreconf -vfi
+```
+or
+```
+aclocal && autoconf && automake --add-missing
+```
+
+### Threads
+
+Lookups are thread safe, but libGeoIP does not guard the functions. Do not
+drop or change the GeoIP database if other threads might be using the
+database.
+
+The recommended pattern is:
+
+1. open database with GEOIP_MEMORY_CACHE
+2. create_threads(your_thread_entry_function)
+3. use the database
+4. join_threads
+5. close database
+
+### Thread Safety on Windows ###
+
+The Windows build is not thread-safe in STANDARD mode because the `pread` is
+not thread-safe.
+
+### Other Build Issues ###
+
+If you run into trouble building your application with GeoIP Legacy support,
+try adding `-fms-extensions` to your `CFLAGS`. If you use Solaris and the
+default C compiler, use `-features=extensions` instead. These options enable
+unnamed union support to fix problems like: `improper member use: dma_code` or
+`'GeoIPRecord' has no member named 'dma_code'`.
+
+Note that it is recommended that you use GNU make. Also, if you are using
+OpenBSD, this library requires OpenBSD 3.1 or greater.
+
+If you get a "cannot load shared object file: No such file or directory"
+error, add the directory `libGeoIP.so` was installed to the `/etc/ld.so.conf`
+file and run `ldconfig`.
+
+#### Solaris ####
+
+On Solaris, if you get a `ld: fatal: relocations remain against allocatable
+but non-writable sections`, try running:
+
+```
+make clean
+./configure --disable-shared
+make
+```
+
+If you get a `ar : command not found` error, make sure that `ar` is in your
+path. On Solaris, `ar` is typically found in `/usr/ccs/bin`
+
+
+#### AIX ####
+
+If you get a `passing argument 3 of 'gethostbyname_r' from incompatible
+pointer type` error on AIX, untar a fresh copy of this library and delete the
+following two lines from `./configure`:
+
+```
+#define HAVE_GETHOSTBYNAME_R 1
+
+#define GETHOSTBYNAME_R_RETURNS_INT 1
+```
+
+then save the configure script and build it as usual:
+
+```
+./configure
+make
+sudo make install
+```
+
+## Bug Tracker ##
+
+Please report all issues with this code using the
+[GitHub issue tracker](https://github.com/maxmind/geoip-api-c/issues).
+
+If you are having an issue with a MaxMind database that is not specific to
+this API, please
+[contact MaxMind support](https://www.maxmind.com/en/support).
+
+## Contributing ##
+
+To contribute, please submit a pull request on
+[GitHub](https://github.com/maxmind/geoip-api-c/).
diff --git a/apps/Makefile.am b/apps/Makefile.am
new file mode 100644
index 0000000..6e2a49c
--- /dev/null
+++ b/apps/Makefile.am
@@ -0,0 +1,18 @@
+AM_CPPFLAGS = -I$(top_srcdir)/libGeoIP -DSYSCONFDIR=\"$(sysconfdir)\" -Wall
+
+DEPS = $(top_builddir)/libGeoIP/libGeoIP.la
+LDADDS = $(top_builddir)/libGeoIP/libGeoIP.la
+
+bin_PROGRAMS = geoiplookup geoiplookup6
+
+geoiplookup_SOURCES = geoiplookup.c
+geoiplookup_LDFLAGS =
+geoiplookup_DEPENDENCIES = $(top_builddir)/libGeoIP/libGeoIP.la
+geoiplookup_LDADD = $(top_builddir)/libGeoIP/libGeoIP.la
+
+geoiplookup6_SOURCES = geoiplookup6.c
+geoiplookup6_LDFLAGS =
+geoiplookup6_DEPENDENCIES = $(top_builddir)/libGeoIP/libGeoIP.la
+geoiplookup6_LDADD = $(top_builddir)/libGeoIP/libGeoIP.la
+
+EXTRA_DIST = Makefile.vc
diff --git a/apps/Makefile.vc b/apps/Makefile.vc
new file mode 100644
index 0000000..266a931
--- /dev/null
+++ b/apps/Makefile.vc
@@ -0,0 +1,25 @@
+#NMAKE makefile for Windows developers.
+#Produces a static library (GeoIP.lib).
+
+COMPILER=cl
+
+LINK = link -nologo
+
+CFLAGS=-DWIN32 -MD -nologo
+
+GEOIPINC = -I..\libGeoIP
+
+CC1 = $(COMPILER) $(CFLAGS) $(GEOIPINC)
+
+GEOIPLIB = ..\libGeoIP\GeoIP.lib
+
+EXTRA_LIBS= advapi32.lib wsock32.lib
+
+AR=lib
+
+APPS: geoiplookup.exe
+
+geoiplookup.exe: geoiplookup.c
+ $(CC1) -c geoiplookup.c
+ $(LINK) geoiplookup.obj $(GEOIPLIB)
+
diff --git a/apps/geoiplookup.c b/apps/geoiplookup.c
new file mode 100644
index 0000000..1c412ea
--- /dev/null
+++ b/apps/geoiplookup.c
@@ -0,0 +1,375 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* geoiplookup.c
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "GeoIP.h"
+#include "GeoIPCity.h"
+#include "GeoIP_internal.h"
+
+#if defined(_WIN32)
+#ifndef uint32_t
+typedef unsigned int uint32_t;
+#endif
+#endif
+
+void geoiplookup(GeoIP *gi, char *hostname, int i);
+
+void usage(void) {
+ fprintf(stderr,
+ "Usage: geoiplookup [-h] [-?] [-d custom_dir] [-f "
+ "custom_file] [-v] [-i] [-l] <ipaddress|hostname>\n");
+}
+
+/* extra info used in _say_range_ip */
+int info_flag = 0;
+
+int main(int argc, char *argv[]) {
+ char *hostname = NULL;
+ char *db_info;
+ GeoIP *gi;
+ int i;
+ char *custom_directory = NULL;
+ char *custom_file = NULL;
+ int version_flag = 0;
+ int charset = GEOIP_CHARSET_UTF8;
+
+ if (argc < 2) {
+ usage();
+ exit(1);
+ }
+ i = 1;
+ while (i < argc) {
+ if (strcmp(argv[i], "-v") == 0) {
+ version_flag = 1;
+ } else if (strcmp(argv[i], "-l") == 0) {
+ charset = GEOIP_CHARSET_ISO_8859_1;
+ } else if (strcmp(argv[i], "-i") == 0) {
+ info_flag = 1;
+ } else if ((strcmp(argv[i], "-?") == 0) ||
+ (strcmp(argv[i], "-h") == 0)) {
+ usage();
+ exit(0);
+ } else if (strcmp(argv[i], "-f") == 0) {
+ if ((i + 1) < argc) {
+ i++;
+ custom_file = argv[i];
+ }
+ } else if (strcmp(argv[i], "-d") == 0) {
+ if ((i + 1) < argc) {
+ i++;
+ custom_directory = argv[i];
+ }
+ } else {
+ hostname = argv[i];
+ }
+ i++;
+ }
+ if (hostname == NULL) {
+ usage();
+ exit(1);
+ }
+
+ if (custom_directory != NULL) {
+ GeoIP_setup_custom_directory(custom_directory);
+ }
+ _GeoIP_setup_dbfilename();
+
+ if (custom_file != NULL) {
+ gi = GeoIP_open(custom_file, GEOIP_STANDARD | GEOIP_SILENCE);
+
+ if (NULL == gi) {
+ printf("%s not available, skipping...\n", custom_file);
+ } else {
+ gi->charset = charset;
+ i = GeoIP_database_edition(gi);
+ if (version_flag == 1) {
+ db_info = GeoIP_database_info(gi);
+ printf("%s: %s\n",
+ GeoIPDBDescription[i],
+ db_info == NULL ? "" : db_info);
+ free(db_info);
+ } else {
+ geoiplookup(gi, hostname, i);
+ }
+ }
+ GeoIP_delete(gi);
+ } else {
+ /* iterate through different database types */
+ for (i = 0; i < NUM_DB_TYPES; ++i) {
+ if (GeoIP_db_avail(i)) {
+ gi = GeoIP_open_type(i, GEOIP_STANDARD | GEOIP_SILENCE);
+ if (NULL == gi) {
+ /* Ignore these errors. It's possible
+ * to use the same database name for
+ * different databases.
+ */
+ ;
+ } else {
+ gi->charset = charset;
+ if (version_flag == 1) {
+ db_info = GeoIP_database_info(gi);
+ printf("%s: %s\n",
+ GeoIPDBDescription[i],
+ db_info == NULL ? "" : db_info);
+ free(db_info);
+ } else {
+ geoiplookup(gi, hostname, i);
+ }
+ }
+ GeoIP_delete(gi);
+ }
+ }
+ }
+ return 0;
+}
+
+static const char *_mk_NA(const char *p) { return p ? p : "N/A"; }
+
+static unsigned long __addr_to_num(const char *addr) {
+ unsigned int c, octet, t;
+ unsigned long ipnum;
+ int i = 3;
+
+ octet = ipnum = 0;
+ while ((c = *addr++)) {
+ if (c == '.') {
+ if (octet > 255) {
+ return 0;
+ }
+ ipnum <<= 8;
+ ipnum += octet;
+ i--;
+ octet = 0;
+ } else {
+ t = octet;
+ octet <<= 3;
+ octet += t;
+ octet += t;
+ c -= '0';
+ if (c > 9) {
+ return 0;
+ }
+ octet += c;
+ }
+ }
+ if ((octet > 255) || (i != 0)) {
+ return 0;
+ }
+ ipnum <<= 8;
+ return ipnum + octet;
+}
+
+/* ptr must be a memory area with at least 16 bytes */
+static char *__num_to_addr_r(unsigned long ipnum, char *ptr) {
+ char *cur_str;
+ int octet[4];
+ int num_chars_written, i;
+
+ cur_str = ptr;
+
+ for (i = 0; i < 4; i++) {
+ octet[3 - i] = ipnum % 256;
+ ipnum >>= 8;
+ }
+
+ for (i = 0; i < 4; i++) {
+ num_chars_written = sprintf(cur_str, "%d", octet[i]);
+ cur_str += num_chars_written;
+
+ if (i < 3) {
+ cur_str[0] = '.';
+ cur_str++;
+ }
+ }
+
+ return ptr;
+}
+
+void _say_range_by_ip(GeoIP *gi, uint32_t ipnum) {
+ unsigned long last_nm, mask, low, hi;
+ char ipaddr[16];
+ char tmp[16];
+ char **range;
+
+ if (info_flag == 0) {
+ return; /* noop unless extra information is requested */
+ }
+ range = GeoIP_range_by_ip(gi, __num_to_addr_r(ipnum, ipaddr));
+ if (range == NULL) {
+ return;
+ }
+
+ printf(" ipaddr: %s\n", ipaddr);
+
+ printf(" range_by_ip: %s - %s\n", range[0], range[1]);
+ last_nm = GeoIP_last_netmask(gi);
+ mask = 0xffffffff << (32 - last_nm);
+ low = ipnum & mask;
+ hi = low + (0xffffffff & ~mask);
+ printf(" network: %s - %s ::%ld\n",
+ __num_to_addr_r(low, ipaddr),
+ __num_to_addr_r(hi, tmp),
+ last_nm);
+ printf(" ipnum: %u\n", ipnum);
+ printf(" range_by_num: %lu - %lu\n",
+ __addr_to_num(range[0]),
+ __addr_to_num(range[1]));
+ printf(" network num: %lu - %lu ::%lu\n", low, hi, last_nm);
+
+ GeoIP_range_by_ip_delete(range);
+}
+
+void geoiplookup(GeoIP *gi, char *hostname, int i) {
+ const char *country_code;
+ const char *country_name;
+ const char *domain_name;
+ const char *asnum_name;
+ int netspeed;
+ int country_id;
+ GeoIPRegion *region;
+ GeoIPRecord *gir;
+ const char *org;
+ uint32_t ipnum;
+
+ ipnum = _GeoIP_lookupaddress(hostname);
+ if (ipnum == 0) {
+ printf("%s: can't resolve hostname ( %s )\n",
+ GeoIPDBDescription[i],
+ hostname);
+ } else {
+ if (GEOIP_DOMAIN_EDITION == i) {
+ domain_name = GeoIP_name_by_ipnum(gi, ipnum);
+ if (domain_name == NULL) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s\n", GeoIPDBDescription[i], domain_name);
+ _say_range_by_ip(gi, ipnum);
+ free((void *)domain_name);
+ }
+ } else if (GEOIP_LOCATIONA_EDITION == i ||
+ GEOIP_ACCURACYRADIUS_EDITION == i ||
+ GEOIP_ASNUM_EDITION == i || GEOIP_USERTYPE_EDITION == i ||
+ GEOIP_REGISTRAR_EDITION == i ||
+ GEOIP_NETSPEED_EDITION_REV1 == i ||
+ GEOIP_COUNTRYCONF_EDITION == i ||
+ GEOIP_CITYCONF_EDITION == i ||
+ GEOIP_REGIONCONF_EDITION == i ||
+ GEOIP_POSTALCONF_EDITION == i) {
+ asnum_name = GeoIP_name_by_ipnum(gi, ipnum);
+ if (asnum_name == NULL) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s\n", GeoIPDBDescription[i], asnum_name);
+ _say_range_by_ip(gi, ipnum);
+ free((void *)asnum_name);
+ }
+ } else if (GEOIP_COUNTRY_EDITION == i) {
+ country_id = GeoIP_id_by_ipnum(gi, ipnum);
+ if (country_id < 0 || country_id >= (int)GeoIP_num_countries()) {
+ printf("%s: Invalid database\n", GeoIPDBDescription[i]);
+ return;
+ }
+ country_code = GeoIP_country_code[country_id];
+ country_name = GeoIP_country_name[country_id];
+ if (country_id == 0) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s\n",
+ GeoIPDBDescription[i],
+ country_code,
+ country_name);
+ _say_range_by_ip(gi, ipnum);
+ }
+ } else if (GEOIP_REGION_EDITION_REV0 == i ||
+ GEOIP_REGION_EDITION_REV1 == i) {
+ region = GeoIP_region_by_ipnum(gi, ipnum);
+ if (NULL == region || region->country_code[0] == '\0') {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s\n",
+ GeoIPDBDescription[i],
+ region->country_code,
+ region->region);
+ _say_range_by_ip(gi, ipnum);
+ }
+ if (region) {
+ GeoIPRegion_delete(region);
+ }
+ } else if (GEOIP_CITY_EDITION_REV0 == i) {
+ gir = GeoIP_record_by_ipnum(gi, ipnum);
+ if (NULL == gir) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s, %s, %s, %s, %f, %f\n",
+ GeoIPDBDescription[i],
+ gir->country_code,
+ _mk_NA(gir->region),
+ _mk_NA(GeoIP_region_name_by_code(gir->country_code,
+ gir->region)),
+ _mk_NA(gir->city),
+ _mk_NA(gir->postal_code),
+ gir->latitude,
+ gir->longitude);
+ _say_range_by_ip(gi, ipnum);
+ GeoIPRecord_delete(gir);
+ }
+ } else if (GEOIP_CITY_EDITION_REV1 == i) {
+ gir = GeoIP_record_by_ipnum(gi, ipnum);
+ if (NULL == gir) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s, %s, %s, %s, %f, %f, %d, %d\n",
+ GeoIPDBDescription[i],
+ gir->country_code,
+ _mk_NA(gir->region),
+ _mk_NA(GeoIP_region_name_by_code(gir->country_code,
+ gir->region)),
+ _mk_NA(gir->city),
+ _mk_NA(gir->postal_code),
+ gir->latitude,
+ gir->longitude,
+ gir->metro_code,
+ gir->area_code);
+ _say_range_by_ip(gi, ipnum);
+ GeoIPRecord_delete(gir);
+ }
+ } else if (GEOIP_ORG_EDITION == i || GEOIP_ISP_EDITION == i) {
+ org = GeoIP_org_by_ipnum(gi, ipnum);
+ if (org == NULL) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s\n", GeoIPDBDescription[i], org);
+ _say_range_by_ip(gi, ipnum);
+ free((void *)org);
+ }
+ } else if (GEOIP_NETSPEED_EDITION == i) {
+ netspeed = GeoIP_id_by_ipnum(gi, ipnum);
+ if (netspeed == GEOIP_UNKNOWN_SPEED) {
+ printf("%s: Unknown\n", GeoIPDBDescription[i]);
+ } else if (netspeed == GEOIP_DIALUP_SPEED) {
+ printf("%s: Dialup\n", GeoIPDBDescription[i]);
+ } else if (netspeed == GEOIP_CABLEDSL_SPEED) {
+ printf("%s: Cable/DSL\n", GeoIPDBDescription[i]);
+ } else if (netspeed == GEOIP_CORPORATE_SPEED) {
+ printf("%s: Corporate\n", GeoIPDBDescription[i]);
+ }
+ _say_range_by_ip(gi, ipnum);
+ }
+ }
+}
diff --git a/apps/geoiplookup6.c b/apps/geoiplookup6.c
new file mode 100644
index 0000000..fe81d98
--- /dev/null
+++ b/apps/geoiplookup6.c
@@ -0,0 +1,195 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* geoiplookup.c
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "GeoIP.h"
+#include "GeoIPCity.h"
+#include "GeoIP_internal.h"
+void geoiplookup(GeoIP *gi, char *hostname, int i);
+
+void usage(void) {
+ fprintf(stderr,
+ "Usage: geoiplookup [-h] [-d custom_dir] [-f custom_file] "
+ "[-v] <ipaddress|hostname>\n");
+}
+
+int main(int argc, char *argv[]) {
+ char *hostname = NULL;
+ char *db_info;
+ GeoIP *gi;
+ int i;
+ char *custom_directory = NULL;
+ char *custom_file = NULL;
+ int version_flag = 0;
+
+ if (argc < 2) {
+ usage();
+ exit(1);
+ }
+ i = 1;
+ while (i < argc) {
+ if (strcmp(argv[i], "-v") == 0) {
+ version_flag = 1;
+ } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-?") == 0) {
+ usage();
+ exit(0);
+ } else if (strcmp(argv[i], "-f") == 0) {
+ if ((i + 1) < argc) {
+ i++;
+ custom_file = argv[i];
+ }
+ } else if (strcmp(argv[i], "-d") == 0) {
+ if ((i + 1) < argc) {
+ i++;
+ custom_directory = argv[i];
+ }
+ } else {
+ hostname = argv[i];
+ }
+ i++;
+ }
+ if (hostname == NULL) {
+ usage();
+ exit(1);
+ }
+
+ if (custom_directory != NULL) {
+ GeoIP_setup_custom_directory(custom_directory);
+ }
+ _GeoIP_setup_dbfilename();
+
+ if (custom_file != NULL) {
+ gi = GeoIP_open(custom_file, GEOIP_STANDARD | GEOIP_SILENCE);
+ if (NULL == gi) {
+ printf("%s not available, skipping...\n", custom_file);
+ } else {
+ i = GeoIP_database_edition(gi);
+ if (version_flag == 1) {
+ db_info = GeoIP_database_info(gi);
+ printf("%s: %s\n",
+ GeoIPDBDescription[i],
+ db_info == NULL ? "" : db_info);
+ free(db_info);
+ } else {
+ geoiplookup(gi, hostname, i);
+ }
+ }
+ GeoIP_delete(gi);
+ } else {
+ /* iterate through different database types */
+ for (i = 0; i < NUM_DB_TYPES; ++i) {
+ if (GeoIP_db_avail(i)) {
+ gi = GeoIP_open_type(i, GEOIP_STANDARD | GEOIP_SILENCE);
+ if (NULL == gi) {
+ /* Ignore these errors. It's possible
+ * to use the same database name for
+ * different databases.
+ */
+ ;
+ } else {
+ if (version_flag == 1) {
+ db_info = GeoIP_database_info(gi);
+ printf("%s: %s\n", GeoIPDBDescription[i], db_info);
+ free(db_info);
+ } else {
+ geoiplookup(gi, hostname, i);
+ }
+ }
+ GeoIP_delete(gi);
+ }
+ }
+ }
+ return 0;
+}
+
+static const char *_mk_NA(const char *p) { return p ? p : "N/A"; }
+
+void geoiplookup(GeoIP *gi, char *hostname, int i) {
+ const char *country_code;
+ const char *country_name;
+ const char *asnum_name;
+ int country_id;
+ GeoIPRecord *gir;
+
+ geoipv6_t ipnum;
+ ipnum = _GeoIP_lookupaddress_v6(hostname);
+ if (__GEOIP_V6_IS_NULL(ipnum)) {
+ printf("%s: can't resolve hostname ( %s )\n",
+ GeoIPDBDescription[i],
+ hostname);
+ } else {
+ if (GEOIP_LOCATIONA_EDITION_V6 == i || GEOIP_ASNUM_EDITION_V6 == i ||
+ GEOIP_USERTYPE_EDITION_V6 == i || GEOIP_REGISTRAR_EDITION_V6 == i ||
+ GEOIP_DOMAIN_EDITION_V6 == i || GEOIP_ORG_EDITION_V6 == i ||
+ GEOIP_ISP_EDITION_V6 == i || GEOIP_NETSPEED_EDITION_REV1_V6 == i) {
+ asnum_name = GeoIP_name_by_ipnum_v6(gi, ipnum);
+ if (asnum_name == NULL) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s\n", GeoIPDBDescription[i], asnum_name);
+ }
+ } else if (GEOIP_CITY_EDITION_REV0_V6 == i) {
+ gir = GeoIP_record_by_ipnum_v6(gi, ipnum);
+ if (NULL == gir) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s, %s, %s, %f, %f\n",
+ GeoIPDBDescription[i],
+ gir->country_code,
+ _mk_NA(gir->region),
+ _mk_NA(gir->city),
+ _mk_NA(gir->postal_code),
+ gir->latitude,
+ gir->longitude);
+ }
+ } else if (GEOIP_CITY_EDITION_REV1_V6 == i) {
+ gir = GeoIP_record_by_ipnum_v6(gi, ipnum);
+ if (NULL == gir) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s, %s, %s, %f, %f, %d, %d\n",
+ GeoIPDBDescription[i],
+ gir->country_code,
+ _mk_NA(gir->region),
+ _mk_NA(gir->city),
+ _mk_NA(gir->postal_code),
+ gir->latitude,
+ gir->longitude,
+ gir->metro_code,
+ gir->area_code);
+ }
+ } else if (GEOIP_COUNTRY_EDITION_V6 == i) {
+ country_id = GeoIP_id_by_ipnum_v6(gi, ipnum);
+ if (country_id < 0 || country_id >= (int)GeoIP_num_countries()) {
+ printf("%s: Invalid database\n", GeoIPDBDescription[i]);
+ return;
+ }
+ country_code = GeoIP_country_code[country_id];
+ country_name = GeoIP_country_name[country_id];
+ if (country_id == 0) {
+ printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
+ } else {
+ printf("%s: %s, %s\n",
+ GeoIPDBDescription[i],
+ country_code,
+ country_name);
+ }
+ }
+ }
+}
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..ddeb7ca
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,20 @@
+---
+install:
+ - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64'
+build_script:
+ - nmake /f Makefile.vc
+notifications:
+ - incoming_webhook:
+ secure: 8FZP/RE3nS77Yi5UWOB/DQKCRSJxh/BYrLjVPEAkBG6mRojCz3r2mnla4O/5GwzDr7V6XCpxCP0xo1buCcZRIzRN0ZUWJ5hzEQqW5u7R+vM=
+ channel: ci
+ on_build_failure: true
+ on_build_status_changed: true
+ on_build_success: true
+ provider: Slack
+ - on_build_failure: true
+ on_build_status_changed: true
+ on_build_success: false
+ provider: Email
+ subject: 'AppVeyor build {{status}}'
+ to:
+ - dev-ci@maxmind.com
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..30fc0f9
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# make sure to use the installed libtool
+rm -f ltmain.sh
+autoreconf -fiv
+
+###################################################
+# the steps below may help with outdated toolsets
+
+# disable dependency trackeing for OS X with multiply arch option's
+# automake -i --gnu --add-missing
+
+
+#aclocal \
+#&& automake -i --gnu --add-missing \
+#&& autoconf
+
+#LIBTOOLIZE=$( which libtoolize glibtoolize | head -1 )
+#$LIBTOOLIZE -f
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..28d098c
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,77 @@
+dnl AM_CONFIG_HEADER(config.h)
+
+AC_PREREQ([2.63])
+AC_INIT([GeoIP], [1.6.12],[support@maxmind.com],[GeoIP])
+AC_CONFIG_AUX_DIR([.])
+AC_CONFIG_SRCDIR([libGeoIP/GeoIP.c])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE(1.10.0)
+AC_GNU_SOURCE
+GEOIP_VERSION_INFO=`echo $VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'`
+AC_SUBST(GEOIP_VERSION_INFO)
+
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+AC_CHECK_TYPE(byte,[AC_DEFINE(HAVE_BYTE_TYPEDEF)],[])
+AC_CHECK_TYPE(ushort,[AC_DEFINE(HAVE_USHORT_TYPEDEF)],[])
+AC_CHECK_TYPE(ulong,[AC_DEFINE(HAVE_ULONG_TYPEDEF)],[])
+AC_CHECK_TYPE(u16,[AC_DEFINE(HAVE_U16_TYPEDEF)],[])
+AC_CHECK_TYPE(u32,[AC_DEFINE(HAVE_U32_TYPEDEF)],[])
+
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+
+AC_C_BIGENDIAN([AC_DEFINE(BIG_ENDIAN_HOST,1)],[AC_DEFINE(LITTLE_ENDIAN_HOST,1)])
+
+AC_CHECK_FUNC(getopt, AC_DEFINE(HAVE_GETOPT))
+AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY))
+AC_CHECK_FUNC(pread, AC_DEFINE(HAVE_PREAD))
+AC_CHECK_FUNC(vasprintf, AC_DEFINE(HAVE_VASPRINTF))
+AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
+AC_CHECK_FUNC(vsprintf, AC_DEFINE(HAVE_VSPRINTF))
+
+AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME),
+ AC_CHECK_LIB(nsl, gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME)
+ LIBS="${LIBS} -lsocket -lnsl"))
+
+AC_CHECK_FUNC(gethostbyname_r, [
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R)
+ # We look for the one that returns `int'.
+ # Hopefully this check is robust enough.
+ AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
+ AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])
+ ])
+
+AC_CHECK_FUNCS([ memset memchr munmap strrchr socket strchr strdup strstr ])
+
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_FUNC_MMAP
+
+AC_ARG_ENABLE([data-files],
+ AS_HELP_STRING([--disable-data-files], [Install library without installing data files]))
+
+AS_IF([test "x$enable_data_files" != xno],
+ AC_SUBST([GEOIP_DB_FILE],[GeoIP.dat]))
+
+case $host_os in
+ mingw* )
+ # To do: Check for and add -Wl,--high-entropy-va if it's supported.
+ LDFLAGS="$LDFLAGS -lwsock32 -lws2_32 -Wl,--dynamicbase -Wl,--nxcompat"
+ ;;
+esac
+
+
+AC_OUTPUT([
+Makefile
+GeoIP.spec
+geoip.pc
+libGeoIP/Makefile
+apps/Makefile
+man/Makefile
+test/Makefile
+])
diff --git a/data/GeoIP.dat b/data/GeoIP.dat
new file mode 100644
index 0000000..a092ad7
--- /dev/null
+++ b/data/GeoIP.dat
Binary files differ
diff --git a/dev-bin/clang-format-all.sh b/dev-bin/clang-format-all.sh
new file mode 100755
index 0000000..b8bec61
--- /dev/null
+++ b/dev-bin/clang-format-all.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+format="clang-format -i -style=file"
+
+for dir in apps libGeoIP test; do
+ c_files=`find $dir -maxdepth 1 -name '*.c'`
+ if [ "$c_files" != "" ]; then
+ $format $dir/*.c;
+ fi
+
+ h_files=`find $dir -maxdepth 1 -name '*.h'`
+ if [ "$h_files" != "" ]; then
+ $format $dir/*.h;
+ fi
+done
diff --git a/dev-bin/release.sh b/dev-bin/release.sh
new file mode 100755
index 0000000..ec6ccfa
--- /dev/null
+++ b/dev-bin/release.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+set -eu -o pipefail
+
+changelog=$(cat ChangeLog)
+
+regex='([0-9]+\.[0-9]+\.[0-9]+) ([0-9]{4}-[0-9]{2}-[0-9]{2})
+
+((.|
+)*)
+'
+
+if [[ ! $changelog =~ $regex ]]; then
+ echo "Could not find date line in change log!"
+ exit 1
+fi
+
+version="${BASH_REMATCH[1]}"
+date="${BASH_REMATCH[2]}"
+notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^[0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
+
+dist="GeoIP-$version.tar.gz"
+
+if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
+ echo "$date is not today!"
+ exit 1
+fi
+
+if [ -n "$(git status --porcelain)" ]; then
+ echo ". is not clean." >&2
+ exit 1
+fi
+
+perl -pi -e "s/(?<=AC_INIT\(\[GeoIP\], \[)(\d+\.\d+\.\d+)(?=])/$version/gsm" configure.ac
+
+if [ -n "$(git status --porcelain)" ]; then
+ git add configure.ac
+ git commit -m "Bumped version to $version"
+fi
+
+./bootstrap
+./configure
+make
+make check
+make clean
+make dist
+
+read -p "Push to origin? (y/n) " should_push
+
+if [ "$should_push" != "y" ]; then
+ echo "Aborting"
+ exit 1
+fi
+
+git push
+
+message="$version
+
+$notes"
+
+hub release create -a "$dist" -m "$message" "v$version"
diff --git a/geoip.ico b/geoip.ico
new file mode 100644
index 0000000..ac13353
--- /dev/null
+++ b/geoip.ico
Binary files differ
diff --git a/geoip.pc.in b/geoip.pc.in
new file mode 100644
index 0000000..31b8fff
--- /dev/null
+++ b/geoip.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@prefix@
+libdir=@libdir@
+includedir=@includedir@
+datadir=@datarootdir@
+
+Name: geoip
+Description: A non-DNS IP-to-country resolver library.
+Version: @VERSION@
+Libs: -L${libdir} -lGeoIP
+Cflags: -I${includedir}/
+databasedir=${datadir}/GeoIP
diff --git a/get_ver.awk b/get_ver.awk
new file mode 100644
index 0000000..0314881
--- /dev/null
+++ b/get_ver.awk
@@ -0,0 +1,14 @@
+# fetch version number from input file and write them to STDOUT
+BEGIN {
+ while ((getline < ARGV[1]) > 0) {
+ if (match ($0, /^VERSION=/)) {
+ split($1, t, "=");
+ my_ver_str = t[2];
+ split(my_ver_str, v, ".");
+ gsub("[^0-9].*$", "", v[3]);
+ my_ver = v[1] "," v[2] "," v[3];
+ }
+ }
+ print "GEOIP_VERSION = " my_ver "";
+ print "GEOIP_VERSION_STR = " my_ver_str "";
+}
diff --git a/libGeoIP/GeoIP.c b/libGeoIP/GeoIP.c
new file mode 100644
index 0000000..587326a
--- /dev/null
+++ b/libGeoIP/GeoIP.c
@@ -0,0 +1,2766 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* GeoIP.c
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "GeoIP.h"
+#include "GeoIP_internal.h"
+
+static geoipv6_t IPV6_NULL;
+
+#if defined(_WIN32)
+#include <io.h>
+
+#ifdef _MSC_VER
+#if _MSC_VER < 1900 // VS 2015 supports snprintf
+#define snprintf _snprintf
+#endif
+#if _MSC_VER >= 1400 // VS 2005+ deprecates fileno, lseek and read
+#define fileno _fileno
+#define read _read
+#define lseek _lseek
+#endif
+#endif
+#else
+#include <netdb.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#endif /* defined(_WIN32) */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h> /* for fstat */
+#include <sys/types.h> /* for fstat */
+
+#ifdef HAVE_GETTIMEOFDAY
+#include <sys/time.h> /* for gettimeofday */
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h> /* For uint32_t */
+#endif
+
+#if defined(_WIN32) && !defined(__MINGW32__)
+#include "pread.h"
+#endif
+
+#ifdef _UNUSED
+#elif defined(__GNUC__)
+#define _UNUSED __attribute__((unused))
+#else
+#define _UNUSED
+#endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE -1
+#endif
+
+#define COUNTRY_BEGIN 16776960
+#define LARGE_COUNTRY_BEGIN 16515072
+#define STATE_BEGIN_REV0 16700000
+#define STATE_BEGIN_REV1 16000000
+#define STRUCTURE_INFO_MAX_SIZE 20
+#define DATABASE_INFO_MAX_SIZE 100
+#define MAX_ORG_RECORD_LENGTH 300
+#define US_OFFSET 1
+#define CANADA_OFFSET 677
+#define WORLD_OFFSET 1353
+#define FIPS_RANGE 360
+
+#define DEBUG_MSGF(flags, fmt, ...) \
+ { \
+ if (((flags)&GEOIP_SILENCE) == 0) { \
+ fprintf(stderr, fmt, ##__VA_ARGS__); \
+ } \
+ }
+
+#ifndef HAVE_PREAD
+#define pread(fd, buf, count, offset) \
+ (lseek(fd, offset, SEEK_SET) == offset ? read(fd, buf, count) : -1)
+#endif /* HAVE_PREAD */
+
+const char GeoIP_country_code[256][3] = {
+ "--", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "CW", "AO",
+ "AQ", "AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF",
+ "BG", "BH", "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW",
+ "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM",
+ "CN", "CO", "CR", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM",
+ "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK",
+ "FM", "FO", "FR", "SX", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL",
+ "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM",
+ "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IO", "IQ", "IR", "IS",
+ "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR",
+ "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU",
+ "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", "MO",
+ "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
+ "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM",
+ "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT",
+ "PW", "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE",
+ "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV",
+ "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO",
+ "TL", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ",
+ "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "RS",
+ "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", "AX", "GG", "IM", "JE", "BL",
+ "MF", "BQ", "SS", "O1"};
+
+static const unsigned num_GeoIP_countries =
+ (unsigned)(sizeof(GeoIP_country_code) / sizeof(GeoIP_country_code[0]));
+
+const char GeoIP_country_code3[256][4] = {
+ "--", "AP", "EU", "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "CUW",
+ "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "AZE", "BIH", "BRB", "BGD",
+ "BEL", "BFA", "BGR", "BHR", "BDI", "BEN", "BMU", "BRN", "BOL", "BRA", "BHS",
+ "BTN", "BVT", "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG", "CHE",
+ "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", "CUB", "CPV", "CXR", "CYP",
+ "CZE", "DEU", "DJI", "DNK", "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH",
+ "ERI", "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", "SXM", "GAB",
+ "GBR", "GRD", "GEO", "GUF", "GHA", "GIB", "GRL", "GMB", "GIN", "GLP", "GNQ",
+ "GRC", "SGS", "GTM", "GUM", "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI",
+ "HUN", "IDN", "IRL", "ISR", "IND", "IOT", "IRQ", "IRN", "ISL", "ITA", "JAM",
+ "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", "COM", "KNA", "PRK", "KOR", "KWT",
+ "CYM", "KAZ", "LAO", "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX",
+ "LVA", "LBY", "MAR", "MCO", "MDA", "MDG", "MHL", "MKD", "MLI", "MMR", "MNG",
+ "MAC", "MNP", "MTQ", "MRT", "MSR", "MLT", "MUS", "MDV", "MWI", "MEX", "MYS",
+ "MOZ", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", "NRU",
+ "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG", "PHL", "PAK", "POL", "SPM",
+ "PCN", "PRI", "PSE", "PRT", "PLW", "PRY", "QAT", "REU", "ROU", "RUS", "RWA",
+ "SAU", "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM", "SVK", "SLE",
+ "SMR", "SEN", "SOM", "SUR", "STP", "SLV", "SYR", "SWZ", "TCA", "TCD", "ATF",
+ "TGO", "THA", "TJK", "TKL", "TKM", "TUN", "TON", "TLS", "TUR", "TTO", "TUV",
+ "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB", "VAT", "VCT", "VEN",
+ "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "YEM", "MYT", "SRB", "ZAF", "ZMB",
+ "MNE", "ZWE", "A1", "A2", "O1", "ALA", "GGY", "IMN", "JEY", "BLM", "MAF",
+ "BES", "SSD", "O1"};
+
+const char *GeoIP_utf8_country_name[256] = {
+ "N/A",
+ "Asia/Pacific Region",
+ "Europe",
+ "Andorra",
+ "United Arab Emirates",
+ "Afghanistan",
+ "Antigua and Barbuda",
+ "Anguilla",
+ "Albania",
+ "Armenia",
+ "Cura"
+ "\xc3\xa7"
+ "ao",
+ "Angola",
+ "Antarctica",
+ "Argentina",
+ "American Samoa",
+ "Austria",
+ "Australia",
+ "Aruba",
+ "Azerbaijan",
+ "Bosnia and Herzegovina",
+ "Barbados",
+ "Bangladesh",
+ "Belgium",
+ "Burkina Faso",
+ "Bulgaria",
+ "Bahrain",
+ "Burundi",
+ "Benin",
+ "Bermuda",
+ "Brunei Darussalam",
+ "Bolivia",
+ "Brazil",
+ "Bahamas",
+ "Bhutan",
+ "Bouvet Island",
+ "Botswana",
+ "Belarus",
+ "Belize",
+ "Canada",
+ "Cocos (Keeling) Islands",
+ "Congo, The Democratic Republic of the",
+ "Central African Republic",
+ "Congo",
+ "Switzerland",
+ "Cote D'Ivoire",
+ "Cook Islands",
+ "Chile",
+ "Cameroon",
+ "China",
+ "Colombia",
+ "Costa Rica",
+ "Cuba",
+ "Cape Verde",
+ "Christmas Island",
+ "Cyprus",
+ "Czech Republic",
+ "Germany",
+ "Djibouti",
+ "Denmark",
+ "Dominica",
+ "Dominican Republic",
+ "Algeria",
+ "Ecuador",
+ "Estonia",
+ "Egypt",
+ "Western Sahara",
+ "Eritrea",
+ "Spain",
+ "Ethiopia",
+ "Finland",
+ "Fiji",
+ "Falkland Islands (Malvinas)",
+ "Micronesia, Federated States of",
+ "Faroe Islands",
+ "France",
+ "Sint Maarten (Dutch part)",
+ "Gabon",
+ "United Kingdom",
+ "Grenada",
+ "Georgia",
+ "French Guiana",
+ "Ghana",
+ "Gibraltar",
+ "Greenland",
+ "Gambia",
+ "Guinea",
+ "Guadeloupe",
+ "Equatorial Guinea",
+ "Greece",
+ "South Georgia and the South Sandwich Islands",
+ "Guatemala",
+ "Guam",
+ "Guinea-Bissau",
+ "Guyana",
+ "Hong Kong",
+ "Heard Island and McDonald Islands",
+ "Honduras",
+ "Croatia",
+ "Haiti",
+ "Hungary",
+ "Indonesia",
+ "Ireland",
+ "Israel",
+ "India",
+ "British Indian Ocean Territory",
+ "Iraq",
+ "Iran, Islamic Republic of",
+ "Iceland",
+ "Italy",
+ "Jamaica",
+ "Jordan",
+ "Japan",
+ "Kenya",
+ "Kyrgyzstan",
+ "Cambodia",
+ "Kiribati",
+ "Comoros",
+ "Saint Kitts and Nevis",
+ "Korea, Democratic People's Republic of",
+ "Korea, Republic of",
+ "Kuwait",
+ "Cayman Islands",
+ "Kazakhstan",
+ "Lao People's Democratic Republic",
+ "Lebanon",
+ "Saint Lucia",
+ "Liechtenstein",
+ "Sri Lanka",
+ "Liberia",
+ "Lesotho",
+ "Lithuania",
+ "Luxembourg",
+ "Latvia",
+ "Libya",
+ "Morocco",
+ "Monaco",
+ "Moldova, Republic of",
+ "Madagascar",
+ "Marshall Islands",
+ "Macedonia",
+ "Mali",
+ "Myanmar",
+ "Mongolia",
+ "Macau",
+ "Northern Mariana Islands",
+ "Martinique",
+ "Mauritania",
+ "Montserrat",
+ "Malta",
+ "Mauritius",
+ "Maldives",
+ "Malawi",
+ "Mexico",
+ "Malaysia",
+ "Mozambique",
+ "Namibia",
+ "New Caledonia",
+ "Niger",
+ "Norfolk Island",
+ "Nigeria",
+ "Nicaragua",
+ "Netherlands",
+ "Norway",
+ "Nepal",
+ "Nauru",
+ "Niue",
+ "New Zealand",
+ "Oman",
+ "Panama",
+ "Peru",
+ "French Polynesia",
+ "Papua New Guinea",
+ "Philippines",
+ "Pakistan",
+ "Poland",
+ "Saint Pierre and Miquelon",
+ "Pitcairn Islands",
+ "Puerto Rico",
+ "Palestinian Territory",
+ "Portugal",
+ "Palau",
+ "Paraguay",
+ "Qatar",
+ "Reunion",
+ "Romania",
+ "Russian Federation",
+ "Rwanda",
+ "Saudi Arabia",
+ "Solomon Islands",
+ "Seychelles",
+ "Sudan",
+ "Sweden",
+ "Singapore",
+ "Saint Helena",
+ "Slovenia",
+ "Svalbard and Jan Mayen",
+ "Slovakia",
+ "Sierra Leone",
+ "San Marino",
+ "Senegal",
+ "Somalia",
+ "Suriname",
+ "Sao Tome and Principe",
+ "El Salvador",
+ "Syrian Arab Republic",
+ "Swaziland",
+ "Turks and Caicos Islands",
+ "Chad",
+ "French Southern Territories",
+ "Togo",
+ "Thailand",
+ "Tajikistan",
+ "Tokelau",
+ "Turkmenistan",
+ "Tunisia",
+ "Tonga",
+ "Timor-Leste",
+ "Turkey",
+ "Trinidad and Tobago",
+ "Tuvalu",
+ "Taiwan",
+ "Tanzania, United Republic of",
+ "Ukraine",
+ "Uganda",
+ "United States Minor Outlying Islands",
+ "United States",
+ "Uruguay",
+ "Uzbekistan",
+ "Holy See (Vatican City State)",
+ "Saint Vincent and the Grenadines",
+ "Venezuela",
+ "Virgin Islands, British",
+ "Virgin Islands, U.S.",
+ "Vietnam",
+ "Vanuatu",
+ "Wallis and Futuna",
+ "Samoa",
+ "Yemen",
+ "Mayotte",
+ "Serbia",
+ "South Africa",
+ "Zambia",
+ "Montenegro",
+ "Zimbabwe",
+ "Anonymous Proxy",
+ "Satellite Provider",
+ "Other",
+ "Aland Islands",
+ "Guernsey",
+ "Isle of Man",
+ "Jersey",
+ "Saint Barthelemy",
+ "Saint Martin",
+ "Bonaire, Saint Eustatius and Saba",
+ "South Sudan",
+ "Other"};
+
+const char *GeoIP_country_name[256] = {
+ "N/A",
+ "Asia/Pacific Region",
+ "Europe",
+ "Andorra",
+ "United Arab Emirates",
+ "Afghanistan",
+ "Antigua and Barbuda",
+ "Anguilla",
+ "Albania",
+ "Armenia",
+ "Curacao",
+ "Angola",
+ "Antarctica",
+ "Argentina",
+ "American Samoa",
+ "Austria",
+ "Australia",
+ "Aruba",
+ "Azerbaijan",
+ "Bosnia and Herzegovina",
+ "Barbados",
+ "Bangladesh",
+ "Belgium",
+ "Burkina Faso",
+ "Bulgaria",
+ "Bahrain",
+ "Burundi",
+ "Benin",
+ "Bermuda",
+ "Brunei Darussalam",
+ "Bolivia",
+ "Brazil",
+ "Bahamas",
+ "Bhutan",
+ "Bouvet Island",
+ "Botswana",
+ "Belarus",
+ "Belize",
+ "Canada",
+ "Cocos (Keeling) Islands",
+ "Congo, The Democratic Republic of the",
+ "Central African Republic",
+ "Congo",
+ "Switzerland",
+ "Cote D'Ivoire",
+ "Cook Islands",
+ "Chile",
+ "Cameroon",
+ "China",
+ "Colombia",
+ "Costa Rica",
+ "Cuba",
+ "Cape Verde",
+ "Christmas Island",
+ "Cyprus",
+ "Czech Republic",
+ "Germany",
+ "Djibouti",
+ "Denmark",
+ "Dominica",
+ "Dominican Republic",
+ "Algeria",
+ "Ecuador",
+ "Estonia",
+ "Egypt",
+ "Western Sahara",
+ "Eritrea",
+ "Spain",
+ "Ethiopia",
+ "Finland",
+ "Fiji",
+ "Falkland Islands (Malvinas)",
+ "Micronesia, Federated States of",
+ "Faroe Islands",
+ "France",
+ "Sint Maarten (Dutch part)",
+ "Gabon",
+ "United Kingdom",
+ "Grenada",
+ "Georgia",
+ "French Guiana",
+ "Ghana",
+ "Gibraltar",
+ "Greenland",
+ "Gambia",
+ "Guinea",
+ "Guadeloupe",
+ "Equatorial Guinea",
+ "Greece",
+ "South Georgia and the South Sandwich Islands",
+ "Guatemala",
+ "Guam",
+ "Guinea-Bissau",
+ "Guyana",
+ "Hong Kong",
+ "Heard Island and McDonald Islands",
+ "Honduras",
+ "Croatia",
+ "Haiti",
+ "Hungary",
+ "Indonesia",
+ "Ireland",
+ "Israel",
+ "India",
+ "British Indian Ocean Territory",
+ "Iraq",
+ "Iran, Islamic Republic of",
+ "Iceland",
+ "Italy",
+ "Jamaica",
+ "Jordan",
+ "Japan",
+ "Kenya",
+ "Kyrgyzstan",
+ "Cambodia",
+ "Kiribati",
+ "Comoros",
+ "Saint Kitts and Nevis",
+ "Korea, Democratic People's Republic of",
+ "Korea, Republic of",
+ "Kuwait",
+ "Cayman Islands",
+ "Kazakhstan",
+ "Lao People's Democratic Republic",
+ "Lebanon",
+ "Saint Lucia",
+ "Liechtenstein",
+ "Sri Lanka",
+ "Liberia",
+ "Lesotho",
+ "Lithuania",
+ "Luxembourg",
+ "Latvia",
+ "Libya",
+ "Morocco",
+ "Monaco",
+ "Moldova, Republic of",
+ "Madagascar",
+ "Marshall Islands",
+ "Macedonia",
+ "Mali",
+ "Myanmar",
+ "Mongolia",
+ "Macau",
+ "Northern Mariana Islands",
+ "Martinique",
+ "Mauritania",
+ "Montserrat",
+ "Malta",
+ "Mauritius",
+ "Maldives",
+ "Malawi",
+ "Mexico",
+ "Malaysia",
+ "Mozambique",
+ "Namibia",
+ "New Caledonia",
+ "Niger",
+ "Norfolk Island",
+ "Nigeria",
+ "Nicaragua",
+ "Netherlands",
+ "Norway",
+ "Nepal",
+ "Nauru",
+ "Niue",
+ "New Zealand",
+ "Oman",
+ "Panama",
+ "Peru",
+ "French Polynesia",
+ "Papua New Guinea",
+ "Philippines",
+ "Pakistan",
+ "Poland",
+ "Saint Pierre and Miquelon",
+ "Pitcairn Islands",
+ "Puerto Rico",
+ "Palestinian Territory",
+ "Portugal",
+ "Palau",
+ "Paraguay",
+ "Qatar",
+ "Reunion",
+ "Romania",
+ "Russian Federation",
+ "Rwanda",
+ "Saudi Arabia",
+ "Solomon Islands",
+ "Seychelles",
+ "Sudan",
+ "Sweden",
+ "Singapore",
+ "Saint Helena",
+ "Slovenia",
+ "Svalbard and Jan Mayen",
+ "Slovakia",
+ "Sierra Leone",
+ "San Marino",
+ "Senegal",
+ "Somalia",
+ "Suriname",
+ "Sao Tome and Principe",
+ "El Salvador",
+ "Syrian Arab Republic",
+ "Swaziland",
+ "Turks and Caicos Islands",
+ "Chad",
+ "French Southern Territories",
+ "Togo",
+ "Thailand",
+ "Tajikistan",
+ "Tokelau",
+ "Turkmenistan",
+ "Tunisia",
+ "Tonga",
+ "Timor-Leste",
+ "Turkey",
+ "Trinidad and Tobago",
+ "Tuvalu",
+ "Taiwan",
+ "Tanzania, United Republic of",
+ "Ukraine",
+ "Uganda",
+ "United States Minor Outlying Islands",
+ "United States",
+ "Uruguay",
+ "Uzbekistan",
+ "Holy See (Vatican City State)",
+ "Saint Vincent and the Grenadines",
+ "Venezuela",
+ "Virgin Islands, British",
+ "Virgin Islands, U.S.",
+ "Vietnam",
+ "Vanuatu",
+ "Wallis and Futuna",
+ "Samoa",
+ "Yemen",
+ "Mayotte",
+ "Serbia",
+ "South Africa",
+ "Zambia",
+ "Montenegro",
+ "Zimbabwe",
+ "Anonymous Proxy",
+ "Satellite Provider",
+ "Other",
+ "Aland Islands",
+ "Guernsey",
+ "Isle of Man",
+ "Jersey",
+ "Saint Barthelemy",
+ "Saint Martin",
+ "Bonaire, Saint Eustatius and Saba",
+ "South Sudan",
+ "Other"};
+
+/* Possible continent codes are AF, AS, EU, NA, OC, SA for Africa, Asia, Europe,
+ North America, Oceania
+ and South America. */
+
+const char GeoIP_country_continent[256][3] = {
+ "--", "AS", "EU", "EU", "AS", "AS", "NA", "NA", "EU", "AS", "NA", "AF",
+ "AN", "SA", "OC", "EU", "OC", "NA", "AS", "EU", "NA", "AS", "EU", "AF",
+ "EU", "AS", "AF", "AF", "NA", "AS", "SA", "SA", "NA", "AS", "AN", "AF",
+ "EU", "NA", "NA", "AS", "AF", "AF", "AF", "EU", "AF", "OC", "SA", "AF",
+ "AS", "SA", "NA", "NA", "AF", "AS", "AS", "EU", "EU", "AF", "EU", "NA",
+ "NA", "AF", "SA", "EU", "AF", "AF", "AF", "EU", "AF", "EU", "OC", "SA",
+ "OC", "EU", "EU", "NA", "AF", "EU", "NA", "AS", "SA", "AF", "EU", "NA",
+ "AF", "AF", "NA", "AF", "EU", "AN", "NA", "OC", "AF", "SA", "AS", "AN",
+ "NA", "EU", "NA", "EU", "AS", "EU", "AS", "AS", "AS", "AS", "AS", "EU",
+ "EU", "NA", "AS", "AS", "AF", "AS", "AS", "OC", "AF", "NA", "AS", "AS",
+ "AS", "NA", "AS", "AS", "AS", "NA", "EU", "AS", "AF", "AF", "EU", "EU",
+ "EU", "AF", "AF", "EU", "EU", "AF", "OC", "EU", "AF", "AS", "AS", "AS",
+ "OC", "NA", "AF", "NA", "EU", "AF", "AS", "AF", "NA", "AS", "AF", "AF",
+ "OC", "AF", "OC", "AF", "NA", "EU", "EU", "AS", "OC", "OC", "OC", "AS",
+ "NA", "SA", "OC", "OC", "AS", "AS", "EU", "NA", "OC", "NA", "AS", "EU",
+ "OC", "SA", "AS", "AF", "EU", "EU", "AF", "AS", "OC", "AF", "AF", "EU",
+ "AS", "AF", "EU", "EU", "EU", "AF", "EU", "AF", "AF", "SA", "AF", "NA",
+ "AS", "AF", "NA", "AF", "AN", "AF", "AS", "AS", "OC", "AS", "AF", "OC",
+ "AS", "EU", "NA", "OC", "AS", "AF", "EU", "AF", "OC", "NA", "SA", "AS",
+ "EU", "NA", "SA", "NA", "NA", "AS", "OC", "OC", "OC", "AS", "AF", "EU",
+ "AF", "AF", "EU", "AF", "--", "--", "--", "EU", "EU", "EU", "EU", "NA",
+ "NA", "NA", "AF", "--"};
+
+static const char *get_db_description(int dbtype) {
+ const char *ptr;
+ if (dbtype >= NUM_DB_TYPES || dbtype < 0) {
+ return "Unknown";
+ }
+ ptr = GeoIPDBDescription[dbtype];
+ return ptr == NULL ? "Unknown" : ptr;
+}
+
+geoipv6_t _GeoIP_lookupaddress_v6(const char *host);
+
+#if defined(_WIN32)
+/* http://www.mail-archive.com/users@ipv6.org/msg02107.html */
+static const char *
+_GeoIP_inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
+ if (af == AF_INET) {
+ struct sockaddr_in in;
+ memset(&in, 0, sizeof(in));
+ in.sin_family = AF_INET;
+ memcpy(&in.sin_addr, src, sizeof(struct in_addr));
+ getnameinfo((struct sockaddr *)&in,
+ sizeof(struct sockaddr_in),
+ dst,
+ cnt,
+ NULL,
+ 0,
+ NI_NUMERICHOST);
+ return dst;
+ } else if (af == AF_INET6) {
+ struct sockaddr_in6 in;
+ memset(&in, 0, sizeof(in));
+ in.sin6_family = AF_INET6;
+ memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
+ getnameinfo((struct sockaddr *)&in,
+ sizeof(struct sockaddr_in6),
+ dst,
+ cnt,
+ NULL,
+ 0,
+ NI_NUMERICHOST);
+ return dst;
+ }
+ return NULL;
+}
+
+static int _GeoIP_inet_pton(int af, const char *src, void *dst) {
+ struct addrinfo hints, *res, *ressave;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = af;
+
+ if (getaddrinfo(src, NULL, &hints, &res) != 0) {
+ return -1;
+ }
+
+ ressave = res;
+
+ while (res) {
+ memcpy(dst, res->ai_addr, res->ai_addrlen);
+ res = res->ai_next;
+ }
+
+ freeaddrinfo(ressave);
+ return 0;
+}
+#else
+static int _GeoIP_inet_pton(int af, const char *src, void *dst) {
+ return inet_pton(af, src, dst);
+}
+static const char *
+_GeoIP_inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
+ return inet_ntop(af, src, dst, cnt);
+}
+#endif /* defined(_WIN32) */
+
+int __GEOIP_V6_IS_NULL(geoipv6_t v6) {
+ int i;
+ for (i = 0; i < 16; i++) {
+ if (v6.s6_addr[i]) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+void __GEOIP_PREPARE_TEREDO(geoipv6_t *v6) {
+ int i;
+ if ((v6->s6_addr[0]) != 0x20) {
+ return;
+ }
+ if ((v6->s6_addr[1]) != 0x01) {
+ return;
+ }
+ if ((v6->s6_addr[2]) != 0x00) {
+ return;
+ }
+ if ((v6->s6_addr[3]) != 0x00) {
+ return;
+ }
+
+ for (i = 0; i < 12; i++) {
+ v6->s6_addr[i] = 0;
+ }
+ for (; i < 16; i++) {
+ v6->s6_addr[i] ^= 0xff;
+ }
+}
+
+const char *GeoIPDBDescription[NUM_DB_TYPES] = {
+ NULL,
+ "GeoIP Country Edition",
+ "GeoIP City Edition, Rev 1",
+ "GeoIP Region Edition, Rev 1",
+ "GeoIP ISP Edition",
+ "GeoIP Organization Edition",
+ "GeoIP City Edition, Rev 0",
+ "GeoIP Region Edition, Rev 0",
+ "GeoIP Proxy Edition",
+ "GeoIP ASNum Edition",
+ "GeoIP Netspeed Edition",
+ "GeoIP Domain Name Edition",
+ "GeoIP Country V6 Edition",
+ "GeoIP LocationID ASCII Edition",
+ "GeoIP Accuracy Radius Edition",
+ NULL,
+ NULL,
+ "GeoIP Large Country Edition",
+ "GeoIP Large Country V6 Edition",
+ NULL,
+ "GeoIP CCM Edition",
+ "GeoIP ASNum V6 Edition",
+ "GeoIP ISP V6 Edition",
+ "GeoIP Organization V6 Edition",
+ "GeoIP Domain Name V6 Edition",
+ "GeoIP LocationID ASCII V6 Edition",
+ "GeoIP Registrar Edition",
+ "GeoIP Registrar V6 Edition",
+ "GeoIP UserType Edition",
+ "GeoIP UserType V6 Edition",
+ "GeoIP City Edition V6, Rev 1",
+ "GeoIP City Edition V6, Rev 0",
+ "GeoIP Netspeed Edition, Rev 1",
+ "GeoIP Netspeed Edition V6, Rev1",
+ "GeoIP Country Confidence Edition",
+ "GeoIP City Confidence Edition",
+ "GeoIP Region Confidence Edition",
+ "GeoIP Postal Confidence Edition",
+ "GeoIP Accuracy Radius Edition V6"};
+
+char *GeoIP_custom_directory = NULL;
+
+void GeoIP_setup_custom_directory(char *dir) { GeoIP_custom_directory = dir; }
+
+char *_GeoIP_full_path_to(const char *file_name) {
+ int len;
+ char *path = malloc(sizeof(char) * 1024);
+
+ if (GeoIP_custom_directory == NULL) {
+#if !defined(_WIN32)
+ memset(path, 0, sizeof(char) * 1024);
+ snprintf(
+ path, sizeof(char) * 1024 - 1, "%s/%s", GEOIPDATADIR, file_name);
+#else
+ char buf[MAX_PATH], *p, *q = NULL;
+ memset(buf, 0, sizeof(buf));
+ len = GetModuleFileNameA(GetModuleHandle(NULL), buf, sizeof(buf) - 1);
+ for (p = buf + len; p > buf; p--) {
+ if (*p == '\\') {
+ if (!q) {
+ q = p;
+ } else {
+ *p = '/';
+ }
+ }
+ }
+ *q = 0;
+ memset(path, 0, sizeof(char) * 1024);
+ snprintf(path, sizeof(char) * 1024 - 1, "%s/%s", buf, file_name);
+#endif
+ } else {
+ len = strlen(GeoIP_custom_directory);
+ if (GeoIP_custom_directory[len - 1] != '/') {
+ snprintf(path,
+ sizeof(char) * 1024 - 1,
+ "%s/%s",
+ GeoIP_custom_directory,
+ file_name);
+ } else {
+ snprintf(path,
+ sizeof(char) * 1024 - 1,
+ "%s%s",
+ GeoIP_custom_directory,
+ file_name);
+ }
+ }
+ return path;
+}
+
+char **GeoIPDBFileName = NULL;
+
+void _GeoIP_setup_dbfilename(void) {
+ if (NULL == GeoIPDBFileName) {
+ GeoIPDBFileName = malloc(sizeof(char *) * NUM_DB_TYPES);
+ memset(GeoIPDBFileName, 0, sizeof(char *) * NUM_DB_TYPES);
+
+ GeoIPDBFileName[GEOIP_COUNTRY_EDITION] =
+ _GeoIP_full_path_to("GeoIP.dat");
+ GeoIPDBFileName[GEOIP_REGION_EDITION_REV0] =
+ _GeoIP_full_path_to("GeoIPRegion.dat");
+ GeoIPDBFileName[GEOIP_REGION_EDITION_REV1] =
+ _GeoIP_full_path_to("GeoIPRegion.dat");
+ GeoIPDBFileName[GEOIP_CITY_EDITION_REV0] =
+ _GeoIP_full_path_to("GeoIPCity.dat");
+ GeoIPDBFileName[GEOIP_CITY_EDITION_REV1] =
+ _GeoIP_full_path_to("GeoIPCity.dat");
+ GeoIPDBFileName[GEOIP_ISP_EDITION] =
+ _GeoIP_full_path_to("GeoIPISP.dat");
+ GeoIPDBFileName[GEOIP_ORG_EDITION] =
+ _GeoIP_full_path_to("GeoIPOrg.dat");
+ GeoIPDBFileName[GEOIP_PROXY_EDITION] =
+ _GeoIP_full_path_to("GeoIPProxy.dat");
+ GeoIPDBFileName[GEOIP_ASNUM_EDITION] =
+ _GeoIP_full_path_to("GeoIPASNum.dat");
+ GeoIPDBFileName[GEOIP_NETSPEED_EDITION] =
+ _GeoIP_full_path_to("GeoIPNetSpeed.dat");
+ GeoIPDBFileName[GEOIP_DOMAIN_EDITION] =
+ _GeoIP_full_path_to("GeoIPDomain.dat");
+ GeoIPDBFileName[GEOIP_COUNTRY_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPv6.dat");
+ GeoIPDBFileName[GEOIP_LOCATIONA_EDITION] =
+ _GeoIP_full_path_to("GeoIPLocA.dat");
+ GeoIPDBFileName[GEOIP_ACCURACYRADIUS_EDITION] =
+ _GeoIP_full_path_to("GeoIPDistance.dat");
+ GeoIPDBFileName[GEOIP_LARGE_COUNTRY_EDITION] =
+ _GeoIP_full_path_to("GeoIP.dat");
+ GeoIPDBFileName[GEOIP_LARGE_COUNTRY_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPv6.dat");
+ GeoIPDBFileName[GEOIP_ASNUM_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPASNumv6.dat");
+ GeoIPDBFileName[GEOIP_ISP_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPISPv6.dat");
+ GeoIPDBFileName[GEOIP_ORG_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPOrgv6.dat");
+ GeoIPDBFileName[GEOIP_DOMAIN_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPDomainv6.dat");
+ GeoIPDBFileName[GEOIP_LOCATIONA_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPLocAv6.dat");
+ GeoIPDBFileName[GEOIP_REGISTRAR_EDITION] =
+ _GeoIP_full_path_to("GeoIPRegistrar.dat");
+ GeoIPDBFileName[GEOIP_REGISTRAR_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPRegistrarv6.dat");
+ GeoIPDBFileName[GEOIP_USERTYPE_EDITION] =
+ _GeoIP_full_path_to("GeoIPUserType.dat");
+ GeoIPDBFileName[GEOIP_USERTYPE_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPUserTypev6.dat");
+ GeoIPDBFileName[GEOIP_CITY_EDITION_REV0_V6] =
+ _GeoIP_full_path_to("GeoIPCityv6.dat");
+ GeoIPDBFileName[GEOIP_CITY_EDITION_REV1_V6] =
+ _GeoIP_full_path_to("GeoIPCityv6.dat");
+ GeoIPDBFileName[GEOIP_NETSPEED_EDITION_REV1] =
+ _GeoIP_full_path_to("GeoIPNetSpeedCell.dat");
+ GeoIPDBFileName[GEOIP_NETSPEED_EDITION_REV1_V6] =
+ _GeoIP_full_path_to("GeoIPNetSpeedCellv6.dat");
+ GeoIPDBFileName[GEOIP_COUNTRYCONF_EDITION] =
+ _GeoIP_full_path_to("GeoIPCountryConf.dat");
+ GeoIPDBFileName[GEOIP_CITYCONF_EDITION] =
+ _GeoIP_full_path_to("GeoIPCityConf.dat");
+ GeoIPDBFileName[GEOIP_REGIONCONF_EDITION] =
+ _GeoIP_full_path_to("GeoIPRegionConf.dat");
+ GeoIPDBFileName[GEOIP_POSTALCONF_EDITION] =
+ _GeoIP_full_path_to("GeoIPPostalConf.dat");
+ GeoIPDBFileName[GEOIP_ACCURACYRADIUS_EDITION_V6] =
+ _GeoIP_full_path_to("GeoIPDistancev6.dat");
+ }
+}
+
+static int _file_exists(const char *file_name) {
+ struct stat file_stat;
+ return (stat(file_name, &file_stat) == 0) ? 1 : 0;
+}
+
+char *_GeoIP_iso_8859_1__utf8(const char *iso) {
+ signed char c;
+ char k;
+ char *p;
+ char *t = (char *)iso;
+ int len = 0;
+ while ((c = *t++)) {
+ if (c < 0) {
+ len++;
+ }
+ }
+ len += t - iso;
+ t = p = malloc(len);
+
+ if (p) {
+ while ((c = *iso++)) {
+ if (c < 0) {
+ k = (char)0xc2;
+ if (c >= -64) {
+ k++;
+ }
+ *t++ = k;
+ c &= ~0x40;
+ }
+ *t++ = c;
+ }
+ *t++ = 0x00;
+ }
+ return p;
+}
+
+int GeoIP_is_private_ipnum_v4(unsigned long ipnum) {
+ return ((ipnum >= 167772160U && ipnum <= 184549375U) ||
+ (ipnum >= 2851995648U && ipnum <= 2852061183U) ||
+ (ipnum >= 2886729728U && ipnum <= 2887778303U) ||
+ (ipnum >= 3232235520U && ipnum <= 3232301055U) ||
+ (ipnum >= 2130706432U && ipnum <= 2147483647U))
+ ? 1
+ : 0;
+}
+
+int GeoIP_is_private_v4(const char *addr) {
+ unsigned long ipnum = GeoIP_addr_to_num(addr);
+ return GeoIP_is_private_ipnum_v4(ipnum);
+}
+
+int GeoIP_db_avail(int type) {
+ const char *filePath;
+ if (type < 0 || type >= NUM_DB_TYPES) {
+ return 0;
+ }
+ _GeoIP_setup_dbfilename();
+ filePath = GeoIPDBFileName[type];
+ if (NULL == filePath) {
+ return 0;
+ }
+ return _file_exists(filePath);
+}
+
+static int _database_has_content(int database_type) {
+ return (database_type != GEOIP_COUNTRY_EDITION &&
+ database_type != GEOIP_PROXY_EDITION &&
+ database_type != GEOIP_NETSPEED_EDITION &&
+ database_type != GEOIP_COUNTRY_EDITION_V6 &&
+ database_type != GEOIP_LARGE_COUNTRY_EDITION &&
+ database_type != GEOIP_LARGE_COUNTRY_EDITION_V6 &&
+ database_type != GEOIP_REGION_EDITION_REV0 &&
+ database_type != GEOIP_REGION_EDITION_REV1)
+ ? 1
+ : 0;
+}
+
+static ssize_t get_index_size(GeoIP *gi, struct stat *buf) {
+ ssize_t index_size;
+ unsigned int segment;
+
+ if (!_database_has_content(gi->databaseType)) {
+ return buf->st_size;
+ }
+
+ segment = gi->databaseSegments[0];
+ index_size = segment * (ssize_t)gi->record_length * 2;
+
+ /* check for overflow in multiplication */
+ if (segment != 0 &&
+ index_size / segment != (ssize_t)gi->record_length * 2) {
+ return -1;
+ }
+
+ /* Index size should never exceed the size of the file */
+ if (index_size > buf->st_size) {
+ return -1;
+ }
+
+ return index_size;
+}
+
+static void _setup_segments(GeoIP *gi) {
+ int i, j, segment_record_length;
+ unsigned char delim[3];
+ unsigned char buf[LARGE_SEGMENT_RECORD_LENGTH];
+ off_t offset = gi->size - 3;
+ int fno = fileno(gi->GeoIPDatabase);
+
+ gi->databaseSegments = NULL;
+
+ /* default to GeoIP Country Edition */
+ gi->databaseType = GEOIP_COUNTRY_EDITION;
+ gi->record_length = STANDARD_RECORD_LENGTH;
+
+ for (i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) {
+ if (pread(fno, delim, 3, offset) != 3) {
+ return;
+ }
+ offset += 3;
+ if (delim[0] == 255 && delim[1] == 255 && delim[2] == 255) {
+ if (pread(fno, &gi->databaseType, 1, offset) != 1) {
+ return;
+ }
+ offset++;
+ if (gi->databaseType >= 106) {
+ /* backwards compatibility with databases from April 2003 and
+ * earlier */
+ gi->databaseType -= 105;
+ }
+
+ if (gi->databaseType == GEOIP_REGION_EDITION_REV0) {
+ /* Region Edition, pre June 2003 */
+ gi->databaseSegments = malloc(sizeof(unsigned int));
+ if (gi->databaseSegments == NULL) {
+ return;
+ }
+ gi->databaseSegments[0] = STATE_BEGIN_REV0;
+ } else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) {
+ /* Region Edition, post June 2003 */
+ gi->databaseSegments = malloc(sizeof(unsigned int));
+ if (gi->databaseSegments == NULL) {
+ return;
+ }
+ gi->databaseSegments[0] = STATE_BEGIN_REV1;
+ } else if (gi->databaseType == GEOIP_CITY_EDITION_REV0 ||
+ gi->databaseType == GEOIP_CITY_EDITION_REV1 ||
+ gi->databaseType == GEOIP_ORG_EDITION ||
+ gi->databaseType == GEOIP_ORG_EDITION_V6 ||
+ gi->databaseType == GEOIP_DOMAIN_EDITION ||
+ gi->databaseType == GEOIP_DOMAIN_EDITION_V6 ||
+ gi->databaseType == GEOIP_ISP_EDITION ||
+ gi->databaseType == GEOIP_ISP_EDITION_V6 ||
+ gi->databaseType == GEOIP_REGISTRAR_EDITION ||
+ gi->databaseType == GEOIP_REGISTRAR_EDITION_V6 ||
+ gi->databaseType == GEOIP_USERTYPE_EDITION ||
+ gi->databaseType == GEOIP_USERTYPE_EDITION_V6 ||
+ gi->databaseType == GEOIP_ASNUM_EDITION ||
+ gi->databaseType == GEOIP_ASNUM_EDITION_V6 ||
+ gi->databaseType == GEOIP_NETSPEED_EDITION_REV1 ||
+ gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6 ||
+ gi->databaseType == GEOIP_LOCATIONA_EDITION ||
+ gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION ||
+ gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION_V6 ||
+ gi->databaseType == GEOIP_CITY_EDITION_REV0_V6 ||
+ gi->databaseType == GEOIP_CITY_EDITION_REV1_V6 ||
+ gi->databaseType == GEOIP_CITYCONF_EDITION ||
+ gi->databaseType == GEOIP_COUNTRYCONF_EDITION ||
+ gi->databaseType == GEOIP_REGIONCONF_EDITION ||
+ gi->databaseType == GEOIP_POSTALCONF_EDITION) {
+ /* City/Org Editions have two segments, read offset of second
+ * segment */
+ gi->databaseSegments = malloc(sizeof(unsigned int));
+ if (gi->databaseSegments == NULL) {
+ return;
+ }
+ gi->databaseSegments[0] = 0;
+ segment_record_length = SEGMENT_RECORD_LENGTH;
+
+ if (pread(fno, buf, segment_record_length, offset) !=
+ segment_record_length) {
+ free(gi->databaseSegments);
+ gi->databaseSegments = NULL;
+ return;
+ }
+
+ for (j = 0; j < segment_record_length; j++) {
+ gi->databaseSegments[0] += (buf[j] << (j * 8));
+ }
+
+ /* the record_length must be correct from here on */
+ if (gi->databaseType == GEOIP_ORG_EDITION ||
+ gi->databaseType == GEOIP_ORG_EDITION_V6 ||
+ gi->databaseType == GEOIP_DOMAIN_EDITION ||
+ gi->databaseType == GEOIP_DOMAIN_EDITION_V6 ||
+ gi->databaseType == GEOIP_ISP_EDITION ||
+ gi->databaseType == GEOIP_ISP_EDITION_V6) {
+ gi->record_length = ORG_RECORD_LENGTH;
+ }
+ }
+ break;
+ } else {
+ offset -= 4;
+ if (offset < 0) {
+ gi->databaseSegments = NULL;
+ return;
+ }
+ }
+ }
+ if (gi->databaseType == GEOIP_COUNTRY_EDITION ||
+ gi->databaseType == GEOIP_PROXY_EDITION ||
+ gi->databaseType == GEOIP_NETSPEED_EDITION ||
+ gi->databaseType == GEOIP_COUNTRY_EDITION_V6) {
+ gi->databaseSegments = malloc(sizeof(unsigned int));
+ if (gi->databaseSegments == NULL) {
+ return;
+ }
+ gi->databaseSegments[0] = COUNTRY_BEGIN;
+ } else if (gi->databaseType == GEOIP_LARGE_COUNTRY_EDITION ||
+ gi->databaseType == GEOIP_LARGE_COUNTRY_EDITION_V6) {
+ gi->databaseSegments = malloc(sizeof(unsigned int));
+ if (gi->databaseSegments == NULL) {
+ return;
+ }
+ gi->databaseSegments[0] = LARGE_COUNTRY_BEGIN;
+ }
+}
+
+static void _check_mtime(GeoIP *gi) {
+ struct stat buf;
+ ssize_t idx_size;
+
+#if !defined(_WIN32)
+ struct timeval t;
+#else /* !defined(_WIN32) */
+ FILETIME ft;
+ ULONGLONG t;
+#endif /* !defined(_WIN32) */
+
+ if (gi->flags & GEOIP_CHECK_CACHE) {
+
+#if !defined(_WIN32)
+ /* stat only has second granularity, so don't
+ * call it more than once a second */
+ if (0 != gettimeofday(&t, NULL)) {
+ DEBUG_MSGF(
+ gi->flags, "Error calling gettimeofday: %s\n", strerror(errno));
+ return;
+ }
+
+ if (t.tv_sec == gi->last_mtime_check) {
+ return;
+ }
+ gi->last_mtime_check = t.tv_sec;
+
+#else /* !defined(_WIN32) */
+
+ /* stat only has second granularity, so don't
+ call it more than once a second */
+ GetSystemTimeAsFileTime(&ft);
+ t = FILETIME_TO_USEC(ft) / 1000 / 1000;
+ if (t == gi->last_mtime_check) {
+ return;
+ }
+ gi->last_mtime_check = t;
+
+#endif /* !defined(_WIN32) */
+
+ if (stat(gi->file_path, &buf) != -1) {
+ /* make sure that the database file is at least 60
+ * seconds untouched. Otherwise we might load the
+ * database only partly and crash
+ */
+ if (buf.st_mtime != gi->mtime &&
+ (buf.st_mtime + 60 < gi->last_mtime_check)) {
+ /* GeoIP Database file updated */
+ if (gi->flags & (GEOIP_MEMORY_CACHE | GEOIP_MMAP_CACHE)) {
+ if (gi->cache && (gi->flags & GEOIP_MMAP_CACHE)) {
+#if !defined(_WIN32)
+ /* MMAP is only avail on UNIX */
+ munmap(gi->cache, gi->size);
+ gi->cache = NULL;
+#endif
+ } else {
+ /* reload database into memory cache */
+ if ((gi->cache = (unsigned char *)realloc(
+ gi->cache, buf.st_size)) == NULL) {
+ DEBUG_MSGF(gi->flags,
+ "Out of memory when reloading %s\n",
+ gi->file_path);
+ return;
+ }
+ }
+ }
+ /* refresh filehandle */
+ fclose(gi->GeoIPDatabase);
+ gi->GeoIPDatabase = fopen(gi->file_path, "rb");
+ if (gi->GeoIPDatabase == NULL) {
+ DEBUG_MSGF(gi->flags,
+ "Error Opening file %s when reloading\n",
+ gi->file_path);
+ return;
+ }
+ gi->mtime = buf.st_mtime;
+ gi->size = buf.st_size;
+
+ if (gi->flags & GEOIP_MMAP_CACHE) {
+#if defined(_WIN32)
+ DEBUG_MSGF(gi->flags,
+ "GEOIP_MMAP_CACHE is not supported on WIN32\n");
+ gi->cache = 0;
+ return;
+#else
+ gi->cache = mmap(NULL,
+ buf.st_size,
+ PROT_READ,
+ MAP_PRIVATE,
+ fileno(gi->GeoIPDatabase),
+ 0);
+ if (gi->cache == MAP_FAILED) {
+
+ DEBUG_MSGF(gi->flags,
+ "Error remapping file %s when reloading\n",
+ gi->file_path);
+
+ gi->cache = NULL;
+ return;
+ }
+#endif
+ } else if (gi->flags & GEOIP_MEMORY_CACHE) {
+ if (pread(fileno(gi->GeoIPDatabase),
+ gi->cache,
+ buf.st_size,
+ 0) != (ssize_t)buf.st_size) {
+ DEBUG_MSGF(gi->flags,
+ "Error reading file %s when reloading\n",
+ gi->file_path);
+ return;
+ }
+ }
+
+ if (gi->databaseSegments != NULL) {
+ free(gi->databaseSegments);
+ gi->databaseSegments = NULL;
+ }
+ _setup_segments(gi);
+ if (gi->databaseSegments == NULL) {
+ DEBUG_MSGF(gi->flags,
+ "Error reading file %s -- corrupt\n",
+ gi->file_path);
+ return;
+ }
+
+ idx_size = get_index_size(gi, &buf);
+ if (idx_size < 0) {
+ DEBUG_MSGF(
+ gi->flags, "Error file %s -- corrupt\n", gi->file_path);
+ return;
+ }
+
+ if (gi->flags & GEOIP_INDEX_CACHE) {
+ gi->index_cache = (unsigned char *)realloc(
+ gi->index_cache, sizeof(unsigned char) * idx_size);
+ if (gi->index_cache != NULL) {
+ if (pread(fileno(gi->GeoIPDatabase),
+ gi->index_cache,
+ idx_size,
+ 0) != idx_size) {
+ DEBUG_MSGF(
+ gi->flags,
+ "Error reading file %s where reloading\n",
+ gi->file_path);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ return;
+}
+
+#define ADDR_STR_LEN (8 * 4 + 7 + 1)
+unsigned int
+_GeoIP_seek_record_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ int depth;
+ char paddr[ADDR_STR_LEN];
+ unsigned int x;
+ unsigned char stack_buffer[2 * MAX_RECORD_LENGTH];
+ const unsigned char *buf = (gi->cache == NULL) ? stack_buffer : NULL;
+ unsigned int offset = 0;
+
+ const unsigned char *p;
+ int j;
+ int fno = fileno(gi->GeoIPDatabase);
+
+ unsigned int record_pair_length = gi->record_length * 2;
+
+ _check_mtime(gi);
+ if (GeoIP_teredo(gi)) {
+ __GEOIP_PREPARE_TEREDO(&ipnum);
+ }
+ for (depth = 127; depth >= 0; depth--) {
+ unsigned int byte_offset = record_pair_length * offset;
+ if (byte_offset > gi->size - record_pair_length) {
+ /* The pointer is invalid */
+ break;
+ }
+ if (gi->cache == NULL && gi->index_cache == NULL) {
+ /* read from disk */
+ if (pread(
+ fno, stack_buffer, record_pair_length, (long)byte_offset) !=
+ record_pair_length) {
+ break;
+ }
+ } else if (gi->index_cache == NULL) {
+ /* simply point to record in memory */
+ buf = gi->cache + (long)byte_offset;
+ } else {
+ buf = gi->index_cache + (long)byte_offset;
+ }
+
+ if (GEOIP_CHKBIT_V6(depth, ipnum.s6_addr)) {
+ /* Take the right-hand branch */
+ if (gi->record_length == 3) {
+ /* Most common case is completely unrolled and uses constants.
+ */
+ x = (buf[3 * 1 + 0] << (0 * 8)) + (buf[3 * 1 + 1] << (1 * 8)) +
+ (buf[3 * 1 + 2] << (2 * 8));
+
+ } else {
+ /* General case */
+ j = gi->record_length;
+ p = &buf[2 * j];
+ x = 0;
+ do {
+ x <<= 8;
+ x += *(--p);
+ } while (--j);
+ }
+
+ } else {
+ /* Take the left-hand branch */
+ if (gi->record_length == 3) {
+ /* Most common case is completely unrolled and uses constants.
+ */
+ x = (buf[3 * 0 + 0] << (0 * 8)) + (buf[3 * 0 + 1] << (1 * 8)) +
+ (buf[3 * 0 + 2] << (2 * 8));
+ } else {
+ /* General case */
+ j = gi->record_length;
+ p = &buf[1 * j];
+ x = 0;
+ do {
+ x <<= 8;
+ x += *(--p);
+ } while (--j);
+ }
+ }
+
+ if (x >= gi->databaseSegments[0]) {
+ gi->netmask = gl->netmask = 128 - depth;
+ return x;
+ }
+ offset = x;
+ }
+
+ /* shouldn't reach here */
+ _GeoIP_inet_ntop(AF_INET6, &ipnum.s6_addr[0], paddr, ADDR_STR_LEN);
+ DEBUG_MSGF(gi->flags,
+ "Error Traversing Database for ipnum = %s - Perhaps database is "
+ "corrupt?\n",
+ paddr);
+ return 0;
+}
+
+geoipv6_t _GeoIP_addr_to_num_v6(const char *addr) {
+ geoipv6_t ipnum;
+ if (1 == _GeoIP_inet_pton(AF_INET6, addr, &ipnum.s6_addr[0])) {
+ return ipnum;
+ }
+ return IPV6_NULL;
+}
+
+unsigned int
+_GeoIP_seek_record_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ int depth;
+ unsigned int x;
+ unsigned char stack_buffer[2 * MAX_RECORD_LENGTH];
+ const unsigned char *buf = (gi->cache == NULL) ? stack_buffer : NULL;
+ unsigned int offset = 0;
+
+ const unsigned char *p;
+ int j;
+ int fno = fileno(gi->GeoIPDatabase);
+
+ unsigned int record_pair_length = gi->record_length * 2;
+
+ _check_mtime(gi);
+ for (depth = 31; depth >= 0; depth--) {
+ unsigned int byte_offset = record_pair_length * offset;
+ if (byte_offset > gi->size - record_pair_length) {
+ /* The pointer is invalid */
+ break;
+ }
+ if (gi->cache == NULL && gi->index_cache == NULL) {
+ /* read from disk */
+ if (pread(fno, stack_buffer, record_pair_length, byte_offset) !=
+ record_pair_length) {
+ break;
+ }
+ } else if (gi->index_cache == NULL) {
+ /* simply point to record in memory */
+ buf = gi->cache + (long)byte_offset;
+ } else {
+ buf = gi->index_cache + (long)byte_offset;
+ }
+
+ if (ipnum & (1 << depth)) {
+ /* Take the right-hand branch */
+ if (gi->record_length == 3) {
+ /* Most common case is completely unrolled and uses constants.
+ */
+ x = (buf[3 * 1 + 0] << (0 * 8)) + (buf[3 * 1 + 1] << (1 * 8)) +
+ (buf[3 * 1 + 2] << (2 * 8));
+
+ } else {
+ /* General case */
+ j = gi->record_length;
+ p = &buf[2 * j];
+ x = 0;
+ do {
+ x <<= 8;
+ x += *(--p);
+ } while (--j);
+ }
+
+ } else {
+ /* Take the left-hand branch */
+ if (gi->record_length == 3) {
+ /* Most common case is completely unrolled and uses constants.
+ */
+ x = (buf[3 * 0 + 0] << (0 * 8)) + (buf[3 * 0 + 1] << (1 * 8)) +
+ (buf[3 * 0 + 2] << (2 * 8));
+ } else {
+ /* General case */
+ j = gi->record_length;
+ p = &buf[1 * j];
+ x = 0;
+ do {
+ x <<= 8;
+ x += *(--p);
+ } while (--j);
+ }
+ }
+
+ if (x >= gi->databaseSegments[0]) {
+ gi->netmask = gl->netmask = 32 - depth;
+ return x;
+ }
+ offset = x;
+ }
+ /* shouldn't reach here */
+ DEBUG_MSGF(gi->flags,
+ "Error Traversing Database for ipnum = %lu - Perhaps database "
+ "is corrupt?\n",
+ ipnum);
+ return 0;
+}
+
+unsigned long GeoIP_addr_to_num(const char *addr) {
+ unsigned int c, octet, t;
+ unsigned long ipnum;
+ int i = 3;
+
+ octet = ipnum = 0;
+ while ((c = *addr++)) {
+ if (c == '.') {
+ if (octet > 255) {
+ return 0;
+ }
+ ipnum <<= 8;
+ ipnum += octet;
+ i--;
+ octet = 0;
+ } else {
+ t = octet;
+ octet <<= 3;
+ octet += t;
+ octet += t;
+ c -= '0';
+ if (c > 9) {
+ return 0;
+ }
+ octet += c;
+ }
+ }
+ if ((octet > 255) || (i != 0)) {
+ return 0;
+ }
+ ipnum <<= 8;
+ return ipnum + octet;
+}
+
+GeoIP *GeoIP_open_type(int type, int flags) {
+ GeoIP *gi;
+ const char *filePath;
+ if (type < 0 || type >= NUM_DB_TYPES) {
+ printf("Invalid database type %d\n", type);
+ return NULL;
+ }
+ _GeoIP_setup_dbfilename();
+ filePath = GeoIPDBFileName[type];
+ if (filePath == NULL) {
+ printf("Invalid database type %d\n", type);
+ return NULL;
+ }
+ gi = GeoIP_open(filePath, flags);
+
+ if (gi) {
+ /* make sure this is the requested database type */
+ int database_type = gi->databaseType;
+ if (database_type > 105) {
+ database_type -= 105;
+ }
+ /* type must match, but we accept org and asnum,
+ * since domain and *conf database have always the wrong type
+ * for historical reason. Maybe we fix it at some point.
+ */
+ if (database_type == type || database_type == GEOIP_ASNUM_EDITION ||
+ database_type == GEOIP_ORG_EDITION) {
+ return gi;
+ }
+ GeoIP_delete(gi);
+ }
+
+ return NULL;
+}
+
+GeoIP *GeoIP_new(int flags) {
+ GeoIP *gi;
+ _GeoIP_setup_dbfilename();
+ gi = GeoIP_open(GeoIPDBFileName[GEOIP_COUNTRY_EDITION], flags);
+ return gi;
+}
+
+GeoIP *GeoIP_open(const char *filename, int flags) {
+ struct stat buf;
+ ssize_t idx_size;
+ GeoIP *gi;
+ size_t len;
+
+ gi = (GeoIP *)calloc(1, sizeof(GeoIP));
+ if (gi == NULL) {
+ return NULL;
+ }
+ len = sizeof(char) * (strlen(filename) + 1);
+ gi->file_path = malloc(len);
+ if (gi->file_path == NULL) {
+ free(gi);
+ return NULL;
+ }
+ strncpy(gi->file_path, filename, len);
+ gi->GeoIPDatabase = fopen(filename, "rb");
+ if (gi->GeoIPDatabase == NULL) {
+ DEBUG_MSGF(flags, "Error Opening file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+
+ if (fstat(fileno(gi->GeoIPDatabase), &buf) == -1) {
+ DEBUG_MSGF(flags, "Error stating file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+
+ gi->size = buf.st_size;
+ if (flags & (GEOIP_MEMORY_CACHE | GEOIP_MMAP_CACHE)) {
+ gi->mtime = buf.st_mtime;
+
+ /* MMAP added my Peter Shipley */
+ if (flags & GEOIP_MMAP_CACHE) {
+#if !defined(_WIN32)
+ gi->cache = mmap(NULL,
+ buf.st_size,
+ PROT_READ,
+ MAP_PRIVATE,
+ fileno(gi->GeoIPDatabase),
+ 0);
+ if (gi->cache == MAP_FAILED) {
+ DEBUG_MSGF(flags, "Error mmaping file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+#endif
+ } else {
+ gi->cache =
+ (unsigned char *)malloc(sizeof(unsigned char) * buf.st_size);
+
+ if (gi->cache != NULL) {
+ if (pread(
+ fileno(gi->GeoIPDatabase), gi->cache, buf.st_size, 0) !=
+ (ssize_t)buf.st_size) {
+ DEBUG_MSGF(flags, "Error reading file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+ }
+ }
+ } else {
+ if (flags & GEOIP_CHECK_CACHE) {
+ if (fstat(fileno(gi->GeoIPDatabase), &buf) == -1) {
+ DEBUG_MSGF(flags, "Error stating file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+ gi->mtime = buf.st_mtime;
+ }
+ gi->cache = NULL;
+ }
+ gi->flags = flags;
+ gi->charset = GEOIP_CHARSET_ISO_8859_1;
+ gi->ext_flags = 1U << GEOIP_TEREDO_BIT;
+ _setup_segments(gi);
+ if (gi->databaseSegments == NULL) {
+ DEBUG_MSGF(
+ gi->flags, "Error reading file %s -- corrupt\n", gi->file_path);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+
+ idx_size = get_index_size(gi, &buf);
+
+ if (idx_size < 0) {
+ DEBUG_MSGF(gi->flags, "Error file %s -- corrupt\n", gi->file_path);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+
+ if (flags & GEOIP_INDEX_CACHE) {
+ gi->index_cache =
+ (unsigned char *)malloc(sizeof(unsigned char) * idx_size);
+ if (gi->index_cache != NULL) {
+ if (pread(
+ fileno(gi->GeoIPDatabase), gi->index_cache, idx_size, 0) !=
+ idx_size) {
+ DEBUG_MSGF(gi->flags, "Error reading file %s\n", filename);
+ GeoIP_delete(gi);
+ return NULL;
+ }
+ }
+ } else {
+ gi->index_cache = NULL;
+ }
+
+ gi->last_mtime_check = 0;
+
+ return gi;
+}
+
+void GeoIP_delete(GeoIP *gi) {
+ if (gi == NULL) {
+ return;
+ }
+ if (gi->GeoIPDatabase != NULL) {
+ fclose(gi->GeoIPDatabase);
+ }
+ if (gi->cache != NULL) {
+ if (gi->flags & GEOIP_MMAP_CACHE) {
+#if !defined(_WIN32)
+ if (gi->cache) {
+ munmap(gi->cache, gi->size);
+ }
+#endif
+ } else {
+ free(gi->cache);
+ }
+ gi->cache = NULL;
+ }
+ free(gi->index_cache);
+ free(gi->file_path);
+ free(gi->databaseSegments);
+ free(gi);
+}
+
+const char *
+GeoIP_country_code_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_v6_gl(gi, name, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_code_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_gl(gi, name, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+
+const char *GeoIP_country_code3_by_name_v6_gl(GeoIP *gi,
+ const char *name,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_v6_gl(gi, name, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_code3_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_gl(gi, name, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_name_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_v6_gl(gi, name, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+const char *
+GeoIP_country_name_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_name_gl(gi, name, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+unsigned long _GeoIP_lookupaddress(const char *host) {
+ unsigned long addr = inet_addr(host);
+ struct hostent phe2;
+ struct hostent *phe = &phe2;
+ char *buf = NULL;
+#ifdef HAVE_GETHOSTBYNAME_R
+ int buflength = 16384;
+ int herr = 0;
+#endif
+ int result = 0;
+#ifdef HAVE_GETHOSTBYNAME_R
+ buf = malloc(buflength);
+#endif
+ if (addr == INADDR_NONE) {
+#ifdef HAVE_GETHOSTBYNAME_R
+ while (1) {
+/* we use gethostbyname_r here because it is thread-safe and gethostbyname is
+ * not */
+#ifdef GETHOSTBYNAME_R_RETURNS_INT
+ result = gethostbyname_r(host, &phe2, buf, buflength, &phe, &herr);
+#else
+ phe = gethostbyname_r(host, &phe2, buf, buflength, &herr);
+#endif
+ if (herr != ERANGE) {
+ break;
+ }
+ if (result == 0) {
+ break;
+ }
+ /* double the buffer if the buffer is too small */
+ buflength = buflength * 2;
+ buf = realloc(buf, buflength);
+ }
+#else
+ /* Some systems do not support gethostbyname_r, such as Mac OS X */
+ phe = gethostbyname(host);
+#endif
+ if (!phe || result != 0) {
+ free(buf);
+ return 0;
+ }
+#if !defined(_WIN32)
+ addr = *((in_addr_t *)phe->h_addr_list[0]);
+#else
+ addr = ((IN_ADDR *)phe->h_addr_list[0])->S_un.S_addr;
+#endif
+ }
+#ifdef HAVE_GETHOSTBYNAME_R
+ free(buf);
+#endif
+ return ntohl(addr);
+}
+
+geoipv6_t _GeoIP_lookupaddress_v6(const char *host) {
+ geoipv6_t ipnum;
+ int gaierr;
+ struct addrinfo hints, *aifirst;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET6;
+ /* hints.ai_flags = AI_V4MAPPED; */
+ hints.ai_socktype = SOCK_STREAM;
+
+ if ((gaierr = getaddrinfo(host, NULL, &hints, &aifirst)) != 0) {
+ /* DEBUG_MSGF("Err: %s (%d %s)\n", host, gaierr, gai_strerror(gaierr));
+ */
+ return IPV6_NULL;
+ }
+ memcpy(ipnum.s6_addr,
+ ((struct sockaddr_in6 *)aifirst->ai_addr)->sin6_addr.s6_addr,
+ sizeof(geoipv6_t));
+ freeaddrinfo(aifirst);
+ /* inet_pton(AF_INET6, host, ipnum.s6_addr); */
+
+ return ipnum;
+}
+
+int GeoIP_id_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ int ret;
+ if (name == NULL) {
+ return 0;
+ }
+ if (gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_PROXY_EDITION &&
+ gi->databaseType != GEOIP_NETSPEED_EDITION) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION));
+ return 0;
+ }
+ if (!(ipnum = _GeoIP_lookupaddress(name))) {
+ return 0;
+ }
+ ret = _GeoIP_seek_record_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+int GeoIP_id_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ int ret;
+ if (name == NULL) {
+ return 0;
+ }
+ if (gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION_V6 &&
+ gi->databaseType != GEOIP_COUNTRY_EDITION_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION_V6));
+ return 0;
+ }
+ ipnum = _GeoIP_lookupaddress_v6(name);
+ if (__GEOIP_V6_IS_NULL(ipnum)) {
+ return 0;
+ }
+
+ ret = _GeoIP_seek_record_v6_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+const char *
+GeoIP_country_code_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_v6_gl(gi, addr, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_code_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_gl(gi, addr, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+const char *GeoIP_country_code3_by_addr_v6_gl(GeoIP *gi,
+ const char *addr,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_v6_gl(gi, addr, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_code3_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_gl(gi, addr, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_name_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_v6_gl(gi, addr, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+const char *
+GeoIP_country_name_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_addr_gl(gi, addr, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+const char *GeoIP_country_name_by_ipnum_gl(GeoIP *gi,
+ unsigned long ipnum,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_gl(gi, ipnum, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+const char *
+GeoIP_country_name_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_v6_gl(gi, ipnum, gl);
+ return GeoIP_country_name_by_id(gi, country_id);
+}
+
+const char *GeoIP_country_code_by_ipnum_gl(GeoIP *gi,
+ unsigned long ipnum,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_gl(gi, ipnum, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+
+const char *
+GeoIP_country_code_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_v6_gl(gi, ipnum, gl);
+ return (country_id > 0) ? GeoIP_code_by_id(country_id) : NULL;
+}
+
+const char *GeoIP_country_code3_by_ipnum_gl(GeoIP *gi,
+ unsigned long ipnum,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_gl(gi, ipnum, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+const char *GeoIP_country_code3_by_ipnum_v6_gl(GeoIP *gi,
+ geoipv6_t ipnum,
+ GeoIPLookup *gl) {
+ int country_id;
+ country_id = GeoIP_id_by_ipnum_v6_gl(gi, ipnum, gl);
+ return (country_id > 0) ? GeoIP_code3_by_id(country_id) : NULL;
+}
+
+int GeoIP_country_id_by_addr_v6_gl(GeoIP *gi,
+ const char *addr,
+ GeoIPLookup *gl) {
+ return GeoIP_id_by_addr_v6_gl(gi, addr, gl);
+}
+
+int GeoIP_country_id_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ return GeoIP_id_by_addr_gl(gi, addr, gl);
+}
+
+int GeoIP_country_id_by_name_v6_gl(GeoIP *gi,
+ const char *host,
+ GeoIPLookup *gl) {
+ return GeoIP_id_by_name_v6_gl(gi, host, gl);
+}
+
+int GeoIP_country_id_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl) {
+ return GeoIP_id_by_name_gl(gi, host, gl);
+}
+
+int GeoIP_id_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ int ret;
+ if (addr == NULL) {
+ return 0;
+ }
+ if (gi->databaseType != GEOIP_COUNTRY_EDITION_V6 &&
+ gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION_V6));
+ return 0;
+ }
+ ipnum = _GeoIP_addr_to_num_v6(addr);
+ ret = _GeoIP_seek_record_v6_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+int GeoIP_id_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ int ret;
+ if (addr == NULL) {
+ return 0;
+ }
+ if (gi->databaseType != GEOIP_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_PROXY_EDITION &&
+ gi->databaseType != GEOIP_NETSPEED_EDITION) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION));
+ return 0;
+ }
+ ipnum = GeoIP_addr_to_num(addr);
+ ret = _GeoIP_seek_record_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+int GeoIP_id_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ int ret;
+ if (gi->databaseType != GEOIP_COUNTRY_EDITION_V6 &&
+ gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION_V6));
+ return 0;
+ }
+ ret = _GeoIP_seek_record_v6_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+int GeoIP_id_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ int ret;
+ if (ipnum == 0) {
+ return 0;
+ }
+ if (gi->databaseType != GEOIP_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_LARGE_COUNTRY_EDITION &&
+ gi->databaseType != GEOIP_PROXY_EDITION &&
+ gi->databaseType != GEOIP_NETSPEED_EDITION) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_COUNTRY_EDITION));
+ return 0;
+ }
+ ret = _GeoIP_seek_record_gl(gi, ipnum, gl) - gi->databaseSegments[0];
+ return ret;
+}
+
+char *GeoIP_database_info(GeoIP *gi) {
+ int i;
+ unsigned char buf[3];
+ char *retval;
+ int has_structure_info = 0;
+ off_t offset = gi->size - 3;
+ int fno;
+
+ if (gi == NULL) {
+ return NULL;
+ }
+
+ fno = fileno(gi->GeoIPDatabase);
+
+ _check_mtime(gi);
+
+ /* first get past the database structure information */
+ for (i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) {
+ if (pread(fno, buf, 3, offset) != 3) {
+ return NULL;
+ }
+ offset += 3;
+ if (buf[0] == 255 && buf[1] == 255 && buf[2] == 255) {
+ has_structure_info = 1;
+ break;
+ }
+ offset -= 4;
+ if (offset < 0) {
+ return NULL;
+ }
+ }
+ if (has_structure_info) {
+ offset -= 6;
+ if (offset < 0) {
+ return NULL;
+ }
+ } else {
+ /* no structure info, must be pre Sep 2002 database, go back to end */
+ offset = gi->size - 3;
+ if (offset < 0) {
+ return NULL;
+ }
+ }
+
+ for (i = 0; i < DATABASE_INFO_MAX_SIZE; i++) {
+ if (pread(fno, buf, 3, offset) != 3) {
+ return NULL;
+ }
+ offset += 3;
+ if (buf[0] == 0 && buf[1] == 0 && buf[2] == 0) {
+ retval = malloc(sizeof(char) * (i + 1));
+ if (retval == NULL) {
+ return NULL;
+ }
+ if (pread(fno, retval, i, offset) != i) {
+ return NULL;
+ }
+ retval[i] = '\0';
+ return retval;
+ }
+ offset -= 4;
+ if (offset < 0) {
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+/* GeoIP Region Edition functions */
+
+void GeoIP_assign_region_by_inetaddr_gl(GeoIP *gi,
+ unsigned long inetaddr,
+ GeoIPRegion *region,
+ GeoIPLookup *gl) {
+ unsigned int seek_region;
+
+ /* This also writes in the terminating NULs (if you decide to
+ * keep them) and clear any fields that are not set. */
+ memset(region, 0, sizeof(GeoIPRegion));
+
+ seek_region = _GeoIP_seek_record_gl(gi, ntohl(inetaddr), gl);
+
+ if (gi->databaseType == GEOIP_REGION_EDITION_REV0) {
+ /* Region Edition, pre June 2003 */
+ seek_region -= STATE_BEGIN_REV0;
+ if (seek_region >= 1000) {
+ region->country_code[0] = 'U';
+ region->country_code[1] = 'S';
+ region->region[0] = (char)((seek_region - 1000) / 26 + 65);
+ region->region[1] = (char)((seek_region - 1000) % 26 + 65);
+ } else {
+ const char *code = GeoIP_code_by_id(seek_region);
+ if (code != NULL) {
+ memcpy(region->country_code, code, 2);
+ }
+ }
+ } else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) {
+ /* Region Edition, post June 2003 */
+ seek_region -= STATE_BEGIN_REV1;
+ if (seek_region < US_OFFSET) {
+ /* Unknown */
+ /* we don't need to do anything here b/c we memset region to 0 */
+ } else if (seek_region < CANADA_OFFSET) {
+ /* USA State */
+ region->country_code[0] = 'U';
+ region->country_code[1] = 'S';
+ region->region[0] = (char)((seek_region - US_OFFSET) / 26 + 65);
+ region->region[1] = (char)((seek_region - US_OFFSET) % 26 + 65);
+ } else if (seek_region < WORLD_OFFSET) {
+ /* Canada Province */
+ region->country_code[0] = 'C';
+ region->country_code[1] = 'A';
+ region->region[0] = (char)((seek_region - CANADA_OFFSET) / 26 + 65);
+ region->region[1] = (char)((seek_region - CANADA_OFFSET) % 26 + 65);
+ } else {
+ /* Not US or Canada ( cc_id is always cc_id * FIPS_RANGE ) */
+ const char *code =
+ GeoIP_code_by_id((seek_region - WORLD_OFFSET) / FIPS_RANGE);
+ if (code != NULL) {
+ /* coverity[dont_call] */
+ memcpy(region->country_code, code, 2);
+ }
+ }
+ }
+}
+
+void GeoIP_assign_region_by_inetaddr_v6_gl(GeoIP *gi,
+ geoipv6_t inetaddr,
+ GeoIPRegion *region,
+ GeoIPLookup *gl) {
+ unsigned int seek_region;
+
+ /* This also writes in the terminating NULs (if you decide to
+ * keep them) and clear any fields that are not set. */
+ memset(region, 0, sizeof(GeoIPRegion));
+
+ seek_region = _GeoIP_seek_record_v6_gl(gi, inetaddr, gl);
+
+ if (gi->databaseType == GEOIP_REGION_EDITION_REV0) {
+ /* Region Edition, pre June 2003 */
+ seek_region -= STATE_BEGIN_REV0;
+ if (seek_region >= 1000) {
+ region->country_code[0] = 'U';
+ region->country_code[1] = 'S';
+ region->region[0] = (char)((seek_region - 1000) / 26 + 65);
+ region->region[1] = (char)((seek_region - 1000) % 26 + 65);
+ } else {
+ const char *code = GeoIP_code_by_id(seek_region);
+ if (code != NULL) {
+ /* coverity[dont_call] */
+ memcpy(region->country_code, code, 2);
+ }
+ }
+ } else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) {
+ /* Region Edition, post June 2003 */
+ seek_region -= STATE_BEGIN_REV1;
+ if (seek_region < US_OFFSET) {
+ /* Unknown */
+ /* we don't need to do anything here b/c we memset region to 0 */
+ } else if (seek_region < CANADA_OFFSET) {
+ /* USA State */
+ region->country_code[0] = 'U';
+ region->country_code[1] = 'S';
+ region->region[0] = (char)((seek_region - US_OFFSET) / 26 + 65);
+ region->region[1] = (char)((seek_region - US_OFFSET) % 26 + 65);
+ } else if (seek_region < WORLD_OFFSET) {
+ /* Canada Province */
+ region->country_code[0] = 'C';
+ region->country_code[1] = 'A';
+ region->region[0] = (char)((seek_region - CANADA_OFFSET) / 26 + 65);
+ region->region[1] = (char)((seek_region - CANADA_OFFSET) % 26 + 65);
+ } else {
+ /* Not US or Canada ( cc_id is always cc_id * FIPS_RANGE ) */
+ const char *code =
+ GeoIP_code_by_id((seek_region - WORLD_OFFSET) / FIPS_RANGE);
+ if (code != NULL) {
+ /* coverity[dont_call] */
+ memcpy(region->country_code, code, 2);
+ }
+ }
+ }
+}
+
+static GeoIPRegion *
+_get_region_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ GeoIPRegion *region;
+
+ region = malloc(sizeof(GeoIPRegion));
+ if (region) {
+ GeoIP_assign_region_by_inetaddr_gl(gi, htonl(ipnum), region, gl);
+ }
+ return region;
+}
+
+static GeoIPRegion *
+_get_region_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ GeoIPRegion *region;
+
+ region = malloc(sizeof(GeoIPRegion));
+ if (region) {
+ GeoIP_assign_region_by_inetaddr_v6_gl(gi, ipnum, region, gl);
+ }
+ return region;
+}
+
+GeoIPRegion *
+GeoIP_region_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ if (addr == NULL) {
+ return NULL;
+ }
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+ ipnum = GeoIP_addr_to_num(addr);
+ return _get_region_gl(gi, ipnum, gl);
+}
+
+GeoIPRegion *
+GeoIP_region_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ if (addr == NULL) {
+ return NULL;
+ }
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+ ipnum = _GeoIP_addr_to_num_v6(addr);
+ return _get_region_v6_gl(gi, ipnum, gl);
+}
+
+GeoIPRegion *
+GeoIP_region_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ if (name == NULL) {
+ return NULL;
+ }
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+ if (!(ipnum = _GeoIP_lookupaddress(name))) {
+ return NULL;
+ }
+ return _get_region_gl(gi, ipnum, gl);
+}
+
+GeoIPRegion *
+GeoIP_region_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ if (name == NULL) {
+ return NULL;
+ }
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+
+ ipnum = _GeoIP_lookupaddress_v6(name);
+ if (__GEOIP_V6_IS_NULL(ipnum)) {
+ return NULL;
+ }
+ return _get_region_v6_gl(gi, ipnum, gl);
+}
+
+GeoIPRegion *
+GeoIP_region_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+ return _get_region_gl(gi, ipnum, gl);
+}
+
+GeoIPRegion *
+GeoIP_region_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
+ gi->databaseType != GEOIP_REGION_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_REGION_EDITION_REV1));
+ return NULL;
+ }
+ return _get_region_v6_gl(gi, ipnum, gl);
+}
+
+void GeoIPRegion_delete(GeoIPRegion *gir) { free(gir); }
+
+/* GeoIP Organization, ISP and AS Number Edition private method */
+static char *_get_name_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ unsigned int seek_org;
+ char buf[MAX_ORG_RECORD_LENGTH];
+ char *org_buf, *buf_pointer;
+ int record_pointer;
+ size_t len;
+
+ if (gi->databaseType != GEOIP_ORG_EDITION &&
+ gi->databaseType != GEOIP_ISP_EDITION &&
+ gi->databaseType != GEOIP_DOMAIN_EDITION &&
+ gi->databaseType != GEOIP_ASNUM_EDITION &&
+ gi->databaseType != GEOIP_ACCURACYRADIUS_EDITION &&
+ gi->databaseType != GEOIP_NETSPEED_EDITION_REV1 &&
+ gi->databaseType != GEOIP_USERTYPE_EDITION &&
+ gi->databaseType != GEOIP_REGISTRAR_EDITION &&
+ gi->databaseType != GEOIP_LOCATIONA_EDITION &&
+ gi->databaseType != GEOIP_CITYCONF_EDITION &&
+ gi->databaseType != GEOIP_COUNTRYCONF_EDITION &&
+ gi->databaseType != GEOIP_REGIONCONF_EDITION &&
+ gi->databaseType != GEOIP_POSTALCONF_EDITION) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_ORG_EDITION));
+ return NULL;
+ }
+
+ seek_org = _GeoIP_seek_record_gl(gi, ipnum, gl);
+ if (seek_org == gi->databaseSegments[0]) {
+ return NULL;
+ }
+
+ record_pointer =
+ seek_org + (2 * gi->record_length - 1) * gi->databaseSegments[0];
+
+ if (gi->cache == NULL) {
+ if (pread(fileno(gi->GeoIPDatabase),
+ buf,
+ MAX_ORG_RECORD_LENGTH,
+ record_pointer) == -1) {
+ return NULL;
+ }
+ if (gi->charset == GEOIP_CHARSET_UTF8) {
+ org_buf = _GeoIP_iso_8859_1__utf8((const char *)buf);
+ } else {
+ len = sizeof(char) * (strlen(buf) + 1);
+ org_buf = malloc(len);
+ strncpy(org_buf, buf, len);
+ }
+ } else {
+ buf_pointer = (char *)(gi->cache + (long)record_pointer);
+ if (gi->charset == GEOIP_CHARSET_UTF8) {
+ org_buf = _GeoIP_iso_8859_1__utf8((const char *)buf_pointer);
+ } else {
+ len = sizeof(char) * (strlen(buf_pointer) + 1);
+ org_buf = malloc(len);
+ strncpy(org_buf, buf_pointer, len);
+ }
+ }
+ return org_buf;
+}
+
+static char *_get_name_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ unsigned int seek_org;
+ char buf[MAX_ORG_RECORD_LENGTH + 1];
+ char *org_buf, *buf_pointer;
+ int record_pointer;
+ size_t len;
+
+ if (gi->databaseType != GEOIP_ORG_EDITION_V6 &&
+ gi->databaseType != GEOIP_ISP_EDITION_V6 &&
+ gi->databaseType != GEOIP_DOMAIN_EDITION_V6 &&
+ gi->databaseType != GEOIP_ASNUM_EDITION_V6 &&
+ gi->databaseType != GEOIP_ACCURACYRADIUS_EDITION_V6 &&
+ gi->databaseType != GEOIP_NETSPEED_EDITION_REV1_V6 &&
+ gi->databaseType != GEOIP_USERTYPE_EDITION_V6 &&
+ gi->databaseType != GEOIP_REGISTRAR_EDITION_V6 &&
+ gi->databaseType != GEOIP_LOCATIONA_EDITION_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ get_db_description(gi->databaseType),
+ get_db_description(GEOIP_ORG_EDITION));
+ return NULL;
+ }
+
+ seek_org = _GeoIP_seek_record_v6_gl(gi, ipnum, gl);
+ if (seek_org == gi->databaseSegments[0]) {
+ return NULL;
+ }
+
+ record_pointer =
+ seek_org + (2 * gi->record_length - 1) * gi->databaseSegments[0];
+
+ if (gi->cache == NULL) {
+ if (pread(fileno(gi->GeoIPDatabase),
+ buf,
+ MAX_ORG_RECORD_LENGTH,
+ record_pointer) == -1) {
+ return NULL;
+ }
+ buf[MAX_ORG_RECORD_LENGTH] = 0;
+ if (gi->charset == GEOIP_CHARSET_UTF8) {
+ org_buf = _GeoIP_iso_8859_1__utf8((const char *)buf);
+ } else {
+ len = sizeof(char) * (strlen(buf) + 1);
+ org_buf = malloc(len);
+ strncpy(org_buf, buf, len);
+ }
+ } else {
+ buf_pointer = (char *)(gi->cache + (long)record_pointer);
+ if (gi->charset == GEOIP_CHARSET_UTF8) {
+ org_buf = _GeoIP_iso_8859_1__utf8((const char *)buf_pointer);
+ } else {
+ len = sizeof(char) * (strlen(buf_pointer) + 1);
+ org_buf = malloc(len);
+ strncpy(org_buf, buf_pointer, len);
+ }
+ }
+ return org_buf;
+}
+
+char *GeoIP_num_to_addr(unsigned long ipnum) {
+ char *ret_str;
+ char *cur_str;
+ int octet[4];
+ int num_chars_written, i;
+
+ ret_str = malloc(sizeof(char) * 16);
+ cur_str = ret_str;
+
+ for (i = 0; i < 4; i++) {
+ octet[3 - i] = ipnum % 256;
+ ipnum >>= 8;
+ }
+
+ for (i = 0; i < 4; i++) {
+ num_chars_written = sprintf(cur_str, "%d", octet[i]);
+ cur_str += num_chars_written;
+
+ if (i < 3) {
+ cur_str[0] = '.';
+ cur_str++;
+ }
+ }
+
+ return ret_str;
+}
+
+char **GeoIP_range_by_ip_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ unsigned long left_seek;
+ unsigned long right_seek;
+ unsigned long mask;
+ int orig_netmask;
+ unsigned int target_value;
+ char **ret;
+ GeoIPLookup t;
+
+ if (addr == NULL) {
+ return NULL;
+ }
+
+ ret = malloc(sizeof(char *) * 2);
+
+ ipnum = GeoIP_addr_to_num(addr);
+ target_value = _GeoIP_seek_record_gl(gi, ipnum, gl);
+ orig_netmask = gl->netmask;
+ mask = 0xffffffff << (32 - orig_netmask);
+ left_seek = ipnum & mask;
+ right_seek = left_seek + (0xffffffff & ~mask);
+
+ while (left_seek != 0 &&
+ target_value == _GeoIP_seek_record_gl(gi, left_seek - 1, &t)) {
+
+ /* Go to beginning of netblock defined by netmask */
+ mask = 0xffffffff << (32 - t.netmask);
+ left_seek = (left_seek - 1) & mask;
+ }
+ ret[0] = GeoIP_num_to_addr(left_seek);
+
+ while (right_seek != 0xffffffff &&
+ target_value == _GeoIP_seek_record_gl(gi, right_seek + 1, &t)) {
+
+ /* Go to end of netblock defined by netmask */
+ mask = 0xffffffff << (32 - t.netmask);
+ right_seek = (right_seek + 1) & mask;
+ right_seek += 0xffffffff & ~mask;
+ }
+ ret[1] = GeoIP_num_to_addr(right_seek);
+
+ gi->netmask = orig_netmask;
+
+ return ret;
+}
+void GeoIP_range_by_ip_delete(char **ptr) {
+ if (ptr) {
+ if (ptr[0]) {
+ free(ptr[0]);
+ }
+ if (ptr[1]) {
+ free(ptr[1]);
+ }
+ free(ptr);
+ }
+}
+
+char *GeoIP_name_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ return _get_name_gl(gi, ipnum, gl);
+}
+
+char *GeoIP_name_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ return _get_name_v6_gl(gi, ipnum, gl);
+}
+
+char *GeoIP_name_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ if (addr == NULL) {
+ return NULL;
+ }
+ ipnum = GeoIP_addr_to_num(addr);
+ return _get_name_gl(gi, ipnum, gl);
+}
+
+char *GeoIP_name_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ if (addr == NULL) {
+ return NULL;
+ }
+ ipnum = _GeoIP_addr_to_num_v6(addr);
+ return _get_name_v6_gl(gi, ipnum, gl);
+}
+
+char *GeoIP_name_by_name_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ unsigned long ipnum;
+ if (name == NULL) {
+ return NULL;
+ }
+ if (!(ipnum = _GeoIP_lookupaddress(name))) {
+ return NULL;
+ }
+ return _get_name_gl(gi, ipnum, gl);
+}
+
+char *GeoIP_name_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl) {
+ geoipv6_t ipnum;
+ if (name == NULL) {
+ return NULL;
+ }
+ ipnum = _GeoIP_lookupaddress_v6(name);
+ if (__GEOIP_V6_IS_NULL(ipnum)) {
+ return NULL;
+ }
+ return _get_name_v6_gl(gi, ipnum, gl);
+}
+
+unsigned char GeoIP_database_edition(GeoIP *gi) { return gi->databaseType; }
+
+int GeoIP_enable_teredo(GeoIP *gi, int true_false) {
+ unsigned int mask = (1U << GEOIP_TEREDO_BIT);
+ int b = (gi->ext_flags & mask) ? 1 : 0;
+ gi->ext_flags &= ~mask;
+ if (true_false) {
+ gi->ext_flags |= true_false;
+ }
+ return b;
+}
+
+int GeoIP_teredo(GeoIP *gi) {
+ unsigned int mask = (1U << GEOIP_TEREDO_BIT);
+ return (gi->ext_flags & mask) ? 1 : 0;
+}
+
+int GeoIP_charset(GeoIP *gi) { return gi->charset; }
+
+int GeoIP_set_charset(GeoIP *gi, int charset) {
+ int old_charset = gi->charset;
+ gi->charset = charset;
+ return old_charset;
+}
+
+/** return two letter country code */
+const char *GeoIP_code_by_id(int id) {
+ if (id < 0 || id >= (int)num_GeoIP_countries) {
+ return NULL;
+ }
+
+ return GeoIP_country_code[id];
+}
+
+/** return three letter country code */
+const char *GeoIP_code3_by_id(int id) {
+ if (id < 0 || id >= (int)num_GeoIP_countries) {
+ return NULL;
+ }
+
+ return GeoIP_country_code3[id];
+}
+
+/** return full name of country in utf8 or iso-8859-1 */
+const char *GeoIP_country_name_by_id(GeoIP *gi, int id) {
+ /* return NULL also even for index 0 for backward compatibility */
+ if (id <= 0 || id >= (int)num_GeoIP_countries) {
+ return NULL;
+ }
+ return (gi->charset == GEOIP_CHARSET_UTF8) ? GeoIP_utf8_country_name[id]
+ : GeoIP_country_name[id];
+}
+
+/** return full name of country in iso-8859-1 */
+const char *GeoIP_name_by_id(int id) {
+ if (id < 0 || id >= (int)num_GeoIP_countries) {
+ return NULL;
+ }
+
+ return GeoIP_country_name[id];
+}
+
+/** return continent of country */
+const char *GeoIP_continent_by_id(int id) {
+ if (id < 0 || id >= (int)num_GeoIP_countries) {
+ return NULL;
+ }
+
+ return GeoIP_country_continent[id];
+}
+
+/** return id by country code **/
+int GeoIP_id_by_code(const char *country) {
+ unsigned i;
+
+ for (i = 0; i < num_GeoIP_countries; ++i) {
+ if (strcmp(country, GeoIP_country_code[i]) == 0) {
+ return i;
+ }
+ }
+
+ return 0;
+}
+
+unsigned GeoIP_num_countries(void) { return num_GeoIP_countries; }
+
+const char *GeoIP_lib_version(void) { return PACKAGE_VERSION; }
+
+int GeoIP_cleanup(void) {
+ int i, result = 0;
+ char **tmpGeoIPDBFileName = GeoIPDBFileName;
+
+ GeoIPDBFileName = NULL;
+
+ if (tmpGeoIPDBFileName) {
+ for (i = 0; i < NUM_DB_TYPES; i++) {
+ if (tmpGeoIPDBFileName[i]) {
+ free(tmpGeoIPDBFileName[i]);
+ }
+ }
+
+ free(tmpGeoIPDBFileName);
+ result = 1;
+ }
+
+ return result;
+}
diff --git a/libGeoIP/GeoIP.h b/libGeoIP/GeoIP.h
new file mode 100644
index 0000000..2852595
--- /dev/null
+++ b/libGeoIP/GeoIP.h
@@ -0,0 +1,444 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* GeoIP.h
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef GEOIP_H
+#define GEOIP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#if !defined(_WIN32)
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#else /* !defined(_WIN32) */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#define FILETIME_TO_USEC(ft) \
+ (((unsigned __int64)ft.dwHighDateTime << 32 | ft.dwLowDateTime) / 10)
+#endif /* !defined(_WIN32) */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h> /* for fstat */
+#include <sys/types.h> /* for fstat */
+
+#define SEGMENT_RECORD_LENGTH 3
+#define LARGE_SEGMENT_RECORD_LENGTH 4
+#define STANDARD_RECORD_LENGTH 3
+#define ORG_RECORD_LENGTH 4
+#define MAX_RECORD_LENGTH 4
+#define NUM_DB_TYPES (38 + 1)
+
+/* 128 bit address in network order */
+typedef struct in6_addr geoipv6_t;
+
+#define GEOIP_CHKBIT_V6(bit, ptr) \
+ (ptr[((127UL - bit) >> 3)] & (1UL << (~(127 - bit) & 7)))
+
+typedef struct GeoIPTag {
+ FILE *GeoIPDatabase;
+ char *file_path;
+ unsigned char *cache;
+ unsigned char *index_cache;
+ unsigned int *databaseSegments;
+ char databaseType;
+ time_t mtime;
+ int flags;
+ off_t size;
+ char record_length;
+ int charset; /* 0 iso-8859-1 1 utf8 */
+ int record_iter; /* used in GeoIP_next_record */
+ int netmask; /* netmask of last lookup - set using depth in
+ _GeoIP_seek_record */
+ time_t last_mtime_check;
+ off_t dyn_seg_size; /* currently only used by the cityconfidence database */
+ unsigned int ext_flags; /* bit 0 teredo support enabled */
+} GeoIP;
+
+typedef struct GeoIPLookup { int netmask; } GeoIPLookup;
+
+typedef enum { GEOIP_TEREDO_BIT = 0 } GeoIPExtFlags;
+
+typedef enum {
+ GEOIP_CHARSET_ISO_8859_1 = 0,
+ GEOIP_CHARSET_UTF8 = 1
+} GeoIPCharset;
+
+typedef struct GeoIPRegionTag {
+ char country_code[3];
+ char region[3];
+} GeoIPRegion;
+
+typedef enum {
+ GEOIP_STANDARD = 0,
+ GEOIP_MEMORY_CACHE = 1,
+ GEOIP_CHECK_CACHE = 2,
+ GEOIP_INDEX_CACHE = 4,
+ GEOIP_MMAP_CACHE = 8,
+ GEOIP_SILENCE = 16,
+} GeoIPOptions;
+
+typedef enum {
+ GEOIP_COUNTRY_EDITION = 1,
+ GEOIP_REGION_EDITION_REV0 = 7,
+ GEOIP_CITY_EDITION_REV0 = 6,
+ GEOIP_ORG_EDITION = 5,
+ GEOIP_ISP_EDITION = 4,
+ GEOIP_CITY_EDITION_REV1 = 2,
+ GEOIP_REGION_EDITION_REV1 = 3,
+ GEOIP_PROXY_EDITION = 8,
+ GEOIP_ASNUM_EDITION = 9,
+ GEOIP_NETSPEED_EDITION = 10,
+ GEOIP_DOMAIN_EDITION = 11,
+ GEOIP_COUNTRY_EDITION_V6 = 12,
+ GEOIP_LOCATIONA_EDITION = 13,
+ GEOIP_ACCURACYRADIUS_EDITION = 14,
+ GEOIP_CITYCONFIDENCE_EDITION = 15, /* unsupported */
+ GEOIP_CITYCONFIDENCEDIST_EDITION = 16, /* unsupported */
+ GEOIP_LARGE_COUNTRY_EDITION = 17,
+ GEOIP_LARGE_COUNTRY_EDITION_V6 = 18,
+ GEOIP_CITYCONFIDENCEDIST_ISP_ORG_EDITION =
+ 19, /* unused, but gaps are not allowed */
+ GEOIP_CCM_COUNTRY_EDITION = 20, /* unused, but gaps are not allowed */
+ GEOIP_ASNUM_EDITION_V6 = 21,
+ GEOIP_ISP_EDITION_V6 = 22,
+ GEOIP_ORG_EDITION_V6 = 23,
+ GEOIP_DOMAIN_EDITION_V6 = 24,
+ GEOIP_LOCATIONA_EDITION_V6 = 25,
+ GEOIP_REGISTRAR_EDITION = 26,
+ GEOIP_REGISTRAR_EDITION_V6 = 27,
+ GEOIP_USERTYPE_EDITION = 28,
+ GEOIP_USERTYPE_EDITION_V6 = 29,
+ GEOIP_CITY_EDITION_REV1_V6 = 30,
+ GEOIP_CITY_EDITION_REV0_V6 = 31,
+ GEOIP_NETSPEED_EDITION_REV1 = 32,
+ GEOIP_NETSPEED_EDITION_REV1_V6 = 33,
+ GEOIP_COUNTRYCONF_EDITION = 34,
+ GEOIP_CITYCONF_EDITION = 35,
+ GEOIP_REGIONCONF_EDITION = 36,
+ GEOIP_POSTALCONF_EDITION = 37,
+ GEOIP_ACCURACYRADIUS_EDITION_V6 = 38
+} GeoIPDBTypes;
+
+typedef enum {
+ GEOIP_ANON_PROXY = 1,
+ GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
+ GEOIP_HTTP_CLIENT_IP_PROXY = 3,
+} GeoIPProxyTypes;
+
+typedef enum {
+ GEOIP_UNKNOWN_SPEED = 0,
+ GEOIP_DIALUP_SPEED = 1,
+ GEOIP_CABLEDSL_SPEED = 2,
+ GEOIP_CORPORATE_SPEED = 3,
+} GeoIPNetspeedValues;
+
+#if defined(_WIN32) && !defined(__MINGW32__)
+#ifdef GEOIP_EXPORTS
+#define GEOIP_API __declspec(dllexport)
+#define GEOIP_DATA __declspec(dllexport)
+#else
+#define GEOIP_DATA __declspec(dllimport)
+#define GEOIP_API
+#endif /* GEOIP_EXPORTS */
+#else
+#define GEOIP_API
+#define GEOIP_DATA
+#endif
+
+extern char **GeoIPDBFileName;
+extern GEOIP_DATA const char *GeoIPDBDescription[NUM_DB_TYPES];
+extern GEOIP_DATA const char *GeoIPCountryDBFileName;
+extern GEOIP_DATA const char *GeoIPRegionDBFileName;
+extern GEOIP_DATA const char *GeoIPCityDBFileName;
+extern GEOIP_DATA const char *GeoIPOrgDBFileName;
+extern GEOIP_DATA const char *GeoIPISPDBFileName;
+extern GEOIP_DATA const char *GeoIPLocationADBFileName;
+extern GEOIP_DATA const char *GeoIPAccuracyRadiusFileName;
+extern GEOIP_DATA const char *GeoIPCityConfidenceFileName;
+extern char *GeoIP_custom_directory;
+
+/* Warning: do not use those arrays as doing so may break your
+ * program with newer GeoIP versions */
+extern GEOIP_DATA const char GeoIP_country_code[256][3];
+extern GEOIP_DATA const char GeoIP_country_code3[256][4];
+extern GEOIP_DATA const char *GeoIP_country_name[256];
+extern GEOIP_DATA const char *GeoIP_utf8_country_name[256];
+extern GEOIP_DATA const char GeoIP_country_continent[256][3];
+
+GEOIP_API void GeoIP_setup_custom_directory(char *dir);
+GEOIP_API GeoIP *GeoIP_open_type(int type, int flags);
+GEOIP_API GeoIP *GeoIP_new(int flags);
+GEOIP_API GeoIP *GeoIP_open(const char *filename, int flags);
+/*
+ * WARNING: GeoIP_db_avail() checks for the existence of a database
+ * file but does not check that it has the requested database revision.
+ * For database types which have more than one revision (including Region,
+ * City, and Cityv6), this can lead to unexpected results. Check the
+ * return value of GeoIP_open_type() to find out whether a particular
+ * database type is really available.
+ */
+GEOIP_API int GeoIP_db_avail(int type);
+GEOIP_API void GeoIP_delete(GeoIP *gi);
+
+GEOIP_API const char *
+GeoIP_country_code_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code3_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code3_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_name_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_name_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_name_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+GEOIP_API const char *GeoIP_country_code3_by_ipnum_gl(GeoIP *gi,
+ unsigned long ipnum,
+ GeoIPLookup *gl);
+
+/* */
+GEOIP_API const char *
+GeoIP_country_name_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code3_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+
+GEOIP_API const char *
+GeoIP_country_code_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code_by_name_v6_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code3_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_code3_by_name_v6_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_name_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API const char *
+GeoIP_country_name_by_name_v6_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+
+GEOIP_API int GeoIP_id_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API int GeoIP_id_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API int
+GeoIP_id_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+
+GEOIP_API int
+GeoIP_id_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API int
+GeoIP_id_by_name_v6_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API int
+GeoIP_id_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_name_v6_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+GEOIP_API GeoIPRegion *
+GeoIP_region_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+
+/* Warning - don't call this after GeoIP_assign_region_by_inetaddr calls */
+GEOIP_API void GeoIPRegion_delete(GeoIPRegion *gir);
+
+GEOIP_API void GeoIP_assign_region_by_inetaddr_gl(GeoIP *gi,
+ unsigned long inetaddr,
+ GeoIPRegion *gir,
+ GeoIPLookup *gl);
+GEOIP_API void GeoIP_assign_region_by_inetaddr_v6_gl(GeoIP *gi,
+ geoipv6_t inetaddr,
+ GeoIPRegion *gir,
+ GeoIPLookup *gl);
+
+/* Used to query GeoIP Organization, ISP and AS Number databases */
+GEOIP_API char *
+GeoIP_name_by_ipnum_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+GEOIP_API char *
+GeoIP_name_by_addr_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API char *
+GeoIP_name_by_name_gl(GeoIP *gi, const char *host, GeoIPLookup *gl);
+
+GEOIP_API char *
+GeoIP_name_by_ipnum_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+GEOIP_API char *
+GeoIP_name_by_addr_v6_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API char *
+GeoIP_name_by_name_v6_gl(GeoIP *gi, const char *name, GeoIPLookup *gl);
+
+/** return two letter country code */
+GEOIP_API const char *GeoIP_code_by_id(int id);
+
+/** return three letter country code */
+GEOIP_API const char *GeoIP_code3_by_id(int id);
+
+/** return full name of country in utf8 or iso-8859-1 */
+GEOIP_API const char *GeoIP_country_name_by_id(GeoIP *gi, int id);
+
+/** return full name of country */
+GEOIP_API const char *GeoIP_name_by_id(int id);
+
+/** return continent of country */
+GEOIP_API const char *GeoIP_continent_by_id(int id);
+
+/** return id by country code **/
+GEOIP_API int GeoIP_id_by_code(const char *country);
+
+/** return return number of known countries */
+GEOIP_API unsigned GeoIP_num_countries(void);
+
+GEOIP_API char *GeoIP_database_info(GeoIP *gi);
+GEOIP_API unsigned char GeoIP_database_edition(GeoIP *gi);
+
+GEOIP_API int GeoIP_charset(GeoIP *gi);
+GEOIP_API int GeoIP_set_charset(GeoIP *gi, int charset);
+GEOIP_API int GeoIP_enable_teredo(GeoIP *gi, int true_false);
+GEOIP_API int GeoIP_teredo(GeoIP *gi);
+
+GEOIP_API char **
+GeoIP_range_by_ip_gl(GeoIP *gi, const char *addr, GeoIPLookup *gl);
+GEOIP_API void GeoIP_range_by_ip_delete(char **ptr);
+
+/* Convert region code to region name */
+GEOIP_API const char *GeoIP_region_name_by_code(const char *country_code,
+ const char *region_code);
+
+/* Get timezone from country and region code */
+GEOIP_API const char *
+GeoIP_time_zone_by_country_and_region(const char *country_code,
+ const char *region_code);
+
+/* some v4 helper functions as of 1.4.7 exported to the public API */
+GEOIP_API unsigned long GeoIP_addr_to_num(const char *addr);
+GEOIP_API char *GeoIP_num_to_addr(unsigned long ipnum);
+
+/* Internal function -- convert iso to utf8; return a malloced utf8 string. */
+char *_GeoIP_iso_8859_1__utf8(const char *iso);
+
+/* Cleans up memory used to hold file name paths. Returns 1 if successful;
+ * otherwise 0.
+ * */
+GEOIP_API int GeoIP_cleanup(void);
+
+/* Returns the library version in use. Helpful if you're loading dynamically. */
+GEOIP_API const char *GeoIP_lib_version(void);
+
+/* deprecated */
+GEOIP_API const char *GeoIP_country_code_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API const char *GeoIP_country_code_by_name(GeoIP *gi, const char *host);
+GEOIP_API const char *GeoIP_country_code3_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API const char *GeoIP_country_code3_by_name(GeoIP *gi, const char *host);
+GEOIP_API const char *GeoIP_country_name_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API const char *GeoIP_country_name_by_name(GeoIP *gi, const char *host);
+GEOIP_API const char *GeoIP_country_name_by_ipnum(GeoIP *gi,
+ unsigned long ipnum);
+GEOIP_API const char *GeoIP_country_code_by_ipnum(GeoIP *gi,
+ unsigned long ipnum);
+GEOIP_API const char *GeoIP_country_code3_by_ipnum(GeoIP *gi,
+ unsigned long ipnum);
+
+GEOIP_API const char *GeoIP_country_name_by_ipnum_v6(GeoIP *gi,
+ geoipv6_t ipnum);
+GEOIP_API const char *GeoIP_country_code_by_ipnum_v6(GeoIP *gi,
+ geoipv6_t ipnum);
+GEOIP_API const char *GeoIP_country_code3_by_ipnum_v6(GeoIP *gi,
+ geoipv6_t ipnum);
+
+GEOIP_API const char *GeoIP_country_code_by_addr_v6(GeoIP *gi,
+ const char *addr);
+GEOIP_API const char *GeoIP_country_code_by_name_v6(GeoIP *gi,
+ const char *host);
+GEOIP_API const char *GeoIP_country_code3_by_addr_v6(GeoIP *gi,
+ const char *addr);
+GEOIP_API const char *GeoIP_country_code3_by_name_v6(GeoIP *gi,
+ const char *host);
+GEOIP_API const char *GeoIP_country_name_by_addr_v6(GeoIP *gi,
+ const char *addr);
+GEOIP_API const char *GeoIP_country_name_by_name_v6(GeoIP *gi,
+ const char *host);
+
+GEOIP_API int GeoIP_id_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API int GeoIP_id_by_name(GeoIP *gi, const char *host);
+GEOIP_API int GeoIP_id_by_ipnum(GeoIP *gi, unsigned long ipnum);
+
+GEOIP_API int GeoIP_id_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API int GeoIP_id_by_name_v6(GeoIP *gi, const char *host);
+GEOIP_API int GeoIP_id_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum);
+
+GEOIP_API GeoIPRegion *GeoIP_region_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API GeoIPRegion *GeoIP_region_by_name(GeoIP *gi, const char *host);
+GEOIP_API GeoIPRegion *GeoIP_region_by_ipnum(GeoIP *gi, unsigned long ipnum);
+
+GEOIP_API GeoIPRegion *GeoIP_region_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API GeoIPRegion *GeoIP_region_by_name_v6(GeoIP *gi, const char *host);
+GEOIP_API GeoIPRegion *GeoIP_region_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum);
+
+GEOIP_API void GeoIP_assign_region_by_inetaddr(GeoIP *gi,
+ unsigned long inetaddr,
+ GeoIPRegion *gir);
+GEOIP_API void GeoIP_assign_region_by_inetaddr_v6(GeoIP *gi,
+ geoipv6_t inetaddr,
+ GeoIPRegion *gir);
+
+GEOIP_API char *GeoIP_name_by_ipnum(GeoIP *gi, unsigned long ipnum);
+GEOIP_API char *GeoIP_name_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API char *GeoIP_name_by_name(GeoIP *gi, const char *host);
+
+GEOIP_API char *GeoIP_name_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum);
+GEOIP_API char *GeoIP_name_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API char *GeoIP_name_by_name_v6(GeoIP *gi, const char *name);
+
+/** GeoIP_last_netmask is deprecated - it is not thread safe */
+GEOIP_API int GeoIP_last_netmask(GeoIP *gi);
+GEOIP_API char **GeoIP_range_by_ip(GeoIP *gi, const char *addr);
+
+/* Deprecated - for backwards compatibility only */
+GEOIP_API int GeoIP_country_id_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API int GeoIP_country_id_by_name(GeoIP *gi, const char *host);
+GEOIP_API char *GeoIP_org_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API char *GeoIP_org_by_name(GeoIP *gi, const char *host);
+GEOIP_API char *GeoIP_org_by_ipnum(GeoIP *gi, unsigned long ipnum);
+
+GEOIP_API int GeoIP_country_id_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API char *GeoIP_org_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum);
+GEOIP_API char *GeoIP_org_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API char *GeoIP_org_by_name_v6(GeoIP *gi, const char *name);
+
+/* End deprecated */
+
+#
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GEOIP_H */
diff --git a/libGeoIP/GeoIPCity.c b/libGeoIP/GeoIPCity.c
new file mode 100644
index 0000000..543f829
--- /dev/null
+++ b/libGeoIP/GeoIPCity.c
@@ -0,0 +1,330 @@
+
+/*
+ * GeoIPCity.c
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "GeoIPCity.h"
+#include "GeoIP.h"
+#include "GeoIP_internal.h"
+#if !defined(_WIN32)
+#include <netdb.h>
+#include <netinet/in.h> /* For ntohl */
+#include <unistd.h>
+#else
+#include <windows.h>
+#include <winsock.h>
+
+#if defined(_MSC_VER) && \
+ _MSC_VER >= 1400 // VS 2005+ deprecates fileno, lseek and read
+#define fileno _fileno
+#define read _read
+#define lseek _lseek
+#endif
+#endif
+#include <sys/types.h> /* For uint32_t */
+#ifdef HAVE_STDINT_H
+#include <stdint.h> /* For uint32_t */
+#endif
+
+#if defined(_WIN32) && !defined(__MINGW32__)
+#include "pread.h"
+#endif
+
+#ifndef HAVE_PREAD
+#define pread(fd, buf, count, offset) \
+ (lseek(fd, offset, SEEK_SET) == offset ? read(fd, buf, count) : -1)
+#endif /* HAVE_PREAD */
+
+static const int FULL_RECORD_LENGTH = 50;
+
+static GeoIPRecord *
+_extract_record(GeoIP *gi, unsigned int seek_record, int *next_record_ptr) {
+ int record_pointer;
+ unsigned char *record_buf = NULL;
+ unsigned char *begin_record_buf = NULL;
+ GeoIPRecord *record;
+ int str_length = 0;
+ int j;
+ double latitude = 0, longitude = 0;
+ int metroarea_combo = 0;
+ int bytes_read = 0;
+ if (seek_record == gi->databaseSegments[0]) {
+ return NULL;
+ }
+
+ record = malloc(sizeof(GeoIPRecord));
+ memset(record, 0, sizeof(GeoIPRecord));
+ record->charset = gi->charset;
+
+ record_pointer =
+ seek_record + (2 * gi->record_length - 1) * gi->databaseSegments[0];
+
+ if (gi->cache == NULL) {
+ begin_record_buf = record_buf =
+ malloc(sizeof(unsigned char) * FULL_RECORD_LENGTH);
+ bytes_read = pread(fileno(gi->GeoIPDatabase),
+ record_buf,
+ FULL_RECORD_LENGTH,
+ record_pointer);
+ if (bytes_read <= 0) {
+ /* eof or other error */
+ free(begin_record_buf);
+ free(record);
+ return NULL;
+ }
+ } else {
+ if (gi->size <= record_pointer) {
+ /* record does not exist in the cache */
+ free(record);
+ return NULL;
+ }
+ record_buf = gi->cache + (long)record_pointer;
+ }
+
+ /* get country */
+ record->continent_code = (char *)GeoIP_country_continent[record_buf[0]];
+ record->country_code = (char *)GeoIP_country_code[record_buf[0]];
+ record->country_code3 = (char *)GeoIP_country_code3[record_buf[0]];
+ record->country_name = (char *)GeoIP_country_name_by_id(gi, record_buf[0]);
+ record_buf++;
+
+ /* get region */
+ while (record_buf[str_length] != '\0') {
+ str_length++;
+ }
+ if (str_length > 0) {
+ record->region = malloc(str_length + 1);
+ strncpy(record->region, (char *)record_buf, str_length + 1);
+ }
+ record_buf += str_length + 1;
+ str_length = 0;
+
+ /* get city */
+ while (record_buf[str_length] != '\0') {
+ str_length++;
+ }
+ if (str_length > 0) {
+ if (gi->charset == GEOIP_CHARSET_UTF8) {
+ record->city = _GeoIP_iso_8859_1__utf8((const char *)record_buf);
+ } else {
+ record->city = malloc(str_length + 1);
+ strncpy(record->city, (const char *)record_buf, str_length + 1);
+ }
+ }
+ record_buf += (str_length + 1);
+ str_length = 0;
+
+ /* get postal code */
+ while (record_buf[str_length] != '\0') {
+ str_length++;
+ }
+ if (str_length > 0) {
+ record->postal_code = malloc(str_length + 1);
+ strncpy(record->postal_code, (char *)record_buf, str_length + 1);
+ }
+ record_buf += (str_length + 1);
+
+ /* get latitude */
+ for (j = 0; j < 3; ++j) {
+ latitude += (record_buf[j] << (j * 8));
+ }
+ record->latitude = (float)(latitude / 10000 - 180);
+ record_buf += 3;
+
+ /* get longitude */
+ for (j = 0; j < 3; ++j) {
+ longitude += (record_buf[j] << (j * 8));
+ }
+ record->longitude = (float)(longitude / 10000 - 180);
+
+ /*
+ * get area code and metro code for post April 2002 databases and for US
+ * locations
+ */
+ if (gi->databaseType == GEOIP_CITY_EDITION_REV1 ||
+ gi->databaseType == GEOIP_CITY_EDITION_REV1_V6) {
+ if (!strcmp(record->country_code, "US")) {
+ record_buf += 3;
+ for (j = 0; j < 3; ++j) {
+ metroarea_combo += (record_buf[j] << (j * 8));
+ }
+ record->metro_code = metroarea_combo / 1000;
+ record->area_code = metroarea_combo % 1000;
+ }
+ }
+
+ if (begin_record_buf != NULL) {
+ free(begin_record_buf);
+ }
+
+ /* Used for GeoIP_next_record */
+ if (next_record_ptr != NULL) {
+ *next_record_ptr = seek_record + record_buf - begin_record_buf + 3;
+ }
+
+ return record;
+}
+
+static GeoIPRecord *
+_get_record_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl) {
+ unsigned int seek_record;
+ GeoIPRecord *r;
+ if (gi->databaseType != GEOIP_CITY_EDITION_REV0 &&
+ gi->databaseType != GEOIP_CITY_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ GeoIPDBDescription[(int)gi->databaseType],
+ GeoIPDBDescription[GEOIP_CITY_EDITION_REV1]);
+ return NULL;
+ }
+
+ seek_record = _GeoIP_seek_record_gl(gi, ipnum, gl);
+ r = _extract_record(gi, seek_record, NULL);
+ if (r) {
+ r->netmask = gl->netmask;
+ }
+ return r;
+}
+
+static GeoIPRecord *_get_record(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return _get_record_gl(gi, ipnum, &gl);
+}
+
+static GeoIPRecord *
+_get_record_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl) {
+ GeoIPRecord *r;
+ unsigned int seek_record;
+ if (gi->databaseType != GEOIP_CITY_EDITION_REV0_V6 &&
+ gi->databaseType != GEOIP_CITY_EDITION_REV1_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ GeoIPDBDescription[(int)gi->databaseType],
+ GeoIPDBDescription[GEOIP_CITY_EDITION_REV1_V6]);
+ return NULL;
+ }
+
+ seek_record = _GeoIP_seek_record_v6_gl(gi, ipnum, gl);
+ r = _extract_record(gi, seek_record, NULL);
+ if (r) {
+ r->netmask = gl->netmask;
+ }
+ return r;
+}
+
+static GeoIPRecord *_get_record_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return _get_record_v6_gl(gi, ipnum, &gl);
+}
+
+GeoIPRecord *GeoIP_record_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ return _get_record(gi, ipnum);
+}
+
+GeoIPRecord *GeoIP_record_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ return _get_record_v6(gi, ipnum);
+}
+
+GeoIPRecord *GeoIP_record_by_addr(GeoIP *gi, const char *addr) {
+ unsigned long ipnum;
+ GeoIPLookup gl;
+ if (addr == NULL) {
+ return 0;
+ }
+ ipnum = GeoIP_addr_to_num(addr);
+ return _get_record_gl(gi, ipnum, &gl);
+}
+
+GeoIPRecord *GeoIP_record_by_addr_v6(GeoIP *gi, const char *addr) {
+ geoipv6_t ipnum;
+ if (addr == NULL) {
+ return 0;
+ }
+ ipnum = _GeoIP_addr_to_num_v6(addr);
+ return _get_record_v6(gi, ipnum);
+}
+
+GeoIPRecord *GeoIP_record_by_name(GeoIP *gi, const char *name) {
+ unsigned long ipnum;
+ if (name == NULL) {
+ return 0;
+ }
+ ipnum = _GeoIP_lookupaddress(name);
+ return _get_record(gi, ipnum);
+}
+
+GeoIPRecord *GeoIP_record_by_name_v6(GeoIP *gi, const char *name) {
+ geoipv6_t ipnum;
+ if (name == NULL) {
+ return 0;
+ }
+ ipnum = _GeoIP_lookupaddress_v6(name);
+ return _get_record_v6(gi, ipnum);
+}
+
+int GeoIP_record_id_by_addr(GeoIP *gi, const char *addr) {
+ unsigned long ipnum;
+ if (gi->databaseType != GEOIP_CITY_EDITION_REV0 &&
+ gi->databaseType != GEOIP_CITY_EDITION_REV1) {
+ printf("Invalid database type %s, expected %s\n",
+ GeoIPDBDescription[(int)gi->databaseType],
+ GeoIPDBDescription[GEOIP_CITY_EDITION_REV1]);
+ return 0;
+ }
+ if (addr == NULL) {
+ return 0;
+ }
+ ipnum = GeoIP_addr_to_num(addr);
+ return _GeoIP_seek_record(gi, ipnum);
+}
+
+int GeoIP_record_id_by_addr_v6(GeoIP *gi, const char *addr) {
+ geoipv6_t ipnum;
+ if (gi->databaseType != GEOIP_CITY_EDITION_REV0_V6 &&
+ gi->databaseType != GEOIP_CITY_EDITION_REV1_V6) {
+ printf("Invalid database type %s, expected %s\n",
+ GeoIPDBDescription[(int)gi->databaseType],
+ GeoIPDBDescription[GEOIP_CITY_EDITION_REV1]);
+ return 0;
+ }
+ if (addr == NULL) {
+ return 0;
+ }
+ ipnum = _GeoIP_addr_to_num_v6(addr);
+ return _GeoIP_seek_record_v6(gi, ipnum);
+}
+
+int GeoIP_init_record_iter(GeoIP *gi) { return gi->databaseSegments[0] + 1; }
+
+int GeoIP_next_record(GeoIP *gi, GeoIPRecord **gir, int *record_iter) {
+ if (gi->cache != NULL) {
+ printf("GeoIP_next_record not supported in memory cache mode\n");
+ return 1;
+ }
+ *gir = _extract_record(gi, *record_iter, record_iter);
+ return 0;
+}
+
+void GeoIPRecord_delete(GeoIPRecord *gir) {
+ if (gir == NULL) {
+ return;
+ }
+ free(gir->region);
+ free(gir->city);
+ free(gir->postal_code);
+ free(gir);
+}
diff --git a/libGeoIP/GeoIPCity.h b/libGeoIP/GeoIPCity.h
new file mode 100644
index 0000000..259fd1e
--- /dev/null
+++ b/libGeoIP/GeoIPCity.h
@@ -0,0 +1,72 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* GeoIPCity.h
+ *
+ * Copyright (C) 2016 MaxMind, Inc.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef GEOIPCITY_H
+#define GEOIPCITY_H
+
+#include "GeoIP.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GEOIP_UNKNOWN_CONF (0x7f)
+
+typedef struct GeoIPRecordTag {
+ char *country_code;
+ char *country_code3;
+ char *country_name;
+ char *region;
+ char *city;
+ char *postal_code;
+ float latitude;
+ float longitude;
+ union {
+ int metro_code; /* metro_code is an alias for dma_code */
+ int dma_code;
+ };
+ int area_code;
+ int charset;
+ char *continent_code;
+ int netmask;
+} GeoIPRecord;
+
+GEOIP_API GeoIPRecord *GeoIP_record_by_ipnum(GeoIP *gi, unsigned long ipnum);
+GEOIP_API GeoIPRecord *GeoIP_record_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API GeoIPRecord *GeoIP_record_by_name(GeoIP *gi, const char *host);
+
+GEOIP_API GeoIPRecord *GeoIP_record_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum);
+GEOIP_API GeoIPRecord *GeoIP_record_by_addr_v6(GeoIP *gi, const char *addr);
+GEOIP_API GeoIPRecord *GeoIP_record_by_name_v6(GeoIP *gi, const char *host);
+
+GEOIP_API int GeoIP_record_id_by_addr(GeoIP *gi, const char *addr);
+GEOIP_API int GeoIP_record_id_by_addr_v6(GeoIP *gi, const char *addr);
+
+GEOIP_API int GeoIP_init_record_iter(GeoIP *gi);
+/* returns 0 on success, 1 on failure */
+GEOIP_API int GeoIP_next_record(GeoIP *gi, GeoIPRecord **gir, int *record_iter);
+
+GEOIP_API void GeoIPRecord_delete(GeoIPRecord *gir);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GEOIPCITY_H */
diff --git a/libGeoIP/GeoIP_deprecated.c b/libGeoIP/GeoIP_deprecated.c
new file mode 100644
index 0000000..aae3685
--- /dev/null
+++ b/libGeoIP/GeoIP_deprecated.c
@@ -0,0 +1,248 @@
+
+#include "GeoIP_internal.h"
+
+char *GeoIP_org_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_ipnum_gl(gi, ipnum, &gl);
+}
+
+char *GeoIP_org_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+
+char *GeoIP_org_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_addr_gl(gi, addr, &gl);
+}
+
+char *GeoIP_org_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_addr_v6_gl(gi, addr, &gl);
+}
+
+char *GeoIP_org_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_name_gl(gi, name, &gl);
+}
+
+char *GeoIP_org_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_name_v6_gl(gi, name, &gl);
+}
+
+int GeoIP_last_netmask(GeoIP *gi) { return gi->netmask; }
+
+unsigned int _GeoIP_seek_record_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return _GeoIP_seek_record_v6_gl(gi, ipnum, &gl);
+}
+
+unsigned int _GeoIP_seek_record(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return _GeoIP_seek_record_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_code_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_name_v6_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_code_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_name_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_code3_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_name_v6_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_code3_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_name_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_name_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_name_v6_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_name_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_name_gl(gi, name, &gl);
+}
+
+int GeoIP_id_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_name_gl(gi, name, &gl);
+}
+int GeoIP_id_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_name_v6_gl(gi, name, &gl);
+}
+
+const char *GeoIP_country_code_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_addr_v6_gl(gi, addr, &gl);
+}
+const char *GeoIP_country_code_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_addr_gl(gi, addr, &gl);
+}
+
+const char *GeoIP_country_code3_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_addr_v6_gl(gi, addr, &gl);
+}
+
+const char *GeoIP_country_code3_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_addr_gl(gi, addr, &gl);
+}
+
+const char *GeoIP_country_name_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_addr_v6_gl(gi, addr, &gl);
+}
+const char *GeoIP_country_name_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_addr_gl(gi, addr, &gl);
+}
+
+const char *GeoIP_country_name_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_ipnum_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_name_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_name_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_code_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_code_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_code_by_ipnum_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_code3_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_ipnum_gl(gi, ipnum, &gl);
+}
+
+const char *GeoIP_country_code3_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_country_code3_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+
+int GeoIP_country_id_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_addr_v6_gl(gi, addr, &gl);
+}
+
+int GeoIP_country_id_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_addr_gl(gi, addr, &gl);
+}
+int GeoIP_country_id_by_name_v6(GeoIP *gi, const char *host) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_name_v6_gl(gi, host, &gl);
+}
+int GeoIP_country_id_by_name(GeoIP *gi, const char *host) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_name_gl(gi, host, &gl);
+}
+int GeoIP_id_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_addr_v6_gl(gi, addr, &gl);
+}
+int GeoIP_id_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_addr_gl(gi, addr, &gl);
+}
+
+int GeoIP_id_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+int GeoIP_id_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_id_by_ipnum_gl(gi, ipnum, &gl);
+}
+void GeoIP_assign_region_by_inetaddr(GeoIP *gi,
+ unsigned long inetaddr,
+ GeoIPRegion *region) {
+ GeoIPLookup gl;
+ GeoIP_assign_region_by_inetaddr_gl(gi, inetaddr, region, &gl);
+}
+
+void GeoIP_assign_region_by_inetaddr_v6(GeoIP *gi,
+ geoipv6_t inetaddr,
+ GeoIPRegion *region) {
+ GeoIPLookup gl;
+ GeoIP_assign_region_by_inetaddr_v6_gl(gi, inetaddr, region, &gl);
+}
+
+GeoIPRegion *GeoIP_region_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_addr_gl(gi, addr, &gl);
+}
+GeoIPRegion *GeoIP_region_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_addr_v6_gl(gi, addr, &gl);
+}
+
+GeoIPRegion *GeoIP_region_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_name_gl(gi, name, &gl);
+}
+GeoIPRegion *GeoIP_region_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_name_v6_gl(gi, name, &gl);
+}
+
+GeoIPRegion *GeoIP_region_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_ipnum_gl(gi, ipnum, &gl);
+}
+GeoIPRegion *GeoIP_region_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_region_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+
+char **GeoIP_range_by_ip(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_range_by_ip_gl(gi, addr, &gl);
+}
+
+char *GeoIP_name_by_ipnum(GeoIP *gi, unsigned long ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_ipnum_gl(gi, ipnum, &gl);
+}
+char *GeoIP_name_by_ipnum_v6(GeoIP *gi, geoipv6_t ipnum) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_ipnum_v6_gl(gi, ipnum, &gl);
+}
+char *GeoIP_name_by_addr(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_addr_gl(gi, addr, &gl);
+}
+char *GeoIP_name_by_addr_v6(GeoIP *gi, const char *addr) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_addr_v6_gl(gi, addr, &gl);
+}
+
+char *GeoIP_name_by_name(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_name_gl(gi, name, &gl);
+}
+
+char *GeoIP_name_by_name_v6(GeoIP *gi, const char *name) {
+ GeoIPLookup gl;
+ return GeoIP_name_by_name_v6_gl(gi, name, &gl);
+}
diff --git a/libGeoIP/GeoIP_internal.h b/libGeoIP/GeoIP_internal.h
new file mode 100644
index 0000000..2c96587
--- /dev/null
+++ b/libGeoIP/GeoIP_internal.h
@@ -0,0 +1,23 @@
+#ifndef GEOIP_INTERNAL_H
+#define GEOIP_INTERNAL_H
+
+#include "GeoIP.h"
+
+GEOIP_API unsigned int
+_GeoIP_seek_record_gl(GeoIP *gi, unsigned long ipnum, GeoIPLookup *gl);
+GEOIP_API unsigned int
+_GeoIP_seek_record_v6_gl(GeoIP *gi, geoipv6_t ipnum, GeoIPLookup *gl);
+GEOIP_API geoipv6_t _GeoIP_addr_to_num_v6(const char *addr);
+
+GEOIP_API unsigned long _GeoIP_lookupaddress(const char *host);
+GEOIP_API geoipv6_t _GeoIP_lookupaddress_v6(const char *host);
+GEOIP_API int __GEOIP_V6_IS_NULL(geoipv6_t v6);
+
+GEOIP_API void _GeoIP_setup_dbfilename(void);
+GEOIP_API char *_GeoIP_full_path_to(const char *file_name);
+
+/* deprecated */
+GEOIP_API unsigned int _GeoIP_seek_record(GeoIP *gi, unsigned long ipnum);
+GEOIP_API unsigned int _GeoIP_seek_record_v6(GeoIP *gi, geoipv6_t ipnum);
+
+#endif
diff --git a/libGeoIP/Makefile.am b/libGeoIP/Makefile.am
new file mode 100644
index 0000000..f85cd00
--- /dev/null
+++ b/libGeoIP/Makefile.am
@@ -0,0 +1,19 @@
+lib_LTLIBRARIES = libGeoIP.la
+
+EXTRA_DIST = Makefile.vc GeoIP_internal.h pread.c pread.h
+
+AM_CPPFLAGS = -DGEOIPDATADIR=\"$(pkgdatadir)\" -Wall
+
+libGeoIP_la_SOURCES = GeoIP.c GeoIP_deprecated.c GeoIPCity.c regionName.c timeZone.c
+include_HEADERS = GeoIP.h GeoIPCity.h
+
+libGeoIP_la_LDFLAGS = -no-undefined -version-info @GEOIP_VERSION_INFO@
+
+GeoIP.lo GeoIP.o: GeoIP.c GeoIP_deprecated.c GeoIP.h
+
+GeoIPCity.lo GeoIPCity.o: GeoIPCity.c GeoIP.h
+
+regionName.lo regionName.o: regionName.c
+
+timeZone.lo timeZone.o: timeZone.c
+
diff --git a/libGeoIP/Makefile.vc b/libGeoIP/Makefile.vc
new file mode 100644
index 0000000..157e014
--- /dev/null
+++ b/libGeoIP/Makefile.vc
@@ -0,0 +1,47 @@
+#NMAKE makefile for Windows developers.
+##Produces a static library (GeoIP.lib).
+#Produces a DLL (GeoIP.dll) and library (GeoIP.lib).
+
+COMPILER=cl
+
+CFLAGS=-DWIN32 -DGEOIP_EXPORTS -MD -nologo
+
+GEOIPINC = -I..\libGeoIP
+
+CC1 = $(COMPILER) $(CFLAGS) $(GEOIPINC) -DGEOIPDATADIR=\"$(GEOIPDATADIR)\" -DPACKAGE_VERSION=\"1.6.3\"
+
+LINKER=link
+
+LDFLAGS=/DLL /nologo /subsystem:console
+
+LD1 = $(LINKER) $(LDFLAGS)
+
+OBJS=GeoIP.obj GeoIPCity.obj GeoIP_deprecated.obj regionName.obj timeZone.obj pread.obj
+
+EXTRA_LIBS= ws2_32.lib
+
+AR=lib
+
+#GeoIP.lib: GeoIP.obj GeoIPCity.obj regionName.obj md5.obj timeZone.obj
+# $(AR) -nologo $(OBJS) $(EXTRA_LIBS) /OUT:GeoIP.lib
+
+GeoIP.dll GeoIP.lib: $(OBJS)
+ $(LD1) $(OBJS) $(EXTRA_LIBS) /out:GeoIP.dll /implib:GeoIP.lib
+
+GeoIP.obj: GeoIP.c
+ $(CC1) -c GeoIP.c $(GEOIPINC)
+
+GeoIPCity.obj: GeoIPCity.c
+ $(CC1) -c GeoIPCity.c $(GEOIPINC)
+
+GeoIP_deprecated.obj: GeoIP_deprecated.c
+ $(CC1) -c GeoIP_deprecated.c $(GEOIPINC)
+
+regionName.obj: regionName.c
+ $(CC1) -c regionName.c $(GEOIPINC)
+
+timeZone.obj: timeZone.c
+ $(CC1) -c timeZone.c $(GEOIPINC)
+
+pread.obj: pread.c
+ $(CC1) -c pread.c $(GEOIPINC)
diff --git a/libGeoIP/pread.c b/libGeoIP/pread.c
new file mode 100644
index 0000000..ae5f462
--- /dev/null
+++ b/libGeoIP/pread.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <io.h>
+#include <stdio.h>
+#include <windows.h>
+
+#include "pread.h"
+
+static CRITICAL_SECTION preadsc;
+
+/* http://stackoverflow.com/a/2390626/1392778 */
+
+#ifdef _MSC_VER
+#pragma section(".CRT$XCU", read)
+#define INITIALIZER2_(f, p) \
+ static void __cdecl f(void); \
+ __declspec(allocate(".CRT$XCU")) void(__cdecl * f##_)(void) = f; \
+ __pragma(comment(linker, "/include:" p #f "_")) static void __cdecl f(void)
+#ifdef _WIN64
+#define INITIALIZER(f) INITIALIZER2_(f, "")
+#else
+#define INITIALIZER(f) INITIALIZER2_(f, "_")
+#endif
+#elif defined(__GNUC__)
+#define INITIALIZER(f) \
+ static void f(void) __attribute__((constructor)); \
+ static void f(void)
+#endif
+
+#ifdef _WIN64
+int pread(int fd, void *buf, unsigned int nbyte, __int64 offset) {
+ int cc = -1;
+ __int64 prev = (__int64)-1L;
+
+ EnterCriticalSection(&preadsc);
+ prev = _lseeki64(fd, 0L, SEEK_CUR);
+ if (prev == (__int64)-1L) {
+ goto done;
+ }
+ if (_lseeki64(fd, offset, SEEK_SET) != offset) {
+ goto done;
+ }
+ cc = _read(fd, buf, nbyte);
+
+done:
+ if (prev != (__int64)-1L) {
+ (void)_lseeki64(fd, prev, SEEK_SET);
+ }
+ LeaveCriticalSection(&preadsc);
+
+ return cc;
+}
+#else
+int pread(int fd, void *buf, unsigned int nbyte, long offset) {
+ int cc = -1;
+ long prev = -1L;
+
+ EnterCriticalSection(&preadsc);
+ prev = _lseek(fd, 0L, SEEK_CUR);
+ if (prev == -1L) {
+ goto done;
+ }
+ if (_lseek(fd, offset, SEEK_SET) != offset) {
+ goto done;
+ }
+ cc = _read(fd, buf, nbyte);
+
+done:
+ if (prev != -1L) {
+ (void)_lseek(fd, prev, SEEK_SET);
+ }
+ LeaveCriticalSection(&preadsc);
+
+ return cc;
+}
+#endif
+
+static void deinitialize(void) { DeleteCriticalSection(&preadsc); }
+
+INITIALIZER(initialize) {
+ InitializeCriticalSection(&preadsc);
+ atexit(deinitialize);
+}
diff --git a/libGeoIP/pread.h b/libGeoIP/pread.h
new file mode 100644
index 0000000..4e48949
--- /dev/null
+++ b/libGeoIP/pread.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef _WIN64
+typedef __int64 ssize_t;
+
+int pread(int fd, void *buf, unsigned int nbyte, __int64 offset);
+#else
+typedef int ssize_t;
+
+int pread(int fd, void *buf, unsigned int nbyte, long offset);
+#endif
+
+#define HAVE_PREAD
diff --git a/libGeoIP/regionName.c b/libGeoIP/regionName.c
new file mode 100644
index 0000000..60f6260
--- /dev/null
+++ b/libGeoIP/regionName.c
@@ -0,0 +1,10197 @@
+#include "GeoIP.h"
+#include <stdio.h>
+#include <string.h>
+
+static const char *get_region_name_AD(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Encamp";
+ case 4:
+ return "La Massana";
+ case 5:
+ return "Ordino";
+ case 6:
+ return "Sant Julia de Loria";
+ case 7:
+ return "Andorra la Vella";
+ case 8:
+ return "Escaldes-Engordany";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abu Dhabi";
+ case 2:
+ return "Ajman";
+ case 3:
+ return "Dubai";
+ case 4:
+ return "Fujairah";
+ case 5:
+ return "Ras Al Khaimah";
+ case 6:
+ return "Sharjah";
+ case 7:
+ return "Umm Al Quwain";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AF(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Badakhshan";
+ case 2:
+ return "Badghis";
+ case 3:
+ return "Baghlan";
+ case 5:
+ return "Bamian";
+ case 6:
+ return "Farah";
+ case 7:
+ return "Faryab";
+ case 8:
+ return "Ghazni";
+ case 9:
+ return "Ghowr";
+ case 10:
+ return "Helmand";
+ case 11:
+ return "Herat";
+ case 13:
+ return "Kabol";
+ case 14:
+ return "Kapisa";
+ case 17:
+ return "Lowgar";
+ case 18:
+ return "Nangarhar";
+ case 19:
+ return "Nimruz";
+ case 23:
+ return "Kandahar";
+ case 24:
+ return "Kondoz";
+ case 26:
+ return "Takhar";
+ case 27:
+ return "Vardak";
+ case 28:
+ return "Zabol";
+ case 29:
+ return "Paktika";
+ case 30:
+ return "Balkh";
+ case 31:
+ return "Jowzjan";
+ case 32:
+ return "Samangan";
+ case 33:
+ return "Sar-e Pol";
+ case 34:
+ return "Konar";
+ case 35:
+ return "Laghman";
+ case 36:
+ return "Paktia";
+ case 37:
+ return "Khowst";
+ case 38:
+ return "Nurestan";
+ case 39:
+ return "Oruzgan";
+ case 40:
+ return "Parvan";
+ case 41:
+ return "Daykondi";
+ case 42:
+ return "Panjshir";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Barbuda";
+ case 3:
+ return "Saint George";
+ case 4:
+ return "Saint John";
+ case 5:
+ return "Saint Mary";
+ case 6:
+ return "Saint Paul";
+ case 7:
+ return "Saint Peter";
+ case 8:
+ return "Saint Philip";
+ case 9:
+ return "Redonda";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AL(int region_code) {
+ switch (region_code) {
+ case 40:
+ return "Berat";
+ case 41:
+ return "Diber";
+ case 42:
+ return "Durres";
+ case 43:
+ return "Elbasan";
+ case 44:
+ return "Fier";
+ case 45:
+ return "Gjirokaster";
+ case 46:
+ return "Korce";
+ case 47:
+ return "Kukes";
+ case 48:
+ return "Lezhe";
+ case 49:
+ return "Shkoder";
+ case 50:
+ return "Tirane";
+ case 51:
+ return "Vlore";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aragatsotn";
+ case 2:
+ return "Ararat";
+ case 3:
+ return "Armavir";
+ case 4:
+ return "Geghark'unik'";
+ case 5:
+ return "Kotayk'";
+ case 6:
+ return "Lorri";
+ case 7:
+ return "Shirak";
+ case 8:
+ return "Syunik'";
+ case 9:
+ return "Tavush";
+ case 10:
+ return "Vayots' Dzor";
+ case 11:
+ return "Yerevan";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Benguela";
+ case 2:
+ return "Bie";
+ case 3:
+ return "Cabinda";
+ case 4:
+ return "Cuando Cubango";
+ case 5:
+ return "Cuanza Norte";
+ case 6:
+ return "Cuanza Sul";
+ case 7:
+ return "Cunene";
+ case 8:
+ return "Huambo";
+ case 9:
+ return "Huila";
+ case 12:
+ return "Malanje";
+ case 13:
+ return "Namibe";
+ case 14:
+ return "Moxico";
+ case 15:
+ return "Uige";
+ case 16:
+ return "Zaire";
+ case 17:
+ return "Lunda Norte";
+ case 18:
+ return "Lunda Sul";
+ case 19:
+ return "Bengo";
+ case 20:
+ return "Luanda";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Buenos Aires";
+ case 2:
+ return "Catamarca";
+ case 3:
+ return "Chaco";
+ case 4:
+ return "Chubut";
+ case 5:
+ return "Cordoba";
+ case 6:
+ return "Corrientes";
+ case 7:
+ return "Distrito Federal";
+ case 8:
+ return "Entre Rios";
+ case 9:
+ return "Formosa";
+ case 10:
+ return "Jujuy";
+ case 11:
+ return "La Pampa";
+ case 12:
+ return "La Rioja";
+ case 13:
+ return "Mendoza";
+ case 14:
+ return "Misiones";
+ case 15:
+ return "Neuquen";
+ case 16:
+ return "Rio Negro";
+ case 17:
+ return "Salta";
+ case 18:
+ return "San Juan";
+ case 19:
+ return "San Luis";
+ case 20:
+ return "Santa Cruz";
+ case 21:
+ return "Santa Fe";
+ case 22:
+ return "Santiago del Estero";
+ case 23:
+ return "Tierra del Fuego";
+ case 24:
+ return "Tucuman";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AT(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Burgenland";
+ case 2:
+ return "Karnten";
+ case 3:
+ return "Niederosterreich";
+ case 4:
+ return "Oberosterreich";
+ case 5:
+ return "Salzburg";
+ case 6:
+ return "Steiermark";
+ case 7:
+ return "Tirol";
+ case 8:
+ return "Vorarlberg";
+ case 9:
+ return "Wien";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AU(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Australian Capital Territory";
+ case 2:
+ return "New South Wales";
+ case 3:
+ return "Northern Territory";
+ case 4:
+ return "Queensland";
+ case 5:
+ return "South Australia";
+ case 6:
+ return "Tasmania";
+ case 7:
+ return "Victoria";
+ case 8:
+ return "Western Australia";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_AZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abseron";
+ case 2:
+ return "Agcabadi";
+ case 3:
+ return "Agdam";
+ case 4:
+ return "Agdas";
+ case 5:
+ return "Agstafa";
+ case 6:
+ return "Agsu";
+ case 7:
+ return "Ali Bayramli";
+ case 8:
+ return "Astara";
+ case 9:
+ return "Baki";
+ case 10:
+ return "Balakan";
+ case 11:
+ return "Barda";
+ case 12:
+ return "Beylaqan";
+ case 13:
+ return "Bilasuvar";
+ case 14:
+ return "Cabrayil";
+ case 15:
+ return "Calilabad";
+ case 16:
+ return "Daskasan";
+ case 17:
+ return "Davaci";
+ case 18:
+ return "Fuzuli";
+ case 19:
+ return "Gadabay";
+ case 20:
+ return "Ganca";
+ case 21:
+ return "Goranboy";
+ case 22:
+ return "Goycay";
+ case 23:
+ return "Haciqabul";
+ case 24:
+ return "Imisli";
+ case 25:
+ return "Ismayilli";
+ case 26:
+ return "Kalbacar";
+ case 27:
+ return "Kurdamir";
+ case 28:
+ return "Lacin";
+ case 29:
+ return "Lankaran";
+ case 30:
+ return "Lankaran";
+ case 31:
+ return "Lerik";
+ case 32:
+ return "Masalli";
+ case 33:
+ return "Mingacevir";
+ case 34:
+ return "Naftalan";
+ case 35:
+ return "Naxcivan";
+ case 36:
+ return "Neftcala";
+ case 37:
+ return "Oguz";
+ case 38:
+ return "Qabala";
+ case 39:
+ return "Qax";
+ case 40:
+ return "Qazax";
+ case 41:
+ return "Qobustan";
+ case 42:
+ return "Quba";
+ case 43:
+ return "Qubadli";
+ case 44:
+ return "Qusar";
+ case 45:
+ return "Saatli";
+ case 46:
+ return "Sabirabad";
+ case 47:
+ return "Saki";
+ case 48:
+ return "Saki";
+ case 49:
+ return "Salyan";
+ case 50:
+ return "Samaxi";
+ case 51:
+ return "Samkir";
+ case 52:
+ return "Samux";
+ case 53:
+ return "Siyazan";
+ case 54:
+ return "Sumqayit";
+ case 55:
+ return "Susa";
+ case 56:
+ return "Susa";
+ case 57:
+ return "Tartar";
+ case 58:
+ return "Tovuz";
+ case 59:
+ return "Ucar";
+ case 60:
+ return "Xacmaz";
+ case 61:
+ return "Xankandi";
+ case 62:
+ return "Xanlar";
+ case 63:
+ return "Xizi";
+ case 64:
+ return "Xocali";
+ case 65:
+ return "Xocavand";
+ case 66:
+ return "Yardimli";
+ case 67:
+ return "Yevlax";
+ case 68:
+ return "Yevlax";
+ case 69:
+ return "Zangilan";
+ case 70:
+ return "Zaqatala";
+ case 71:
+ return "Zardab";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Federation of Bosnia and Herzegovina";
+ case 3:
+ return "Brcko District";
+ case 2:
+ return "Republika Srpska";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BB(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Christ Church";
+ case 2:
+ return "Saint Andrew";
+ case 3:
+ return "Saint George";
+ case 4:
+ return "Saint James";
+ case 5:
+ return "Saint John";
+ case 6:
+ return "Saint Joseph";
+ case 7:
+ return "Saint Lucy";
+ case 8:
+ return "Saint Michael";
+ case 9:
+ return "Saint Peter";
+ case 10:
+ return "Saint Philip";
+ case 11:
+ return "Saint Thomas";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BD(int region_code) {
+ switch (region_code) {
+ case 81:
+ return "Dhaka";
+ case 82:
+ return "Khulna";
+ case 83:
+ return "Rajshahi";
+ case 84:
+ return "Chittagong";
+ case 85:
+ return "Barisal";
+ case 86:
+ return "Sylhet";
+ case 87:
+ return "Rangpur";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Antwerpen";
+ case 3:
+ return "Hainaut";
+ case 4:
+ return "Liege";
+ case 5:
+ return "Limburg";
+ case 6:
+ return "Luxembourg";
+ case 7:
+ return "Namur";
+ case 8:
+ return "Oost-Vlaanderen";
+ case 9:
+ return "West-Vlaanderen";
+ case 10:
+ return "Brabant Wallon";
+ case 11:
+ return "Brussels Hoofdstedelijk Gewest";
+ case 12:
+ return "Vlaams-Brabant";
+ case 13:
+ return "Flanders";
+ case 14:
+ return "Wallonia";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BF(int region_code) {
+ switch (region_code) {
+ case 15:
+ return "Bam";
+ case 19:
+ return "Boulkiemde";
+ case 20:
+ return "Ganzourgou";
+ case 21:
+ return "Gnagna";
+ case 28:
+ return "Kouritenga";
+ case 33:
+ return "Oudalan";
+ case 34:
+ return "Passore";
+ case 36:
+ return "Sanguie";
+ case 40:
+ return "Soum";
+ case 42:
+ return "Tapoa";
+ case 44:
+ return "Zoundweogo";
+ case 45:
+ return "Bale";
+ case 46:
+ return "Banwa";
+ case 47:
+ return "Bazega";
+ case 48:
+ return "Bougouriba";
+ case 49:
+ return "Boulgou";
+ case 50:
+ return "Gourma";
+ case 51:
+ return "Houet";
+ case 52:
+ return "Ioba";
+ case 53:
+ return "Kadiogo";
+ case 54:
+ return "Kenedougou";
+ case 55:
+ return "Komoe";
+ case 56:
+ return "Komondjari";
+ case 57:
+ return "Kompienga";
+ case 58:
+ return "Kossi";
+ case 59:
+ return "Koulpelogo";
+ case 60:
+ return "Kourweogo";
+ case 61:
+ return "Leraba";
+ case 62:
+ return "Loroum";
+ case 63:
+ return "Mouhoun";
+ case 64:
+ return "Namentenga";
+ case 65:
+ return "Naouri";
+ case 66:
+ return "Nayala";
+ case 67:
+ return "Noumbiel";
+ case 68:
+ return "Oubritenga";
+ case 69:
+ return "Poni";
+ case 70:
+ return "Sanmatenga";
+ case 71:
+ return "Seno";
+ case 72:
+ return "Sissili";
+ case 73:
+ return "Sourou";
+ case 74:
+ return "Tuy";
+ case 75:
+ return "Yagha";
+ case 76:
+ return "Yatenga";
+ case 77:
+ return "Ziro";
+ case 78:
+ return "Zondoma";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BG(int region_code) {
+ switch (region_code) {
+ case 33:
+ return "Mikhaylovgrad";
+ case 38:
+ return "Blagoevgrad";
+ case 39:
+ return "Burgas";
+ case 40:
+ return "Dobrich";
+ case 41:
+ return "Gabrovo";
+ case 42:
+ return "Grad Sofiya";
+ case 43:
+ return "Khaskovo";
+ case 44:
+ return "Kurdzhali";
+ case 45:
+ return "Kyustendil";
+ case 46:
+ return "Lovech";
+ case 47:
+ return "Montana";
+ case 48:
+ return "Pazardzhik";
+ case 49:
+ return "Pernik";
+ case 50:
+ return "Pleven";
+ case 51:
+ return "Plovdiv";
+ case 52:
+ return "Razgrad";
+ case 53:
+ return "Ruse";
+ case 54:
+ return "Shumen";
+ case 55:
+ return "Silistra";
+ case 56:
+ return "Sliven";
+ case 57:
+ return "Smolyan";
+ case 58:
+ return "Sofiya";
+ case 59:
+ return "Stara Zagora";
+ case 60:
+ return "Turgovishte";
+ case 61:
+ return "Varna";
+ case 62:
+ return "Veliko Turnovo";
+ case 63:
+ return "Vidin";
+ case 64:
+ return "Vratsa";
+ case 65:
+ return "Yambol";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Al Hadd";
+ case 2:
+ return "Al Manamah";
+ case 5:
+ return "Jidd Hafs";
+ case 6:
+ return "Sitrah";
+ case 8:
+ return "Al Mintaqah al Gharbiyah";
+ case 9:
+ return "Mintaqat Juzur Hawar";
+ case 10:
+ return "Al Mintaqah ash Shamaliyah";
+ case 11:
+ return "Al Mintaqah al Wusta";
+ case 12:
+ return "Madinat";
+ case 13:
+ return "Ar Rifa";
+ case 14:
+ return "Madinat Hamad";
+ case 15:
+ return "Al Muharraq";
+ case 16:
+ return "Al Asimah";
+ case 17:
+ return "Al Janubiyah";
+ case 18:
+ return "Ash Shamaliyah";
+ case 19:
+ return "Al Wusta";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BI(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Bujumbura";
+ case 9:
+ return "Bubanza";
+ case 10:
+ return "Bururi";
+ case 11:
+ return "Cankuzo";
+ case 12:
+ return "Cibitoke";
+ case 13:
+ return "Gitega";
+ case 14:
+ return "Karuzi";
+ case 15:
+ return "Kayanza";
+ case 16:
+ return "Kirundo";
+ case 17:
+ return "Makamba";
+ case 18:
+ return "Muyinga";
+ case 19:
+ return "Ngozi";
+ case 20:
+ return "Rutana";
+ case 21:
+ return "Ruyigi";
+ case 22:
+ return "Muramvya";
+ case 23:
+ return "Mwaro";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BJ(int region_code) {
+ switch (region_code) {
+ case 7:
+ return "Alibori";
+ case 8:
+ return "Atakora";
+ case 9:
+ return "Atlanyique";
+ case 10:
+ return "Borgou";
+ case 11:
+ return "Collines";
+ case 12:
+ return "Kouffo";
+ case 13:
+ return "Donga";
+ case 14:
+ return "Littoral";
+ case 15:
+ return "Mono";
+ case 16:
+ return "Oueme";
+ case 17:
+ return "Plateau";
+ case 18:
+ return "Zou";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Devonshire";
+ case 2:
+ return "Hamilton";
+ case 3:
+ return "Hamilton";
+ case 4:
+ return "Paget";
+ case 5:
+ return "Pembroke";
+ case 6:
+ return "Saint George";
+ case 7:
+ return "Saint George's";
+ case 8:
+ return "Sandys";
+ case 9:
+ return "Smiths";
+ case 10:
+ return "Southampton";
+ case 11:
+ return "Warwick";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BN(int region_code) {
+ switch (region_code) {
+ case 7:
+ return "Alibori";
+ case 8:
+ return "Belait";
+ case 9:
+ return "Brunei and Muara";
+ case 10:
+ return "Temburong";
+ case 11:
+ return "Collines";
+ case 12:
+ return "Kouffo";
+ case 13:
+ return "Donga";
+ case 14:
+ return "Littoral";
+ case 15:
+ return "Tutong";
+ case 16:
+ return "Oueme";
+ case 17:
+ return "Plateau";
+ case 18:
+ return "Zou";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Chuquisaca";
+ case 2:
+ return "Cochabamba";
+ case 3:
+ return "El Beni";
+ case 4:
+ return "La Paz";
+ case 5:
+ return "Oruro";
+ case 6:
+ return "Pando";
+ case 7:
+ return "Potosi";
+ case 8:
+ return "Santa Cruz";
+ case 9:
+ return "Tarija";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Acre";
+ case 2:
+ return "Alagoas";
+ case 3:
+ return "Amapa";
+ case 4:
+ return "Amazonas";
+ case 5:
+ return "Bahia";
+ case 6:
+ return "Ceara";
+ case 7:
+ return "Distrito Federal";
+ case 8:
+ return "Espirito Santo";
+ case 11:
+ return "Mato Grosso do Sul";
+ case 13:
+ return "Maranhao";
+ case 14:
+ return "Mato Grosso";
+ case 15:
+ return "Minas Gerais";
+ case 16:
+ return "Para";
+ case 17:
+ return "Paraiba";
+ case 18:
+ return "Parana";
+ case 20:
+ return "Piaui";
+ case 21:
+ return "Rio de Janeiro";
+ case 22:
+ return "Rio Grande do Norte";
+ case 23:
+ return "Rio Grande do Sul";
+ case 24:
+ return "Rondonia";
+ case 25:
+ return "Roraima";
+ case 26:
+ return "Santa Catarina";
+ case 27:
+ return "Sao Paulo";
+ case 28:
+ return "Sergipe";
+ case 29:
+ return "Goias";
+ case 30:
+ return "Pernambuco";
+ case 31:
+ return "Tocantins";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BS(int region_code) {
+ switch (region_code) {
+ case 5:
+ return "Bimini";
+ case 6:
+ return "Cat Island";
+ case 10:
+ return "Exuma";
+ case 13:
+ return "Inagua";
+ case 15:
+ return "Long Island";
+ case 16:
+ return "Mayaguana";
+ case 18:
+ return "Ragged Island";
+ case 22:
+ return "Harbour Island";
+ case 23:
+ return "New Providence";
+ case 24:
+ return "Acklins and Crooked Islands";
+ case 25:
+ return "Freeport";
+ case 26:
+ return "Fresh Creek";
+ case 27:
+ return "Governor's Harbour";
+ case 28:
+ return "Green Turtle Cay";
+ case 29:
+ return "High Rock";
+ case 30:
+ return "Kemps Bay";
+ case 31:
+ return "Marsh Harbour";
+ case 32:
+ return "Nichollstown and Berry Islands";
+ case 33:
+ return "Rock Sound";
+ case 34:
+ return "Sandy Point";
+ case 35:
+ return "San Salvador and Rum Cay";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BT(int region_code) {
+ switch (region_code) {
+ case 5:
+ return "Bumthang";
+ case 6:
+ return "Chhukha";
+ case 7:
+ return "Chirang";
+ case 8:
+ return "Daga";
+ case 9:
+ return "Geylegphug";
+ case 10:
+ return "Ha";
+ case 11:
+ return "Lhuntshi";
+ case 12:
+ return "Mongar";
+ case 13:
+ return "Paro";
+ case 14:
+ return "Pemagatsel";
+ case 15:
+ return "Punakha";
+ case 16:
+ return "Samchi";
+ case 17:
+ return "Samdrup";
+ case 18:
+ return "Shemgang";
+ case 19:
+ return "Tashigang";
+ case 20:
+ return "Thimphu";
+ case 21:
+ return "Tongsa";
+ case 22:
+ return "Wangdi Phodrang";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Central";
+ case 3:
+ return "Ghanzi";
+ case 4:
+ return "Kgalagadi";
+ case 5:
+ return "Kgatleng";
+ case 6:
+ return "Kweneng";
+ case 8:
+ return "North-East";
+ case 9:
+ return "South-East";
+ case 10:
+ return "Southern";
+ case 11:
+ return "North-West";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Brestskaya Voblasts'";
+ case 2:
+ return "Homyel'skaya Voblasts'";
+ case 3:
+ return "Hrodzyenskaya Voblasts'";
+ case 4:
+ return "Minsk";
+ case 5:
+ return "Minskaya Voblasts'";
+ case 6:
+ return "Mahilyowskaya Voblasts'";
+ case 7:
+ return "Vitsyebskaya Voblasts'";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_BZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Belize";
+ case 2:
+ return "Cayo";
+ case 3:
+ return "Corozal";
+ case 4:
+ return "Orange Walk";
+ case 5:
+ return "Stann Creek";
+ case 6:
+ return "Toledo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CA(int region_code) {
+ switch (region_code) {
+ case 849:
+ return "Alberta";
+ case 893:
+ return "British Columbia";
+ case 1365:
+ return "Manitoba";
+ case 1408:
+ return "New Brunswick";
+ case 1418:
+ return "Newfoundland";
+ case 1425:
+ return "Nova Scotia";
+ case 1426:
+ return "Northwest Territories";
+ case 1427:
+ return "Nunavut";
+ case 1463:
+ return "Ontario";
+ case 1497:
+ return "Prince Edward Island";
+ case 1538:
+ return "Quebec";
+ case 1632:
+ return "Saskatchewan";
+ case 1899:
+ return "Yukon Territory";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CD(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bandundu";
+ case 2:
+ return "Equateur";
+ case 4:
+ return "Kasai-Oriental";
+ case 5:
+ return "Katanga";
+ case 6:
+ return "Kinshasa";
+ case 8:
+ return "Bas-Congo";
+ case 9:
+ return "Orientale";
+ case 10:
+ return "Maniema";
+ case 11:
+ return "Nord-Kivu";
+ case 12:
+ return "Sud-Kivu";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CF(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bamingui-Bangoran";
+ case 2:
+ return "Basse-Kotto";
+ case 3:
+ return "Haute-Kotto";
+ case 4:
+ return "Mambere-Kadei";
+ case 5:
+ return "Haut-Mbomou";
+ case 6:
+ return "Kemo";
+ case 7:
+ return "Lobaye";
+ case 8:
+ return "Mbomou";
+ case 9:
+ return "Nana-Mambere";
+ case 11:
+ return "Ouaka";
+ case 12:
+ return "Ouham";
+ case 13:
+ return "Ouham-Pende";
+ case 14:
+ return "Cuvette-Ouest";
+ case 15:
+ return "Nana-Grebizi";
+ case 16:
+ return "Sangha-Mbaere";
+ case 17:
+ return "Ombella-Mpoko";
+ case 18:
+ return "Bangui";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bouenza";
+ case 4:
+ return "Kouilou";
+ case 5:
+ return "Lekoumou";
+ case 6:
+ return "Likouala";
+ case 7:
+ return "Niari";
+ case 8:
+ return "Plateaux";
+ case 10:
+ return "Sangha";
+ case 11:
+ return "Pool";
+ case 12:
+ return "Brazzaville";
+ case 13:
+ return "Cuvette";
+ case 14:
+ return "Cuvette-Ouest";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aargau";
+ case 2:
+ return "Ausser-Rhoden";
+ case 3:
+ return "Basel-Landschaft";
+ case 4:
+ return "Basel-Stadt";
+ case 5:
+ return "Bern";
+ case 6:
+ return "Fribourg";
+ case 7:
+ return "Geneve";
+ case 8:
+ return "Glarus";
+ case 9:
+ return "Graubunden";
+ case 10:
+ return "Inner-Rhoden";
+ case 11:
+ return "Luzern";
+ case 12:
+ return "Neuchatel";
+ case 13:
+ return "Nidwalden";
+ case 14:
+ return "Obwalden";
+ case 15:
+ return "Sankt Gallen";
+ case 16:
+ return "Schaffhausen";
+ case 17:
+ return "Schwyz";
+ case 18:
+ return "Solothurn";
+ case 19:
+ return "Thurgau";
+ case 20:
+ return "Ticino";
+ case 21:
+ return "Uri";
+ case 22:
+ return "Valais";
+ case 23:
+ return "Vaud";
+ case 24:
+ return "Zug";
+ case 25:
+ return "Zurich";
+ case 26:
+ return "Jura";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CI(int region_code) {
+ switch (region_code) {
+ case 74:
+ return "Agneby";
+ case 75:
+ return "Bafing";
+ case 76:
+ return "Bas-Sassandra";
+ case 77:
+ return "Denguele";
+ case 78:
+ return "Dix-Huit Montagnes";
+ case 79:
+ return "Fromager";
+ case 80:
+ return "Haut-Sassandra";
+ case 81:
+ return "Lacs";
+ case 82:
+ return "Lagunes";
+ case 83:
+ return "Marahoue";
+ case 84:
+ return "Moyen-Cavally";
+ case 85:
+ return "Moyen-Comoe";
+ case 86:
+ return "N'zi-Comoe";
+ case 87:
+ return "Savanes";
+ case 88:
+ return "Sud-Bandama";
+ case 89:
+ return "Sud-Comoe";
+ case 90:
+ return "Vallee du Bandama";
+ case 91:
+ return "Worodougou";
+ case 92:
+ return "Zanzan";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CL(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Valparaiso";
+ case 2:
+ return "Aisen del General Carlos Ibanez del Campo";
+ case 3:
+ return "Antofagasta";
+ case 4:
+ return "Araucania";
+ case 5:
+ return "Atacama";
+ case 6:
+ return "Bio-Bio";
+ case 7:
+ return "Coquimbo";
+ case 8:
+ return "Libertador General Bernardo O'Higgins";
+ case 9:
+ return "Los Lagos";
+ case 10:
+ return "Magallanes y de la Antartica Chilena";
+ case 11:
+ return "Maule";
+ case 12:
+ return "Region Metropolitana";
+ case 13:
+ return "Tarapaca";
+ case 14:
+ return "Los Lagos";
+ case 15:
+ return "Tarapaca";
+ case 16:
+ return "Arica y Parinacota";
+ case 17:
+ return "Los Rios";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CM(int region_code) {
+ switch (region_code) {
+ case 4:
+ return "Est";
+ case 5:
+ return "Littoral";
+ case 7:
+ return "Nord-Ouest";
+ case 8:
+ return "Ouest";
+ case 9:
+ return "Sud-Ouest";
+ case 10:
+ return "Adamaoua";
+ case 11:
+ return "Centre";
+ case 12:
+ return "Extreme-Nord";
+ case 13:
+ return "Nord";
+ case 14:
+ return "Sud";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Anhui";
+ case 2:
+ return "Zhejiang";
+ case 3:
+ return "Jiangxi";
+ case 4:
+ return "Jiangsu";
+ case 5:
+ return "Jilin";
+ case 6:
+ return "Qinghai";
+ case 7:
+ return "Fujian";
+ case 8:
+ return "Heilongjiang";
+ case 9:
+ return "Henan";
+ case 10:
+ return "Hebei";
+ case 11:
+ return "Hunan";
+ case 12:
+ return "Hubei";
+ case 13:
+ return "Xinjiang";
+ case 14:
+ return "Xizang";
+ case 15:
+ return "Gansu";
+ case 16:
+ return "Guangxi";
+ case 18:
+ return "Guizhou";
+ case 19:
+ return "Liaoning";
+ case 20:
+ return "Nei Mongol";
+ case 21:
+ return "Ningxia";
+ case 22:
+ return "Beijing";
+ case 23:
+ return "Shanghai";
+ case 24:
+ return "Shanxi";
+ case 25:
+ return "Shandong";
+ case 26:
+ return "Shaanxi";
+ case 28:
+ return "Tianjin";
+ case 29:
+ return "Yunnan";
+ case 30:
+ return "Guangdong";
+ case 31:
+ return "Hainan";
+ case 32:
+ return "Sichuan";
+ case 33:
+ return "Chongqing";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Amazonas";
+ case 2:
+ return "Antioquia";
+ case 3:
+ return "Arauca";
+ case 4:
+ return "Atlantico";
+ case 8:
+ return "Caqueta";
+ case 9:
+ return "Cauca";
+ case 10:
+ return "Cesar";
+ case 11:
+ return "Choco";
+ case 12:
+ return "Cordoba";
+ case 14:
+ return "Guaviare";
+ case 15:
+ return "Guainia";
+ case 16:
+ return "Huila";
+ case 17:
+ return "La Guajira";
+ case 19:
+ return "Meta";
+ case 20:
+ return "Narino";
+ case 21:
+ return "Norte de Santander";
+ case 22:
+ return "Putumayo";
+ case 23:
+ return "Quindio";
+ case 24:
+ return "Risaralda";
+ case 25:
+ return "San Andres y Providencia";
+ case 26:
+ return "Santander";
+ case 27:
+ return "Sucre";
+ case 28:
+ return "Tolima";
+ case 29:
+ return "Valle del Cauca";
+ case 30:
+ return "Vaupes";
+ case 31:
+ return "Vichada";
+ case 32:
+ return "Casanare";
+ case 33:
+ return "Cundinamarca";
+ case 34:
+ return "Distrito Especial";
+ case 35:
+ return "Bolivar";
+ case 36:
+ return "Boyaca";
+ case 37:
+ return "Caldas";
+ case 38:
+ return "Magdalena";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Alajuela";
+ case 2:
+ return "Cartago";
+ case 3:
+ return "Guanacaste";
+ case 4:
+ return "Heredia";
+ case 6:
+ return "Limon";
+ case 7:
+ return "Puntarenas";
+ case 8:
+ return "San Jose";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CU(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Pinar del Rio";
+ case 2:
+ return "Ciudad de la Habana";
+ case 3:
+ return "Matanzas";
+ case 4:
+ return "Isla de la Juventud";
+ case 5:
+ return "Camaguey";
+ case 7:
+ return "Ciego de Avila";
+ case 8:
+ return "Cienfuegos";
+ case 9:
+ return "Granma";
+ case 10:
+ return "Guantanamo";
+ case 11:
+ return "La Habana";
+ case 12:
+ return "Holguin";
+ case 13:
+ return "Las Tunas";
+ case 14:
+ return "Sancti Spiritus";
+ case 15:
+ return "Santiago de Cuba";
+ case 16:
+ return "Villa Clara";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CV(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Boa Vista";
+ case 2:
+ return "Brava";
+ case 4:
+ return "Maio";
+ case 5:
+ return "Paul";
+ case 7:
+ return "Ribeira Grande";
+ case 8:
+ return "Sal";
+ case 10:
+ return "Sao Nicolau";
+ case 11:
+ return "Sao Vicente";
+ case 13:
+ return "Mosteiros";
+ case 14:
+ return "Praia";
+ case 15:
+ return "Santa Catarina";
+ case 16:
+ return "Santa Cruz";
+ case 17:
+ return "Sao Domingos";
+ case 18:
+ return "Sao Filipe";
+ case 19:
+ return "Sao Miguel";
+ case 20:
+ return "Tarrafal";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Famagusta";
+ case 2:
+ return "Kyrenia";
+ case 3:
+ return "Larnaca";
+ case 4:
+ return "Nicosia";
+ case 5:
+ return "Limassol";
+ case 6:
+ return "Paphos";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_CZ(int region_code) {
+ switch (region_code) {
+ case 52:
+ return "Hlavni mesto Praha";
+ case 78:
+ return "Jihomoravsky kraj";
+ case 79:
+ return "Jihocesky kraj";
+ case 80:
+ return "Vysocina";
+ case 81:
+ return "Karlovarsky kraj";
+ case 82:
+ return "Kralovehradecky kraj";
+ case 83:
+ return "Liberecky kraj";
+ case 84:
+ return "Olomoucky kraj";
+ case 85:
+ return "Moravskoslezsky kraj";
+ case 86:
+ return "Pardubicky kraj";
+ case 87:
+ return "Plzensky kraj";
+ case 88:
+ return "Stredocesky kraj";
+ case 89:
+ return "Ustecky kraj";
+ case 90:
+ return "Zlinsky kraj";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Baden-Wurttemberg";
+ case 2:
+ return "Bayern";
+ case 3:
+ return "Bremen";
+ case 4:
+ return "Hamburg";
+ case 5:
+ return "Hessen";
+ case 6:
+ return "Niedersachsen";
+ case 7:
+ return "Nordrhein-Westfalen";
+ case 8:
+ return "Rheinland-Pfalz";
+ case 9:
+ return "Saarland";
+ case 10:
+ return "Schleswig-Holstein";
+ case 11:
+ return "Brandenburg";
+ case 12:
+ return "Mecklenburg-Vorpommern";
+ case 13:
+ return "Sachsen";
+ case 14:
+ return "Sachsen-Anhalt";
+ case 15:
+ return "Thuringen";
+ case 16:
+ return "Berlin";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DJ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ali Sabieh";
+ case 4:
+ return "Obock";
+ case 5:
+ return "Tadjoura";
+ case 6:
+ return "Dikhil";
+ case 7:
+ return "Djibouti";
+ case 8:
+ return "Arta";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DK(int region_code) {
+ switch (region_code) {
+ case 17:
+ return "Hovedstaden";
+ case 18:
+ return "Midtjylland";
+ case 19:
+ return "Nordjylland";
+ case 20:
+ return "Sjelland";
+ case 21:
+ return "Syddanmark";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DM(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Saint Andrew";
+ case 3:
+ return "Saint David";
+ case 4:
+ return "Saint George";
+ case 5:
+ return "Saint John";
+ case 6:
+ return "Saint Joseph";
+ case 7:
+ return "Saint Luke";
+ case 8:
+ return "Saint Mark";
+ case 9:
+ return "Saint Patrick";
+ case 10:
+ return "Saint Paul";
+ case 11:
+ return "Saint Peter";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Azua";
+ case 2:
+ return "Baoruco";
+ case 3:
+ return "Barahona";
+ case 4:
+ return "Dajabon";
+ case 5:
+ return "Distrito Nacional";
+ case 6:
+ return "Duarte";
+ case 8:
+ return "Espaillat";
+ case 9:
+ return "Independencia";
+ case 10:
+ return "La Altagracia";
+ case 11:
+ return "Elias Pina";
+ case 12:
+ return "La Romana";
+ case 14:
+ return "Maria Trinidad Sanchez";
+ case 15:
+ return "Monte Cristi";
+ case 16:
+ return "Pedernales";
+ case 17:
+ return "Peravia";
+ case 18:
+ return "Puerto Plata";
+ case 19:
+ return "Salcedo";
+ case 20:
+ return "Samana";
+ case 21:
+ return "Sanchez Ramirez";
+ case 23:
+ return "San Juan";
+ case 24:
+ return "San Pedro De Macoris";
+ case 25:
+ return "Santiago";
+ case 26:
+ return "Santiago Rodriguez";
+ case 27:
+ return "Valverde";
+ case 28:
+ return "El Seibo";
+ case 29:
+ return "Hato Mayor";
+ case 30:
+ return "La Vega";
+ case 31:
+ return "Monsenor Nouel";
+ case 32:
+ return "Monte Plata";
+ case 33:
+ return "San Cristobal";
+ case 34:
+ return "Distrito Nacional";
+ case 35:
+ return "Peravia";
+ case 36:
+ return "San Jose de Ocoa";
+ case 37:
+ return "Santo Domingo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_DZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Alger";
+ case 3:
+ return "Batna";
+ case 4:
+ return "Constantine";
+ case 6:
+ return "Medea";
+ case 7:
+ return "Mostaganem";
+ case 9:
+ return "Oran";
+ case 10:
+ return "Saida";
+ case 12:
+ return "Setif";
+ case 13:
+ return "Tiaret";
+ case 14:
+ return "Tizi Ouzou";
+ case 15:
+ return "Tlemcen";
+ case 18:
+ return "Bejaia";
+ case 19:
+ return "Biskra";
+ case 20:
+ return "Blida";
+ case 21:
+ return "Bouira";
+ case 22:
+ return "Djelfa";
+ case 23:
+ return "Guelma";
+ case 24:
+ return "Jijel";
+ case 25:
+ return "Laghouat";
+ case 26:
+ return "Mascara";
+ case 27:
+ return "M'sila";
+ case 29:
+ return "Oum el Bouaghi";
+ case 30:
+ return "Sidi Bel Abbes";
+ case 31:
+ return "Skikda";
+ case 33:
+ return "Tebessa";
+ case 34:
+ return "Adrar";
+ case 35:
+ return "Ain Defla";
+ case 36:
+ return "Ain Temouchent";
+ case 37:
+ return "Annaba";
+ case 38:
+ return "Bechar";
+ case 39:
+ return "Bordj Bou Arreridj";
+ case 40:
+ return "Boumerdes";
+ case 41:
+ return "Chlef";
+ case 42:
+ return "El Bayadh";
+ case 43:
+ return "El Oued";
+ case 44:
+ return "El Tarf";
+ case 45:
+ return "Ghardaia";
+ case 46:
+ return "Illizi";
+ case 47:
+ return "Khenchela";
+ case 48:
+ return "Mila";
+ case 49:
+ return "Naama";
+ case 50:
+ return "Ouargla";
+ case 51:
+ return "Relizane";
+ case 52:
+ return "Souk Ahras";
+ case 53:
+ return "Tamanghasset";
+ case 54:
+ return "Tindouf";
+ case 55:
+ return "Tipaza";
+ case 56:
+ return "Tissemsilt";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_EC(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Galapagos";
+ case 2:
+ return "Azuay";
+ case 3:
+ return "Bolivar";
+ case 4:
+ return "Canar";
+ case 5:
+ return "Carchi";
+ case 6:
+ return "Chimborazo";
+ case 7:
+ return "Cotopaxi";
+ case 8:
+ return "El Oro";
+ case 9:
+ return "Esmeraldas";
+ case 10:
+ return "Guayas";
+ case 11:
+ return "Imbabura";
+ case 12:
+ return "Loja";
+ case 13:
+ return "Los Rios";
+ case 14:
+ return "Manabi";
+ case 15:
+ return "Morona-Santiago";
+ case 17:
+ return "Pastaza";
+ case 18:
+ return "Pichincha";
+ case 19:
+ return "Tungurahua";
+ case 20:
+ return "Zamora-Chinchipe";
+ case 22:
+ return "Sucumbios";
+ case 23:
+ return "Napo";
+ case 24:
+ return "Orellana";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_EE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Harjumaa";
+ case 2:
+ return "Hiiumaa";
+ case 3:
+ return "Ida-Virumaa";
+ case 4:
+ return "Jarvamaa";
+ case 5:
+ return "Jogevamaa";
+ case 6:
+ return "Kohtla-Jarve";
+ case 7:
+ return "Laanemaa";
+ case 8:
+ return "Laane-Virumaa";
+ case 9:
+ return "Narva";
+ case 10:
+ return "Parnu";
+ case 11:
+ return "Parnumaa";
+ case 12:
+ return "Polvamaa";
+ case 13:
+ return "Raplamaa";
+ case 14:
+ return "Saaremaa";
+ case 15:
+ return "Sillamae";
+ case 16:
+ return "Tallinn";
+ case 17:
+ return "Tartu";
+ case 18:
+ return "Tartumaa";
+ case 19:
+ return "Valgamaa";
+ case 20:
+ return "Viljandimaa";
+ case 21:
+ return "Vorumaa";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_EG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ad Daqahliyah";
+ case 2:
+ return "Al Bahr al Ahmar";
+ case 3:
+ return "Al Buhayrah";
+ case 4:
+ return "Al Fayyum";
+ case 5:
+ return "Al Gharbiyah";
+ case 6:
+ return "Al Iskandariyah";
+ case 7:
+ return "Al Isma'iliyah";
+ case 8:
+ return "Al Jizah";
+ case 9:
+ return "Al Minufiyah";
+ case 10:
+ return "Al Minya";
+ case 11:
+ return "Al Qahirah";
+ case 12:
+ return "Al Qalyubiyah";
+ case 13:
+ return "Al Wadi al Jadid";
+ case 14:
+ return "Ash Sharqiyah";
+ case 15:
+ return "As Suways";
+ case 16:
+ return "Aswan";
+ case 17:
+ return "Asyut";
+ case 18:
+ return "Bani Suwayf";
+ case 19:
+ return "Bur Sa'id";
+ case 20:
+ return "Dumyat";
+ case 21:
+ return "Kafr ash Shaykh";
+ case 22:
+ return "Matruh";
+ case 23:
+ return "Qina";
+ case 24:
+ return "Suhaj";
+ case 26:
+ return "Janub Sina'";
+ case 27:
+ return "Shamal Sina'";
+ case 28:
+ return "Al Uqsur";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ER(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Anseba";
+ case 2:
+ return "Debub";
+ case 3:
+ return "Debubawi K'eyih Bahri";
+ case 4:
+ return "Gash Barka";
+ case 5:
+ return "Ma'akel";
+ case 6:
+ return "Semenawi K'eyih Bahri";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ES(int region_code) {
+ switch (region_code) {
+ case 7:
+ return "Islas Baleares";
+ case 27:
+ return "La Rioja";
+ case 29:
+ return "Madrid";
+ case 31:
+ return "Murcia";
+ case 32:
+ return "Navarra";
+ case 34:
+ return "Asturias";
+ case 39:
+ return "Cantabria";
+ case 51:
+ return "Andalucia";
+ case 52:
+ return "Aragon";
+ case 53:
+ return "Canarias";
+ case 54:
+ return "Castilla-La Mancha";
+ case 55:
+ return "Castilla y Leon";
+ case 56:
+ return "Catalonia";
+ case 57:
+ return "Extremadura";
+ case 58:
+ return "Galicia";
+ case 59:
+ return "Pais Vasco";
+ case 60:
+ return "Comunidad Valenciana";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ET(int region_code) {
+ switch (region_code) {
+ case 44:
+ return "Adis Abeba";
+ case 45:
+ return "Afar";
+ case 46:
+ return "Amara";
+ case 47:
+ return "Binshangul Gumuz";
+ case 48:
+ return "Dire Dawa";
+ case 49:
+ return "Gambela Hizboch";
+ case 50:
+ return "Hareri Hizb";
+ case 51:
+ return "Oromiya";
+ case 52:
+ return "Sumale";
+ case 53:
+ return "Tigray";
+ case 54:
+ return "YeDebub Biheroch Bihereseboch na Hizboch";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_FI(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aland";
+ case 6:
+ return "Lapland";
+ case 8:
+ return "Oulu";
+ case 13:
+ return "Southern Finland";
+ case 14:
+ return "Eastern Finland";
+ case 15:
+ return "Western Finland";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_FJ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Central";
+ case 2:
+ return "Eastern";
+ case 3:
+ return "Northern";
+ case 4:
+ return "Rotuma";
+ case 5:
+ return "Western";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_FM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Kosrae";
+ case 2:
+ return "Pohnpei";
+ case 3:
+ return "Chuuk";
+ case 4:
+ return "Yap";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_FR(int region_code) {
+ switch (region_code) {
+ case 97:
+ return "Aquitaine";
+ case 98:
+ return "Auvergne";
+ case 99:
+ return "Basse-Normandie";
+ case 832:
+ return "Bourgogne";
+ case 833:
+ return "Bretagne";
+ case 834:
+ return "Centre";
+ case 835:
+ return "Champagne-Ardenne";
+ case 836:
+ return "Corse";
+ case 837:
+ return "Franche-Comte";
+ case 838:
+ return "Haute-Normandie";
+ case 839:
+ return "Ile-de-France";
+ case 840:
+ return "Languedoc-Roussillon";
+ case 875:
+ return "Limousin";
+ case 876:
+ return "Lorraine";
+ case 877:
+ return "Midi-Pyrenees";
+ case 878:
+ return "Nord-Pas-de-Calais";
+ case 879:
+ return "Pays de la Loire";
+ case 880:
+ return "Picardie";
+ case 881:
+ return "Poitou-Charentes";
+ case 882:
+ return "Provence-Alpes-Cote d'Azur";
+ case 883:
+ return "Rhone-Alpes";
+ case 918:
+ return "Alsace";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Estuaire";
+ case 2:
+ return "Haut-Ogooue";
+ case 3:
+ return "Moyen-Ogooue";
+ case 4:
+ return "Ngounie";
+ case 5:
+ return "Nyanga";
+ case 6:
+ return "Ogooue-Ivindo";
+ case 7:
+ return "Ogooue-Lolo";
+ case 8:
+ return "Ogooue-Maritime";
+ case 9:
+ return "Woleu-Ntem";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GB(int region_code) {
+ switch (region_code) {
+ case 832:
+ return "Barking and Dagenham";
+ case 833:
+ return "Barnet";
+ case 834:
+ return "Barnsley";
+ case 835:
+ return "Bath and North East Somerset";
+ case 836:
+ return "Bedfordshire";
+ case 837:
+ return "Bexley";
+ case 838:
+ return "Birmingham";
+ case 839:
+ return "Blackburn with Darwen";
+ case 840:
+ return "Blackpool";
+ case 875:
+ return "Bolton";
+ case 876:
+ return "Bournemouth";
+ case 877:
+ return "Bracknell Forest";
+ case 878:
+ return "Bradford";
+ case 879:
+ return "Brent";
+ case 880:
+ return "Brighton and Hove";
+ case 881:
+ return "Bristol, City of";
+ case 882:
+ return "Bromley";
+ case 883:
+ return "Buckinghamshire";
+ case 918:
+ return "Bury";
+ case 919:
+ return "Calderdale";
+ case 920:
+ return "Cambridgeshire";
+ case 921:
+ return "Camden";
+ case 922:
+ return "Cheshire";
+ case 923:
+ return "Cornwall";
+ case 924:
+ return "Coventry";
+ case 925:
+ return "Croydon";
+ case 926:
+ return "Cumbria";
+ case 961:
+ return "Darlington";
+ case 962:
+ return "Derby";
+ case 963:
+ return "Derbyshire";
+ case 964:
+ return "Devon";
+ case 965:
+ return "Doncaster";
+ case 966:
+ return "Dorset";
+ case 967:
+ return "Dudley";
+ case 968:
+ return "Durham";
+ case 969:
+ return "Ealing";
+ case 1004:
+ return "East Riding of Yorkshire";
+ case 1005:
+ return "East Sussex";
+ case 1006:
+ return "Enfield";
+ case 1007:
+ return "Essex";
+ case 1008:
+ return "Gateshead";
+ case 1009:
+ return "Gloucestershire";
+ case 1010:
+ return "Greenwich";
+ case 1011:
+ return "Hackney";
+ case 1012:
+ return "Halton";
+ case 1047:
+ return "Hammersmith and Fulham";
+ case 1048:
+ return "Hampshire";
+ case 1049:
+ return "Haringey";
+ case 1050:
+ return "Harrow";
+ case 1051:
+ return "Hartlepool";
+ case 1052:
+ return "Havering";
+ case 1053:
+ return "Herefordshire";
+ case 1054:
+ return "Hertford";
+ case 1055:
+ return "Hillingdon";
+ case 1090:
+ return "Hounslow";
+ case 1091:
+ return "Isle of Wight";
+ case 1092:
+ return "Islington";
+ case 1093:
+ return "Kensington and Chelsea";
+ case 1094:
+ return "Kent";
+ case 1095:
+ return "Kingston upon Hull, City of";
+ case 1096:
+ return "Kingston upon Thames";
+ case 1097:
+ return "Kirklees";
+ case 1098:
+ return "Knowsley";
+ case 1133:
+ return "Lambeth";
+ case 1134:
+ return "Lancashire";
+ case 1135:
+ return "Leeds";
+ case 1136:
+ return "Leicester";
+ case 1137:
+ return "Leicestershire";
+ case 1138:
+ return "Lewisham";
+ case 1139:
+ return "Lincolnshire";
+ case 1140:
+ return "Liverpool";
+ case 1141:
+ return "London, City of";
+ case 1176:
+ return "Luton";
+ case 1177:
+ return "Manchester";
+ case 1178:
+ return "Medway";
+ case 1179:
+ return "Merton";
+ case 1180:
+ return "Middlesbrough";
+ case 1181:
+ return "Milton Keynes";
+ case 1182:
+ return "Newcastle upon Tyne";
+ case 1183:
+ return "Newham";
+ case 1184:
+ return "Norfolk";
+ case 1219:
+ return "Northamptonshire";
+ case 1220:
+ return "North East Lincolnshire";
+ case 1221:
+ return "North Lincolnshire";
+ case 1222:
+ return "North Somerset";
+ case 1223:
+ return "North Tyneside";
+ case 1224:
+ return "Northumberland";
+ case 1225:
+ return "North Yorkshire";
+ case 1226:
+ return "Nottingham";
+ case 1227:
+ return "Nottinghamshire";
+ case 1262:
+ return "Oldham";
+ case 1263:
+ return "Oxfordshire";
+ case 1264:
+ return "Peterborough";
+ case 1265:
+ return "Plymouth";
+ case 1266:
+ return "Poole";
+ case 1267:
+ return "Portsmouth";
+ case 1268:
+ return "Reading";
+ case 1269:
+ return "Redbridge";
+ case 1270:
+ return "Redcar and Cleveland";
+ case 1305:
+ return "Richmond upon Thames";
+ case 1306:
+ return "Rochdale";
+ case 1307:
+ return "Rotherham";
+ case 1308:
+ return "Rutland";
+ case 1309:
+ return "Salford";
+ case 1310:
+ return "Shropshire";
+ case 1311:
+ return "Sandwell";
+ case 1312:
+ return "Sefton";
+ case 1313:
+ return "Sheffield";
+ case 1348:
+ return "Slough";
+ case 1349:
+ return "Solihull";
+ case 1350:
+ return "Somerset";
+ case 1351:
+ return "Southampton";
+ case 1352:
+ return "Southend-on-Sea";
+ case 1353:
+ return "South Gloucestershire";
+ case 1354:
+ return "South Tyneside";
+ case 1355:
+ return "Southwark";
+ case 1356:
+ return "Staffordshire";
+ case 1391:
+ return "St. Helens";
+ case 1392:
+ return "Stockport";
+ case 1393:
+ return "Stockton-on-Tees";
+ case 1394:
+ return "Stoke-on-Trent";
+ case 1395:
+ return "Suffolk";
+ case 1396:
+ return "Sunderland";
+ case 1397:
+ return "Surrey";
+ case 1398:
+ return "Sutton";
+ case 1399:
+ return "Swindon";
+ case 1434:
+ return "Tameside";
+ case 1435:
+ return "Telford and Wrekin";
+ case 1436:
+ return "Thurrock";
+ case 1437:
+ return "Torbay";
+ case 1438:
+ return "Tower Hamlets";
+ case 1439:
+ return "Trafford";
+ case 1440:
+ return "Wakefield";
+ case 1441:
+ return "Walsall";
+ case 1442:
+ return "Waltham Forest";
+ case 1477:
+ return "Wandsworth";
+ case 1478:
+ return "Warrington";
+ case 1479:
+ return "Warwickshire";
+ case 1480:
+ return "West Berkshire";
+ case 1481:
+ return "Westminster";
+ case 1482:
+ return "West Sussex";
+ case 1483:
+ return "Wigan";
+ case 1484:
+ return "Wiltshire";
+ case 1485:
+ return "Windsor and Maidenhead";
+ case 1520:
+ return "Wirral";
+ case 1521:
+ return "Wokingham";
+ case 1522:
+ return "Wolverhampton";
+ case 1523:
+ return "Worcestershire";
+ case 1524:
+ return "York";
+ case 1525:
+ return "Antrim";
+ case 1526:
+ return "Ards";
+ case 1527:
+ return "Armagh";
+ case 1528:
+ return "Ballymena";
+ case 1563:
+ return "Ballymoney";
+ case 1564:
+ return "Banbridge";
+ case 1565:
+ return "Belfast";
+ case 1566:
+ return "Carrickfergus";
+ case 1567:
+ return "Castlereagh";
+ case 1568:
+ return "Coleraine";
+ case 1569:
+ return "Cookstown";
+ case 1570:
+ return "Craigavon";
+ case 1571:
+ return "Down";
+ case 1606:
+ return "Dungannon";
+ case 1607:
+ return "Fermanagh";
+ case 1608:
+ return "Larne";
+ case 1609:
+ return "Limavady";
+ case 1610:
+ return "Lisburn";
+ case 1611:
+ return "Derry";
+ case 1612:
+ return "Magherafelt";
+ case 1613:
+ return "Moyle";
+ case 1614:
+ return "Newry and Mourne";
+ case 1649:
+ return "Newtownabbey";
+ case 1650:
+ return "North Down";
+ case 1651:
+ return "Omagh";
+ case 1652:
+ return "Strabane";
+ case 1653:
+ return "Aberdeen City";
+ case 1654:
+ return "Aberdeenshire";
+ case 1655:
+ return "Angus";
+ case 1656:
+ return "Argyll and Bute";
+ case 1657:
+ return "Scottish Borders, The";
+ case 1692:
+ return "Clackmannanshire";
+ case 1693:
+ return "Dumfries and Galloway";
+ case 1694:
+ return "Dundee City";
+ case 1695:
+ return "East Ayrshire";
+ case 1696:
+ return "East Dunbartonshire";
+ case 1697:
+ return "East Lothian";
+ case 1698:
+ return "East Renfrewshire";
+ case 1699:
+ return "Edinburgh, City of";
+ case 1700:
+ return "Falkirk";
+ case 1735:
+ return "Fife";
+ case 1736:
+ return "Glasgow City";
+ case 1737:
+ return "Highland";
+ case 1738:
+ return "Inverclyde";
+ case 1739:
+ return "Midlothian";
+ case 1740:
+ return "Moray";
+ case 1741:
+ return "North Ayrshire";
+ case 1742:
+ return "North Lanarkshire";
+ case 1743:
+ return "Orkney";
+ case 1778:
+ return "Perth and Kinross";
+ case 1779:
+ return "Renfrewshire";
+ case 1780:
+ return "Shetland Islands";
+ case 1781:
+ return "South Ayrshire";
+ case 1782:
+ return "South Lanarkshire";
+ case 1783:
+ return "Stirling";
+ case 1784:
+ return "West Dunbartonshire";
+ case 1785:
+ return "Eilean Siar";
+ case 1786:
+ return "West Lothian";
+ case 1821:
+ return "Isle of Anglesey";
+ case 1822:
+ return "Blaenau Gwent";
+ case 1823:
+ return "Bridgend";
+ case 1824:
+ return "Caerphilly";
+ case 1825:
+ return "Cardiff";
+ case 1826:
+ return "Ceredigion";
+ case 1827:
+ return "Carmarthenshire";
+ case 1828:
+ return "Conwy";
+ case 1829:
+ return "Denbighshire";
+ case 1864:
+ return "Flintshire";
+ case 1865:
+ return "Gwynedd";
+ case 1866:
+ return "Merthyr Tydfil";
+ case 1867:
+ return "Monmouthshire";
+ case 1868:
+ return "Neath Port Talbot";
+ case 1869:
+ return "Newport";
+ case 1870:
+ return "Pembrokeshire";
+ case 1871:
+ return "Powys";
+ case 1872:
+ return "Rhondda Cynon Taff";
+ case 1907:
+ return "Swansea";
+ case 1908:
+ return "Torfaen";
+ case 1909:
+ return "Vale of Glamorgan, The";
+ case 1910:
+ return "Wrexham";
+ case 1911:
+ return "Bedfordshire";
+ case 1912:
+ return "Central Bedfordshire";
+ case 1913:
+ return "Cheshire East";
+ case 1914:
+ return "Cheshire West and Chester";
+ case 1915:
+ return "Isles of Scilly";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GD(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Saint Andrew";
+ case 2:
+ return "Saint David";
+ case 3:
+ return "Saint George";
+ case 4:
+ return "Saint John";
+ case 5:
+ return "Saint Mark";
+ case 6:
+ return "Saint Patrick";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abashis Raioni";
+ case 2:
+ return "Abkhazia";
+ case 3:
+ return "Adigenis Raioni";
+ case 4:
+ return "Ajaria";
+ case 5:
+ return "Akhalgoris Raioni";
+ case 6:
+ return "Akhalk'alak'is Raioni";
+ case 7:
+ return "Akhalts'ikhis Raioni";
+ case 8:
+ return "Akhmetis Raioni";
+ case 9:
+ return "Ambrolauris Raioni";
+ case 10:
+ return "Aspindzis Raioni";
+ case 11:
+ return "Baghdat'is Raioni";
+ case 12:
+ return "Bolnisis Raioni";
+ case 13:
+ return "Borjomis Raioni";
+ case 14:
+ return "Chiat'ura";
+ case 15:
+ return "Ch'khorotsqus Raioni";
+ case 16:
+ return "Ch'okhatauris Raioni";
+ case 17:
+ return "Dedop'listsqaros Raioni";
+ case 18:
+ return "Dmanisis Raioni";
+ case 19:
+ return "Dushet'is Raioni";
+ case 20:
+ return "Gardabanis Raioni";
+ case 21:
+ return "Gori";
+ case 22:
+ return "Goris Raioni";
+ case 23:
+ return "Gurjaanis Raioni";
+ case 24:
+ return "Javis Raioni";
+ case 25:
+ return "K'arelis Raioni";
+ case 26:
+ return "Kaspis Raioni";
+ case 27:
+ return "Kharagaulis Raioni";
+ case 28:
+ return "Khashuris Raioni";
+ case 29:
+ return "Khobis Raioni";
+ case 30:
+ return "Khonis Raioni";
+ case 31:
+ return "K'ut'aisi";
+ case 32:
+ return "Lagodekhis Raioni";
+ case 33:
+ return "Lanch'khut'is Raioni";
+ case 34:
+ return "Lentekhis Raioni";
+ case 35:
+ return "Marneulis Raioni";
+ case 36:
+ return "Martvilis Raioni";
+ case 37:
+ return "Mestiis Raioni";
+ case 38:
+ return "Mts'khet'is Raioni";
+ case 39:
+ return "Ninotsmindis Raioni";
+ case 40:
+ return "Onis Raioni";
+ case 41:
+ return "Ozurget'is Raioni";
+ case 42:
+ return "P'ot'i";
+ case 43:
+ return "Qazbegis Raioni";
+ case 44:
+ return "Qvarlis Raioni";
+ case 45:
+ return "Rust'avi";
+ case 46:
+ return "Sach'kheris Raioni";
+ case 47:
+ return "Sagarejos Raioni";
+ case 48:
+ return "Samtrediis Raioni";
+ case 49:
+ return "Senakis Raioni";
+ case 50:
+ return "Sighnaghis Raioni";
+ case 51:
+ return "T'bilisi";
+ case 52:
+ return "T'elavis Raioni";
+ case 53:
+ return "T'erjolis Raioni";
+ case 54:
+ return "T'et'ritsqaros Raioni";
+ case 55:
+ return "T'ianet'is Raioni";
+ case 56:
+ return "Tqibuli";
+ case 57:
+ return "Ts'ageris Raioni";
+ case 58:
+ return "Tsalenjikhis Raioni";
+ case 59:
+ return "Tsalkis Raioni";
+ case 60:
+ return "Tsqaltubo";
+ case 61:
+ return "Vanis Raioni";
+ case 62:
+ return "Zestap'onis Raioni";
+ case 63:
+ return "Zugdidi";
+ case 64:
+ return "Zugdidis Raioni";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Greater Accra";
+ case 2:
+ return "Ashanti";
+ case 3:
+ return "Brong-Ahafo";
+ case 4:
+ return "Central";
+ case 5:
+ return "Eastern";
+ case 6:
+ return "Northern";
+ case 8:
+ return "Volta";
+ case 9:
+ return "Western";
+ case 10:
+ return "Upper East";
+ case 11:
+ return "Upper West";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GL(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Nordgronland";
+ case 2:
+ return "Ostgronland";
+ case 3:
+ return "Vestgronland";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Banjul";
+ case 2:
+ return "Lower River";
+ case 3:
+ return "Central River";
+ case 4:
+ return "Upper River";
+ case 5:
+ return "Western";
+ case 7:
+ return "North Bank";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Beyla";
+ case 2:
+ return "Boffa";
+ case 3:
+ return "Boke";
+ case 4:
+ return "Conakry";
+ case 5:
+ return "Dabola";
+ case 6:
+ return "Dalaba";
+ case 7:
+ return "Dinguiraye";
+ case 9:
+ return "Faranah";
+ case 10:
+ return "Forecariah";
+ case 11:
+ return "Fria";
+ case 12:
+ return "Gaoual";
+ case 13:
+ return "Gueckedou";
+ case 15:
+ return "Kerouane";
+ case 16:
+ return "Kindia";
+ case 17:
+ return "Kissidougou";
+ case 18:
+ return "Koundara";
+ case 19:
+ return "Kouroussa";
+ case 21:
+ return "Macenta";
+ case 22:
+ return "Mali";
+ case 23:
+ return "Mamou";
+ case 25:
+ return "Pita";
+ case 27:
+ return "Telimele";
+ case 28:
+ return "Tougue";
+ case 29:
+ return "Yomou";
+ case 30:
+ return "Coyah";
+ case 31:
+ return "Dubreka";
+ case 32:
+ return "Kankan";
+ case 33:
+ return "Koubia";
+ case 34:
+ return "Labe";
+ case 35:
+ return "Lelouma";
+ case 36:
+ return "Lola";
+ case 37:
+ return "Mandiana";
+ case 38:
+ return "Nzerekore";
+ case 39:
+ return "Siguiri";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GQ(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Annobon";
+ case 4:
+ return "Bioko Norte";
+ case 5:
+ return "Bioko Sur";
+ case 6:
+ return "Centro Sur";
+ case 7:
+ return "Kie-Ntem";
+ case 8:
+ return "Litoral";
+ case 9:
+ return "Wele-Nzas";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Evros";
+ case 2:
+ return "Rodhopi";
+ case 3:
+ return "Xanthi";
+ case 4:
+ return "Drama";
+ case 5:
+ return "Serrai";
+ case 6:
+ return "Kilkis";
+ case 7:
+ return "Pella";
+ case 8:
+ return "Florina";
+ case 9:
+ return "Kastoria";
+ case 10:
+ return "Grevena";
+ case 11:
+ return "Kozani";
+ case 12:
+ return "Imathia";
+ case 13:
+ return "Thessaloniki";
+ case 14:
+ return "Kavala";
+ case 15:
+ return "Khalkidhiki";
+ case 16:
+ return "Pieria";
+ case 17:
+ return "Ioannina";
+ case 18:
+ return "Thesprotia";
+ case 19:
+ return "Preveza";
+ case 20:
+ return "Arta";
+ case 21:
+ return "Larisa";
+ case 22:
+ return "Trikala";
+ case 23:
+ return "Kardhitsa";
+ case 24:
+ return "Magnisia";
+ case 25:
+ return "Kerkira";
+ case 26:
+ return "Levkas";
+ case 27:
+ return "Kefallinia";
+ case 28:
+ return "Zakinthos";
+ case 29:
+ return "Fthiotis";
+ case 30:
+ return "Evritania";
+ case 31:
+ return "Aitolia kai Akarnania";
+ case 32:
+ return "Fokis";
+ case 33:
+ return "Voiotia";
+ case 34:
+ return "Evvoia";
+ case 35:
+ return "Attiki";
+ case 36:
+ return "Argolis";
+ case 37:
+ return "Korinthia";
+ case 38:
+ return "Akhaia";
+ case 39:
+ return "Ilia";
+ case 40:
+ return "Messinia";
+ case 41:
+ return "Arkadhia";
+ case 42:
+ return "Lakonia";
+ case 43:
+ return "Khania";
+ case 44:
+ return "Rethimni";
+ case 45:
+ return "Iraklion";
+ case 46:
+ return "Lasithi";
+ case 47:
+ return "Dhodhekanisos";
+ case 48:
+ return "Samos";
+ case 49:
+ return "Kikladhes";
+ case 50:
+ return "Khios";
+ case 51:
+ return "Lesvos";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GT(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Alta Verapaz";
+ case 2:
+ return "Baja Verapaz";
+ case 3:
+ return "Chimaltenango";
+ case 4:
+ return "Chiquimula";
+ case 5:
+ return "El Progreso";
+ case 6:
+ return "Escuintla";
+ case 7:
+ return "Guatemala";
+ case 8:
+ return "Huehuetenango";
+ case 9:
+ return "Izabal";
+ case 10:
+ return "Jalapa";
+ case 11:
+ return "Jutiapa";
+ case 12:
+ return "Peten";
+ case 13:
+ return "Quetzaltenango";
+ case 14:
+ return "Quiche";
+ case 15:
+ return "Retalhuleu";
+ case 16:
+ return "Sacatepequez";
+ case 17:
+ return "San Marcos";
+ case 18:
+ return "Santa Rosa";
+ case 19:
+ return "Solola";
+ case 20:
+ return "Suchitepequez";
+ case 21:
+ return "Totonicapan";
+ case 22:
+ return "Zacapa";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bafata";
+ case 2:
+ return "Quinara";
+ case 4:
+ return "Oio";
+ case 5:
+ return "Bolama";
+ case 6:
+ return "Cacheu";
+ case 7:
+ return "Tombali";
+ case 10:
+ return "Gabu";
+ case 11:
+ return "Bissau";
+ case 12:
+ return "Biombo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_GY(int region_code) {
+ switch (region_code) {
+ case 10:
+ return "Barima-Waini";
+ case 11:
+ return "Cuyuni-Mazaruni";
+ case 12:
+ return "Demerara-Mahaica";
+ case 13:
+ return "East Berbice-Corentyne";
+ case 14:
+ return "Essequibo Islands-West Demerara";
+ case 15:
+ return "Mahaica-Berbice";
+ case 16:
+ return "Pomeroon-Supenaam";
+ case 17:
+ return "Potaro-Siparuni";
+ case 18:
+ return "Upper Demerara-Berbice";
+ case 19:
+ return "Upper Takutu-Upper Essequibo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_HN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Atlantida";
+ case 2:
+ return "Choluteca";
+ case 3:
+ return "Colon";
+ case 4:
+ return "Comayagua";
+ case 5:
+ return "Copan";
+ case 6:
+ return "Cortes";
+ case 7:
+ return "El Paraiso";
+ case 8:
+ return "Francisco Morazan";
+ case 9:
+ return "Gracias a Dios";
+ case 10:
+ return "Intibuca";
+ case 11:
+ return "Islas de la Bahia";
+ case 12:
+ return "La Paz";
+ case 13:
+ return "Lempira";
+ case 14:
+ return "Ocotepeque";
+ case 15:
+ return "Olancho";
+ case 16:
+ return "Santa Barbara";
+ case 17:
+ return "Valle";
+ case 18:
+ return "Yoro";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_HR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bjelovarsko-Bilogorska";
+ case 2:
+ return "Brodsko-Posavska";
+ case 3:
+ return "Dubrovacko-Neretvanska";
+ case 4:
+ return "Istarska";
+ case 5:
+ return "Karlovacka";
+ case 6:
+ return "Koprivnicko-Krizevacka";
+ case 7:
+ return "Krapinsko-Zagorska";
+ case 8:
+ return "Licko-Senjska";
+ case 9:
+ return "Medimurska";
+ case 10:
+ return "Osjecko-Baranjska";
+ case 11:
+ return "Pozesko-Slavonska";
+ case 12:
+ return "Primorsko-Goranska";
+ case 13:
+ return "Sibensko-Kninska";
+ case 14:
+ return "Sisacko-Moslavacka";
+ case 15:
+ return "Splitsko-Dalmatinska";
+ case 16:
+ return "Varazdinska";
+ case 17:
+ return "Viroviticko-Podravska";
+ case 18:
+ return "Vukovarsko-Srijemska";
+ case 19:
+ return "Zadarska";
+ case 20:
+ return "Zagrebacka";
+ case 21:
+ return "Grad Zagreb";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_HT(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Nord-Ouest";
+ case 6:
+ return "Artibonite";
+ case 7:
+ return "Centre";
+ case 9:
+ return "Nord";
+ case 10:
+ return "Nord-Est";
+ case 11:
+ return "Ouest";
+ case 12:
+ return "Sud";
+ case 13:
+ return "Sud-Est";
+ case 14:
+ return "Grand' Anse";
+ case 15:
+ return "Nippes";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_HU(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bacs-Kiskun";
+ case 2:
+ return "Baranya";
+ case 3:
+ return "Bekes";
+ case 4:
+ return "Borsod-Abauj-Zemplen";
+ case 5:
+ return "Budapest";
+ case 6:
+ return "Csongrad";
+ case 7:
+ return "Debrecen";
+ case 8:
+ return "Fejer";
+ case 9:
+ return "Gyor-Moson-Sopron";
+ case 10:
+ return "Hajdu-Bihar";
+ case 11:
+ return "Heves";
+ case 12:
+ return "Komarom-Esztergom";
+ case 13:
+ return "Miskolc";
+ case 14:
+ return "Nograd";
+ case 15:
+ return "Pecs";
+ case 16:
+ return "Pest";
+ case 17:
+ return "Somogy";
+ case 18:
+ return "Szabolcs-Szatmar-Bereg";
+ case 19:
+ return "Szeged";
+ case 20:
+ return "Jasz-Nagykun-Szolnok";
+ case 21:
+ return "Tolna";
+ case 22:
+ return "Vas";
+ case 23:
+ return "Veszprem";
+ case 24:
+ return "Zala";
+ case 25:
+ return "Gyor";
+ case 26:
+ return "Bekescsaba";
+ case 27:
+ return "Dunaujvaros";
+ case 28:
+ return "Eger";
+ case 29:
+ return "Hodmezovasarhely";
+ case 30:
+ return "Kaposvar";
+ case 31:
+ return "Kecskemet";
+ case 32:
+ return "Nagykanizsa";
+ case 33:
+ return "Nyiregyhaza";
+ case 34:
+ return "Sopron";
+ case 35:
+ return "Szekesfehervar";
+ case 36:
+ return "Szolnok";
+ case 37:
+ return "Szombathely";
+ case 38:
+ return "Tatabanya";
+ case 39:
+ return "Veszprem";
+ case 40:
+ return "Zalaegerszeg";
+ case 41:
+ return "Salgotarjan";
+ case 42:
+ return "Szekszard";
+ case 43:
+ return "Erd";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ID(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aceh";
+ case 2:
+ return "Bali";
+ case 3:
+ return "Bengkulu";
+ case 4:
+ return "Jakarta Raya";
+ case 5:
+ return "Jambi";
+ case 7:
+ return "Jawa Tengah";
+ case 8:
+ return "Jawa Timur";
+ case 10:
+ return "Yogyakarta";
+ case 11:
+ return "Kalimantan Barat";
+ case 12:
+ return "Kalimantan Selatan";
+ case 13:
+ return "Kalimantan Tengah";
+ case 14:
+ return "Kalimantan Timur";
+ case 15:
+ return "Lampung";
+ case 17:
+ return "Nusa Tenggara Barat";
+ case 18:
+ return "Nusa Tenggara Timur";
+ case 21:
+ return "Sulawesi Tengah";
+ case 22:
+ return "Sulawesi Tenggara";
+ case 24:
+ return "Sumatera Barat";
+ case 26:
+ return "Sumatera Utara";
+ case 28:
+ return "Maluku";
+ case 29:
+ return "Maluku Utara";
+ case 30:
+ return "Jawa Barat";
+ case 31:
+ return "Sulawesi Utara";
+ case 32:
+ return "Sumatera Selatan";
+ case 33:
+ return "Banten";
+ case 34:
+ return "Gorontalo";
+ case 35:
+ return "Kepulauan Bangka Belitung";
+ case 36:
+ return "Papua";
+ case 37:
+ return "Riau";
+ case 38:
+ return "Sulawesi Selatan";
+ case 39:
+ return "Irian Jaya Barat";
+ case 40:
+ return "Kepulauan Riau";
+ case 41:
+ return "Sulawesi Barat";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Carlow";
+ case 2:
+ return "Cavan";
+ case 3:
+ return "Clare";
+ case 4:
+ return "Cork";
+ case 6:
+ return "Donegal";
+ case 7:
+ return "Dublin";
+ case 10:
+ return "Galway";
+ case 11:
+ return "Kerry";
+ case 12:
+ return "Kildare";
+ case 13:
+ return "Kilkenny";
+ case 14:
+ return "Leitrim";
+ case 15:
+ return "Laois";
+ case 16:
+ return "Limerick";
+ case 18:
+ return "Longford";
+ case 19:
+ return "Louth";
+ case 20:
+ return "Mayo";
+ case 21:
+ return "Meath";
+ case 22:
+ return "Monaghan";
+ case 23:
+ return "Offaly";
+ case 24:
+ return "Roscommon";
+ case 25:
+ return "Sligo";
+ case 26:
+ return "Tipperary";
+ case 27:
+ return "Waterford";
+ case 29:
+ return "Westmeath";
+ case 30:
+ return "Wexford";
+ case 31:
+ return "Wicklow";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IL(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "HaDarom";
+ case 2:
+ return "HaMerkaz";
+ case 3:
+ return "HaZafon";
+ case 4:
+ return "Hefa";
+ case 5:
+ return "Tel Aviv";
+ case 6:
+ return "Yerushalayim";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Andaman and Nicobar Islands";
+ case 2:
+ return "Andhra Pradesh";
+ case 3:
+ return "Assam";
+ case 5:
+ return "Chandigarh";
+ case 6:
+ return "Dadra and Nagar Haveli";
+ case 7:
+ return "Delhi";
+ case 9:
+ return "Gujarat";
+ case 10:
+ return "Haryana";
+ case 11:
+ return "Himachal Pradesh";
+ case 12:
+ return "Jammu and Kashmir";
+ case 13:
+ return "Kerala";
+ case 14:
+ return "Lakshadweep";
+ case 16:
+ return "Maharashtra";
+ case 17:
+ return "Manipur";
+ case 18:
+ return "Meghalaya";
+ case 19:
+ return "Karnataka";
+ case 20:
+ return "Nagaland";
+ case 21:
+ return "Orissa";
+ case 22:
+ return "Puducherry";
+ case 23:
+ return "Punjab";
+ case 24:
+ return "Rajasthan";
+ case 25:
+ return "Tamil Nadu";
+ case 26:
+ return "Tripura";
+ case 28:
+ return "West Bengal";
+ case 29:
+ return "Sikkim";
+ case 30:
+ return "Arunachal Pradesh";
+ case 31:
+ return "Mizoram";
+ case 32:
+ return "Daman and Diu";
+ case 33:
+ return "Goa";
+ case 34:
+ return "Bihar";
+ case 35:
+ return "Madhya Pradesh";
+ case 36:
+ return "Uttar Pradesh";
+ case 37:
+ return "Chhattisgarh";
+ case 38:
+ return "Jharkhand";
+ case 39:
+ return "Uttarakhand";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IQ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Al Anbar";
+ case 2:
+ return "Al Basrah";
+ case 3:
+ return "Al Muthanna";
+ case 4:
+ return "Al Qadisiyah";
+ case 5:
+ return "As Sulaymaniyah";
+ case 6:
+ return "Babil";
+ case 7:
+ return "Baghdad";
+ case 8:
+ return "Dahuk";
+ case 9:
+ return "Dhi Qar";
+ case 10:
+ return "Diyala";
+ case 11:
+ return "Arbil";
+ case 12:
+ return "Karbala'";
+ case 13:
+ return "At Ta'mim";
+ case 14:
+ return "Maysan";
+ case 15:
+ return "Ninawa";
+ case 16:
+ return "Wasit";
+ case 17:
+ return "An Najaf";
+ case 18:
+ return "Salah ad Din";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Azarbayjan-e Bakhtari";
+ case 3:
+ return "Chahar Mahall va Bakhtiari";
+ case 4:
+ return "Sistan va Baluchestan";
+ case 5:
+ return "Kohkiluyeh va Buyer Ahmadi";
+ case 7:
+ return "Fars";
+ case 8:
+ return "Gilan";
+ case 9:
+ return "Hamadan";
+ case 10:
+ return "Ilam";
+ case 11:
+ return "Hormozgan";
+ case 12:
+ return "Kerman";
+ case 13:
+ return "Bakhtaran";
+ case 15:
+ return "Khuzestan";
+ case 16:
+ return "Kordestan";
+ case 17:
+ return "Mazandaran";
+ case 18:
+ return "Semnan Province";
+ case 19:
+ return "Markazi";
+ case 21:
+ return "Zanjan";
+ case 22:
+ return "Bushehr";
+ case 23:
+ return "Lorestan";
+ case 24:
+ return "Markazi";
+ case 25:
+ return "Semnan";
+ case 26:
+ return "Tehran";
+ case 27:
+ return "Zanjan";
+ case 28:
+ return "Esfahan";
+ case 29:
+ return "Kerman";
+ case 30:
+ return "Khorasan";
+ case 31:
+ return "Yazd";
+ case 32:
+ return "Ardabil";
+ case 33:
+ return "East Azarbaijan";
+ case 34:
+ return "Markazi";
+ case 35:
+ return "Mazandaran";
+ case 36:
+ return "Zanjan";
+ case 37:
+ return "Golestan";
+ case 38:
+ return "Qazvin";
+ case 39:
+ return "Qom";
+ case 40:
+ return "Yazd";
+ case 41:
+ return "Khorasan-e Janubi";
+ case 42:
+ return "Khorasan-e Razavi";
+ case 43:
+ return "Khorasan-e Shemali";
+ case 44:
+ return "Alborz";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IS(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Arnessysla";
+ case 5:
+ return "Austur-Hunavatnssysla";
+ case 6:
+ return "Austur-Skaftafellssysla";
+ case 7:
+ return "Borgarfjardarsysla";
+ case 9:
+ return "Eyjafjardarsysla";
+ case 10:
+ return "Gullbringusysla";
+ case 15:
+ return "Kjosarsysla";
+ case 17:
+ return "Myrasysla";
+ case 20:
+ return "Nordur-Mulasysla";
+ case 21:
+ return "Nordur-Tingeyjarsysla";
+ case 23:
+ return "Rangarvallasysla";
+ case 28:
+ return "Skagafjardarsysla";
+ case 29:
+ return "Snafellsnes- og Hnappadalssysla";
+ case 30:
+ return "Strandasysla";
+ case 31:
+ return "Sudur-Mulasysla";
+ case 32:
+ return "Sudur-Tingeyjarsysla";
+ case 34:
+ return "Vestur-Bardastrandarsysla";
+ case 35:
+ return "Vestur-Hunavatnssysla";
+ case 36:
+ return "Vestur-Isafjardarsysla";
+ case 37:
+ return "Vestur-Skaftafellssysla";
+ case 38:
+ return "Austurland";
+ case 39:
+ return "Hofuoborgarsvaoio";
+ case 40:
+ return "Norourland Eystra";
+ case 41:
+ return "Norourland Vestra";
+ case 42:
+ return "Suourland";
+ case 43:
+ return "Suournes";
+ case 44:
+ return "Vestfiroir";
+ case 45:
+ return "Vesturland";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_IT(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abruzzi";
+ case 2:
+ return "Basilicata";
+ case 3:
+ return "Calabria";
+ case 4:
+ return "Campania";
+ case 5:
+ return "Emilia-Romagna";
+ case 6:
+ return "Friuli-Venezia Giulia";
+ case 7:
+ return "Lazio";
+ case 8:
+ return "Liguria";
+ case 9:
+ return "Lombardia";
+ case 10:
+ return "Marche";
+ case 11:
+ return "Molise";
+ case 12:
+ return "Piemonte";
+ case 13:
+ return "Puglia";
+ case 14:
+ return "Sardegna";
+ case 15:
+ return "Sicilia";
+ case 16:
+ return "Toscana";
+ case 17:
+ return "Trentino-Alto Adige";
+ case 18:
+ return "Umbria";
+ case 19:
+ return "Valle d'Aosta";
+ case 20:
+ return "Veneto";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_JM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Clarendon";
+ case 2:
+ return "Hanover";
+ case 4:
+ return "Manchester";
+ case 7:
+ return "Portland";
+ case 8:
+ return "Saint Andrew";
+ case 9:
+ return "Saint Ann";
+ case 10:
+ return "Saint Catherine";
+ case 11:
+ return "Saint Elizabeth";
+ case 12:
+ return "Saint James";
+ case 13:
+ return "Saint Mary";
+ case 14:
+ return "Saint Thomas";
+ case 15:
+ return "Trelawny";
+ case 16:
+ return "Westmoreland";
+ case 17:
+ return "Kingston";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_JO(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Al Balqa'";
+ case 9:
+ return "Al Karak";
+ case 12:
+ return "At Tafilah";
+ case 15:
+ return "Al Mafraq";
+ case 16:
+ return "Amman";
+ case 17:
+ return "Az Zaraqa";
+ case 18:
+ return "Irbid";
+ case 19:
+ return "Ma'an";
+ case 20:
+ return "Ajlun";
+ case 21:
+ return "Al Aqabah";
+ case 22:
+ return "Jarash";
+ case 23:
+ return "Madaba";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_JP(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aichi";
+ case 2:
+ return "Akita";
+ case 3:
+ return "Aomori";
+ case 4:
+ return "Chiba";
+ case 5:
+ return "Ehime";
+ case 6:
+ return "Fukui";
+ case 7:
+ return "Fukuoka";
+ case 8:
+ return "Fukushima";
+ case 9:
+ return "Gifu";
+ case 10:
+ return "Gumma";
+ case 11:
+ return "Hiroshima";
+ case 12:
+ return "Hokkaido";
+ case 13:
+ return "Hyogo";
+ case 14:
+ return "Ibaraki";
+ case 15:
+ return "Ishikawa";
+ case 16:
+ return "Iwate";
+ case 17:
+ return "Kagawa";
+ case 18:
+ return "Kagoshima";
+ case 19:
+ return "Kanagawa";
+ case 20:
+ return "Kochi";
+ case 21:
+ return "Kumamoto";
+ case 22:
+ return "Kyoto";
+ case 23:
+ return "Mie";
+ case 24:
+ return "Miyagi";
+ case 25:
+ return "Miyazaki";
+ case 26:
+ return "Nagano";
+ case 27:
+ return "Nagasaki";
+ case 28:
+ return "Nara";
+ case 29:
+ return "Niigata";
+ case 30:
+ return "Oita";
+ case 31:
+ return "Okayama";
+ case 32:
+ return "Osaka";
+ case 33:
+ return "Saga";
+ case 34:
+ return "Saitama";
+ case 35:
+ return "Shiga";
+ case 36:
+ return "Shimane";
+ case 37:
+ return "Shizuoka";
+ case 38:
+ return "Tochigi";
+ case 39:
+ return "Tokushima";
+ case 40:
+ return "Tokyo";
+ case 41:
+ return "Tottori";
+ case 42:
+ return "Toyama";
+ case 43:
+ return "Wakayama";
+ case 44:
+ return "Yamagata";
+ case 45:
+ return "Yamaguchi";
+ case 46:
+ return "Yamanashi";
+ case 47:
+ return "Okinawa";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Central";
+ case 2:
+ return "Coast";
+ case 3:
+ return "Eastern";
+ case 5:
+ return "Nairobi Area";
+ case 6:
+ return "North-Eastern";
+ case 7:
+ return "Nyanza";
+ case 8:
+ return "Rift Valley";
+ case 9:
+ return "Western";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bishkek";
+ case 2:
+ return "Chuy";
+ case 3:
+ return "Jalal-Abad";
+ case 4:
+ return "Naryn";
+ case 5:
+ return "Osh";
+ case 6:
+ return "Talas";
+ case 7:
+ return "Ysyk-Kol";
+ case 8:
+ return "Osh";
+ case 9:
+ return "Batken";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Batdambang";
+ case 2:
+ return "Kampong Cham";
+ case 3:
+ return "Kampong Chhnang";
+ case 4:
+ return "Kampong Speu";
+ case 5:
+ return "Kampong Thum";
+ case 6:
+ return "Kampot";
+ case 7:
+ return "Kandal";
+ case 8:
+ return "Koh Kong";
+ case 9:
+ return "Kracheh";
+ case 10:
+ return "Mondulkiri";
+ case 11:
+ return "Phnum Penh";
+ case 12:
+ return "Pursat";
+ case 13:
+ return "Preah Vihear";
+ case 14:
+ return "Prey Veng";
+ case 15:
+ return "Ratanakiri Kiri";
+ case 16:
+ return "Siem Reap";
+ case 17:
+ return "Stung Treng";
+ case 18:
+ return "Svay Rieng";
+ case 19:
+ return "Takeo";
+ case 22:
+ return "Phnum Penh";
+ case 23:
+ return "Ratanakiri";
+ case 25:
+ return "Banteay Meanchey";
+ case 28:
+ return "Preah Seihanu";
+ case 29:
+ return "Batdambang";
+ case 30:
+ return "Pailin";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KI(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Gilbert Islands";
+ case 2:
+ return "Line Islands";
+ case 3:
+ return "Phoenix Islands";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Anjouan";
+ case 2:
+ return "Grande Comore";
+ case 3:
+ return "Moheli";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Christ Church Nichola Town";
+ case 2:
+ return "Saint Anne Sandy Point";
+ case 3:
+ return "Saint George Basseterre";
+ case 4:
+ return "Saint George Gingerland";
+ case 5:
+ return "Saint James Windward";
+ case 6:
+ return "Saint John Capisterre";
+ case 7:
+ return "Saint John Figtree";
+ case 8:
+ return "Saint Mary Cayon";
+ case 9:
+ return "Saint Paul Capisterre";
+ case 10:
+ return "Saint Paul Charlestown";
+ case 11:
+ return "Saint Peter Basseterre";
+ case 12:
+ return "Saint Thomas Lowland";
+ case 13:
+ return "Saint Thomas Middle Island";
+ case 15:
+ return "Trinity Palmetto Point";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KP(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Chagang-do";
+ case 3:
+ return "Hamgyong-namdo";
+ case 6:
+ return "Hwanghae-namdo";
+ case 7:
+ return "Hwanghae-bukto";
+ case 8:
+ return "Kaesong-si";
+ case 9:
+ return "Kangwon-do";
+ case 11:
+ return "P'yongan-bukto";
+ case 12:
+ return "P'yongyang-si";
+ case 13:
+ return "Yanggang-do";
+ case 14:
+ return "Namp'o-si";
+ case 15:
+ return "P'yongan-namdo";
+ case 17:
+ return "Hamgyong-bukto";
+ case 18:
+ return "Najin Sonbong-si";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Cheju-do";
+ case 3:
+ return "Cholla-bukto";
+ case 5:
+ return "Ch'ungch'ong-bukto";
+ case 6:
+ return "Kangwon-do";
+ case 10:
+ return "Pusan-jikhalsi";
+ case 11:
+ return "Seoul-t'ukpyolsi";
+ case 12:
+ return "Inch'on-jikhalsi";
+ case 13:
+ return "Kyonggi-do";
+ case 14:
+ return "Kyongsang-bukto";
+ case 15:
+ return "Taegu-jikhalsi";
+ case 16:
+ return "Cholla-namdo";
+ case 17:
+ return "Ch'ungch'ong-namdo";
+ case 18:
+ return "Kwangju-jikhalsi";
+ case 19:
+ return "Taejon-jikhalsi";
+ case 20:
+ return "Kyongsang-namdo";
+ case 21:
+ return "Ulsan-gwangyoksi";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Al Ahmadi";
+ case 2:
+ return "Al Kuwayt";
+ case 5:
+ return "Al Jahra";
+ case 7:
+ return "Al Farwaniyah";
+ case 8:
+ return "Hawalli";
+ case 9:
+ return "Mubarak al Kabir";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Creek";
+ case 2:
+ return "Eastern";
+ case 3:
+ return "Midland";
+ case 4:
+ return "South Town";
+ case 5:
+ return "Spot Bay";
+ case 6:
+ return "Stake Bay";
+ case 7:
+ return "West End";
+ case 8:
+ return "Western";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_KZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Almaty";
+ case 2:
+ return "Almaty City";
+ case 3:
+ return "Aqmola";
+ case 4:
+ return "Aqtobe";
+ case 5:
+ return "Astana";
+ case 6:
+ return "Atyrau";
+ case 7:
+ return "West Kazakhstan";
+ case 8:
+ return "Bayqonyr";
+ case 9:
+ return "Mangghystau";
+ case 10:
+ return "South Kazakhstan";
+ case 11:
+ return "Pavlodar";
+ case 12:
+ return "Qaraghandy";
+ case 13:
+ return "Qostanay";
+ case 14:
+ return "Qyzylorda";
+ case 15:
+ return "East Kazakhstan";
+ case 16:
+ return "North Kazakhstan";
+ case 17:
+ return "Zhambyl";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Attapu";
+ case 2:
+ return "Champasak";
+ case 3:
+ return "Houaphan";
+ case 4:
+ return "Khammouan";
+ case 5:
+ return "Louang Namtha";
+ case 7:
+ return "Oudomxai";
+ case 8:
+ return "Phongsali";
+ case 9:
+ return "Saravan";
+ case 10:
+ return "Savannakhet";
+ case 11:
+ return "Vientiane";
+ case 13:
+ return "Xaignabouri";
+ case 14:
+ return "Xiangkhoang";
+ case 17:
+ return "Louangphrabang";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LB(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Beqaa";
+ case 2:
+ return "Al Janub";
+ case 3:
+ return "Liban-Nord";
+ case 4:
+ return "Beyrouth";
+ case 5:
+ return "Mont-Liban";
+ case 6:
+ return "Liban-Sud";
+ case 7:
+ return "Nabatiye";
+ case 8:
+ return "Beqaa";
+ case 9:
+ return "Liban-Nord";
+ case 10:
+ return "Aakk,r";
+ case 11:
+ return "Baalbek-Hermel";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LC(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Anse-la-Raye";
+ case 2:
+ return "Dauphin";
+ case 3:
+ return "Castries";
+ case 4:
+ return "Choiseul";
+ case 5:
+ return "Dennery";
+ case 6:
+ return "Gros-Islet";
+ case 7:
+ return "Laborie";
+ case 8:
+ return "Micoud";
+ case 9:
+ return "Soufriere";
+ case 10:
+ return "Vieux-Fort";
+ case 11:
+ return "Praslin";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LI(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Balzers";
+ case 2:
+ return "Eschen";
+ case 3:
+ return "Gamprin";
+ case 4:
+ return "Mauren";
+ case 5:
+ return "Planken";
+ case 6:
+ return "Ruggell";
+ case 7:
+ return "Schaan";
+ case 8:
+ return "Schellenberg";
+ case 9:
+ return "Triesen";
+ case 10:
+ return "Triesenberg";
+ case 11:
+ return "Vaduz";
+ case 21:
+ return "Gbarpolu";
+ case 22:
+ return "River Gee";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LK(int region_code) {
+ switch (region_code) {
+ case 29:
+ return "Central";
+ case 30:
+ return "North Central";
+ case 32:
+ return "North Western";
+ case 33:
+ return "Sabaragamuwa";
+ case 34:
+ return "Southern";
+ case 35:
+ return "Uva";
+ case 36:
+ return "Western";
+ case 37:
+ return "Eastern";
+ case 38:
+ return "Northern";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bong";
+ case 4:
+ return "Grand Cape Mount";
+ case 5:
+ return "Lofa";
+ case 6:
+ return "Maryland";
+ case 7:
+ return "Monrovia";
+ case 9:
+ return "Nimba";
+ case 10:
+ return "Sino";
+ case 11:
+ return "Grand Bassa";
+ case 12:
+ return "Grand Cape Mount";
+ case 13:
+ return "Maryland";
+ case 14:
+ return "Montserrado";
+ case 17:
+ return "Margibi";
+ case 18:
+ return "River Cess";
+ case 19:
+ return "Grand Gedeh";
+ case 20:
+ return "Lofa";
+ case 21:
+ return "Gbarpolu";
+ case 22:
+ return "River Gee";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LS(int region_code) {
+ switch (region_code) {
+ case 10:
+ return "Berea";
+ case 11:
+ return "Butha-Buthe";
+ case 12:
+ return "Leribe";
+ case 13:
+ return "Mafeteng";
+ case 14:
+ return "Maseru";
+ case 15:
+ return "Mohales Hoek";
+ case 16:
+ return "Mokhotlong";
+ case 17:
+ return "Qachas Nek";
+ case 18:
+ return "Quthing";
+ case 19:
+ return "Thaba-Tseka";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LT(int region_code) {
+ switch (region_code) {
+ case 56:
+ return "Alytaus Apskritis";
+ case 57:
+ return "Kauno Apskritis";
+ case 58:
+ return "Klaipedos Apskritis";
+ case 59:
+ return "Marijampoles Apskritis";
+ case 60:
+ return "Panevezio Apskritis";
+ case 61:
+ return "Siauliu Apskritis";
+ case 62:
+ return "Taurages Apskritis";
+ case 63:
+ return "Telsiu Apskritis";
+ case 64:
+ return "Utenos Apskritis";
+ case 65:
+ return "Vilniaus Apskritis";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LU(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Diekirch";
+ case 2:
+ return "Grevenmacher";
+ case 3:
+ return "Luxembourg";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LV(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aizkraukles";
+ case 2:
+ return "Aluksnes";
+ case 3:
+ return "Balvu";
+ case 4:
+ return "Bauskas";
+ case 5:
+ return "Cesu";
+ case 6:
+ return "Daugavpils";
+ case 7:
+ return "Daugavpils";
+ case 8:
+ return "Dobeles";
+ case 9:
+ return "Gulbenes";
+ case 10:
+ return "Jekabpils";
+ case 11:
+ return "Jelgava";
+ case 12:
+ return "Jelgavas";
+ case 13:
+ return "Jurmala";
+ case 14:
+ return "Kraslavas";
+ case 15:
+ return "Kuldigas";
+ case 16:
+ return "Liepaja";
+ case 17:
+ return "Liepajas";
+ case 18:
+ return "Limbazu";
+ case 19:
+ return "Ludzas";
+ case 20:
+ return "Madonas";
+ case 21:
+ return "Ogres";
+ case 22:
+ return "Preilu";
+ case 23:
+ return "Rezekne";
+ case 24:
+ return "Rezeknes";
+ case 25:
+ return "Riga";
+ case 26:
+ return "Rigas";
+ case 27:
+ return "Saldus";
+ case 28:
+ return "Talsu";
+ case 29:
+ return "Tukuma";
+ case 30:
+ return "Valkas";
+ case 31:
+ return "Valmieras";
+ case 32:
+ return "Ventspils";
+ case 33:
+ return "Ventspils";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_LY(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Al Aziziyah";
+ case 5:
+ return "Al Jufrah";
+ case 8:
+ return "Al Kufrah";
+ case 13:
+ return "Ash Shati'";
+ case 30:
+ return "Murzuq";
+ case 34:
+ return "Sabha";
+ case 41:
+ return "Tarhunah";
+ case 42:
+ return "Tubruq";
+ case 45:
+ return "Zlitan";
+ case 47:
+ return "Ajdabiya";
+ case 48:
+ return "Al Fatih";
+ case 49:
+ return "Al Jabal al Akhdar";
+ case 50:
+ return "Al Khums";
+ case 51:
+ return "An Nuqat al Khams";
+ case 52:
+ return "Awbari";
+ case 53:
+ return "Az Zawiyah";
+ case 54:
+ return "Banghazi";
+ case 55:
+ return "Darnah";
+ case 56:
+ return "Ghadamis";
+ case 57:
+ return "Gharyan";
+ case 58:
+ return "Misratah";
+ case 59:
+ return "Sawfajjin";
+ case 60:
+ return "Surt";
+ case 61:
+ return "Tarabulus";
+ case 62:
+ return "Yafran";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MA(int region_code) {
+ switch (region_code) {
+ case 45:
+ return "Grand Casablanca";
+ case 46:
+ return "Fes-Boulemane";
+ case 47:
+ return "Marrakech-Tensift-Al Haouz";
+ case 48:
+ return "Meknes-Tafilalet";
+ case 49:
+ return "Rabat-Sale-Zemmour-Zaer";
+ case 50:
+ return "Chaouia-Ouardigha";
+ case 51:
+ return "Doukkala-Abda";
+ case 52:
+ return "Gharb-Chrarda-Beni Hssen";
+ case 53:
+ return "Guelmim-Es Smara";
+ case 54:
+ return "Oriental";
+ case 55:
+ return "Souss-Massa-Dr,a";
+ case 56:
+ return "Tadla-Azilal";
+ case 57:
+ return "Tanger-Tetouan";
+ case 58:
+ return "Taza-Al Hoceima-Taounate";
+ case 59:
+ return "La,youne-Boujdour-Sakia El Hamra";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MC(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "La Condamine";
+ case 2:
+ return "Monaco";
+ case 3:
+ return "Monte-Carlo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MD(int region_code) {
+ switch (region_code) {
+ case 51:
+ return "Gagauzia";
+ case 57:
+ return "Chisinau";
+ case 58:
+ return "Stinga Nistrului";
+ case 59:
+ return "Anenii Noi";
+ case 60:
+ return "Balti";
+ case 61:
+ return "Basarabeasca";
+ case 62:
+ return "Bender";
+ case 63:
+ return "Briceni";
+ case 64:
+ return "Cahul";
+ case 65:
+ return "Cantemir";
+ case 66:
+ return "Calarasi";
+ case 67:
+ return "Causeni";
+ case 68:
+ return "Cimislia";
+ case 69:
+ return "Criuleni";
+ case 70:
+ return "Donduseni";
+ case 71:
+ return "Drochia";
+ case 72:
+ return "Dubasari";
+ case 73:
+ return "Edinet";
+ case 74:
+ return "Falesti";
+ case 75:
+ return "Floresti";
+ case 76:
+ return "Glodeni";
+ case 77:
+ return "Hincesti";
+ case 78:
+ return "Ialoveni";
+ case 79:
+ return "Leova";
+ case 80:
+ return "Nisporeni";
+ case 81:
+ return "Ocnita";
+ case 82:
+ return "Orhei";
+ case 83:
+ return "Rezina";
+ case 84:
+ return "Riscani";
+ case 85:
+ return "Singerei";
+ case 86:
+ return "Soldanesti";
+ case 87:
+ return "Soroca";
+ case 88:
+ return "Stefan-Voda";
+ case 89:
+ return "Straseni";
+ case 90:
+ return "Taraclia";
+ case 91:
+ return "Telenesti";
+ case 92:
+ return "Ungheni";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Antsiranana";
+ case 2:
+ return "Fianarantsoa";
+ case 3:
+ return "Mahajanga";
+ case 4:
+ return "Toamasina";
+ case 5:
+ return "Antananarivo";
+ case 6:
+ return "Toliara";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MK(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aracinovo";
+ case 2:
+ return "Bac";
+ case 3:
+ return "Belcista";
+ case 4:
+ return "Berovo";
+ case 5:
+ return "Bistrica";
+ case 6:
+ return "Bitola";
+ case 7:
+ return "Blatec";
+ case 8:
+ return "Bogdanci";
+ case 9:
+ return "Bogomila";
+ case 10:
+ return "Bogovinje";
+ case 11:
+ return "Bosilovo";
+ case 12:
+ return "Brvenica";
+ case 13:
+ return "Cair";
+ case 14:
+ return "Capari";
+ case 15:
+ return "Caska";
+ case 16:
+ return "Cegrane";
+ case 17:
+ return "Centar";
+ case 18:
+ return "Centar Zupa";
+ case 19:
+ return "Cesinovo";
+ case 20:
+ return "Cucer-Sandevo";
+ case 21:
+ return "Debar";
+ case 22:
+ return "Delcevo";
+ case 23:
+ return "Delogozdi";
+ case 24:
+ return "Demir Hisar";
+ case 25:
+ return "Demir Kapija";
+ case 26:
+ return "Dobrusevo";
+ case 27:
+ return "Dolna Banjica";
+ case 28:
+ return "Dolneni";
+ case 29:
+ return "Dorce Petrov";
+ case 30:
+ return "Drugovo";
+ case 31:
+ return "Dzepciste";
+ case 32:
+ return "Gazi Baba";
+ case 33:
+ return "Gevgelija";
+ case 34:
+ return "Gostivar";
+ case 35:
+ return "Gradsko";
+ case 36:
+ return "Ilinden";
+ case 37:
+ return "Izvor";
+ case 38:
+ return "Jegunovce";
+ case 39:
+ return "Kamenjane";
+ case 40:
+ return "Karbinci";
+ case 41:
+ return "Karpos";
+ case 42:
+ return "Kavadarci";
+ case 43:
+ return "Kicevo";
+ case 44:
+ return "Kisela Voda";
+ case 45:
+ return "Klecevce";
+ case 46:
+ return "Kocani";
+ case 47:
+ return "Konce";
+ case 48:
+ return "Kondovo";
+ case 49:
+ return "Konopiste";
+ case 50:
+ return "Kosel";
+ case 51:
+ return "Kratovo";
+ case 52:
+ return "Kriva Palanka";
+ case 53:
+ return "Krivogastani";
+ case 54:
+ return "Krusevo";
+ case 55:
+ return "Kuklis";
+ case 56:
+ return "Kukurecani";
+ case 57:
+ return "Kumanovo";
+ case 58:
+ return "Labunista";
+ case 59:
+ return "Lipkovo";
+ case 60:
+ return "Lozovo";
+ case 61:
+ return "Lukovo";
+ case 62:
+ return "Makedonska Kamenica";
+ case 63:
+ return "Makedonski Brod";
+ case 64:
+ return "Mavrovi Anovi";
+ case 65:
+ return "Meseista";
+ case 66:
+ return "Miravci";
+ case 67:
+ return "Mogila";
+ case 68:
+ return "Murtino";
+ case 69:
+ return "Negotino";
+ case 70:
+ return "Negotino-Polosko";
+ case 71:
+ return "Novaci";
+ case 72:
+ return "Novo Selo";
+ case 73:
+ return "Oblesevo";
+ case 74:
+ return "Ohrid";
+ case 75:
+ return "Orasac";
+ case 76:
+ return "Orizari";
+ case 77:
+ return "Oslomej";
+ case 78:
+ return "Pehcevo";
+ case 79:
+ return "Petrovec";
+ case 80:
+ return "Plasnica";
+ case 81:
+ return "Podares";
+ case 82:
+ return "Prilep";
+ case 83:
+ return "Probistip";
+ case 84:
+ return "Radovis";
+ case 85:
+ return "Rankovce";
+ case 86:
+ return "Resen";
+ case 87:
+ return "Rosoman";
+ case 88:
+ return "Rostusa";
+ case 89:
+ return "Samokov";
+ case 90:
+ return "Saraj";
+ case 91:
+ return "Sipkovica";
+ case 92:
+ return "Sopiste";
+ case 93:
+ return "Sopotnica";
+ case 94:
+ return "Srbinovo";
+ case 95:
+ return "Staravina";
+ case 96:
+ return "Star Dojran";
+ case 97:
+ return "Staro Nagoricane";
+ case 98:
+ return "Stip";
+ case 99:
+ return "Struga";
+ case 832:
+ return "Strumica";
+ case 833:
+ return "Studenicani";
+ case 834:
+ return "Suto Orizari";
+ case 835:
+ return "Sveti Nikole";
+ case 836:
+ return "Tearce";
+ case 837:
+ return "Tetovo";
+ case 838:
+ return "Topolcani";
+ case 839:
+ return "Valandovo";
+ case 840:
+ return "Vasilevo";
+ case 875:
+ return "Veles";
+ case 876:
+ return "Velesta";
+ case 877:
+ return "Vevcani";
+ case 878:
+ return "Vinica";
+ case 879:
+ return "Vitoliste";
+ case 880:
+ return "Vranestica";
+ case 881:
+ return "Vrapciste";
+ case 882:
+ return "Vratnica";
+ case 883:
+ return "Vrutok";
+ case 918:
+ return "Zajas";
+ case 919:
+ return "Zelenikovo";
+ case 920:
+ return "Zelino";
+ case 921:
+ return "Zitose";
+ case 922:
+ return "Zletovo";
+ case 923:
+ return "Zrnovci";
+ case 925:
+ return "Cair";
+ case 926:
+ return "Caska";
+ case 962:
+ return "Debar";
+ case 963:
+ return "Demir Hisar";
+ case 964:
+ return "Gostivar";
+ case 965:
+ return "Jegunovce";
+ case 966:
+ return "Kavadarci";
+ case 967:
+ return "Kumanovo";
+ case 968:
+ return "Makedonski Brod";
+ case 1005:
+ return "Ohrid";
+ case 1006:
+ return "Prilep";
+ case 1008:
+ return "Dojran";
+ case 1009:
+ return "Struga";
+ case 1010:
+ return "Strumica";
+ case 1011:
+ return "Tetovo";
+ case 1012:
+ return "Valandovo";
+ case 1047:
+ return "Veles";
+ case 1048:
+ return "Aerodrom";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ML(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bamako";
+ case 3:
+ return "Kayes";
+ case 4:
+ return "Mopti";
+ case 5:
+ return "Segou";
+ case 6:
+ return "Sikasso";
+ case 7:
+ return "Koulikoro";
+ case 8:
+ return "Tombouctou";
+ case 9:
+ return "Gao";
+ case 10:
+ return "Kidal";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Rakhine State";
+ case 2:
+ return "Chin State";
+ case 3:
+ return "Irrawaddy";
+ case 4:
+ return "Kachin State";
+ case 5:
+ return "Karan State";
+ case 6:
+ return "Kayah State";
+ case 7:
+ return "Magwe";
+ case 8:
+ return "Mandalay";
+ case 9:
+ return "Pegu";
+ case 10:
+ return "Sagaing";
+ case 11:
+ return "Shan State";
+ case 12:
+ return "Tenasserim";
+ case 13:
+ return "Mon State";
+ case 14:
+ return "Rangoon";
+ case 17:
+ return "Yangon";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Arhangay";
+ case 2:
+ return "Bayanhongor";
+ case 3:
+ return "Bayan-Olgiy";
+ case 5:
+ return "Darhan";
+ case 6:
+ return "Dornod";
+ case 7:
+ return "Dornogovi";
+ case 8:
+ return "Dundgovi";
+ case 9:
+ return "Dzavhan";
+ case 10:
+ return "Govi-Altay";
+ case 11:
+ return "Hentiy";
+ case 12:
+ return "Hovd";
+ case 13:
+ return "Hovsgol";
+ case 14:
+ return "Omnogovi";
+ case 15:
+ return "Ovorhangay";
+ case 16:
+ return "Selenge";
+ case 17:
+ return "Suhbaatar";
+ case 18:
+ return "Tov";
+ case 19:
+ return "Uvs";
+ case 20:
+ return "Ulaanbaatar";
+ case 21:
+ return "Bulgan";
+ case 22:
+ return "Erdenet";
+ case 23:
+ return "Darhan-Uul";
+ case 24:
+ return "Govisumber";
+ case 25:
+ return "Orhon";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ilhas";
+ case 2:
+ return "Macau";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Hodh Ech Chargui";
+ case 2:
+ return "Hodh El Gharbi";
+ case 3:
+ return "Assaba";
+ case 4:
+ return "Gorgol";
+ case 5:
+ return "Brakna";
+ case 6:
+ return "Trarza";
+ case 7:
+ return "Adrar";
+ case 8:
+ return "Dakhlet Nouadhibou";
+ case 9:
+ return "Tagant";
+ case 10:
+ return "Guidimaka";
+ case 11:
+ return "Tiris Zemmour";
+ case 12:
+ return "Inchiri";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MS(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Saint Anthony";
+ case 2:
+ return "Saint Georges";
+ case 3:
+ return "Saint Peter";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MU(int region_code) {
+ switch (region_code) {
+ case 12:
+ return "Black River";
+ case 13:
+ return "Flacq";
+ case 14:
+ return "Grand Port";
+ case 15:
+ return "Moka";
+ case 16:
+ return "Pamplemousses";
+ case 17:
+ return "Plaines Wilhems";
+ case 18:
+ return "Port Louis";
+ case 19:
+ return "Riviere du Rempart";
+ case 20:
+ return "Savanne";
+ case 21:
+ return "Agalega Islands";
+ case 22:
+ return "Cargados Carajos";
+ case 23:
+ return "Rodrigues";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MV(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Seenu";
+ case 5:
+ return "Laamu";
+ case 30:
+ return "Alifu";
+ case 31:
+ return "Baa";
+ case 32:
+ return "Dhaalu";
+ case 33:
+ return "Faafu ";
+ case 34:
+ return "Gaafu Alifu";
+ case 35:
+ return "Gaafu Dhaalu";
+ case 36:
+ return "Haa Alifu";
+ case 37:
+ return "Haa Dhaalu";
+ case 38:
+ return "Kaafu";
+ case 39:
+ return "Lhaviyani";
+ case 40:
+ return "Maale";
+ case 41:
+ return "Meemu";
+ case 42:
+ return "Gnaviyani";
+ case 43:
+ return "Noonu";
+ case 44:
+ return "Raa";
+ case 45:
+ return "Shaviyani";
+ case 46:
+ return "Thaa";
+ case 47:
+ return "Vaavu";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MW(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Chikwawa";
+ case 3:
+ return "Chiradzulu";
+ case 4:
+ return "Chitipa";
+ case 5:
+ return "Thyolo";
+ case 6:
+ return "Dedza";
+ case 7:
+ return "Dowa";
+ case 8:
+ return "Karonga";
+ case 9:
+ return "Kasungu";
+ case 11:
+ return "Lilongwe";
+ case 12:
+ return "Mangochi";
+ case 13:
+ return "Mchinji";
+ case 15:
+ return "Mzimba";
+ case 16:
+ return "Ntcheu";
+ case 17:
+ return "Nkhata Bay";
+ case 18:
+ return "Nkhotakota";
+ case 19:
+ return "Nsanje";
+ case 20:
+ return "Ntchisi";
+ case 21:
+ return "Rumphi";
+ case 22:
+ return "Salima";
+ case 23:
+ return "Zomba";
+ case 24:
+ return "Blantyre";
+ case 25:
+ return "Mwanza";
+ case 26:
+ return "Balaka";
+ case 27:
+ return "Likoma";
+ case 28:
+ return "Machinga";
+ case 29:
+ return "Mulanje";
+ case 30:
+ return "Phalombe";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MX(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aguascalientes";
+ case 2:
+ return "Baja California";
+ case 3:
+ return "Baja California Sur";
+ case 4:
+ return "Campeche";
+ case 5:
+ return "Chiapas";
+ case 6:
+ return "Chihuahua";
+ case 7:
+ return "Coahuila de Zaragoza";
+ case 8:
+ return "Colima";
+ case 9:
+ return "Distrito Federal";
+ case 10:
+ return "Durango";
+ case 11:
+ return "Guanajuato";
+ case 12:
+ return "Guerrero";
+ case 13:
+ return "Hidalgo";
+ case 14:
+ return "Jalisco";
+ case 15:
+ return "Mexico";
+ case 16:
+ return "Michoacan de Ocampo";
+ case 17:
+ return "Morelos";
+ case 18:
+ return "Nayarit";
+ case 19:
+ return "Nuevo Leon";
+ case 20:
+ return "Oaxaca";
+ case 21:
+ return "Puebla";
+ case 22:
+ return "Queretaro de Arteaga";
+ case 23:
+ return "Quintana Roo";
+ case 24:
+ return "San Luis Potosi";
+ case 25:
+ return "Sinaloa";
+ case 26:
+ return "Sonora";
+ case 27:
+ return "Tabasco";
+ case 28:
+ return "Tamaulipas";
+ case 29:
+ return "Tlaxcala";
+ case 30:
+ return "Veracruz-Llave";
+ case 31:
+ return "Yucatan";
+ case 32:
+ return "Zacatecas";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Johor";
+ case 2:
+ return "Kedah";
+ case 3:
+ return "Kelantan";
+ case 4:
+ return "Melaka";
+ case 5:
+ return "Negeri Sembilan";
+ case 6:
+ return "Pahang";
+ case 7:
+ return "Perak";
+ case 8:
+ return "Perlis";
+ case 9:
+ return "Pulau Pinang";
+ case 11:
+ return "Sarawak";
+ case 12:
+ return "Selangor";
+ case 13:
+ return "Terengganu";
+ case 14:
+ return "Kuala Lumpur";
+ case 15:
+ return "Labuan";
+ case 16:
+ return "Sabah";
+ case 17:
+ return "Putrajaya";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_MZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Cabo Delgado";
+ case 2:
+ return "Gaza";
+ case 3:
+ return "Inhambane";
+ case 4:
+ return "Maputo";
+ case 5:
+ return "Sofala";
+ case 6:
+ return "Nampula";
+ case 7:
+ return "Niassa";
+ case 8:
+ return "Tete";
+ case 9:
+ return "Zambezia";
+ case 10:
+ return "Manica";
+ case 11:
+ return "Maputo";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bethanien";
+ case 2:
+ return "Caprivi Oos";
+ case 3:
+ return "Boesmanland";
+ case 4:
+ return "Gobabis";
+ case 5:
+ return "Grootfontein";
+ case 6:
+ return "Kaokoland";
+ case 7:
+ return "Karibib";
+ case 8:
+ return "Keetmanshoop";
+ case 9:
+ return "Luderitz";
+ case 10:
+ return "Maltahohe";
+ case 11:
+ return "Okahandja";
+ case 12:
+ return "Omaruru";
+ case 13:
+ return "Otjiwarongo";
+ case 14:
+ return "Outjo";
+ case 15:
+ return "Owambo";
+ case 16:
+ return "Rehoboth";
+ case 17:
+ return "Swakopmund";
+ case 18:
+ return "Tsumeb";
+ case 20:
+ return "Karasburg";
+ case 21:
+ return "Windhoek";
+ case 22:
+ return "Damaraland";
+ case 23:
+ return "Hereroland Oos";
+ case 24:
+ return "Hereroland Wes";
+ case 25:
+ return "Kavango";
+ case 26:
+ return "Mariental";
+ case 27:
+ return "Namaland";
+ case 28:
+ return "Caprivi";
+ case 29:
+ return "Erongo";
+ case 30:
+ return "Hardap";
+ case 31:
+ return "Karas";
+ case 32:
+ return "Kunene";
+ case 33:
+ return "Ohangwena";
+ case 34:
+ return "Okavango";
+ case 35:
+ return "Omaheke";
+ case 36:
+ return "Omusati";
+ case 37:
+ return "Oshana";
+ case 38:
+ return "Oshikoto";
+ case 39:
+ return "Otjozondjupa";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Agadez";
+ case 2:
+ return "Diffa";
+ case 3:
+ return "Dosso";
+ case 4:
+ return "Maradi";
+ case 5:
+ return "Niamey";
+ case 6:
+ return "Tahoua";
+ case 7:
+ return "Zinder";
+ case 8:
+ return "Niamey";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NG(int region_code) {
+ switch (region_code) {
+ case 5:
+ return "Lagos";
+ case 11:
+ return "Federal Capital Territory";
+ case 16:
+ return "Ogun";
+ case 21:
+ return "Akwa Ibom";
+ case 22:
+ return "Cross River";
+ case 23:
+ return "Kaduna";
+ case 24:
+ return "Katsina";
+ case 25:
+ return "Anambra";
+ case 26:
+ return "Benue";
+ case 27:
+ return "Borno";
+ case 28:
+ return "Imo";
+ case 29:
+ return "Kano";
+ case 30:
+ return "Kwara";
+ case 31:
+ return "Niger";
+ case 32:
+ return "Oyo";
+ case 35:
+ return "Adamawa";
+ case 36:
+ return "Delta";
+ case 37:
+ return "Edo";
+ case 39:
+ return "Jigawa";
+ case 40:
+ return "Kebbi";
+ case 41:
+ return "Kogi";
+ case 42:
+ return "Osun";
+ case 43:
+ return "Taraba";
+ case 44:
+ return "Yobe";
+ case 45:
+ return "Abia";
+ case 46:
+ return "Bauchi";
+ case 47:
+ return "Enugu";
+ case 48:
+ return "Ondo";
+ case 49:
+ return "Plateau";
+ case 50:
+ return "Rivers";
+ case 51:
+ return "Sokoto";
+ case 52:
+ return "Bayelsa";
+ case 53:
+ return "Ebonyi";
+ case 54:
+ return "Ekiti";
+ case 55:
+ return "Gombe";
+ case 56:
+ return "Nassarawa";
+ case 57:
+ return "Zamfara";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NI(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Boaco";
+ case 2:
+ return "Carazo";
+ case 3:
+ return "Chinandega";
+ case 4:
+ return "Chontales";
+ case 5:
+ return "Esteli";
+ case 6:
+ return "Granada";
+ case 7:
+ return "Jinotega";
+ case 8:
+ return "Leon";
+ case 9:
+ return "Madriz";
+ case 10:
+ return "Managua";
+ case 11:
+ return "Masaya";
+ case 12:
+ return "Matagalpa";
+ case 13:
+ return "Nueva Segovia";
+ case 14:
+ return "Rio San Juan";
+ case 15:
+ return "Rivas";
+ case 16:
+ return "Zelaya";
+ case 17:
+ return "Autonoma Atlantico Norte";
+ case 18:
+ return "Region Autonoma Atlantico Sur";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NL(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Drenthe";
+ case 2:
+ return "Friesland";
+ case 3:
+ return "Gelderland";
+ case 4:
+ return "Groningen";
+ case 5:
+ return "Limburg";
+ case 6:
+ return "Noord-Brabant";
+ case 7:
+ return "Noord-Holland";
+ case 9:
+ return "Utrecht";
+ case 10:
+ return "Zeeland";
+ case 11:
+ return "Zuid-Holland";
+ case 15:
+ return "Overijssel";
+ case 16:
+ return "Flevoland";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Akershus";
+ case 2:
+ return "Aust-Agder";
+ case 4:
+ return "Buskerud";
+ case 5:
+ return "Finnmark";
+ case 6:
+ return "Hedmark";
+ case 7:
+ return "Hordaland";
+ case 8:
+ return "More og Romsdal";
+ case 9:
+ return "Nordland";
+ case 10:
+ return "Nord-Trondelag";
+ case 11:
+ return "Oppland";
+ case 12:
+ return "Oslo";
+ case 13:
+ return "Ostfold";
+ case 14:
+ return "Rogaland";
+ case 15:
+ return "Sogn og Fjordane";
+ case 16:
+ return "Sor-Trondelag";
+ case 17:
+ return "Telemark";
+ case 18:
+ return "Troms";
+ case 19:
+ return "Vest-Agder";
+ case 20:
+ return "Vestfold";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NP(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bagmati";
+ case 2:
+ return "Bheri";
+ case 3:
+ return "Dhawalagiri";
+ case 4:
+ return "Gandaki";
+ case 5:
+ return "Janakpur";
+ case 6:
+ return "Karnali";
+ case 7:
+ return "Kosi";
+ case 8:
+ return "Lumbini";
+ case 9:
+ return "Mahakali";
+ case 10:
+ return "Mechi";
+ case 11:
+ return "Narayani";
+ case 12:
+ return "Rapti";
+ case 13:
+ return "Sagarmatha";
+ case 14:
+ return "Seti";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NR(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Aiwo";
+ case 2:
+ return "Anabar";
+ case 3:
+ return "Anetan";
+ case 4:
+ return "Anibare";
+ case 5:
+ return "Baiti";
+ case 6:
+ return "Boe";
+ case 7:
+ return "Buada";
+ case 8:
+ return "Denigomodu";
+ case 9:
+ return "Ewa";
+ case 10:
+ return "Ijuw";
+ case 11:
+ return "Meneng";
+ case 12:
+ return "Nibok";
+ case 13:
+ return "Uaboe";
+ case 14:
+ return "Yaren";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_NZ(int region_code) {
+ switch (region_code) {
+ case 10:
+ return "Chatham Islands";
+ case 1010:
+ return "Auckland";
+ case 1011:
+ return "Bay of Plenty";
+ case 1012:
+ return "Canterbury";
+ case 1047:
+ return "Gisborne";
+ case 1048:
+ return "Hawke's Bay";
+ case 1049:
+ return "Manawatu-Wanganui";
+ case 1050:
+ return "Marlborough";
+ case 1051:
+ return "Nelson";
+ case 1052:
+ return "Northland";
+ case 1053:
+ return "Otago";
+ case 1054:
+ return "Southland";
+ case 1055:
+ return "Taranaki";
+ case 1090:
+ return "Waikato";
+ case 1091:
+ return "Wellington";
+ case 1092:
+ return "West Coast";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_OM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ad Dakhiliyah";
+ case 2:
+ return "Al Batinah";
+ case 3:
+ return "Al Wusta";
+ case 4:
+ return "Ash Sharqiyah";
+ case 5:
+ return "Az Zahirah";
+ case 6:
+ return "Masqat";
+ case 7:
+ return "Musandam";
+ case 8:
+ return "Zufar";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bocas del Toro";
+ case 2:
+ return "Chiriqui";
+ case 3:
+ return "Cocle";
+ case 4:
+ return "Colon";
+ case 5:
+ return "Darien";
+ case 6:
+ return "Herrera";
+ case 7:
+ return "Los Santos";
+ case 8:
+ return "Panama";
+ case 9:
+ return "San Blas";
+ case 10:
+ return "Veraguas";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Amazonas";
+ case 2:
+ return "Ancash";
+ case 3:
+ return "Apurimac";
+ case 4:
+ return "Arequipa";
+ case 5:
+ return "Ayacucho";
+ case 6:
+ return "Cajamarca";
+ case 7:
+ return "Callao";
+ case 8:
+ return "Cusco";
+ case 9:
+ return "Huancavelica";
+ case 10:
+ return "Huanuco";
+ case 11:
+ return "Ica";
+ case 12:
+ return "Junin";
+ case 13:
+ return "La Libertad";
+ case 14:
+ return "Lambayeque";
+ case 15:
+ return "Lima";
+ case 16:
+ return "Loreto";
+ case 17:
+ return "Madre de Dios";
+ case 18:
+ return "Moquegua";
+ case 19:
+ return "Pasco";
+ case 20:
+ return "Piura";
+ case 21:
+ return "Puno";
+ case 22:
+ return "San Martin";
+ case 23:
+ return "Tacna";
+ case 24:
+ return "Tumbes";
+ case 25:
+ return "Ucayali";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PG(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Central";
+ case 2:
+ return "Gulf";
+ case 3:
+ return "Milne Bay";
+ case 4:
+ return "Northern";
+ case 5:
+ return "Southern Highlands";
+ case 6:
+ return "Western";
+ case 7:
+ return "North Solomons";
+ case 8:
+ return "Chimbu";
+ case 9:
+ return "Eastern Highlands";
+ case 10:
+ return "East New Britain";
+ case 11:
+ return "East Sepik";
+ case 12:
+ return "Madang";
+ case 13:
+ return "Manus";
+ case 14:
+ return "Morobe";
+ case 15:
+ return "New Ireland";
+ case 16:
+ return "Western Highlands";
+ case 17:
+ return "West New Britain";
+ case 18:
+ return "Sandaun";
+ case 19:
+ return "Enga";
+ case 20:
+ return "National Capital";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abra";
+ case 2:
+ return "Agusan del Norte";
+ case 3:
+ return "Agusan del Sur";
+ case 4:
+ return "Aklan";
+ case 5:
+ return "Albay";
+ case 6:
+ return "Antique";
+ case 7:
+ return "Bataan";
+ case 8:
+ return "Batanes";
+ case 9:
+ return "Batangas";
+ case 10:
+ return "Benguet";
+ case 11:
+ return "Bohol";
+ case 12:
+ return "Bukidnon";
+ case 13:
+ return "Bulacan";
+ case 14:
+ return "Cagayan";
+ case 15:
+ return "Camarines Norte";
+ case 16:
+ return "Camarines Sur";
+ case 17:
+ return "Camiguin";
+ case 18:
+ return "Capiz";
+ case 19:
+ return "Catanduanes";
+ case 20:
+ return "Cavite";
+ case 21:
+ return "Cebu";
+ case 22:
+ return "Basilan";
+ case 23:
+ return "Eastern Samar";
+ case 24:
+ return "Davao";
+ case 25:
+ return "Davao del Sur";
+ case 26:
+ return "Davao Oriental";
+ case 27:
+ return "Ifugao";
+ case 28:
+ return "Ilocos Norte";
+ case 29:
+ return "Ilocos Sur";
+ case 30:
+ return "Iloilo";
+ case 31:
+ return "Isabela";
+ case 32:
+ return "Kalinga-Apayao";
+ case 33:
+ return "Laguna";
+ case 34:
+ return "Lanao del Norte";
+ case 35:
+ return "Lanao del Sur";
+ case 36:
+ return "La Union";
+ case 37:
+ return "Leyte";
+ case 38:
+ return "Marinduque";
+ case 39:
+ return "Masbate";
+ case 40:
+ return "Mindoro Occidental";
+ case 41:
+ return "Mindoro Oriental";
+ case 42:
+ return "Misamis Occidental";
+ case 43:
+ return "Misamis Oriental";
+ case 44:
+ return "Mountain";
+ case 45:
+ return "Negros Occidental";
+ case 46:
+ return "Negros Oriental";
+ case 47:
+ return "Nueva Ecija";
+ case 48:
+ return "Nueva Vizcaya";
+ case 49:
+ return "Palawan";
+ case 50:
+ return "Pampanga";
+ case 51:
+ return "Pangasinan";
+ case 53:
+ return "Rizal";
+ case 54:
+ return "Romblon";
+ case 55:
+ return "Samar";
+ case 56:
+ return "Maguindanao";
+ case 57:
+ return "North Cotabato";
+ case 58:
+ return "Sorsogon";
+ case 59:
+ return "Southern Leyte";
+ case 60:
+ return "Sulu";
+ case 61:
+ return "Surigao del Norte";
+ case 62:
+ return "Surigao del Sur";
+ case 63:
+ return "Tarlac";
+ case 64:
+ return "Zambales";
+ case 65:
+ return "Zamboanga del Norte";
+ case 66:
+ return "Zamboanga del Sur";
+ case 67:
+ return "Northern Samar";
+ case 68:
+ return "Quirino";
+ case 69:
+ return "Siquijor";
+ case 70:
+ return "South Cotabato";
+ case 71:
+ return "Sultan Kudarat";
+ case 72:
+ return "Tawitawi";
+ case 832:
+ return "Angeles";
+ case 833:
+ return "Bacolod";
+ case 834:
+ return "Bago";
+ case 835:
+ return "Baguio";
+ case 836:
+ return "Bais";
+ case 837:
+ return "Basilan City";
+ case 838:
+ return "Batangas City";
+ case 839:
+ return "Butuan";
+ case 840:
+ return "Cabanatuan";
+ case 875:
+ return "Cadiz";
+ case 876:
+ return "Cagayan de Oro";
+ case 877:
+ return "Calbayog";
+ case 878:
+ return "Caloocan";
+ case 879:
+ return "Canlaon";
+ case 880:
+ return "Cavite City";
+ case 881:
+ return "Cebu City";
+ case 882:
+ return "Cotabato";
+ case 883:
+ return "Dagupan";
+ case 918:
+ return "Danao";
+ case 919:
+ return "Dapitan";
+ case 920:
+ return "Davao City";
+ case 921:
+ return "Dipolog";
+ case 922:
+ return "Dumaguete";
+ case 923:
+ return "General Santos";
+ case 924:
+ return "Gingoog";
+ case 925:
+ return "Iligan";
+ case 926:
+ return "Iloilo City";
+ case 961:
+ return "Iriga";
+ case 962:
+ return "La Carlota";
+ case 963:
+ return "Laoag";
+ case 964:
+ return "Lapu-Lapu";
+ case 965:
+ return "Legaspi";
+ case 966:
+ return "Lipa";
+ case 967:
+ return "Lucena";
+ case 968:
+ return "Mandaue";
+ case 969:
+ return "Manila";
+ case 1004:
+ return "Marawi";
+ case 1005:
+ return "Naga";
+ case 1006:
+ return "Olongapo";
+ case 1007:
+ return "Ormoc";
+ case 1008:
+ return "Oroquieta";
+ case 1009:
+ return "Ozamis";
+ case 1010:
+ return "Pagadian";
+ case 1011:
+ return "Palayan";
+ case 1012:
+ return "Pasay";
+ case 1047:
+ return "Puerto Princesa";
+ case 1048:
+ return "Quezon City";
+ case 1049:
+ return "Roxas";
+ case 1050:
+ return "San Carlos";
+ case 1051:
+ return "San Carlos";
+ case 1052:
+ return "San Jose";
+ case 1053:
+ return "San Pablo";
+ case 1054:
+ return "Silay";
+ case 1055:
+ return "Surigao";
+ case 1090:
+ return "Tacloban";
+ case 1091:
+ return "Tagaytay";
+ case 1092:
+ return "Tagbilaran";
+ case 1093:
+ return "Tangub";
+ case 1094:
+ return "Toledo";
+ case 1095:
+ return "Trece Martires";
+ case 1096:
+ return "Zamboanga";
+ case 1097:
+ return "Aurora";
+ case 1134:
+ return "Quezon";
+ case 1135:
+ return "Negros Occidental";
+ case 1141:
+ return "Biliran";
+ case 1181:
+ return "Compostela Valley";
+ case 1182:
+ return "Davao del Norte";
+ case 1221:
+ return "Guimaras";
+ case 1222:
+ return "Himamaylan";
+ case 1225:
+ return "Kalinga";
+ case 1262:
+ return "Las Pinas";
+ case 1266:
+ return "Malabon";
+ case 1267:
+ return "Malaybalay";
+ case 1308:
+ return "Muntinlupa";
+ case 1309:
+ return "Navotas";
+ case 1311:
+ return "Paranaque";
+ case 1313:
+ return "Passi";
+ case 1477:
+ return "Zambales";
+ case 1352:
+ return "San Jose del Monte";
+ case 1353:
+ return "San Juan";
+ case 1355:
+ return "Santiago";
+ case 1356:
+ return "Sarangani";
+ case 1391:
+ return "Sipalay";
+ case 1393:
+ return "Surigao del Norte";
+ case 1478:
+ return "Zamboanga";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PK(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Federally Administered Tribal Areas";
+ case 2:
+ return "Balochistan";
+ case 3:
+ return "North-West Frontier";
+ case 4:
+ return "Punjab";
+ case 5:
+ return "Sindh";
+ case 6:
+ return "Azad Kashmir";
+ case 7:
+ return "Northern Areas";
+ case 8:
+ return "Islamabad";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PL(int region_code) {
+ switch (region_code) {
+ case 72:
+ return "Dolnoslaskie";
+ case 73:
+ return "Kujawsko-Pomorskie";
+ case 74:
+ return "Lodzkie";
+ case 75:
+ return "Lubelskie";
+ case 76:
+ return "Lubuskie";
+ case 77:
+ return "Malopolskie";
+ case 78:
+ return "Mazowieckie";
+ case 79:
+ return "Opolskie";
+ case 80:
+ return "Podkarpackie";
+ case 81:
+ return "Podlaskie";
+ case 82:
+ return "Pomorskie";
+ case 83:
+ return "Slaskie";
+ case 84:
+ return "Swietokrzyskie";
+ case 85:
+ return "Warminsko-Mazurskie";
+ case 86:
+ return "Wielkopolskie";
+ case 87:
+ return "Zachodniopomorskie";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PS(int region_code) {
+ switch (region_code) {
+ case 1131:
+ return "Gaza";
+ case 1798:
+ return "West Bank";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PT(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Aveiro";
+ case 3:
+ return "Beja";
+ case 4:
+ return "Braga";
+ case 5:
+ return "Braganca";
+ case 6:
+ return "Castelo Branco";
+ case 7:
+ return "Coimbra";
+ case 8:
+ return "Evora";
+ case 9:
+ return "Faro";
+ case 10:
+ return "Madeira";
+ case 11:
+ return "Guarda";
+ case 13:
+ return "Leiria";
+ case 14:
+ return "Lisboa";
+ case 16:
+ return "Portalegre";
+ case 17:
+ return "Porto";
+ case 18:
+ return "Santarem";
+ case 19:
+ return "Setubal";
+ case 20:
+ return "Viana do Castelo";
+ case 21:
+ return "Vila Real";
+ case 22:
+ return "Viseu";
+ case 23:
+ return "Azores";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_PY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Alto Parana";
+ case 2:
+ return "Amambay";
+ case 4:
+ return "Caaguazu";
+ case 5:
+ return "Caazapa";
+ case 6:
+ return "Central";
+ case 7:
+ return "Concepcion";
+ case 8:
+ return "Cordillera";
+ case 10:
+ return "Guaira";
+ case 11:
+ return "Itapua";
+ case 12:
+ return "Misiones";
+ case 13:
+ return "Neembucu";
+ case 15:
+ return "Paraguari";
+ case 16:
+ return "Presidente Hayes";
+ case 17:
+ return "San Pedro";
+ case 19:
+ return "Canindeyu";
+ case 22:
+ return "Asuncion";
+ case 23:
+ return "Alto Paraguay";
+ case 24:
+ return "Boqueron";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_QA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ad Dawhah";
+ case 2:
+ return "Al Ghuwariyah";
+ case 3:
+ return "Al Jumaliyah";
+ case 4:
+ return "Al Khawr";
+ case 5:
+ return "Al Wakrah Municipality";
+ case 6:
+ return "Ar Rayyan";
+ case 8:
+ return "Madinat ach Shamal";
+ case 9:
+ return "Umm Salal";
+ case 10:
+ return "Al Wakrah";
+ case 11:
+ return "Jariyan al Batnah";
+ case 12:
+ return "Umm Sa'id";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_RO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Alba";
+ case 2:
+ return "Arad";
+ case 3:
+ return "Arges";
+ case 4:
+ return "Bacau";
+ case 5:
+ return "Bihor";
+ case 6:
+ return "Bistrita-Nasaud";
+ case 7:
+ return "Botosani";
+ case 8:
+ return "Braila";
+ case 9:
+ return "Brasov";
+ case 10:
+ return "Bucuresti";
+ case 11:
+ return "Buzau";
+ case 12:
+ return "Caras-Severin";
+ case 13:
+ return "Cluj";
+ case 14:
+ return "Constanta";
+ case 15:
+ return "Covasna";
+ case 16:
+ return "Dambovita";
+ case 17:
+ return "Dolj";
+ case 18:
+ return "Galati";
+ case 19:
+ return "Gorj";
+ case 20:
+ return "Harghita";
+ case 21:
+ return "Hunedoara";
+ case 22:
+ return "Ialomita";
+ case 23:
+ return "Iasi";
+ case 25:
+ return "Maramures";
+ case 26:
+ return "Mehedinti";
+ case 27:
+ return "Mures";
+ case 28:
+ return "Neamt";
+ case 29:
+ return "Olt";
+ case 30:
+ return "Prahova";
+ case 31:
+ return "Salaj";
+ case 32:
+ return "Satu Mare";
+ case 33:
+ return "Sibiu";
+ case 34:
+ return "Suceava";
+ case 35:
+ return "Teleorman";
+ case 36:
+ return "Timis";
+ case 37:
+ return "Tulcea";
+ case 38:
+ return "Vaslui";
+ case 39:
+ return "Valcea";
+ case 40:
+ return "Vrancea";
+ case 41:
+ return "Calarasi";
+ case 42:
+ return "Giurgiu";
+ case 43:
+ return "Ilfov";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_RS(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Kosovo";
+ case 2:
+ return "Vojvodina";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_RU(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Adygeya, Republic of";
+ case 2:
+ return "Aginsky Buryatsky AO";
+ case 3:
+ return "Gorno-Altay";
+ case 4:
+ return "Altaisky krai";
+ case 5:
+ return "Amur";
+ case 6:
+ return "Arkhangel'sk";
+ case 7:
+ return "Astrakhan'";
+ case 8:
+ return "Bashkortostan";
+ case 9:
+ return "Belgorod";
+ case 10:
+ return "Bryansk";
+ case 11:
+ return "Buryat";
+ case 12:
+ return "Chechnya";
+ case 13:
+ return "Chelyabinsk";
+ case 14:
+ return "Chita";
+ case 15:
+ return "Chukot";
+ case 16:
+ return "Chuvashia";
+ case 17:
+ return "Dagestan";
+ case 18:
+ return "Evenk";
+ case 19:
+ return "Ingush";
+ case 20:
+ return "Irkutsk";
+ case 21:
+ return "Ivanovo";
+ case 22:
+ return "Kabardin-Balkar";
+ case 23:
+ return "Kaliningrad";
+ case 24:
+ return "Kalmyk";
+ case 25:
+ return "Kaluga";
+ case 26:
+ return "Kamchatka";
+ case 27:
+ return "Karachay-Cherkess";
+ case 28:
+ return "Karelia";
+ case 29:
+ return "Kemerovo";
+ case 30:
+ return "Khabarovsk";
+ case 31:
+ return "Khakass";
+ case 32:
+ return "Khanty-Mansiy";
+ case 33:
+ return "Kirov";
+ case 34:
+ return "Komi";
+ case 36:
+ return "Koryak";
+ case 37:
+ return "Kostroma";
+ case 38:
+ return "Krasnodar";
+ case 39:
+ return "Krasnoyarsk";
+ case 40:
+ return "Kurgan";
+ case 41:
+ return "Kursk";
+ case 42:
+ return "Leningrad";
+ case 43:
+ return "Lipetsk";
+ case 44:
+ return "Magadan";
+ case 45:
+ return "Mariy-El";
+ case 46:
+ return "Mordovia";
+ case 47:
+ return "Moskva";
+ case 48:
+ return "Moscow City";
+ case 49:
+ return "Murmansk";
+ case 50:
+ return "Nenets";
+ case 51:
+ return "Nizhegorod";
+ case 52:
+ return "Novgorod";
+ case 53:
+ return "Novosibirsk";
+ case 54:
+ return "Omsk";
+ case 55:
+ return "Orenburg";
+ case 56:
+ return "Orel";
+ case 57:
+ return "Penza";
+ case 58:
+ return "Perm'";
+ case 59:
+ return "Primor'ye";
+ case 60:
+ return "Pskov";
+ case 61:
+ return "Rostov";
+ case 62:
+ return "Ryazan'";
+ case 63:
+ return "Sakha";
+ case 64:
+ return "Sakhalin";
+ case 65:
+ return "Samara";
+ case 66:
+ return "Saint Petersburg City";
+ case 67:
+ return "Saratov";
+ case 68:
+ return "North Ossetia";
+ case 69:
+ return "Smolensk";
+ case 70:
+ return "Stavropol'";
+ case 71:
+ return "Sverdlovsk";
+ case 72:
+ return "Tambovskaya oblast";
+ case 73:
+ return "Tatarstan";
+ case 74:
+ return "Taymyr";
+ case 75:
+ return "Tomsk";
+ case 76:
+ return "Tula";
+ case 77:
+ return "Tver'";
+ case 78:
+ return "Tyumen'";
+ case 79:
+ return "Tuva";
+ case 80:
+ return "Udmurt";
+ case 81:
+ return "Ul'yanovsk";
+ case 83:
+ return "Vladimir";
+ case 84:
+ return "Volgograd";
+ case 85:
+ return "Vologda";
+ case 86:
+ return "Voronezh";
+ case 87:
+ return "Yamal-Nenets";
+ case 88:
+ return "Yaroslavl'";
+ case 89:
+ return "Yevrey";
+ case 90:
+ return "Permskiy Kray";
+ case 91:
+ return "Krasnoyarskiy Kray";
+ case 92:
+ return "Kamchatskiy Kray";
+ case 93:
+ return "Zabaykal'skiy Kray";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_RW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Butare";
+ case 6:
+ return "Gitarama";
+ case 7:
+ return "Kibungo";
+ case 9:
+ return "Kigali";
+ case 11:
+ return "Est";
+ case 12:
+ return "Kigali";
+ case 13:
+ return "Nord";
+ case 14:
+ return "Ouest";
+ case 15:
+ return "Sud";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SA(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Al Bahah";
+ case 5:
+ return "Al Madinah";
+ case 6:
+ return "Ash Sharqiyah";
+ case 8:
+ return "Al Qasim";
+ case 10:
+ return "Ar Riyad";
+ case 11:
+ return "Asir Province";
+ case 13:
+ return "Ha'il";
+ case 14:
+ return "Makkah";
+ case 15:
+ return "Al Hudud ash Shamaliyah";
+ case 16:
+ return "Najran";
+ case 17:
+ return "Jizan";
+ case 19:
+ return "Tabuk";
+ case 20:
+ return "Al Jawf";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SB(int region_code) {
+ switch (region_code) {
+ case 3:
+ return "Malaita";
+ case 6:
+ return "Guadalcanal";
+ case 7:
+ return "Isabel";
+ case 8:
+ return "Makira";
+ case 9:
+ return "Temotu";
+ case 10:
+ return "Central";
+ case 11:
+ return "Western";
+ case 12:
+ return "Choiseul";
+ case 13:
+ return "Rennell and Bellona";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SC(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Anse aux Pins";
+ case 2:
+ return "Anse Boileau";
+ case 3:
+ return "Anse Etoile";
+ case 4:
+ return "Anse Louis";
+ case 5:
+ return "Anse Royale";
+ case 6:
+ return "Baie Lazare";
+ case 7:
+ return "Baie Sainte Anne";
+ case 8:
+ return "Beau Vallon";
+ case 9:
+ return "Bel Air";
+ case 10:
+ return "Bel Ombre";
+ case 11:
+ return "Cascade";
+ case 12:
+ return "Glacis";
+ case 13:
+ return "Grand' Anse";
+ case 14:
+ return "Grand' Anse";
+ case 15:
+ return "La Digue";
+ case 16:
+ return "La Riviere Anglaise";
+ case 17:
+ return "Mont Buxton";
+ case 18:
+ return "Mont Fleuri";
+ case 19:
+ return "Plaisance";
+ case 20:
+ return "Pointe La Rue";
+ case 21:
+ return "Port Glaud";
+ case 22:
+ return "Saint Louis";
+ case 23:
+ return "Takamaka";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SD(int region_code) {
+ switch (region_code) {
+ case 27:
+ return "Al Wusta";
+ case 28:
+ return "Al Istiwa'iyah";
+ case 29:
+ return "Al Khartum";
+ case 30:
+ return "Ash Shamaliyah";
+ case 31:
+ return "Ash Sharqiyah";
+ case 32:
+ return "Bahr al Ghazal";
+ case 33:
+ return "Darfur";
+ case 34:
+ return "Kurdufan";
+ case 35:
+ return "Upper Nile";
+ case 40:
+ return "Al Wahadah State";
+ case 44:
+ return "Central Equatoria State";
+ case 49:
+ return "Southern Darfur";
+ case 50:
+ return "Southern Kordofan";
+ case 52:
+ return "Kassala";
+ case 53:
+ return "River Nile";
+ case 55:
+ return "Northern Darfur";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SE(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Blekinge Lan";
+ case 3:
+ return "Gavleborgs Lan";
+ case 5:
+ return "Gotlands Lan";
+ case 6:
+ return "Hallands Lan";
+ case 7:
+ return "Jamtlands Lan";
+ case 8:
+ return "Jonkopings Lan";
+ case 9:
+ return "Kalmar Lan";
+ case 10:
+ return "Dalarnas Lan";
+ case 12:
+ return "Kronobergs Lan";
+ case 14:
+ return "Norrbottens Lan";
+ case 15:
+ return "Orebro Lan";
+ case 16:
+ return "Ostergotlands Lan";
+ case 18:
+ return "Sodermanlands Lan";
+ case 21:
+ return "Uppsala Lan";
+ case 22:
+ return "Varmlands Lan";
+ case 23:
+ return "Vasterbottens Lan";
+ case 24:
+ return "Vasternorrlands Lan";
+ case 25:
+ return "Vastmanlands Lan";
+ case 26:
+ return "Stockholms Lan";
+ case 27:
+ return "Skane Lan";
+ case 28:
+ return "Vastra Gotaland";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ascension";
+ case 2:
+ return "Saint Helena";
+ case 3:
+ return "Tristan da Cunha";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SI(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ajdovscina Commune";
+ case 2:
+ return "Beltinci Commune";
+ case 3:
+ return "Bled Commune";
+ case 4:
+ return "Bohinj Commune";
+ case 5:
+ return "Borovnica Commune";
+ case 6:
+ return "Bovec Commune";
+ case 7:
+ return "Brda Commune";
+ case 8:
+ return "Brezice Commune";
+ case 9:
+ return "Brezovica Commune";
+ case 11:
+ return "Celje Commune";
+ case 12:
+ return "Cerklje na Gorenjskem Commune";
+ case 13:
+ return "Cerknica Commune";
+ case 14:
+ return "Cerkno Commune";
+ case 15:
+ return "Crensovci Commune";
+ case 16:
+ return "Crna na Koroskem Commune";
+ case 17:
+ return "Crnomelj Commune";
+ case 19:
+ return "Divaca Commune";
+ case 20:
+ return "Dobrepolje Commune";
+ case 22:
+ return "Dol pri Ljubljani Commune";
+ case 24:
+ return "Dornava Commune";
+ case 25:
+ return "Dravograd Commune";
+ case 26:
+ return "Duplek Commune";
+ case 27:
+ return "Gorenja vas-Poljane Commune";
+ case 28:
+ return "Gorisnica Commune";
+ case 29:
+ return "Gornja Radgona Commune";
+ case 30:
+ return "Gornji Grad Commune";
+ case 31:
+ return "Gornji Petrovci Commune";
+ case 32:
+ return "Grosuplje Commune";
+ case 34:
+ return "Hrastnik Commune";
+ case 35:
+ return "Hrpelje-Kozina Commune";
+ case 36:
+ return "Idrija Commune";
+ case 37:
+ return "Ig Commune";
+ case 38:
+ return "Ilirska Bistrica Commune";
+ case 39:
+ return "Ivancna Gorica Commune";
+ case 40:
+ return "Izola-Isola Commune";
+ case 42:
+ return "Jursinci Commune";
+ case 44:
+ return "Kanal Commune";
+ case 45:
+ return "Kidricevo Commune";
+ case 46:
+ return "Kobarid Commune";
+ case 47:
+ return "Kobilje Commune";
+ case 49:
+ return "Komen Commune";
+ case 50:
+ return "Koper-Capodistria Urban Commune";
+ case 51:
+ return "Kozje Commune";
+ case 52:
+ return "Kranj Commune";
+ case 53:
+ return "Kranjska Gora Commune";
+ case 54:
+ return "Krsko Commune";
+ case 55:
+ return "Kungota Commune";
+ case 57:
+ return "Lasko Commune";
+ case 61:
+ return "Ljubljana Urban Commune";
+ case 62:
+ return "Ljubno Commune";
+ case 64:
+ return "Logatec Commune";
+ case 66:
+ return "Loski Potok Commune";
+ case 68:
+ return "Lukovica Commune";
+ case 71:
+ return "Medvode Commune";
+ case 72:
+ return "Menges Commune";
+ case 73:
+ return "Metlika Commune";
+ case 74:
+ return "Mezica Commune";
+ case 76:
+ return "Mislinja Commune";
+ case 77:
+ return "Moravce Commune";
+ case 78:
+ return "Moravske Toplice Commune";
+ case 79:
+ return "Mozirje Commune";
+ case 80:
+ return "Murska Sobota Urban Commune";
+ case 81:
+ return "Muta Commune";
+ case 82:
+ return "Naklo Commune";
+ case 83:
+ return "Nazarje Commune";
+ case 84:
+ return "Nova Gorica Urban Commune";
+ case 86:
+ return "Odranci Commune";
+ case 87:
+ return "Ormoz Commune";
+ case 88:
+ return "Osilnica Commune";
+ case 89:
+ return "Pesnica Commune";
+ case 91:
+ return "Pivka Commune";
+ case 92:
+ return "Podcetrtek Commune";
+ case 94:
+ return "Postojna Commune";
+ case 97:
+ return "Puconci Commune";
+ case 98:
+ return "Race-Fram Commune";
+ case 99:
+ return "Radece Commune";
+ case 832:
+ return "Radenci Commune";
+ case 833:
+ return "Radlje ob Dravi Commune";
+ case 834:
+ return "Radovljica Commune";
+ case 837:
+ return "Rogasovci Commune";
+ case 838:
+ return "Rogaska Slatina Commune";
+ case 839:
+ return "Rogatec Commune";
+ case 875:
+ return "Semic Commune";
+ case 876:
+ return "Sencur Commune";
+ case 877:
+ return "Sentilj Commune";
+ case 878:
+ return "Sentjernej Commune";
+ case 880:
+ return "Sevnica Commune";
+ case 881:
+ return "Sezana Commune";
+ case 882:
+ return "Skocjan Commune";
+ case 883:
+ return "Skofja Loka Commune";
+ case 918:
+ return "Skofljica Commune";
+ case 919:
+ return "Slovenj Gradec Urban Commune";
+ case 921:
+ return "Slovenske Konjice Commune";
+ case 922:
+ return "Smarje pri Jelsah Commune";
+ case 923:
+ return "Smartno ob Paki Commune";
+ case 924:
+ return "Sostanj Commune";
+ case 925:
+ return "Starse Commune";
+ case 926:
+ return "Store Commune";
+ case 961:
+ return "Sveti Jurij Commune";
+ case 962:
+ return "Tolmin Commune";
+ case 963:
+ return "Trbovlje Commune";
+ case 964:
+ return "Trebnje Commune";
+ case 965:
+ return "Trzic Commune";
+ case 966:
+ return "Turnisce Commune";
+ case 967:
+ return "Velenje Urban Commune";
+ case 968:
+ return "Velike Lasce Commune";
+ case 1004:
+ return "Vipava Commune";
+ case 1005:
+ return "Vitanje Commune";
+ case 1006:
+ return "Vodice Commune";
+ case 1008:
+ return "Vrhnika Commune";
+ case 1009:
+ return "Vuzenica Commune";
+ case 1010:
+ return "Zagorje ob Savi Commune";
+ case 1012:
+ return "Zavrc Commune";
+ case 1047:
+ return "Zelezniki Commune";
+ case 1048:
+ return "Ziri Commune";
+ case 1049:
+ return "Zrece Commune";
+ case 1050:
+ return "Benedikt Commune";
+ case 1051:
+ return "Bistrica ob Sotli Commune";
+ case 1052:
+ return "Bloke Commune";
+ case 1053:
+ return "Braslovce Commune";
+ case 1054:
+ return "Cankova Commune";
+ case 1055:
+ return "Cerkvenjak Commune";
+ case 1090:
+ return "Destrnik Commune";
+ case 1091:
+ return "Dobje Commune";
+ case 1092:
+ return "Dobrna Commune";
+ case 1093:
+ return "Dobrova-Horjul-Polhov Gradec Commune";
+ case 1094:
+ return "Dobrovnik-Dobronak Commune";
+ case 1095:
+ return "Dolenjske Toplice Commune";
+ case 1096:
+ return "Domzale Commune";
+ case 1097:
+ return "Grad Commune";
+ case 1098:
+ return "Hajdina Commune";
+ case 1133:
+ return "Hoce-Slivnica Commune";
+ case 1134:
+ return "Hodos-Hodos Commune";
+ case 1135:
+ return "Horjul Commune";
+ case 1136:
+ return "Jesenice Commune";
+ case 1137:
+ return "Jezersko Commune";
+ case 1138:
+ return "Kamnik Commune";
+ case 1139:
+ return "Kocevje Commune";
+ case 1140:
+ return "Komenda Commune";
+ case 1141:
+ return "Kostel Commune";
+ case 1176:
+ return "Krizevci Commune";
+ case 1177:
+ return "Kuzma Commune";
+ case 1178:
+ return "Lenart Commune";
+ case 1179:
+ return "Lendava-Lendva Commune";
+ case 1180:
+ return "Litija Commune";
+ case 1181:
+ return "Ljutomer Commune";
+ case 1182:
+ return "Loska Dolina Commune";
+ case 1183:
+ return "Lovrenc na Pohorju Commune";
+ case 1184:
+ return "Luce Commune";
+ case 1219:
+ return "Majsperk Commune";
+ case 1220:
+ return "Maribor Commune";
+ case 1221:
+ return "Markovci Commune";
+ case 1222:
+ return "Miklavz na Dravskem polju Commune";
+ case 1223:
+ return "Miren-Kostanjevica Commune";
+ case 1224:
+ return "Mirna Pec Commune";
+ case 1225:
+ return "Novo mesto Urban Commune";
+ case 1226:
+ return "Oplotnica Commune";
+ case 1227:
+ return "Piran-Pirano Commune";
+ case 1262:
+ return "Podlehnik Commune";
+ case 1263:
+ return "Podvelka Commune";
+ case 1264:
+ return "Polzela Commune";
+ case 1265:
+ return "Prebold Commune";
+ case 1266:
+ return "Preddvor Commune";
+ case 1267:
+ return "Prevalje Commune";
+ case 1268:
+ return "Ptuj Urban Commune";
+ case 1269:
+ return "Ravne na Koroskem Commune";
+ case 1270:
+ return "Razkrizje Commune";
+ case 1305:
+ return "Ribnica Commune";
+ case 1306:
+ return "Ribnica na Pohorju Commune";
+ case 1307:
+ return "Ruse Commune";
+ case 1308:
+ return "Salovci Commune";
+ case 1309:
+ return "Selnica ob Dravi Commune";
+ case 1310:
+ return "Sempeter-Vrtojba Commune";
+ case 1311:
+ return "Sentjur pri Celju Commune";
+ case 1312:
+ return "Slovenska Bistrica Commune";
+ case 1313:
+ return "Smartno pri Litiji Commune";
+ case 1348:
+ return "Sodrazica Commune";
+ case 1349:
+ return "Solcava Commune";
+ case 1350:
+ return "Sveta Ana Commune";
+ case 1351:
+ return "Sveti Andraz v Slovenskih goricah Commune";
+ case 1352:
+ return "Tabor Commune";
+ case 1353:
+ return "Tisina Commune";
+ case 1354:
+ return "Trnovska vas Commune";
+ case 1355:
+ return "Trzin Commune";
+ case 1356:
+ return "Velika Polana Commune";
+ case 1391:
+ return "Verzej Commune";
+ case 1392:
+ return "Videm Commune";
+ case 1393:
+ return "Vojnik Commune";
+ case 1394:
+ return "Vransko Commune";
+ case 1395:
+ return "Zalec Commune";
+ case 1396:
+ return "Zetale Commune";
+ case 1397:
+ return "Zirovnica Commune";
+ case 1398:
+ return "Zuzemberk Commune";
+ case 1399:
+ return "Apace Commune";
+ case 1434:
+ return "Cirkulane Commune";
+ case 1435:
+ return "Gorje";
+ case 1436:
+ return "Kostanjevica na Krki";
+ case 1437:
+ return "Log-Dragomer";
+ case 1438:
+ return "Makole";
+ case 1439:
+ return "Mirna";
+ case 1440:
+ return "Mokronog-Trebelno";
+ case 1441:
+ return "Poljcane";
+ case 1442:
+ return "Recica ob Savinji";
+ case 1477:
+ return "Rence-Vogrsko";
+ case 1478:
+ return "Sentrupert";
+ case 1479:
+ return "Smarjesk Toplice";
+ case 1480:
+ return "Sredisce ob Dravi";
+ case 1481:
+ return "Straza";
+ case 1483:
+ return "Sveti Jurij v Slovenskih Goricah";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SK(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Banska Bystrica";
+ case 2:
+ return "Bratislava";
+ case 3:
+ return "Kosice";
+ case 4:
+ return "Nitra";
+ case 5:
+ return "Presov";
+ case 6:
+ return "Trencin";
+ case 7:
+ return "Trnava";
+ case 8:
+ return "Zilina";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SL(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Eastern";
+ case 2:
+ return "Northern";
+ case 3:
+ return "Southern";
+ case 4:
+ return "Western Area";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Acquaviva";
+ case 2:
+ return "Chiesanuova";
+ case 3:
+ return "Domagnano";
+ case 4:
+ return "Faetano";
+ case 5:
+ return "Fiorentino";
+ case 6:
+ return "Borgo Maggiore";
+ case 7:
+ return "San Marino";
+ case 8:
+ return "Monte Giardino";
+ case 9:
+ return "Serravalle";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Dakar";
+ case 3:
+ return "Diourbel";
+ case 5:
+ return "Tambacounda";
+ case 7:
+ return "Thies";
+ case 9:
+ return "Fatick";
+ case 10:
+ return "Kaolack";
+ case 11:
+ return "Kolda";
+ case 12:
+ return "Ziguinchor";
+ case 13:
+ return "Louga";
+ case 14:
+ return "Saint-Louis";
+ case 15:
+ return "Matam";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Bakool";
+ case 2:
+ return "Banaadir";
+ case 3:
+ return "Bari";
+ case 4:
+ return "Bay";
+ case 5:
+ return "Galguduud";
+ case 6:
+ return "Gedo";
+ case 7:
+ return "Hiiraan";
+ case 8:
+ return "Jubbada Dhexe";
+ case 9:
+ return "Jubbada Hoose";
+ case 10:
+ return "Mudug";
+ case 11:
+ return "Nugaal";
+ case 12:
+ return "Sanaag";
+ case 13:
+ return "Shabeellaha Dhexe";
+ case 14:
+ return "Shabeellaha Hoose";
+ case 16:
+ return "Woqooyi Galbeed";
+ case 18:
+ return "Nugaal";
+ case 19:
+ return "Togdheer";
+ case 20:
+ return "Woqooyi Galbeed";
+ case 21:
+ return "Awdal";
+ case 22:
+ return "Sool";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SR(int region_code) {
+ switch (region_code) {
+ case 10:
+ return "Brokopondo";
+ case 11:
+ return "Commewijne";
+ case 12:
+ return "Coronie";
+ case 13:
+ return "Marowijne";
+ case 14:
+ return "Nickerie";
+ case 15:
+ return "Para";
+ case 16:
+ return "Paramaribo";
+ case 17:
+ return "Saramacca";
+ case 18:
+ return "Sipaliwini";
+ case 19:
+ return "Wanica";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SS(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Central Equatoria";
+ case 2:
+ return "Eastern Equatoria";
+ case 3:
+ return "Jonglei";
+ case 4:
+ return "Lakes";
+ case 5:
+ return "Northern Bahr el Ghazal";
+ case 6:
+ return "Unity";
+ case 7:
+ return "Upper Nile";
+ case 8:
+ return "Warrap";
+ case 9:
+ return "Western Bahr el Ghazal";
+ case 10:
+ return "Western Equatoria";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ST(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Principe";
+ case 2:
+ return "Sao Tome";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SV(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ahuachapan";
+ case 2:
+ return "Cabanas";
+ case 3:
+ return "Chalatenango";
+ case 4:
+ return "Cuscatlan";
+ case 5:
+ return "La Libertad";
+ case 6:
+ return "La Paz";
+ case 7:
+ return "La Union";
+ case 8:
+ return "Morazan";
+ case 9:
+ return "San Miguel";
+ case 10:
+ return "San Salvador";
+ case 11:
+ return "Santa Ana";
+ case 12:
+ return "San Vicente";
+ case 13:
+ return "Sonsonate";
+ case 14:
+ return "Usulutan";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Al Hasakah";
+ case 2:
+ return "Al Ladhiqiyah";
+ case 3:
+ return "Al Qunaytirah";
+ case 4:
+ return "Ar Raqqah";
+ case 5:
+ return "As Suwayda'";
+ case 6:
+ return "Dar";
+ case 7:
+ return "Dayr az Zawr";
+ case 8:
+ return "Rif Dimashq";
+ case 9:
+ return "Halab";
+ case 10:
+ return "Hamah";
+ case 11:
+ return "Hims";
+ case 12:
+ return "Idlib";
+ case 13:
+ return "Dimashq";
+ case 14:
+ return "Tartus";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_SZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Hhohho";
+ case 2:
+ return "Lubombo";
+ case 3:
+ return "Manzini";
+ case 4:
+ return "Shiselweni";
+ case 5:
+ return "Praslin";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TD(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Batha";
+ case 2:
+ return "Biltine";
+ case 3:
+ return "Borkou-Ennedi-Tibesti";
+ case 4:
+ return "Chari-Baguirmi";
+ case 5:
+ return "Guera";
+ case 6:
+ return "Kanem";
+ case 7:
+ return "Lac";
+ case 8:
+ return "Logone Occidental";
+ case 9:
+ return "Logone Oriental";
+ case 10:
+ return "Mayo-Kebbi";
+ case 11:
+ return "Moyen-Chari";
+ case 12:
+ return "Ouaddai";
+ case 13:
+ return "Salamat";
+ case 14:
+ return "Tandjile";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TG(int region_code) {
+ switch (region_code) {
+ case 22:
+ return "Centrale";
+ case 23:
+ return "Kara";
+ case 24:
+ return "Maritime";
+ case 25:
+ return "Plateaux";
+ case 26:
+ return "Savanes";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TH(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Mae Hong Son";
+ case 2:
+ return "Chiang Mai";
+ case 3:
+ return "Chiang Rai";
+ case 4:
+ return "Nan";
+ case 5:
+ return "Lamphun";
+ case 6:
+ return "Lampang";
+ case 7:
+ return "Phrae";
+ case 8:
+ return "Tak";
+ case 9:
+ return "Sukhothai";
+ case 10:
+ return "Uttaradit";
+ case 11:
+ return "Kamphaeng Phet";
+ case 12:
+ return "Phitsanulok";
+ case 13:
+ return "Phichit";
+ case 14:
+ return "Phetchabun";
+ case 15:
+ return "Uthai Thani";
+ case 16:
+ return "Nakhon Sawan";
+ case 17:
+ return "Nong Khai";
+ case 18:
+ return "Loei";
+ case 20:
+ return "Sakon Nakhon";
+ case 21:
+ return "Nakhon Phanom";
+ case 22:
+ return "Khon Kaen";
+ case 23:
+ return "Kalasin";
+ case 24:
+ return "Maha Sarakham";
+ case 25:
+ return "Roi Et";
+ case 26:
+ return "Chaiyaphum";
+ case 27:
+ return "Nakhon Ratchasima";
+ case 28:
+ return "Buriram";
+ case 29:
+ return "Surin";
+ case 30:
+ return "Sisaket";
+ case 31:
+ return "Narathiwat";
+ case 32:
+ return "Chai Nat";
+ case 33:
+ return "Sing Buri";
+ case 34:
+ return "Lop Buri";
+ case 35:
+ return "Ang Thong";
+ case 36:
+ return "Phra Nakhon Si Ayutthaya";
+ case 37:
+ return "Saraburi";
+ case 38:
+ return "Nonthaburi";
+ case 39:
+ return "Pathum Thani";
+ case 40:
+ return "Krung Thep";
+ case 41:
+ return "Phayao";
+ case 42:
+ return "Samut Prakan";
+ case 43:
+ return "Nakhon Nayok";
+ case 44:
+ return "Chachoengsao";
+ case 45:
+ return "Prachin Buri";
+ case 46:
+ return "Chon Buri";
+ case 47:
+ return "Rayong";
+ case 48:
+ return "Chanthaburi";
+ case 49:
+ return "Trat";
+ case 50:
+ return "Kanchanaburi";
+ case 51:
+ return "Suphan Buri";
+ case 52:
+ return "Ratchaburi";
+ case 53:
+ return "Nakhon Pathom";
+ case 54:
+ return "Samut Songkhram";
+ case 55:
+ return "Samut Sakhon";
+ case 56:
+ return "Phetchaburi";
+ case 57:
+ return "Prachuap Khiri Khan";
+ case 58:
+ return "Chumphon";
+ case 59:
+ return "Ranong";
+ case 60:
+ return "Surat Thani";
+ case 61:
+ return "Phangnga";
+ case 62:
+ return "Phuket";
+ case 63:
+ return "Krabi";
+ case 64:
+ return "Nakhon Si Thammarat";
+ case 65:
+ return "Trang";
+ case 66:
+ return "Phatthalung";
+ case 67:
+ return "Satun";
+ case 68:
+ return "Songkhla";
+ case 69:
+ return "Pattani";
+ case 70:
+ return "Yala";
+ case 71:
+ return "Ubon Ratchathani";
+ case 72:
+ return "Yasothon";
+ case 73:
+ return "Nakhon Phanom";
+ case 74:
+ return "Prachin Buri";
+ case 75:
+ return "Ubon Ratchathani";
+ case 76:
+ return "Udon Thani";
+ case 77:
+ return "Amnat Charoen";
+ case 78:
+ return "Mukdahan";
+ case 79:
+ return "Nong Bua Lamphu";
+ case 80:
+ return "Sa Kaeo";
+ case 81:
+ return "Bueng Kan";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TJ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Kuhistoni Badakhshon";
+ case 2:
+ return "Khatlon";
+ case 3:
+ return "Sughd";
+ case 4:
+ return "Dushanbe";
+ case 5:
+ return "Nohiyahoi Tobei Jumhuri";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TL(int region_code) {
+ switch (region_code) {
+ case 6:
+ return "Dili";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ahal";
+ case 2:
+ return "Balkan";
+ case 3:
+ return "Dashoguz";
+ case 4:
+ return "Lebap";
+ case 5:
+ return "Mary";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TN(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Kasserine";
+ case 3:
+ return "Kairouan";
+ case 6:
+ return "Jendouba";
+ case 10:
+ return "Qafsah";
+ case 14:
+ return "El Kef";
+ case 15:
+ return "Al Mahdia";
+ case 16:
+ return "Al Munastir";
+ case 17:
+ return "Bajah";
+ case 18:
+ return "Bizerte";
+ case 19:
+ return "Nabeul";
+ case 22:
+ return "Siliana";
+ case 23:
+ return "Sousse";
+ case 27:
+ return "Ben Arous";
+ case 28:
+ return "Madanin";
+ case 29:
+ return "Gabes";
+ case 31:
+ return "Kebili";
+ case 32:
+ return "Sfax";
+ case 33:
+ return "Sidi Bou Zid";
+ case 34:
+ return "Tataouine";
+ case 35:
+ return "Tozeur";
+ case 36:
+ return "Tunis";
+ case 37:
+ return "Zaghouan";
+ case 38:
+ return "Aiana";
+ case 39:
+ return "Manouba";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TO(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Ha";
+ case 2:
+ return "Tongatapu";
+ case 3:
+ return "Vava";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TR(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Adiyaman";
+ case 3:
+ return "Afyonkarahisar";
+ case 4:
+ return "Agri";
+ case 5:
+ return "Amasya";
+ case 7:
+ return "Antalya";
+ case 8:
+ return "Artvin";
+ case 9:
+ return "Aydin";
+ case 10:
+ return "Balikesir";
+ case 11:
+ return "Bilecik";
+ case 12:
+ return "Bingol";
+ case 13:
+ return "Bitlis";
+ case 14:
+ return "Bolu";
+ case 15:
+ return "Burdur";
+ case 16:
+ return "Bursa";
+ case 17:
+ return "Canakkale";
+ case 19:
+ return "Corum";
+ case 20:
+ return "Denizli";
+ case 21:
+ return "Diyarbakir";
+ case 22:
+ return "Edirne";
+ case 23:
+ return "Elazig";
+ case 24:
+ return "Erzincan";
+ case 25:
+ return "Erzurum";
+ case 26:
+ return "Eskisehir";
+ case 28:
+ return "Giresun";
+ case 31:
+ return "Hatay";
+ case 32:
+ return "Mersin";
+ case 33:
+ return "Isparta";
+ case 34:
+ return "Istanbul";
+ case 35:
+ return "Izmir";
+ case 37:
+ return "Kastamonu";
+ case 38:
+ return "Kayseri";
+ case 39:
+ return "Kirklareli";
+ case 40:
+ return "Kirsehir";
+ case 41:
+ return "Kocaeli";
+ case 43:
+ return "Kutahya";
+ case 44:
+ return "Malatya";
+ case 45:
+ return "Manisa";
+ case 46:
+ return "Kahramanmaras";
+ case 48:
+ return "Mugla";
+ case 49:
+ return "Mus";
+ case 50:
+ return "Nevsehir";
+ case 52:
+ return "Ordu";
+ case 53:
+ return "Rize";
+ case 54:
+ return "Sakarya";
+ case 55:
+ return "Samsun";
+ case 57:
+ return "Sinop";
+ case 58:
+ return "Sivas";
+ case 59:
+ return "Tekirdag";
+ case 60:
+ return "Tokat";
+ case 61:
+ return "Trabzon";
+ case 62:
+ return "Tunceli";
+ case 63:
+ return "Sanliurfa";
+ case 64:
+ return "Usak";
+ case 65:
+ return "Van";
+ case 66:
+ return "Yozgat";
+ case 68:
+ return "Ankara";
+ case 69:
+ return "Gumushane";
+ case 70:
+ return "Hakkari";
+ case 71:
+ return "Konya";
+ case 72:
+ return "Mardin";
+ case 73:
+ return "Nigde";
+ case 74:
+ return "Siirt";
+ case 75:
+ return "Aksaray";
+ case 76:
+ return "Batman";
+ case 77:
+ return "Bayburt";
+ case 78:
+ return "Karaman";
+ case 79:
+ return "Kirikkale";
+ case 80:
+ return "Sirnak";
+ case 81:
+ return "Adana";
+ case 82:
+ return "Cankiri";
+ case 83:
+ return "Gaziantep";
+ case 84:
+ return "Kars";
+ case 85:
+ return "Zonguldak";
+ case 86:
+ return "Ardahan";
+ case 87:
+ return "Bartin";
+ case 88:
+ return "Igdir";
+ case 89:
+ return "Karabuk";
+ case 90:
+ return "Kilis";
+ case 91:
+ return "Osmaniye";
+ case 92:
+ return "Yalova";
+ case 93:
+ return "Duzce";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TT(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Arima";
+ case 2:
+ return "Caroni";
+ case 3:
+ return "Mayaro";
+ case 4:
+ return "Nariva";
+ case 5:
+ return "Port-of-Spain";
+ case 6:
+ return "Saint Andrew";
+ case 7:
+ return "Saint David";
+ case 8:
+ return "Saint George";
+ case 9:
+ return "Saint Patrick";
+ case 10:
+ return "San Fernando";
+ case 11:
+ return "Tobago";
+ case 12:
+ return "Victoria";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Fu-chien";
+ case 2:
+ return "Kao-hsiung";
+ case 3:
+ return "T'ai-pei";
+ case 4:
+ return "T'ai-wan";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_TZ(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Pwani";
+ case 3:
+ return "Dodoma";
+ case 4:
+ return "Iringa";
+ case 5:
+ return "Kigoma";
+ case 6:
+ return "Kilimanjaro";
+ case 7:
+ return "Lindi";
+ case 8:
+ return "Mara";
+ case 9:
+ return "Mbeya";
+ case 10:
+ return "Morogoro";
+ case 11:
+ return "Mtwara";
+ case 12:
+ return "Mwanza";
+ case 13:
+ return "Pemba North";
+ case 14:
+ return "Ruvuma";
+ case 15:
+ return "Shinyanga";
+ case 16:
+ return "Singida";
+ case 17:
+ return "Tabora";
+ case 18:
+ return "Tanga";
+ case 19:
+ return "Kagera";
+ case 20:
+ return "Pemba South";
+ case 21:
+ return "Zanzibar Central";
+ case 22:
+ return "Zanzibar North";
+ case 23:
+ return "Dar es Salaam";
+ case 24:
+ return "Rukwa";
+ case 25:
+ return "Zanzibar Urban";
+ case 26:
+ return "Arusha";
+ case 27:
+ return "Manyara";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_UA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Cherkas'ka Oblast'";
+ case 2:
+ return "Chernihivs'ka Oblast'";
+ case 3:
+ return "Chernivets'ka Oblast'";
+ case 4:
+ return "Dnipropetrovs'ka Oblast'";
+ case 5:
+ return "Donets'ka Oblast'";
+ case 6:
+ return "Ivano-Frankivs'ka Oblast'";
+ case 7:
+ return "Kharkivs'ka Oblast'";
+ case 8:
+ return "Khersons'ka Oblast'";
+ case 9:
+ return "Khmel'nyts'ka Oblast'";
+ case 10:
+ return "Kirovohrads'ka Oblast'";
+ case 11:
+ return "Krym";
+ case 12:
+ return "Kyyiv";
+ case 13:
+ return "Kyyivs'ka Oblast'";
+ case 14:
+ return "Luhans'ka Oblast'";
+ case 15:
+ return "L'vivs'ka Oblast'";
+ case 16:
+ return "Mykolayivs'ka Oblast'";
+ case 17:
+ return "Odes'ka Oblast'";
+ case 18:
+ return "Poltavs'ka Oblast'";
+ case 19:
+ return "Rivnens'ka Oblast'";
+ case 20:
+ return "Sevastopol'";
+ case 21:
+ return "Sums'ka Oblast'";
+ case 22:
+ return "Ternopil's'ka Oblast'";
+ case 23:
+ return "Vinnyts'ka Oblast'";
+ case 24:
+ return "Volyns'ka Oblast'";
+ case 25:
+ return "Zakarpats'ka Oblast'";
+ case 26:
+ return "Zaporiz'ka Oblast'";
+ case 27:
+ return "Zhytomyrs'ka Oblast'";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_UG(int region_code) {
+ switch (region_code) {
+ case 26:
+ return "Apac";
+ case 28:
+ return "Bundibugyo";
+ case 29:
+ return "Bushenyi";
+ case 30:
+ return "Gulu";
+ case 31:
+ return "Hoima";
+ case 33:
+ return "Jinja";
+ case 36:
+ return "Kalangala";
+ case 37:
+ return "Kampala";
+ case 38:
+ return "Kamuli";
+ case 39:
+ return "Kapchorwa";
+ case 40:
+ return "Kasese";
+ case 41:
+ return "Kibale";
+ case 42:
+ return "Kiboga";
+ case 43:
+ return "Kisoro";
+ case 45:
+ return "Kotido";
+ case 46:
+ return "Kumi";
+ case 47:
+ return "Lira";
+ case 50:
+ return "Masindi";
+ case 52:
+ return "Mbarara";
+ case 56:
+ return "Mubende";
+ case 58:
+ return "Nebbi";
+ case 59:
+ return "Ntungamo";
+ case 60:
+ return "Pallisa";
+ case 61:
+ return "Rakai";
+ case 65:
+ return "Adjumani";
+ case 66:
+ return "Bugiri";
+ case 67:
+ return "Busia";
+ case 69:
+ return "Katakwi";
+ case 70:
+ return "Luwero";
+ case 71:
+ return "Masaka";
+ case 72:
+ return "Moyo";
+ case 73:
+ return "Nakasongola";
+ case 74:
+ return "Sembabule";
+ case 76:
+ return "Tororo";
+ case 77:
+ return "Arua";
+ case 78:
+ return "Iganga";
+ case 79:
+ return "Kabarole";
+ case 80:
+ return "Kaberamaido";
+ case 81:
+ return "Kamwenge";
+ case 82:
+ return "Kanungu";
+ case 83:
+ return "Kayunga";
+ case 84:
+ return "Kitgum";
+ case 85:
+ return "Kyenjojo";
+ case 86:
+ return "Mayuge";
+ case 87:
+ return "Mbale";
+ case 88:
+ return "Moroto";
+ case 89:
+ return "Mpigi";
+ case 90:
+ return "Mukono";
+ case 91:
+ return "Nakapiripirit";
+ case 92:
+ return "Pader";
+ case 93:
+ return "Rukungiri";
+ case 94:
+ return "Sironko";
+ case 95:
+ return "Soroti";
+ case 96:
+ return "Wakiso";
+ case 97:
+ return "Yumbe";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_US(int region_code) {
+ switch (region_code) {
+ case 848:
+ return "Armed Forces Americas";
+ case 852:
+ return "Armed Forces Europe, Middle East, & Canada";
+ case 858:
+ return "Alaska";
+ case 859:
+ return "Alabama";
+ case 863:
+ return "Armed Forces Pacific";
+ case 865:
+ return "Arkansas";
+ case 866:
+ return "American Samoa";
+ case 873:
+ return "Arizona";
+ case 934:
+ return "California";
+ case 948:
+ return "Colorado";
+ case 953:
+ return "Connecticut";
+ case 979:
+ return "District of Columbia";
+ case 981:
+ return "Delaware";
+ case 1074:
+ return "Florida";
+ case 1075:
+ return "Federated States of Micronesia";
+ case 1106:
+ return "Georgia";
+ case 1126:
+ return "Guam";
+ case 1157:
+ return "Hawaii";
+ case 1192:
+ return "Iowa";
+ case 1195:
+ return "Idaho";
+ case 1203:
+ return "Illinois";
+ case 1205:
+ return "Indiana";
+ case 1296:
+ return "Kansas";
+ case 1302:
+ return "Kentucky";
+ case 1321:
+ return "Louisiana";
+ case 1364:
+ return "Massachusetts";
+ case 1367:
+ return "Maryland";
+ case 1368:
+ return "Maine";
+ case 1371:
+ return "Marshall Islands";
+ case 1372:
+ return "Michigan";
+ case 1377:
+ return "Minnesota";
+ case 1378:
+ return "Missouri";
+ case 1379:
+ return "Northern Mariana Islands";
+ case 1382:
+ return "Mississippi";
+ case 1383:
+ return "Montana";
+ case 1409:
+ return "North Carolina";
+ case 1410:
+ return "North Dakota";
+ case 1411:
+ return "Nebraska";
+ case 1414:
+ return "New Hampshire";
+ case 1416:
+ return "New Jersey";
+ case 1419:
+ return "New Mexico";
+ case 1428:
+ return "Nevada";
+ case 1431:
+ return "New York";
+ case 1457:
+ return "Ohio";
+ case 1460:
+ return "Oklahoma";
+ case 1467:
+ return "Oregon";
+ case 1493:
+ return "Pennsylvania";
+ case 1515:
+ return "Palau";
+ case 1587:
+ return "Rhode Island";
+ case 1624:
+ return "South Carolina";
+ case 1625:
+ return "South Dakota";
+ case 1678:
+ return "Tennessee";
+ case 1688:
+ return "Texas";
+ case 1727:
+ return "Utah";
+ case 1751:
+ return "Virginia";
+ case 1759:
+ return "Virgin Islands";
+ case 1770:
+ return "Vermont";
+ case 1794:
+ return "Washington";
+ case 1802:
+ return "Wisconsin";
+ case 1815:
+ return "West Virginia";
+ case 1818:
+ return "Wyoming";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_UY(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Artigas";
+ case 2:
+ return "Canelones";
+ case 3:
+ return "Cerro Largo";
+ case 4:
+ return "Colonia";
+ case 5:
+ return "Durazno";
+ case 6:
+ return "Flores";
+ case 7:
+ return "Florida";
+ case 8:
+ return "Lavalleja";
+ case 9:
+ return "Maldonado";
+ case 10:
+ return "Montevideo";
+ case 11:
+ return "Paysandu";
+ case 12:
+ return "Rio Negro";
+ case 13:
+ return "Rivera";
+ case 14:
+ return "Rocha";
+ case 15:
+ return "Salto";
+ case 16:
+ return "San Jose";
+ case 17:
+ return "Soriano";
+ case 18:
+ return "Tacuarembo";
+ case 19:
+ return "Treinta y Tres";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_UZ(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Andijon";
+ case 2:
+ return "Bukhoro";
+ case 3:
+ return "Farghona";
+ case 4:
+ return "Jizzakh";
+ case 5:
+ return "Khorazm";
+ case 6:
+ return "Namangan";
+ case 7:
+ return "Nawoiy";
+ case 8:
+ return "Qashqadaryo";
+ case 9:
+ return "Qoraqalpoghiston";
+ case 10:
+ return "Samarqand";
+ case 11:
+ return "Sirdaryo";
+ case 12:
+ return "Surkhondaryo";
+ case 13:
+ return "Toshkent";
+ case 14:
+ return "Toshkent";
+ case 15:
+ return "Jizzax";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_VC(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Charlotte";
+ case 2:
+ return "Saint Andrew";
+ case 3:
+ return "Saint David";
+ case 4:
+ return "Saint George";
+ case 5:
+ return "Saint Patrick";
+ case 6:
+ return "Grenadines";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_VE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Amazonas";
+ case 2:
+ return "Anzoategui";
+ case 3:
+ return "Apure";
+ case 4:
+ return "Aragua";
+ case 5:
+ return "Barinas";
+ case 6:
+ return "Bolivar";
+ case 7:
+ return "Carabobo";
+ case 8:
+ return "Cojedes";
+ case 9:
+ return "Delta Amacuro";
+ case 11:
+ return "Falcon";
+ case 12:
+ return "Guarico";
+ case 13:
+ return "Lara";
+ case 14:
+ return "Merida";
+ case 15:
+ return "Miranda";
+ case 16:
+ return "Monagas";
+ case 17:
+ return "Nueva Esparta";
+ case 18:
+ return "Portuguesa";
+ case 19:
+ return "Sucre";
+ case 20:
+ return "Tachira";
+ case 21:
+ return "Trujillo";
+ case 22:
+ return "Yaracuy";
+ case 23:
+ return "Zulia";
+ case 24:
+ return "Dependencias Federales";
+ case 25:
+ return "Distrito Federal";
+ case 26:
+ return "Vargas";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_VN(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "An Giang";
+ case 3:
+ return "Ben Tre";
+ case 5:
+ return "Cao Bang";
+ case 9:
+ return "Dong Thap";
+ case 13:
+ return "Hai Phong";
+ case 20:
+ return "Ho Chi Minh";
+ case 21:
+ return "Kien Giang";
+ case 23:
+ return "Lam Dong";
+ case 24:
+ return "Long An";
+ case 30:
+ return "Quang Ninh";
+ case 32:
+ return "Son La";
+ case 33:
+ return "Tay Ninh";
+ case 34:
+ return "Thanh Hoa";
+ case 35:
+ return "Thai Binh";
+ case 37:
+ return "Tien Giang";
+ case 39:
+ return "Lang Son";
+ case 43:
+ return "Dong Nai";
+ case 44:
+ return "Ha Noi";
+ case 45:
+ return "Ba Ria-Vung Tau";
+ case 46:
+ return "Binh Dinh";
+ case 47:
+ return "Binh Thuan";
+ case 49:
+ return "Gia Lai";
+ case 50:
+ return "Ha Giang";
+ case 52:
+ return "Ha Tinh";
+ case 53:
+ return "Hoa Binh";
+ case 54:
+ return "Khanh Hoa";
+ case 55:
+ return "Kon Tum";
+ case 58:
+ return "Nghe An";
+ case 59:
+ return "Ninh Binh";
+ case 60:
+ return "Ninh Thuan";
+ case 61:
+ return "Phu Yen";
+ case 62:
+ return "Quang Binh";
+ case 63:
+ return "Quang Ngai";
+ case 64:
+ return "Quang Tri";
+ case 65:
+ return "Soc Trang";
+ case 66:
+ return "Thua Thien-Hue";
+ case 67:
+ return "Tra Vinh";
+ case 68:
+ return "Tuyen Quang";
+ case 69:
+ return "Vinh Long";
+ case 70:
+ return "Yen Bai";
+ case 71:
+ return "Bac Giang";
+ case 72:
+ return "Bac Kan";
+ case 73:
+ return "Bac Lieu";
+ case 74:
+ return "Bac Ninh";
+ case 75:
+ return "Binh Duong";
+ case 76:
+ return "Binh Phuoc";
+ case 77:
+ return "Ca Mau";
+ case 78:
+ return "Da Nang";
+ case 79:
+ return "Hai Duong";
+ case 80:
+ return "Ha Nam";
+ case 81:
+ return "Hung Yen";
+ case 82:
+ return "Nam Dinh";
+ case 83:
+ return "Phu Tho";
+ case 84:
+ return "Quang Nam";
+ case 85:
+ return "Thai Nguyen";
+ case 86:
+ return "Vinh Phuc";
+ case 87:
+ return "Can Tho";
+ case 88:
+ return "Dac Lak";
+ case 89:
+ return "Lai Chau";
+ case 90:
+ return "Lao Cai";
+ case 91:
+ return "Dak Nong";
+ case 92:
+ return "Dien Bien";
+ case 93:
+ return "Hau Giang";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_VU(int region_code) {
+ switch (region_code) {
+ case 5:
+ return "Ambrym";
+ case 6:
+ return "Aoba";
+ case 7:
+ return "Torba";
+ case 8:
+ return "Efate";
+ case 9:
+ return "Epi";
+ case 10:
+ return "Malakula";
+ case 11:
+ return "Paama";
+ case 12:
+ return "Pentecote";
+ case 13:
+ return "Sanma";
+ case 14:
+ return "Shepherd";
+ case 15:
+ return "Tafea";
+ case 16:
+ return "Malampa";
+ case 17:
+ return "Penama";
+ case 18:
+ return "Shefa";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_WS(int region_code) {
+ switch (region_code) {
+ case 2:
+ return "Aiga-i-le-Tai";
+ case 3:
+ return "Atua";
+ case 4:
+ return "Fa";
+ case 5:
+ return "Gaga";
+ case 6:
+ return "Va";
+ case 7:
+ return "Gagaifomauga";
+ case 8:
+ return "Palauli";
+ case 9:
+ return "Satupa";
+ case 10:
+ return "Tuamasaga";
+ case 11:
+ return "Vaisigano";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_YE(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Abyan";
+ case 2:
+ return "Adan";
+ case 3:
+ return "Al Mahrah";
+ case 4:
+ return "Hadramawt";
+ case 5:
+ return "Shabwah";
+ case 6:
+ return "Lahij";
+ case 7:
+ return "Al Bayda'";
+ case 8:
+ return "Al Hudaydah";
+ case 9:
+ return "Al Jawf";
+ case 10:
+ return "Al Mahwit";
+ case 11:
+ return "Dhamar";
+ case 12:
+ return "Hajjah";
+ case 13:
+ return "Ibb";
+ case 14:
+ return "Ma'rib";
+ case 15:
+ return "Sa'dah";
+ case 16:
+ return "San'a'";
+ case 17:
+ return "Taizz";
+ case 18:
+ return "Ad Dali";
+ case 19:
+ return "Amran";
+ case 20:
+ return "Al Bayda'";
+ case 21:
+ return "Al Jawf";
+ case 22:
+ return "Hajjah";
+ case 23:
+ return "Ibb";
+ case 24:
+ return "Lahij";
+ case 25:
+ return "Taizz";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ZA(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "North-Western Province";
+ case 2:
+ return "KwaZulu-Natal";
+ case 3:
+ return "Free State";
+ case 5:
+ return "Eastern Cape";
+ case 6:
+ return "Gauteng";
+ case 7:
+ return "Mpumalanga";
+ case 8:
+ return "Northern Cape";
+ case 9:
+ return "Limpopo";
+ case 10:
+ return "North-West";
+ case 11:
+ return "Western Cape";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ZM(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Western";
+ case 2:
+ return "Central";
+ case 3:
+ return "Eastern";
+ case 4:
+ return "Luapula";
+ case 5:
+ return "Northern";
+ case 6:
+ return "North-Western";
+ case 7:
+ return "Southern";
+ case 8:
+ return "Copperbelt";
+ case 9:
+ return "Lusaka";
+ default:
+ return NULL;
+ }
+}
+
+static const char *get_region_name_ZW(int region_code) {
+ switch (region_code) {
+ case 1:
+ return "Manicaland";
+ case 2:
+ return "Midlands";
+ case 3:
+ return "Mashonaland Central";
+ case 4:
+ return "Mashonaland East";
+ case 5:
+ return "Mashonaland West";
+ case 6:
+ return "Matabeleland North";
+ case 7:
+ return "Matabeleland South";
+ case 8:
+ return "Masvingo";
+ case 9:
+ return "Bulawayo";
+ case 10:
+ return "Harare";
+ default:
+ return NULL;
+ }
+}
+
+const char *GeoIP_region_name_by_code(const char *country_code,
+ const char *region_code) {
+ int region_code2 = -1;
+ if (region_code == NULL) {
+ return NULL;
+ }
+
+ if (((region_code[0] >= 48) && (region_code[0] < (48 + 10))) &&
+ ((region_code[1] >= 48) && (region_code[1] < (48 + 10)))) {
+
+ /* only numbers, that shortens the large switch statements */
+ region_code2 = (region_code[0] - 48) * 10 + region_code[1] - 48;
+ }
+
+ else if ((((region_code[0] >= 65) && (region_code[0] < (65 + 26))) ||
+ ((region_code[0] >= 48) && (region_code[0] < (48 + 10)))) &&
+ (((region_code[1] >= 65) && (region_code[1] < (65 + 26))) ||
+ ((region_code[1] >= 48) && (region_code[1] < (48 + 10))))) {
+
+ region_code2 =
+ (region_code[0] - 48) * (65 + 26 - 48) + region_code[1] - 48 + 100;
+ }
+
+ if (region_code2 == -1) {
+ return NULL;
+ }
+
+ if (strcmp(country_code, "AD") == 0) {
+ return get_region_name_AD(region_code2);
+ }
+ if (strcmp(country_code, "AE") == 0) {
+ return get_region_name_AE(region_code2);
+ }
+ if (strcmp(country_code, "AF") == 0) {
+ return get_region_name_AF(region_code2);
+ }
+ if (strcmp(country_code, "AG") == 0) {
+ return get_region_name_AG(region_code2);
+ }
+ if (strcmp(country_code, "AL") == 0) {
+ return get_region_name_AL(region_code2);
+ }
+ if (strcmp(country_code, "AM") == 0) {
+ return get_region_name_AM(region_code2);
+ }
+ if (strcmp(country_code, "AO") == 0) {
+ return get_region_name_AO(region_code2);
+ }
+ if (strcmp(country_code, "AR") == 0) {
+ return get_region_name_AR(region_code2);
+ }
+ if (strcmp(country_code, "AT") == 0) {
+ return get_region_name_AT(region_code2);
+ }
+ if (strcmp(country_code, "AU") == 0) {
+ return get_region_name_AU(region_code2);
+ }
+ if (strcmp(country_code, "AZ") == 0) {
+ return get_region_name_AZ(region_code2);
+ }
+ if (strcmp(country_code, "BA") == 0) {
+ return get_region_name_BA(region_code2);
+ }
+ if (strcmp(country_code, "BB") == 0) {
+ return get_region_name_BB(region_code2);
+ }
+ if (strcmp(country_code, "BD") == 0) {
+ return get_region_name_BD(region_code2);
+ }
+ if (strcmp(country_code, "BE") == 0) {
+ return get_region_name_BE(region_code2);
+ }
+ if (strcmp(country_code, "BF") == 0) {
+ return get_region_name_BF(region_code2);
+ }
+ if (strcmp(country_code, "BG") == 0) {
+ return get_region_name_BG(region_code2);
+ }
+ if (strcmp(country_code, "BH") == 0) {
+ return get_region_name_BH(region_code2);
+ }
+ if (strcmp(country_code, "BI") == 0) {
+ return get_region_name_BI(region_code2);
+ }
+ if (strcmp(country_code, "BJ") == 0) {
+ return get_region_name_BJ(region_code2);
+ }
+ if (strcmp(country_code, "BM") == 0) {
+ return get_region_name_BM(region_code2);
+ }
+ if (strcmp(country_code, "BN") == 0) {
+ return get_region_name_BN(region_code2);
+ }
+ if (strcmp(country_code, "BO") == 0) {
+ return get_region_name_BO(region_code2);
+ }
+ if (strcmp(country_code, "BR") == 0) {
+ return get_region_name_BR(region_code2);
+ }
+ if (strcmp(country_code, "BS") == 0) {
+ return get_region_name_BS(region_code2);
+ }
+ if (strcmp(country_code, "BT") == 0) {
+ return get_region_name_BT(region_code2);
+ }
+ if (strcmp(country_code, "BW") == 0) {
+ return get_region_name_BW(region_code2);
+ }
+ if (strcmp(country_code, "BY") == 0) {
+ return get_region_name_BY(region_code2);
+ }
+ if (strcmp(country_code, "BZ") == 0) {
+ return get_region_name_BZ(region_code2);
+ }
+ if (strcmp(country_code, "CA") == 0) {
+ return get_region_name_CA(region_code2);
+ }
+ if (strcmp(country_code, "CD") == 0) {
+ return get_region_name_CD(region_code2);
+ }
+ if (strcmp(country_code, "CF") == 0) {
+ return get_region_name_CF(region_code2);
+ }
+ if (strcmp(country_code, "CG") == 0) {
+ return get_region_name_CG(region_code2);
+ }
+ if (strcmp(country_code, "CH") == 0) {
+ return get_region_name_CH(region_code2);
+ }
+ if (strcmp(country_code, "CI") == 0) {
+ return get_region_name_CI(region_code2);
+ }
+ if (strcmp(country_code, "CL") == 0) {
+ return get_region_name_CL(region_code2);
+ }
+ if (strcmp(country_code, "CM") == 0) {
+ return get_region_name_CM(region_code2);
+ }
+ if (strcmp(country_code, "CN") == 0) {
+ return get_region_name_CN(region_code2);
+ }
+ if (strcmp(country_code, "CO") == 0) {
+ return get_region_name_CO(region_code2);
+ }
+ if (strcmp(country_code, "CR") == 0) {
+ return get_region_name_CR(region_code2);
+ }
+ if (strcmp(country_code, "CU") == 0) {
+ return get_region_name_CU(region_code2);
+ }
+ if (strcmp(country_code, "CV") == 0) {
+ return get_region_name_CV(region_code2);
+ }
+ if (strcmp(country_code, "CY") == 0) {
+ return get_region_name_CY(region_code2);
+ }
+ if (strcmp(country_code, "CZ") == 0) {
+ return get_region_name_CZ(region_code2);
+ }
+ if (strcmp(country_code, "DE") == 0) {
+ return get_region_name_DE(region_code2);
+ }
+ if (strcmp(country_code, "DJ") == 0) {
+ return get_region_name_DJ(region_code2);
+ }
+ if (strcmp(country_code, "DK") == 0) {
+ return get_region_name_DK(region_code2);
+ }
+ if (strcmp(country_code, "DM") == 0) {
+ return get_region_name_DM(region_code2);
+ }
+ if (strcmp(country_code, "DO") == 0) {
+ return get_region_name_DO(region_code2);
+ }
+ if (strcmp(country_code, "DZ") == 0) {
+ return get_region_name_DZ(region_code2);
+ }
+ if (strcmp(country_code, "EC") == 0) {
+ return get_region_name_EC(region_code2);
+ }
+ if (strcmp(country_code, "EE") == 0) {
+ return get_region_name_EE(region_code2);
+ }
+ if (strcmp(country_code, "EG") == 0) {
+ return get_region_name_EG(region_code2);
+ }
+ if (strcmp(country_code, "ER") == 0) {
+ return get_region_name_ER(region_code2);
+ }
+ if (strcmp(country_code, "ES") == 0) {
+ return get_region_name_ES(region_code2);
+ }
+ if (strcmp(country_code, "ET") == 0) {
+ return get_region_name_ET(region_code2);
+ }
+ if (strcmp(country_code, "FI") == 0) {
+ return get_region_name_FI(region_code2);
+ }
+ if (strcmp(country_code, "FJ") == 0) {
+ return get_region_name_FJ(region_code2);
+ }
+ if (strcmp(country_code, "FM") == 0) {
+ return get_region_name_FM(region_code2);
+ }
+ if (strcmp(country_code, "FR") == 0) {
+ return get_region_name_FR(region_code2);
+ }
+ if (strcmp(country_code, "GA") == 0) {
+ return get_region_name_GA(region_code2);
+ }
+ if (strcmp(country_code, "GB") == 0) {
+ return get_region_name_GB(region_code2);
+ }
+ if (strcmp(country_code, "GD") == 0) {
+ return get_region_name_GD(region_code2);
+ }
+ if (strcmp(country_code, "GE") == 0) {
+ return get_region_name_GE(region_code2);
+ }
+ if (strcmp(country_code, "GH") == 0) {
+ return get_region_name_GH(region_code2);
+ }
+ if (strcmp(country_code, "GL") == 0) {
+ return get_region_name_GL(region_code2);
+ }
+ if (strcmp(country_code, "GM") == 0) {
+ return get_region_name_GM(region_code2);
+ }
+ if (strcmp(country_code, "GN") == 0) {
+ return get_region_name_GN(region_code2);
+ }
+ if (strcmp(country_code, "GQ") == 0) {
+ return get_region_name_GQ(region_code2);
+ }
+ if (strcmp(country_code, "GR") == 0) {
+ return get_region_name_GR(region_code2);
+ }
+ if (strcmp(country_code, "GT") == 0) {
+ return get_region_name_GT(region_code2);
+ }
+ if (strcmp(country_code, "GW") == 0) {
+ return get_region_name_GW(region_code2);
+ }
+ if (strcmp(country_code, "GY") == 0) {
+ return get_region_name_GY(region_code2);
+ }
+ if (strcmp(country_code, "HN") == 0) {
+ return get_region_name_HN(region_code2);
+ }
+ if (strcmp(country_code, "HR") == 0) {
+ return get_region_name_HR(region_code2);
+ }
+ if (strcmp(country_code, "HT") == 0) {
+ return get_region_name_HT(region_code2);
+ }
+ if (strcmp(country_code, "HU") == 0) {
+ return get_region_name_HU(region_code2);
+ }
+ if (strcmp(country_code, "ID") == 0) {
+ return get_region_name_ID(region_code2);
+ }
+ if (strcmp(country_code, "IE") == 0) {
+ return get_region_name_IE(region_code2);
+ }
+ if (strcmp(country_code, "IL") == 0) {
+ return get_region_name_IL(region_code2);
+ }
+ if (strcmp(country_code, "IN") == 0) {
+ return get_region_name_IN(region_code2);
+ }
+ if (strcmp(country_code, "IQ") == 0) {
+ return get_region_name_IQ(region_code2);
+ }
+ if (strcmp(country_code, "IR") == 0) {
+ return get_region_name_IR(region_code2);
+ }
+ if (strcmp(country_code, "IS") == 0) {
+ return get_region_name_IS(region_code2);
+ }
+ if (strcmp(country_code, "IT") == 0) {
+ return get_region_name_IT(region_code2);
+ }
+ if (strcmp(country_code, "JM") == 0) {
+ return get_region_name_JM(region_code2);
+ }
+ if (strcmp(country_code, "JO") == 0) {
+ return get_region_name_JO(region_code2);
+ }
+ if (strcmp(country_code, "JP") == 0) {
+ return get_region_name_JP(region_code2);
+ }
+ if (strcmp(country_code, "KE") == 0) {
+ return get_region_name_KE(region_code2);
+ }
+ if (strcmp(country_code, "KG") == 0) {
+ return get_region_name_KG(region_code2);
+ }
+ if (strcmp(country_code, "KH") == 0) {
+ return get_region_name_KH(region_code2);
+ }
+ if (strcmp(country_code, "KI") == 0) {
+ return get_region_name_KI(region_code2);
+ }
+ if (strcmp(country_code, "KM") == 0) {
+ return get_region_name_KM(region_code2);
+ }
+ if (strcmp(country_code, "KN") == 0) {
+ return get_region_name_KN(region_code2);
+ }
+ if (strcmp(country_code, "KP") == 0) {
+ return get_region_name_KP(region_code2);
+ }
+ if (strcmp(country_code, "KR") == 0) {
+ return get_region_name_KR(region_code2);
+ }
+ if (strcmp(country_code, "KW") == 0) {
+ return get_region_name_KW(region_code2);
+ }
+ if (strcmp(country_code, "KY") == 0) {
+ return get_region_name_KY(region_code2);
+ }
+ if (strcmp(country_code, "KZ") == 0) {
+ return get_region_name_KZ(region_code2);
+ }
+ if (strcmp(country_code, "LA") == 0) {
+ return get_region_name_LA(region_code2);
+ }
+ if (strcmp(country_code, "LB") == 0) {
+ return get_region_name_LB(region_code2);
+ }
+ if (strcmp(country_code, "LC") == 0) {
+ return get_region_name_LC(region_code2);
+ }
+ if (strcmp(country_code, "LI") == 0) {
+ return get_region_name_LI(region_code2);
+ }
+ if (strcmp(country_code, "LK") == 0) {
+ return get_region_name_LK(region_code2);
+ }
+ if (strcmp(country_code, "LR") == 0) {
+ return get_region_name_LR(region_code2);
+ }
+ if (strcmp(country_code, "LS") == 0) {
+ return get_region_name_LS(region_code2);
+ }
+ if (strcmp(country_code, "LT") == 0) {
+ return get_region_name_LT(region_code2);
+ }
+ if (strcmp(country_code, "LU") == 0) {
+ return get_region_name_LU(region_code2);
+ }
+ if (strcmp(country_code, "LV") == 0) {
+ return get_region_name_LV(region_code2);
+ }
+ if (strcmp(country_code, "LY") == 0) {
+ return get_region_name_LY(region_code2);
+ }
+ if (strcmp(country_code, "MA") == 0) {
+ return get_region_name_MA(region_code2);
+ }
+ if (strcmp(country_code, "MC") == 0) {
+ return get_region_name_MC(region_code2);
+ }
+ if (strcmp(country_code, "MD") == 0) {
+ return get_region_name_MD(region_code2);
+ }
+ if (strcmp(country_code, "MG") == 0) {
+ return get_region_name_MG(region_code2);
+ }
+ if (strcmp(country_code, "MK") == 0) {
+ return get_region_name_MK(region_code2);
+ }
+ if (strcmp(country_code, "ML") == 0) {
+ return get_region_name_ML(region_code2);
+ }
+ if (strcmp(country_code, "MM") == 0) {
+ return get_region_name_MM(region_code2);
+ }
+ if (strcmp(country_code, "MN") == 0) {
+ return get_region_name_MN(region_code2);
+ }
+ if (strcmp(country_code, "MO") == 0) {
+ return get_region_name_MO(region_code2);
+ }
+ if (strcmp(country_code, "MR") == 0) {
+ return get_region_name_MR(region_code2);
+ }
+ if (strcmp(country_code, "MS") == 0) {
+ return get_region_name_MS(region_code2);
+ }
+ if (strcmp(country_code, "MU") == 0) {
+ return get_region_name_MU(region_code2);
+ }
+ if (strcmp(country_code, "MV") == 0) {
+ return get_region_name_MV(region_code2);
+ }
+ if (strcmp(country_code, "MW") == 0) {
+ return get_region_name_MW(region_code2);
+ }
+ if (strcmp(country_code, "MX") == 0) {
+ return get_region_name_MX(region_code2);
+ }
+ if (strcmp(country_code, "MY") == 0) {
+ return get_region_name_MY(region_code2);
+ }
+ if (strcmp(country_code, "MZ") == 0) {
+ return get_region_name_MZ(region_code2);
+ }
+ if (strcmp(country_code, "NA") == 0) {
+ return get_region_name_NA(region_code2);
+ }
+ if (strcmp(country_code, "NE") == 0) {
+ return get_region_name_NE(region_code2);
+ }
+ if (strcmp(country_code, "NG") == 0) {
+ return get_region_name_NG(region_code2);
+ }
+ if (strcmp(country_code, "NI") == 0) {
+ return get_region_name_NI(region_code2);
+ }
+ if (strcmp(country_code, "NL") == 0) {
+ return get_region_name_NL(region_code2);
+ }
+ if (strcmp(country_code, "NO") == 0) {
+ return get_region_name_NO(region_code2);
+ }
+ if (strcmp(country_code, "NP") == 0) {
+ return get_region_name_NP(region_code2);
+ }
+ if (strcmp(country_code, "NR") == 0) {
+ return get_region_name_NR(region_code2);
+ }
+ if (strcmp(country_code, "NZ") == 0) {
+ return get_region_name_NZ(region_code2);
+ }
+ if (strcmp(country_code, "OM") == 0) {
+ return get_region_name_OM(region_code2);
+ }
+ if (strcmp(country_code, "PA") == 0) {
+ return get_region_name_PA(region_code2);
+ }
+ if (strcmp(country_code, "PE") == 0) {
+ return get_region_name_PE(region_code2);
+ }
+ if (strcmp(country_code, "PG") == 0) {
+ return get_region_name_PG(region_code2);
+ }
+ if (strcmp(country_code, "PH") == 0) {
+ return get_region_name_PH(region_code2);
+ }
+ if (strcmp(country_code, "PK") == 0) {
+ return get_region_name_PK(region_code2);
+ }
+ if (strcmp(country_code, "PL") == 0) {
+ return get_region_name_PL(region_code2);
+ }
+ if (strcmp(country_code, "PS") == 0) {
+ return get_region_name_PS(region_code2);
+ }
+ if (strcmp(country_code, "PT") == 0) {
+ return get_region_name_PT(region_code2);
+ }
+ if (strcmp(country_code, "PY") == 0) {
+ return get_region_name_PY(region_code2);
+ }
+ if (strcmp(country_code, "QA") == 0) {
+ return get_region_name_QA(region_code2);
+ }
+ if (strcmp(country_code, "RO") == 0) {
+ return get_region_name_RO(region_code2);
+ }
+ if (strcmp(country_code, "RS") == 0) {
+ return get_region_name_RS(region_code2);
+ }
+ if (strcmp(country_code, "RU") == 0) {
+ return get_region_name_RU(region_code2);
+ }
+ if (strcmp(country_code, "RW") == 0) {
+ return get_region_name_RW(region_code2);
+ }
+ if (strcmp(country_code, "SA") == 0) {
+ return get_region_name_SA(region_code2);
+ }
+ if (strcmp(country_code, "SB") == 0) {
+ return get_region_name_SB(region_code2);
+ }
+ if (strcmp(country_code, "SC") == 0) {
+ return get_region_name_SC(region_code2);
+ }
+ if (strcmp(country_code, "SD") == 0) {
+ return get_region_name_SD(region_code2);
+ }
+ if (strcmp(country_code, "SE") == 0) {
+ return get_region_name_SE(region_code2);
+ }
+ if (strcmp(country_code, "SH") == 0) {
+ return get_region_name_SH(region_code2);
+ }
+ if (strcmp(country_code, "SI") == 0) {
+ return get_region_name_SI(region_code2);
+ }
+ if (strcmp(country_code, "SK") == 0) {
+ return get_region_name_SK(region_code2);
+ }
+ if (strcmp(country_code, "SL") == 0) {
+ return get_region_name_SL(region_code2);
+ }
+ if (strcmp(country_code, "SM") == 0) {
+ return get_region_name_SM(region_code2);
+ }
+ if (strcmp(country_code, "SN") == 0) {
+ return get_region_name_SN(region_code2);
+ }
+ if (strcmp(country_code, "SO") == 0) {
+ return get_region_name_SO(region_code2);
+ }
+ if (strcmp(country_code, "SR") == 0) {
+ return get_region_name_SR(region_code2);
+ }
+ if (strcmp(country_code, "SS") == 0) {
+ return get_region_name_SS(region_code2);
+ }
+ if (strcmp(country_code, "ST") == 0) {
+ return get_region_name_ST(region_code2);
+ }
+ if (strcmp(country_code, "SV") == 0) {
+ return get_region_name_SV(region_code2);
+ }
+ if (strcmp(country_code, "SY") == 0) {
+ return get_region_name_SY(region_code2);
+ }
+ if (strcmp(country_code, "SZ") == 0) {
+ return get_region_name_SZ(region_code2);
+ }
+ if (strcmp(country_code, "TD") == 0) {
+ return get_region_name_TD(region_code2);
+ }
+ if (strcmp(country_code, "TG") == 0) {
+ return get_region_name_TG(region_code2);
+ }
+ if (strcmp(country_code, "TH") == 0) {
+ return get_region_name_TH(region_code2);
+ }
+ if (strcmp(country_code, "TJ") == 0) {
+ return get_region_name_TJ(region_code2);
+ }
+ if (strcmp(country_code, "TL") == 0) {
+ return get_region_name_TL(region_code2);
+ }
+ if (strcmp(country_code, "TM") == 0) {
+ return get_region_name_TM(region_code2);
+ }
+ if (strcmp(country_code, "TN") == 0) {
+ return get_region_name_TN(region_code2);
+ }
+ if (strcmp(country_code, "TO") == 0) {
+ return get_region_name_TO(region_code2);
+ }
+ if (strcmp(country_code, "TR") == 0) {
+ return get_region_name_TR(region_code2);
+ }
+ if (strcmp(country_code, "TT") == 0) {
+ return get_region_name_TT(region_code2);
+ }
+ if (strcmp(country_code, "TW") == 0) {
+ return get_region_name_TW(region_code2);
+ }
+ if (strcmp(country_code, "TZ") == 0) {
+ return get_region_name_TZ(region_code2);
+ }
+ if (strcmp(country_code, "UA") == 0) {
+ return get_region_name_UA(region_code2);
+ }
+ if (strcmp(country_code, "UG") == 0) {
+ return get_region_name_UG(region_code2);
+ }
+ if (strcmp(country_code, "US") == 0) {
+ return get_region_name_US(region_code2);
+ }
+ if (strcmp(country_code, "UY") == 0) {
+ return get_region_name_UY(region_code2);
+ }
+ if (strcmp(country_code, "UZ") == 0) {
+ return get_region_name_UZ(region_code2);
+ }
+ if (strcmp(country_code, "VC") == 0) {
+ return get_region_name_VC(region_code2);
+ }
+ if (strcmp(country_code, "VE") == 0) {
+ return get_region_name_VE(region_code2);
+ }
+ if (strcmp(country_code, "VN") == 0) {
+ return get_region_name_VN(region_code2);
+ }
+ if (strcmp(country_code, "VU") == 0) {
+ return get_region_name_VU(region_code2);
+ }
+ if (strcmp(country_code, "WS") == 0) {
+ return get_region_name_WS(region_code2);
+ }
+ if (strcmp(country_code, "YE") == 0) {
+ return get_region_name_YE(region_code2);
+ }
+ if (strcmp(country_code, "ZA") == 0) {
+ return get_region_name_ZA(region_code2);
+ }
+ if (strcmp(country_code, "ZM") == 0) {
+ return get_region_name_ZM(region_code2);
+ }
+ if (strcmp(country_code, "ZW") == 0) {
+ return get_region_name_ZW(region_code2);
+ }
+ return NULL;
+}
diff --git a/libGeoIP/timeZone.c b/libGeoIP/timeZone.c
new file mode 100644
index 0000000..cc30619
--- /dev/null
+++ b/libGeoIP/timeZone.c
@@ -0,0 +1,1775 @@
+#include <string.h>
+const char *GeoIP_time_zone_by_country_and_region(const char *country,
+ const char *region) {
+ const char *timezone = NULL;
+ if (country == NULL) {
+ return NULL;
+ }
+ if (region == NULL) {
+ region = "";
+ }
+ if (strcmp(country, "AD") == 0) {
+ return "Europe/Andorra";
+ }
+ if (strcmp(country, "AE") == 0) {
+ return "Asia/Dubai";
+ }
+ if (strcmp(country, "AF") == 0) {
+ return "Asia/Kabul";
+ }
+ if (strcmp(country, "AG") == 0) {
+ return "America/Antigua";
+ }
+ if (strcmp(country, "AI") == 0) {
+ return "America/Anguilla";
+ }
+ if (strcmp(country, "AL") == 0) {
+ return "Europe/Tirane";
+ }
+ if (strcmp(country, "AM") == 0) {
+ return "Asia/Yerevan";
+ }
+ if (strcmp(country, "AN") == 0) {
+ return "America/Curacao";
+ }
+ if (strcmp(country, "AO") == 0) {
+ return "Africa/Luanda";
+ }
+ if (strcmp(country, "AQ") == 0) {
+ return "Antarctica/South_Pole";
+ }
+ if (strcmp(country, "AR") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "02") == 0) {
+ return "America/Argentina/Catamarca";
+ } else if (strcmp(region, "03") == 0) {
+ return "America/Argentina/Tucuman";
+ } else if (strcmp(region, "04") == 0) {
+ return "America/Argentina/Rio_Gallegos";
+ } else if (strcmp(region, "05") == 0) {
+ return "America/Argentina/Cordoba";
+ } else if (strcmp(region, "06") == 0) {
+ return "America/Argentina/Tucuman";
+ } else if (strcmp(region, "07") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "08") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "09") == 0) {
+ return "America/Argentina/Tucuman";
+ } else if (strcmp(region, "10") == 0) {
+ return "America/Argentina/Jujuy";
+ } else if (strcmp(region, "11") == 0) {
+ return "America/Argentina/San_Luis";
+ } else if (strcmp(region, "12") == 0) {
+ return "America/Argentina/La_Rioja";
+ } else if (strcmp(region, "13") == 0) {
+ return "America/Argentina/Mendoza";
+ } else if (strcmp(region, "14") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "15") == 0) {
+ return "America/Argentina/San_Luis";
+ } else if (strcmp(region, "16") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "17") == 0) {
+ return "America/Argentina/Salta";
+ } else if (strcmp(region, "18") == 0) {
+ return "America/Argentina/San_Juan";
+ } else if (strcmp(region, "19") == 0) {
+ return "America/Argentina/San_Luis";
+ } else if (strcmp(region, "20") == 0) {
+ return "America/Argentina/Rio_Gallegos";
+ } else if (strcmp(region, "21") == 0) {
+ return "America/Argentina/Buenos_Aires";
+ } else if (strcmp(region, "22") == 0) {
+ return "America/Argentina/Catamarca";
+ } else if (strcmp(region, "23") == 0) {
+ return "America/Argentina/Ushuaia";
+ } else if (strcmp(region, "24") == 0) {
+ return "America/Argentina/Tucuman";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "AS") == 0) {
+ return "Pacific/Pago_Pago";
+ }
+ if (strcmp(country, "AT") == 0) {
+ return "Europe/Vienna";
+ }
+ if (strcmp(country, "AU") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Australia/Sydney";
+ } else if (strcmp(region, "02") == 0) {
+ return "Australia/Sydney";
+ } else if (strcmp(region, "03") == 0) {
+ return "Australia/Darwin";
+ } else if (strcmp(region, "04") == 0) {
+ return "Australia/Brisbane";
+ } else if (strcmp(region, "05") == 0) {
+ return "Australia/Adelaide";
+ } else if (strcmp(region, "06") == 0) {
+ return "Australia/Hobart";
+ } else if (strcmp(region, "07") == 0) {
+ return "Australia/Melbourne";
+ } else if (strcmp(region, "08") == 0) {
+ return "Australia/Perth";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "AW") == 0) {
+ return "America/Aruba";
+ }
+ if (strcmp(country, "AX") == 0) {
+ return "Europe/Mariehamn";
+ }
+ if (strcmp(country, "AZ") == 0) {
+ return "Asia/Baku";
+ }
+ if (strcmp(country, "BA") == 0) {
+ return "Europe/Sarajevo";
+ }
+ if (strcmp(country, "BB") == 0) {
+ return "America/Barbados";
+ }
+ if (strcmp(country, "BD") == 0) {
+ return "Asia/Dhaka";
+ }
+ if (strcmp(country, "BE") == 0) {
+ return "Europe/Brussels";
+ }
+ if (strcmp(country, "BF") == 0) {
+ return "Africa/Ouagadougou";
+ }
+ if (strcmp(country, "BG") == 0) {
+ return "Europe/Sofia";
+ }
+ if (strcmp(country, "BH") == 0) {
+ return "Asia/Bahrain";
+ }
+ if (strcmp(country, "BI") == 0) {
+ return "Africa/Bujumbura";
+ }
+ if (strcmp(country, "BJ") == 0) {
+ return "Africa/Porto-Novo";
+ }
+ if (strcmp(country, "BL") == 0) {
+ return "America/St_Barthelemy";
+ }
+ if (strcmp(country, "BM") == 0) {
+ return "Atlantic/Bermuda";
+ }
+ if (strcmp(country, "BN") == 0) {
+ return "Asia/Brunei";
+ }
+ if (strcmp(country, "BO") == 0) {
+ return "America/La_Paz";
+ }
+ if (strcmp(country, "BQ") == 0) {
+ return "America/Curacao";
+ }
+ if (strcmp(country, "BR") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "America/Rio_Branco";
+ } else if (strcmp(region, "02") == 0) {
+ return "America/Maceio";
+ } else if (strcmp(region, "03") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "04") == 0) {
+ return "America/Manaus";
+ } else if (strcmp(region, "05") == 0) {
+ return "America/Bahia";
+ } else if (strcmp(region, "06") == 0) {
+ return "America/Fortaleza";
+ } else if (strcmp(region, "07") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "08") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "11") == 0) {
+ return "America/Campo_Grande";
+ } else if (strcmp(region, "13") == 0) {
+ return "America/Belem";
+ } else if (strcmp(region, "14") == 0) {
+ return "America/Cuiaba";
+ } else if (strcmp(region, "15") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "16") == 0) {
+ return "America/Belem";
+ } else if (strcmp(region, "17") == 0) {
+ return "America/Recife";
+ } else if (strcmp(region, "18") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "20") == 0) {
+ return "America/Fortaleza";
+ } else if (strcmp(region, "21") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "22") == 0) {
+ return "America/Recife";
+ } else if (strcmp(region, "23") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "24") == 0) {
+ return "America/Porto_Velho";
+ } else if (strcmp(region, "25") == 0) {
+ return "America/Boa_Vista";
+ } else if (strcmp(region, "26") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "27") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "28") == 0) {
+ return "America/Maceio";
+ } else if (strcmp(region, "29") == 0) {
+ return "America/Sao_Paulo";
+ } else if (strcmp(region, "30") == 0) {
+ return "America/Recife";
+ } else if (strcmp(region, "31") == 0) {
+ return "America/Araguaina";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "BS") == 0) {
+ return "America/Nassau";
+ }
+ if (strcmp(country, "BT") == 0) {
+ return "Asia/Thimphu";
+ }
+ if (strcmp(country, "BV") == 0) {
+ return "Antarctica/Syowa";
+ }
+ if (strcmp(country, "BW") == 0) {
+ return "Africa/Gaborone";
+ }
+ if (strcmp(country, "BY") == 0) {
+ return "Europe/Minsk";
+ }
+ if (strcmp(country, "BZ") == 0) {
+ return "America/Belize";
+ }
+ if (strcmp(country, "CA") == 0) {
+ if (strcmp(region, "AB") == 0) {
+ return "America/Edmonton";
+ } else if (strcmp(region, "BC") == 0) {
+ return "America/Vancouver";
+ } else if (strcmp(region, "MB") == 0) {
+ return "America/Winnipeg";
+ } else if (strcmp(region, "NB") == 0) {
+ return "America/Halifax";
+ } else if (strcmp(region, "NL") == 0) {
+ return "America/St_Johns";
+ } else if (strcmp(region, "NS") == 0) {
+ return "America/Halifax";
+ } else if (strcmp(region, "NT") == 0) {
+ return "America/Yellowknife";
+ } else if (strcmp(region, "NU") == 0) {
+ return "America/Rankin_Inlet";
+ } else if (strcmp(region, "ON") == 0) {
+ return "America/Toronto";
+ } else if (strcmp(region, "PE") == 0) {
+ return "America/Halifax";
+ } else if (strcmp(region, "QC") == 0) {
+ return "America/Montreal";
+ } else if (strcmp(region, "SK") == 0) {
+ return "America/Regina";
+ } else if (strcmp(region, "YT") == 0) {
+ return "America/Whitehorse";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "CC") == 0) {
+ return "Indian/Cocos";
+ }
+ if (strcmp(country, "CD") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Africa/Kinshasa";
+ } else if (strcmp(region, "02") == 0) {
+ return "Africa/Kinshasa";
+ } else if (strcmp(region, "03") == 0) {
+ return "Africa/Kinshasa";
+ } else if (strcmp(region, "04") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "05") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "06") == 0) {
+ return "Africa/Kinshasa";
+ } else if (strcmp(region, "07") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "08") == 0) {
+ return "Africa/Kinshasa";
+ } else if (strcmp(region, "09") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "10") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "11") == 0) {
+ return "Africa/Lubumbashi";
+ } else if (strcmp(region, "12") == 0) {
+ return "Africa/Lubumbashi";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "CF") == 0) {
+ return "Africa/Bangui";
+ }
+ if (strcmp(country, "CG") == 0) {
+ return "Africa/Brazzaville";
+ }
+ if (strcmp(country, "CH") == 0) {
+ return "Europe/Zurich";
+ }
+ if (strcmp(country, "CI") == 0) {
+ return "Africa/Abidjan";
+ }
+ if (strcmp(country, "CK") == 0) {
+ return "Pacific/Rarotonga";
+ }
+ if (strcmp(country, "CL") == 0) {
+ return "America/Santiago";
+ }
+ if (strcmp(country, "CM") == 0) {
+ return "Africa/Lagos";
+ }
+ if (strcmp(country, "CN") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "02") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "03") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "04") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "05") == 0) {
+ return "Asia/Harbin";
+ } else if (strcmp(region, "06") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "07") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "08") == 0) {
+ return "Asia/Harbin";
+ } else if (strcmp(region, "09") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "10") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "12") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "13") == 0) {
+ return "Asia/Urumqi";
+ } else if (strcmp(region, "14") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "15") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "16") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "18") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "19") == 0) {
+ return "Asia/Harbin";
+ } else if (strcmp(region, "20") == 0) {
+ return "Asia/Harbin";
+ } else if (strcmp(region, "21") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "22") == 0) {
+ return "Asia/Harbin";
+ } else if (strcmp(region, "23") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "24") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "25") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "26") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "28") == 0) {
+ return "Asia/Shanghai";
+ } else if (strcmp(region, "29") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "30") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "31") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "32") == 0) {
+ return "Asia/Chongqing";
+ } else if (strcmp(region, "33") == 0) {
+ return "Asia/Chongqing";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "CO") == 0) {
+ return "America/Bogota";
+ }
+ if (strcmp(country, "CR") == 0) {
+ return "America/Costa_Rica";
+ }
+ if (strcmp(country, "CU") == 0) {
+ return "America/Havana";
+ }
+ if (strcmp(country, "CV") == 0) {
+ return "Atlantic/Cape_Verde";
+ }
+ if (strcmp(country, "CW") == 0) {
+ return "America/Curacao";
+ }
+ if (strcmp(country, "CX") == 0) {
+ return "Indian/Christmas";
+ }
+ if (strcmp(country, "CY") == 0) {
+ return "Asia/Nicosia";
+ }
+ if (strcmp(country, "CZ") == 0) {
+ return "Europe/Prague";
+ }
+ if (strcmp(country, "DE") == 0) {
+ return "Europe/Berlin";
+ }
+ if (strcmp(country, "DJ") == 0) {
+ return "Africa/Djibouti";
+ }
+ if (strcmp(country, "DK") == 0) {
+ return "Europe/Copenhagen";
+ }
+ if (strcmp(country, "DM") == 0) {
+ return "America/Dominica";
+ }
+ if (strcmp(country, "DO") == 0) {
+ return "America/Santo_Domingo";
+ }
+ if (strcmp(country, "DZ") == 0) {
+ return "Africa/Algiers";
+ }
+ if (strcmp(country, "EC") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Pacific/Galapagos";
+ } else if (strcmp(region, "02") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "03") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "04") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "05") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "06") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "07") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "08") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "09") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "10") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "11") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "12") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "13") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "14") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "15") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "17") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "18") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "19") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "20") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "22") == 0) {
+ return "America/Guayaquil";
+ } else if (strcmp(region, "24") == 0) {
+ return "America/Guayaquil";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "EE") == 0) {
+ return "Europe/Tallinn";
+ }
+ if (strcmp(country, "EG") == 0) {
+ return "Africa/Cairo";
+ }
+ if (strcmp(country, "EH") == 0) {
+ return "Africa/El_Aaiun";
+ }
+ if (strcmp(country, "ER") == 0) {
+ return "Africa/Asmara";
+ }
+ if (strcmp(country, "ES") == 0) {
+ if (strcmp(region, "07") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "27") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "29") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "31") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "32") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "34") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "39") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "51") == 0) {
+ return "Africa/Ceuta";
+ } else if (strcmp(region, "52") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "53") == 0) {
+ return "Atlantic/Canary";
+ } else if (strcmp(region, "54") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "55") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "56") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "57") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "58") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "59") == 0) {
+ return "Europe/Madrid";
+ } else if (strcmp(region, "60") == 0) {
+ return "Europe/Madrid";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "ET") == 0) {
+ return "Africa/Addis_Ababa";
+ }
+ if (strcmp(country, "FI") == 0) {
+ return "Europe/Helsinki";
+ }
+ if (strcmp(country, "FJ") == 0) {
+ return "Pacific/Fiji";
+ }
+ if (strcmp(country, "FK") == 0) {
+ return "Atlantic/Stanley";
+ }
+ if (strcmp(country, "FM") == 0) {
+ return "Pacific/Pohnpei";
+ }
+ if (strcmp(country, "FO") == 0) {
+ return "Atlantic/Faroe";
+ }
+ if (strcmp(country, "FR") == 0) {
+ return "Europe/Paris";
+ }
+ if (strcmp(country, "FX") == 0) {
+ return "Europe/Paris";
+ }
+ if (strcmp(country, "GA") == 0) {
+ return "Africa/Libreville";
+ }
+ if (strcmp(country, "GB") == 0) {
+ return "Europe/London";
+ }
+ if (strcmp(country, "GD") == 0) {
+ return "America/Grenada";
+ }
+ if (strcmp(country, "GE") == 0) {
+ return "Asia/Tbilisi";
+ }
+ if (strcmp(country, "GF") == 0) {
+ return "America/Cayenne";
+ }
+ if (strcmp(country, "GG") == 0) {
+ return "Europe/Guernsey";
+ }
+ if (strcmp(country, "GH") == 0) {
+ return "Africa/Accra";
+ }
+ if (strcmp(country, "GI") == 0) {
+ return "Europe/Gibraltar";
+ }
+ if (strcmp(country, "GL") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "America/Thule";
+ } else if (strcmp(region, "02") == 0) {
+ return "America/Godthab";
+ } else if (strcmp(region, "03") == 0) {
+ return "America/Godthab";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "GM") == 0) {
+ return "Africa/Banjul";
+ }
+ if (strcmp(country, "GN") == 0) {
+ return "Africa/Conakry";
+ }
+ if (strcmp(country, "GP") == 0) {
+ return "America/Guadeloupe";
+ }
+ if (strcmp(country, "GQ") == 0) {
+ return "Africa/Malabo";
+ }
+ if (strcmp(country, "GR") == 0) {
+ return "Europe/Athens";
+ }
+ if (strcmp(country, "GS") == 0) {
+ return "Atlantic/South_Georgia";
+ }
+ if (strcmp(country, "GT") == 0) {
+ return "America/Guatemala";
+ }
+ if (strcmp(country, "GU") == 0) {
+ return "Pacific/Guam";
+ }
+ if (strcmp(country, "GW") == 0) {
+ return "Africa/Bissau";
+ }
+ if (strcmp(country, "GY") == 0) {
+ return "America/Guyana";
+ }
+ if (strcmp(country, "HK") == 0) {
+ return "Asia/Hong_Kong";
+ }
+ if (strcmp(country, "HN") == 0) {
+ return "America/Tegucigalpa";
+ }
+ if (strcmp(country, "HR") == 0) {
+ return "Europe/Zagreb";
+ }
+ if (strcmp(country, "HT") == 0) {
+ return "America/Port-au-Prince";
+ }
+ if (strcmp(country, "HU") == 0) {
+ return "Europe/Budapest";
+ }
+ if (strcmp(country, "ID") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "02") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "03") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "04") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "05") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "06") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "07") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "08") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "09") == 0) {
+ return "Asia/Jayapura";
+ } else if (strcmp(region, "10") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "12") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "13") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "14") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "15") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "16") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "17") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "18") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "19") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "20") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "21") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "22") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "23") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "24") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "25") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "26") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "28") == 0) {
+ return "Asia/Jayapura";
+ } else if (strcmp(region, "29") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "30") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "31") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "32") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "33") == 0) {
+ return "Asia/Jakarta";
+ } else if (strcmp(region, "34") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "35") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "36") == 0) {
+ return "Asia/Jayapura";
+ } else if (strcmp(region, "37") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "38") == 0) {
+ return "Asia/Makassar";
+ } else if (strcmp(region, "39") == 0) {
+ return "Asia/Jayapura";
+ } else if (strcmp(region, "40") == 0) {
+ return "Asia/Pontianak";
+ } else if (strcmp(region, "41") == 0) {
+ return "Asia/Makassar";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "IE") == 0) {
+ return "Europe/Dublin";
+ }
+ if (strcmp(country, "IL") == 0) {
+ return "Asia/Jerusalem";
+ }
+ if (strcmp(country, "IM") == 0) {
+ return "Europe/Isle_of_Man";
+ }
+ if (strcmp(country, "IN") == 0) {
+ return "Asia/Kolkata";
+ }
+ if (strcmp(country, "IO") == 0) {
+ return "Indian/Chagos";
+ }
+ if (strcmp(country, "IQ") == 0) {
+ return "Asia/Baghdad";
+ }
+ if (strcmp(country, "IR") == 0) {
+ return "Asia/Tehran";
+ }
+ if (strcmp(country, "IS") == 0) {
+ return "Atlantic/Reykjavik";
+ }
+ if (strcmp(country, "IT") == 0) {
+ return "Europe/Rome";
+ }
+ if (strcmp(country, "JE") == 0) {
+ return "Europe/Jersey";
+ }
+ if (strcmp(country, "JM") == 0) {
+ return "America/Jamaica";
+ }
+ if (strcmp(country, "JO") == 0) {
+ return "Asia/Amman";
+ }
+ if (strcmp(country, "JP") == 0) {
+ return "Asia/Tokyo";
+ }
+ if (strcmp(country, "KE") == 0) {
+ return "Africa/Nairobi";
+ }
+ if (strcmp(country, "KG") == 0) {
+ return "Asia/Bishkek";
+ }
+ if (strcmp(country, "KH") == 0) {
+ return "Asia/Phnom_Penh";
+ }
+ if (strcmp(country, "KI") == 0) {
+ return "Pacific/Tarawa";
+ }
+ if (strcmp(country, "KM") == 0) {
+ return "Indian/Comoro";
+ }
+ if (strcmp(country, "KN") == 0) {
+ return "America/St_Kitts";
+ }
+ if (strcmp(country, "KP") == 0) {
+ return "Asia/Pyongyang";
+ }
+ if (strcmp(country, "KR") == 0) {
+ return "Asia/Seoul";
+ }
+ if (strcmp(country, "KW") == 0) {
+ return "Asia/Kuwait";
+ }
+ if (strcmp(country, "KY") == 0) {
+ return "America/Cayman";
+ }
+ if (strcmp(country, "KZ") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Asia/Almaty";
+ } else if (strcmp(region, "02") == 0) {
+ return "Asia/Almaty";
+ } else if (strcmp(region, "03") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "04") == 0) {
+ return "Asia/Aqtobe";
+ } else if (strcmp(region, "05") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "06") == 0) {
+ return "Asia/Aqtau";
+ } else if (strcmp(region, "07") == 0) {
+ return "Asia/Oral";
+ } else if (strcmp(region, "08") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "09") == 0) {
+ return "Asia/Aqtau";
+ } else if (strcmp(region, "10") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Almaty";
+ } else if (strcmp(region, "12") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "13") == 0) {
+ return "Asia/Aqtobe";
+ } else if (strcmp(region, "14") == 0) {
+ return "Asia/Qyzylorda";
+ } else if (strcmp(region, "15") == 0) {
+ return "Asia/Almaty";
+ } else if (strcmp(region, "16") == 0) {
+ return "Asia/Aqtobe";
+ } else if (strcmp(region, "17") == 0) {
+ return "Asia/Almaty";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "LA") == 0) {
+ return "Asia/Vientiane";
+ }
+ if (strcmp(country, "LB") == 0) {
+ return "Asia/Beirut";
+ }
+ if (strcmp(country, "LC") == 0) {
+ return "America/St_Lucia";
+ }
+ if (strcmp(country, "LI") == 0) {
+ return "Europe/Vaduz";
+ }
+ if (strcmp(country, "LK") == 0) {
+ return "Asia/Colombo";
+ }
+ if (strcmp(country, "LR") == 0) {
+ return "Africa/Monrovia";
+ }
+ if (strcmp(country, "LS") == 0) {
+ return "Africa/Maseru";
+ }
+ if (strcmp(country, "LT") == 0) {
+ return "Europe/Vilnius";
+ }
+ if (strcmp(country, "LU") == 0) {
+ return "Europe/Luxembourg";
+ }
+ if (strcmp(country, "LV") == 0) {
+ return "Europe/Riga";
+ }
+ if (strcmp(country, "LY") == 0) {
+ return "Africa/Tripoli";
+ }
+ if (strcmp(country, "MA") == 0) {
+ return "Africa/Casablanca";
+ }
+ if (strcmp(country, "MC") == 0) {
+ return "Europe/Monaco";
+ }
+ if (strcmp(country, "MD") == 0) {
+ return "Europe/Chisinau";
+ }
+ if (strcmp(country, "ME") == 0) {
+ return "Europe/Podgorica";
+ }
+ if (strcmp(country, "MF") == 0) {
+ return "America/Marigot";
+ }
+ if (strcmp(country, "MG") == 0) {
+ return "Indian/Antananarivo";
+ }
+ if (strcmp(country, "MH") == 0) {
+ return "Pacific/Kwajalein";
+ }
+ if (strcmp(country, "MK") == 0) {
+ return "Europe/Skopje";
+ }
+ if (strcmp(country, "ML") == 0) {
+ return "Africa/Bamako";
+ }
+ if (strcmp(country, "MM") == 0) {
+ return "Asia/Rangoon";
+ }
+ if (strcmp(country, "MN") == 0) {
+ if (strcmp(region, "06") == 0) {
+ return "Asia/Choibalsan";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Ulaanbaatar";
+ } else if (strcmp(region, "17") == 0) {
+ return "Asia/Choibalsan";
+ } else if (strcmp(region, "19") == 0) {
+ return "Asia/Hovd";
+ } else if (strcmp(region, "20") == 0) {
+ return "Asia/Ulaanbaatar";
+ } else if (strcmp(region, "21") == 0) {
+ return "Asia/Ulaanbaatar";
+ } else if (strcmp(region, "25") == 0) {
+ return "Asia/Ulaanbaatar";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "MO") == 0) {
+ return "Asia/Macau";
+ }
+ if (strcmp(country, "MP") == 0) {
+ return "Pacific/Saipan";
+ }
+ if (strcmp(country, "MQ") == 0) {
+ return "America/Martinique";
+ }
+ if (strcmp(country, "MR") == 0) {
+ return "Africa/Nouakchott";
+ }
+ if (strcmp(country, "MS") == 0) {
+ return "America/Montserrat";
+ }
+ if (strcmp(country, "MT") == 0) {
+ return "Europe/Malta";
+ }
+ if (strcmp(country, "MU") == 0) {
+ return "Indian/Mauritius";
+ }
+ if (strcmp(country, "MV") == 0) {
+ return "Indian/Maldives";
+ }
+ if (strcmp(country, "MW") == 0) {
+ return "Africa/Blantyre";
+ }
+ if (strcmp(country, "MX") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "02") == 0) {
+ return "America/Tijuana";
+ } else if (strcmp(region, "03") == 0) {
+ return "America/Hermosillo";
+ } else if (strcmp(region, "04") == 0) {
+ return "America/Merida";
+ } else if (strcmp(region, "05") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "06") == 0) {
+ return "America/Chihuahua";
+ } else if (strcmp(region, "07") == 0) {
+ return "America/Monterrey";
+ } else if (strcmp(region, "08") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "09") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "10") == 0) {
+ return "America/Mazatlan";
+ } else if (strcmp(region, "11") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "12") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "13") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "14") == 0) {
+ return "America/Mazatlan";
+ } else if (strcmp(region, "15") == 0) {
+ return "America/Chihuahua";
+ } else if (strcmp(region, "16") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "17") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "18") == 0) {
+ return "America/Mazatlan";
+ } else if (strcmp(region, "19") == 0) {
+ return "America/Monterrey";
+ } else if (strcmp(region, "20") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "21") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "22") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "23") == 0) {
+ return "America/Cancun";
+ } else if (strcmp(region, "24") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "25") == 0) {
+ return "America/Mazatlan";
+ } else if (strcmp(region, "26") == 0) {
+ return "America/Hermosillo";
+ } else if (strcmp(region, "27") == 0) {
+ return "America/Merida";
+ } else if (strcmp(region, "28") == 0) {
+ return "America/Monterrey";
+ } else if (strcmp(region, "29") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "30") == 0) {
+ return "America/Mexico_City";
+ } else if (strcmp(region, "31") == 0) {
+ return "America/Merida";
+ } else if (strcmp(region, "32") == 0) {
+ return "America/Monterrey";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "MY") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "02") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "03") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "04") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "05") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "06") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "07") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "08") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "09") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Kuching";
+ } else if (strcmp(region, "12") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "13") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "14") == 0) {
+ return "Asia/Kuala_Lumpur";
+ } else if (strcmp(region, "15") == 0) {
+ return "Asia/Kuching";
+ } else if (strcmp(region, "16") == 0) {
+ return "Asia/Kuching";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "MZ") == 0) {
+ return "Africa/Maputo";
+ }
+ if (strcmp(country, "NA") == 0) {
+ return "Africa/Windhoek";
+ }
+ if (strcmp(country, "NC") == 0) {
+ return "Pacific/Noumea";
+ }
+ if (strcmp(country, "NE") == 0) {
+ return "Africa/Niamey";
+ }
+ if (strcmp(country, "NF") == 0) {
+ return "Pacific/Norfolk";
+ }
+ if (strcmp(country, "NG") == 0) {
+ return "Africa/Lagos";
+ }
+ if (strcmp(country, "NI") == 0) {
+ return "America/Managua";
+ }
+ if (strcmp(country, "NL") == 0) {
+ return "Europe/Amsterdam";
+ }
+ if (strcmp(country, "NO") == 0) {
+ return "Europe/Oslo";
+ }
+ if (strcmp(country, "NP") == 0) {
+ return "Asia/Kathmandu";
+ }
+ if (strcmp(country, "NR") == 0) {
+ return "Pacific/Nauru";
+ }
+ if (strcmp(country, "NU") == 0) {
+ return "Pacific/Niue";
+ }
+ if (strcmp(country, "NZ") == 0) {
+ if (strcmp(region, "85") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "E7") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "E8") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "E9") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F1") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F2") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F3") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F4") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F5") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F6") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F7") == 0) {
+ return "Pacific/Chatham";
+ } else if (strcmp(region, "F8") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "F9") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "G1") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "G2") == 0) {
+ return "Pacific/Auckland";
+ } else if (strcmp(region, "G3") == 0) {
+ return "Pacific/Auckland";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "OM") == 0) {
+ return "Asia/Muscat";
+ }
+ if (strcmp(country, "PA") == 0) {
+ return "America/Panama";
+ }
+ if (strcmp(country, "PE") == 0) {
+ return "America/Lima";
+ }
+ if (strcmp(country, "PF") == 0) {
+ return "Pacific/Marquesas";
+ }
+ if (strcmp(country, "PG") == 0) {
+ return "Pacific/Port_Moresby";
+ }
+ if (strcmp(country, "PH") == 0) {
+ return "Asia/Manila";
+ }
+ if (strcmp(country, "PK") == 0) {
+ return "Asia/Karachi";
+ }
+ if (strcmp(country, "PL") == 0) {
+ return "Europe/Warsaw";
+ }
+ if (strcmp(country, "PM") == 0) {
+ return "America/Miquelon";
+ }
+ if (strcmp(country, "PN") == 0) {
+ return "Pacific/Pitcairn";
+ }
+ if (strcmp(country, "PR") == 0) {
+ return "America/Puerto_Rico";
+ }
+ if (strcmp(country, "PS") == 0) {
+ return "Asia/Gaza";
+ }
+ if (strcmp(country, "PT") == 0) {
+ if (strcmp(region, "02") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "03") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "04") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "05") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "06") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "07") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "08") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "09") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "10") == 0) {
+ return "Atlantic/Madeira";
+ } else if (strcmp(region, "11") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "13") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "14") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "16") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "17") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "18") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "19") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "20") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "21") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "22") == 0) {
+ return "Europe/Lisbon";
+ } else if (strcmp(region, "23") == 0) {
+ return "Atlantic/Azores";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "PW") == 0) {
+ return "Pacific/Palau";
+ }
+ if (strcmp(country, "PY") == 0) {
+ return "America/Asuncion";
+ }
+ if (strcmp(country, "QA") == 0) {
+ return "Asia/Qatar";
+ }
+ if (strcmp(country, "RE") == 0) {
+ return "Indian/Reunion";
+ }
+ if (strcmp(country, "RO") == 0) {
+ return "Europe/Bucharest";
+ }
+ if (strcmp(country, "RS") == 0) {
+ return "Europe/Belgrade";
+ }
+ if (strcmp(country, "RU") == 0) {
+ if (strcmp(region, "01") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "02") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "03") == 0) {
+ return "Asia/Novokuznetsk";
+ } else if (strcmp(region, "04") == 0) {
+ return "Asia/Novosibirsk";
+ } else if (strcmp(region, "05") == 0) {
+ return "Asia/Vladivostok";
+ } else if (strcmp(region, "06") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "07") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "08") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "09") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "10") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "11") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "12") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "13") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "14") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "15") == 0) {
+ return "Asia/Anadyr";
+ } else if (strcmp(region, "16") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "17") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "18") == 0) {
+ return "Asia/Krasnoyarsk";
+ } else if (strcmp(region, "20") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "21") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "22") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "23") == 0) {
+ return "Europe/Kaliningrad";
+ } else if (strcmp(region, "24") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "25") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "26") == 0) {
+ return "Asia/Kamchatka";
+ } else if (strcmp(region, "27") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "28") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "29") == 0) {
+ return "Asia/Novokuznetsk";
+ } else if (strcmp(region, "30") == 0) {
+ return "Asia/Vladivostok";
+ } else if (strcmp(region, "31") == 0) {
+ return "Asia/Krasnoyarsk";
+ } else if (strcmp(region, "32") == 0) {
+ return "Asia/Omsk";
+ } else if (strcmp(region, "33") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "34") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "35") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "36") == 0) {
+ return "Asia/Anadyr";
+ } else if (strcmp(region, "37") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "38") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "39") == 0) {
+ return "Asia/Krasnoyarsk";
+ } else if (strcmp(region, "40") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "41") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "42") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "43") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "44") == 0) {
+ return "Asia/Magadan";
+ } else if (strcmp(region, "45") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "46") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "47") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "48") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "49") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "50") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "51") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "52") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "53") == 0) {
+ return "Asia/Novosibirsk";
+ } else if (strcmp(region, "54") == 0) {
+ return "Asia/Omsk";
+ } else if (strcmp(region, "55") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "56") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "57") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "58") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "59") == 0) {
+ return "Asia/Vladivostok";
+ } else if (strcmp(region, "60") == 0) {
+ return "Europe/Kaliningrad";
+ } else if (strcmp(region, "61") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "62") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "63") == 0) {
+ return "Asia/Yakutsk";
+ } else if (strcmp(region, "64") == 0) {
+ return "Asia/Sakhalin";
+ } else if (strcmp(region, "65") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "66") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "67") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "68") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "69") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "70") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "71") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "72") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "73") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "74") == 0) {
+ return "Asia/Krasnoyarsk";
+ } else if (strcmp(region, "75") == 0) {
+ return "Asia/Novosibirsk";
+ } else if (strcmp(region, "76") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "77") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "78") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "79") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "80") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "81") == 0) {
+ return "Europe/Samara";
+ } else if (strcmp(region, "82") == 0) {
+ return "Asia/Irkutsk";
+ } else if (strcmp(region, "83") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "84") == 0) {
+ return "Europe/Volgograd";
+ } else if (strcmp(region, "85") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "86") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "87") == 0) {
+ return "Asia/Novosibirsk";
+ } else if (strcmp(region, "88") == 0) {
+ return "Europe/Moscow";
+ } else if (strcmp(region, "89") == 0) {
+ return "Asia/Vladivostok";
+ } else if (strcmp(region, "90") == 0) {
+ return "Asia/Yekaterinburg";
+ } else if (strcmp(region, "91") == 0) {
+ return "Asia/Krasnoyarsk";
+ } else if (strcmp(region, "92") == 0) {
+ return "Asia/Anadyr";
+ } else if (strcmp(region, "93") == 0) {
+ return "Asia/Irkutsk";
+ } else {
+ return NULL;
+ }
+ }
+ if (strcmp(country, "RW") == 0) {
+ return "Africa/Kigali";
+ }
+ if (strcmp(country, "SA") == 0) {
+ return "Asia/Riyadh";
+ }
+ if (strcmp(country, "SB") == 0) {
+ return "Pacific/Guadalcanal";
+ }
+ if (strcmp(country, "SC") == 0) {
+ return "Indian/Mahe";
+ }
+ if (strcmp(country, "SD") == 0) {
+ return "Africa/Khartoum";
+ }
+ if (strcmp(country, "SE") == 0) {
+ return "Europe/Stockholm";
+ }
+ if (strcmp(country, "SG") == 0) {
+ return "Asia/Singapore";
+ }
+ if (strcmp(country, "SH") == 0) {
+ return "Atlantic/St_Helena";
+ }
+ if (strcmp(country, "SI") == 0) {
+ return "Europe/Ljubljana";
+ }
+ if (strcmp(country, "SJ") == 0) {
+ return "Arctic/Longyearbyen";
+ }
+ if (strcmp(country, "SK") == 0) {
+ return "Europe/Bratislava";
+ }
+ if (strcmp(country, "SL") == 0) {
+ return "Africa/Freetown";
+ }
+ if (strcmp(country, "SM") == 0) {
+ return "Europe/San_Marino";
+ }
+ if (strcmp(country, "SN") == 0) {
+ return "Africa/Dakar";
+ }
+ if (strcmp(country, "SO") == 0) {
+ return "Africa/Mogadishu";
+ }
+ if (strcmp(country, "SR") == 0) {
+ return "America/Paramaribo";
+ }
+ if (strcmp(country, "SS") == 0) {
+ return "Africa/Juba";
+ }
+ if (strcmp(country, "ST") == 0) {
+ return "Africa/Sao_Tome";
+ }
+ if (strcmp(country, "SV") == 0) {
+ return "America/El_Salvador";
+ }
+ if (strcmp(country, "SX") == 0) {
+ return "America/Curacao";
+ }
+ if (strcmp(country, "SY") == 0) {
+ return "Asia/Damascus";
+ }
+ if (strcmp(country, "SZ") == 0) {
+ return "Africa/Mbabane";
+ }
+ if (strcmp(country, "TC") == 0) {
+ return "America/Grand_Turk";
+ }
+ if (strcmp(country, "TD") == 0) {
+ return "Africa/Ndjamena";
+ }
+ if (strcmp(country, "TF") == 0) {
+ return "Indian/Kerguelen";
+ }
+ if (strcmp(country, "TG") == 0) {
+ return "Africa/Lome";
+ }
+ if (strcmp(country, "TH") == 0) {
+ return "Asia/Bangkok";
+ }
+ if (strcmp(country, "TJ") == 0) {
+ return "Asia/Dushanbe";
+ }
+ if (strcmp(country, "TK") == 0) {
+ return "Pacific/Fakaofo";
+ }
+ if (strcmp(country, "TL") == 0) {
+ return "Asia/Dili";
+ }
+ if (strcmp(country, "TM") == 0) {
+