sends lib log to /dev/null in posix and added option (v) to reactivate
There in an error handling and messaging inside
This commit is contained in:
parent
3f4b7a037a
commit
4e922e8194
1 changed files with 28 additions and 1 deletions
|
@ -54,6 +54,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <nfc/nfc.h>
|
#include <nfc/nfc.h>
|
||||||
|
|
||||||
#include "mifare.h"
|
#include "mifare.h"
|
||||||
|
@ -571,7 +577,11 @@ static void
|
||||||
print_usage(const char *pcProgramName)
|
print_usage(const char *pcProgramName)
|
||||||
{
|
{
|
||||||
printf("Usage: ");
|
printf("Usage: ");
|
||||||
|
#ifndef _WIN32
|
||||||
|
printf("%s f|r|R|w|W a|b u|U<01ab23cd> <dump.mfd> [<keys.mfd> [f] [v]]\n", pcProgramName);
|
||||||
|
#else
|
||||||
printf("%s f|r|R|w|W a|b u|U<01ab23cd> <dump.mfd> [<keys.mfd> [f]]\n", pcProgramName);
|
printf("%s f|r|R|w|W a|b u|U<01ab23cd> <dump.mfd> [<keys.mfd> [f]]\n", pcProgramName);
|
||||||
|
#endif
|
||||||
printf(" f|r|R|w|W - Perform format (f) or read from (r) or unlocked read from (R) or write to (w) or unlocked write to (W) card\n");
|
printf(" f|r|R|w|W - Perform format (f) or read from (r) or unlocked read from (R) or write to (w) or unlocked write to (W) card\n");
|
||||||
printf(" *** format will reset all keys to FFFFFFFFFFFF and all data to 00 and all ACLs to default\n");
|
printf(" *** format will reset all keys to FFFFFFFFFFFF and all data to 00 and all ACLs to default\n");
|
||||||
printf(" *** unlocked read does not require authentication and will reveal A and B keys\n");
|
printf(" *** unlocked read does not require authentication and will reveal A and B keys\n");
|
||||||
|
@ -582,7 +592,9 @@ print_usage(const char *pcProgramName)
|
||||||
printf(" <dump.mfd> - MiFare Dump (MFD) used to write (card to MFD) or (MFD to card)\n");
|
printf(" <dump.mfd> - MiFare Dump (MFD) used to write (card to MFD) or (MFD to card)\n");
|
||||||
printf(" <keys.mfd> - MiFare Dump (MFD) that contain the keys (optional)\n");
|
printf(" <keys.mfd> - MiFare Dump (MFD) that contain the keys (optional)\n");
|
||||||
printf(" f - Force using the keyfile even if UID does not match (optional)\n");
|
printf(" f - Force using the keyfile even if UID does not match (optional)\n");
|
||||||
|
#ifndef _WIN32
|
||||||
|
printf(" v - Sends libnfc log output to console (optional)\n");
|
||||||
|
#endif
|
||||||
printf("Examples: \n\n");
|
printf("Examples: \n\n");
|
||||||
printf(" Read card to file, using key A:\n\n");
|
printf(" Read card to file, using key A:\n\n");
|
||||||
printf(" %s r a u mycard.mfd\n\n", pcProgramName);
|
printf(" %s r a u mycard.mfd\n\n", pcProgramName);
|
||||||
|
@ -706,6 +718,21 @@ main(int argc, const char *argv[])
|
||||||
tag_uid = NULL;
|
tag_uid = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
// Send noise from lib to /dev/null
|
||||||
|
bool verbose = false;
|
||||||
|
if (argv[7]) {
|
||||||
|
if (strcmp(argv[7], "v") == 0) verbose = true;
|
||||||
|
} else {
|
||||||
|
if (strcmp(argv[6], "v") == 0) verbose = true;
|
||||||
|
}
|
||||||
|
if (!verbose) {
|
||||||
|
int fd = open("/dev/null", O_WRONLY);
|
||||||
|
dup2(fd, 2);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (atAction == ACTION_USAGE) {
|
if (atAction == ACTION_USAGE) {
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue