summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-05-20 20:00:58 +0000
committermidipix <writeonce@midipix.org>2018-05-21 01:44:57 -0400
commitc59ae6812f148839a5d07e1dd266c12fa7f3b2f5 (patch)
tree60ef81e0a6a0ec7e0aa730c58be81fbd94b37f26 /src
parent719722f99fa8cea88c4937436b0fe61b69cbbc5d (diff)
downloadntux-c59ae6812f148839a5d07e1dd266c12fa7f3b2f5.tar.bz2
ntux-c59ae6812f148839a5d07e1dd266c12fa7f3b2f5.tar.xz
driver: require --cmd=<cmd> as needed.
Diffstat (limited to 'src')
-rw-r--r--src/driver/ntux_amain.c12
-rw-r--r--src/driver/ntux_driver_ctx.c3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/driver/ntux_amain.c b/src/driver/ntux_amain.c
index 709c73b..6b9acf4 100644
--- a/src/driver/ntux_amain.c
+++ b/src/driver/ntux_amain.c
@@ -47,6 +47,14 @@ static ssize_t ntux_version(struct ntux_driver_ctx * dctx)
verclr[4],verinfo->commit,verclr[5]);
}
+static void ntux_perform_unit_actions(
+ const struct ntux_driver_ctx * dctx,
+ const char * unit)
+{
+ (void)dctx;
+ (void)unit;
+}
+
static int ntux_exit(struct ntux_driver_ctx * dctx, int ret)
{
ntux_free_driver_ctx(dctx);
@@ -57,6 +65,7 @@ int ntux_main(int argc, char ** argv, char ** envp)
{
int ret;
struct ntux_driver_ctx * dctx;
+ const char ** unit;
if ((ret = ntux_get_driver_ctx(argv,envp,NTUX_DRIVER_FLAGS,&dctx)))
return (ret == NTUX_USAGE)
@@ -67,5 +76,8 @@ int ntux_main(int argc, char ** argv, char ** envp)
if ((ntux_version(dctx)) < 0)
return ntux_exit(dctx,NTUX_ERROR);
+ for (unit=dctx->units; *unit; unit++)
+ ntux_perform_unit_actions(dctx,*unit);
+
return ntux_exit(dctx,dctx->errv[0] ? NTUX_ERROR : NTUX_OK);
}
diff --git a/src/driver/ntux_driver_ctx.c b/src/driver/ntux_driver_ctx.c
index 0398d5f..2aca14c 100644
--- a/src/driver/ntux_driver_ctx.c
+++ b/src/driver/ntux_driver_ctx.c
@@ -175,6 +175,9 @@ int ntux_get_driver_ctx(
nunits++;
}
+ if (nunits && !cctx.cmd)
+ return ntux_driver_usage(program,0,optv,meta);
+
if (!(ctx = ntux_driver_ctx_alloc(meta,&cctx,nunits)))
return ntux_get_driver_ctx_fail(meta);