summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-12-27 00:29:01 +0200
committermidipix <writeonce@midipix.org>2018-05-21 01:44:56 -0400
commit6a7c0258ae558172eda31c56c9ed21605d02bec0 (patch)
tree2cf4edd67090ec9414b2b1fbce578315a9ce7d2e
parent2404cd8761998d454dd7f0e2e276d2a14970f32a (diff)
downloadntux-6a7c0258ae558172eda31c56c9ed21605d02bec0.tar.bz2
ntux-6a7c0258ae558172eda31c56c9ed21605d02bec0.tar.xz
driver: added --cmd support, added 'stat' as an available command.
-rw-r--r--include/ntux/ntux.h6
-rw-r--r--src/driver/ntux_driver_ctx.c10
-rw-r--r--src/internal/ntux_driver_impl.h1
-rw-r--r--src/skin/ntux_skin_default.c3
4 files changed, 18 insertions, 2 deletions
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] <file>...\n" "Options:\n",
- program);
+ "Usage: %s [options] ...\n"
+ "Usage: %s [options] --cmd=<command> <arg> <arg> ...\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}
};