@@ -138,9 +138,20 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
138
138
}
139
139
}
140
140
141
+ // A wrapper function that actually takes a bool argument
142
+ static int tox_config_lookup_bool (const config_t * config , const char * path , bool * bool_value )
143
+ {
144
+ int int_value = 0 ;
145
+ if (config_lookup_bool (config , path , & int_value ) == CONFIG_FALSE ) {
146
+ return CONFIG_FALSE ;
147
+ }
148
+ * bool_value = int_value != 0 ;
149
+ return CONFIG_TRUE ;
150
+ }
151
+
141
152
bool get_general_config (const char * cfg_file_path , char * * pid_file_path , char * * keys_file_path , int * port ,
142
- int * enable_ipv6 , int * enable_ipv4_fallback , int * enable_lan_discovery , int * enable_tcp_relay ,
143
- uint16_t * * tcp_relay_ports , int * tcp_relay_port_count , int * enable_motd , char * * motd )
153
+ bool * enable_ipv6 , bool * enable_ipv4_fallback , bool * enable_lan_discovery , bool * enable_tcp_relay ,
154
+ uint16_t * * tcp_relay_ports , int * tcp_relay_port_count , bool * enable_motd , char * * motd )
144
155
{
145
156
config_t cfg ;
146
157
@@ -207,51 +218,51 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
207
218
memcpy (* keys_file_path , tmp_keys_file , keys_file_path_len );
208
219
209
220
// Get IPv6 option
210
- if (config_lookup_bool (& cfg , NAME_ENABLE_IPV6 , enable_ipv6 ) == CONFIG_FALSE ) {
221
+ if (tox_config_lookup_bool (& cfg , NAME_ENABLE_IPV6 , enable_ipv6 ) == CONFIG_FALSE ) {
211
222
log_write (LOG_LEVEL_WARNING , "No '%s' setting in configuration file.\n" , NAME_ENABLE_IPV6 );
212
223
log_write (LOG_LEVEL_WARNING , "Using default '%s': %s\n" , NAME_ENABLE_IPV6 , DEFAULT_ENABLE_IPV6 ? "true" : "false" );
213
224
* enable_ipv6 = DEFAULT_ENABLE_IPV6 ;
214
225
}
215
226
216
227
// Get IPv4 fallback option
217
- if (config_lookup_bool (& cfg , NAME_ENABLE_IPV4_FALLBACK , enable_ipv4_fallback ) == CONFIG_FALSE ) {
228
+ if (tox_config_lookup_bool (& cfg , NAME_ENABLE_IPV4_FALLBACK , enable_ipv4_fallback ) == CONFIG_FALSE ) {
218
229
log_write (LOG_LEVEL_WARNING , "No '%s' setting in configuration file.\n" , NAME_ENABLE_IPV4_FALLBACK );
219
230
log_write (LOG_LEVEL_WARNING , "Using default '%s': %s\n" , NAME_ENABLE_IPV4_FALLBACK ,
220
231
DEFAULT_ENABLE_IPV4_FALLBACK ? "true" : "false" );
221
232
* enable_ipv4_fallback = DEFAULT_ENABLE_IPV4_FALLBACK ;
222
233
}
223
234
224
235
// Get LAN discovery option
225
- if (config_lookup_bool (& cfg , NAME_ENABLE_LAN_DISCOVERY , enable_lan_discovery ) == CONFIG_FALSE ) {
236
+ if (tox_config_lookup_bool (& cfg , NAME_ENABLE_LAN_DISCOVERY , enable_lan_discovery ) == CONFIG_FALSE ) {
226
237
log_write (LOG_LEVEL_WARNING , "No '%s' setting in configuration file.\n" , NAME_ENABLE_LAN_DISCOVERY );
227
238
log_write (LOG_LEVEL_WARNING , "Using default '%s': %s\n" , NAME_ENABLE_LAN_DISCOVERY ,
228
239
DEFAULT_ENABLE_LAN_DISCOVERY ? "true" : "false" );
229
240
* enable_lan_discovery = DEFAULT_ENABLE_LAN_DISCOVERY ;
230
241
}
231
242
232
243
// Get TCP relay option
233
- if (config_lookup_bool (& cfg , NAME_ENABLE_TCP_RELAY , enable_tcp_relay ) == CONFIG_FALSE ) {
244
+ if (tox_config_lookup_bool (& cfg , NAME_ENABLE_TCP_RELAY , enable_tcp_relay ) == CONFIG_FALSE ) {
234
245
log_write (LOG_LEVEL_WARNING , "No '%s' setting in configuration file.\n" , NAME_ENABLE_TCP_RELAY );
235
246
log_write (LOG_LEVEL_WARNING , "Using default '%s': %s\n" , NAME_ENABLE_TCP_RELAY ,
236
247
DEFAULT_ENABLE_TCP_RELAY ? "true" : "false" );
237
248
* enable_tcp_relay = DEFAULT_ENABLE_TCP_RELAY ;
238
249
}
239
250
240
- if (* enable_tcp_relay != 0 ) {
251
+ if (* enable_tcp_relay ) {
241
252
parse_tcp_relay_ports_config (& cfg , tcp_relay_ports , tcp_relay_port_count );
242
253
} else {
243
254
* tcp_relay_port_count = 0 ;
244
255
}
245
256
246
257
// Get MOTD option
247
- if (config_lookup_bool (& cfg , NAME_ENABLE_MOTD , enable_motd ) == CONFIG_FALSE ) {
258
+ if (tox_config_lookup_bool (& cfg , NAME_ENABLE_MOTD , enable_motd ) == CONFIG_FALSE ) {
248
259
log_write (LOG_LEVEL_WARNING , "No '%s' setting in configuration file.\n" , NAME_ENABLE_MOTD );
249
260
log_write (LOG_LEVEL_WARNING , "Using default '%s': %s\n" , NAME_ENABLE_MOTD ,
250
261
DEFAULT_ENABLE_MOTD ? "true" : "false" );
251
262
* enable_motd = DEFAULT_ENABLE_MOTD ;
252
263
}
253
264
254
- if (* enable_motd != 0 ) {
265
+ if (* enable_motd ) {
255
266
// Get MOTD
256
267
const char * tmp_motd ;
257
268
@@ -273,14 +284,14 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
273
284
log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_PID_FILE_PATH , * pid_file_path );
274
285
log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_KEYS_FILE_PATH , * keys_file_path );
275
286
log_write (LOG_LEVEL_INFO , "'%s': %d\n" , NAME_PORT , * port );
276
- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV6 , * enable_ipv6 != 0 ? "true" : "false" );
277
- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV4_FALLBACK , * enable_ipv4_fallback != 0 ? "true" : "false" );
278
- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_LAN_DISCOVERY , * enable_lan_discovery != 0 ? "true" : "false" );
287
+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV6 , * enable_ipv6 ? "true" : "false" );
288
+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_IPV4_FALLBACK , * enable_ipv4_fallback ? "true" : "false" );
289
+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_LAN_DISCOVERY , * enable_lan_discovery ? "true" : "false" );
279
290
280
- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_TCP_RELAY , * enable_tcp_relay != 0 ? "true" : "false" );
291
+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_TCP_RELAY , * enable_tcp_relay ? "true" : "false" );
281
292
282
293
// Show info about tcp ports only if tcp relay is enabled
283
- if (* enable_tcp_relay != 0 ) {
294
+ if (* enable_tcp_relay ) {
284
295
if (* tcp_relay_port_count == 0 ) {
285
296
log_write (LOG_LEVEL_ERROR , "No TCP ports could be read.\n" );
286
297
} else {
@@ -292,9 +303,9 @@ bool get_general_config(const char *cfg_file_path, char **pid_file_path, char **
292
303
}
293
304
}
294
305
295
- log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_MOTD , * enable_motd != 0 ? "true" : "false" );
306
+ log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_ENABLE_MOTD , * enable_motd ? "true" : "false" );
296
307
297
- if (* enable_motd != 0 ) {
308
+ if (* enable_motd ) {
298
309
log_write (LOG_LEVEL_INFO , "'%s': %s\n" , NAME_MOTD , * motd );
299
310
}
300
311
0 commit comments