Commit e8ebd079 authored by Michael Tremer's avatar Michael Tremer

country: Make country codes beginning with X invalid

According to ISO3166, they are only allowed for "private use".
Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 3eb1eed6
......@@ -209,6 +209,10 @@ LOC_EXPORT int loc_country_code_is_valid(const char* cc) {
return 0;
}
// The code cannot begin with an X (those are reserved for private use)
if (*cc == 'X')
return 0;
// Looks valid
return 1;
}
......
......@@ -33,8 +33,8 @@ int main(int argc, char** argv) {
int err;
// Check some valid country codes
if (!loc_country_code_is_valid("XX")) {
fprintf(stderr, "Valid country code detected as invalid: %s\n", "XX");
if (!loc_country_code_is_valid("DE")) {
fprintf(stderr, "Valid country code detected as invalid: %s\n", "DE");
exit(EXIT_FAILURE);
}
......@@ -101,7 +101,7 @@ int main(int argc, char** argv) {
exit(EXIT_FAILURE);
// Create a country
err = loc_writer_add_country(writer, &country, "XX");
err = loc_writer_add_country(writer, &country, "DE");
if (err) {
fprintf(stderr, "Could not create country\n");
exit(EXIT_FAILURE);
......
......@@ -62,7 +62,7 @@ int main(int argc, char** argv) {
exit(EXIT_FAILURE);
}
err = loc_network_set_country_code(network1, "XX");
err = loc_network_set_country_code(network1, "DE");
if (err) {
fprintf(stderr, "Could not set country code\n");
exit(EXIT_FAILURE);
......@@ -113,7 +113,7 @@ int main(int argc, char** argv) {
exit(EXIT_FAILURE);
}
err = loc_network_set_country_code(network2, "XY");
err = loc_network_set_country_code(network2, "DE");
if (err) {
fprintf(stderr, "Could not set country code\n");
exit(EXIT_FAILURE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment