]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
centralize TTY header goop in ntp_tty.h.
authorDave Hart <hart@ntp.org>
Sat, 4 Dec 2010 07:42:26 +0000 (07:42 +0000)
committerDave Hart <hart@ntp.org>
Sat, 4 Dec 2010 07:42:26 +0000 (07:42 +0000)
move clockstuff utils closer to building cleanly.

bk: 4cf9f0e2FtwusOQa4TZq-SuxRRWJdA

clockstuff/Makefile.am
clockstuff/clktest-opts.def
clockstuff/clktest.c
include/ntp_machine.h
include/ntp_refclock.h
include/ntp_tty.h
libntp/icom.c
ntpd/refclock_datum.c

index 9bf6fd8ad562f0ec0983a20878077177006ef3c5..6b244beb76ae7f4d9e1f1b49371eab86e8ce8a41 100644 (file)
@@ -2,9 +2,9 @@ AUTOMAKE_OPTIONS =
 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
index 2960f0f181516949588b6aec83ebc54993fad9aa..68dc47ff0e7135e3fa2dfdc4d14634ab5c2acd5e 100644 (file)
@@ -18,38 +18,6 @@ detail = <<- _EODetail_
 
 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;
index a97884fb247d8b8467a5a3429d3869c409aae0c5..5bd6ae0d900e61c19051e0b10a6d0b253a6426d0 100644 (file)
@@ -7,6 +7,40 @@
 #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)
index ad4b5860bb6ce23ea3ae6011df8faa3563905479..1346b09f5ed0373a7695bdfc17dd93c233b9717e 100644 (file)
@@ -329,44 +329,9 @@ extern char *strdup(const char *);
 #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 */
index e6bc11fecdee2751b69d8cb742821e391abcc6e6..ec1756ff07a6cf35896bf32d624716d08aa56f8c 100644 (file)
@@ -5,44 +5,14 @@
 #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); \
index 9833119238f4ea96f79d3e83d299766cc3b5abfa..8280063896c0be04f93451b08af42b30b0187166 100644 (file)
@@ -1,10 +1,31 @@
 /*
  * 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 */
index f45a591fedd986daa130b76994cde00e5a77728c..881ca6707f1fd3ccefb6d343ade6fd3f756e7093 100644 (file)
@@ -87,10 +87,10 @@ doublefreq(                 /* returns void */
        )
 {
        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 != ' ') {
@@ -98,13 +98,13 @@ doublefreq(                 /* returns void */
                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
index 743bfb0c124edf3fe7dd278f97283dfc008e6636..68804bf69efcc7ba0ecac29a37e4d6d8fc5150da 100644 (file)
@@ -19,6 +19,7 @@
 
 #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)