diff --git a/configure.ac b/configure.ac index f4b2964..cc2a577 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,17 @@ then AC_DEFINE([LOG], [1], [Enable log]) fi +# Conf support (default:yes) +AC_ARG_ENABLE([conf],AS_HELP_STRING([--disable-conf],[Disable use of config files and environment variables]),[enable_conf=$enableval],[enable_conf="yes"]) +AC_MSG_CHECKING(for conf flag) +AC_MSG_RESULT($enable_conf) +AM_CONDITIONAL([WITH_CONF], [test "$enable_conf" != "no"]) + +if test x"$enable_conf" = "xyes" +then + AC_DEFINE([CONF], [1], [Enable conf]) +fi + # Debug support (default:no) AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug mode]),[enable_debug=$enableval],[enable_debug="no"]) AC_MSG_CHECKING(for debug flag) diff --git a/libnfc/conf.c b/libnfc/conf.c index 6e0c967..2fa744f 100644 --- a/libnfc/conf.c +++ b/libnfc/conf.c @@ -21,6 +21,7 @@ # include "config.h" #endif // HAVE_CONFIG_H +#ifdef CONF #include #include #include @@ -189,3 +190,5 @@ conf_load(nfc_context *context) conf_devices_load(LIBNFC_DEVICECONFDIR, context); } +#endif // CONF + diff --git a/libnfc/log-printf.c b/libnfc/log-printf.c index c2feaf9..d0405d5 100644 --- a/libnfc/log-printf.c +++ b/libnfc/log-printf.c @@ -34,9 +34,13 @@ void log_init(const nfc_context *context) { +#ifdef CONF char str[32]; sprintf(str, "%"PRIu32, context->log_level); setenv("LIBNFC_LOG_LEVEL", str, 1); +#else + (void)context; +#endif } void @@ -47,7 +51,10 @@ log_exit(void) void log_put(const uint8_t group, const char *category, const uint8_t priority, const char *format, ...) { - char *env_log_level = getenv("LIBNFC_LOG_LEVEL"); + char *env_log_level = NULL; +#ifdef CONF + env_log_level = getenv("LIBNFC_LOG_LEVEL"); +#endif uint32_t log_level; if (NULL == env_log_level) { // LIBNFC_LOG_LEVEL is not set diff --git a/libnfc/nfc-internal.c b/libnfc/nfc-internal.c index 96d71a8..8afa5fb 100644 --- a/libnfc/nfc-internal.c +++ b/libnfc/nfc-internal.c @@ -24,7 +24,14 @@ #include #include "nfc-internal.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef CONF #include "conf.h" +#endif #include #include @@ -81,6 +88,7 @@ nfc_context_new(void) } res->user_defined_device_count = 0; +#ifdef CONF // Load user defined device from environment variable at first char *envvar = getenv("LIBNFC_DEFAULT_DEVICE"); if (envvar) { @@ -102,6 +110,7 @@ nfc_context_new(void) if (envvar) { res->log_level = atoi(envvar); } +#endif // CONF // Initialize log before use it... log_init(res); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index bb3a302..a9fe746 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -294,6 +294,7 @@ nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], const size_ { size_t device_found = 0; +#ifdef CONF // Load manually configured devices (from config file and env variables) // TODO From env var... for (uint32_t i = 0; i < context->user_defined_device_count; i++) { @@ -334,6 +335,7 @@ nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], const size_ return device_found; } } +#endif // CONF // Device auto-detection if (context->allow_autoscan) {