move clockstuff utils closer to building cleanly.
bk: 4cf9f0e2FtwusOQa4TZq-SuxRRWJdA
noinst_PROGRAMS = @PROPDELAY@ @CHUTEST@ @CLKTEST@
EXTRA_PROGRAMS = propdelay chutest clktest
-BUILT_SOURCES = clktest-opts.c clktest-opts.h
+BUILT_SOURCES = $(srcdir)/clktest-opts.c $(srcdir)/clktest-opts.h
-clktest_SOURCES = clktest.c clktest-opts.c clktest-opts.h
+clktest_SOURCES = clktest.c clktest-opts.c
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include
INCLUDES += -I$(top_srcdir)/lib/isc/nothreads/include
test-main;
-export = <<- _EOExport_
- #include <stdio.h>
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <signal.h>
- #include <netinet/in.h>
- #include <sys/ioctl.h>
- #include <sys/time.h>
- #include <sys/file.h>
- #include <sgtty.h>
-
- #include "../include/ntp_fp.h"
- #include "../include/ntp.h"
- #include "../include/ntp_unixtime.h"
-
- #ifdef CLKLDISC
- # define DEFMAGIC '\r'
- #endif
-
- #ifdef CLKLDISC
- # ifdef STREAM
- # include <stropts.h>
- # ifdef HAVE_SYS_CLKDEFS_H
- # include <sys/clkdefs.h>
- # endif
- # undef DEFMAGIC
- # define DEFMAGIC "\r"
- # endif
- #endif
- _EOExport_;
-
#ifdef CLKLDISC
flag = {
name = magic2;
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <signal.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#ifdef HAVE_SGTTY_H
+#include <sgtty.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef CLKLDISC
+# define DEFMAGIC '\r'
+#endif
+
+#ifdef CLKLDISC
+# ifdef STREAM
+# include <stropts.h>
+# ifdef HAVE_SYS_CLKDEFS_H
+# include <sys/clkdefs.h>
+# endif
+# undef DEFMAGIC
+# define DEFMAGIC "\r"
+# endif
+#endif
+
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_unixtime.h"
#include "clktest-opts.h"
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
#include "ERROR: You must define one of the HAVE_xx_NICE defines!"
#endif
-/*
- * use only one tty model - no use in initialising
- * a tty in three ways
- * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
- */
-
-#ifdef HAVE_TERMIOS_H
-# define HAVE_TERMIOS
-#else
-# ifdef HAVE_TERMIO_H
-# define HAVE_SYSV_TTYS
-# else
-# ifdef HAVE_SGTTY_H
-# define HAVE_BSD_TTYS
-# endif
-# endif
-#endif
-
-#ifdef HAVE_TERMIOS
-# undef HAVE_BSD_TTYS
-# undef HAVE_SYSV_TTYS
-#endif
-
#ifndef HAVE_TIMEGM
extern time_t timegm (struct tm *);
#endif
-#ifdef HAVE_SYSV_TTYS
-# undef HAVE_BSD_TTYS
-#endif
-
-#if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
-# if !defined(HAVE_SYSV_TTYS) \
- && !defined(HAVE_BSD_TTYS) \
- && !defined(HAVE_TERMIOS)
-#include "ERROR: no tty type defined!"
-# endif
-#endif /* !SYS_WINNT && !VMS && !SYS_VXWORKS*/
-
#endif /* NTP_MACHINE_H */
#ifndef NTP_REFCLOCK_H
#define NTP_REFCLOCK_H
-#include "ntp_types.h"
-
-#if defined(HAVE_BSD_TTYS)
-#include <sgtty.h>
-#endif /* HAVE_BSD_TTYS */
-
-#if defined(HAVE_SYSV_TTYS)
-#include <termio.h>
-#endif /* HAVE_SYSV_TTYS */
-
-#if defined(HAVE_TERMIOS)
-# ifdef TERMIOS_NEEDS__SVID3
-# define _SVID3
-# endif
-# include <termios.h>
-# ifdef TERMIOS_NEEDS__SVID3
-# undef _SVID3
-# endif
-#endif
-
#if defined(HAVE_SYS_MODEM_H)
#include <sys/modem.h>
#endif
-#if 0 /* If you need that, include ntp_io.h instead */
-#if defined(STREAM)
-#include <stropts.h>
-#if defined(CLK) /* This is never defined, except perhaps by a system header file */
-#include <sys/clkdefs.h>
-#endif /* CLK */
-#endif /* STREAM */
-#endif
-
+#include "ntp_types.h"
+#include "ntp_tty.h"
#include "recvbuff.h"
-#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
-#define BSD_TTYS
-#endif /* SYSV_TTYS STREAM BSD_TTYS */
#define SAMPLE(x) pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \
pp->filter[pp->coderecv] = (x); \
/*
* ntp_tty.h - header file for serial lines handling
*/
-
#ifndef NTP_TTY_H
#define NTP_TTY_H
+/*
+ * use only one tty model - no use in initialising
+ * a tty in three ways
+ * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
+ */
+
+#if defined(HAVE_TERMIOS_H) || defined(HAVE_SYS_TERMIOS_H)
+# define HAVE_TERMIOS
+#elif defined(HAVE_TERMIO_H)
+# define HAVE_SYSV_TTYS
+#elif defined(HAVE_SGTTY_H)
+# define HAVE_BSD_TTYS
+#endif
+
+#if !defined(VMS) && !defined(SYS_VXWORKS)
+# if !defined(HAVE_SYSV_TTYS) \
+ && !defined(HAVE_BSD_TTYS) \
+ && !defined(HAVE_TERMIOS)
+#include "ERROR: no tty type defined!"
+# endif
+#endif /* !VMS && !SYS_VXWORKS*/
+
#if defined(HAVE_BSD_TTYS)
#include <sgtty.h>
#define TTY struct sgttyb
#endif /* HAVE_SYSV_TTYS */
#if defined(HAVE_TERMIOS)
-# ifdef TERMIOS_NEEDS__SVID3
-# define _SVID3
-# endif
-# include <termios.h>
-# ifdef TERMIOS_NEEDS__SVID3
-# undef _SVID3
+# if defined(HAVE_TERMIOS_H)
+# ifdef TERMIOS_NEEDS__SVID3
+# define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+# undef _SVID3
+# endif
+# elif defined(HAVE_SYS_TERMIOS_H)
+# include <sys/termios.h>
# endif
-#define TTY struct termios
+# define TTY struct termios
#endif
#if defined(HAVE_SYS_MODEM_H)
#include <sys/modem.h>
#endif
-#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
-#define BSD_TTYS
-#endif /* SYSV_TTYS STREAM BSD_TTYS */
+/*
+ * Line discipline flags. These require line discipline or streams
+ * modules to be installed/loaded in the kernel. If specified, but not
+ * installed, the code runs as if unspecified.
+ */
+#define LDISC_STD 0x00 /* standard */
+#define LDISC_CLK 0x01 /* tty_clk \n intercept */
+#define LDISC_CLKPPS 0x02 /* tty_clk \377 intercept */
+#define LDISC_ACTS 0x04 /* tty_clk #* intercept */
+#define LDISC_CHU 0x08 /* depredated */
+#define LDISC_PPS 0x10 /* ppsclock, ppsapi */
+#define LDISC_RAW 0x20 /* raw binary */
+#define LDISC_ECHO 0x40 /* enable echo */
+#define LDISC_REMOTE 0x80 /* remote mode */
+#define LDISC_7O1 0x100 /* 7-bit, odd parity for Z3801A */
+
+/* function prototypes for ntp_tty.c */
+#if !defined(SYS_VXWORKS) && !defined(SYS_WINNT)
+# if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || \
+ defined(HAVE_BSD_TTYS)
+extern int ntp_tty_setup(int, u_int, u_int);
+extern int ntp_tty_ioctl(int, u_int);
+# endif
+#endif
#endif /* NTP_TTY_H */
)
{
int i;
- char s1[11];
+ char s1[16];
char *y;
- sprintf(s1, " %10.0f", freq);
+ snprintf(s1, sizeof(s1), " %10.0f", freq);
y = s1 + 10;
i = 0;
while (*y != ' ') {
x[i] = x[i] | ((*y-- & 0x0f) << 4);
i++;
}
- for (; i < len; i++)
+ for ( ; i < len; i++)
x[i] = 0;
x[i] = FI;
}
/*
- * icom_open() - open and initialize serial interface
+ * icom_init() - open and initialize serial interface
*
* This routine opens the serial interface for raw transmission; that
* is, character-at-a-time, no stripping, checking or monkeying with the
#include "ntpd.h"
#include "ntp_io.h"
+#include "ntp_tty.h"
#include "ntp_refclock.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
#include <stdio.h>
#include <ctype.h>
-#if defined(HAVE_BSD_TTYS)
-#include <sgtty.h>
-#endif /* HAVE_BSD_TTYS */
-
-#if defined(HAVE_SYSV_TTYS)
-#include <termio.h>
-#endif /* HAVE_SYSV_TTYS */
-
-#if defined(HAVE_TERMIOS)
-#include <termios.h>
-#endif
#if defined(STREAM)
#include <stropts.h>
#if defined(WWVBCLK)