summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-06-25 12:33:13 -0400
committermidipix <writeonce@midipix.org>2016-06-25 12:33:13 -0400
commitfffc91a9f62e6b3fa791a988f18958c3a159be18 (patch)
tree18f798fb32b4684161828c8fdc5e2a81be383e82
parent9355e9ac6c35be29a7bdc591d484dfd091fb3440 (diff)
downloadslibtool-fffc91a9f62e6b3fa791a988f18958c3a159be18.tar.bz2
slibtool-fffc91a9f62e6b3fa791a988f18958c3a159be18.tar.xz
utility: added slbt_main() as a public interface, refactored accordingly.
-rw-r--r--include/slibtool/slibtool.h1
-rw-r--r--src/internal/slibtool_driver_impl.h1
-rw-r--r--src/slibtool.c28
3 files changed, 15 insertions, 15 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index e4b21c0..d69b1c6 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -259,6 +259,7 @@ slbt_api int slbt_copy_file (const struct slbt_driver_ctx *, struct slbt_exec_
slbt_api int slbt_dump_machine (const char * compiler, char * machine, size_t bufsize);
/* utility api */
+slbt_api int slbt_main (int, char **, char **);
slbt_api int slbt_output_config (const struct slbt_driver_ctx *);
slbt_api int slbt_output_exec (const struct slbt_driver_ctx *, const struct slbt_exec_ctx *, const char *);
slbt_api int slbt_output_compile (const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h
index 4a40122..f79f9e3 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -8,7 +8,6 @@
#include <slibtool/slibtool.h>
#include "argv/argv.h"
-extern int slibtool_main(int, char **, char **);
extern const struct argv_option slbt_default_options[];
enum app_tags {
diff --git a/src/slibtool.c b/src/slibtool.c
index 24cd9be..63b570c 100644
--- a/src/slibtool.c
+++ b/src/slibtool.c
@@ -31,7 +31,7 @@ static const char * const slbt_ver_plain[6] = {
"",""
};
-static ssize_t slibtool_version(struct slbt_driver_ctx * dctx)
+static ssize_t slbt_version(struct slbt_driver_ctx * dctx)
{
const struct slbt_source_version * verinfo;
const char * const * verclr;
@@ -50,7 +50,7 @@ static ssize_t slibtool_version(struct slbt_driver_ctx * dctx)
verclr[5],gitver ? "]" : "");
}
-static void slibtool_perform_driver_actions(struct slbt_driver_ctx * dctx)
+static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx)
{
if (dctx->cctx->drvflags & SLBT_DRIVER_CONFIG)
dctx->nerrors += (slbt_output_config(dctx) < 0);
@@ -68,12 +68,12 @@ static void slibtool_perform_driver_actions(struct slbt_driver_ctx * dctx)
dctx->nerrors += (slbt_exec_link(dctx,0) < 0);
}
-static void slibtool_perform_unit_actions(struct slbt_unit_ctx * uctx)
+static void slbt_perform_unit_actions(struct slbt_unit_ctx * uctx)
{
(void)uctx;
}
-static int slibtool_exit(struct slbt_driver_ctx * dctx, int nerrors)
+static int slbt_exit(struct slbt_driver_ctx * dctx, int nerrors)
{
if (nerrors && errno)
strerror(errno);
@@ -82,7 +82,7 @@ static int slibtool_exit(struct slbt_driver_ctx * dctx, int nerrors)
return nerrors ? 2 : 0;
}
-int slibtool_main(int argc, char ** argv, char ** envp)
+int slbt_main(int argc, char ** argv, char ** envp)
{
int ret;
uint64_t flags;
@@ -105,9 +105,9 @@ int slibtool_main(int argc, char ** argv, char ** envp)
sargv[4] = 0;
return (slbt_get_driver_ctx(sargv,envp,SLBT_DRIVER_FLAGS,&dctx))
- ? 2 : (slibtool_version(dctx) < 0)
- ? slibtool_exit(dctx,2)
- : slibtool_exit(dctx,0);
+ ? 2 : (slbt_version(dctx) < 0)
+ ? slbt_exit(dctx,2)
+ : slbt_exit(dctx,0);
}
/* program */
@@ -154,28 +154,28 @@ int slibtool_main(int argc, char ** argv, char ** envp)
return (ret == SLBT_USAGE) ? !--argc : 2;
if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION)
- if ((slibtool_version(dctx)) < 0)
- return slibtool_exit(dctx,2);
+ if ((slbt_version(dctx)) < 0)
+ return slbt_exit(dctx,2);
- slibtool_perform_driver_actions(dctx);
+ slbt_perform_driver_actions(dctx);
ret += dctx->nerrors;
for (unit=dctx->units; *unit; unit++) {
if (!(slbt_get_unit_ctx(dctx,*unit,&uctx))) {
- slibtool_perform_unit_actions(uctx);
+ slbt_perform_unit_actions(uctx);
ret += uctx->nerrors;
slbt_free_unit_ctx(uctx);
}
}
- return slibtool_exit(dctx,ret);
+ return slbt_exit(dctx,ret);
}
#ifndef SLIBTOOL_IN_A_BOX
int main(int argc, char ** argv, char ** envp)
{
- return slibtool_main(argc,argv,envp);
+ return slbt_main(argc,argv,envp);
}
#endif