diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-07-07 16:10:06 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-07-13 09:08:15 +0000 |
commit | 3807f631e0fee4fd2e87353b3578a580dbf8cb00 (patch) | |
tree | db15436e600e807eaabd83194fb6d0e5211ee3be | |
parent | 06f04ba7aa619a722a6c4eaa11e49a1c0ed6a240 (diff) |
Add debug option to sdpscanner permitting plain text output of scan results
Change-Id: I8b2c8931b3755306491deff51b57d1476fe87e3a
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
-rw-r--r-- | src/tools/sdpscanner/main.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp index 1efb6de2..50870651 100644 --- a/src/tools/sdpscanner/main.cpp +++ b/src/tools/sdpscanner/main.cpp @@ -46,9 +46,11 @@ void usage() { fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\tsdpscanner <remote bdaddr> <local bdaddr>\n\n"); + fprintf(stderr, "\tsdpscanner <remote bdaddr> <local bdaddr> [Options]\n\n"); fprintf(stderr, "Performs an SDP scan on remote device, using the SDP server\n" - "represented by the local Bluetooth device.\n"); + "represented by the local Bluetooth device.\n\n" + "Options:\n" + " -p Show scan results in human-readable form\n"); } #define BUFFER_SIZE 1024 @@ -245,7 +247,7 @@ QByteArray parseSdpRecord(sdp_record_t *record) int main(int argc, char **argv) { - if (argc != 3) { + if (argc < 3) { usage(); return RETURN_USAGE; } @@ -266,6 +268,27 @@ int main(int argc, char **argv) return RETURN_INVALPARAM; } + bool showHumanReadable = false; + + for (int i = 3; i < argc; i++) { + if (argv[i][0] != '-') { + usage(); + return RETURN_USAGE; + } + + switch (argv[i][1]) + { + case 'p': + showHumanReadable = true; + break; + default: + fprintf(stderr, "Wrong argument: %s\n", argv[i]); + usage(); + return RETURN_USAGE; + + } + } + sdp_session_t *session = sdp_connect( &local, &remote, SDP_RETRY_IF_BUSY); if (!session) { //try one more time if first time failed @@ -314,7 +337,10 @@ int main(int argc, char **argv) } if (!total.isEmpty()) { - printf("%s", total.toBase64().constData()); + if (showHumanReadable) + printf("%s", total.constData()); + else + printf("%s", total.toBase64().constData()); } sdp_close(session); |