diff options
author | midipix <writeonce@midipix.org> | 2025-06-01 10:19:36 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2025-06-01 10:19:36 +0000 |
commit | c73e19fc0eb524dd28e2b52d7f52e4ee564ba9c4 (patch) | |
tree | e7845b00e87009bd61f1c53e99b1edae6a5f5a98 | |
parent | 7b3da5c46dc9716f1996dc7d1f3af37018607c8c (diff) | |
download | perk-c73e19fc0eb524dd28e2b52d7f52e4ee564ba9c4.tar.bz2 perk-c73e19fc0eb524dd28e2b52d7f52e4ee564ba9c4.tar.xz |
driver: added --cmd=ar support, the pe_cmd_ar() stub, and the perk-ar symlink.
-rw-r--r-- | include/perk/perk.h | 2 | ||||
-rw-r--r-- | project/common.mk | 2 | ||||
-rw-r--r-- | project/extras.mk | 6 | ||||
-rw-r--r-- | src/cmds/pe_cmd_ar.c | 14 | ||||
-rw-r--r-- | src/driver/pe_amain.c | 4 | ||||
-rw-r--r-- | src/driver/pe_driver_ctx.c | 14 | ||||
-rw-r--r-- | src/internal/perk_driver_impl.h | 1 | ||||
-rw-r--r-- | src/skin/pe_skin_ar.c | 15 | ||||
-rw-r--r-- | src/skin/pe_skin_default.c | 2 |
9 files changed, 58 insertions, 2 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h index 2ed6eed..9075163 100644 --- a/include/perk/perk.h +++ b/include/perk/perk.h @@ -94,6 +94,7 @@ enum pe_custom_error { enum pe_cmd { PERK_CMD_DEFAULT, PERK_CMD_PERK, + PERK_CMD_AR, PERK_CMD_CAP, }; @@ -256,6 +257,7 @@ perk_api int pe_lib_set_driver_fdctx (struct pe_driver_ctx *, const s /* cmd api */ perk_api int pe_cmd_perk (const struct pe_driver_ctx *, const char *); +perk_api int pe_cmd_ar (const struct pe_driver_ctx *); /* utility api */ perk_api int pe_main (char **, char **, const struct pe_fd_ctx *); diff --git a/project/common.mk b/project/common.mk index 0ad5c41..4f95df4 100644 --- a/project/common.mk +++ b/project/common.mk @@ -4,6 +4,7 @@ API_SRCS = \ src/arbits/pe_armap_bsd_64.c \ src/arbits/pe_armap_sysv_32.c \ src/arbits/pe_armap_sysv_64.c \ + src/cmds/pe_cmd_ar.c \ src/cmds/pe_cmd_perk.c \ src/driver/pe_amain.c \ src/driver/pe_driver_ctx.c \ @@ -37,6 +38,7 @@ API_SRCS = \ src/reader/pe_read_optional_header.c \ src/reader/pe_read_section_header.c \ src/skin/pe_skin_default.c \ + src/skin/pe_skin_ar.c \ src/skin/pe_skin_perk.c \ INTERNAL_SRCS = \ diff --git a/project/extras.mk b/project/extras.mk index cae7dcc..b4af0c3 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -6,3 +6,9 @@ CFLAGS_CONFIG += $(CFLAGS_ATTR_VISIBILITY_HIDDEN) src/driver/pe_driver_ctx.o: version.tag src/driver/pe_driver_ctx.lo: version.tag + +install-app-extras: + mkdir -p $(DESTDIR)$(BINDIR) + rm -f bin/$(NICKNAME)-ar$(OS_APP_SUFFIX).tmp + ln -s ./$(NICKNAME)$(OS_APP_SUFFIX) bin/$(NICKNAME)-ar$(OS_APP_SUFFIX).tmp + mv bin/$(NICKNAME)-ar$(OS_APP_SUFFIX).tmp $(DESTDIR)$(BINDIR)/$(NICKNAME)-ar$(OS_APP_SUFFIX) diff --git a/src/cmds/pe_cmd_ar.c b/src/cmds/pe_cmd_ar.c new file mode 100644 index 0000000..2df578c --- /dev/null +++ b/src/cmds/pe_cmd_ar.c @@ -0,0 +1,14 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2025 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include <perk/perk.h> +#include "perk_driver_impl.h" + +int pe_cmd_ar(const struct pe_driver_ctx * dctx) +{ + (void)dctx; + return 0; +} diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c index 606184d..c48ec1c 100644 --- a/src/driver/pe_amain.c +++ b/src/driver/pe_amain.c @@ -84,6 +84,10 @@ int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx) pe_cmd_perk(dctx,*unit); break; + case PERK_CMD_AR: + pe_cmd_ar(dctx); + break; + default: break; } diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c index afa46e7..a427252 100644 --- a/src/driver/pe_driver_ctx.c +++ b/src/driver/pe_driver_ctx.c @@ -27,12 +27,14 @@ static const struct pe_source_version pe_src_version = { /* perk command names */ static const char * const perk_cmd_name[PERK_CMD_CAP] = { [PERK_CMD_PERK] = "perk", + [PERK_CMD_AR] = "ar", }; /* perk command options */ static const struct argv_option * perk_cmd_options[PERK_CMD_CAP] = { [PERK_CMD_DEFAULT] = pe_default_options, [PERK_CMD_PERK] = pe_perk_options, + [PERK_CMD_AR] = pe_ar_options, }; /* default fd context */ @@ -160,6 +162,9 @@ static int pe_cmd_from_program(const char * program) if (!strcmp(mark,"perk")) { return PERK_CMD_PERK; + } else if (!strcmp(mark,"ar")) { + return PERK_CMD_AR; + } else { return PERK_CMD_DEFAULT; } @@ -417,6 +422,9 @@ int pe_lib_get_driver_ctx( } else if (cctx.cmd == PERK_CMD_PERK) { argv_optv_init(pe_perk_options,optv); + + } else if (cctx.cmd == PERK_CMD_AR) { + argv_optv_init(pe_ar_options,optv); } /* process the selected tool's command-line arguments */ @@ -434,12 +442,16 @@ int pe_lib_get_driver_ctx( } /* utility mode and no action to take? */ - if (cctx.drvflags & PERK_DRIVER_VERBOSITY_UTILITY) + if (cctx.cmd == PERK_CMD_AR) { + (void)0; + + } else if (cctx.drvflags & PERK_DRIVER_VERBOSITY_UTILITY) { if (!nunits && !(cctx.drvflags & PERK_DRIVER_VERSION)) return pe_driver_usage( fdctx->fdout, program,0, optv,meta,cctx.cmd); + } /* context allocation */ if (!(ctx = pe_driver_ctx_alloc(meta,fdctx,&cctx,nunits))) diff --git a/src/internal/perk_driver_impl.h b/src/internal/perk_driver_impl.h index 99c68be..3948eae 100644 --- a/src/internal/perk_driver_impl.h +++ b/src/internal/perk_driver_impl.h @@ -14,6 +14,7 @@ extern const struct argv_option pe_default_options[]; extern const struct argv_option pe_perk_options[]; +extern const struct argv_option pe_ar_options[]; enum app_tags { TAG_HELP, diff --git a/src/skin/pe_skin_ar.c b/src/skin/pe_skin_ar.c new file mode 100644 index 0000000..512073d --- /dev/null +++ b/src/skin/pe_skin_ar.c @@ -0,0 +1,15 @@ +#include "perk_driver_impl.h" +#include "perk_visibility_impl.h" +#include "argv/argv.h" + +const perk_hidden struct argv_option pe_ar_options[] = { + {"Wversion", 'v',TAG_VERSION,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "show version information"}, + + {"Whelp", 'h',TAG_HELP,ARGV_OPTARG_NONE, + ARGV_OPTION_HYBRID_ONLY,0,0, + "show usage information"}, + + {0,0,0,0,0,0,0,0} +}; diff --git a/src/skin/pe_skin_default.c b/src/skin/pe_skin_default.c index 5ca7387..95024c7 100644 --- a/src/skin/pe_skin_default.c +++ b/src/skin/pe_skin_default.c @@ -10,7 +10,7 @@ const perk_hidden struct argv_option pe_default_options[] = { "show usage information [listing %s options only]"}, {"cmd", 0,TAG_CMD,ARGV_OPTARG_REQUIRED,0, - "perk",0, + "perk|ar",0, "invoke one of the following perk commands: {%s}"}, {0,0,0,0,0,0,0,0} |