This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/15927 ) Change subject: sim: allow opening reader# > 0 ...................................................................... sim: allow opening reader# > 0 Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5 --- M src/sim/reader_pcsc.c M utils/osmo-sim-test.c 2 files changed, 53 insertions(+), 4 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sim/reader_pcsc.c b/src/sim/reader_pcsc.c index f22103f..9e05e3c 100644 --- a/src/sim/reader_pcsc.c +++ b/src/sim/reader_pcsc.c @@ -79,17 +79,18 @@ rc = SCardListReaders(st->hContext, NULL, (LPSTR)&mszReaders, &dwReaders); PCSC_ERROR(rc, "SCardListReaders"); + /* SCARD_S_SUCCESS means there is at least one reader in the group */ num_readers = 0; ptr = mszReaders; - while (*ptr != '\0') { + while (*ptr != '\0' && num_readers != num) { ptr += strlen(ptr)+1; num_readers++; } - if (num_readers == 0) + if (num != num_readers) goto end; - st->name = talloc_strdup(rh, mszReaders); + st->name = talloc_strdup(rh, ptr); st->dwActiveProtocol = -1; return rh; diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c index 5588294..cd98397 100644 --- a/utils/osmo-sim-test.c +++ b/utils/osmo-sim-test.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <errno.h> #include <string.h> +#include <getopt.h> #include <arpa/inet.h> #include <osmocom/core/msgb.h> @@ -328,6 +329,51 @@ return -EINVAL; } +static void print_help(void) +{ + printf( "osmo-sim-test Usage:\n" + " -h --help This message\n" + " -n --reader-num NR Open reader number NR\n" + ); +} + +static int readernum = 0; + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + const struct option long_options[] = { + { "help", 0, 0, 'h' }, + { "reader-num", 1, 0, 'n' }, + {0,0,0,0} + }; + + c = getopt_long(argc, argv, "hn:", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_help(); + exit(0); + break; + case 'n': + readernum = atoi(optarg); + break; + default: + exit(2); + break; + } + } + + if (argc > optind) { + fprintf(stderr, "Unsupported positional arguments on command line\n"); + exit(2); + } +} + int main(int argc, char **argv) { struct osim_reader_hdl *reader; @@ -335,7 +381,9 @@ struct osim_chan_hdl *chan; struct msgb *msg; - reader = osim_reader_open(OSIM_READER_DRV_PCSC, 0, "", NULL); + handle_options(argc, argv); + + reader = osim_reader_open(OSIM_READER_DRV_PCSC, readernum, "", NULL); if (!reader) exit(1); card = osim_card_open(reader, OSIM_PROTO_T0); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15927 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5 Gerrit-Change-Number: 15927 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191209/fef07acd/attachment.htm>