aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-15 10:42:17 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-15 10:42:17 +0200
commitf2710d02210bbba4a9580c11ff053b01081eaf54 (patch)
treefe18f6f4f483c3180e46ed00df7c0531e3be5c97
parent05e8605ab8a01120af7c9f011c2334ab34381fdf (diff)
downloadbusybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.tar.gz
busybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.tar.bz2
busybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.zip
date: move applet and usage bits to date.c
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--coreutils/date.c106
-rw-r--r--include/applets.src.h1
-rw-r--r--include/usage.src.h40
3 files changed, 74 insertions, 73 deletions
diff --git a/coreutils/date.c b/coreutils/date.c
index c9dfedf81..87cc8f2ef 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -19,38 +19,7 @@
19/* Input parsing code is always bulky - used heavy duty libc stuff as 19/* Input parsing code is always bulky - used heavy duty libc stuff as
20 much as possible, missed out a lot of bounds checking */ 20 much as possible, missed out a lot of bounds checking */
21 21
22/* Default input handling to save surprising some people */ 22//applet:IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP))
23
24/* GNU coreutils 6.9 man page:
25 * date [OPTION]... [+FORMAT]
26 * date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
27 * -d, --date=STRING
28 * display time described by STRING, not `now'
29 * -f, --file=DATEFILE
30 * like --date once for each line of DATEFILE
31 * -r, --reference=FILE
32 * display the last modification time of FILE
33 * -R, --rfc-2822
34 * output date and time in RFC 2822 format.
35 * Example: Mon, 07 Aug 2006 12:34:56 -0600
36 * --rfc-3339=TIMESPEC
37 * output date and time in RFC 3339 format.
38 * TIMESPEC='date', 'seconds', or 'ns'
39 * Date and time components are separated by a single space:
40 * 2006-08-07 12:34:56-06:00
41 * -s, --set=STRING
42 * set time described by STRING
43 * -u, --utc, --universal
44 * print or set Coordinated Universal Time
45 *
46 * Busybox:
47 * long options are not supported
48 * -f is not supported
49 * -I seems to roughly match --rfc-3339, but -I has _optional_ param
50 * (thus "-I seconds" doesn't work, only "-Iseconds"),
51 * and does not support -Ins
52 * -D FMT is a bbox extension for _input_ conversion of -d DATE
53 */
54 23
55//kbuild:lib-$(CONFIG_DATE) += date.o 24//kbuild:lib-$(CONFIG_DATE) += date.o
56 25
@@ -69,6 +38,7 @@
69//config: Enable option (-I) to output an ISO-8601 compliant 38//config: Enable option (-I) to output an ISO-8601 compliant
70//config: date/time string. 39//config: date/time string.
71//config: 40//config:
41//config:# defaults to "no": stat's nanosecond field is a bit non-portable
72//config:config FEATURE_DATE_NANO 42//config:config FEATURE_DATE_NANO
73//config: bool "Support %[num]N nanosecond format specifier" 43//config: bool "Support %[num]N nanosecond format specifier"
74//config: default n 44//config: default n
@@ -92,6 +62,78 @@
92//config: the same format. With it on, 'date DATE' additionally supports 62//config: the same format. With it on, 'date DATE' additionally supports
93//config: MMDDhhmm[[YY]YY][.ss] format. 63//config: MMDDhhmm[[YY]YY][.ss] format.
94 64
65/* GNU coreutils 6.9 man page:
66 * date [OPTION]... [+FORMAT]
67 * date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
68 * -d, --date=STRING
69 * display time described by STRING, not `now'
70 * -f, --file=DATEFILE
71 * like --date once for each line of DATEFILE
72 * -r, --reference=FILE
73 * display the last modification time of FILE
74 * -R, --rfc-2822
75 * output date and time in RFC 2822 format.
76 * Example: Mon, 07 Aug 2006 12:34:56 -0600
77 * --rfc-3339=TIMESPEC
78 * output date and time in RFC 3339 format.
79 * TIMESPEC='date', 'seconds', or 'ns'
80 * Date and time components are separated by a single space:
81 * 2006-08-07 12:34:56-06:00
82 * -s, --set=STRING
83 * set time described by STRING
84 * -u, --utc, --universal
85 * print or set Coordinated Universal Time
86 *
87 * Busybox:
88 * long options are not supported
89 * -f is not supported
90 * -I seems to roughly match --rfc-3339, but -I has _optional_ param
91 * (thus "-I seconds" doesn't work, only "-Iseconds"),
92 * and does not support -Ins
93 * -D FMT is a bbox extension for _input_ conversion of -d DATE
94 */
95
96//usage:#define date_trivial_usage
97//usage: "[OPTIONS] [+FMT] [TIME]"
98//usage:#define date_full_usage "\n\n"
99//usage: "Display time (using +FMT), or set time\n"
100//usage: "\nOptions:"
101//usage: IF_NOT_LONG_OPTS(
102//usage: "\n [-s] TIME Set time to TIME"
103//usage: "\n -u Work in UTC (don't convert to local time)"
104//usage: "\n -R Output RFC-2822 compliant date string"
105//usage: ) IF_LONG_OPTS(
106//usage: "\n [-s,--set] TIME Set time to TIME"
107//usage: "\n -u,--utc Work in UTC (don't convert to local time)"
108//usage: "\n -R,--rfc-2822 Output RFC-2822 compliant date string"
109//usage: )
110//usage: IF_FEATURE_DATE_ISOFMT(
111//usage: "\n -I[SPEC] Output ISO-8601 compliant date string"
112//usage: "\n SPEC='date' (default) for date only,"
113//usage: "\n 'hours', 'minutes', or 'seconds' for date and"
114//usage: "\n time to the indicated precision"
115//usage: )
116//usage: IF_NOT_LONG_OPTS(
117//usage: "\n -r FILE Display last modification time of FILE"
118//usage: "\n -d TIME Display TIME, not 'now'"
119//usage: ) IF_LONG_OPTS(
120//usage: "\n -r,--reference FILE Display last modification time of FILE"
121//usage: "\n -d,--date TIME Display TIME, not 'now'"
122//usage: )
123//usage: IF_FEATURE_DATE_ISOFMT(
124//usage: "\n -D FMT Use FMT for -d TIME conversion"
125//usage: )
126//usage: "\n"
127//usage: "\nRecognized TIME formats:"
128//usage: "\n hh:mm[:ss]"
129//usage: "\n [YYYY.]MM.DD-hh:mm[:ss]"
130//usage: "\n YYYY-MM-DD hh:mm[:ss]"
131//usage: "\n [[[[[YY]YY]MM]DD]hh]mm[.ss]"
132//usage:
133//usage:#define date_example_usage
134//usage: "$ date\n"
135//usage: "Wed Apr 12 18:52:41 MDT 2000\n"
136
95#include "libbb.h" 137#include "libbb.h"
96#if ENABLE_FEATURE_DATE_NANO 138#if ENABLE_FEATURE_DATE_NANO
97# include <sys/syscall.h> 139# include <sys/syscall.h>
diff --git a/include/applets.src.h b/include/applets.src.h
index 545d3c5c2..a42f6fffa 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -98,7 +98,6 @@ IF_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
98IF_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) 98IF_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE))
99IF_CRYPTPW(APPLET(cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 99IF_CRYPTPW(APPLET(cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP))
100IF_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_DROP, cut)) 100IF_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_DROP, cut))
101IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP))
102IF_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 101IF_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_DROP))
103IF_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_DROP, dd)) 102IF_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_DROP, dd))
104IF_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 103IF_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_DROP))
diff --git a/include/usage.src.h b/include/usage.src.h
index 084427cc0..1bb4b563c 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -702,46 +702,6 @@ INSERT
702 "$ echo \"Hello world\" | cut -f 2 -d ' '\n" \ 702 "$ echo \"Hello world\" | cut -f 2 -d ' '\n" \
703 "world\n" 703 "world\n"
704 704
705#define date_trivial_usage \
706 "[OPTIONS] [+FMT] [TIME]"
707#define date_full_usage "\n\n" \
708 "Display time (using +FMT), or set time\n" \
709 "\nOptions:" \
710 IF_NOT_LONG_OPTS( \
711 "\n [-s] TIME Set time to TIME" \
712 "\n -u Work in UTC (don't convert to local time)" \
713 "\n -R Output RFC-2822 compliant date string" \
714 ) IF_LONG_OPTS( \
715 "\n [-s,--set] TIME Set time to TIME" \
716 "\n -u,--utc Work in UTC (don't convert to local time)" \
717 "\n -R,--rfc-2822 Output RFC-2822 compliant date string" \
718 ) \
719 IF_FEATURE_DATE_ISOFMT( \
720 "\n -I[SPEC] Output ISO-8601 compliant date string" \
721 "\n SPEC='date' (default) for date only," \
722 "\n 'hours', 'minutes', or 'seconds' for date and" \
723 "\n time to the indicated precision" \
724 ) IF_NOT_LONG_OPTS( \
725 "\n -r FILE Display last modification time of FILE" \
726 "\n -d TIME Display TIME, not 'now'" \
727 ) IF_LONG_OPTS( \
728 "\n -r,--reference FILE Display last modification time of FILE" \
729 "\n -d,--date TIME Display TIME, not 'now'" \
730 ) \
731 IF_FEATURE_DATE_ISOFMT( \
732 "\n -D FMT Use FMT for -d TIME conversion" \
733 ) \
734 "\n" \
735 "\nRecognized TIME formats:" \
736 "\n hh:mm[:ss]" \
737 "\n [YYYY.]MM.DD-hh:mm[:ss]" \
738 "\n YYYY-MM-DD hh:mm[:ss]" \
739 "\n [[[[[YY]YY]MM]DD]hh]mm[.ss]" \
740
741#define date_example_usage \
742 "$ date\n" \
743 "Wed Apr 12 18:52:41 MDT 2000\n"
744
745#define dd_trivial_usage \ 705#define dd_trivial_usage \
746 "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n" \ 706 "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n" \
747 " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]") 707 " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]")