1 |
/**
|
2 |
* Navit, a modular navigation system.
|
3 |
* Copyright (C) 2005-2008 Navit Team
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
#include <string.h>
|
21 |
#include <stdio.h>
|
22 |
#include <stdlib.h>
|
23 |
#include <glib.h>
|
24 |
#include "debug.h"
|
25 |
#include "item.h"
|
26 |
#include "country.h"
|
27 |
#include "search.h"
|
28 |
#include "navit_nls.h"
|
29 |
|
30 |
struct country {
|
31 |
int id;
|
32 |
char *car;
|
33 |
char *iso2;
|
34 |
char *iso3;
|
35 |
char *name;
|
36 |
};
|
37 |
|
38 |
static struct country country[]= {
|
39 |
{ 20, "AND", "AD", "AND", /* 020 */ _n("Andorra")},
|
40 |
{784, "UAE", "AE", "ARE", /* 784 */ _n("United Arab Emirates")},
|
41 |
{ 4, "AFG", "AF", "AFG", /* 004 */ _n("Afghanistan")},
|
42 |
{ 28, "AG", "AG", "ATG", /* 028 */ _n("Antigua and Barbuda")},
|
43 |
{660, NULL, "AI", "AIA", /* 660 */ _n("Anguilla")},
|
44 |
{ 8, "AL", "AL", "ALB", /* 008 */ _n("Albania")},
|
45 |
{ 51, "ARM", "AM", "ARM", /* 051 */ _n("Armenia")},
|
46 |
{530, "NA", "AN", "ANT", /* 530 */ _n("Netherlands Antilles")},
|
47 |
{ 24, "ANG", "AO", "AGO", /* 024 */ _n("Angola")},
|
48 |
{ 10, NULL, "AQ", "ATA", /* 010 */ _n("Antarctica")},
|
49 |
{ 32, "RA", "AR", "ARG", /* 032 */ _n("Argentina")},
|
50 |
{ 16, NULL, "AS", "ASM", /* 016 */ _n("American Samoa")},
|
51 |
{ 40, "A", "AT", "AUT", /* 040 */ _n("Austria")},
|
52 |
{ 36, "AUS", "AU", "AUS", /* 036 */ _n("Australia")},
|
53 |
{533, "ARU", "AW", "ABW", /* 533 */ _n("Aruba")},
|
54 |
{248, "AX", "AX", "ALA", /* 248 */ _n("Aland Islands")},
|
55 |
{ 31, "AZ", "AZ", "AZE", /* 031 */ _n("Azerbaijan")},
|
56 |
{ 70, "BiH", "BA", "BIH", /* 070 */ _n("Bosnia and Herzegovina")},
|
57 |
{ 52, "BDS", "BB", "BRB", /* 052 */ _n("Barbados")},
|
58 |
{ 50, "BD", "BD", "BGD", /* 050 */ _n("Bangladesh")},
|
59 |
{ 56, "B", "BE", "BEL", /* 056 */ _n("Belgium")},
|
60 |
{854, "BF", "BF", "BFA", /* 854 */ _n("Burkina Faso")},
|
61 |
{100, "BG", "BG", "BGR", /* 100 */ _n("Bulgaria")},
|
62 |
{ 48, "BRN", "BH", "BHR", /* 048 */ _n("Bahrain")},
|
63 |
{108, "RU", "BI", "BDI", /* 108 */ _n("Burundi")},
|
64 |
{204, "BJ", "BJ", "BEN", /* 204 */ _n("Benin")},
|
65 |
{652, NULL, "BL", "BLM", /* 652 */ _n("Saint Barthelemy")},
|
66 |
{ 60, NULL, "BM", "BMU", /* 060 */ _n("Bermuda")},
|
67 |
{ 96, "BRU", "BN", "BRN", /* 096 */ _n("Brunei Darussalam")},
|
68 |
{ 68, "BOL", "BO", "BOL", /* 068 */ _n("Bolivia")},
|
69 |
{ 76, "BR", "BR", "BRA", /* 076 */ _n("Brazil")},
|
70 |
{ 44, "BS", "BS", "BHS", /* 044 */ _n("Bahamas")},
|
71 |
{ 64, "BHT", "BT", "BTN", /* 064 */ _n("Bhutan")},
|
72 |
{ 74, NULL, "BV", "BVT", /* 074 */ _n("Bouvet Island")},
|
73 |
{ 72, "RB", "BW", "BWA", /* 072 */ _n("Botswana")},
|
74 |
{112, "BY", "BY", "BLR", /* 112 */ _n("Belarus")},
|
75 |
{ 84, "BZ", "BZ", "BLZ", /* 084 */ _n("Belize")},
|
76 |
{124, "CDN", "CA", "CAN", /* 124 */ _n("Canada")},
|
77 |
{166, NULL, "CC", "CCK", /* 166 */ _n("Cocos (Keeling) Islands")},
|
78 |
{180, "CGO", "CD", "COD", /* 180 */ _n("Congo, Democratic Republic of the")},
|
79 |
{140, "RCA", "CF", "CAF", /* 140 */ _n("Central African Republic")},
|
80 |
{178, NULL, "CG", "COG", /* 178 */ _n("Congo")},
|
81 |
{756, "CH", "CH", "CHE", /* 756 */ _n("Switzerland")},
|
82 |
{384, "CI", "CI", "CIV", /* 384 */ _n("Cote d'Ivoire")},
|
83 |
{184, NULL, "CK", "COK", /* 184 */ _n("Cook Islands")},
|
84 |
{152, "RCH", "CL", "CHL", /* 152 */ _n("Chile")},
|
85 |
{120, "CAM", "CM", "CMR", /* 120 */ _n("Cameroon")},
|
86 |
{156, "RC", "CN", "CHN", /* 156 */ _n("China")},
|
87 |
{170, "CO", "CO", "COL", /* 170 */ _n("Colombia")},
|
88 |
{188, "CR", "CR", "CRI", /* 188 */ _n("Costa Rica")},
|
89 |
{192, "C", "CU", "CUB", /* 192 */ _n("Cuba")},
|
90 |
{132, "CV", "CV", "CPV", /* 132 */ _n("Cape Verde")},
|
91 |
{162, NULL, "CX", "CXR", /* 162 */ _n("Christmas Island")},
|
92 |
{196, "CY", "CY", "CYP", /* 196 */ _n("Cyprus")},
|
93 |
{203, "CZ", "CZ", "CZE", /* 203 */ _n("Czech Republic")},
|
94 |
{276, "D", "DE", "DEU", /* 276 */ _n("Germany")},
|
95 |
{262, "DJI", "DJ", "DJI", /* 262 */ _n("Djibouti")},
|
96 |
{208, "DK", "DK", "DNK", /* 208 */ _n("Denmark")},
|
97 |
{212, "WD", "DM", "DMA", /* 212 */ _n("Dominica")},
|
98 |
{214, "DOM", "DO", "DOM", /* 214 */ _n("Dominican Republic")},
|
99 |
{ 12, "DZ", "DZ", "DZA", /* 012 */ _n("Algeria")},
|
100 |
{218, "EC", "EC", "ECU", /* 218 */ _n("Ecuador")},
|
101 |
{233, "EST", "EE", "EST", /* 233 */ _n("Estonia")},
|
102 |
{818, "ET", "EG", "EGY", /* 818 */ _n("Egypt")},
|
103 |
{732, "WSA", "EH", "ESH", /* 732 */ _n("Western Sahara")},
|
104 |
{232, "ER", "ER", "ERI", /* 232 */ _n("Eritrea")},
|
105 |
{724, "E", "ES", "ESP", /* 724 */ _n("Spain")},
|
106 |
{231, "ETH", "ET", "ETH", /* 231 */ _n("Ethiopia")},
|
107 |
{246, "FIN", "FI", "FIN", /* 246 */ _n("Finland")},
|
108 |
{242, "FJI", "FJ", "FJI", /* 242 */ _n("Fiji")},
|
109 |
{238, NULL, "FK", "FLK", /* 238 */ _n("Falkland Islands (Malvinas)")},
|
110 |
{583, "FSM", "FM", "FSM", /* 583 */ _n("Micronesia, Federated States of")},
|
111 |
{234, "FO", "FO", "FRO", /* 234 */ _n("Faroe Islands")},
|
112 |
{250, "F", "FR", "FRA", /* 250 */ _n("France")},
|
113 |
{266, "G", "GA", "GAB", /* 266 */ _n("Gabon")},
|
114 |
{826, "GB", "GB", "GBR", /* 826 */ _n("United Kingdom")},
|
115 |
{308, "WG", "GD", "GRD", /* 308 */ _n("Grenada")},
|
116 |
{268, "GE", "GE", "GEO", /* 268 */ _n("Georgia")},
|
117 |
{254, NULL, "GF", "GUF", /* 254 */ _n("French Guiana")},
|
118 |
{831, NULL, "GG", "GGY", /* 831 */ _n("Guernsey")},
|
119 |
{288, "GH", "GH", "GHA", /* 288 */ _n("Ghana")},
|
120 |
{292, "GBZ", "GI", "GIB", /* 292 */ _n("Gibraltar")},
|
121 |
{304, "KN", "GL", "GRL", /* 304 */ _n("Greenland")},
|
122 |
{270, "WAG", "GM", "GMB", /* 270 */ _n("Gambia")},
|
123 |
{324, "RG", "GN", "GIN", /* 324 */ _n("Guinea")},
|
124 |
{312, NULL, "GP", "GLP", /* 312 */ _n("Guadeloupe")},
|
125 |
{226, "GQ", "GQ", "GNQ", /* 226 */ _n("Equatorial Guinea")},
|
126 |
{300, "GR", "GR", "GRC", /* 300 */ _n("Greece")},
|
127 |
{239, NULL, "GS", "SGS", /* 239 */ _n("South Georgia and the South Sandwich Islands")},
|
128 |
{320, "GCA", "GT", "GTM", /* 320 */ _n("Guatemala")},
|
129 |
{316, NULL, "GU", "GUM", /* 316 */ _n("Guam")},
|
130 |
{624, "GUB", "GW", "GNB", /* 624 */ _n("Guinea-Bissau")},
|
131 |
{328, "GUY", "GY", "GUY", /* 328 */ _n("Guyana")},
|
132 |
{344, "HK", "HK", "HKG", /* 344 */ _n("Hong Kong")},
|
133 |
{334, NULL, "HM", "HMD", /* 334 */ _n("Heard Island and McDonald Islands")},
|
134 |
{340, "HN", "HN", "HND", /* 340 */ _n("Honduras")},
|
135 |
{191, "HR", "HR", "HRV", /* 191 */ _n("Croatia")},
|
136 |
{332, "RH", "HT", "HTI", /* 332 */ _n("Haiti")},
|
137 |
{348, "H", "HU", "HUN", /* 348 */ _n("Hungary")},
|
138 |
{360, "RI", "ID", "IDN", /* 360 */ _n("Indonesia")},
|
139 |
{372, "IRL", "IE", "IRL", /* 372 */ _n("Ireland")},
|
140 |
{376, "IL", "IL", "ISR", /* 376 */ _n("Israel")},
|
141 |
{833, NULL, "IM", "IMN", /* 833 */ _n("Isle of Man")},
|
142 |
{356, "IND", "IN", "IND", /* 356 */ _n("India")},
|
143 |
{ 86, NULL, "IO", "IOT", /* 086 */ _n("British Indian Ocean Territory")},
|
144 |
{368, "IRQ", "IQ", "IRQ", /* 368 */ _n("Iraq")},
|
145 |
{364, "IR", "IR", "IRN", /* 364 */ _n("Iran, Islamic Republic of")},
|
146 |
{352, "IS", "IS", "ISL", /* 352 */ _n("Iceland")},
|
147 |
{380, "I", "IT", "ITA", /* 380 */ _n("Italy")},
|
148 |
{832, NULL, "JE", "JEY", /* 832 */ _n("Jersey")},
|
149 |
{388, "JA", "JM", "JAM", /* 388 */ _n("Jamaica")},
|
150 |
{400, "JOR", "JO", "JOR", /* 400 */ _n("Jordan")},
|
151 |
{392, "J", "JP", "JPN", /* 392 */ _n("Japan")},
|
152 |
{404, "EAK", "KE", "KEN", /* 404 */ _n("Kenya")},
|
153 |
{417, "KS", "KG", "KGZ", /* 417 */ _n("Kyrgyzstan")},
|
154 |
{116, "K", "KH", "KHM", /* 116 */ _n("Cambodia")},
|
155 |
{296, "KIR", "KI", "KIR", /* 296 */ _n("Kiribati")},
|
156 |
{174, "COM", "KM", "COM", /* 174 */ _n("Comoros")},
|
157 |
{659, "KAN", "KN", "KNA", /* 659 */ _n("Saint Kitts and Nevis")},
|
158 |
{408, "KP", "KP", "PRK", /* 408 */ _n("Korea, Democratic People's Republic of")},
|
159 |
{410, "ROK", "KR", "KOR", /* 410 */ _n("Korea, Republic of")},
|
160 |
{414, "KWT", "KW", "KWT", /* 414 */ _n("Kuwait")},
|
161 |
{136, NULL, "KY", "CYM", /* 136 */ _n("Cayman Islands")},
|
162 |
{398, "KZ", "KZ", "KAZ", /* 398 */ _n("Kazakhstan")},
|
163 |
{418, "LAO", "LA", "LAO", /* 418 */ _n("Lao People's Democratic Republic")},
|
164 |
{422, "RL", "LB", "LBN", /* 422 */ _n("Lebanon")},
|
165 |
{662, "WL", "LC", "LCA", /* 662 */ _n("Saint Lucia")},
|
166 |
{438, "FL", "LI", "LIE", /* 438 */ _n("Liechtenstein")},
|
167 |
{144, "CL", "LK", "LKA", /* 144 */ _n("Sri Lanka")},
|
168 |
{430, "LB", "LR", "LBR", /* 430 */ _n("Liberia")},
|
169 |
{426, "LS", "LS", "LSO", /* 426 */ _n("Lesotho")},
|
170 |
{440, "LT", "LT", "LTU", /* 440 */ _n("Lithuania")},
|
171 |
{442, "L", "LU", "LUX", /* 442 */ _n("Luxembourg")},
|
172 |
{428, "LV", "LV", "LVA", /* 428 */ _n("Latvia")},
|
173 |
{434, "LAR", "LY", "LBY", /* 434 */ _n("Libyan Arab Jamahiriya")},
|
174 |
{504, "MA", "MA", "MAR", /* 504 */ _n("Morocco")},
|
175 |
{492, "MC", "MC", "MCO", /* 492 */ _n("Monaco")},
|
176 |
{498, "MD", "MD", "MDA", /* 498 */ _n("Moldova, Republic of")},
|
177 |
{499, "MNE", "ME", "MNE", /* 499 */ _n("Montenegro")},
|
178 |
{663, NULL, "MF", "MAF", /* 663 */ _n("Saint Martin (French part)")},
|
179 |
{450, "RM", "MG", "MDG", /* 450 */ _n("Madagascar")},
|
180 |
{584, "MH", "MH", "MHL", /* 584 */ _n("Marshall Islands")},
|
181 |
{807, "MK", "MK", "MKD", /* 807 */ _n("Macedonia, the former Yugoslav Republic of")},
|
182 |
{466, "RMM", "ML", "MLI", /* 466 */ _n("Mali")},
|
183 |
{104, "MYA", "MM", "MMR", /* 104 */ _n("Myanmar")},
|
184 |
{496, "MGL", "MN", "MNG", /* 496 */ _n("Mongolia")},
|
185 |
{446, NULL, "MO", "MAC", /* 446 */ _n("Macao")},
|
186 |
{580, NULL, "MP", "MNP", /* 580 */ _n("Northern Mariana Islands")},
|
187 |
{474, NULL, "MQ", "MTQ", /* 474 */ _n("Martinique")},
|
188 |
{478, "RIM", "MR", "MRT", /* 478 */ _n("Mauritania")},
|
189 |
{500, NULL, "MS", "MSR", /* 500 */ _n("Montserrat")},
|
190 |
{470, "M", "MT", "MLT", /* 470 */ _n("Malta")},
|
191 |
{480, "MS", "MU", "MUS", /* 480 */ _n("Mauritius")},
|
192 |
{462, "MV", "MV", "MDV", /* 462 */ _n("Maldives")},
|
193 |
{454, "MW", "MW", "MWI", /* 454 */ _n("Malawi")},
|
194 |
{484, "MEX", "MX", "MEX", /* 484 */ _n("Mexico")},
|
195 |
{458, "MAL", "MY", "MYS", /* 458 */ _n("Malaysia")},
|
196 |
{508, "MOC", "MZ", "MOZ", /* 508 */ _n("Mozambique")},
|
197 |
{516, "NAM", "NA", "NAM", /* 516 */ _n("Namibia")},
|
198 |
{540, "NCL", "NC", "NCL", /* 540 */ _n("New Caledonia")},
|
199 |
{562, "RN", "NE", "NER", /* 562 */ _n("Niger")},
|
200 |
{574, NULL, "NF", "NFK", /* 574 */ _n("Norfolk Island")},
|
201 |
{566, "NGR", "NG", "NGA", /* 566 */ _n("Nigeria")},
|
202 |
{558, "NIC", "NI", "NIC", /* 558 */ _n("Nicaragua")},
|
203 |
{528, "NL", "NL", "NLD", /* 528 */ _n("Netherlands")},
|
204 |
{578, "N", "NO", "NOR", /* 578 */ _n("Norway")},
|
205 |
{524, "NEP", "NP", "NPL", /* 524 */ _n("Nepal")},
|
206 |
{520, "NAU", "NR", "NRU", /* 520 */ _n("Nauru")},
|
207 |
{570, NULL, "NU", "NIU", /* 570 */ _n("Niue")},
|
208 |
{554, "NZ", "NZ", "NZL", /* 554 */ _n("New Zealand")},
|
209 |
{512, "OM", "OM", "OMN", /* 512 */ _n("Oman")},
|
210 |
{591, "PA", "PA", "PAN", /* 591 */ _n("Panama")},
|
211 |
{604, "PE", "PE", "PER", /* 604 */ _n("Peru")},
|
212 |
{258, NULL, "PF", "PYF", /* 258 */ _n("French Polynesia")},
|
213 |
{598, "PNG", "PG", "PNG", /* 598 */ _n("Papua New Guinea")},
|
214 |
{608, "RP", "PH", "PHL", /* 608 */ _n("Philippines")},
|
215 |
{586, "PK", "PK", "PAK", /* 586 */ _n("Pakistan")},
|
216 |
{616, "PL", "PL", "POL", /* 616 */ _n("Poland")},
|
217 |
{666, NULL, "PM", "SPM", /* 666 */ _n("Saint Pierre and Miquelon")},
|
218 |
{612, NULL, "PN", "PCN", /* 612 */ _n("Pitcairn")},
|
219 |
{630, "PRI", "PR", "PRI", /* 630 */ _n("Puerto Rico")},
|
220 |
{275, "AUT", "PS", "PSE", /* 275 */ _n("Palestinian Territory, Occupied")},
|
221 |
{620, "P", "PT", "PRT", /* 620 */ _n("Portugal")},
|
222 |
{585, "PAL", "PW", "PLW", /* 585 */ _n("Palau")},
|
223 |
{600, "PY", "PY", "PRY", /* 600 */ _n("Paraguay")},
|
224 |
{634, "Q", "QA", "QAT", /* 634 */ _n("Qatar")},
|
225 |
{638, NULL, "RE", "REU", /* 638 */ _n("Reunion")},
|
226 |
{642, "RO", "RO", "ROU", /* 642 */ _n("Romania")},
|
227 |
{688, "SRB", "RS", "SRB", /* 688 */ _n("Serbia")},
|
228 |
{643, "RUS", "RU", "RUS", /* 643 */ _n("Russian Federation")},
|
229 |
{646, "RWA", "RW", "RWA", /* 646 */ _n("Rwanda")},
|
230 |
{682, "KSA", "SA", "SAU", /* 682 */ _n("Saudi Arabia")},
|
231 |
{ 90, "SOL", "SB", "SLB", /* 090 */ _n("Solomon Islands")},
|
232 |
{690, "SY", "SC", "SYC", /* 690 */ _n("Seychelles")},
|
233 |
{736, "SUD", "SD", "SDN", /* 736 */ _n("Sudan")},
|
234 |
{752, "S", "SE", "SWE", /* 752 */ _n("Sweden")},
|
235 |
{702, "SGP", "SG", "SGP", /* 702 */ _n("Singapore")},
|
236 |
{654, NULL, "SH", "SHN", /* 654 */ _n("Saint Helena")},
|
237 |
{705, "SLO", "SI", "SVN", /* 705 */ _n("Slovenia")},
|
238 |
{744, NULL, "SJ", "SJM", /* 744 */ _n("Svalbard and Jan Mayen")},
|
239 |
{703, "SK", "SK", "SVK", /* 703 */ _n("Slovakia")},
|
240 |
{694, "WAL", "SL", "SLE", /* 694 */ _n("Sierra Leone")},
|
241 |
{674, "RSM", "SM", "SMR", /* 674 */ _n("San Marino")},
|
242 |
{686, "SN", "SN", "SEN", /* 686 */ _n("Senegal")},
|
243 |
{706, "SO", "SO", "SOM", /* 706 */ _n("Somalia")},
|
244 |
{740, "SME", "SR", "SUR", /* 740 */ _n("Suriname")},
|
245 |
{678, "STP", "ST", "STP", /* 678 */ _n("Sao Tome and Principe")},
|
246 |
{222, "ES", "SV", "SLV", /* 222 */ _n("El Salvador")},
|
247 |
{760, "SYR", "SY", "SYR", /* 760 */ _n("Syrian Arab Republic")},
|
248 |
{748, "SD", "SZ", "SWZ", /* 748 */ _n("Swaziland")},
|
249 |
{796, NULL, "TC", "TCA", /* 796 */ _n("Turks and Caicos Islands")},
|
250 |
{148, "TD", "TD", "TCD", /* 148 */ _n("Chad")},
|
251 |
{260, "ARK", "TF", "ATF", /* 260 */ _n("French Southern Territories")},
|
252 |
{768, "RT", "TG", "TGO", /* 768 */ _n("Togo")},
|
253 |
{764, "T", "TH", "THA", /* 764 */ _n("Thailand")},
|
254 |
{762, "TJ", "TJ", "TJK", /* 762 */ _n("Tajikistan")},
|
255 |
{772, NULL, "TK", "TKL", /* 772 */ _n("Tokelau")},
|
256 |
{626, "TL", "TL", "TLS", /* 626 */ _n("Timor-Leste")},
|
257 |
{795, "TM", "TM", "TKM", /* 795 */ _n("Turkmenistan")},
|
258 |
{788, "TN", "TN", "TUN", /* 788 */ _n("Tunisia")},
|
259 |
{776, "TON", "TO", "TON", /* 776 */ _n("Tonga")},
|
260 |
{792, "TR", "TR", "TUR", /* 792 */ _n("Turkey")},
|
261 |
{780, "TT", "TT", "TTO", /* 780 */ _n("Trinidad and Tobago")},
|
262 |
{798, "TUV", "TV", "TUV", /* 798 */ _n("Tuvalu")},
|
263 |
{158, NULL, "TW", "TWN", /* 158 */ _n("Taiwan, Province of China")},
|
264 |
{834, "EAT", "TZ", "TZA", /* 834 */ _n("Tanzania, United Republic of")},
|
265 |
{804, "UA", "UA", "UKR", /* 804 */ _n("Ukraine")},
|
266 |
{800, "EAU", "UG", "UGA", /* 800 */ _n("Uganda")},
|
267 |
{581, NULL, "UM", "UMI", /* 581 */ _n("United States Minor Outlying Islands")},
|
268 |
{840, "USA", "US", "USA", /* 840 */ _n("United States")},
|
269 |
{858, "ROU", "UY", "URY", /* 858 */ _n("Uruguay")},
|
270 |
{860, "UZ", "UZ", "UZB", /* 860 */ _n("Uzbekistan")},
|
271 |
{336, "SCV", "VA", "VAT", /* 336 */ _n("Holy See (Vatican City State)")},
|
272 |
{670, "WV", "VC", "VCT", /* 670 */ _n("Saint Vincent and the Grenadines")},
|
273 |
{862, "YV", "VE", "VEN", /* 862 */ _n("Venezuela")},
|
274 |
{ 92, NULL, "VG", "VGB", /* 092 */ _n("Virgin Islands, British")},
|
275 |
{850, NULL, "VI", "VIR", /* 850 */ _n("Virgin Islands, U.S.")},
|
276 |
{704, "VN", "VN", "VNM", /* 704 */ _n("Viet Nam")},
|
277 |
{548, "VAN", "VU", "VUT", /* 548 */ _n("Vanuatu")},
|
278 |
{876, NULL, "WF", "WLF", /* 876 */ _n("Wallis and Futuna")},
|
279 |
{882, "WS", "WS", "WSM", /* 882 */ _n("Samoa")},
|
280 |
{887, "YAR", "YE", "YEM", /* 887 */ _n("Yemen")},
|
281 |
{175, NULL, "YT", "MYT", /* 175 */ _n("Mayotte")},
|
282 |
{710, "ZA", "ZA", "ZAF", /* 710 */ _n("South Africa") },
|
283 |
{894, "Z", "ZM", "ZMB", /* 894 */ _n("Zambia")},
|
284 |
{716, "ZW", "ZW", "ZWE", /* 716 */ _n("Zimbabwe")},
|
285 |
{999, "*", "*", "*", _n("Unknown")},
|
286 |
};
|
287 |
|
288 |
|
289 |
struct country_search {
|
290 |
struct attr search;
|
291 |
int len;
|
292 |
int partial;
|
293 |
struct item item;
|
294 |
int count;
|
295 |
struct country *country;
|
296 |
enum attr_type attr_next;
|
297 |
};
|
298 |
|
299 |
static int
|
300 |
country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
|
301 |
{
|
302 |
struct country_search *this_=priv_data;
|
303 |
struct country *country=this_->country;
|
304 |
|
305 |
attr->type=attr_type;
|
306 |
switch (attr_type) {
|
307 |
case attr_any:
|
308 |
while (this_->attr_next != attr_none) {
|
309 |
if (country_attr_get(this_, this_->attr_next, attr))
|
310 |
return 1;
|
311 |
}
|
312 |
return 0;
|
313 |
case attr_label:
|
314 |
attr->u.str=gettext(country->name);
|
315 |
this_->attr_next=attr_country_id;
|
316 |
return 1;
|
317 |
case attr_country_id:
|
318 |
attr->u.num=country->id;
|
319 |
this_->attr_next=country->car ? attr_country_car : attr_country_iso2;
|
320 |
return 1;
|
321 |
case attr_country_car:
|
322 |
attr->u.str=country->car;
|
323 |
this_->attr_next=attr_country_iso2;
|
324 |
return attr->u.str ? 1 : 0;
|
325 |
case attr_country_iso2:
|
326 |
attr->u.str=country->iso2;
|
327 |
this_->attr_next=attr_country_iso3;
|
328 |
return 1;
|
329 |
case attr_country_iso3:
|
330 |
attr->u.str=country->iso3;
|
331 |
this_->attr_next=attr_country_name;
|
332 |
return 1;
|
333 |
case attr_country_name:
|
334 |
attr->u.str=gettext(country->name);
|
335 |
this_->attr_next=attr_none;
|
336 |
return 1;
|
337 |
default:
|
338 |
return 0;
|
339 |
}
|
340 |
}
|
341 |
|
342 |
|
343 |
|
344 |
struct item_methods country_meth = {
|
345 |
NULL, /* coord_rewind */
|
346 |
NULL, /* coord_get */
|
347 |
NULL, /* attr_rewind */
|
348 |
country_attr_get, /* attr_get */
|
349 |
};
|
350 |
|
351 |
struct country_search *
|
352 |
country_search_new(struct attr *search, int partial)
|
353 |
{
|
354 |
struct country_search *ret=g_new(struct country_search, 1);
|
355 |
ret->search=*search;
|
356 |
if (search->type != attr_country_id)
|
357 |
ret->len=strlen(search->u.str);
|
358 |
else
|
359 |
ret->len=0;
|
360 |
ret->partial=partial;
|
361 |
ret->count=0;
|
362 |
|
363 |
ret->item.type=type_country_label;
|
364 |
ret->item.id_hi=0;
|
365 |
ret->item.map=NULL;
|
366 |
ret->item.meth=&country_meth;
|
367 |
ret->item.priv_data=ret;
|
368 |
|
369 |
return ret;
|
370 |
}
|
371 |
|
372 |
|
373 |
static int
|
374 |
match(struct country_search *this_, enum attr_type type, const char *name)
|
375 |
{
|
376 |
int ret;
|
377 |
char *s1, *s2;
|
378 |
if (!name)
|
379 |
return 0;
|
380 |
if (this_->search.type != type && this_->search.type != attr_country_all)
|
381 |
return 0;
|
382 |
s1=linguistics_casefold(this_->search.u.str);
|
383 |
s2=linguistics_casefold(name);
|
384 |
ret=linguistics_compare(s2,s1,this_->partial)==0;
|
385 |
g_free(s1);
|
386 |
g_free(s2);
|
387 |
return ret;
|
388 |
}
|
389 |
|
390 |
|
391 |
struct item *
|
392 |
country_search_get_item(struct country_search *this_)
|
393 |
{
|
394 |
for (;;) {
|
395 |
if (this_->count >= sizeof(country)/sizeof(struct country))
|
396 |
return NULL;
|
397 |
this_->country=&country[this_->count++];
|
398 |
if ((this_->search.type == attr_country_id && this_->search.u.num == this_->country->id) ||
|
399 |
match(this_, attr_country_iso3, this_->country->iso3) ||
|
400 |
match(this_, attr_country_iso2, this_->country->iso2) ||
|
401 |
match(this_, attr_country_car, this_->country->car) ||
|
402 |
match(this_, attr_country_name, gettext(this_->country->name))) {
|
403 |
this_->item.id_lo=this_->country->id;
|
404 |
return &this_->item;
|
405 |
}
|
406 |
}
|
407 |
}
|
408 |
|
409 |
static struct attr country_default_attr;
|
410 |
static char iso2[3];
|
411 |
|
412 |
struct attr *
|
413 |
country_default(void)
|
414 |
{
|
415 |
char *lang;
|
416 |
if (country_default_attr.u.str)
|
417 |
return &country_default_attr;
|
418 |
lang=getenv("LANG");
|
419 |
if (!lang || strlen(lang) < 5)
|
420 |
return NULL;
|
421 |
strncpy(iso2, lang+3, 2);
|
422 |
country_default_attr.type=attr_country_iso2;
|
423 |
country_default_attr.u.str=iso2;
|
424 |
return &country_default_attr;
|
425 |
}
|
426 |
|
427 |
void
|
428 |
country_search_destroy(struct country_search *this_)
|
429 |
{
|
430 |
g_free(this_);
|
431 |
}
|