aboutsummaryrefslogtreecommitdiff
path: root/toys/touch.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-01-20 17:25:44 -0600
committerRob Landley <rob@landley.net>2008-01-20 17:25:44 -0600
commitb1aaba1fc8176ac0b7c202a664d2554aa0967116 (patch)
tree7bbd14f5dd2413a6b913ea04b0bdf746a2d5b1fb /toys/touch.c
parenteb9b8da0698aacd14f5aa0879d2a8e390c0c6c13 (diff)
downloadtoybox-b1aaba1fc8176ac0b7c202a664d2554aa0967116.tar.gz
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
macros in each C file, and making generated/globals.h from that. Rename "toy" to "this" along the way to avoid toy/toys confusion.
Diffstat (limited to 'toys/touch.c')
-rw-r--r--toys/touch.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/toys/touch.c b/toys/touch.c
index 65afe58d..c8cba76b 100644
--- a/toys/touch.c
+++ b/toys/touch.c
@@ -26,6 +26,14 @@ config TOUCH
#include "toys.h"
+DEFINE_GLOBALS(
+ char *ref_file;
+ char *time;
+ long length;
+)
+
+#define TT this.touch
+
#define OPT_MTIME 0x01
#define OPT_NOCREATE 0x02
#define OPT_ATIME 0x04
@@ -48,7 +56,7 @@ void touch_main(void)
if (toys.optflags & OPT_TIME)
error_exit("Redundant time source");
- xstat(toy.touch.ref_file, &sb);
+ xstat(TT.ref_file, &sb);
curr_m = sb.st_mtime;
curr_a = sb.st_atime;
@@ -60,10 +68,10 @@ void touch_main(void)
curr = time(NULL);
if (localtime_r(&curr, &t)
- || !(c = strptime(toy.touch.time, "%m%d%H%M", &t))
+ || !(c = strptime(TT.time, "%m%d%H%M", &t))
|| *c || -1==(curr_a = curr_m = mktime(&t)))
{
- error_exit("Unknown time %s", toy.touch.time);
+ error_exit("Unknown time %s", TT.time);
}
// use current time
@@ -93,7 +101,7 @@ void touch_main(void)
}
if (toys.optflags & OPT_LENGTH)
- if (truncate(arg, toy.touch.length))
+ if (truncate(arg, TT.length))
goto error;
if (utime(arg, &buf))
error: