📄 countries.c
字号:
/*
** File Rev $Revision: \main\20010426_1.4_integration_branch\1 $
**
** Date $Date: Wed May 22 11:56:12 2002 $
**
** Master file for FTA2000 country definitions
*/
#include <stdio.h>
struct COUNTRY
{
unsigned char *name;
unsigned char *code;
};
struct COUNTRY countries[] =
{
"Afghanistan", "AFG",
"Albania", "ALB",
"Algeria", "DZA",
"American Samoa", "ASM",
"Andorra", "AND",
"Angola", "AGO",
"Anguilla", "AIA",
"Antigua & Barbuda", "ATG", //Shortened from "Antigua and Barbuda"
"Argentina", "ARG",
"Armenia", "ARM",
"Aruba", "ABW",
"Australia", "AUS",
"Austria", "AUT",
"Azerbaijan", "AZE",
"Bahamas", "BHS",
"Bahrain", "BHR",
"Bangladesh", "BGD",
"Barbados", "BRB",
"Belarus", "BLR",
"Belgium", "BEL",
"Belize", "BLZ",
"Benin", "BEN",
"Bermuda", "BMU",
"Bhutan", "BTN",
"Bolivia", "BOL",
"Bosnia & Herzegovina", "BIH", //Shortened from "Bosnia and Herzegovina"
"Botswana", "BWA",
"Brazil", "BRA",
"British Virgin Is", "VGB", //Shortened from "British Virgin Islands"
"Brunei Darussalam", "BRN",
"Bulgaria", "BGR",
"Burkina Faso", "BFA",
"Burundi", "BDI",
"Cambodia", "KHM",
"Cameroon", "CMR",
"Canada", "CAN",
"Cape Verde", "CPV",
"Cayman Islands", "CYM",
"Central African Republic", "CAF",
"Chad", "TCD",
//"Channel Islands", "???", No unique code
"Chile", "CHL",
"China", "CHN",
//"Hong Kong Special Administrative Region of China", moved to "Hong Kong"
//"Macao Special Administrative Region of China", moved to "Macao"
"Colombia", "COL",
"Comoros", "COM",
"Congo", "COG",
"Cook Islands", "COK",
"Costa Rica", "CRI",
"Cote d'Ivoire", "CIV",
"Croatia", "HRV",
"Cuba", "CUB",
"Cyprus", "CYP",
"Czech Republic", "CZE",
//"Democratic People's Republic of Korea" moved to "Korea, North"
"Democratic Rep of the Congo", "COD", // Shortened from "Democratic Republic of the Congo"
"Denmark", "DNK",
"Djibouti", "DJI",
"Dominica", "DMA",
"Dominican Republic", "DOM",
"East Timor", "TMP",
"Ecuador", "ECU",
"Egypt", "EGY",
"El Salvador", "SLV",
"Equatorial Guinea", "GNQ",
"Eritrea", "ERI",
"Estonia", "EST",
"Ethiopia", "ETH",
"Faeroe Islands", "FRO",
"Falkland Islands", "FLK", // Shortened from "Falkland Islands (Malvinas)"
"Fiji", "FJI",
"Finland", "FIN",
"France", "FRA",
"French Guiana", "GUF",
"French Polynesia", "PYF",
"Gabon", "GAB",
"Gambia", "GMB",
"Georgia", "GEO",
"Germany", "DEU",
"Ghana", "GHA",
"Gibraltar", "GIB",
"Greece", "GRC",
"Greenland", "GRL",
"Grenada", "GRD",
"Guadeloupe", "GLP",
"Guam", "GUM",
"Guatemala", "GTM",
"Guinea", "GIN",
"Guinea-Bissau", "GNB",
"Guyana", "GUY",
"Haiti", "HTI",
"Holy See", "VAT",
"Honduras", "HND",
"Hong Kong", "HKG", // From "Hong Kong Special Administrative Region of China"
"Hungary", "HUN",
"Iceland", "ISL",
"India", "IND",
"Indonesia", "IDN",
"Iran", "IRN", // Shortened from "Iran (Islamic Republic of)"
"Iraq", "IRQ",
"Ireland", "IRL",
"Isle of Man", "IMY",
"Israel", "ISR",
"Italy", "ITA",
"Jamaica", "JAM",
"Japan", "JPN",
"Jordan", "JOR",
"Kazakhstan", "KAZ",
"Kenya", "KEN",
"Kiribati", "KIR",
"Korea, North", "PRK", // From "Democratic People's Republic of Korea"
"Korea, South", "KOR", // From "Republic of Korea"
"Kuwait", "KWT",
"Kyrgyzstan", "KGZ",
"Lao People's Democratic Rep", "LAO", // Shortened from "Lao People's Democratic Republic"
"Latvia", "LVA",
"Lebanon", "LBN",
"Lesotho", "LSO",
"Liberia", "LBR",
"Libya", "LBY", // Shortened from "Libyan Arab Jamahiriya"
"Liechtenstein", "LIE",
"Lithuania", "LTU",
"Luxembourg", "LUX",
"Macao", "MAC", // From "Macao Special Administrative Region of China"
"Macedonia", "MKD", // From "The former Yugoslav Republic of Macedonia"
"Madagascar", "MDG",
"Malawi", "MWI",
"Malaysia", "MYS",
"Maldives", "MDV",
"Mali", "MLI",
"Malta", "MLT",
"Marshall Islands", "MHL",
"Martinique", "MTQ",
"Mauritania", "MRT",
"Mauritius", "MUS",
"Mexico", "MEX",
"Micronesia, Fed States of", "FSM", // Shortened from "Micronesia, Federated States of"
"Monaco", "MCO",
"Mongolia", "MNG",
"Montserrat", "MSR",
"Morocco", "MAR",
"Mozambique", "MOZ",
"Myanmar", "MMR",
"Namibia", "NAM",
"Nauru", "NRU",
"Nepal", "NPL",
"Netherlands", "NLD",
"Netherlands Antilles", "ANT",
"New Caledonia", "NCL",
"New Zealand", "NZL",
"Nicaragua", "NIC",
"Niger", "NER",
"Nigeria", "NGA",
"Niue", "NIU",
"Norfolk Island", "NFK",
"Northern Mariana Islands", "MNP",
"Norway", "NOR",
"Occupied Palestinian Territory", "PSE",
"Oman", "OMN",
"Pakistan", "PAK",
"Palau", "PLW",
"Panama", "PAN",
"Papua New Guinea", "PNG",
"Paraguay", "PRY",
"Peru", "PER",
"Philippines", "PHL",
"Pitcairn", "PCN",
"Poland", "POL",
"Portugal", "PRT",
"Puerto Rico", "PRI",
"Qatar", "QAT",
//"Republic of Korea" moved to "Korea, South"
"Republic of Moldova", "MDA",
//"R閡nion", "REU", No accented letters
"Reunion", "REU",
"Romania", "ROM",
"Russian Federation", "RUS",
"Rwanda", "RWA",
"Saint Helena", "SHN",
"Saint Kitts & Nevis", "KNA",
"Saint Lucia", "LCA",
"Saint Pierre & Miquelon", "SPM",
"St Vincent & the Grenadines", "VCT", // Shortened from "Saint Vincent & the Grenadines"
"Samoa", "WSM",
"San Marino", "SMR",
"Sao Tome & Principe", "STP",
"Saudi Arabia", "SAU",
"Senegal", "SEN",
"Seychelles", "SYC",
"Sierra Leone", "SLE",
"Singapore", "SGP",
"Slovakia", "SVK",
"Slovenia", "SVN",
"Solomon Islands", "SLB",
"Somalia", "SOM",
"South Africa", "ZAF",
"Spain", "ESP",
"Sri Lanka", "LKA",
"Sudan", "SDN",
"Suriname", "SUR",
"Svalbard & Jan Mayen Is", "SJM", // Shortened from "Svalbard and Jan Mayen Islands"
"Swaziland", "SWZ",
"Sweden", "SWE",
"Switzerland", "CHE",
"Syrian Arab Republic", "SYR",
"Taiwan", "TWN", // Shortened from "Taiwan Province of China"
"Tajikistan", "TJK",
"Tanzania", "TZA",
"Thailand", "THA",
//"The former Yugoslav Republic of Macedonia" moved to "Macedonia"
"Togo", "TGO",
"Tokelau", "TKL",
"Tonga", "TON",
"Trinidad & Tobago", "TTO", // Shortened from "Trinidad and Tobago"
"Tunisia", "TUN",
"Turkey", "TUR",
"Turkmenistan", "TKM",
"Turks & Caicos Is", "TCA", // Shortened from "Turks and Caicos Islands"
"Tuvalu", "TUV",
"Uganda", "UGA",
"Ukraine", "UKR",
"United Arab Emirates", "ARE",
"United Kingdom", "GBR",
//"United Republic of Tanzania" moved to "Tanzania"
"United States", "USA",
"US Virgin Is", "VIR", // Shortened from "United States Virgin Islands"
"Uruguay", "URY",
"Uzbekistan", "UZB",
"Vanuatu", "VUT",
"Venezuela", "VEN",
"Viet Nam", "VNM",
"Wallis & Futuna Is", "WLF", // Shortened from "Wallis and Futuna Islands"
"Western Sahara", "ESH",
"Yemen", "YEM",
"Yugoslavia", "YUG",
"Zambia", "ZMB",
"Zimbabwe", "ZWE",
};
int main(int argc, char *argv[])
{
unsigned int countryCount,
i;
unsigned short countryCode;
FILE *outFile, *headerFile;
countryCount = sizeof(countries) / sizeof(struct COUNTRY);
fprintf(stdout, "\nFTA2000 ISO3166 Country Code Parser\n");
fprintf(stdout, "==============================\n\n\t%d Countries Declared\n\n", countryCount);
fprintf(stdout, "\tOpening Output File\n");
outFile = fopen("iso3166.c", "w");
if (outFile == NULL)
{
fprintf(stderr, "Couldn't open iso3166.c\n");
exit(1);
}
fprintf(stdout, "\tOpening Output Header File\n");
headerFile = fopen("iso3166.h", "w");
if (headerFile == NULL)
{
fprintf(stderr, "Couldn't open iso3166.h\n");
exit(1);
}
fprintf(stdout, "\tWriting Header Information\n");
fprintf(outFile, "/*\n** FTA2000 ISO3166 Country Support\n**\n");
fprintf(outFile, "** Machine generated source file containing %d countries\n**\n", countryCount);
fprintf(outFile, "** Each entry contains the name of the country (in English)\n");
fprintf(outFile, "** and Base-26 (in decimal!) representations of the iso3166\n");
fprintf(outFile, "** code. Using numerical references saves storage space and\n");
fprintf(outFile, "** speeds searching.\n*/\n");
fprintf(headerFile, "/*\n** FTA2000 ISO3166 Country Support\n**\n");
fprintf(headerFile, "** Machine generated source file containing %d countries\n**\n", countryCount);
fprintf(headerFile, "** Each entry contains the name of the country (in English)\n");
fprintf(headerFile, "** and Base-26 (in decimal!) representations of the iso3166\n");
fprintf(headerFile, "** code. Using numerical references saves storage space and\n");
fprintf(headerFile, "** speeds searching.\n*/\n");
fprintf(headerFile, "struct COUNTRY\n{\n unsigned char *name;\n unsigned short code;\n");
fprintf(headerFile, "};\n\n#define COUNTRY_COUNT %d\n", countryCount);
fprintf(headerFile, "\nextern struct COUNTRY countries[];\n");
fprintf(outFile, "\n#include \"iso3166.h\"\n\n");
fprintf(outFile, "struct COUNTRY countries[] =\n{\n");
fprintf(stdout, "\tWriting Country Information\n");
for (i = 0;i<countryCount ;i++ )
{
countryCode = (countries[i].code[0] - 'A') * 26 * 26;
countryCode += (countries[i].code[1] - 'A') * 26;
countryCode += (countries[i].code[2] - 'A');
fprintf(outFile, " {\"%s\", %d}, /* %s */\n", countries[i].name,
countryCode,
countries[i].code );
}
fprintf(stdout, "\tCountry Parsing Complete\n");
fprintf(outFile, "};\n\n/* The END */\n");
fprintf(headerFile, "\n/* The END */\n");
fprintf(stdout, "\tClosing file and exiting, results are in iso3166.c and iso3166.h\n\n");
fclose(outFile);
fclose(headerFile);
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -