#include "data.h"
#include <unistd.h>
#include <stdio.h>

char *biz[] = {
"afghanistan",
"albania",
"algeria",
"american_samoa",
"anarchist",
"anarcommunist",
"andorra",
"angola",
"anguilla",
"antarctica",
"antigua_and_barbuda",
"argentina",
"armenia",
"aruba",
"australia_aboriginies",
"australia_capital_territory",
"australia_christmas_island",
"australia_eureka_historic",
"australia_mike_honeychur_01",
"australia_new_south_wales",
"australia_norfolk_island",
"australia_northern_territory",
"australia_queensland",
"australia_south_australia",
"australia",
"australia_tasmania",
"australia_torres_streight_islanders",
"australia_victoria",
"australia_western_australia",
"austria",
"azerbaijan",
"bahamas",
"bahrain",
"banana_republic",
"bangladesh",
"barbados",
"batasuna_basque_nationalists",
"belarus_historic",
"belarus",
"belgium_brussels",
"belgium_flanders",
"belgium",
"belgium_walloon",
"belize",
"benin",
"bermuda",
"bhutan",
"bolivia",
"bosnia_and_herzegovina",
"botswana",
"brazil",
"bretagne_01",
"british_virgin_islands",
"brunei_darussalam",
"bulgaria",
"burkina_faso",
"burundi",
"cambodia",
"cameroon",
"canada_acadia",
"canada_alberta",
"canada_british_columbia",
"canada_flag",
"canada_manitoba",
"canada_new_brunswick",
"canada_newfoundland",
"canada_northwest_territories",
"canada_nova_scotia",
"canada_nunavut",
"canada_ontario",
"canada_prince_edward_island",
"canada_quebec",
"canada_saskatchewan",
"canada",
"canada_yukon",
"capeverde",
"central_african_republic",
"chad",
"chile",
"china_historic",
"china_hong_kong",
"china_macao",
"china",
"christian",
"citt_di_torino_01",
"colombia",
"comoros",
"congo-brazzaville",
"congo_kinshasa",
"cook_islands",
"copileftcommies_flag_nic_01",
"costa_rica",
"cote_divoire",
"croatia",
"cuba",
"cyprus",
"czech_republic",
"dannebrog_split",
"denmark_faroe",
"denmark_greenland",
"denmark_jutland",
"denmark",
"djibouti",
"dominican_republic",
"dominica",
"ecuador",
"egypt",
"el_salvador",
"equatorial_guinea",
"eritrea",
"esperanto",
"es",
"estonia",
"ethiopia",
"eu_flag_hash_0x8a0ab9c__01",
"europeanunion",
"fiji",
"finland_aaland",
"finland",
"finnish_region_satakunt_01",
"flags_of_the_world_flag",
"france_alsace",
"france_anjou",
"france_aquitaine",
"france_artois",
"france_auvergne",
"france_basse_normandie",
"france_bearn",
"france_berry",
"france_bourgogne",
"france_brittany",
"france_centre_val_de_loire",
"france_champagne-ardenne",
"france_comtat_venaissin",
"france_comte_de_foix",
"france_comte_de_nice",
"france_corsica",
"france_dauphine",
"france_franche_comte",
"france_french_royal_navy_historic",
"france_gascogne",
"france_haute_normandie",
"france_ile_de_france",
"france_languedoc_roussillon",
"france_limousin_alternate",
"france_limousin",
"france_lorraine",
"france_lyonnais",
"france_maine",
"france_marche",
"france_martinique",
"france_midi_pyrenee",
"france_nivernais",
"france_nord_pas_de_calais",
"france_normandy",
"france_orleanais",
"france_pays_de_la_loire",
"france_picardie",
"france_poitou_charentes",
"france_provence_alpes_cote_d_azur",
"france_provence_alternate",
"france_provence",
"france_rhone_alpes",
"france_roussillon",
"france_savoie",
"france_st_pierre_and_miquelon",
"france",
"france_touraine",
"france_wallis_and_futuna",
"french_polynesia",
"gabon",
"gambia",
"gay_pride_flag_kimiko_01",
"georgia_historic",
"georgia",
"germany_baden-wurttemberg",
"germany_bavaria",
"germany_berlin",
"germany_bremen",
"germany_eastfrisia",
"germany_east_historic",
"germany_hamburg",
"germany_lower_saxony",
"germany_north_rhine_westphalia",
"germany_saxony",
"germany_schleswig-holstein",
"germany",
"ghana",
"greece",
"grenada",
"guam",
"guatemala",
"guinea_bissau",
"guineabissau",
"guinea",
"guyana",
"gwen_ha_du_01",
"haiti",
"honduras",
"hungary",
"iceland",
"ile_de_france_01",
"india",
"indonesia",
"iran",
"iraq",
"ireland",
"isle_of_man",
"israeli_flag_anonymous_01",
"israel",
"italy",
"jamaica",
"japan",
"jordan",
"kansasflag_dave_reckonin_01",
"kazakhstan",
"kenya",
"kiribati",
"kuwait",
"kyrgyzstan",
"laos",
"latvia",
"lebanon",
"lesotho",
"liberia",
"libyan_arab_jamahiriya",
"liechtenstein",
"lithuania",
"luxembourg",
"macedonia",
"madagascar",
"malawi",
"malaysia",
"maldives",
"maledives",
"mali",
"malta",
"marshall_islands",
"mauritania",
"mauritius",
"mexico",
"micronesia",
"moldova",
"monaco",
"mongolia",
"montserrat",
"morocco",
"mozambique",
"myanmar",
"namibia",
"national_flag_of_canada_01",
"national_flag_of_canada_02",
"national_flag_of_canada_03",
"national_flag_of_canada_04",
"national_flag_of_the_re_01",
"nato",
"nauru",
"nazi_historic",
"nepal",
"netherland_dutch_royal_navy_historic",
"netherlands_antilles",
"netherlands",
"new_zealand_maori",
"newzealand",
"nicaragua",
"nigeria",
"niger",
"niue",
"northern_mariana",
"north_korea",
"norway",
"oman",
"pakistan",
"palau",
"palestine",
"panama",
"papua_new_guinea",
"paraguay",
"peru",
"philippines",
"piemonte",
"pirate_blackbeard_edward_teach",
"pirate_emanuel_wynne",
"pirate_henry_every",
"pirate_jack_rackham",
"pirate_stede_bonnet",
"pirate_thomas_tew",
"pitcairn_islands",
"poland",
"portugal",
"puerto_rico",
"qatar",
"romania",
"russian_federation",
"rwanda",
"saint_helena",
"saint_kitts_and_nevis",
"saint_lucia",
"saint_vincent_and_the_grenadines",
"samoa",
"san_marino",
"sao_tome_and_principe",
"saudi_arabia",
"senegal",
"serbia_and_montenegro",
"seychelles",
"sierra_leone",
"singapore",
"slovakia",
"slovenia",
"socialist",
"solomonislands",
"somalia",
"south_africa_historic",
"south_africa",
"southen_cross_black_01",
"south_georgia_and_south_sandwich_islands",
"south_korea",
"south_korea_-_taegeukgi_01",
"spain_asturias",
"spain_basque",
"spain_canary",
"spain_catalunya",
"spain_galicia",
"spain_galiza_nationalists",
"spain_madrid",
"spain_murcia",
"spain_plain",
"spain_secondrepublic_historic",
"spain_spanish_royal_navy_historic",
"spain",
"sri_lanka",
"sudan",
"suisse",
"suriname",
"swaziland",
"sweden",
"syrian_arab_republic",
"taiwan",
"tajikistan",
"tanzania",
"thailand",
"the_official_flag_of_is_01",
"tibet",
"timor_leste",
"togo",
"tonga",
"trinidad_and_tobago",
"trust_territory_of_the_pacific_islands",
"tunisia",
"turkey",
"turkmenistan",
"turks_and_caicos",
"tuvalu",
"tux_bulgarian_licho_lich_01",
"uganda",
"uk_british_indian_ocean_territory",
"uk_england",
"uk_english_royal_navy_historic",
"uk_gibraltar",
"uk_kernow",
"uk_orkney",
"ukraine",
"uk_scotland",
"uk_shetland",
"uk_wales",
"unesco",
"unicef",
"united_arab_emirates",
"united_kingdom",
"unitednations",
"united_states",
"uruguay",
"usa_alabama",
"usa_alaska",
"usa_arizona",
"usa_arkansas",
"usa_betsy_ross_historic",
"usa_california",
"usa_colorado",
"usa_district_of_columbia",
"usa_florida",
"usa_hawaii",
"usa_indiana",
"usa_maryland",
"usa_missisipi",
"usa_nevada",
"usa_newmexico",
"usa_northcarolina",
"usa_ohio",
"usa_rhode_island",
"usa_southcarolina",
"usa_tenessee",
"usa_texas",
"usa_virgin_islands",
"usa_washington",
"usa_wyoming",
"ussr_historic",
"uzbekistan",
"vanuatu",
"vatican",
"venezuela",
"vietnam_historic",
"viet_nam",
"western_sahara",
"who",
"yemen",
"yugoslavia_historic",
"zambia",
"zimbabwe"
};

