Annotation of coherent/g/usr/lib/uucp/tay104/time.c, revision 1.1

1.1     ! root        1: /* time.c
        !             2:    Routines to deal with UUCP time spans.
        !             3: 
        !             4:    Copyright (C) 1991, 1992 Ian Lance Taylor
        !             5: 
        !             6:    This file is part of the Taylor UUCP package.
        !             7: 
        !             8:    This program is free software; you can redistribute it and/or
        !             9:    modify it under the terms of the GNU General Public License as
        !            10:    published by the Free Software Foundation; either version 2 of the
        !            11:    License, or (at your option) any later version.
        !            12: 
        !            13:    This program is distributed in the hope that it will be useful, but
        !            14:    WITHOUT ANY WARRANTY; without even the implied warranty of
        !            15:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            16:    General Public License for more details.
        !            17: 
        !            18:    You should have received a copy of the GNU General Public License
        !            19:    along with this program; if not, write to the Free Software
        !            20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            21: 
        !            22:    The author of the program may be contacted at [email protected] or
        !            23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
        !            24:    */
        !            25: 
        !            26: #include "uucp.h"
        !            27: 
        !            28: #if USE_RCS_ID
        !            29: const char time_rcsid[] = "$Id: time.c,v 1.1 93/07/30 07:54:18 bin Exp Locker: bin $";
        !            30: #endif
        !            31: 
        !            32: #include <ctype.h>
        !            33: 
        !            34: #if HAVE_TIME_H
        !            35: #include <time.h>
        !            36: #endif
        !            37: 
        !            38: #include "uudefs.h"
        !            39: #include "uuconf.h"
        !            40: 
        !            41: /* External functions.  */
        !            42: #ifndef time
        !            43: extern time_t time ();
        !            44: #endif
        !            45: #ifndef localtime
        !            46: extern struct tm *localtime ();
        !            47: #endif
        !            48: 
        !            49: /* See if the current time matches a time span.  If it does, return
        !            50:    TRUE, set *pival to the value for the matching span, and set
        !            51:    *pcretry to the retry for the matching span.  Otherwise return
        !            52:    FALSE.  */
        !            53: 
        !            54: boolean
        !            55: ftimespan_match (qspan, pival, pcretry)
        !            56:      const struct uuconf_timespan *qspan;
        !            57:      long *pival;
        !            58:      int *pcretry;
        !            59: {
        !            60:   time_t inow;
        !            61:   struct tm *qtm;
        !            62:   int itm;
        !            63:   const struct uuconf_timespan *q;
        !            64: 
        !            65:   if (qspan == NULL)
        !            66:     return FALSE;
        !            67: 
        !            68:   time (&inow);
        !            69:   qtm = localtime (&inow);
        !            70: 
        !            71:   /* Get the number of minutes since Sunday for the time.  */
        !            72:   itm = qtm->tm_wday * 24 * 60 + qtm->tm_hour * 60 + qtm->tm_min;
        !            73: 
        !            74:   for (q = qspan; q != NULL; q = q->uuconf_qnext)
        !            75:     {
        !            76:       if (q->uuconf_istart <= itm && itm <= q->uuconf_iend)
        !            77:        {
        !            78:          if (pival != NULL)
        !            79:            *pival = q->uuconf_ival;
        !            80:          if (pcretry != NULL)
        !            81:            *pcretry = q->uuconf_cretry;
        !            82:          return TRUE;
        !            83:        }
        !            84:     }
        !            85: 
        !            86:   return FALSE;
        !            87: }
        !            88: 
        !            89: /* Determine the maximum size that may ever be transferred, according
        !            90:    to a timesize span.  This returns -1 if there is no limit.  */
        !            91: 
        !            92: long
        !            93: cmax_size_ever (qtimesize)
        !            94:      const struct uuconf_timespan *qtimesize;
        !            95: {
        !            96:   long imax;
        !            97:   const struct uuconf_timespan *q;
        !            98: 
        !            99:   if (qtimesize == NULL)
        !           100:     return -1;
        !           101: 
        !           102:   /* Look through the list of spans.  If there is any gap larger than
        !           103:      1 hour, we assume there are no restrictions.  Otherwise we keep
        !           104:      track of the largest value we see.  I picked 1 hour arbitrarily,
        !           105:      on the theory that a 1 hour span to transfer large files might
        !           106:      actually occur, and is probably not an accident.  */
        !           107:   if (qtimesize->uuconf_istart >= 60)
        !           108:     return -1;
        !           109: 
        !           110:   imax = -1;
        !           111: 
        !           112:   for (q = qtimesize; q != NULL; q = q->uuconf_qnext)
        !           113:     {
        !           114:       if (q->uuconf_qnext == NULL)
        !           115:        {
        !           116:          if (q->uuconf_iend <= 6 * 24 * 60 + 23 * 60)
        !           117:            return -1;
        !           118:        }
        !           119:       else
        !           120:        {
        !           121:          if (q->uuconf_iend + 60 <= q->uuconf_qnext->uuconf_istart)
        !           122:            return -1;
        !           123:        }
        !           124: 
        !           125:       if (imax < q->uuconf_ival)
        !           126:        imax = q->uuconf_ival;
        !           127:     }
        !           128: 
        !           129:   return imax;
        !           130: }

unix.superglobalmegacorp.com

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