From: Michael Tremer Date: Tue, 30 Jan 2018 22:29:45 +0000 (+0000) Subject: network: Allow setting an empty country code X-Git-Tag: 0.9.0~88 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=901ef8828b949b6887b69abd452df1efaa5cf368 network: Allow setting an empty country code Signed-off-by: Michael Tremer --- diff --git a/src/network.c b/src/network.c index 3d38612..d960153 100644 --- a/src/network.c +++ b/src/network.c @@ -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;