Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/coreutils/sleep.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/coreutils/sleep.c
r821 r1770 5 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> 6 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 21 8 */ 22 9 … … 32 19 */ 33 20 34 #include <stdlib.h> 35 #include <limits.h> 36 #include <unistd.h> 37 #include "busybox.h" 21 #include "libbb.h" 38 22 39 #ifdef CONFIG_FEATURE_FANCY_SLEEP 40 static const struct suffix_mult sleep_suffixes[] = { 23 /* This is a NOFORK applet. Be very careful! */ 24 25 26 #if ENABLE_FEATURE_FANCY_SLEEP 27 static const struct suffix_mult sfx[] = { 41 28 { "s", 1 }, 42 29 { "m", 60 }, 43 30 { "h", 60*60 }, 44 31 { "d", 24*60*60 }, 45 { NULL, 0}32 { } 46 33 }; 47 34 #endif 48 35 36 int sleep_main(int argc, char **argv); 49 37 int sleep_main(int argc, char **argv) 50 38 { 51 unsigned intduration;39 unsigned duration; 52 40 53 #if def CONFIG_FEATURE_FANCY_SLEEP41 #if ENABLE_FEATURE_FANCY_SLEEP 54 42 55 43 if (argc < 2) { … … 60 48 duration = 0; 61 49 do { 62 duration += bb_xgetularg_bnd_sfx(*argv, 10, 63 0, UINT_MAX-duration, 64 sleep_suffixes); 50 duration += xatoul_range_sfx(*argv, 0, UINT_MAX-duration, sfx); 65 51 } while (*++argv); 66 52 67 #else /* CONFIG_FEATURE_FANCY_SLEEP */53 #else /* FEATURE_FANCY_SLEEP */ 68 54 69 55 if (argc != 2) { … … 71 57 } 72 58 73 #if UINT_MAX == ULONG_MAX 74 duration = bb_xgetularg10(argv[1]); 75 #else 76 duration = bb_xgetularg10_bnd(argv[1], 0, UINT_MAX); 77 #endif 59 duration = xatou(argv[1]); 78 60 79 #endif /* CONFIG_FEATURE_FANCY_SLEEP */61 #endif /* FEATURE_FANCY_SLEEP */ 80 62 81 63 if (sleep(duration)) {
Note:
See TracChangeset
for help on using the changeset viewer.