summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2025-06-02 20:50:53 +0000
committermidipix <writeonce@midipix.org>2025-06-02 20:50:53 +0000
commitc5c7073a522fc96ec5c0270de6d5e48154d5cd62 (patch)
tree4b962baea52ed9bcf57a090f43c44a139043ae8e /src
parent6fef9e880f2475628ccb74e2bd0a2b8fdc347361 (diff)
downloadperk-c5c7073a522fc96ec5c0270de6d5e48154d5cd62.tar.bz2
perk-c5c7073a522fc96ec5c0270de6d5e48154d5cd62.tar.xz
driver: utility: invoke pe_cmd_ar() with appropriate <posname> & <arname> args.
Diffstat (limited to 'src')
-rw-r--r--src/driver/pe_amain.c20
-rw-r--r--src/internal/perk_ar_impl.h4
2 files changed, 23 insertions, 1 deletions
diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c
index fb68e30..02e3a0a 100644
--- a/src/driver/pe_amain.c
+++ b/src/driver/pe_amain.c
@@ -10,6 +10,7 @@
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_dprintf_impl.h"
+#include "perk_ar_impl.h"
#ifndef PERK_DRIVER_FLAGS
#define PERK_DRIVER_FLAGS PERK_DRIVER_VERBOSITY_ERRORS \
@@ -65,6 +66,10 @@ int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx)
uint64_t flags;
struct pe_driver_ctx * dctx;
const char ** unit;
+ const char * posname;
+ const char * arname;
+ const char ** arfiles;
+ uint64_t arflags;
flags = PERK_DRIVER_FLAGS;
fdout = fdctx ? fdctx->fdout : STDOUT_FILENO;
@@ -85,7 +90,20 @@ int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx)
break;
case PERK_CMD_AR:
- pe_cmd_ar(dctx,0,0,0,0);
+ arflags = dctx->cctx->drvflags;
+
+ if (arflags & AR_POSNAME_MASK) {
+ posname = dctx->units[0];
+ arname = posname ? dctx->units[1] : 0;
+ arfiles = arname ? &dctx->units[2] : 0;
+ } else {
+ posname = 0;
+ arname = dctx->units[0];
+ arfiles = arname ? &dctx->units[1] : 0;
+ }
+
+ pe_cmd_ar(dctx,arflags,posname,arname,arfiles);
+
break;
default:
diff --git a/src/internal/perk_ar_impl.h b/src/internal/perk_ar_impl.h
index 543526d..aa44396 100644
--- a/src/internal/perk_ar_impl.h
+++ b/src/internal/perk_ar_impl.h
@@ -20,6 +20,10 @@
/* initial number of elements in the transient, on-stack vector */
# define AR_STACK_VECTOR_ELEMENTS (0x200)
+/* bit mask to indicate that the first non-option argument is <posname> */
+#define AR_POSNAME_MASK (PERK_DRIVER_AR_POSITION_AFTER \
+ |PERK_DRIVER_AR_POSITION_BEFORE)
+
extern const struct argv_option pe_ar_options[];
struct ar_armaps_impl {