Split the processing of options out of main().

This commit is contained in:
nekral-guest 2007-12-28 10:41:22 +00:00
parent 08e09354b2
commit cc1f6c10be
2 changed files with 86 additions and 77 deletions

View File

@ -14,6 +14,7 @@
the return code was E_SUCCESS, fail_exit() wouldn't have exited. Fix
the scope of #idef WITH_AUDIT.
* src/groupadd.c: Avoid implicit brackets.
* src/groupadd.c: Split the processing of options out of main().
2007-12-27 Nicolas François <nicolas.francois@centraliens.net>

View File

@ -353,34 +353,12 @@ static gid_t get_gid (const char *gidstr)
}
/*
* main - groupadd command
* process_args - parse the command line options
*
* It will not return if an error is encountered.
*/
int main (int argc, char **argv)
static void process_args (int argc, char **argv)
{
#ifdef USE_PAM
pam_handle_t *pamh = NULL;
int retval;
#endif
#ifdef WITH_AUDIT
audit_help_open ();
#endif
/*
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
OPENLOG ("groupadd");
{
/*
* Parse the command line options.
*/
char *cp;
int option_index = 0;
int c;
@ -441,7 +419,6 @@ int main (int argc, char **argv)
usage ();
}
}
}
if (oflg && !gflg) {
usage ();
@ -451,8 +428,39 @@ int main (int argc, char **argv)
usage ();
}
group_name = argv[argc - 1];
group_name = argv[optind];
check_new_name ();
}
/*
* main - groupadd command
*/
int main (int argc, char **argv)
{
#ifdef USE_PAM
pam_handle_t *pamh = NULL;
int retval;
#endif
#ifdef WITH_AUDIT
audit_help_open ();
#endif
/*
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
OPENLOG ("groupadd");
/*
* Parse the command line options.
*/
process_args (argc, argv);
#ifdef USE_PAM
retval = PAM_SUCCESS;