From 0254dfb578e56cdc5cfef8df959b45fb454e3a8f Mon Sep 17 00:00:00 2001 From: midipix Date: Oct 24 2016 16:44:08 +0000 Subject: driver: status codes: refactor and normalize. --- diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 1a4b9fe..4aa2552 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -23,10 +23,7 @@ extern "C" { /* status codes */ #define SLBT_OK 0x00 #define SLBT_USAGE 0x01 -#define SLBT_BAD_OPT 0x02 -#define SLBT_BAD_OPT_VAL 0x03 -#define SLBT_IO_ERROR 0xA0 -#define SLBT_MAP_ERROR 0xA1 +#define SLBT_ERROR 0x02 /* driver flags */ #define SLBT_DRIVER_VERBOSITY_NONE 0x0000 diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 5d1417e..4c66820 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -100,9 +100,9 @@ int slbt_main(int argc, char ** argv, char ** envp) sargv[4] = 0; return (slbt_get_driver_ctx(sargv,envp,SLBT_DRIVER_FLAGS,&dctx)) - ? 2 : (slbt_version(dctx) < 0) - ? slbt_exit(dctx,2) - : slbt_exit(dctx,0); + ? SLBT_ERROR : (slbt_version(dctx) < 0) + ? slbt_exit(dctx,SLBT_ERROR) + : slbt_exit(dctx,SLBT_OK); } /* program */ @@ -146,13 +146,15 @@ int slbt_main(int argc, char ** argv, char ** envp) /* driver context */ if ((ret = slbt_get_driver_ctx(argv,envp,flags,&dctx))) - return (ret == SLBT_USAGE) ? !--argc : 2; + return (ret == SLBT_USAGE) + ? !--argc + : SLBT_ERROR; if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION) if ((slbt_version(dctx)) < 0) - return slbt_exit(dctx,2); + return slbt_exit(dctx,SLBT_ERROR); slbt_perform_driver_actions(dctx); - return slbt_exit(dctx,dctx->errv[0] ? 2 : 0); + return slbt_exit(dctx,dctx->errv[0] ? SLBT_ERROR : SLBT_OK); }