diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-07-26 09:16:00 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-07-26 09:16:00 +0000 |
commit | a1ed06b04739d85389fe23e78e97556864b77c64 (patch) | |
tree | 80ceac0ee76ad0bee1838252ced4f0cfd097659c /debianutils/run_parts.c | |
parent | aa820dbc00860a2ddcb7a0205345ffe39c7d18d7 (diff) | |
download | busybox-w32-a1ed06b04739d85389fe23e78e97556864b77c64.tar.gz busybox-w32-a1ed06b04739d85389fe23e78e97556864b77c64.tar.bz2 busybox-w32-a1ed06b04739d85389fe23e78e97556864b77c64.zip |
Move start_stop_daemon to debianutils.
Cleanup run_parts a bit and add long opts
Diffstat (limited to 'debianutils/run_parts.c')
-rw-r--r-- | debianutils/run_parts.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index a941e1fc8..98fd58887 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c | |||
@@ -54,6 +54,13 @@ | |||
54 | 54 | ||
55 | #include "libbb.h" | 55 | #include "libbb.h" |
56 | 56 | ||
57 | static const struct option runparts_long_options[] = { | ||
58 | { "test", 0, NULL, 't' }, | ||
59 | { "umask", 1, NULL, 'u' }, | ||
60 | { "arg", 1, NULL, 'a' }, | ||
61 | { 0, 0, 0, 0 } | ||
62 | }; | ||
63 | |||
57 | /* run_parts_main */ | 64 | /* run_parts_main */ |
58 | /* Process options */ | 65 | /* Process options */ |
59 | int run_parts_main(int argc, char **argv) | 66 | int run_parts_main(int argc, char **argv) |
@@ -65,32 +72,31 @@ int run_parts_main(int argc, char **argv) | |||
65 | 72 | ||
66 | umask(022); | 73 | umask(022); |
67 | 74 | ||
68 | while ((opt = getopt(argc, argv, "tu:a:")) != -1) { | 75 | while ((opt = getopt_long (argc, argv, "tu:a:", |
76 | runparts_long_options, NULL)) > 0) | ||
77 | { | ||
69 | switch (opt) { | 78 | switch (opt) { |
70 | case 't': /* Enable test mode */ | 79 | /* Enable test mode */ |
71 | test_mode = 1; | 80 | case 't': |
72 | break; | 81 | test_mode++; |
73 | case 'u': /* Set the umask of the programs executed */ | 82 | break; |
74 | /* Check and set the umask of the program executed. As stated in the original | 83 | /* Set the umask of the programs executed */ |
75 | * run-parts, the octal conversion in libc is not foolproof; it will take the | 84 | case 'u': |
76 | * 8 and 9 digits under some circumstances. We'll just have to live with it. | 85 | /* Check and set the umask of the program executed. As stated in the original |
77 | */ | 86 | * run-parts, the octal conversion in libc is not foolproof; it will take the |
78 | { | 87 | * 8 and 9 digits under some circumstances. We'll just have to live with it. |
79 | const unsigned int mask = (unsigned int) strtol(optarg, NULL, 8); | 88 | */ |
80 | if (mask > 07777) { | 89 | umask(bb_xgetlarg(optarg, 8, 0, 07777)); |
81 | bb_perror_msg_and_die("bad umask value"); | 90 | break; |
82 | } | 91 | /* Pass an argument to the programs */ |
83 | umask(mask); | 92 | case 'a': |
84 | } | 93 | /* Add an argument to the commands that we will call. |
85 | break; | 94 | * Called once for every argument. */ |
86 | case 'a': /* Pass an argument to the programs */ | 95 | args = xrealloc(args, (argcount + 2) * (sizeof(char *))); |
87 | /* Add an argument to the commands that we will call. | 96 | args[argcount++] = optarg; |
88 | * Called once for every argument. */ | 97 | break; |
89 | args = xrealloc(args, (argcount + 2) * (sizeof(char *))); | 98 | default: |
90 | args[argcount++] = optarg; | 99 | bb_show_usage(); |
91 | break; | ||
92 | default: | ||
93 | bb_show_usage(); | ||
94 | } | 100 | } |
95 | } | 101 | } |
96 | 102 | ||