void conv(char *buf, char *str)
{
   int i, j, l, blank;
   char c;
   
   blank = 0;
   l = strlen(str);
   j = 0;
   for (i=0; i<l; i++) {
       c = tolower(str[i]);
       if (c>='a' && c<='z') {
	  blank = 0;
	  buf[j] = c;
	  j++;
	  continue;
       }
       if (c>='&') break;
       if (isspace(c)) {
	  if (blank) break;
	  buf[j] = '_';
	  j++;
	  blank = 1;
       }
   }
   buf[j] = '\0';
}

int main(int argc, char **argv)
{
   int N, B, i, j, k;
   char buf[256];
   char *suf;

   if (!argv[1]) 
      suf = "";
   else
      suf = argv[1];
      
   N = sizeof(countries_short)/(2*sizeof(char *));
   B = sizeof(biz)/(sizeof(char *));
   for (i=0; i<B; i++) {
       for (j=0; j<N; j++) {
	   conv(buf, countries_short[2*j+1]);
	   if (!strcmp(buf, biz[i])) break;
       }
       if (j>=N) 
	   printf("%s.%s.gz ??\n", biz[i]);
       else {
	   printf("ln -s %s.%s.gz ", biz[i], suf);
	   for (k=0; k<=1; k++) printf("%c", countries_short[2*j][k]+32);
	   printf(".%s.gz\n", suf);
       }
   }
}

  
