check return value from GNUNET_PROGRAM_run in taler-wire

This commit is contained in:
Christian Grothoff 2019-06-03 00:31:19 +02:00
parent 7d142ad261
commit 8d26ab35e0
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -16,7 +16,6 @@
License along with TALER; see the file COPYING. If not, License along with TALER; see the file COPYING. If not,
see <http://www.gnu.org/licenses/> see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file taler-wire.c * @file taler-wire.c
* @brief Utility performing wire transfers. * @brief Utility performing wire transfers.
@ -69,7 +68,7 @@ char *since_when;
/** /**
* Which config section has the credentials to access the bank. * Which config section has the credentials to access the bank.
*/ */
char *account_section; char *account_section;
/** /**
* URL identifying the account that is going to receive the * URL identifying the account that is going to receive the
@ -102,7 +101,7 @@ struct TALER_WIRE_Plugin *plugin_handle;
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to * @return #GNUNET_OK to continue, #GNUNET_SYSERR to
* abort iteration * abort iteration
*/ */
int static int
history_cb (void *cls, history_cb (void *cls,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
enum TALER_BANK_Direction dir, enum TALER_BANK_Direction dir,
@ -133,11 +132,12 @@ history_cb (void *cls,
return GNUNET_OK; return GNUNET_OK;
} }
/** /**
* Callback that processes the outcome of a wire transfer * Callback that processes the outcome of a wire transfer
* execution. * execution.
*/ */
void static void
confirmation_cb (void *cls, confirmation_cb (void *cls,
int success, int success,
const void *row_id, const void *row_id,
@ -147,7 +147,7 @@ confirmation_cb (void *cls,
if (GNUNET_YES != success) if (GNUNET_YES != success)
{ {
fprintf (stderr, fprintf (stderr,
"The wire transfer didn't execute correctly.\n"); "The wire transfer didn't execute correctly.\n");
GNUNET_assert (NULL != emsg); GNUNET_assert (NULL != emsg);
fprintf (stderr, fprintf (stderr,
"%s", "%s",
@ -171,7 +171,7 @@ confirmation_cb (void *cls,
* @param buf prepared wire transfer data. * @param buf prepared wire transfer data.
* @param buf_size size of the prepared wire transfer data. * @param buf_size size of the prepared wire transfer data.
*/ */
void static void
prepare_cb (void *cls, prepare_cb (void *cls,
const char *buf, const char *buf,
size_t buf_size) size_t buf_size)
@ -186,7 +186,7 @@ prepare_cb (void *cls,
NULL))) NULL)))
{ {
fprintf (stderr, fprintf (stderr,
"Could not execute the wire transfer\n"); "Could not execute the wire transfer\n");
plugin_handle->prepare_wire_transfer_cancel plugin_handle->prepare_wire_transfer_cancel
(plugin_handle->cls, (plugin_handle->cls,
@ -204,7 +204,7 @@ prepare_cb (void *cls,
/** /**
* Ask the bank to execute a wire transfer. * Ask the bank to execute a wire transfer.
*/ */
void static void
execute_wire_transfer () execute_wire_transfer ()
{ {
struct TALER_Amount a; struct TALER_Amount a;
@ -222,7 +222,7 @@ execute_wire_transfer ()
&a)) &a))
{ {
fprintf (stderr, fprintf (stderr,
"Amount string incorrect.\n"); "Amount string incorrect.\n");
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
@ -230,7 +230,7 @@ execute_wire_transfer ()
{ {
fprintf (stderr, fprintf (stderr,
"Please give destination" "Please give destination"
" account URL (--destination/-d)\n"); " account URL (--destination/-d)\n");
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
@ -250,11 +250,12 @@ execute_wire_transfer ()
} }
} }
/** /**
* Ask the bank the list of transactions for the bank account * Ask the bank the list of transactions for the bank account
* mentioned in the config section given by the user. * mentioned in the config section given by the user.
*/ */
void static void
execute_history () execute_history ()
{ {
size_t bin_len = 0; size_t bin_len = 0;
@ -290,9 +291,9 @@ execute_history ()
} }
} }
/** /**
* Gets executed upon shutdown. Main duty is * Gets executed upon shutdown. Main duty is wire-plugin unloading.
* wire-plugin unloading.
* *
* @param cls closure. * @param cls closure.
*/ */
@ -302,6 +303,7 @@ do_shutdown (void *cls)
TALER_WIRE_plugin_unload (plugin_handle); TALER_WIRE_plugin_unload (plugin_handle);
} }
/** /**
* Main function that will be run. * Main function that will be run.
* *
@ -357,6 +359,7 @@ run (void *cls,
NULL); NULL);
} }
/** /**
* Main function of taler-wire. This tool is used to command the * Main function of taler-wire. This tool is used to command the
* execution of wire transfers from the command line. Its main * execution of wire transfers from the command line. Its main
@ -372,18 +375,15 @@ main (int argc,
char *const *argv) char *const *argv)
{ {
struct GNUNET_GETOPT_CommandLineOption options[] = { struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('H', GNUNET_GETOPT_option_flag ('H',
"history", "history",
"Ask to get a list of 10" "Ask to get a list of 10"
" transactions.", " transactions.",
&history), &history),
GNUNET_GETOPT_option_flag ('t', GNUNET_GETOPT_option_flag ('t',
"transfer", "transfer",
"Execute a wire transfer.", "Execute a wire transfer.",
&transfer), &transfer),
GNUNET_GETOPT_option_string ('w', GNUNET_GETOPT_option_string ('w',
"since-when", "since-when",
"SW", "SW",
@ -395,7 +395,6 @@ main (int argc,
" the 10 youngest transactions" " the 10 youngest transactions"
" are returned.", " are returned.",
&since_when), &since_when),
GNUNET_GETOPT_option_string ('s', GNUNET_GETOPT_option_string ('s',
"section", "section",
"ACCOUNT-SECTION", "ACCOUNT-SECTION",
@ -403,13 +402,11 @@ main (int argc,
" credentials to access the" " credentials to access the"
" bank. Mandatory.\n", " bank. Mandatory.\n",
&account_section), &account_section),
GNUNET_GETOPT_option_string ('a', GNUNET_GETOPT_option_string ('a',
"amount", "amount",
"AMOUNT", "AMOUNT",
"Specify the amount to transfer.", "Specify the amount to transfer.",
&amount), &amount),
GNUNET_GETOPT_option_string ('d', GNUNET_GETOPT_option_string ('d',
"destination", "destination",
"PAYTO-URL", "PAYTO-URL",
@ -418,12 +415,13 @@ main (int argc,
&destination_account_url), &destination_account_url),
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };
int ret;
GNUNET_assert GNUNET_assert
(GNUNET_OK == GNUNET_log_setup ("taler-wire", (GNUNET_OK == GNUNET_log_setup ("taler-wire",
"WARNING", "WARNING",
NULL)); /* filename */ NULL)); /* filename */
GNUNET_PROGRAM_run ret = GNUNET_PROGRAM_run
(argc, (argc,
argv, argv,
"taler-wire", "taler-wire",
@ -431,6 +429,9 @@ main (int argc,
options, options,
&run, &run,
NULL); NULL);
if (GNUNET_OK != ret)
return ret;
return global_ret; return global_ret;
} }
/* end of taler-wire.c */