diff options
Diffstat (limited to 'src/driver/sfrt_amain.c')
-rw-r--r-- | src/driver/sfrt_amain.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/driver/sfrt_amain.c b/src/driver/sfrt_amain.c index 0b18010..c37f77d 100644 --- a/src/driver/sfrt_amain.c +++ b/src/driver/sfrt_amain.c @@ -2,6 +2,7 @@ #include <unistd.h> #include <sofort/sofort.h> #include "sofort_driver_impl.h" +#include "sofort_dprintf_impl.h" #ifndef SFRT_DRIVER_FLAGS #define SFRT_DRIVER_FLAGS SFRT_DRIVER_VERBOSITY_ERRORS \ @@ -24,15 +25,16 @@ static const char * const sfrt_ver_plain[6] = { "","" }; -static ssize_t sfrt_version(struct sfrt_driver_ctx * dctx) +static ssize_t sfrt_version(int fdout, struct sfrt_driver_ctx * dctx) { const struct sfrt_source_version * verinfo; const char * const * verclr; verinfo = sfrt_source_version(); - verclr = isatty(STDOUT_FILENO) ? sfrt_ver_color : sfrt_ver_plain; + verclr = isatty(fdout) ? sfrt_ver_color : sfrt_ver_plain; - return fprintf(stdout,vermsg, + return sfrt_dprintf( + fdout,vermsg, verclr[0],dctx->program,verclr[1], verclr[2],verinfo->major,verinfo->minor, verinfo->revision,verclr[3], @@ -59,20 +61,25 @@ static int sfrt_exit(struct sfrt_driver_ctx * dctx, int ret) return ret; } -int sfrt_main(int argc, char ** argv, char ** envp) +int sfrt_main(int argc, char ** argv, char ** envp, const struct sfrt_fd_ctx * fdctx) { int ret; + int fdout; + uint64_t flags; struct sfrt_driver_ctx * dctx; struct sfrt_unit_ctx * uctx; const char ** unit; - if ((ret = sfrt_get_driver_ctx(argv,envp,SFRT_DRIVER_FLAGS,&dctx))) + flags = SFRT_DRIVER_FLAGS; + fdout = fdctx ? fdctx->fdout : STDOUT_FILENO; + + if ((ret = sfrt_get_driver_ctx(argv,envp,flags,fdctx,&dctx))) return (ret == SFRT_USAGE) ? !--argc : SFRT_ERROR; if (dctx->cctx->drvflags & SFRT_DRIVER_VERSION) - if ((sfrt_version(dctx)) < 0) + if ((sfrt_version(fdout,dctx)) < 0) return sfrt_exit(dctx,SFRT_ERROR); if (dctx->cctx->anystring) /* dummy */ |