diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2017-05-05 11:32:17 -0500 |
---|---|---|
committer | Adriana Kobylak <anoo@us.ibm.com> | 2017-05-11 09:15:00 -0500 |
commit | 6a8688f4f46df8c0c98f7571a072241eac4290af (patch) | |
tree | ba675e8a46dbb1b88709c094c4a4803f8ac13450 | |
parent | 04d7c7d962ddce2fbe5fde49c104b7712cc58620 (diff) | |
download | phosphor-objmgr-6a8688f4f46df8c0c98f7571a072241eac4290af.tar.gz phosphor-objmgr-6a8688f4f46df8c0c98f7571a072241eac4290af.zip |
app: Split subtree argument
Split the argument string on the first colon (:) character
to get the namespace and interface.
Change-Id: Ia9c67bd149c23e68945fd80252a93a2f1fe78382
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r-- | libmapper/app.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libmapper/app.c b/libmapper/app.c index 9713835..501a191 100644 --- a/libmapper/app.c +++ b/libmapper/app.c @@ -140,10 +140,21 @@ finish: static int subtree_main(int argc, char *argv[]) { int r = 0; + static const char* token = ":"; + char* tmp = NULL; + char* namespace = NULL; + char* interface = NULL; if (argc != 3) { fprintf(stderr, "Usage: %s subtree-remove " - "NAMESPACE:INTERFACE\n", argv[0]); + "NAMESPACE%sINTERFACE\n", argv[0], token); + exit(EXIT_FAILURE); + } + + namespace = strtok_r(argv[2], token, &tmp); + interface = strtok_r(NULL, token, &tmp); + if ((namespace == NULL) || (interface == NULL)) { + fprintf(stderr, "Token '%s' was not found in '%s'\n", token, argv[2]); exit(EXIT_FAILURE); } |