home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* This module was written by Bob Hartman */
- /* with some hacking done by Vince Perriello */
- /* */
- /* */
- /* BinkleyTerm timer routines */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- /*
-
- This file contains routines to implement a simple multiple
- alarm system. The routines allow setting any number of alarms,
- and then checking if any one of them has expired. It also allows
- adding time to an alarm.
- */
-
-
- /*
- * $Log$
- */
-
-
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h"
- #include "timer.h"
-
- /*
- long timerset (t)
- unsigned int t;
-
- This routine returns a timer variable based on the MS-DOS
- time. The variable returned is a long which corresponds to
- the MS-DOS time at which the timer will expire. The variable
- need never be used once set, but to find if the timer has in
- fact expired, it will be necessary to call the timeup function.
- The expire time 't' is in hundredths of a second.
-
- Note: This routine as coded had a granularity of one week. I
- have put the code that implements that inside the flag
- "HIGH_OVERHEAD". If you want it, go ahead and use it. For
- BT's purposes, (minute) granularity should suffice.
-
- */
- long timerset (t)
- unsigned int t;
- {
- long l;
-
- #ifdef HIGH_OVERHEAD
- int l2;
-
- #endif
- int hours, mins, secs, ths;
-
- #ifdef HIGH_OVERHEAD
- extern int week_day ();
-
- #endif
-
- /* Get the DOS time and day of week */
- dostime (&hours, &mins, &secs, &ths);
-
- #ifdef HIGH_OVERHEAD
- l2 = week_day ();
- #endif
-
- /* Figure out the hundredths of a second so far this week */
- l =
-
- #ifdef HIGH_OVERHEAD
- l2 * PER_DAY +
- (hours % 24) * PER_HOUR +
- #endif
- (mins % 60) * PER_MINUTE +
- (secs % 60) * PER_SECOND +
- ths;
-
- /* Add in the timer value */
- l += t;
-
- /* Return the alarm off time */
- return (l);
- }
-
- /*
- int timeup (t)
- long t;
-
- This routine returns a 1 if the passed timer variable corresponds
- to a timer which has expired, or 0 otherwise.
- */
- int timeup (t)
- long t;
- {
- long l;
-
- /* Get current time in hundredths */
- l = timerset (0);
-
- /* If current is less then set by more than max int, then adjust */
- if (l < (t - 65536L))
- {
- #ifdef HIGH_OVERHEAD
- l += PER_WEEK;
- #else
- l += PER_HOUR;
- #endif
- }
-
- /* Return whether the current is greater than the timer variable */
- return ((l - t) >= 0L);
- }
-
-
- /*
- long addtime (t1, t2)
- long t1;
- unsigned int t2;
-
- This routine adds t2 hundredths of a second to the timer variable
- in t1. It returns a new timer variable.
-
- Not needed in BinkleyTerm, commented out.
-
- long addtime (t1, t2)
- long t1;
- unsigned int t2;
- {
- return (t1 + t2);
- }
- */
-