2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Program that makes country files
9 #include <exec/types.h>
10 #include <libraries/locale.h>
11 #include <prefs/locale.h>
16 #include <aros/system.h>
21 (x) = (((x) & 0xFF000000) >> 24)\
22 | (((x) & 0x00FF0000) >> 8)\
23 | (((x) & 0x0000FF00) << 8)\
24 | (((x) & 0x000000FF) << 24);\
30 struct CountryPrefs
*ca_Data
;
33 extern struct CountryPrefs
39 bosna_i_hercegovinaPrefs
,
84 /* Please keep this in alphabetical order, ie the order of Latin 1 */
86 struct CountryEntry CountryArray
[] =
88 { "andorra" , &andorraPrefs
},
89 { "argentina" , &argentinaPrefs
},
90 { "australia" , &australiaPrefs
},
91 { "belgië" , &belgiePrefs
},
92 { "belgique" , &belgiquePrefs
},
93 { "bosna_i_hercegovina", &bosna_i_hercegovinaPrefs
},
94 { "brasil" , &brasilPrefs
},
95 { "bulgarija" , &bulgarijaPrefs
},
96 { "canada" , &canadaPrefs
},
97 { "canada_français" , &canada_francaisPrefs
},
98 { "czech_republic" , &czech_republicPrefs
},
99 { "danmark" , &danmarkPrefs
},
100 { "deutschland" , &deutschPrefs
},
101 { "éire" , &eirePrefs
},
102 { "españa" , &espanaPrefs
},
103 { "france" , &francePrefs
},
104 { "great_britain" , &greatBritainPrefs
},
105 { "hrvatska" , &hrvatskaPrefs
},
106 { "iran" , &iranPrefs
},
107 { "ireland" , &irelandPrefs
},
108 { "ísland" , &islandPrefs
},
109 { "italia" , &italiaPrefs
},
110 { "jugoslavija" , &jugoslavijaPrefs
},
111 { "liechtenstein" , &liechtensteinPrefs
},
112 { "lëtzebuerg" , &letzebuergPrefs
},
113 { "lietuva" , &lietuvaPrefs
},
114 { "magyarország" , &magyarorszagPrefs
},
115 { "monaco" , &monacoPrefs
},
116 { "nihon" , &nihonPrefs
},
117 { "nederland" , &nederlandPrefs
},
118 { "norge" , &norgePrefs
},
119 { "österreich" , &osterreichPrefs
},
120 { "polska" , &polskaPrefs
},
121 { "portugal" , &portugalPrefs
},
122 { "românia" , &romaniaPrefs
},
123 { "rossija" , &rossijaPrefs
},
124 { "san_marino" , &san_marinoPrefs
},
125 { "schweiz" , &schweizPrefs
},
126 { "slovakia" , &slovakiaPrefs
},
127 { "slovenija" , &slovenijaPrefs
},
128 { "suisse" , &suissePrefs
},
129 { "suomi" , &suomiPrefs
},
130 { "sverige" , &sverigePrefs
},
131 { "svizzera" , &svizzeraPrefs
},
132 { "türkiye" , &turkiyePrefs
},
133 { "ukrajina" , &ukrajinaPrefs
},
134 { "united_kingdom" , &united_kingdomPrefs
},
135 { "united_states" , &united_statesPrefs
},
136 { "vaticano" , &vaticanoPrefs
},
140 /* This is equivalent to the start of the catalog file.
141 It is a series of strings, so that the endianness is
146 "FORM" "\x00\x00\x02\x12" "PREF"
148 "PRHD" "\x00\x00\x00\x06"
149 "\x00\x00\x00\x00\x00\x00"
151 "CTRY" "\x00\x00\x01\xF8"
155 int doCountry(struct CountryPrefs
*cp
, STRPTR progname
, STRPTR filename
)
159 fp
= fopen(filename
, "w");
162 printf("%s: Could not open file %s\n", progname
, filename
);
166 /* Write the preamble...
172 if(fwrite(preamble
, 34, 1, fp
) < 1)
174 printf("%s: Write error during preable of %s.\n", progname
, filename
);
179 #if (AROS_BIG_ENDIAN == 0)
180 /* We have to convert the endianness of this data,
181 thankfully there are only two fields which this applies
184 EC(cp
->cp_CountryCode
);
185 EC(cp
->cp_TelephoneCode
);
188 if(fwrite(cp
, sizeof(struct CountryPrefs
), 1, fp
) < 1)
190 printf("%s: Write error during data for %s.\n", progname
, filename
);
199 int main(int argc
, char **argv
)
205 size_t inbytes
, outbytes
;
210 printf("%s: Wrong number of arguments\n", argv
[0]);
214 cd
= iconv_open("ISO-8859-1", "ISO-8859-1");
215 if(cd
== (iconv_t
)(-1))
217 printf("%s: Error converting character sets\n", argv
[0]);
221 for(i
=2; i
< argc
; i
++)
223 for(j
=0; CountryArray
[j
].ca_Name
!= NULL
; j
++)
225 /* Convert country name to local character set */
226 inpos
= CountryArray
[j
].ca_Name
;
227 inbytes
= strlen(inpos
) + 1;
230 iconv(cd
, &inpos
, &inbytes
, &outpos
, &outbytes
);
232 res
= strcmp(buffer
, argv
[i
]);
235 strcpy(buffer
, argv
[1]);
236 strcat(buffer
, argv
[i
]);
237 strcat(buffer
, ".country");
238 doCountry(CountryArray
[j
].ca_Data
, argv
[0], buffer
);
242 /* stegerg: does not work because of 'ö' in österreich */
243 /* If countryArray < argv[] don't bother searching */
251 printf("Unknown country %s\n", argv
[i
]);