Fixed auto-arranging of options groups. Fixed spelling of license option.
Showing
1 changed file
with
27 additions
and
19 deletions
... | @@ -64,8 +64,8 @@ static struct argp_option mu_common_argp_options[] = | ... | @@ -64,8 +64,8 @@ static struct argp_option mu_common_argp_options[] = |
64 | { NULL, 0, NULL, 0, NULL, 0 } | 64 | { NULL, 0, NULL, 0, NULL, 0 } |
65 | }; | 65 | }; |
66 | 66 | ||
67 | /* Option to print the licence. */ | 67 | /* Option to print the license. */ |
68 | static struct argp_option mu_licence_argp_option[] = { | 68 | static struct argp_option mu_license_argp_option[] = { |
69 | { "license", 'L', NULL, 0, "Print license and exit", -2 }, | 69 | { "license", 'L', NULL, 0, "Print license and exit", -2 }, |
70 | { NULL, 0, NULL, 0, NULL, 0 } | 70 | { NULL, 0, NULL, 0, NULL, 0 } |
71 | }; | 71 | }; |
... | @@ -139,20 +139,20 @@ struct argp mu_common_argp = { | ... | @@ -139,20 +139,20 @@ struct argp mu_common_argp = { |
139 | struct argp_child mu_common_argp_child = { | 139 | struct argp_child mu_common_argp_child = { |
140 | &mu_common_argp, | 140 | &mu_common_argp, |
141 | 0, | 141 | 0, |
142 | "", | 142 | NULL, |
143 | -10, | 143 | 0, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | struct argp mu_licence_argp = { | 146 | struct argp mu_license_argp = { |
147 | mu_licence_argp_option, | 147 | mu_license_argp_option, |
148 | mu_common_argp_parser, | 148 | mu_common_argp_parser, |
149 | }; | 149 | }; |
150 | 150 | ||
151 | struct argp_child mu_licence_argp_child = { | 151 | struct argp_child mu_license_argp_child = { |
152 | &mu_licence_argp, | 152 | &mu_license_argp, |
153 | 0, | 153 | 0, |
154 | "", | 154 | NULL, |
155 | -2 | 155 | 0 |
156 | }; | 156 | }; |
157 | 157 | ||
158 | struct argp mu_mailbox_argp = { | 158 | struct argp mu_mailbox_argp = { |
... | @@ -163,8 +163,8 @@ struct argp mu_mailbox_argp = { | ... | @@ -163,8 +163,8 @@ struct argp mu_mailbox_argp = { |
163 | struct argp_child mu_mailbox_argp_child = { | 163 | struct argp_child mu_mailbox_argp_child = { |
164 | &mu_mailbox_argp, | 164 | &mu_mailbox_argp, |
165 | 0, | 165 | 0, |
166 | "", | 166 | NULL, |
167 | -3 | 167 | 0 |
168 | }; | 168 | }; |
169 | 169 | ||
170 | struct argp mu_logging_argp = { | 170 | struct argp mu_logging_argp = { |
... | @@ -175,8 +175,8 @@ struct argp mu_logging_argp = { | ... | @@ -175,8 +175,8 @@ struct argp mu_logging_argp = { |
175 | struct argp_child mu_logging_argp_child = { | 175 | struct argp_child mu_logging_argp_child = { |
176 | &mu_logging_argp, | 176 | &mu_logging_argp, |
177 | 0, | 177 | 0, |
178 | "", | 178 | NULL, |
179 | -3 | 179 | 0 |
180 | }; | 180 | }; |
181 | 181 | ||
182 | struct argp mu_auth_argp = { | 182 | struct argp mu_auth_argp = { |
... | @@ -188,6 +188,7 @@ struct argp_child mu_auth_argp_child = { | ... | @@ -188,6 +188,7 @@ struct argp_child mu_auth_argp_child = { |
188 | &mu_auth_argp, | 188 | &mu_auth_argp, |
189 | 0, | 189 | 0, |
190 | "Authentication options", | 190 | "Authentication options", |
191 | 0 | ||
191 | }; | 192 | }; |
192 | 193 | ||
193 | struct argp mu_daemon_argp = { | 194 | struct argp mu_daemon_argp = { |
... | @@ -276,7 +277,7 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -276,7 +277,7 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) |
276 | { | 277 | { |
277 | /* common */ | 278 | /* common */ |
278 | case 'L': | 279 | case 'L': |
279 | printf ("Licence for %s:\n\n", argp_program_version); | 280 | printf ("License for %s:\n\n", argp_program_version); |
280 | printf ("%s", license_text); | 281 | printf ("%s", license_text); |
281 | exit (0); | 282 | exit (0); |
282 | 283 | ||
... | @@ -664,7 +665,7 @@ struct argp_capa { | ... | @@ -664,7 +665,7 @@ struct argp_capa { |
664 | struct argp_child *child; | 665 | struct argp_child *child; |
665 | } mu_argp_capa[] = { | 666 | } mu_argp_capa[] = { |
666 | {"common", &mu_common_argp_child}, | 667 | {"common", &mu_common_argp_child}, |
667 | {"licence", &mu_licence_argp_child}, | 668 | {"license", &mu_license_argp_child}, |
668 | {"mailbox", &mu_mailbox_argp_child}, | 669 | {"mailbox", &mu_mailbox_argp_child}, |
669 | {"logging", &mu_logging_argp_child}, | 670 | {"logging", &mu_logging_argp_child}, |
670 | {"auth", &mu_auth_argp_child}, | 671 | {"auth", &mu_auth_argp_child}, |
... | @@ -688,8 +689,9 @@ mu_build_argp (const struct argp *template, const char *capa[]) | ... | @@ -688,8 +689,9 @@ mu_build_argp (const struct argp *template, const char *capa[]) |
688 | int n; | 689 | int n; |
689 | int nchild; | 690 | int nchild; |
690 | struct argp_child *ap; | 691 | struct argp_child *ap; |
692 | struct argp_option *opt; | ||
691 | struct argp *argp; | 693 | struct argp *argp; |
692 | int group = -100; | 694 | int group = 0; |
693 | 695 | ||
694 | /* Count the capabilities. */ | 696 | /* Count the capabilities. */ |
695 | for (n = 0; capa && capa[n]; n++) | 697 | for (n = 0; capa && capa[n]; n++) |
... | @@ -711,7 +713,13 @@ mu_build_argp (const struct argp *template, const char *capa[]) | ... | @@ -711,7 +713,13 @@ mu_build_argp (const struct argp *template, const char *capa[]) |
711 | for (n = 0; template->children[n].argp; n++, nchild++) | 713 | for (n = 0; template->children[n].argp; n++, nchild++) |
712 | ap[nchild] = template->children[n]; | 714 | ap[nchild] = template->children[n]; |
713 | 715 | ||
714 | group = -nchild - 1; | 716 | /* Find next group number */ |
717 | for (opt = template->options; | ||
718 | opt && ((opt->name && opt->key) || opt->doc); opt++) | ||
719 | if (opt->group > group) | ||
720 | group = opt->group; | ||
721 | |||
722 | group++; | ||
715 | 723 | ||
716 | /* Append any capabilities to the children or options, as appropriate. */ | 724 | /* Append any capabilities to the children or options, as appropriate. */ |
717 | for (n = 0; capa && capa[n]; n++) | 725 | for (n = 0; capa && capa[n]; n++) |
... | @@ -724,7 +732,7 @@ mu_build_argp (const struct argp *template, const char *capa[]) | ... | @@ -724,7 +732,7 @@ mu_build_argp (const struct argp *template, const char *capa[]) |
724 | abort (); | 732 | abort (); |
725 | } | 733 | } |
726 | ap[nchild] = *child; | 734 | ap[nchild] = *child; |
727 | // ap[nchild].group = group++; | 735 | ap[nchild].group = group++; |
728 | nchild++; | 736 | nchild++; |
729 | } | 737 | } |
730 | ap[nchild].argp = NULL; | 738 | ap[nchild].argp = NULL; | ... | ... |
-
Please register or sign in to post a comment