mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-08-05 08:10:15 +02:00
(main): Move to the end.
Remove most fwd dcls.
This commit is contained in:
+68
-72
@@ -53,11 +53,7 @@ char *savedir ();
|
||||
char *xmalloc ();
|
||||
char *xrealloc ();
|
||||
|
||||
static int change_file_group (char *file, int group);
|
||||
static int change_dir_group (char *dir, int group, struct stat *statp);
|
||||
static void describe_change (char *file, int changed);
|
||||
static void parse_group (char *name, int *g);
|
||||
static void usage (int status);
|
||||
static int change_dir_group __P ((char *dir, int group, struct stat *statp));
|
||||
|
||||
/* The name the program was run with. */
|
||||
char *program_name;
|
||||
@@ -95,62 +91,16 @@ static struct option const long_options[] =
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void
|
||||
main (int argc, char **argv)
|
||||
/* Tell the user the group name to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE was that group already. */
|
||||
|
||||
static void
|
||||
describe_change (char *file, int changed)
|
||||
{
|
||||
int group;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind <= 1)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
usage (1);
|
||||
}
|
||||
|
||||
parse_group (argv[optind++], &group);
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (argv[optind], group);
|
||||
|
||||
exit (errors);
|
||||
if (changed)
|
||||
printf ("group of %s changed to %s\n", file, groupname);
|
||||
else
|
||||
printf ("group of %s retained as %s\n", file, groupname);
|
||||
}
|
||||
|
||||
/* Set *G according to NAME. */
|
||||
@@ -289,18 +239,6 @@ change_dir_group (char *dir, int group, struct stat *statp)
|
||||
return errors;
|
||||
}
|
||||
|
||||
/* Tell the user the group name to which ownership of FILE
|
||||
has been given; if CHANGED is zero, FILE was that group already. */
|
||||
|
||||
static void
|
||||
describe_change (char *file, int changed)
|
||||
{
|
||||
if (changed)
|
||||
printf ("group of %s changed to %s\n", file, groupname);
|
||||
else
|
||||
printf ("group of %s retained as %s\n", file, groupname);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -322,3 +260,61 @@ Change the group membership of each FILE to GROUP.\n\
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
void
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int group;
|
||||
int errors = 0;
|
||||
int optc;
|
||||
|
||||
program_name = argv[0];
|
||||
recurse = force_silent = verbose = changes_only = 0;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "Rcfv", long_options, (int *) 0))
|
||||
!= EOF)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 'R':
|
||||
recurse = 1;
|
||||
break;
|
||||
case 'c':
|
||||
verbose = 1;
|
||||
changes_only = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force_silent = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("chgrp - %s\n", version_string);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind <= 1)
|
||||
{
|
||||
error (0, 0, "too few arguments");
|
||||
usage (1);
|
||||
}
|
||||
|
||||
parse_group (argv[optind++], &group);
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
errors |= change_file_group (argv[optind], group);
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
+21
-23
@@ -38,8 +38,6 @@
|
||||
#include "version.h"
|
||||
#include "error.h"
|
||||
|
||||
static void usage (int status);
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
@@ -62,6 +60,27 @@ static struct option const longopts[] =
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION] DIRECTORY...\n", program_name);
|
||||
printf ("\
|
||||
Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
\n\
|
||||
-p, --parents no error if existing, make parent directories as needed\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -134,24 +153,3 @@ main (int argc, char **argv)
|
||||
|
||||
exit (errors);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
printf ("Usage: %s [OPTION] DIRECTORY...\n", program_name);
|
||||
printf ("\
|
||||
Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
\n\
|
||||
-p, --parents no error if existing, make parent directories as needed\n\
|
||||
-m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n");
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user