Oops. Forgot the usleep.c file.
[oweals/busybox.git] / chmod_chown_chgrp.c
index d5e67b599b6863995db7cf7e88c20c41f665e49a..00c6b349a34b7fd217c1e085e6624e3a3716df49 100644 (file)
@@ -60,7 +60,7 @@ static const char chmod_usage[] =
        "\nOptions:\n\t-R\tchange files and directories recursively.\n";
 
 
-static int fileAction(const char *fileName, struct stat *statbuf)
+static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
 {
        switch (whichApp) {
        case CHGRP_APP:
@@ -81,9 +81,7 @@ static int fileAction(const char *fileName, struct stat *statbuf)
        case CHMOD_APP:
                /* Parse the specified modes */
                if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
-                       fprintf(stderr, "%s: unknown mode: %s\n", invocationName,
-                                       theMode);
-                       exit(FALSE);
+                       fatalError( "%s: unknown mode: %s\n", invocationName, theMode);
                }
                if (chmod(fileName, statbuf->st_mode) == 0)
                        return (TRUE);
@@ -100,15 +98,12 @@ int chmod_chown_chgrp_main(int argc, char **argv)
        char *p;
        const char *appUsage;
 
-       whichApp =
-               (strcmp(*argv, "chown") ==
-                0) ? CHOWN_APP : (strcmp(*argv,
-                                                                 "chmod") == 0) ? CHMOD_APP : CHGRP_APP;
+       whichApp = (strcmp(*argv, "chown") == 0)? 
+                       CHOWN_APP : (strcmp(*argv, "chmod") == 0)? 
+                               CHMOD_APP : CHGRP_APP;
 
-       appUsage =
-               (whichApp == CHOWN_APP) ? chown_usage : (whichApp ==
-                                                                                                CHMOD_APP) ? chmod_usage :
-               chgrp_usage;
+       appUsage = (whichApp == CHOWN_APP)? 
+                       chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
 
        if (argc < 2)
                usage(appUsage);
@@ -163,28 +158,31 @@ int chmod_chown_chgrp_main(int argc, char **argv)
                        if (*argv == p)
                                uid = my_getpwnam(*argv);
                        if (uid == -1) {
-                               fprintf(stderr, "%s: unknown user name: %s\n",
+                               fatalError( "%s: unknown user name: %s\n", 
                                                invocationName, *argv);
-                               exit(FALSE);
                        }
                }
        }
 
        /* Ok, ready to do the deed now */
        if (argc <= 1) {
-               fprintf(stderr, "%s: too few arguments\n", invocationName);
-               exit(FALSE);
+               fatalError( "%s: too few arguments\n", invocationName);
        }
        while (argc-- > 1) {
-               if (recursiveAction
-                       (*(++argv), recursiveFlag, TRUE, FALSE, fileAction,
-                        fileAction) == FALSE)
+               if (recursiveAction (*(++argv), recursiveFlag, TRUE, FALSE, 
+                                       fileAction, fileAction, NULL) == FALSE)
                        exit(FALSE);
        }
        exit(TRUE);
 
   bad_group:
-       fprintf(stderr, "%s: unknown group name: %s\n", invocationName,
-                       groupName);
-       exit(FALSE);
+       fatalError( "%s: unknown group name: %s\n", invocationName, groupName);
 }
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/