From c5881dbd61aa7a8eafed13af436e7a988c0ffd5d Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 25 Jun 2016 15:26:07 -0400 Subject: utility: added sfrt_main() as a public interface, refactored accordingly. --- src/internal/sofort_driver_impl.h | 1 - src/sofort.c | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/internal/sofort_driver_impl.h b/src/internal/sofort_driver_impl.h index 91c6bff..5ee4952 100644 --- a/src/internal/sofort_driver_impl.h +++ b/src/internal/sofort_driver_impl.h @@ -8,7 +8,6 @@ #include #include "argv/argv.h" -extern int sofort_main(int, char **, char **); extern const struct argv_option sfrt_default_options[]; enum app_tags { diff --git a/src/sofort.c b/src/sofort.c index 20c6cc3..553bda6 100644 --- a/src/sofort.c +++ b/src/sofort.c @@ -24,7 +24,7 @@ static const char * const sfrt_ver_plain[6] = { "","" }; -static ssize_t sofort_version(struct sfrt_driver_ctx * dctx) +static ssize_t sfrt_version(struct sfrt_driver_ctx * dctx) { const struct sfrt_source_version * verinfo; const char * const * verclr; @@ -39,7 +39,7 @@ static ssize_t sofort_version(struct sfrt_driver_ctx * dctx) verclr[4],verinfo->commit,verclr[5]); } -static void sofort_perform_unit_actions(struct sfrt_unit_ctx * uctx) +static void sfrt_perform_unit_actions(struct sfrt_unit_ctx * uctx) { uint64_t flags = uctx->cctx->actflags; /* dummy */ /* dummy */ @@ -55,13 +55,13 @@ static void sofort_perform_unit_actions(struct sfrt_unit_ctx * uctx) (void)uctx; } -static int sofort_exit(struct sfrt_driver_ctx * dctx, int nerrors) +static int sfrt_exit(struct sfrt_driver_ctx * dctx, int nerrors) { sfrt_free_driver_ctx(dctx); return nerrors ? 2 : 0; } -int sofort_main(int argc, char ** argv, char ** envp) +int sfrt_main(int argc, char ** argv, char ** envp) { int ret; struct sfrt_driver_ctx * dctx; @@ -72,29 +72,29 @@ int sofort_main(int argc, char ** argv, char ** envp) return (ret == SFRT_USAGE) ? !--argc : 2; if (dctx->cctx->drvflags & SFRT_DRIVER_VERSION) - if ((sofort_version(dctx)) < 0) - return sofort_exit(dctx,2); + if ((sfrt_version(dctx)) < 0) + return sfrt_exit(dctx,2); if (dctx->cctx->anystring) /* dummy */ if ((sfrt_output_dummy(dctx->cctx,stdout)) < 0) /* dummy */ - return sofort_exit(dctx,2); /* dummy */ + return sfrt_exit(dctx,2); /* dummy */ /* dummy */ for (unit=dctx->units; *unit; unit++) { if (!(sfrt_get_unit_ctx(dctx,*unit,&uctx))) { - sofort_perform_unit_actions(uctx); + sfrt_perform_unit_actions(uctx); ret += uctx->nerrors; sfrt_free_unit_ctx(uctx); } } - return sofort_exit(dctx,ret); + return sfrt_exit(dctx,ret); } #ifndef SOFORT_IN_A_BOX int main(int argc, char ** argv, char ** envp) { - return sofort_main(argc,argv,envp); + return sfrt_main(argc,argv,envp); } #endif -- cgit v1.2.3