diff options
author | midipix <writeonce@midipix.org> | 2016-06-25 15:26:07 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-06-25 15:26:07 -0400 |
commit | c5881dbd61aa7a8eafed13af436e7a988c0ffd5d (patch) | |
tree | 0776d7173d91b1f7d7ad342e02ad93e9045b89a2 | |
parent | 8e6b56c8d74cbc8f7521153413bf01156dd3ae2b (diff) | |
download | sofort-c5881dbd61aa7a8eafed13af436e7a988c0ffd5d.tar.bz2 sofort-c5881dbd61aa7a8eafed13af436e7a988c0ffd5d.tar.xz |
utility: added sfrt_main() as a public interface, refactored accordingly.
-rw-r--r-- | include/sofort/sofort.h | 1 | ||||
-rw-r--r-- | src/internal/sofort_driver_impl.h | 1 | ||||
-rw-r--r-- | src/sofort.c | 20 |
3 files changed, 11 insertions, 11 deletions
diff --git a/include/sofort/sofort.h b/include/sofort/sofort.h index 4bf4c1a..9d56acd 100644 --- a/include/sofort/sofort.h +++ b/include/sofort/sofort.h @@ -93,6 +93,7 @@ sfrt_api int sfrt_map_input (int fd, const char * path, int prot, struct sfrt_ sfrt_api int sfrt_unmap_input (struct sfrt_input *); /* utility api */ +sfrt_api int sfrt_main (int, char **, char **); sfrt_api int sfrt_output_dummy (const struct sfrt_common_ctx *, FILE *); /* dummy */ sfrt_api int sfrt_output_name (const struct sfrt_unit_ctx *, FILE *); /* dummy */ sfrt_api int sfrt_output_address (const struct sfrt_unit_ctx *, FILE *); /* dummy */ 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 <sofort/sofort.h> #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 |