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 3d38612..d960153 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) {
+       // 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;