home *** CD-ROM | disk | FTP | other *** search
- NAVYTIME -- Get Date/Time from Naval Observatory Page 1
-
-
- Copyright 1987 Michael M Rubenstein
-
- This software may be freely distributed as long as no fee is
- assessed and the copyright notice is retained.
-
- The functions contained in COMM.C, TIMER.C, ATFINISH.C, and
- SETTZ.C may be distributed as part of an executable program
- (even if a fee is charged) provided the following copyright
- notice is included:
-
- Portions copyright 1987 Michael M Rubenstein
-
-
- Changes in Version 1.1.
-
- - The interrupt service routine for the timer has been
- rewritten to reduce the stack space required. The
- modification is based on a routine by Don Corbitt.
-
- - The RS232 interface is cleared after dialing. This
- prevents old messages from aborting the transfer.
-
- - Defines for TRUE and FALSE have been inserted so the
- standard Turbo C include files may be used (the original
- required my modified STDIO.H.
-
- - The file BUILTINS.MAK is now included. This is required
- for the makefile to work.
-
- - The documentation now mentions that getopt (distributed
- with Turbo C in source form only) is required and
- discusses the implications (the compiled version uses a
- private version of getopt which does not respect the
- switch character as does the one in the Turbo C
- distribution.
-
-
- Description.
-
- NAVYTIME calls the 1200 baud Naval Observatory time service for
- digital clocks at (202) 653-0351 and sets the system time.
- Because of delays in the phone system, the time may be off by as
- much as .5 second.
-
-
- Installation.
-
- Before using NAVYTIME certain things have to be set up. The
- program must know the time zone and whether daylight savings time
- is used. This is done by setting an environment variable TZ with
- the command
-
- set TZ=xxxnyyy
-
- where xxx and yyy are any letters and n is the number of hours
- NAVYTIME -- Get Date/Time from Naval Observatory Page 2
-
-
- behind Greenwich Mean time for standard time. If yyy is omitted,
- the NAVYTIME assumes that daylight savings time is NOT used. xxx
- and yyy are intended to be the abbreviation for the time used
- (xxx for standard time, yyy for daylight savings time).
-
- For example, if the area you are in uses Eastern Standard/Eastern
- Daylight time, the command would be
-
- set TZ=EST5DST
-
- (Eastern Standard is 5 hours behind GMT). If Eastern Standard is
- used throughout the year, the command would be
-
- set TZ=EST5
-
- Note that the number of hours behind GMT may be more than one
- digit (in the Pacific) or may be negative (in most of Europe,
- Africa, and Asia). The program, however, determines if Daylight
- savings time is in effect based on the United States conventions.
-
- It will also be necessary to modify the the configuration file,
- NAVYTIME.RC. Users not in the Washington DC local calling area
- will have to change the phone number on the second line to
- include the area code. If your modem is not on COM1 or is not
- compatible with the Hayes 1200, other changes will be required.
-
- The configuration file has a rather inflexible format. Each line
- has a specific meaning. It is important that there be no spaces
- at the ends of lines. The lines have the following meanings
-
- Line Meaning
- ---- -------------------------------------------------
- 1 The COM port to use. Only 1 and 2 are supported.
-
- 2 The command to initialize the modem and dial. It
- consists of any combination of the following
-
- - Strings in quotes which are sent to the
- modem verbatim.
-
- - Pairs of the form ^x where x is any
- printing character which results in the
- control character corresponding to x to be
- sent. For example, to send a carriage
- return, include the pair
-
- ^m
-
- - Integers which specify a delay in tenths of
- a second. To pause one second include the
- integer 10. Numbers larger than 3600 (if
- your modem needs a delay any where close to
- that, you have my deepest sympathy) will
- not work properly.
- NAVYTIME -- Get Date/Time from Naval Observatory Page 3
-
-
- - Any other characters, typically spaces,
- which are ignored.
-
- 3 The command to send to terminate a call. This
- line may be empty if the modem is configured to
- disconnect when DTR is dropped.
-
- 4 The string to match to recognize establishment of
- a connection. The modem must send a connection
- message terminated by a carriage return or line
- feed. A message containing this string in any
- position (for example, NNEC will match CONNECT)
- will be taken as indicating that the connection is
- complete. Upper and lower case letters are
- considered different.
-
- 4-19 Up to 15 strings to match to recognize failure to
- make a connection. These are matched in the same
- way as the connect string.
-
- An alternate configuration file for the Racal Vadic 2400V (and
- possibly other Racal Vadic) modems is included as NAVYTIME.RV.
-
- Finally, it is necessary to inform the program where the
- configuration file will be found. Normally, it assumes that the
- configuration file will be C:\ETC\NAVYTIME.RC. If this is not
- convenient, set the environment variable NAVYTIME to the full
- name of the configuration file. For example, if the file will be
- D:\CONFIG\NAVYTIME.CFG, use the command
-
- set NAVYTIME=d:\config\navytime.cfg
-
-
-
- Using NAVYTIME.
-
- If invoked with no parameters, NAVYTIME will call the time
- service and set the DOS time, displaying no messages if
- successful. If the command line parameter -v is given, the time
- will be displayed. If the parameter -vv is given, modem messages
- will also be displayed.
-
- NAVYTIME does not set a battery backed up clock unless this is
- done by MSDOS when the DOS time is set. To set a battery backed
- up clock, invoke NAVYTIME with a batch file includes a command to
- set the battery clock from the MSDOS time.
-
-
-
- For the Hacker.
-
- NAVYTIME is written in Turbo C. Since one of the reasons for
- writing this program was to evaluate Turbo C, no attempt was made
- to keep compatibility with other versions of C. Most other C
- compilers will have difficulty with the prototype declarations
- NAVYTIME -- Get Date/Time from Naval Observatory Page 4
-
-
- and the inline assembly code of comm.c.
-
- The function getopt is used. This function is included with
- Turbo C in source form only. If generating NAVYTIME.EXE, this
- function must be included in CS.LIB or the makefile must be
- modified to compile and link getopt.obj.
-
- Four files, COMM.C, TIMER.C, ATFINISH.C, and SETTZ.C will be of
- general interest to Turbo C programmers.
-
- COMM.C implements simple interrupt driven output, polled input to
- COM1 and COM2. The main limitations are no checking for parity
- or other errors and flow control is not implemented.
-
- TIMER.C is a simple stopwatch timer. Because of MSDOS
- limitations, timer completion must be polled with chk_timer().
-
- ATFINISH is similar to the library function ATEXIT except that
- the registered function will always be executed when the program
- terminates (ATEXIT functions are executed only on normal
- termination). Up to 8 functions may be registered.
-
- SETTZ sets the time zone from information in the DOS environment.
-
- These functions may be used for both free and commercial
- distribution provided my copyright notice is included.
- Commercial distributions may not include source or relocatables.