lib/kuhl-config.c
/** Returns 1 if the key is set to true in the config file. Returns 0
 * if it is set to false. Returns returnWhenMissing if the key is
 * missing. Returns returnInvalidValue if the key is set to a
 * non-boolean value. */
Returns 1 if the key is set to true in the config file. Returns 0
if it is set to false. Returns returnWhenMissing if the key is
missing. Returns returnInvalidValue if the key is set to a
non-boolean value.
Returns 1 if the key is set to true in the config file . Returns 0 if it is set to false . Returns returnWhenMissing if the key is missing . Returns returnInvalidValue if the key is set to a non - boolean value .
int kuhl_config_boolean(const char *key, int returnWhenMissing, int returnInvalidValue)
{
	const char *value = kuhl_config_get(key);
	if(value == NULL)
		return returnWhenMissing;
	else if(strcasecmp(value, "true") == 0 ||
	   strcasecmp(value, "yes") == 0 ||
	   strcasecmp(value, "y") == 0 ||
	   strcasecmp(value, "t") == 0 ||
	   strcmp(value, "1") == 0)
		return 1;
	else if(strcasecmp(value, "false") == 0 ||
	        strcasecmp(value, "no") == 0 ||
	        strcasecmp(value, "n") == 0 ||
	        strcasecmp(value, "f") == 0 ||
	        strcmp(value, "0") == 0)
		return 0;
	else
		return returnInvalidValue;
}
int kuhl_config_boolean ( const char * key , int returnWhenMissing , int returnInvalidValue ) { const char * value = kuhl_config_get ( key ) ; if ( value == NULL ) return returnWhenMissing ; else if ( strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcmp ( value , " " ) == 0 ) return 1 ; else if ( strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcasecmp ( value , " " ) == 0 || strcmp ( value , " " ) == 0 ) return 0 ; else return returnInvalidValue ; }
Returns 1 if the key is set to true in the config file.
Returns 1 if the key is set to true in the config file .