2
* /src/NTP/ntp-4/parseutil/dcfd.c,v 4.9 1999/02/28 13:06:27 kardel RELEASE_19990228_A
2
* /src/NTP/REPOSITORY/ntp4-dev/parseutil/dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
4
* dcfd.c,v 4.9 1999/02/28 13:06:27 kardel RELEASE_19990228_A
4
* dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
6
6
* DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
14
14
* Leap second handling (at that level you should switch to NTP Version 4 - really!)
16
* Copyright (C) 1995-1999 by Frank Kardel <kardel@acm.org>
17
* Copyright (C) 1993-1994 by Frank Kardel
18
* Friedrich-Alexander Universit�t Erlangen-N�rnberg, Germany
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24
* This program may not be sold or used for profit without prior
25
* written consent of the author.
16
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
17
* Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universit�t Erlangen-N�rnberg, Germany
19
* Redistribution and use in source and binary forms, with or without
20
* modification, are permitted provided that the following conditions
22
* 1. Redistributions of source code must retain the above copyright
23
* notice, this list of conditions and the following disclaimer.
24
* 2. Redistributions in binary form must reproduce the above copyright
25
* notice, this list of conditions and the following disclaimer in the
26
* documentation and/or other materials provided with the distribution.
27
* 3. Neither the name of the author nor the names of its contributors
28
* may be used to endorse or promote products derived from this software
29
* without specific prior written permission.
31
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
32
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
35
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
45
#ifdef HAVE_CONFIG_H
29
46
# include <config.h>
49
#include <sys/ioctl.h>
32
50
#include <unistd.h>
1549
1569
memset(term.c_cc, 0, sizeof(term.c_cc));
1550
1570
term.c_cc[VMIN] = 1;
1551
1571
#ifdef NO_PARENB_IGNPAR
1552
term.c_cflag = B50|CS8|CREAD|CLOCAL;
1572
term.c_cflag = CS8|CREAD|CLOCAL;
1554
term.c_cflag = B50|CS8|CREAD|CLOCAL|PARENB;
1574
term.c_cflag = CS8|CREAD|CLOCAL|PARENB;
1556
1576
term.c_iflag = IGNPAR;
1557
1577
term.c_oflag = 0;
1558
1578
term.c_lflag = 0;
1580
cfsetispeed(&term, B50);
1581
cfsetospeed(&term, B50);
1560
1583
if (TTY_SETATTR(fd, &term) == -1)
1562
1585
perror("tcsetattr");
1582
1605
* setup periodic operations (state control / frequency control)
1588
vec.sv_handler = tick;
1592
if (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1)
1594
syslog(LOG_ERR, "sigvec(SIGALRM): %m");
1599
1607
#ifdef HAVE_SIGACTION
1601
1609
struct sigaction act;
1603
act.sa_handler = tick;
1604
1611
# ifdef HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION
1605
1612
act.sa_sigaction = (void (*) P((int, siginfo_t *, void *)))0;
1606
1613
# endif /* HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION */
1614
act.sa_handler = tick;
1607
1615
sigemptyset(&act.sa_mask);
1608
1616
act.sa_flags = 0;
1881
* Revision 4.18 2005/10/07 22:08:18 kardel
1882
* make dcfd.c compile on NetBSD 3.99.9 again (configure/sigvec compatibility fix)
1884
* Revision 4.17.2.1 2005/10/03 19:15:16 kardel
1885
* work around configure not detecting a missing sigvec compatibility
1886
* interface on NetBSD 3.99.9 and above
1888
* Revision 4.17 2005/08/10 10:09:44 kardel
1889
* output revision information
1891
* Revision 4.16 2005/08/10 06:33:25 kardel
1894
* Revision 4.15 2005/08/10 06:28:45 kardel
1895
* fix setting of baud rate
1897
* Revision 4.14 2005/04/16 17:32:10 kardel
1900
* Revision 4.13 2004/11/14 15:29:41 kardel
1901
* support PPSAPI, upgrade Copyright to Berkeley style