@@ -134,9 +134,9 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
134134 }
135135}
136136
137- int get_general_config (const char * cfg_file_path , char * * pid_file_path , char * * keys_file_path , int * port ,
138- int * enable_ipv6 , int * enable_ipv4_fallback , int * enable_lan_discovery , int * enable_tcp_relay ,
139- uint16_t * * tcp_relay_ports , int * tcp_relay_port_count , int * enable_motd , char * * motd )
137+ bool get_general_config (const char * cfg_file_path , char * * pid_file_path , char * * keys_file_path , int * port ,
138+ int * enable_ipv6 , int * enable_ipv4_fallback , int * enable_lan_discovery , int * enable_tcp_relay ,
139+ uint16_t * * tcp_relay_ports , int * tcp_relay_port_count , int * enable_motd , char * * motd )
140140{
141141 config_t cfg ;
142142
@@ -156,7 +156,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
156156 if (config_read_file (& cfg , cfg_file_path ) == CONFIG_FALSE ) {
157157 log_write (LOG_LEVEL_ERROR , "%s:%d - %s\n" , config_error_file (& cfg ), config_error_line (& cfg ), config_error_text (& cfg ));
158158 config_destroy (& cfg );
159- return 0 ;
159+ return false ;
160160 }
161161
162162 // Get port
@@ -223,7 +223,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
223223 * enable_tcp_relay = DEFAULT_ENABLE_TCP_RELAY ;
224224 }
225225
226- if (* enable_tcp_relay ) {
226+ if (* enable_tcp_relay != 0 ) {
227227 parse_tcp_relay_ports_config (& cfg , tcp_relay_ports , tcp_relay_port_count );
228228 } else {
229229 * tcp_relay_port_count = 0 ;
@@ -237,7 +237,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
237237 * enable_motd = DEFAULT_ENABLE_MOTD ;
238238 }
239239
240- if (* enable_motd ) {
240+ if (* enable_motd != 0 ) {
241241 // Get MOTD
242242 const char * tmp_motd ;
243243
@@ -259,14 +259,14 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
259259 log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_PID_FILE_PATH , * pid_file_path );
260260 log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_KEYS_FILE_PATH , * keys_file_path );
261261 log_write (LOG_LEVEL_INFO , "'%s': %d\n" , NAME_PORT , * port );
262- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV6 , * enable_ipv6 ? "true" : "false" );
263- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV4_FALLBACK , * enable_ipv4_fallback ? "true" : "false" );
264- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_LAN_DISCOVERY , * enable_lan_discovery ? "true" : "false" );
262+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV6 , * enable_ipv6 != 0 ? "true" : "false" );
263+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV4_FALLBACK , * enable_ipv4_fallback != 0 ? "true" : "false" );
264+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_LAN_DISCOVERY , * enable_lan_discovery != 0 ? "true" : "false" );
265265
266- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_TCP_RELAY , * enable_tcp_relay ? "true" : "false" );
266+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_TCP_RELAY , * enable_tcp_relay != 0 ? "true" : "false" );
267267
268268 // Show info about tcp ports only if tcp relay is enabled
269- if (* enable_tcp_relay ) {
269+ if (* enable_tcp_relay != 0 ) {
270270 if (* tcp_relay_port_count == 0 ) {
271271 log_write (LOG_LEVEL_ERROR , "No TCP ports could be read.\n" );
272272 } else {
@@ -278,13 +278,13 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
278278 }
279279 }
280280
281- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_MOTD , * enable_motd ? "true" : "false" );
281+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_MOTD , * enable_motd != 0 ? "true" : "false" );
282282
283- if (* enable_motd ) {
283+ if (* enable_motd != 0 ) {
284284 log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_MOTD , * motd );
285285 }
286286
287- return 1 ;
287+ return true ;
288288}
289289
290290/**
@@ -316,7 +316,7 @@ static uint8_t *bootstrap_hex_string_to_bin(const char *hex_string)
316316 return ret ;
317317}
318318
319- int bootstrap_from_config (const char * cfg_file_path , DHT * dht , int enable_ipv6 )
319+ bool bootstrap_from_config (const char * cfg_file_path , DHT * dht , bool enable_ipv6 )
320320{
321321 const char * const NAME_BOOTSTRAP_NODES = "bootstrap_nodes" ;
322322
@@ -331,7 +331,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
331331 if (config_read_file (& cfg , cfg_file_path ) == CONFIG_FALSE ) {
332332 log_write (LOG_LEVEL_ERROR , "%s:%d - %s\n" , config_error_file (& cfg ), config_error_line (& cfg ), config_error_text (& cfg ));
333333 config_destroy (& cfg );
334- return 0 ;
334+ return false ;
335335 }
336336
337337 config_setting_t * node_list = config_lookup (& cfg , NAME_BOOTSTRAP_NODES );
@@ -340,13 +340,13 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
340340 log_write (LOG_LEVEL_WARNING , "No '%s' setting in the configuration file. Skipping bootstrapping.\n" ,
341341 NAME_BOOTSTRAP_NODES );
342342 config_destroy (& cfg );
343- return 1 ;
343+ return true ;
344344 }
345345
346346 if (config_setting_length (node_list ) == 0 ) {
347347 log_write (LOG_LEVEL_WARNING , "No bootstrap nodes found. Skipping bootstrapping.\n" );
348348 config_destroy (& cfg );
349- return 1 ;
349+ return true ;
350350 }
351351
352352 int bs_port ;
@@ -357,15 +357,15 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
357357
358358 int i = 0 ;
359359
360- while (config_setting_length (node_list )) {
361- int address_resolved ;
360+ while (config_setting_length (node_list ) != 0 ) {
361+ bool address_resolved ;
362362 uint8_t * bs_public_key_bin ;
363363
364364 node = config_setting_get_elem (node_list , 0 );
365365
366366 if (node == nullptr ) {
367367 config_destroy (& cfg );
368- return 0 ;
368+ return false ;
369369 }
370370
371371 // Check that all settings are present
@@ -421,5 +421,5 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
421421
422422 config_destroy (& cfg );
423423
424- return 1 ;
424+ return true ;
425425}
0 commit comments