- add libbb function str_tolower to convert a string to lowercase.
[oweals/busybox.git] / coreutils / touch.c
index 3d780e1679e2c832d555fb03c2f8cb585d64b0aa..5f81b2380858dd9086e3c43b06be775c71ace2b0 100644 (file)
@@ -2,22 +2,9 @@
 /*
  * Mini touch implementation for busybox
  *
- * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 /* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m, -r, -t not supported. */
  * Also, exiting on a failure was a bug.  All args should be processed.
  */
 
-#include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
 #include "busybox.h"
 
-extern int touch_main(int argc, char **argv)
+/* This is a NOFORK applet. Be very careful! */
+
+int touch_main(int argc, char **argv);
+int touch_main(int argc, char **argv)
 {
        int fd;
-       int flags;
        int status = EXIT_SUCCESS;
-
-       flags = bb_getopt_ulflags(argc, argv, "c");
+       int flags = getopt32(argc, argv, "c");
 
        argv += optind;
 
@@ -55,8 +36,8 @@ extern int touch_main(int argc, char **argv)
 
        do {
                if (utime(*argv, NULL)) {
-                       if (errno == ENOENT) {  /* no such file*/
-                               if (flags & 1) {        /* Creation is disabled, so ignore. */
+                       if (errno == ENOENT) {  /* no such file */
+                               if (flags) {    /* Creation is disabled, so ignore. */
                                        continue;
                                }
                                /* Try to create the file. */