]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
network: Allow setting an empty country code
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 22:29:45 +0000 (22:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 22:29:45 +0000 (22:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network.c

index 3d386126f103bd3c8716ea3f98ad353588cd4a80..d960153170030aa554484041db0ee146ec4f8cc1 100644 (file)
@@ -288,6 +288,12 @@ LOC_EXPORT const char* loc_network_get_country_code(struct loc_network* network)
 }
 
 LOC_EXPORT int loc_network_set_country_code(struct loc_network* network, const char* country_code) {
 }
 
 LOC_EXPORT int loc_network_set_country_code(struct loc_network* network, const char* country_code) {
+       // Set empty country code
+       if (!country_code || !*country_code) {
+               *network->country_code = '\0';
+               return 0;
+       }
+
        // Country codes must be two characters
        if (strlen(country_code) != 2)
                return -EINVAL;
        // Country codes must be two characters
        if (strlen(country_code) != 2)
                return -EINVAL;