From 1379f79d286988f2582ff8efb1af736bf4229a3f Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 24 Oct 2016 12:34:04 -0400 Subject: driver: removed unit context and related interfaces (not needed by slibtool). --- src/driver/slbt_amain.c | 14 ---------- src/driver/slbt_driver_ctx.c | 23 ++++------------ src/driver/slbt_unit_ctx.c | 62 -------------------------------------------- 3 files changed, 5 insertions(+), 94 deletions(-) delete mode 100644 src/driver/slbt_unit_ctx.c (limited to 'src/driver') diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 25a1159..5d1417e 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -72,11 +72,6 @@ static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) slbt_exec_uninstall(dctx,0); } -static void slbt_perform_unit_actions(struct slbt_unit_ctx * uctx) -{ - (void)uctx; -} - static int slbt_exit(struct slbt_driver_ctx * dctx, int ret) { slbt_output_error_vector(dctx); @@ -89,8 +84,6 @@ int slbt_main(int argc, char ** argv, char ** envp) int ret; uint64_t flags; struct slbt_driver_ctx * dctx; - struct slbt_unit_ctx * uctx; - const char ** unit; char * program; char * dash; char * sargv[5]; @@ -161,12 +154,5 @@ int slbt_main(int argc, char ** argv, char ** envp) slbt_perform_driver_actions(dctx); - for (unit=dctx->units; *unit; unit++) { - if (!(slbt_get_unit_ctx(dctx,*unit,&uctx))) { - slbt_perform_unit_actions(uctx); - slbt_free_unit_ctx(uctx); - } - } - return slbt_exit(dctx,dctx->errv[0] ? 2 : 0); } diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index ac41ed3..088f431 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -73,7 +73,6 @@ struct slbt_driver_ctx_alloc { struct argv_meta * meta; struct slbt_driver_ctx_impl ctx; uint64_t guard; - const char * units[]; }; static void slbt_output_raw_vector(char ** argv, char ** envp) @@ -146,17 +145,13 @@ static int slbt_driver_usage( static struct slbt_driver_ctx_impl * slbt_driver_ctx_alloc( struct argv_meta * meta, - const struct slbt_common_ctx * cctx, - size_t nunits) + const struct slbt_common_ctx * cctx) { struct slbt_driver_ctx_alloc * ictx; size_t size; - struct argv_entry * entry; - const char ** units; int elements; size = sizeof(struct slbt_driver_ctx_alloc); - size += (nunits+1)*sizeof(const char *); if (!(ictx = calloc(1,size))) return 0; @@ -164,17 +159,12 @@ static struct slbt_driver_ctx_impl * slbt_driver_ctx_alloc( if (cctx) memcpy(&ictx->ctx.cctx,cctx,sizeof(*cctx)); - for (entry=meta->entries,units=ictx->units; entry->fopt || entry->arg; entry++) - if (!entry->fopt) - *units++ = entry->arg; - elements = sizeof(ictx->ctx.erribuf) / sizeof(*ictx->ctx.erribuf); ictx->ctx.errinfp = &ictx->ctx.erriptr[0]; ictx->ctx.erricap = &ictx->ctx.erriptr[--elements]; ictx->meta = meta; - ictx->ctx.ctx.units = ictx->units; ictx->ctx.ctx.errv = ictx->ctx.errinfp; return &ictx->ctx; } @@ -810,7 +800,6 @@ int slbt_get_driver_ctx( const struct argv_option * options; struct argv_meta * meta; struct argv_entry * entry; - size_t nunits; const char * program; options = slbt_default_options; @@ -821,7 +810,6 @@ int slbt_get_driver_ctx( if (!(meta = argv_get(sargv.targv,options,slbt_argv_flags(flags)))) return -1; - nunits = 0; program = argv_program_name(argv[0]); memset(&cctx,0,sizeof(cctx)); @@ -831,7 +819,7 @@ int slbt_get_driver_ctx( /* full annotation when annotation is on; */ cctx.drvflags |= SLBT_DRIVER_ANNOTATE_FULL; - /* get options, count units */ + /* get options */ for (entry=meta->entries; entry->fopt || entry->arg; entry++) { if (entry->fopt) { switch (entry->tag) { @@ -1057,8 +1045,7 @@ int slbt_get_driver_ctx( cctx.drvflags &= ~(uint64_t)SLBT_DRIVER_SHARED; break; } - } else - nunits++; + } } /* debug: raw argument vector */ @@ -1072,7 +1059,7 @@ int slbt_get_driver_ctx( } /* driver context */ - if (!(ctx = slbt_driver_ctx_alloc(meta,&cctx,nunits))) + if (!(ctx = slbt_driver_ctx_alloc(meta,&cctx))) return slbt_get_driver_ctx_fail(meta); ctx->ctx.program = program; @@ -1134,7 +1121,7 @@ int slbt_create_driver_ctx( if (!(meta = argv_get(argv,slbt_default_options,0))) return -1; - if (!(ctx = slbt_driver_ctx_alloc(meta,cctx,0))) + if (!(ctx = slbt_driver_ctx_alloc(meta,cctx))) return slbt_get_driver_ctx_fail(0); ctx->ctx.cctx = &ctx->cctx; diff --git a/src/driver/slbt_unit_ctx.c b/src/driver/slbt_unit_ctx.c deleted file mode 100644 index 3fab392..0000000 --- a/src/driver/slbt_unit_ctx.c +++ /dev/null @@ -1,62 +0,0 @@ -/*******************************************************************/ -/* slibtool: a skinny libtool implementation, written in C */ -/* Copyright (C) 2016 Z. Gilboa */ -/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ -/*******************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include "slibtool_driver_impl.h" - -static int slbt_free_unit_ctx_impl(struct slbt_unit_ctx_impl * ctx, int status) -{ - if (ctx) { - slbt_unmap_input(&ctx->map); - free(ctx); - } - - return status; -} - -int slbt_get_unit_ctx( - const struct slbt_driver_ctx * dctx, - const char * path, - struct slbt_unit_ctx ** pctx) -{ - struct slbt_unit_ctx_impl * ctx; - - if (!dctx || !(ctx = calloc(1,sizeof(*ctx)))) - return -1; - - if (slbt_map_input(-1,path,PROT_READ,&ctx->map)) - return slbt_free_unit_ctx_impl(ctx,-1); - - memcpy(&ctx->cctx,dctx->cctx, - sizeof(ctx->cctx)); - - ctx->path = path; - - ctx->uctx.path = &ctx->path; - ctx->uctx.map = &ctx->map; - ctx->uctx.cctx = &ctx->cctx; - - *pctx = &ctx->uctx; - return 0; -} - -void slbt_free_unit_ctx(struct slbt_unit_ctx * ctx) -{ - struct slbt_unit_ctx_impl * ictx; - uintptr_t addr; - - if (ctx) { - addr = (uintptr_t)ctx - offsetof(struct slbt_unit_ctx_impl,uctx); - ictx = (struct slbt_unit_ctx_impl *)addr; - slbt_free_unit_ctx_impl(ictx,0); - } -} -- cgit v1.2.3