Annotation of 43BSDTahoe/new/notes/src/gdate.c, revision 1.1

1.1     ! root        1: #include       "parms.h"
        !             2: #include       "structs.h"
        !             3: 
        !             4: #ifdef RCSIDENT
        !             5: static char rcsid[] = "$Header: gdate.c,v 1.7.0.1 85/09/09 18:32:11 notes Rel $";
        !             6: #endif RCSIDENT
        !             7: 
        !             8: 
        !             9: /*
        !            10:  * this gdate routine reads a "search date" from the keyboard.  This date
        !            11:  * must be of the form mm/dd or mm/dd/yy (number of digits in each is
        !            12:  * irrelevant).  it sets the date parameter correctly to the input or
        !            13:  * returns -1 to indicate failure to complete a date (i.e., a return alone
        !            14:  * was entered on a line).  If the date is invalid, it must be retyped.
        !            15:  * I know it is unfortunate that we can't have a plato arrow type judging
        !            16:  * system here.  I just don't want to go to all the hassle of making one now.
        !            17:  * perhaps this is an area of improvement for this program.  RK  11/10/80.
        !            18:  *
        !            19:  *     Rewritten to use the parsetime() routine which understands
        !            20:  *     about converting ASCII time specifications into a UNIX
        !            21:  *     Internal time.  
        !            22:  *             -- Ray Essick, March 1984
        !            23:  *
        !            24:  */
        !            25: 
        !            26: #define        TIMELEN 40                                      /* longest time spec */
        !            27: 
        !            28: gdate (date) struct when_f *date;
        !            29: {
        !            30:     char    datin[TIMELEN + 1],
        !            31:             fmt[DATELEN];
        !            32:     register int    i,
        !            33:                     pass;
        !            34:     struct when_f   tmpdate;                           /* hold it */
        !            35: 
        !            36:     pass = 0;
        !            37:     while (1)
        !            38:     {
        !            39:        sprdate (date, fmt);                            /* current setting */
        !            40:        at (0, PROMPTMSGX);
        !            41:        printf ("Set to read notes since: %-*s", DATELEN, fmt);
        !            42:        at (-1, 10);
        !            43:        printf ("New Date > %*s", TIMELEN, " ");
        !            44:        at (-1, 21);
        !            45:        for (i = 0; i < TIMELEN; i++)
        !            46:            datin[i] = ' ';
        !            47:        if (gline (datin, TIMELEN) == 1)
        !            48:        {                                               /* empty line */
        !            49:            at (-1, 10);
        !            50:            printf ("%*s", 23 + TIMELEN, " ");          /* space padding */
        !            51:            if (pass)
        !            52:                return 0;                               /* ok */
        !            53:            else
        !            54:                return (-1);                            /* 1st pass return */
        !            55:        }
        !            56:        switch (parsetime (datin, &tmpdate))            /* parsed? */
        !            57:        {
        !            58:            case 0:                                     /* worked */
        !            59:                *date = tmpdate;                        /* transfer it */
        !            60:                pass++;                                 /* count passes */
        !            61:                break;
        !            62: 
        !            63:            default:                                    /* failures */
        !            64:                putc ('\07', stdout);                   /* bark at him */
        !            65:                break;
        !            66:        }
        !            67: 
        !            68:     }
        !            69: /*     yes, we know about the fact that this statement is unreachable! */
        !            70:     return 0;                                          /* never executed */
        !            71: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.