Changeset 5fef523 in rtems for cpukit/libmisc/shell


Ignore:
Timestamp:
May 25, 2001, 5:52:03 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
d024ab6a
Parents:
88249fa0
Message:

2001-05-25 Joel Sherrill <joel@…>

  • shell/cmds.c: Removed code from inappropriate source.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/shell/cmds.c

    r88249fa0 r5fef523  
    1111 * at my call procedure
    1212 *
    13  * MINIX date.c is adapted to run here. Like a exercise only....
    14  *
    1513 * TODO: A lot of improvements of course.
    1614 *      cp, mv, ...
     
    386384}
    387385/*-----------------------------------------------------------*/         
    388 /* date - print or set time and date            Author: Jan Looyen */
    389 /* MINIX 1.5 GPL'ed */
    390 
    391 
    392 #define MIN     60L             /* # seconds in a minute */
    393 #define HOUR    (60 * MIN)      /* # seconds in an hour */
    394 #define DAY     (24 * HOUR)     /* # seconds in a day */
    395 #define YEAR    (365 * DAY)     /* # seconds in a year */
    396 
    397 static int conv(unsigned32 *value,char **ptr,unsigned32 max)
    398 {
    399   int buf;
    400   *ptr -= 2;
    401   buf = atoi(*ptr);
    402   **ptr = 0;
    403   if (buf < 0 || buf > max) {
    404    fprintf(stderr, "Date: bad conversion\n");
    405    return 0;
    406   };
    407   *value=buf;
    408   return 1;
    409 }
     386/* date - print or set time and date */
    410387
    411388static int set_time(char *t)
     
    413390  rtems_time_of_day tod;       
    414391  FILE * rtc;
    415   char *tp;
    416392  int len;
    417   if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod)!=RTEMS_SUCCESSFUL)
    418           memset(&tod,0,sizeof(tod));
    419   len = strlen(t);
    420   if (len != 12 && len != 10 && len != 6 && len != 4) return 0;
    421   tp = t;
    422   while (*tp)
    423    if (!isdigit(*tp++)) {
    424     fprintf(stderr, "date: bad conversion\n");
    425     return 0;
    426    };
    427   if (len == 6 || len == 12)
    428    if (!conv(&tod.second,&tp, 59)) return 0;
    429   if (!conv(&tod.minute,&tp, 59)) return 0;
    430   if (!conv(&tod.hour,&tp, 23)) return 0;
    431   if (len == 12 || len == 10) {
    432    if (!conv(&tod.year,&tp, 99)) return 0;
    433    tod.year+=1900;
    434    if (tod.year<TOD_BASE_YEAR) tod.year+=100;
    435    if (!conv(&tod.day   ,&tp, 31)) return 0;
    436    if (!conv(&tod.month ,&tp, 12)) return 0;
    437   }
     393
     394  if ( rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod) != RTEMS_SUCCESSFUL )
     395     memset( &tod, 0, sizeof(tod) );
     396
     397  /* JRS
     398   *
     399   *  This code that was used to parse the command line was taken
     400   *  from an inappropriate source.  It has been removed and needs
     401   *  to be replaced.
     402   */
     403
    438404  if (!_TOD_Validate(&tod)) {
    439405    fprintf(stderr, "Invalid date value\n");
     
    453419{
    454420  time_t t;
    455   if (argc == 2) set_time(argv[1]);
     421  if (argc == 2)
     422    set_time(argv[1]);
    456423  time(&t);
    457424  printf("%s", ctime(&t));
Note: See TracChangeset for help on using the changeset viewer.