share debug.[ch] across all executables
This avoids us having to re-define log_info/log_info_cat for each
program.
Change-Id: I22f4f8a51b91ee09c5be26b1ed1bfca41730c577
diff --git a/src/Makefile.am b/src/Makefile.am
index ca799ce..5f0d846 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,15 +25,15 @@
pcsc_test_LDADD = $(OSMOCORE_LIBS) \
$(PCSC_LIBS) libosmo-rspro.la
-remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c
+remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c debug.c
remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) \
$(PCSC_LIBS) libosmo-rspro.la -lcsv
-remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c
+remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c debug.c
remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
libosmo-rspro.la
-simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c \
+simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c debug.c \
simtrace2/apdu_dispatch.c \
simtrace2/simtrace2-discovery.c \
simtrace2/libusb_util.c
diff --git a/src/bankd_main.c b/src/bankd_main.c
index 5e94afb..fde03cd 100644
--- a/src/bankd_main.c
+++ b/src/bankd_main.c
@@ -26,6 +26,7 @@
#include <osmocom/rspro/RsproPDU.h>
#include "bankd.h"
+#include "debug.h"
#include "rspro_util.h"
__thread void *talloc_asn1_ctx;
@@ -36,19 +37,6 @@
* bankd core / main thread
***********************************************************************/
-static const struct log_info_cat default_categories[] = {
- [DMAIN] = {
- .name = "DMAIN",
- .loglevel = LOGL_DEBUG,
- .enabled = 1,
- },
-};
-
-static const struct log_info log_info = {
- .cat = default_categories,
- .num_cat = ARRAY_SIZE(default_categories),
-};
-
int asn_debug;
static void bankd_init(struct bankd *bankd)
diff --git a/src/debug.c b/src/debug.c
new file mode 100644
index 0000000..046dc8c
--- /dev/null
+++ b/src/debug.c
@@ -0,0 +1,16 @@
+#include <osmocom/core/logging.h>
+#include <osmocom/core/utils.h>
+#include "debug.h"
+
+static const struct log_info_cat default_categories[] = {
+ [DMAIN] = {
+ .name = "DMAIN",
+ .loglevel = LOGL_DEBUG,
+ .enabled = 1,
+ },
+};
+
+const struct log_info log_info = {
+ .cat = default_categories,
+ .num_cat = ARRAY_SIZE(default_categories),
+};
diff --git a/src/debug.h b/src/debug.h
index 187d895..02551eb 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -3,3 +3,5 @@
enum {
DMAIN,
};
+
+extern const struct log_info log_info;
diff --git a/src/remsim_client.c b/src/remsim_client.c
index 2f740d4..0c2dcbe 100644
--- a/src/remsim_client.c
+++ b/src/remsim_client.c
@@ -15,6 +15,7 @@
#include "rspro_util.h"
#include "client.h"
+#include "debug.h"
static int bankd_handle_msg(struct bankd_client *bc, struct msgb *msg)
{
@@ -68,19 +69,6 @@
return -1;
}
-static const struct log_info_cat default_categories[] = {
- [DMAIN] = {
- .name = "DMAIN",
- .loglevel = LOGL_DEBUG,
- .enabled = 1,
- },
-};
-
-static const struct log_info log_info = {
- .cat = default_categories,
- .num_cat = ARRAY_SIZE(default_categories),
-};
-
static struct bankd_client *g_client;
static void *g_tall_ctx;
void __thread *talloc_asn1_ctx;
diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 79da419..0832300 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -15,6 +15,7 @@
#include "rspro_util.h"
#include "client.h"
+#include "debug.h"
#include <unistd.h>
#include <stdio.h>
@@ -619,19 +620,6 @@
}
-static const struct log_info_cat default_categories[] = {
- [DMAIN] = {
- .name = "DMAIN",
- .loglevel = LOGL_DEBUG,
- .enabled = 1,
- },
-};
-
-static const struct log_info log_info = {
- .cat = default_categories,
- .num_cat = ARRAY_SIZE(default_categories),
-};
-
static void print_welcome(void)
{
printf("simtrace2-remsim-client - Remote SIM card client for SIMtrace\n"