summaryrefslogtreecommitdiff
path: root/src/wire
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-03 19:23:34 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-03 19:24:08 +0100
commit4d2faa5ec92213efc4ee40f707ab0ad3615e5433 (patch)
tree4bb94dba0c77cca9d0ba6b7fb223bc9476edc08e /src/wire
parentd06dac625072cad6888c9d0a77f6bd19faa5f2d9 (diff)
downloadexchange-4d2faa5ec92213efc4ee40f707ab0ad3615e5433.tar.gz
exchange-4d2faa5ec92213efc4ee40f707ab0ad3615e5433.tar.bz2
exchange-4d2faa5ec92213efc4ee40f707ab0ad3615e5433.zip
changing wire plugin specification from [exchange]WIREFORMAT to [exchange-wire-PLUGIN]enable=YES/NO
Diffstat (limited to 'src/wire')
-rw-r--r--src/wire/wire-sepa.conf6
-rw-r--r--src/wire/wire-test.conf6
-rw-r--r--src/wire/wire.c78
3 files changed, 89 insertions, 1 deletions
diff --git a/src/wire/wire-sepa.conf b/src/wire/wire-sepa.conf
index b7c09153f..88d2ac03c 100644
--- a/src/wire/wire-sepa.conf
+++ b/src/wire/wire-sepa.conf
@@ -1,5 +1,11 @@
+# This file is in the public domain.
+#
# Configuration for SEPA wire plugin.
+[exchange-wire-sepa]
+# Set to "YES" to activate the 'sepa' plugin.
+ENABLE = NO
+
[exchange-wire-incoming-sepa]
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
diff --git a/src/wire/wire-test.conf b/src/wire/wire-test.conf
index fc03f1b83..fcc156426 100644
--- a/src/wire/wire-test.conf
+++ b/src/wire/wire-test.conf
@@ -1,5 +1,11 @@
# This file is in the public domain.
#
+# Configuration for TEST wire plugin.
+#
+[exchange-wire-test]
+# Set to "YES" to activate the 'test' plugin.
+ENABLE = NO
+
[exchange-wire-incoming-test]
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
diff --git a/src/wire/wire.c b/src/wire/wire.c
index 4d53b0d0b..c799334f9 100644
--- a/src/wire/wire.c
+++ b/src/wire/wire.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2015, 2016 GNUnet e.V.
+ (C) 2015, 2016, 2017 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -69,4 +69,80 @@ TALER_WIRE_plugin_unload (struct TALER_WIRE_Plugin *plugin)
}
+/**
+ * Closure of #check_for_wire.
+ */
+struct FindEnabledWireContext
+{
+ /**
+ * Configuration we are usign.
+ */
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ /**
+ * Callback to invoke.
+ */
+ TALER_WIRE_EnabledCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+};
+
+
+/**
+ * Check if @a section begins with "exchange-wire-", and if
+ * so if the "ENABLE" option is set to "YES". If both are
+ * true, call the callback from the context with the
+ * rest of the section name.
+ *
+ * @param cls our `struct FindEnabledWireContext`
+ * @param section name of a section in the configuration
+ */
+static void
+check_for_wire (void *cls,
+ const char *section)
+{
+ struct FindEnabledWireContext *ctx = cls;
+ const char *name;
+
+ if (0 != strncasecmp (section,
+ "exchange-wire-",
+ strlen ("exchange-wire-")))
+ return;
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (ctx->cfg,
+ section,
+ "ENABLE"))
+ return;
+ name = &section[strlen ("exchange-wire-")];
+ ctx->cb (ctx->cb_cls,
+ name);
+}
+
+
+/**
+ * Check which wire plugins are enabled in @a cfg and call @a cb for each one.
+ *
+ * @param cfg configuration to use
+ * @param cb callback to invoke
+ * @param cb_cls closure for @a cb
+ */
+void
+TALER_WIRE_find_enabled (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ TALER_WIRE_EnabledCallback cb,
+ void *cb_cls)
+{
+ struct FindEnabledWireContext ctx;
+
+ ctx.cfg = cfg;
+ ctx.cb = cb;
+ ctx.cb_cls = cb_cls;
+ GNUNET_CONFIGURATION_iterate_sections (cfg,
+ &check_for_wire,
+ &ctx);
+}
+
+
/* end of wire.c */