Split process_flags() out of main(). New global variables is_shadow,

sort_mode.
This commit is contained in:
nekral-guest 2008-01-01 15:07:41 +00:00
parent a3501dfd95
commit 6912ac253a
2 changed files with 43 additions and 23 deletions

View File

@ -1,3 +1,8 @@
2008-01-01 Nicolas François <nicolas.francois@centraliens.net>
* src/pwck.c: Split process_flags() out of main(). New global
variables is_shadow, sort_mode.
2008-01-01 Nicolas François <nicolas.francois@centraliens.net> 2008-01-01 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/xgetXXbyYY.c: De-comment code (duplicate the entry when * libmisc/xgetXXbyYY.c: De-comment code (duplicate the entry when

View File

@ -66,13 +66,18 @@ extern struct commonio_entry *__spw_get_head (void);
static char *Prog; static char *Prog;
static const char *pwd_file = PASSWD_FILE; static const char *pwd_file = PASSWD_FILE;
static const char *spw_file = SHADOW_FILE; static const char *spw_file = SHADOW_FILE;
static int is_shadow = 0;
/* Options */
static int read_only = 0; static int read_only = 0;
static int sort_mode = 0;
static int quiet = 0; /* don't report warnings, only errors */ static int quiet = 0; /* don't report warnings, only errors */
/* local function prototypes */ /* local function prototypes */
static void usage (void); static void usage (void);
static void process_flags (int argc, char **argv);
/* /*
* usage - print syntax message and exit * usage - print syntax message and exit
@ -85,31 +90,13 @@ static void usage (void)
} }
/* /*
* pwck - verify password file integrity * process_flags - parse the command line options
*
* It will not return if an error is encountered.
*/ */
int main (int argc, char **argv) static void process_flags (int argc, char **argv)
{ {
int arg; int arg;
int errors = 0;
int changed = 0;
struct commonio_entry *pfe, *tpfe;
struct passwd *pwd;
int sort_mode = 0;
struct commonio_entry *spe, *tspe;
struct spwd *spw;
int is_shadow = 0;
/*
* 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 ("pwck");
/* /*
* Parse the command line arguments * Parse the command line arguments
@ -156,6 +143,34 @@ int main (int argc, char **argv)
is_shadow = 1; is_shadow = 1;
} else if (optind == argc) } else if (optind == argc)
is_shadow = spw_file_present (); is_shadow = spw_file_present ();
}
/*
* pwck - verify password file integrity
*/
int main (int argc, char **argv)
{
int errors = 0;
int changed = 0;
struct commonio_entry *pfe, *tpfe;
struct passwd *pwd;
struct commonio_entry *spe, *tspe;
struct spwd *spw;
/*
* 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 ("pwck");
/* Parse the command line arguments */
process_flags (argc, argv);
/* /*
* Lock the files if we aren't in "read-only" mode * Lock the files if we aren't in "read-only" mode