1 #ifdef RCS
2 static char rcsid[]="$Id: country.c,v 1.1.1.1 2000/11/13 02:42:40 holsta Exp $";
3 #endif
4 /******************************************************************************
5 * Internetting Cooperating Programmers
6 * ----------------------------------------------------------------------------
7 *
8 * ____ PROJECT
9 * | _ \ __ _ _ __ ___ ___ _ __
10 * | | | |/ _` | '_ \ / __/ _ \ '__|
11 * | |_| | (_| | | | | (_| __/ |
12 * |____/ \__,_|_| |_|\___\___|_| the IRC bot
13 *
14 * All files in this archive are subject to the GNU General Public License.
15 *
16 * $Source: /cvsroot/dancer/dancer/src/country.c,v $
17 * $Revision: 1.1.1.1 $
18 * $Date: 2000/11/13 02:42:40 $
19 * $Author: holsta $
20 * $State: Exp $
21 * $Locker: $
22 *
23 * ---------------------------------------------------------------------------
24 *****************************************************************************/
25
26 #include "dancer.h"
27 #include "trio.h"
28 #include "strio.h"
29 #include "function.h"
30 #include "user.h"
31 #include "transfer.h"
32 #include "country.h"
33
34 /* --- Global ----------------------------------------------------- */
35
36 char *continents[7] = {
37 "Europe",
38 "Asia",
39 "Africa",
40 "Australia",
41 "North America",
42 "South America",
43 "Antarctica"
44 };
45
46 land countries[] = {
47 {eu, "ad", "Andorra", "Les Valls d'Andorr�"},
48 {as, "ae", "Arab Emirates", "(United Arab Emirates) Al-Imarat Al'Arabiya Al-Muttahida", "Dirham", "AED"},
49 {as, "af", "Afghanistan", "Jamhuria Afghanistan / Dowlat-e Eslami-ye Afghanestan", "Afghani", "AFA"},
50 {sa, "ag", "Artigua", "Artigua-Barbuda"},
51 {as, "ai", "Anguilla", "", "Dollar", "AID"},
52 {eu, "al", "Albania", "Republika e Shqip�ris�", "Lek", "ALL"},
53 {as, "am", "Armenia", "Haikakan", "Dram", "AMD"},
54 {as, "an", "Antilles", "(Netherlands Antilles)", "Guilder", "ANG"},
55 {af, "ao", "Angola", "A Rep�blica de Angola", "Kwanza Reajustado", "AOK"},
56 {an, "aq", "Antarctica", "Antarctica"},
57 {sa, "ar", "Argentina", "Rep�blica Argentina", "Peso", "ARP"},
58 {sa, "as", "American Samoa", "American Samoa"},
59 {eu, "at", "Austria", "Republik �sterreich", "Schilling", "ATS"},
60 {au, "au", "Australia", "The Commonwealth of Australia", "Dollar", "AUD"},
61 {sa, "aw", "Aruba", "Aruba"},
62 {eu, "az", "Azerbaijan", "Azarbaijchan", "Mana", "AZM"},
63 {eu, "ba", "Bosnia", "Bosna i Hercegovina", "Dinar", "BAD"},
64 {sa, "bb", "Barbados", "Barbados", "Dollar", "BBD"},
65 {as, "bd", "Bangladesh", "Gana Praja Tantri Bangla Desh", "Taka", "BDT"},
66 {eu, "be", "Belgium", "Royaume de Belgique / Koninkrijk Belgi", "Franc", "BEF"},
67 {af, "bf", "Burkina Faso", "Burkina Faso / R�publique de Burkina", "Franc", "BFF"},
68 {eu, "bg", "Bulgaria", "Republika Bulgariya", "Lev", "BGL"},
69 {as, "bh", "Bahrain", "Daulat al-Bahrain", "Dinar", "BHD"},
70 {as, "bi", "Burundi", "La R�publique du Burundi / Republika y'Uburundi", "Franc", "BIR"},
71 {af, "bj", "Benin", "La R�plublique du B�nin", "Franc", "BJF"},
72 {sa, "bm", "Bermuda", "Bermuda (British)", "Dollar", "BMD"},
73 {as, "bn", "Brunei", "Negara Brunei Darussalam", "Dollar", "BND"},
74 {sa, "bo", "Bolivia", "R�publica de Bolivia", "Bolivianos", "BOB"},
75 {sa, "br", "Brazil", "A Rep�blica Federativa do Brasil", "Real", "BRC"},
76 {sa, "bs", "Bahamas", "The Commonwealth of Bahamas", "Dollar", "BSD"},
77 {as, "bt", "Bhutan", "Druk-yul", "Ngultrum", "BTN"},
78 {eu, "bv", "Bouvet", "(Bouvet Island)"},
79 {af, "bw", "Botswana", "Republic of Botswana", "Pula", "BWP"},
80 {as, "by", "Belarus", "Republika Belarus", "Ruble", "BYR"},
81 {sa, "bz", "Belize", "Belize", "Dollar", "BZD"},
82 {na, "ca", "Canada", "Canada", "Dollar", "CAD"},
83 {sa, "cc", "Cocos", "Territory of Cocos (Keeling) Islands"},
84 {af, "cd", "Congo", "The Democratic Republic of Congo"},
85 {af, "cf", "Central African", "La R�publique Centrafricaine", "Franc", "CFF"},
86 {af, "cg", "Congo", "La R�publique populaire du Congo", "Franc", "CGF"},
87 {eu, "ch", "Switzerland", "Schweizerische Eidgeno�enschaft / Conf�d�ration Suisse / Confederazione Svizzera / Confederaziun Helvetica", "Franc", "CHF"},
88 {af, "ci", "Cote D'Ivoire", "La R�publique de la C�te d'Ivoire", "Franc", "CIF"},
89 {af, "ck", "Cook", "(Cook Islands)", "Dollar", "CKD"},
90 {sa, "cl", "Chile", "Rep�blica de Chile", "Pesos", "CLP"},
91 {af, "cm", "Cameroon", "La R�publique unie du Cameroun", "Franc", "CMF"},
92 {as, "cn", "China", "Zhonghua Renmin Gongheguo", "Yuan", "CNY"},
93 {sa, "co", "Colombia", "La Rep�blica de Colombia", "Peso", "COP"},
94 {sa, "cr", "Costa Rica", "Rep�blica de Costa Rica", "Colone", "CRC"},
95 {eu, "cs", "Czechoslovakia", "Czechoslovakia"},
96 {sa, "cu", "Cuba", "La Rep�blica de Cuba", "Peso", "CUP"},
97 {af, "cv", "Cape Verde", "A Rep�blica de Cabo Verde", "Escudo", "CVE"},
98 {sa, "cx", "Christmas", "Territory of Christmas Island"},
99 {eu, "cy", "Cyprus", "Kypriaki Dimokratia / Kibris Cumhuriyeti", "Pound", "CYP"},
100 {eu, "cz", "Czech", "(Czech Republic) Cesk� Republika", "Korouna", "CSK"},
101 {eu, "de", "Germany", "Bundesrepublik Deutschland", "Mark", "DEM"},
102 {af, "dj", "Djibouti", "Jumhuriya Djibuti", "Franc", "DJF"},
103 {eu, "dk", "Denmark", "Kongeriget Danmark", "Krone", "DKK"},
104 {sa, "dm", "Dominica", "Commonwealth of Dominica", "Dollar", "DMD"},
105 {sa, "do", "Dominican Republic", "Rep�blica Dominicana", "Peso", "DOP"},
106 {af, "dz", "Algeria", "El Djemhouria El Djaza�ria Demokratia Echaabia", "Dinar", "DZD"},
107 {sa, "ec", "Ecuador", "Rep�blica del Ecuador", "Sucre", "ECS"},
108 {eu, "ee", "Estonia", "Eesti Vabariik", "Kroon", "EEK"},
109 {af, "eg", "Egypt", "Jumhuriyat Misr al'Arabiya", "Pound", "EGP"},
110 {af, "eh", "Western Sahara", "Western Sahara"},
111 {eu, "es", "Spain", "Reino de Espa�a", "Peseta", "ESP"},
112 {af, "et", "Ethiopia", "Ityopia", "Birr", "ETB"},
113 {eu, "fi", "Finland", "Suomen Tasavalta", "Markka", "FIM"},
114 {as, "fj", "Fiji", "Matanitu Ko Viti", "Dollar", "FJD"},
115 {sa, "fk", "Falkland", "Falkland Islands (Malvinas)"},
116 {as, "fm", "Micronesia", "The Federated States of Micronesia"},
117 {eu, "fo", "Faroe", "(Faroe Islands) F�royar"},
118 {eu, "fr", "France", "La R�publique Fran�aise", "Franc", "FRF"},
119 {eu, "fx", "Metropolitan", "France Metropolitan"},
120 {af, "ga", "Gabon", "La R�publique Gabonaise", "Franc", "GAF"},
121 {eu, "gb", "Great Britain", "The United Kingdom of Great Britain and Northern Ireland", "Pound", "UKP"},
122 {sa, "gd", "Grenada", "Grenada", "Dollar", "GDD"},
123 {as, "ge", "Georgia", "Sakartvelo / Sakartvelos Respublica", "Lari", "GEL"},
124 {af, "gf", "Guiana", "Guyane (French Guiana)", "Franc", "GFF"},
125 {af, "gh", "Ghana", "Republic of Ghana", "Cedi", "GHC"},
126 {eu, "gi", "Gibraltar", ""},
127 {eu, "gl", "Greenland", "Kalaallit Nunaat"},
128 {af, "gm", "Gambia", "Republic of The Gambia", "Dalasi", "GMD"},
129 {af, "gn", "Guinea", "La R�publique de Guin�e"},
130 {af, "gp", "Guadeloupe", "Guadeloupe (French)", "Franc", "GPF"},
131 {af, "gq", "Equatorial Guinea", "La Rep�blica de Guinea Ecuatorial", "Franc", "GQF"},
132 {eu, "gr", "Greece", "Elleniki Dimocr�tia / Ell�s", "Drachma", "GRD"},
133 {sa, "gt", "Guatemala", "Rep�blica de Guatemala", "Quetzale", "GTQ"},
134 {af, "gu", "Guam", "Territory of Guam"},
135 {af, "gw", "Guinea-Bissau", "Republica da Guin�-Bissau", "Peso", "GWP"},
136 {af, "gy", "Guyana", "The Cooperative Republic of Guyana", "Dollar", "GYD"},
137 {as, "hk", "Hong Kong", "Hong Kong (British)", "Dollar", "HKD"},
138 {as, "hm", "Heard, Mc Donald", "Heard and Mc Donald Islands"},
139 {sa, "hn", "Honduras", "La Rep�blica de Honduras", "Lempira", "HNL"},
140 {eu, "hr", "Croatia", "Republika Hrvatska", "Kuna", "HRK"},
141 {sa, "ht", "Haiti", "La R�publique d'Haiti", "Gourde", "HTG"},
142 {eu, "hu", "Hungary", "Magyarorsz�g / Magyar K�zt�rs�sag", "Forint", "HUF"},
143 {as, "id", "Indonesia", "Republik Indonesia", "Rupiah", "IDR"},
144 {eu, "ie", "Ireland", "Poblacht na h'�ireann", "Pound", "IEP"},
145 {as, "il", "Israel", "Medinat Israel", "Shekel", "ILS"},
146 {as, "in", "India", "Bharat", "Rupee", "INR"},
147 {as, "io", "Indian Ocean", "British Indian Ocean Territory"},
148 {as, "iq", "Iraq", "Al-Jumhuriya al'Iraqiya", "Dinar", "IQD"},
149 {as, "ir", "Iran", "Jomhori-e-Islami-e-Ir�n", "Rial", "IRR"},
150 {eu, "is", "Iceland", "L��veldi� �sland", "Kr�na", "ISK"},
151 {eu, "it", "Italy", "Italia / Repubblica Italiana", "Lira", "ITL"},
152 {sa, "jm", "Jamaica", "Jamaica", "Dollar", "JMD"},
153 {as, "jo", "Jordan", "Al-Mamlaka al-Urduniya al-Hashemiyah", "Dinar", "JOD"},
154 {as, "jp", "Japan", "Nippon / Nihon", "Yen", "JPY"},
155 {af, "ke", "Kenya", "Jamhuri ya Kenya", "Shilling", "KES"},
156 {as, "kg", "Kyrgyzstan", "Kyrgyzstan", "Som", "KGS"},
157 {as, "kh", "Cambodia", "Roat Kampuchea", "Riel", "KHR"},
158 {as, "ki", "Kiribati", "Republic of Kiribati", "Dollar", "AUD"}, /* Australian dollars */
159 {as, "km", "Comoros", "La R�publique f�d�rale islamique des Comores", "Franc", "KMF"},
160 {as, "kn", "Saint Kitts", "The Federation of Saint Christopher and Nevis", "Dollar", "KND"},
161 {as, "kp", "North Korea", "Chosun Mincho-chui Inmin Konghwaguk", "Won", "KPW"},
162 {as, "kr", "South Korea", "Daehan-Minuk", "Won", "KRW"},
163 {as, "kw", "Kuwait", "Dowlat al-Kuwait", "Dinar", "KWD"},
164 {as, "ky", "Cayman", "(Cayman Island)", "Dollar", "KYD"},
165 {as, "kz", "Kazakhstan", "Kazak Respublikasy", "Tenge", "KZT"},
166 {as, "la", "Lao", "Saathiaranagroat Prachhathippatay Prachhachhon Lao", "Kip", "LAK"},
167 {as, "lb", "Lebanon", "Al-Lubnan", "Pound", "LBP"},
168 {as, "lc", "Saint Lucia", "Saint Lucia", "Dollar", "LCD"},
169 {eu, "li", "Liechtenstein", "F�rstentum Liechtenstein"},
170 {as, "lk", "Sri Lanka", "Sri Lanka Prajatantrika Samajawadi Janarajaya", "Rupee", "LKR"},
171 {af, "lr", "Liberia", "The Republic of Liberia", "Dollar", "LRD"},
172 {af, "ls", "Lesotho", "The Kingdom of Lesotho", "Maloti", "LSM"},
173 {eu, "lt", "Lithuania", "Lietuva", "Litai", "LTL"},
174 {eu, "lu", "Luxembourg", "Grand-Duch� de Luxembourg", "Franc", "LUF"},
175 {eu, "lv", "Latvia", "Latvija", "Lat", "LVL"},
176 {af, "ly", "Libyan", "Daulat Libiya al'Arabiya al-Ishtrakiya al-Jumhuriya", "Dinar", "LYD"},
177 {af, "ma", "Morocco", "Al-Mamlaka al-Maghribiya", "Dirham", "MAD"},
178 {eu, "mc", "Monaco", "Principaut� de Monaco", "Franc", "MCF"},
179 {eu, "md", "Moldova", "Republica Moldoveneaca", "Leu", "MDL"},
180 {af, "mg", "Madagascar", "Repoblika Demokratika n'i Madagaskar", "Franc", "MGF"},
181 {as, "mh", "Marshall", "The Republic of the Marshall Islands"},
182 {eu, "mk", "Macedonia", "Republika Makedonija", "Denar", "MKD"},
183 {af, "ml", "Mali", "La R�publique du Mali", "Franc", "MLF"},
184 {af, "mm", "Myanmar", "Myanmar Naingngandaw", "Kyat", "MMK"},
185 {as, "mn", "Mongolia", "Mongol Uls", "Tughrik", "MNT"},
186 {as, "mo", "Macau", "Ilha de Macau", "Pataca", "MOP"},
187 {as, "mp", "Mariana", "Northern Mariana Islands"},
188 {af, "mq", "Martinique", "Martinique (French)", "Franc", "MQF"},
189 {af, "mr", "Mauritania", "Jumhuriyat Muritaniya al-Islamiya", "Ouguiya", "MRO"},
190 {af, "ms", "Montserrat", "Montserrat (British)", "Dollar", "MSD"},
191 {eu, "mt", "Malta", "Repubblika Ta'Malta", "Lira", "MTL"},
192 {af, "mu", "Mauritius", "Republic of Mauritius", "Rupee", "MUR"},
193 {as, "mv", "Maldives", "Dhivehi Jumburiya", "Rufiyaa", "MVR"},
194 {af, "mw", "Malawi", "The Republic of Malawi", "Kwacha", "MWK"},
195 {na, "mx", "Mexico", "Estados Unidos M�xicanos", "Peso", "MXP"},
196 {as, "my", "Malaysia", "Persekutuan Tanah Melaysiu", "Ringgit", "MYR"},
197 {af, "mz", "Mozambique", "A Rep�blica de Mo�ambique", "Metical", "MZM"},
198 {af, "na", "Namibia", "The Republic of Namibia / Republiek van Namibie", "Dollar", "NAD"},
199 {au, "nc", "New Caledonia", "Territoire des Nouvelle-Caledonie et Dependances", "Franc", "NCF"},
200 {af, "ne", "Niger", "La R�publique du Niger", "Franc", "NEF"},
201 {eu, "nf", "Norfolk", "Territory of Norfolk Island"},
202 {af, "ng", "Nigeria", "The Federal Republic of Nigeria", "Naira", "NGN"},
203 {sa, "ni", "Nicaragua", "Rep�blica de Nicaragua", "Cordoba", "NIC"},
204 {eu, "nl", "Netherlands", "Koninkrijk der Nederlanden (Holland)", "Guilder", "NLG"},
205 {eu, "no", "Norway", "Kongeriket Norge", "Krone", "NOK"},
206 {as, "np", "Nepal", "Nepal Adhirajya", "Rupee", "NPR"},
207 {af, "nr", "Nauru", "The Republic of Nauru", "Dollar", "AUD"}, /* australian dollars */
208 {as, "nt", "Neutral Zone", ""},
209 {af, "nu", "Niue", "Niue", "Dollar", "NZD"}, /* New Zealand Dollars */
210 {au, "nz", "New Zealand", "Dominion of New Zealand", "Dollar", "NZD"},
211 {as, "om", "Oman", "Sultanat 'Uman'", "Rial Omani", "OMR"},
212 {sa, "pa", "Panama", "La Rep�blica de Panam�", "Balboa", "PAB"},
213 {sa, "pe", "Peru", "Rep�blica del Per�", "Nuevo Sol", "PES"},
214 {as, "pf", "French Polynesia", "Territory de la Polynesie Francaise"},
215 {as, "pg", "Papua", "The Independent State of Papua New Guinea", "Kina", "PGK"},
216 {as, "ph", "Philippines", "Rep�blika fig Pilipinas", "Pesos", "PHP"},
217 {as, "pk", "Pakistan", "Islami Jamhuria-e-Pakistan", "Rupee", "PKR"},
218 {eu, "pl", "Poland", "Polska Rzecpospolita", "Zloty", "PLZ"},
219 {eu, "pm", "St. Pierre, Miquelon", "Departement de Saint-Pierre et Miquelon"},
220 {as, "pn", "Pitcairn", "Pitcairn, Henderson, Ducie, and Oeno Islands"},
221 {sa, "pr", "Puerto Rico", "Commonwealth of Puerto Rico"},
222 {eu, "pt", "Portugal", "A Rep�blica Portuguesa", "Escudo", "PTE"},
223 {as, "pw", "Palau", "Republic of Palau"},
224 {sa, "py", "Paraguay", "La Rep�blica del Paraguay", "Guranie", "PYG"},
225 {as, "qa", "Qatar", "Dawlat Qatar", "Riyal", "QAR"},
226 {af, "re", "Reunion", "R�union (French)"},
227 {eu, "ro", "Romania", "R�mania", "Leu", "ROL"},
228 {eu, "ru", "Russia", "Rossijskaja Federativnaja Respublika / Rossija", "Ruble", "SUR"},
229 {af, "rw", "Rwanda", "La R�publique Rwandaise / Republika y'u Rwanda", "Franc", "RWF"},
230 {as, "sa", "Saudi Arabia", "Al-Mamlaka al'Arabiya as-Sa'udiya", "Riyal", "SAR"},
231 {as, "sb", "Solomon", "(Solomon Islands)", "Dollar", "SBD"},
232 {as, "sc", "Seychelles", "The Republic of Seychelles", "Rupee", "SCR"},
233 {af, "sd", "Sudan", "Al Jumhuriyat al-Sudan", "Dinar", "SDD"},
234 {eu, "se", "Sweden", "Konungariket Sverige", "Krona", "SEK"},
235 {as, "sg", "Singapore", "Hsing-chia p'o Kung-ho Kuo / Republik Singapura / Republic of Singapore", "Dollar", "SGD"},
236 {af, "sh", "St. Helena", "Saint Helena (British)"},
237 {eu, "si", "Slovenia", "Republika Slovenija", "Tolar", "SIT"},
238 {eu, "sj", "Svalbard", "(Svalbard and Jan Mayen Islands)"},
239 {eu, "sk", "Slovakia", "Republika Slovensk�", "Korouna", "SKK"},
240 {af, "sl", "Sierra Leone", "The Republic of Sierra Leone", "Leone", "SLL"},
241 {eu, "sm", "San Marino", "Repubblica di San Marino"},
242 {af, "sn", "Senegal", "La R�publique du S�n�gal", "Franc", "SNF"},
243 {af, "so", "Somalia", "Jamhuuriyadda Dimugraadiga Soomaliya", "Shilling", "SOS"},
244 {sa, "sr", "Suriname", "Republiek Suriname", "Guilder", "SRG"},
245 {sa, "st", "Sao Tome, Principe", "A Rep�blica Democr�tica de S�o Tom� e Pr�cipe", "Dobra", "STD"},
246 {as, "su", "USSR", "(Soviet Union)"},
247 {sa, "sv", "El Salvador", "La Rep�blica de El Salvador", "Colone", "SVC"},
248 {as, "sy", "Syria", "Al-Jumhuriy al'Arabia as-Suriya", "Pound", "SYP"},
249 {af, "sz", "Swaziland", "Umbuso Weswatina", "Emalangeni", "SZE"},
250 {as, "tc", "Turks, Caicos", "(Turks and Caicos Islands)", "Dollar", "USD"}, /* US Dollars */
251 {af, "td", "Chad", "La R�publique du Tchad", "Franc", "TDF"},
252 {af, "tf", "Southern", "(French Southern Territories)"},
253 {af, "tg", "Togo", "La R�publique Togolaise", "Franc", "TGF"},
254 {as, "th", "Thailand", "Prathet Thai", "Baht", "THB"},
255 {as, "tj", "Tajikistan", "Respublika i Tojikiston", "Ruble", "TJR"},
256 {as, "tk", "Tokelau", "Tokelau"},
257 {as, "tm", "Turkmenistan", "Tiurkmenostan", "Manat", "TMM"},
258 {af, "tn", "Tunisia", "Al-Jumhuriya at-Turnisiya", "Dinar", "TND"},
259 {af, "to", "Tonga", "Pule'anga Fakatu'i'o Tonga", "Pa'anga", "TOP"},
260 {as, "tp", "East Timor", ""},
261 {as, "tr", "Turkey", "T�rkiye Cumhuriyeti", "Lira", "TRL"},
262 {sa, "tt", "Trinidad", "Republic of Trinidad and Tobago", "Dollar", "TTD"},
263 {as, "tv", "Tuvalu", "Tuvalu", "Dollar", "AUD"}, /* Australian Dollars */
264 {as, "tw", "Taiwan", "Chung-hua Min Kuo", "Dollar", "TWD"},
265 {af, "tz", "Tanzania", "Jamhuri ya Muungano wa Tanzania / The United Republic of Tanzania", "Shilling", "TZS"},
266 {eu, "ua", "Ukraine", "Ukraina", "Hryvna", "UAH"},
267 {af, "ug", "Uganda", "The Republic of Uganda", "Shilling", "YGS"},
268 {eu, "uk", "United Kingdom", "The United Kingdom", "Pound", "UKP"},
269 {na, "um", "Minor Outlying", "United States Minor Outlying Islands"},
270 {na, "us", "United States", "United States of America", "Dollar", "USD"},
271 {sa, "uy", "Uruguay", "La Rep�blica Oriental del Uruguay", "Uruguayo", "UYU"},
272 {as, "uz", "Uzbekistan", "Ozbekiston", "Som", "UZS"},
273 {eu, "va", "Vatican", "Stato delle Citt� del Vaticano"},
274 {sa, "vc", "Saint Vincent, Grenadines", "Saint Vincent and the Grenadines", "Dollar", "VCD"},
275 {sa, "ve", "Venezuela", "La Rep�blica de Venezuela", "Bolivar", "VEB"},
276 {sa, "vg", "British Virgin", "British Virgin Islands", "Dollar", "USD"}, /* US Dollars */
277 {sa, "vi", "US Virgin", "U.S. Virgin Islands", "Dollar", "USD"}, /* US Dollars */
278 {as, "vn", "Vietnam", "C�ng hoa x� h�i chu nghia Vi�t", "Dong", "VND"},
279 {as, "vu", "Vanuatu", "The Republic of Vanuatu / La R�publique de Vanuatu", "Vatu", "VUV"},
280 {as, "wf", "Wallis, Futuna", "Wallis and Futuna Islands"},
281 {as, "ws", "Samoa", "", "Tala", "WST"},
282 {as, "ye", "Yemen", "Al-Jamhiya al-Yamaniya", "Rial", "YER"},
283 {0, "yt", "Mayotte", "(Territorial Collectivity of Mayotte)"},
284 {eu, "yu", "Yugoslavia", "Federativna Republika Jugoslavija", "Dinar", "YUD"},
285 {af, "za", "South Africa", "Republic of South Africa / Republiek van Suid-Afrika", "Rand", "ZAR"},
286 {af, "zm", "Zambia", "The Republic of Zambia", "Kwacha", "ZMK"},
287
288 /* 1997-07-14
289 ZAIRE (ZA) changed to CONGO, THE DEMOCRATIC REPUBLIC OF THE (CD)
290 change of name, alpha-2 and alpha-3, numeric remains 180 */
291
292 {af, "zr", "Zaire", "La R�publique du Za�re", "Zaire", "ZRZ"},
293 {af, "zw", "Zimbabwe", "The Republic of Zimbabwe", "Dollar", "ZWD"},
294
295 {na, "edu", "Educational", "U.S. Educational domain"},
296 {na, "gov", "Government", "U.S. Government"},
297 {na, "mil", "Military", "U.S. Military"},
298 {na, "com", "Commercial", ""},
299 {na, "org", "Organization", ""},
300 {na, "net", "Net", ""},
301 {na, "int", "International", ""},
302 {na, "nato","Nato", ""},
303 {na, "arpa","Arpa", ""},
304
305 {eu, ""/*none*/, "EU", "European Union", "Euro", "EUR"},
306 };
307
308 /* --- MarkLetters ------------------------------------------------ */
309
MarkLetters(char * name)310 ulong MarkLetters(char *name)
311 {
312 char c;
313 ulong let = 0;
314
315 while (c = *name++)
316 let |= 1 << (c % ULONG_BIT);
317 return let;
318 }
319
320 /* --- HammingDistance -------------------------------------------- */
321
HammingDistance(ulong x,ulong y)322 ulong HammingDistance(ulong x, ulong y)
323 {
324 ulong a = 0;
325
326 for (x ^= y; x; a += (x & 1), x >>= 1);
327 return a;
328 }
329
330 /* --- UnequalBits ------------------------------------------------ */
331
UnequalBits(ulong x,ulong y)332 ulong UnequalBits(ulong x, ulong y)
333 {
334 ulong a = 0;
335
336 for (x ^= (x | y); x; a += (x & 1), x >>= 1);
337 return a;
338 }
339
340 /* --- FindByCode ------------------------------------------------- */
341
342 /* Given the code find the country */
343
FindByCode(char * code)344 land *FindByCode(char *code)
345 {
346 int i;
347
348 for (i=0; i < sizeof(countries)/sizeof(countries[0]); i++) {
349 if (StrEqual(countries[i].code, code))
350 return &countries[i];
351 }
352 return NULL;
353 }
354
355 /* --- FindByCurrency --------------------------------------------- */
356
357 /* Given the currency find the country
358 *
359 * There might be several countries using the same currency (USD, AUD. NZD are
360 * a few examples). To fullfill this match, we want the country that the
361 * currency originate from and therefore we check that the first two letters
362 * of the toplevel domain name is the same as the currency's.
363 */
364
FindByCurrency(char * code)365 land *FindByCurrency(char *code)
366 {
367 int i;
368
369 for (i=0; i < sizeof(countries)/sizeof(countries[0]); i++) {
370 if (countries[i].currency &&
371 StrEqualMax(countries[i].currency, 2, countries[i].code) &&
372 StrEqual(countries[i].currency, code))
373 return &countries[i];
374 }
375 return NULL;
376 }
377
378 /* --- FindByCountry ---------------------------------------------- */
379
FindByCountry(char * country)380 land *FindByCountry(char *country)
381 {
382 int min = INT_MAX;
383 int index = -1;
384 int i, d;
385 ulong sig, let;
386
387 sig = HashSignatureU(country);
388 let = MarkLetters(country);
389
390 for (i=0; i < sizeof(countries)/sizeof(countries[0]); i++) {
391 d = HammingDistance(countries[i].sig, sig) +
392 UnequalBits(countries[i].let, let);
393 if (min > d) {
394 min = d;
395 index = i;
396 }
397 }
398
399 return ((index > -1) ? &countries[index] : NULL);
400 }
401
402 /* --- Country ---------------------------------------------------- */
403
404 /* If prepended by a dot (.)
405 * search for code
406 * Else if nick on channel
407 * search for top-level domain
408 * Else
409 * search for country name
410 */
411
Country(char * from,char * line)412 void Country(char *from, char *line)
413 {
414 extern char *errfrom;
415 char buffer[BIGBUFFER] = "";
416 char *country, *pointer;
417 itemguest *g;
418 land *n;
419
420 country = NextQuoteWord(line);
421 if (country) {
422 if ('.' == country[0]) {
423 n = FindByCode(&country[1]);
424 if (n) {
425 if (n->fullname[0])
426 StrFormatMax(buffer, sizeof(buffer), " (%s)", n->fullname);
427 Sendf(from, "%s %s %s%s", country, GetText(msg_is), n->country, buffer);
428 }
429 else
430 Sendf(from, GetText(msg_x_not_found), country);
431 }
432 else {
433 g = FindNick(country);
434 if (g) {
435 pointer = StrIndexLast(g->ident->host, '.');
436 if (pointer) {
437 n = FindByCode(&pointer[1]);
438 if (n) {
439 if (n->fullname[0])
440 StrFormatMax(buffer, sizeof(buffer), " (%s)", n->fullname);
441 Sendf(from, GetText(msg_is_from), country, n->country, buffer);
442 }
443 else /* Catching IP numerical addresses */
444 Sendf(from, GetText(msg_cannot_find_info), country);
445 }
446 }
447 else {
448 n = FindByCountry(country);
449 if (n) {
450 if (n->fullname[0])
451 StrFormatMax(buffer, sizeof(buffer), " (%s)", n->fullname);
452 if (StrEqual(n->country, country))
453 Sendf(from, GetText(msg_has_country_code), country, n->code, buffer);
454 else
455 Sendf(from, GetText(msg_has_country_assuming),
456 country, n->code, n->country, buffer);
457 }
458 else
459 Sendf(from, GetText(msg_is_unknown), country);
460 }
461 }
462 }
463 else
464 CmdSyntax(errfrom, "COUNTRY");
465 }
466
467 /* --- CountryInit ------------------------------------------------ */
468
CountryInit(void)469 void CountryInit(void)
470 {
471 int i;
472
473 for (i=0; i < sizeof(countries)/sizeof(countries[0]); i++) {
474 countries[i].sig = HashSignatureU(countries[i].country);
475 countries[i].let = MarkLetters(countries[i].country);
476 }
477 }
478