From 6a7c0258ae558172eda31c56c9ed21605d02bec0 Mon Sep 17 00:00:00 2001 From: midipix Date: May 21 2018 05:44:56 +0000 Subject: driver: added --cmd support, added 'stat' as an available command. --- diff --git a/include/ntux/ntux.h b/include/ntux/ntux.h index 896f301..7e9ca52 100644 --- a/include/ntux/ntux.h +++ b/include/ntux/ntux.h @@ -32,6 +32,11 @@ extern "C" { #define NTUX_DRIVER_VERSION 0x0010 #define NTUX_DRIVER_DRY_RUN 0x0020 +enum ntux_cmd { + NTUX_CMD_DEFAULT, + NTUX_CMD_STAT, +}; + struct ntux_source_version { int major; int minor; @@ -55,6 +60,7 @@ struct ntux_common_ctx { uint64_t drvflags; uint64_t actflags; uint64_t fmtflags; + enum ntux_cmd cmd; }; struct ntux_driver_ctx { diff --git a/src/driver/ntux_driver_ctx.c b/src/driver/ntux_driver_ctx.c index 3759ef7..0398d5f 100644 --- a/src/driver/ntux_driver_ctx.c +++ b/src/driver/ntux_driver_ctx.c @@ -69,8 +69,9 @@ static int ntux_driver_usage( char header[512]; snprintf(header,sizeof(header), - "Usage: %s [options] ...\n" "Options:\n", - program); + "Usage: %s [options] ...\n" + "Usage: %s [options] --cmd= ...\n" "Options:\n", + program,program); argv_usage(stdout,header,optv,arg); argv_free(meta); @@ -164,6 +165,11 @@ int ntux_get_driver_ctx( case TAG_VERSION: cctx.drvflags |= NTUX_DRIVER_VERSION; break; + + case TAG_CMD: + if (!strcmp(entry->arg,"stat")) + cctx.cmd = NTUX_CMD_STAT; + break; } } else nunits++; diff --git a/src/internal/ntux_driver_impl.h b/src/internal/ntux_driver_impl.h index 822f131..6c635de 100644 --- a/src/internal/ntux_driver_impl.h +++ b/src/internal/ntux_driver_impl.h @@ -19,6 +19,7 @@ extern const ntapi_vtbl * ntux_ntapi; enum app_tags { TAG_HELP, TAG_VERSION, + TAG_CMD, }; struct ntux_driver_ctx_impl { diff --git a/src/skin/ntux_skin_default.c b/src/skin/ntux_skin_default.c index 7bb0045..fa4c33d 100644 --- a/src/skin/ntux_skin_default.c +++ b/src/skin/ntux_skin_default.c @@ -8,5 +8,8 @@ const struct argv_option ntux_default_options[] = { {"help", 'h',TAG_HELP,ARGV_OPTARG_OPTIONAL,0,"short|long",0, "show usage information [listing %s options only]"}, + {"cmd", 0,TAG_CMD,ARGV_OPTARG_REQUIRED,0,"stat",0, + "invoke an internal ntux command"}, + {0,0,0,0,0,0,0,0} };