From 5fef5234a48986c93b13b205be3e8dc131a4fa19 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 25 May 2001 17:52:03 +0000 Subject: 2001-05-25 Joel Sherrill * shell/cmds.c: Removed code from inappropriate source. --- cpukit/libmisc/shell/cmds.c | 61 +++++++++++---------------------------------- 1 file changed, 14 insertions(+), 47 deletions(-) (limited to 'cpukit/libmisc/shell/cmds.c') diff --git a/cpukit/libmisc/shell/cmds.c b/cpukit/libmisc/shell/cmds.c index 32402aa1e7..aa7449e9a6 100644 --- a/cpukit/libmisc/shell/cmds.c +++ b/cpukit/libmisc/shell/cmds.c @@ -10,8 +10,6 @@ * A 'monitor' command is added to adapt the call rtems monitor commands * at my call procedure * - * MINIX date.c is adapted to run here. Like a exercise only.... - * * TODO: A lot of improvements of course. * cp, mv, ... * hexdump, @@ -385,56 +383,24 @@ int main_rm (int argc, char *argv[]) return 0; } /*-----------------------------------------------------------*/ -/* date - print or set time and date Author: Jan Looyen */ -/* MINIX 1.5 GPL'ed */ - - -#define MIN 60L /* # seconds in a minute */ -#define HOUR (60 * MIN) /* # seconds in an hour */ -#define DAY (24 * HOUR) /* # seconds in a day */ -#define YEAR (365 * DAY) /* # seconds in a year */ - -static int conv(unsigned32 *value,char **ptr,unsigned32 max) -{ - int buf; - *ptr -= 2; - buf = atoi(*ptr); - **ptr = 0; - if (buf < 0 || buf > max) { - fprintf(stderr, "Date: bad conversion\n"); - return 0; - }; - *value=buf; - return 1; -} +/* date - print or set time and date */ static int set_time(char *t) { rtems_time_of_day tod; FILE * rtc; - char *tp; int len; - if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod)!=RTEMS_SUCCESSFUL) - memset(&tod,0,sizeof(tod)); - len = strlen(t); - if (len != 12 && len != 10 && len != 6 && len != 4) return 0; - tp = t; - while (*tp) - if (!isdigit(*tp++)) { - fprintf(stderr, "date: bad conversion\n"); - return 0; - }; - if (len == 6 || len == 12) - if (!conv(&tod.second,&tp, 59)) return 0; - if (!conv(&tod.minute,&tp, 59)) return 0; - if (!conv(&tod.hour,&tp, 23)) return 0; - if (len == 12 || len == 10) { - if (!conv(&tod.year,&tp, 99)) return 0; - tod.year+=1900; - if (tod.year