-code cleanup
This commit is contained in:
parent
8e0f06c86b
commit
3d4baa9969
@ -1484,6 +1484,8 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
|
|||||||
while (NULL != (lp = GNUNET_CONTAINER_heap_remove_root (h->lp_heap)))
|
while (NULL != (lp = GNUNET_CONTAINER_heap_remove_root (h->lp_heap)))
|
||||||
lp_trigger (lp,
|
lp_trigger (lp,
|
||||||
h);
|
h);
|
||||||
|
GNUNET_assert (0 ==
|
||||||
|
pthread_mutex_unlock (&h->big_lock));
|
||||||
GNUNET_break (sizeof (val) ==
|
GNUNET_break (sizeof (val) ==
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
write (h->lp_event,
|
write (h->lp_event,
|
||||||
@ -1492,8 +1494,6 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
|
|||||||
#endif
|
#endif
|
||||||
&val,
|
&val,
|
||||||
sizeof (val)));
|
sizeof (val)));
|
||||||
GNUNET_assert (0 ==
|
|
||||||
pthread_mutex_unlock (&h->big_lock));
|
|
||||||
GNUNET_break (0 ==
|
GNUNET_break (0 ==
|
||||||
pthread_join (h->lp_thread,
|
pthread_join (h->lp_thread,
|
||||||
&ret));
|
&ret));
|
||||||
@ -3012,7 +3012,7 @@ handle_bank_integration (struct TALER_FAKEBANK_Handle *h,
|
|||||||
char dummy;
|
char dummy;
|
||||||
|
|
||||||
if (1 != sscanf (lp_s,
|
if (1 != sscanf (lp_s,
|
||||||
"%lld%c",
|
"%llu%c",
|
||||||
&d,
|
&d,
|
||||||
&dummy))
|
&dummy))
|
||||||
{
|
{
|
||||||
@ -3427,6 +3427,7 @@ post_testing_register (struct TALER_FAKEBANK_Handle *h,
|
|||||||
acc = lookup_account (h,
|
acc = lookup_account (h,
|
||||||
username,
|
username,
|
||||||
username);
|
username);
|
||||||
|
GNUNET_assert (NULL != acc);
|
||||||
acc->password = GNUNET_strdup (password);
|
acc->password = GNUNET_strdup (password);
|
||||||
acc->balance = h->signup_bonus; /* magic money creation! */
|
acc->balance = h->signup_bonus; /* magic money creation! */
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ withdraw_cs_stage_two_callback (
|
|||||||
&wh->pd))
|
&wh->pd))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (wh);
|
break;
|
||||||
}
|
}
|
||||||
wh->wh2 = TALER_EXCHANGE_withdraw2 (wh->exchange,
|
wh->wh2 = TALER_EXCHANGE_withdraw2 (wh->exchange,
|
||||||
&wh->pd,
|
&wh->pd,
|
||||||
|
@ -82,7 +82,7 @@ struct JanssonClosure
|
|||||||
* Last bang we found.
|
* Last bang we found.
|
||||||
*/
|
*/
|
||||||
enum Bang found_bang;
|
enum Bang found_bang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language for i18n lookups.
|
* Language for i18n lookups.
|
||||||
*/
|
*/
|
||||||
@ -129,11 +129,11 @@ find (struct JanssonClosure *e, const char *name)
|
|||||||
|
|
||||||
if (0 == strcmp (bang, "i18n"))
|
if (0 == strcmp (bang, "i18n"))
|
||||||
e->found_bang = BANG_I18N;
|
e->found_bang = BANG_I18N;
|
||||||
else if (0 == strcmp(bang, "stringify"))
|
else if (0 == strcmp (bang, "stringify"))
|
||||||
e->found_bang = BANG_STRINGIFY;
|
e->found_bang = BANG_STRINGIFY;
|
||||||
else if (0 == strcmp(bang, "amount_decimal"))
|
else if (0 == strcmp (bang, "amount_decimal"))
|
||||||
e->found_bang = BANG_AMOUNT_CURRENCY;
|
e->found_bang = BANG_AMOUNT_CURRENCY;
|
||||||
else if (0 == strcmp(bang, "amount_currency"))
|
else if (0 == strcmp (bang, "amount_currency"))
|
||||||
e->found_bang = BANG_AMOUNT_DECIMAL;
|
e->found_bang = BANG_AMOUNT_DECIMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ find (struct JanssonClosure *e, const char *name)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
start(void *closure)
|
start (void *closure)
|
||||||
{
|
{
|
||||||
struct JanssonClosure *e = closure;
|
struct JanssonClosure *e = closure;
|
||||||
e->depth = 0;
|
e->depth = 0;
|
||||||
@ -174,25 +174,25 @@ static int
|
|||||||
emituw (void *closure, const char *buffer, size_t size, int escape, FILE *file)
|
emituw (void *closure, const char *buffer, size_t size, int escape, FILE *file)
|
||||||
{
|
{
|
||||||
struct JanssonClosure *e = closure;
|
struct JanssonClosure *e = closure;
|
||||||
if (!escape)
|
if (! escape)
|
||||||
e->writecb (file, buffer, size);
|
e->writecb (file, buffer, size);
|
||||||
else
|
else
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
switch (*buffer)
|
switch (*buffer)
|
||||||
{
|
{
|
||||||
case '<':
|
case '<':
|
||||||
e->writecb (file, "<", 4);
|
e->writecb (file, "<", 4);
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
e->writecb (file, ">", 4);
|
e->writecb (file, ">", 4);
|
||||||
break;
|
break;
|
||||||
case '&':
|
case '&':
|
||||||
e->writecb (file, "&", 5);
|
e->writecb (file, "&", 5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
e->writecb (file, buffer, 1);
|
e->writecb (file, buffer, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer++;
|
buffer++;
|
||||||
}
|
}
|
||||||
@ -202,10 +202,10 @@ emituw (void *closure, const char *buffer, size_t size, int escape, FILE *file)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
enter(void *closure, const char *name)
|
enter (void *closure, const char *name)
|
||||||
{
|
{
|
||||||
struct JanssonClosure *e = closure;
|
struct JanssonClosure *e = closure;
|
||||||
json_t *o = find(e, name);
|
json_t *o = find (e, name);
|
||||||
if (++e->depth >= MUSTACH_MAX_DEPTH)
|
if (++e->depth >= MUSTACH_MAX_DEPTH)
|
||||||
return MUSTACH_ERROR_TOO_DEEP;
|
return MUSTACH_ERROR_TOO_DEEP;
|
||||||
|
|
||||||
@ -277,6 +277,7 @@ next (void *closure)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
leave (void *closure)
|
leave (void *closure)
|
||||||
{
|
{
|
||||||
@ -287,12 +288,14 @@ leave (void *closure)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freecb (void *v)
|
freecb (void *v)
|
||||||
{
|
{
|
||||||
free (v);
|
free (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get (void *closure, const char *name, struct mustach_sbuf *sbuf)
|
get (void *closure, const char *name, struct mustach_sbuf *sbuf)
|
||||||
{
|
{
|
||||||
@ -300,7 +303,7 @@ get (void *closure, const char *name, struct mustach_sbuf *sbuf)
|
|||||||
json_t *obj;
|
json_t *obj;
|
||||||
|
|
||||||
if ( (0 == strcmp (name, "*") ) &&
|
if ( (0 == strcmp (name, "*") ) &&
|
||||||
(e->stack[e->depth].is_objiter ) )
|
(e->stack[e->depth].is_objiter) )
|
||||||
{
|
{
|
||||||
sbuf->value = json_object_iter_key (e->stack[e->depth].iter);
|
sbuf->value = json_object_iter_key (e->stack[e->depth].iter);
|
||||||
return MUSTACH_OK;
|
return MUSTACH_OK;
|
||||||
@ -310,64 +313,65 @@ get (void *closure, const char *name, struct mustach_sbuf *sbuf)
|
|||||||
{
|
{
|
||||||
switch (e->found_bang)
|
switch (e->found_bang)
|
||||||
{
|
{
|
||||||
case BANG_I18N:
|
case BANG_I18N:
|
||||||
case BANG_NONE:
|
case BANG_NONE:
|
||||||
|
{
|
||||||
|
const char *s = json_string_value (obj);
|
||||||
|
if (NULL != s)
|
||||||
{
|
{
|
||||||
const char *s = json_string_value (obj);
|
sbuf->value = s;
|
||||||
if (NULL != s)
|
return MUSTACH_OK;
|
||||||
{
|
|
||||||
sbuf->value = s;
|
|
||||||
return MUSTACH_OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case BANG_STRINGIFY:
|
break;
|
||||||
sbuf->value = json_dumps (obj, JSON_INDENT (2));
|
case BANG_STRINGIFY:
|
||||||
|
sbuf->value = json_dumps (obj, JSON_INDENT (2));
|
||||||
|
sbuf->freecb = freecb;
|
||||||
|
return MUSTACH_OK;
|
||||||
|
case BANG_AMOUNT_DECIMAL:
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
char *c;
|
||||||
|
if (! json_is_string (obj))
|
||||||
|
break;
|
||||||
|
s = GNUNET_strdup (json_string_value (obj));
|
||||||
|
c = strchr (s, ':');
|
||||||
|
if (NULL != c)
|
||||||
|
*c = 0;
|
||||||
|
sbuf->value = s;
|
||||||
sbuf->freecb = freecb;
|
sbuf->freecb = freecb;
|
||||||
return MUSTACH_OK;
|
return MUSTACH_OK;
|
||||||
case BANG_AMOUNT_DECIMAL:
|
}
|
||||||
{
|
break;
|
||||||
char *s;
|
case BANG_AMOUNT_CURRENCY:
|
||||||
char *c;
|
{
|
||||||
if (!json_is_string (obj))
|
const char *s;
|
||||||
break;
|
if (! json_is_string (obj))
|
||||||
s = strdup (json_string_value (obj));
|
break;
|
||||||
c = strchr (s, ':');
|
s = json_string_value (obj);
|
||||||
if (NULL != c)
|
s = strchr (s, ':');
|
||||||
*c = 0;
|
if (NULL == s)
|
||||||
sbuf->value = s;
|
break;
|
||||||
sbuf->freecb = freecb;
|
sbuf->value = s + 1;
|
||||||
return MUSTACH_OK;
|
return MUSTACH_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BANG_AMOUNT_CURRENCY:
|
default:
|
||||||
{
|
break;
|
||||||
const char *s;
|
|
||||||
if (!json_is_string (obj))
|
|
||||||
break;
|
|
||||||
s = json_string_value (obj);
|
|
||||||
s = strchr (s, ':');
|
|
||||||
if (NULL == s)
|
|
||||||
break;
|
|
||||||
sbuf->value = s + 1;
|
|
||||||
return MUSTACH_OK;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sbuf->value = "";
|
sbuf->value = "";
|
||||||
return MUSTACH_OK;
|
return MUSTACH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct mustach_itf itf = {
|
static struct mustach_itf itf = {
|
||||||
.start = start,
|
.start = start,
|
||||||
.put = NULL,
|
.put = NULL,
|
||||||
.enter = enter,
|
.enter = enter,
|
||||||
.next = next,
|
.next = next,
|
||||||
.leave = leave,
|
.leave = leave,
|
||||||
.partial =NULL,
|
.partial = NULL,
|
||||||
.get = get,
|
.get = get,
|
||||||
.emit = NULL,
|
.emit = NULL,
|
||||||
.stop = NULL
|
.stop = NULL
|
||||||
@ -385,33 +389,41 @@ static struct mustach_itf itfuw = {
|
|||||||
.stop = NULL
|
.stop = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int fmustach_jansson (const char *template, json_t *root, FILE *file)
|
int
|
||||||
|
fmustach_jansson (const char *template, json_t *root, FILE *file)
|
||||||
{
|
{
|
||||||
struct JanssonClosure e = { 0 };
|
struct JanssonClosure e = { 0 };
|
||||||
e.root = root;
|
e.root = root;
|
||||||
return fmustach(template, &itf, &e, file);
|
return fmustach (template, &itf, &e, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdmustach_jansson (const char *template, json_t *root, int fd)
|
|
||||||
|
int
|
||||||
|
fdmustach_jansson (const char *template, json_t *root, int fd)
|
||||||
{
|
{
|
||||||
struct JanssonClosure e = { 0 };
|
struct JanssonClosure e = { 0 };
|
||||||
e.root = root;
|
e.root = root;
|
||||||
return fdmustach(template, &itf, &e, fd);
|
return fdmustach (template, &itf, &e, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mustach_jansson (const char *template, json_t *root, char **result, size_t *size)
|
|
||||||
|
int
|
||||||
|
mustach_jansson (const char *template, json_t *root, char **result,
|
||||||
|
size_t *size)
|
||||||
{
|
{
|
||||||
struct JanssonClosure e = { 0 };
|
struct JanssonClosure e = { 0 };
|
||||||
e.root = root;
|
e.root = root;
|
||||||
e.writecb = NULL;
|
e.writecb = NULL;
|
||||||
return mustach(template, &itf, &e, result, size);
|
return mustach (template, &itf, &e, result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int umustach_jansson (const char *template, json_t *root, mustach_jansson_write_cb writecb, void *closure)
|
|
||||||
|
int
|
||||||
|
umustach_jansson (const char *template, json_t *root, mustach_jansson_write_cb
|
||||||
|
writecb, void *closure)
|
||||||
{
|
{
|
||||||
struct JanssonClosure e = { 0 };
|
struct JanssonClosure e = { 0 };
|
||||||
e.root = root;
|
e.root = root;
|
||||||
e.writecb = writecb;
|
e.writecb = writecb;
|
||||||
return fmustach(template, &itfuw, &e, closure);
|
return fmustach (template, &itfuw, &e, closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ get_cb (void *cls,
|
|||||||
}
|
}
|
||||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||||
ds->contract_ref);
|
ds->contract_ref);
|
||||||
|
GNUNET_assert (NULL != ref);
|
||||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||||
{
|
{
|
||||||
const struct TALER_PurseMergePrivateKeyP *mp;
|
const struct TALER_PurseMergePrivateKeyP *mp;
|
||||||
|
@ -91,6 +91,7 @@ closer_run (void *cls,
|
|||||||
|
|
||||||
rcmd = TALER_TESTING_interpreter_lookup_command (is,
|
rcmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||||
as->reserve_ref);
|
as->reserve_ref);
|
||||||
|
GNUNET_assert (NULL != rcmd);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_reserve_pub (rcmd,
|
TALER_TESTING_get_trait_reserve_pub (rcmd,
|
||||||
&reserve_pubp))
|
&reserve_pubp))
|
||||||
|
@ -163,7 +163,7 @@ deposit_cb (void *cls,
|
|||||||
|
|
||||||
purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
|
purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||||
ds->purse_ref);
|
ds->purse_ref);
|
||||||
|
GNUNET_assert (NULL != purse_cmd);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_reserve_sig (purse_cmd,
|
TALER_TESTING_get_trait_reserve_sig (purse_cmd,
|
||||||
&reserve_sig))
|
&reserve_sig))
|
||||||
@ -270,6 +270,7 @@ deposit_run (void *cls,
|
|||||||
|
|
||||||
purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
purse_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ds->purse_ref);
|
ds->purse_ref);
|
||||||
|
GNUNET_assert (NULL != purse_cmd);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_purse_pub (purse_cmd,
|
TALER_TESTING_get_trait_purse_pub (purse_cmd,
|
||||||
&purse_pub))
|
&purse_pub))
|
||||||
@ -291,13 +292,7 @@ deposit_run (void *cls,
|
|||||||
|
|
||||||
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||||
cr->command_ref);
|
cr->command_ref);
|
||||||
if (NULL == coin_cmd)
|
GNUNET_assert (NULL != coin_cmd);
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_coin_priv (coin_cmd,
|
TALER_TESTING_get_trait_coin_priv (coin_cmd,
|
||||||
cr->coin_index,
|
cr->coin_index,
|
||||||
|
@ -188,13 +188,7 @@ status_run (void *cls,
|
|||||||
create_purse
|
create_purse
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ss->purse_reference);
|
ss->purse_reference);
|
||||||
|
GNUNET_assert (NULL != create_purse);
|
||||||
if (NULL == create_purse)
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_purse_pub (create_purse,
|
TALER_TESTING_get_trait_purse_pub (create_purse,
|
||||||
&ss->purse_pub))
|
&ss->purse_pub))
|
||||||
@ -311,6 +305,7 @@ finish_run (void *cls,
|
|||||||
poll_purse
|
poll_purse
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ps->poll_reference);
|
ps->poll_reference);
|
||||||
|
GNUNET_assert (NULL != poll_purse);
|
||||||
GNUNET_assert (poll_purse->run == &status_run);
|
GNUNET_assert (poll_purse->run == &status_run);
|
||||||
ss = poll_purse->cls;
|
ss = poll_purse->cls;
|
||||||
if (NULL == ss->pgh)
|
if (NULL == ss->pgh)
|
||||||
|
@ -183,13 +183,7 @@ status_run (void *cls,
|
|||||||
create_reserve
|
create_reserve
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ss->reserve_reference);
|
ss->reserve_reference);
|
||||||
|
GNUNET_assert (NULL != create_reserve);
|
||||||
if (NULL == create_reserve)
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_reserve_pub (create_reserve,
|
TALER_TESTING_get_trait_reserve_pub (create_reserve,
|
||||||
&ss->reserve_pubp))
|
&ss->reserve_pubp))
|
||||||
@ -328,6 +322,7 @@ finish_run (void *cls,
|
|||||||
poll_reserve
|
poll_reserve
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ps->poll_reference);
|
ps->poll_reference);
|
||||||
|
GNUNET_assert (NULL != poll_reserve);
|
||||||
GNUNET_assert (poll_reserve->run == &status_run);
|
GNUNET_assert (poll_reserve->run == &status_run);
|
||||||
ss = poll_reserve->cls;
|
ss = poll_reserve->cls;
|
||||||
if (NULL == ss->rsh)
|
if (NULL == ss->rsh)
|
||||||
|
@ -105,6 +105,12 @@ wire_cb (void *cls,
|
|||||||
char *method;
|
char *method;
|
||||||
|
|
||||||
method = TALER_payto_get_method (accounts[i].payto_uri);
|
method = TALER_payto_get_method (accounts[i].payto_uri);
|
||||||
|
if (NULL == method)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (ws->is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (0 == strcmp (ws->expected_method,
|
if (0 == strcmp (ws->expected_method,
|
||||||
method))
|
method))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user