New function check_flags(). Split the validation of

options and arguments out of process_flags.
This commit is contained in:
nekral-guest 2007-12-28 21:04:04 +00:00
parent 605a338216
commit 8dc4ca297c
2 changed files with 13 additions and 5 deletions

View File

@ -22,6 +22,8 @@
* src/groupadd.c: Avoid implicit brackets. * src/groupadd.c: Avoid implicit brackets.
* src/groupadd.c: Split the processing and checking of options out of * src/groupadd.c: Split the processing and checking of options out of
main() (process_flags). main() (process_flags).
* src/groupadd.c: New function check_flags(). Split the validation of
options and arguments out of process_flags.
* src/groupadd.c: Add the parameters' names in the prototypes. * src/groupadd.c: Add the parameters' names in the prototypes.
2007-12-27 Nicolas François <nicolas.francois@centraliens.net> 2007-12-27 Nicolas François <nicolas.francois@centraliens.net>

View File

@ -91,6 +91,7 @@ static void open_files (void);
static void fail_exit (int code); static void fail_exit (int code);
static gid_t get_gid (const char *gidstr); static gid_t get_gid (const char *gidstr);
static void process_flags (int argc, char **argv); static void process_flags (int argc, char **argv);
static void check_flags (void);
static void check_perms (void); static void check_perms (void);
/* /*
@ -434,16 +435,21 @@ static void process_flags (int argc, char **argv)
/* /*
* Check the flags consistency * Check the flags consistency
*/ */
if (oflg && !gflg) {
usage ();
}
if (optind != argc - 1) { if (optind != argc - 1) {
usage (); usage ();
} }
group_name = argv[optind]; group_name = argv[optind];
check_flags ();
}
static void check_flags (void)
{
/* -o does not make sense without -g */
if (oflg && !gflg) {
usage ();
}
check_new_name (); check_new_name ();
/* /*