diff options
Diffstat (limited to 'src/driver/pe_amain.c')
-rw-r--r-- | src/driver/pe_amain.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c index 547714a..5b85bef 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,15 @@ 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_NM: + pe_cmd_common(dctx,pe_cmd_nm); + break; + + case PERK_CMD_SIZE: + pe_cmd_common(dctx,pe_cmd_size); break; case PERK_CMD_AR: |