From ea41378c1731e3d3b0faff05346d1aac467823b0 Mon Sep 17 00:00:00 2001 From: midipix Date: Feb 19 2024 02:59:31 +0000 Subject: library api's: _lib_ (program driver) namespace overhaul. --- diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 3a09ba0..f31ae72 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -346,14 +346,14 @@ slbt_api int slbt_map_input (const struct slbt_driver_ctx *, slbt_api int slbt_unmap_input (struct slbt_input *); /* driver api */ -slbt_api int slbt_get_driver_ctx (char ** argv, char ** envp, uint64_t flags, +slbt_api int slbt_lib_get_driver_ctx (char ** argv, char ** envp, uint64_t flags, const struct slbt_fd_ctx *, struct slbt_driver_ctx **); -slbt_api void slbt_free_driver_ctx (struct slbt_driver_ctx *); +slbt_api void slbt_lib_free_driver_ctx (struct slbt_driver_ctx *); -slbt_api int slbt_get_driver_fdctx (const struct slbt_driver_ctx *, struct slbt_fd_ctx *); -slbt_api int slbt_set_driver_fdctx (struct slbt_driver_ctx *, const struct slbt_fd_ctx *); +slbt_api int slbt_lib_get_driver_fdctx (const struct slbt_driver_ctx *, struct slbt_fd_ctx *); +slbt_api int slbt_lib_set_driver_fdctx (struct slbt_driver_ctx *, const struct slbt_fd_ctx *); /* command execution context api */ slbt_api int slbt_ectx_get_exec_ctx (const struct slbt_driver_ctx *, struct slbt_exec_ctx **); diff --git a/src/arbits/output/slbt_ar_output_arname.c b/src/arbits/output/slbt_ar_output_arname.c index 131e749..6948934 100644 --- a/src/arbits/output/slbt_ar_output_arname.c +++ b/src/arbits/output/slbt_ar_output_arname.c @@ -67,7 +67,7 @@ int slbt_au_output_arname(const struct slbt_archive_ctx * actx) dctx = (slbt_get_archive_ictx(actx))->dctx; - if (slbt_get_driver_fdctx(dctx,&fdctx) < 0) + if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0) return SLBT_NESTED_ERROR(dctx); switch (dctx->cctx->fmtflags & SLBT_PRETTY_FLAGS) { diff --git a/src/arbits/output/slbt_ar_output_mapfile.c b/src/arbits/output/slbt_ar_output_mapfile.c index 2859558..f8cc1b7 100644 --- a/src/arbits/output/slbt_ar_output_mapfile.c +++ b/src/arbits/output/slbt_ar_output_mapfile.c @@ -75,7 +75,7 @@ static int slbt_ar_create_mapfile_impl( mctx = slbt_archive_meta_ictx(meta); dctx = (slbt_archive_meta_ictx(meta))->dctx; - if (slbt_get_driver_fdctx(dctx,&fdctx) < 0) + if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0) return SLBT_NESTED_ERROR(dctx); if (!meta->a_memberv) diff --git a/src/arbits/output/slbt_ar_output_members.c b/src/arbits/output/slbt_ar_output_members.c index 6c60163..dc79201 100644 --- a/src/arbits/output/slbt_ar_output_members.c +++ b/src/arbits/output/slbt_ar_output_members.c @@ -256,7 +256,7 @@ int slbt_au_output_members(const struct slbt_archive_meta * meta) dctx = (slbt_archive_meta_ictx(meta))->dctx; - if (slbt_get_driver_fdctx(dctx,&fdctx) < 0) + if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0) return SLBT_NESTED_ERROR(dctx); if (!meta->a_memberv) diff --git a/src/arbits/output/slbt_ar_output_symbols.c b/src/arbits/output/slbt_ar_output_symbols.c index fb9065b..2e9d6c7 100644 --- a/src/arbits/output/slbt_ar_output_symbols.c +++ b/src/arbits/output/slbt_ar_output_symbols.c @@ -82,7 +82,7 @@ int slbt_au_output_symbols(const struct slbt_archive_meta * meta) mctx = slbt_archive_meta_ictx(meta); dctx = (slbt_archive_meta_ictx(meta))->dctx; - if (slbt_get_driver_fdctx(dctx,&fdctx) < 0) + if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0) return SLBT_NESTED_ERROR(dctx); if (!meta->a_memberv) diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index 9ac5669..2ff5338 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -90,7 +90,7 @@ static void slbt_perform_driver_actions(struct slbt_driver_ctx * dctx) static int slbt_exit(struct slbt_driver_ctx * dctx, int ret) { slbt_output_error_vector(dctx); - slbt_free_driver_ctx(dctx); + slbt_lib_free_driver_ctx(dctx); return ret; } @@ -169,7 +169,7 @@ int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) | SLBT_DRIVER_LEGABITS); /* driver context */ - if ((ret = slbt_get_driver_ctx(argv,envp,flags|noclr,fdctx,&dctx))) + if ((ret = slbt_lib_get_driver_ctx(argv,envp,flags|noclr,fdctx,&dctx))) return (ret == SLBT_USAGE) ? !argv || !argv[0] || !argv[1] || !argv[2] : SLBT_ERROR; diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index acd3131..83f6b1e 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -268,13 +268,13 @@ static struct slbt_driver_ctx_impl * slbt_driver_ctx_alloc( return &ictx->ctx; } -static int slbt_get_driver_ctx_fail( +static int slbt_lib_get_driver_ctx_fail( struct slbt_driver_ctx * dctx, struct argv_meta * meta) { if (dctx) { slbt_output_error_vector(dctx); - slbt_free_driver_ctx(dctx); + slbt_lib_free_driver_ctx(dctx); } else { argv_free(meta); } @@ -314,7 +314,7 @@ static int slbt_driver_fail_incompatible_args( aclr_reset); } - return slbt_get_driver_ctx_fail(0,meta); + return slbt_lib_get_driver_ctx_fail(0,meta); } @@ -375,7 +375,7 @@ static int slbt_driver_parse_tool_argv(const char * tool, char *** tool_argv) } -int slbt_get_driver_ctx( +int slbt_lib_get_driver_ctx( char ** argv, char ** envp, uint64_t flags, @@ -866,7 +866,7 @@ int slbt_get_driver_ctx( /* driver context */ if (!(ctx = slbt_driver_ctx_alloc(meta,fdctx,&cctx,&sargv,objlistv,envp))) - return slbt_get_driver_ctx_fail(0,meta); + return slbt_lib_get_driver_ctx_fail(0,meta); /* ctx */ ctx->ctx.program = program; @@ -878,7 +878,7 @@ int slbt_get_driver_ctx( /* heuristics */ if (cctx.drvflags & SLBT_DRIVER_HEURISTICS) { if (slbt_get_lconf_flags(&ctx->ctx,lconf,&lflags) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); if (ctx->cctx.host.host && !cfgmeta_host) cfgmeta_host = cfglconf; @@ -939,23 +939,23 @@ int slbt_get_driver_ctx( cfgmeta_as, cfgmeta_ranlib, cfgmeta_dlltool)) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); /* host tool arguments */ if (slbt_driver_parse_tool_argv(ctx->cctx.host.ar,&ctx->host.ar_argv) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); if (slbt_driver_parse_tool_argv(ctx->cctx.host.ranlib,&ctx->host.ranlib_argv) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); if (slbt_driver_parse_tool_argv(ctx->cctx.host.as,&ctx->host.as_argv) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); if (slbt_driver_parse_tool_argv(ctx->cctx.host.dlltool,&ctx->host.dlltool_argv) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); if (slbt_driver_parse_tool_argv(ctx->cctx.host.mdso,&ctx->host.mdso_argv) < 0) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); /* flavor settings */ slbt_init_flavor_settings( @@ -964,16 +964,16 @@ int slbt_get_driver_ctx( /* ldpath */ if (slbt_init_ldrpath(&ctx->cctx,&ctx->cctx.host)) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); /* version info */ if (slbt_init_version_info(ctx,&ctx->cctx.verinfo)) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); /* link params */ if (cctx.mode == SLBT_MODE_LINK) if (slbt_init_link_params(ctx)) - return slbt_get_driver_ctx_fail(&ctx->ctx,0); + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); *pctx = &ctx->ctx; @@ -981,7 +981,7 @@ int slbt_get_driver_ctx( } -static void slbt_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) +static void slbt_lib_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) { struct slbt_error_info ** perr; struct slbt_error_info * erri; @@ -1021,7 +1021,7 @@ static void slbt_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) } -void slbt_free_driver_ctx(struct slbt_driver_ctx * ctx) +void slbt_lib_free_driver_ctx(struct slbt_driver_ctx * ctx) { struct slbt_driver_ctx_alloc * ictx; uintptr_t addr; @@ -1030,7 +1030,7 @@ void slbt_free_driver_ctx(struct slbt_driver_ctx * ctx) addr = (uintptr_t)ctx - offsetof(struct slbt_driver_ctx_impl,ctx); addr = addr - offsetof(struct slbt_driver_ctx_alloc,ctx); ictx = (struct slbt_driver_ctx_alloc *)addr; - slbt_free_driver_ctx_impl(ictx); + slbt_lib_free_driver_ctx_impl(ictx); } } @@ -1041,7 +1041,7 @@ const struct slbt_source_version * slbt_source_version(void) } -int slbt_get_driver_fdctx( +int slbt_lib_get_driver_fdctx( const struct slbt_driver_ctx * dctx, struct slbt_fd_ctx * fdctx) { @@ -1060,7 +1060,7 @@ int slbt_get_driver_fdctx( } -int slbt_set_driver_fdctx( +int slbt_lib_set_driver_fdctx( struct slbt_driver_ctx * dctx, const struct slbt_fd_ctx * fdctx) { diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index e817ac9..e30514d 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -334,42 +334,42 @@ static inline char ** slbt_driver_envp(const struct slbt_driver_ctx * dctx) static inline int slbt_driver_fdin(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fdin; } static inline int slbt_driver_fdout(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fdout; } static inline int slbt_driver_fderr(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fderr; } static inline int slbt_driver_fdlog(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fdlog; } static inline int slbt_driver_fdcwd(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fdcwd; } static inline int slbt_driver_fddst(const struct slbt_driver_ctx * dctx) { struct slbt_fd_ctx fdctx; - slbt_get_driver_fdctx(dctx,&fdctx); + slbt_lib_get_driver_fdctx(dctx,&fdctx); return fdctx.fddst; }