aboutsummaryrefslogtreecommitdiff
path: root/src/mintdb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-28 12:29:35 +0100
committerChristian Grothoff <christian@grothoff.org>2015-03-28 12:29:35 +0100
commit44b894ebe16f2646b49429bc45208dabb8bbc30b (patch)
tree5529b660eec8a9ce491673c0f594bb96c9a828dd /src/mintdb
parentc626ccac51dc968725b2ead1ecb0cebedd9987fc (diff)
more rename-fest work
Diffstat (limited to 'src/mintdb')
-rw-r--r--src/mintdb/mintdb_keyio.c46
-rw-r--r--src/mintdb/mintdb_plugin.c18
-rw-r--r--src/mintdb/test_mintdb.c12
-rw-r--r--src/mintdb/test_mintdb_deposits.c22
-rw-r--r--src/mintdb/test_mintdb_keyio.c10
5 files changed, 61 insertions, 47 deletions
diff --git a/src/mintdb/mintdb_keyio.c b/src/mintdb/mintdb_keyio.c
index 321b890c3..9add57974 100644
--- a/src/mintdb/mintdb_keyio.c
+++ b/src/mintdb/mintdb_keyio.c
@@ -34,7 +34,7 @@ struct SignkeysIterateContext
/**
* Function to call on each signing key.
*/
- TALER_MINT_SignkeyIterator it;
+ TALER_MINTDB_SigningKeyIterator it;
/**
* Closure for @e it.
@@ -60,12 +60,12 @@ signkeys_iterate_dir_iter (void *cls,
{
struct SignkeysIterateContext *skc = cls;
ssize_t nread;
- struct TALER_MintSigningKeyValidityPSPriv issue;
+ struct TALER_MINTDB_PrivateSigningKeyInformationP issue;
nread = GNUNET_DISK_fn_read (filename,
&issue,
- sizeof (struct TALER_MintSigningKeyValidityPSPriv));
- if (nread != sizeof (struct TALER_MintSigningKeyValidityPSPriv))
+ sizeof (struct TALER_MINTDB_PrivateSigningKeyInformationP));
+ if (nread != sizeof (struct TALER_MINTDB_PrivateSigningKeyInformationP))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Invalid signkey file `%s': wrong size\n",
@@ -82,7 +82,7 @@ signkeys_iterate_dir_iter (void *cls,
* Call @a it for each signing key found in the @a mint_base_dir.
*
* @param mint_base_dir base directory for the mint,
- * the signing keys must be in the #DIR_SIGNKEYS
+ * the signing keys must be in the #TALER_MINTDB_DIR_SIGNING_KEYS
* subdirectory
* @param it function to call on each signing key
* @param it_cls closure for @a it
@@ -91,16 +91,16 @@ signkeys_iterate_dir_iter (void *cls,
* files are simply skipped), -1 on error
*/
int
-TALER_MINT_signkeys_iterate (const char *mint_base_dir,
- TALER_MINT_SignkeyIterator it,
- void *it_cls)
+TALER_MINTDB_signing_keys_iterate (const char *mint_base_dir,
+ TALER_MINTDB_SigningKeyIterator it,
+ void *it_cls)
{
char *signkey_dir;
struct SignkeysIterateContext skc;
int ret;
GNUNET_asprintf (&signkey_dir,
- "%s" DIR_SEPARATOR_STR DIR_SIGNKEYS,
+ "%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_SIGNING_KEYS,
mint_base_dir);
skc.it = it;
skc.it_cls = it_cls;
@@ -121,8 +121,8 @@ TALER_MINT_signkeys_iterate (const char *mint_base_dir,
* #GNUNET_SYSERR upon failure
*/
int
-TALER_MINT_read_denom_key (const char *filename,
- struct TALER_DenominationKeyIssueInformation *dki)
+TALER_MINTDB_denomination_key_read (const char *filename,
+ struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
{
uint64_t size;
size_t offset;
@@ -183,8 +183,8 @@ TALER_MINT_read_denom_key (const char *filename,
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
*/
int
-TALER_MINT_write_denom_key (const char *filename,
- const struct TALER_DenominationKeyIssueInformation *dki)
+TALER_MINTDB_denomination_key_write (const char *filename,
+ const struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
{
char *priv_enc;
size_t priv_enc_size;
@@ -242,7 +242,7 @@ struct DenomkeysIterateContext
/**
* Function to call on each denomination key.
*/
- TALER_MINT_DenomkeyIterator it;
+ TALER_MINTDB_DenominationKeyIterator it;
/**
* Closure for @e it.
@@ -267,10 +267,10 @@ denomkeys_iterate_keydir_iter (void *cls,
const char *filename)
{
struct DenomkeysIterateContext *dic = cls;
- struct TALER_DenominationKeyIssueInformation issue;
+ struct TALER_MINTDB_DenominationKeyIssueInformation issue;
if (GNUNET_OK !=
- TALER_MINT_read_denom_key (filename,
+ TALER_MINTDB_denomination_key_read (filename,
&issue))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -285,7 +285,7 @@ denomkeys_iterate_keydir_iter (void *cls,
/**
- * Function called on each subdirectory in the #DIR_DENOMKEYS. Will
+ * Function called on each subdirectory in the #TALER_MINTDB_DIR_DENOMINATION_KEYS. Will
* call the #denomkeys_iterate_keydir_iter() on each file in the
* subdirectory.
*
@@ -313,7 +313,7 @@ denomkeys_iterate_topdir_iter (void *cls,
* Call @a it for each denomination key found in the @a mint_base_dir.
*
* @param mint_base_dir base directory for the mint,
- * the signing keys must be in the #DIR_DENOMKEYS
+ * the signing keys must be in the #TALER_MINTDB_DIR_DENOMINATION_KEYS
* subdirectory
* @param it function to call on each denomination key found
* @param it_cls closure for @a it
@@ -323,16 +323,16 @@ denomkeys_iterate_topdir_iter (void *cls,
* as maybe none of the files were well-formed)
*/
int
-TALER_MINT_denomkeys_iterate (const char *mint_base_dir,
- TALER_MINT_DenomkeyIterator it,
- void *it_cls)
+TALER_MINTDB_denomination_keys_iterate (const char *mint_base_dir,
+ TALER_MINTDB_DenominationKeyIterator it,
+ void *it_cls)
{
char *dir;
struct DenomkeysIterateContext dic;
int ret;
GNUNET_asprintf (&dir,
- "%s" DIR_SEPARATOR_STR DIR_DENOMKEYS,
+ "%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_DENOMINATION_KEYS,
mint_base_dir);
dic.it = it;
dic.it_cls = it_cls;
@@ -344,4 +344,4 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir,
}
-/* end of key_io.c */
+/* end of mintdb_keyio.c */
diff --git a/src/mintdb/mintdb_plugin.c b/src/mintdb/mintdb_plugin.c
index b109ff3d1..13d7c8f71 100644
--- a/src/mintdb/mintdb_plugin.c
+++ b/src/mintdb/mintdb_plugin.c
@@ -25,19 +25,13 @@
/**
- * Libtool search path before we started.
- */
-static char *old_dlsearchpath;
-
-
-/**
* Initialize the plugin.
*
* @param cfg configuration to use
* @return #GNUNET_OK on success
*/
struct TALER_MINTDB_Plugin *
-TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
+TALER_MINTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
char *plugin_name;
char *lib_name;
@@ -76,7 +70,7 @@ TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
* @param plugin the plugin to unload
*/
void
-TALER_MINT_plugin_unload (struct TALER_MINTDB_Plugin *plugin)
+TALER_MINTDB_plugin_unload (struct TALER_MINTDB_Plugin *plugin)
{
char *lib_name;
@@ -90,6 +84,12 @@ TALER_MINT_plugin_unload (struct TALER_MINTDB_Plugin *plugin)
/**
+ * Libtool search path before we started.
+ */
+static char *old_dlsearchpath;
+
+
+/**
* Setup libtool paths.
*/
void __attribute__ ((constructor))
@@ -146,4 +146,4 @@ plugin_fini ()
}
-/* end of plugin.c */
+/* end of mintdb_plugin.c */
diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c
index a82094075..b98a09cd5 100644
--- a/src/mintdb/test_mintdb.c
+++ b/src/mintdb/test_mintdb.c
@@ -19,7 +19,8 @@
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
#include "platform.h"
-#include "plugin.h"
+#include "taler_mintdb_lib.h"
+#include "taler_mintdb_plugin.h"
static int result;
@@ -40,6 +41,8 @@ static int result;
#define CURRENCY "EUR"
+static struct TALER_MINTDB_Plugin *plugin;
+
/**
* Checks if the given reserve has the given amount of balance and expiry
*
@@ -154,8 +157,8 @@ run (void *cls,
session = NULL;
ZR_BLK (&cbc);
ZR_BLK (&cbc2);
- if (GNUNET_OK !=
- TALER_MINT_plugin_load (cfg))
+ if (NULL ==
+ (plugin = TALER_MINTDB_plugin_load (cfg)))
{
result = 1;
return;
@@ -344,7 +347,8 @@ run (void *cls,
if (NULL != cbc2.sig.rsa_signature)
GNUNET_CRYPTO_rsa_signature_free (cbc2.sig.rsa_signature);
dkp = NULL;
- TALER_MINT_plugin_unload ();
+ TALER_MINTDB_plugin_unload (plugin);
+ plugin = NULL;
}
diff --git a/src/mintdb/test_mintdb_deposits.c b/src/mintdb/test_mintdb_deposits.c
index dbe12e88d..766bedd70 100644
--- a/src/mintdb/test_mintdb_deposits.c
+++ b/src/mintdb/test_mintdb_deposits.c
@@ -21,9 +21,11 @@
#include "platform.h"
#include <libpq-fe.h>
#include <gnunet/gnunet_util_lib.h>
-#include "plugin.h"
#include "taler_pq_lib.h"
-#include "taler-mint-httpd.h"
+#include "taler_mintdb_lib.h"
+#include "taler_mintdb_plugin.h"
+
+#define MINT_CURRENCY "EUR"
#define DB_URI "postgres:///taler"
@@ -51,6 +53,10 @@ static int persistent;
*/
static int result;
+/**
+ * The plugin.
+ */
+static struct TALER_MINTDB_Plugin *plugin;
/**
* Main function that will be run by the scheduler.
@@ -77,7 +83,7 @@ run (void *cls,
struct TALER_MINTDB_Session *session;
deposit = NULL;
- EXITIF (GNUNET_OK != TALER_MINT_plugin_load (cfg));
+ EXITIF (NULL == (plugin = TALER_MINTDB_plugin_load (cfg)));
EXITIF (GNUNET_OK !=
plugin->create_tables (plugin->cls,
! persistent));
@@ -98,8 +104,8 @@ run (void *cls,
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
deposit->amount_with_fee.fraction =
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
- GNUNET_assert (strlen (TMH_MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency));
- strcpy (deposit->amount_with_fee.currency, TMH_MINT_CURRENCY);
+ GNUNET_assert (strlen (MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency));
+ strcpy (deposit->amount_with_fee.currency, MINT_CURRENCY);
/* Copy wireformat */
deposit->wire = json_loads (wire, 0, NULL);
EXITIF (GNUNET_OK !=
@@ -114,7 +120,11 @@ run (void *cls,
EXITIF_exit:
GNUNET_free_non_null (deposit);
- return;
+ if (NULL != plugin)
+ {
+ TALER_MINTDB_plugin_unload (plugin);
+ plugin = NULL;
+ }
}
diff --git a/src/mintdb/test_mintdb_keyio.c b/src/mintdb/test_mintdb_keyio.c
index 83df25046..a32d64931 100644
--- a/src/mintdb/test_mintdb_keyio.c
+++ b/src/mintdb/test_mintdb_keyio.c
@@ -21,7 +21,7 @@
#include "platform.h"
#include "gnunet/gnunet_util_lib.h"
#include "taler_signatures.h"
-#include "key_io.h"
+#include "taler_mintdb_lib.h"
#define RSA_KEY_SIZE 1024
@@ -36,10 +36,10 @@ int
main (int argc,
const char *const argv[])
{
- struct TALER_DenominationKeyIssueInformation dki;
+ struct TALER_MINTDB_DenominationKeyIssueInformation dki;
char *enc;
size_t enc_size;
- struct TALER_DenominationKeyIssueInformation dki_read;
+ struct TALER_MINTDB_DenominationKeyIssueInformation dki_read;
char *enc_read;
size_t enc_read_size;
char *tmpfile;
@@ -60,8 +60,8 @@ main (int argc,
enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki.denom_priv.rsa_private_key,
&enc);
EXITIF (NULL == (tmpfile = GNUNET_DISK_mktemp ("test_mint_common")));
- EXITIF (GNUNET_OK != TALER_MINT_write_denom_key (tmpfile, &dki));
- EXITIF (GNUNET_OK != TALER_MINT_read_denom_key (tmpfile, &dki_read));
+ EXITIF (GNUNET_OK != TALER_MINTDB_denomination_key_write (tmpfile, &dki));
+ EXITIF (GNUNET_OK != TALER_MINTDB_denomination_key_read (tmpfile, &dki_read));
enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode (dki_read.denom_priv.rsa_private_key,
&enc_read);
EXITIF (enc_size != enc_read_size);