examples/utils: add nfc_exit() to signal traps
and one missing nfc_abort_command()
This commit is contained in:
parent
73b5c9d0af
commit
e55efd6db0
7 changed files with 23 additions and 9 deletions
|
@ -53,11 +53,13 @@ static nfc_device *pnd;
|
||||||
static void stop_dep_communication(int sig)
|
static void stop_dep_communication(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else
|
} else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
|
|
|
@ -52,11 +52,13 @@ static nfc_device *pnd;
|
||||||
static void stop_dep_communication(int sig)
|
static void stop_dep_communication(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else
|
} else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
|
|
|
@ -82,6 +82,7 @@ stop_emulation(int sig)
|
||||||
if (pnd != NULL) {
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
} else {
|
} else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,9 @@ intr_hdlr(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
printf("\nQuitting...\n");
|
printf("\nQuitting...\n");
|
||||||
|
if (pnd != NULL) {
|
||||||
|
nfc_abort_command(pnd);
|
||||||
|
}
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -58,9 +58,11 @@ static void stop_polling(int sig)
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd != NULL)
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else
|
else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_usage(const char *progname)
|
print_usage(const char *progname)
|
||||||
|
|
|
@ -237,11 +237,13 @@ nfcforum_tag4_io(struct nfc_emulator *emulator, const uint8_t *data_in, const si
|
||||||
static void stop_emulation(int sig)
|
static void stop_emulation(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else
|
} else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ndef_message_load(char *filename, struct nfcforum_tag4_ndef_data *tag_data)
|
ndef_message_load(char *filename, struct nfcforum_tag4_ndef_data *tag_data)
|
||||||
|
|
|
@ -72,11 +72,13 @@ print_usage(char *progname)
|
||||||
static void stop_select(int sig)
|
static void stop_select(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else
|
} else {
|
||||||
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_felica_frame(const nfc_felica_info nfi, const uint8_t command, const uint8_t *payload, const size_t payload_len, uint8_t *frame, size_t *frame_len)
|
build_felica_frame(const nfc_felica_info nfi, const uint8_t command, const uint8_t *payload, const size_t payload_len, uint8_t *frame, size_t *frame_len)
|
||||||
|
|
Loading…
Reference in a new issue