diff options
author | midipix <writeonce@midipix.org> | 2025-06-18 19:15:01 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2025-06-18 19:15:01 +0000 |
commit | b8e5620be56aed113d59dcd6f9953cad53d58831 (patch) | |
tree | bbd843d117027475ccf7b194efad967d1689ea89 | |
parent | 71b7c27d150c4048c6aac04ff4e00e6f29265034 (diff) | |
download | perk-b8e5620be56aed113d59dcd6f9953cad53d58831.tar.bz2 perk-b8e5620be56aed113d59dcd6f9953cad53d58831.tar.xz |
driver: pe_main(): refactor, internally use pe_cmd_common().
-rw-r--r-- | src/driver/pe_amain.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c index 2a977ad..5a925f5 100644 --- a/src/driver/pe_amain.c +++ b/src/driver/pe_amain.c @@ -57,13 +57,24 @@ static int pe_exit(struct pe_driver_ctx * dctx, int ret) return ret; } +typedef int (*pe_cmd)(const struct pe_driver_ctx *, const char *); + +static void pe_cmd_common( + const struct pe_driver_ctx * dctx, + pe_cmd cmdfn) +{ + const char ** unit; + + for (unit=dctx->units; *unit; unit++) + cmdfn(dctx,*unit); +} + int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx) { int ret; int fdout; uint64_t flags; struct pe_driver_ctx * dctx; - const char ** unit; const char * posname; const char * arname; const char ** arfiles; @@ -83,8 +94,7 @@ int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx) switch (dctx->cctx->cmd) { case PERK_CMD_PERK: - for (unit=dctx->units; *unit; unit++) - pe_cmd_perk(dctx,*unit); + pe_cmd_common(dctx,pe_cmd_perk); break; case PERK_CMD_AR: @@ -105,13 +115,11 @@ int pe_main(char ** argv, char ** envp, const struct pe_fd_ctx * fdctx) break; case PERK_CMD_NM: - for (unit=dctx->units; *unit; unit++) - pe_cmd_nm(dctx,*unit); + pe_cmd_common(dctx,pe_cmd_nm); break; case PERK_CMD_SIZE: - for (unit=dctx->units; *unit; unit++) - pe_cmd_size(dctx,*unit); + pe_cmd_common(dctx,pe_cmd_size); break; default: |