diff options
author | midipix <writeonce@midipix.org> | 2016-03-04 13:32:05 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-03-08 14:21:05 -0500 |
commit | 9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6 (patch) | |
tree | d1659a6814efef596730d6da5247b3fdd58d179b /src/slibtool.c | |
parent | 0ff546cab29192407bf991bf915dce52c049c387 (diff) | |
download | slibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.bz2 slibtool-9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6.tar.xz |
created skeleton.
Diffstat (limited to 'src/slibtool.c')
-rw-r--r-- | src/slibtool.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/slibtool.c b/src/slibtool.c new file mode 100644 index 0000000..6fb3422 --- /dev/null +++ b/src/slibtool.c @@ -0,0 +1,67 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016 Z. Gilboa */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include <stdio.h> +#include <unistd.h> +#include <slibtool/slibtool.h> +#include "slibtool_version.h" +#include "slibtool_driver_impl.h" + +#ifndef SLBT_DRIVER_FLAGS +#define SLBT_DRIVER_FLAGS SLBT_DRIVER_VERBOSITY_ERRORS \ + | SLBT_DRIVER_VERBOSITY_USAGE +#endif + +static const char vermsg[] = "%s (git://midipix.org/slibtool): commit %s.\n"; + +static ssize_t slibtool_version(struct slbt_driver_ctx * dctx) +{ + return fprintf(stdout,vermsg,dctx->program,SLIBTOOL_GIT_VERSION); +} + +static void slibtool_perform_unit_actions(struct slbt_unit_ctx * uctx) +{ +} + +static int slibtool_exit(struct slbt_driver_ctx * dctx, int nerrors) +{ + slbt_free_driver_ctx(dctx); + return nerrors ? 2 : 0; +} + +int slibtool_main(int argc, char ** argv, char ** envp) +{ + int ret; + struct slbt_driver_ctx * dctx; + struct slbt_unit_ctx * uctx; + const char ** unit; + + if ((ret = slbt_get_driver_ctx(argv,envp,SLBT_DRIVER_FLAGS,&dctx))) + return (ret == SLBT_USAGE) ? !--argc : 2; + + if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION) + if ((slibtool_version(dctx)) < 0) + return slibtool_exit(dctx,2); + + for (unit=dctx->units; *unit; unit++) { + if (!(slbt_get_unit_ctx(dctx,*unit,&uctx))) { + slibtool_perform_unit_actions(uctx); + ret += uctx->nerrors; + slbt_free_unit_ctx(uctx); + } + } + + return slibtool_exit(dctx,ret); +} + +#ifndef SLIBTOOL_IN_A_BOX + +int main(int argc, char ** argv, char ** envp) +{ + return slibtool_main(argc,argv,envp); +} + +#endif |