]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Remove remaining sprintf() calls except refclock_ripencc.c (which is
authorDave Hart <hart@ntp.org>
Tue, 12 Apr 2011 06:01:57 +0000 (06:01 +0000)
committerDave Hart <hart@ntp.org>
Tue, 12 Apr 2011 06:01:57 +0000 (06:01 +0000)
  kept out of --enable-all-clocks as a result), upstream libs which use
  sprintf() ony after careful buffer sizing, and ntp_proto.c.

bk: 4da3ead5DcGKUDh099LhXtKjhFj3Rw

26 files changed:
ChangeLog
configure.ac
include/Makefile.am
include/ntp_sprintf.h [deleted file]
lib/isc/inet_ntop.c
libntp/bsd_strerror.c
libntp/snprintf.c
libparse/ieee754io.c
ntpd/refclock_mx4200.c
ntpd/refclock_tpro.c
ntpd/refclock_tt560.c
ntpd/refclock_wwv.c
ntpdate/ntptimeset.c
ports/winnt/include/config.h
ports/winnt/libntp/syslog.c
ports/winnt/ntpd/hopf_PCI_io.c
ports/winnt/ntpd/refclock_trimbledc.c [deleted file]
ports/winnt/ntpd/refclock_trimbledc.h [deleted file]
ports/winnt/vs2003/libntp.vcproj
ports/winnt/vs2005/libntp.vcproj
ports/winnt/vs2008/libntp/libntp.vcproj
ports/winnt/vs2008/ntpd/ntpd.vcproj
util/audio-pcm.c
util/sht.c
util/tg.c
util/tg2.c

index 447c930097c68f800a5f2b07dbe617b8cf9ee941..4187237d7e21c9e2d237f2d729ba4a01373c418b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 * Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
 * On systems without C99-compliant (v)snprintf(), use C99-snprintf
   replacements (http://www.jhweiss.de/software/snprintf.html)
+* Remove remaining sprintf() calls except refclock_ripencc.c (which is
+  kept out of --enable-all-clocks as a result), upstream libs which use
+  sprintf() ony after careful buffer sizing, and ntp_proto.c.
 (4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1881] describe the {+,-,s} characters in configure --help output.
 (4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn@ntp.org>
index 3d28424815c76e5507c1a0f560613fda895b1476..49fa71881293693809da670861610825463cbf44 100644 (file)
@@ -895,12 +895,6 @@ case "$ac_cv_func_recvmsg" in
     esac
 esac
 
-case "$host" in
- *-*-sunos4*)
-    AC_DEFINE([SPRINTF_CHAR], [1], [*s*printf() functions are char*])
-    ;;
-esac
-
 AC_CACHE_CHECK(
     [number of arguments taken by setpgrp()],
     [ntp_cv_func_setpgrp_nargs],
index a9070b0ead1a431713d179cb73dce5e8f625de59..61efd97fbb23456e0e53dd9d7dac6e7375b0ee15 100644 (file)
@@ -49,7 +49,6 @@ noinst_HEADERS =      \
        ntp_request.h   \
        ntp_rfc2553.h   \
        ntp_select.h    \
-       ntp_sprintf.h   \
        ntp_stdlib.h    \
        ntp_string.h    \
        ntp_syscall.h   \
diff --git a/include/ntp_sprintf.h b/include/ntp_sprintf.h
deleted file mode 100644 (file)
index a456a89..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Handle ancient char* *s*printf*() systems
- */
-
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x)    strlen(sprintf/**/x)
-# define SNPRINTF(x)   strlen(snprintf/**/x)
-# define VSNPRINTF(x)  strlen(vsnprintf/**/x)
-#else
-# define SPRINTF(x)    ((size_t)sprintf x)
-# define SNPRINTF(x)   ((size_t)snprintf x)
-# define VSNPRINTF(x)  ((size_t)vsnprintf x)
-#endif
index 997bfd9bfa8ca4fbd0669827df5b41ed35cbf383..febbfb35cc1f3d22120c7cf9a7fbf65e4915d453 100644 (file)
@@ -31,8 +31,6 @@ static char rcsid[] =
 #include <isc/net.h>
 #include <isc/print.h>
 
-#include "ntp_sprintf.h"       /* NTP local change, helps SunOS 4 */
-
 #define NS_INT16SZ      2
 #define NS_IN6ADDRSZ   16
 
@@ -181,7 +179,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
                        tp += strlen(tp);
                        break;
                }
-               tp += SPRINTF((tp, "%x", words[i]));    /* NTP local change */
+               tp += sprintf(tp, "%x", words[i]);
        }
        /* Was it a trailing run of 0x00's? */
        if (best.base != -1 && (best.base + best.len) ==
index 9d8ae8e4f4830f7cbae4852213dde7456580437f..5ace9aa48542e7c815a52c4b71f453d9a8b3bdd3 100644 (file)
@@ -39,9 +39,10 @@ strerror(
        static char ebuf[20];
 
        if ((unsigned int)errnum < sys_nerr)
-               return(sys_errlist[errnum]);
-       (void)sprintf(ebuf, "Unknown error: %d", errnum);
-       return(ebuf);
+               return sys_errlist[errnum];
+       snprintf(ebuf, sizeof(ebuf), "Unknown error: %d", errnum);
+
+       return ebuf;
 }
 #else
 int strerror_bs;
index 3864ef0732496a8a4c2f3957a38d95a77dcce4de..4ea9aed667f4a56c9def1296b12af704dddb0d45 100644 (file)
  *     HW_WANT_RPL_SNPRINTF
  *     HW_WANT_RPL_VASPRINTF
  *     HW_WANT_RPL_ASPRINTF
- *     HAVE_VSNPRINTF
- *     HAVE_SNPRINTF
- *     HAVE_VASPRINTF
- *     HAVE_ASPRINTF
+ *     HAVE_VSNPRINTF  // define to 1 #if HW_WANT_RPL_VSNPRINTF
+ *     HAVE_SNPRINTF   // define to 1 #if HW_WANT_RPL_SNPRINTF
+ *     HAVE_VASPRINTF  // define to 1 #if HW_WANT_RPL_VASPRINTF
+ *     HAVE_ASPRINTF   // define to 1 #if HW_WANT_RPL_ASPRINTF
  *     HAVE_STDARG_H
  *     HAVE_STDDEF_H
  *     HAVE_STDINT_H
index 8f3175e369a7a4d7fd32a2672366d3d75ec6f78e..61bc8533b0d7c9fdc8e2a7b6a3f266b9f018f559 100644 (file)
@@ -89,14 +89,15 @@ fmt_flt(
        unsigned long ch
        )
 {
-  char *buf;
+       char *buf;
 
-  LIB_GETBUF(buf);
-  sprintf(buf, "%c %s %s %s", sign ? '-' : '+',
-         fmt_blong(ch, 11),
-         fmt_blong(mh, 20),
-         fmt_blong(ml, 32));
-  return buf;
+       LIB_GETBUF(buf);
+       snprintf(buf, LIB_BUFLENGTH, "%c %s %s %s", sign ? '-' : '+',
+                fmt_blong(ch, 11),
+                fmt_blong(mh, 20),
+                fmt_blong(ml, 32));
+
+       return buf;
 }
 
 static char *
@@ -105,15 +106,18 @@ fmt_hex(
        int length
        )
 {
-  char *buf;
-  int i;
+       char *  buf;
+       char    hex[4];
+       int     i;
+
+       LIB_GETBUF(buf);
+       buf[0] = '\0';
+       for (i = 0; i < length; i++) {
+               snprintf(hex, sizeof(hex), "%02x", bufp[i]);
+               strlcat(buf, hex, LIB_BUFLENGTH);
+       }
 
-  LIB_GETBUF(buf);
-  for (i = 0; i < length; i++)
-    {
-      sprintf(buf+i*2, "%02x", bufp[i]);
-    }
-  return buf;
+       return buf;
 }
 
 #endif
index 44b3e246339f0cc0df61fb1cd2001be44acf019c..c9422290d39a449fb5333ec8c1fa22376643207d 100644 (file)
@@ -67,8 +67,6 @@
 # include <sys/ppsclock.h>
 #endif
 
-#include "ntp_sprintf.h"
-
 #ifndef HAVE_STRUCT_PPSCLOCKEV
 struct ppsclockev {
 # ifdef HAVE_STRUCT_TIMESPEC
index 5a2255fd5f31cdec224fe9eaef569c194dfed6b1..dc5f5c004ba2b1a67a38042ccc06967755794569 100644 (file)
@@ -160,7 +160,7 @@ tpro_poll(
         * proper format, we declare bad format and exit. Note: we
         * can't use the sec/usec conversion produced by the driver,
         * since the year may be suspect. All format error checking is
-        * done by the sprintf() and sscanf() routines.
+        * done by the snprintf() and sscanf() routines.
         *
         * Note that the refclockproc usec member has now become nsec.
         * We could either multiply the read-in usec value by 1000 or
index 7aa2180e756f61d17f07be8105eee5a6447bcff8..94fdef14f24fe072176461917137612ff3859b59 100644 (file)
@@ -76,14 +76,14 @@ tt560_start(
 {
        register struct tt560unit *up;
        struct refclockproc *pp;
-       char device[20];
-       int     fd;
-        caddr_t membase;
+       char    device[20];
+       int     fd;
+       caddr_t membase;
 
        /*
         * Open TT560 device
         */
-       (void)sprintf(device, DEVICE, unit);
+       snprintf(device, sizeof(device), DEVICE, unit);
        fd = open(device, O_RDWR);
        if (fd == -1) {
                msyslog(LOG_ERR, "tt560_start: open of %s: %m", device);
@@ -195,9 +195,9 @@ tt560_poll(
         * proper format, we declare bad format and exit. Note: we
         * can't use the sec/usec conversion produced by the driver,
         * since the year may be suspect. All format error checking is
-        * done by the sprintf() and sscanf() routines.
+        * done by the snprintf() and sscanf() routines.
         */
-       sprintf(pp->a_lastcode,
+       snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
            "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
            tp->hun_day,  tp->tens_day,  tp->unit_day,
                          tp->tens_hour, tp->unit_hour,
index a2f693a0f15827298ac683a1da42222bdf097f6c..08a5754cd70469a1d488797bc309a8ee971bdc5b 100644 (file)
@@ -1569,7 +1569,7 @@ wwv_endpoc(
                }
        }
        if (pp->sloppyclockflag & CLK_FLAG4) {
-               sprintf(tbuf,
+               snprintf(tbuf, sizeof(tbuf),
                    "wwv2 %04x %5.0f %5.1f %5d %4d %4d %4d %4.0f %7.2f",
                    up->status, up->epomax, up->eposnr, mepoch,
                    up->avgint, maxrun, mcount - zcount, dtemp,
@@ -2021,7 +2021,7 @@ wwv_rsec(
        }
        if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
            DSYNC)) {
-               sprintf(tbuf,
+               snprintf(tbuf, sizeof(tbuf),
                    "wwv3 %2d %04x %3d %4d %5.0f %5.1f %5.0f %5.1f %5.0f",
                    nsec, up->status, up->gain, up->yepoch, up->epomax,
                    up->eposnr, up->datsig, up->datsnr, bit);
index 46c2f8f1d187b91113633d12a5d6ed2f11ca1f1e..fa622a973275fb1ec3987f92632765a95c398ae9 100644 (file)
@@ -4,7 +4,7 @@
  * GOAL:
  * The goal of ntptime is to set the current time on system startup
  * to the best possible time using the network very wisely. It is assumed
- * that after a resonable time has been sett then ntp daemon will
+ * that after a reasonable time has been set then ntp daemon will
  * maintain it.
  *
  * PROBLEM DOMAIN:
@@ -51,7 +51,7 @@
  * NOTE: Please do not have this program print out every minute some line,
  *       of output. If this happens and the environment is in trouble then
  *       many pages of paper on many different machines will be filled up.
- *       Save some tress in your lifetime.
+ *       Save some trees in your lifetime.
  * 
  * CONCLUSION:
  * The behavior of the program derived from these three issues should be
@@ -318,9 +318,6 @@ static      void    init_io         P((void));
 static int     sendpkt         P((struct sockaddr_in *dest, struct pkt *pkt, int len));
        void    input_handler   P((l_fp *xts));
 static void    printserver     P((register struct server *pp, FILE *fp));
-#if !defined(HAVE_VSPRINTF)
-int    vsprintf        P((char *str, const char *fmt, va_list ap));
-#endif
 
 #ifdef HAVE_SIGNALED_IO
 extern  void    wait_for_signal P((void));
@@ -592,10 +589,8 @@ ntptimesetmain(
                        exit(1);
                }
                if (!authistrusted(sys_authkey)) {
-                       char buf[10];
-
-                       (void) sprintf(buf, "%lu", (unsigned long)sys_authkey);
-                       msyslog(LOG_ERR, "authentication key %s unknown", buf);
+                       msyslog(LOG_ERR, "authentication key %lu unknown",
+                               (u_long)sys_authkey);
                        exit(1);
                }
        }
@@ -2137,23 +2132,3 @@ printserver(
        (void) fprintf(fp, "offset %s\n\n",
                           lfptoa(&pp->offset, 6));
 }
-
-#if !defined(HAVE_VSPRINTF)
-int
-vsprintf(
-       char *str,
-       const char *fmt,
-       va_list ap
-       )
-{
-       FILE f;
-       int len;
-
-       f._flag = _IOWRT+_IOSTRG;
-       f._ptr = str;
-       f._cnt = 32767;
-       len = _doprnt(fmt, ap, &f);
-       *f._ptr = 0;
-       return (len);
-}
-#endif
index b8658a88a829dbcac8423676770d83c16269c672..4ffe3ea96c1bb7c521aa270f6e3b40bd97805324 100644 (file)
@@ -262,8 +262,8 @@ typedef int socklen_t;
  * to other names
  */
 #define inline         __inline
-#define vsnprintf      _vsnprintf
-#define snprintf       _snprintf
+/* #define vsnprintf   _vsnprintf */
+/* #define snprintf    _snprintf */
 #define stricmp                _stricmp
 #define strcasecmp     _stricmp
 #define isascii                __isascii
@@ -390,6 +390,8 @@ typedef __int32 int32_t;    /* define a typedef for int32_t */
 
 #define HW_WANT_RPL_VSNPRINTF          1
 #define HW_WANT_RPL_SNPRINTF           1
+#define HAVE_VSNPRINTF                 1
+#define HAVE_SNPRINTF                  1
 
 typedef char *caddr_t;
 
index 2a2915a20107ac5e765b883f411faf49022f28e9..6b82e924ed9df267d043c95cfbb3d9bddc234f87 100644 (file)
@@ -102,7 +102,7 @@ syslog(int level, const char *fmt, ...) {
        str[0] = buf;
 
        va_start(ap, fmt);
-       vsprintf(buf, fmt, ap);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
        va_end(ap);
 
        /* Make sure that the channel is open to write the event */
index 171b7a7d43518da6950d4a688156ac31e3d77441..a1ba200f117125631f8da9034411022e2829205d 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <winioctl.h>
+
+#include "ntp_stdlib.h"
 #include "hopf_PCI_io.h"
 
 
diff --git a/ports/winnt/ntpd/refclock_trimbledc.c b/ports/winnt/ntpd/refclock_trimbledc.c
deleted file mode 100644 (file)
index c90b526..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if defined(REFCLOCK) && defined(CLOCK_TRIMBLEDC)
-
-#include "refclock_trimbledc.h"
-extern int debug;
-
-static int     trimbledc_start         (int, struct peer *);
-static void    trimbledc_shutdown      (int, struct peer *);
-static void    trimbledc_receive       (struct recvbuf *);
-static void    trimbledc_poll          (int, struct peer *);
-static void    trimbledc_io            (char, int, unsigned char *, l_fp*, struct trimbledc_unit *);
-
-
-/*
- * Transfer vector
- */
-struct refclock refclock_trimbledc = {
-       trimbledc_start,        /* start up driver */
-       trimbledc_shutdown,     /* shut down driver */
-       trimbledc_poll,         /* transmit poll message */
-       noentry,                /* not used  */
-       noentry,                /* initialize driver (not used) */
-       noentry,                /* not used */
-       NOFLAGS                 /* not used */
-};
-
-
-/*
- * trimbledc_start - open the devices and initialize data for processing
- */
-static int
-trimbledc_start (
-       int unit,
-       struct peer *peer
-       )
-{
-       register struct trimbledc_unit *up;
-       struct refclockproc *pp;
-       int fd;
-       char gpsdev[20];
-
-       struct termios tio;
-#ifdef SYS_WINNT
-       (void) sprintf(gpsdev, DEVICE, unit);
-#else
-       (void) sprintf(gpsdev, DEVICE, unit + 1);
-#endif
-       /*
-        * Open serial port. 
-        */
-       fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
-       if (fd == -1) {
-               msyslog(LOG_ERR,"Trimble (%d) start: open %s failed: %m",
-                       unit, gpsdev);
-               return 0;
-       }
-
-       msyslog(LOG_NOTICE, "Trimble (%d) fd: %d dev: %s", unit, fd, gpsdev);
-
-        if (tcgetattr(fd, &tio) < 0) {
-                msyslog(LOG_ERR, 
-                       "Trimble (%d) tcgetattr(fd, &tio): %m",unit);
-                return (0);
-        }
-
-        tio.c_cflag |= (PARENB|PARODD);
-        tio.c_iflag &= ~ICRNL;
-
-       if (tcsetattr(fd, TCSANOW, &tio) == -1) {
-                msyslog(LOG_ERR, "Trimble (%d) tcsetattr(fd, &tio): %m",unit);
-                return 0;
-        }
-
-       /*
-        * Allocate and initialize unit structure
-        */
-       if (!(up = (struct trimbledc_unit *)
-             emalloc(sizeof(struct trimbledc_unit)))) {
-               (void) close(fd);
-               return (0);
-       }
-       memset((char *)up, 0, sizeof(struct trimbledc_unit));
-
-       pp = peer->procptr;
-       pp->io.clock_recv = trimbledc_receive;
-       pp->io.srcclock = (caddr_t)peer;
-       pp->io.datalen = 0;
-       pp->io.fd = fd;
-
-       if (!io_addclock(&pp->io)) {
-               (void) close(fd);
-               free(up);
-               return (0);
-       }
-
-       /*
-        * Initialize miscellaneous variables
-        */
-       pp->unitptr = (caddr_t)up;
-       pp->clockdesc = DESCRIPTION;
-
-       peer->precision = PRECISION;
-       peer->sstclktype = CTL_SST_TS_UHF;
-       peer->minpoll = TRIMBLEDC_MINPOLL;
-       peer->maxpoll = TRIMBLEDC_MAXPOLL;
-       memcpy((char *)&pp->refid, REFID, 4);
-
-       up->leap_status = 0;
-       up->unit = unit;
-       up->io_ptr[0] = up->io_ptr[1] = 0;
-
-       return 1;
-}
-
-
-/*
- * trimbledc_shutdown - shut down the clock
- */
-static void
-trimbledc_shutdown (
-       int unit,
-       struct peer *peer
-       )
-{
-       register struct trimbledc_unit *up;
-       struct refclockproc *pp;
-       pp = peer->procptr;
-       up = (struct trimbledc_unit *)pp->unitptr;
-       io_closeclock(&pp->io);
-       free(up);
-}
-
-
-
-/* 
- * TSIP_decode - decode the TSIP data packets 
- */
-static int
-trimbledc_decode (
-       struct peer *peer
-       )
-{
-#ifdef DEBUG
-       double lat, lon, alt;
-#endif
-       int st, ts;
-       long   secint;
-       double secs;
-       double secfrac;
-       unsigned short event = 0;
-
-       register struct trimbledc_unit *up;
-       struct refclockproc *pp;
-
-       pp = peer->procptr;
-       up = (struct trimbledc_unit *)pp->unitptr;
-
-       /*
-        * Check the time packet, decode its contents. 
-        * If the timecode has invalid length or is not in
-        * proper format, declare bad format and exit.
-        */
-
-       if (up->rpt_buf[0] ==0x41) 
-       /* standard time packet - GPS time and GPS week number */
-               return 0;       
-
-
-       refclock_report(peer, CEVNT_BADREPLY);
-       up->polled = -1;
-#ifdef DEBUG
-       if (debug)
-       printf("TRIMBLEDC_decode: unit %d: bad packet %02x-%02x event %d len %d\n", 
-                  up->unit, up->rpt_buf[0] & 0xff, mb(0) & 0xff, 
-                       event, up->rpt_cnt);
-#endif
-       return 0;
-}
-
-/*
- * trimbledc__receive - receive data from the serial interface
- */
-
-static void
-trimbledc_receive (
-       struct recvbuf *rbufp
-       )
-{
-       register struct trimbledc_unit *up;
-       struct refclockproc *pp;
-       struct peer *peer;
-
-       /*
-        * Initialize pointers and read the timecode and timestamp.
-        */
-       peer = (struct peer *)rbufp->recv_srcclock;
-       pp = peer->procptr;
-       up = (struct trimbledc_unit *)pp->unitptr;
-
-       
-       for (;FALSE;) {
-               trimbledc_io(pp->sloppyclockflag & CLK_FLAG2, rbufp->recv_length,
-                           &rbufp->recv_buffer, &pp->lastrec, up);       
-
-
-
-
-               (void) sprintf(pp->a_lastcode,"%4d %03d %02d:%02d:%02d.%06ld",
-                               pp->year,pp->day,pp->hour,pp->minute, pp->second,pp->usec); 
-                               pp->lencode = 24;
-
-               if (!refclock_process(pp)) {
-                       refclock_report(peer, CEVNT_BADTIME);
-
-#ifdef DEBUG
-                       if (debug)
-                       printf("trimbledc_receive: unit %d: refclock_process failed!\n",
-                               up->unit);
-#endif
-                       continue;
-               }
-
-               record_clock_stats(&peer->srcadr, pp->a_lastcode); 
-
-#ifdef DEBUG
-               if (debug)
-                       if (debug)
-                       printf("trimbledc_receive: unit %d: %s\n",
-                          up->unit, prettydate(&pp->lastrec));
-#endif
-
-               refclock_receive(peer);
-       }
-}
-
-
-/*
- * trimbledc_poll - called by the transmit procedure
- *
- */
-static void
-trimbledc_poll (
-       int unit,
-       struct peer *peer
-       )
-{
-       struct trimbledc_unit *up;
-       struct refclockproc *pp;
-       
-       pp = peer->procptr;
-       up = (struct trimbledc_unit *)pp->unitptr;
-
-       pp->polls++;
-       if (up->polled > 0) /* last reply never arrived or error */ 
-           refclock_report(peer, CEVNT_TIMEOUT);
-
-       up->polled = 2; /* synchronous packet + 1 event */
-       
-#ifdef DEBUG
-       if (debug)
-           printf("trimbledc_poll: unit %d: polling %s\n", unit,
-                  (pp->sloppyclockflag & CLK_FLAG2) ? 
-                       "synchronous packet" : "event");
-#endif 
-
-       if (pp->sloppyclockflag & CLK_FLAG2) 
-           return;  /* using synchronous packet input */
-
-//     if (HW_poll(pp) < 0) 
-           refclock_report(peer, CEVNT_FAULT); 
-}
-
-
-static void
-trimbledc_io (
-       char noevents,
-       int buflen,                     /* bytes in buffer to process */
-       unsigned char *bufp,            /* receive buffer */
-       l_fp* t_in,                     /* receive time stamp */
-       struct trimbledc_unit *up       /* pointer to unit data structure   */
-       )
-{
-       
-}
-
-
-
-
-#endif /* REFCLOCK */
diff --git a/ports/winnt/ntpd/refclock_trimbledc.h b/ports/winnt/ntpd/refclock_trimbledc.h
deleted file mode 100644 (file)
index f53ff7f..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * refclock_trimbledc - clock driver for the Trimble Data Collector compatible
- * GPS receivers (4000, 4700, 4800, 7400, ...)
- *
- * Greg Brackley (greg@trimble.co.nz)
- */
-
-#ifndef _REFCLOCK_TRIMBLEDC_H
-#define _REFCLOCK_TRIMBLEDC_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if defined HAVE_SYS_MODEM_H
-#include <sys/modem.h>
-#define TIOCMSET MCSETA
-#define TIOCMGET MCGETA
-#define TIOCM_RTS MRTS
-#endif
-
-#ifdef HAVE_TERMIOS_H
-#include <termios.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#include "ntpd.h"
-#include "ntp_io.h"
-#include "ntp_control.h"
-#include "ntp_refclock.h"
-#include "ntp_unixtime.h"
-#include "ntp_stdlib.h"
-
-/*
- * GPS Definitions
- */
-#define        DESCRIPTION     "Trimble Data Collector GPS" /* Long name */
-#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
-#define        REFID           "GPS\0" /* reference ID */
-#define NSAMPLES               1
-#define NSKEEP                 1
-#define TRIMBLEDC_MINPOLL      4
-#define TRIMBLEDC_MAXPOLL      4
-
-/*
- * I/O Definitions
- */
-#if !defined SYS_WINNT
-#define        DEVICE          "/dev/trimbledc%d"      /* device name and unit */
-#else
-#define        DEVICE          "\\\\.\\COM%d"          /* device name and unit */
-#endif
-#define        SPEED232        B9600                   /* uart speed (9600 baud) */
-
-#define POLL_AVG       10  /* number of samples to average code delay */
-#define DC_IO_BUFSIZE  512 /* IO buffer */
-#define DC_MAXLEN      260  /* maximum length TSIP packet */
-
-/* 
- * Leap-Insert and Leap-Delete are encoded as follows:
- *     PALISADE_UTC_TIME set   and PALISADE_LEAP_PENDING set: INSERT leap
- *     PALISADE_UTC_TIME clear and PALISADE_LEAP_PENDING set: DELETE leap
- */
-
-#define PALISADE_LEAP_WARNING    0x04 /* GPS Leap Warning (see ICD-200) */
-#define PALISADE_LEAP_PENDING    0x02 /* Leap Pending (24 hours) */
-#define PALISADE_UTC_TIME        0x01 /* UTC time available */
-
-#define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
-
-/* Conversion Definitions */
-#define GPS_PI                 (3.1415926535898)
-#define        R2D             (180.0/GPS_PI)
-
-typedef enum TrimbleDcParseState {
-
-  TrimbleParseStateAck,
-  TrimbleParseStateNak,
-  TrimbleParseStateData,
-
-} TrimbleDcParseState;
-
-struct trimbledc_unit {
-       int             unit;           /* NTP refclock unit number */
-       int             polled;         /* flag to detect noreplies */
-       char            leap_status;    /* leap second flag */
-       TrimbleDcParseState             rpt_status;     
-       short           rpt_cnt;        
-       char            rpt_buf[DC_MAXLEN];     
-       char            io_buf[DC_IO_BUFSIZE];
-       short           io_ptr[2];      /* 0 = head, 1 = tail */
-};
-
-#endif /* _REFCLOCK_TRIMBLEDC_H */
index 827e563d89b67543d44b182955e6f7ff9aeb1e61..56d0671bf89c39b63ddbcce14bb3d7620f90812f 100644 (file)
                        <File
                                RelativePath="..\..\..\include\ntp_select.h">
                        </File>
-                       <File
-                               RelativePath="..\..\..\include\ntp_sprintf.h">
-                       </File>
                        <File
                                RelativePath="..\..\..\include\ntp_stdlib.h">
                        </File>
index 8cf2feab8ebcb8dd3a686f022289fb80037b260b..d7df6717f1d001931e2506400669a86ff7dcd6b1 100644 (file)
                                RelativePath="..\..\..\include\ntp_select.h"
                                >
                        </File>
-                       <File
-                               RelativePath="..\..\..\include\ntp_sprintf.h"
-                               >
-                       </File>
                        <File
                                RelativePath="..\..\..\include\ntp_stdlib.h"
                                >
index 2c9de4e90566892401479d37b115e07ffdc550d3..6dbd6ee1609d3b850cfae18077b459fb3468cf12 100644 (file)
                                RelativePath="..\..\..\..\include\ntp_select.h"
                                >
                        </File>
-                       <File
-                               RelativePath="..\..\..\..\include\ntp_sprintf.h"
-                               >
-                       </File>
                        <File
                                RelativePath="..\..\..\..\include\ntp_stdlib.h"
                                >
index 43b6963ea1d59f488674b4e5de1f9b473de74777..184fc3c1210e22fb8580191fc4b1c5f4cb041b9a 100644 (file)
                                RelativePath="..\..\..\..\ntpd\refclock_true.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\ntpd\refclock_tt560.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\ntpd\refclock_ulink.c"
                                >
index 6f2e4fa84a6d4b6f0a2a223226ed3c162cd270bf..cbaf0f2f460bdd691f6ae0763ba54cfcdb745e0b 100644 (file)
@@ -94,8 +94,8 @@ main( )
        char *actl = ac_dev;
        int devmask = 0, recmask = 0, recsrc = 0;
 
-       (void)sprintf(ai_dev, AI_DEV, unit);
-       (void)sprintf(ac_dev, AC_DEV, unit);
+       snprintf(ai_dev, sizeof(ai_dev), AI_DEV, unit);
+       snprintf(ac_dev, sizeof(ac_dev), AC_DEV, unit);
 
        /*
         * Open audio device. Do not complain if not there.
index b993de907d0819265b27868d2770b382c001fb67..2a83f401c5d21b65e49187b008e26f11b9d40f83 100644 (file)
@@ -62,7 +62,7 @@ getShmTime (
 #else
        char buf[10];
        LPSECURITY_ATTRIBUTES psec=0;
-       sprintf (buf,"NTP%d",unit);
+       snprintf (buf, sizeof(buf), "NTP%d", unit);
        SECURITY_DESCRIPTOR sd;
        SECURITY_ATTRIBUTES sa;
        HANDLE shmid;
index 0d0fce6887e44d20b24b4125c774796504899875..8a96a816ad296ded5749a1cd5fcf194e26ba3b90 100644 (file)
--- a/util/tg.c
+++ b/util/tg.c
@@ -374,8 +374,8 @@ main(
        case WWV:
                printf("year %d day %d time %02d:%02d:%02d tone %d\n",
                    year, day, hour, minute, second, tone);
-               sprintf(code, "%01d%03d%02d%02d%01d", year / 10, day,
-                   hour, minute, year % 10);
+               snprintf(code, sizeof(code), "%01d%03d%02d%02d%01d",
+                   year / 10, day, hour, minute, year % 10);
                printf("%s\n", code);
                ptr = 8;
                for (i = 0; i <= second; i++) {
@@ -431,16 +431,17 @@ main(
                                year++;
                        }
                        if (encode == WWV) {
-                               sprintf(code, "%01d%03d%02d%02d%01d",
-                                   year / 10, day, hour, minute, year %
-                                   10);
+                               snprintf(code, sizeof(code),
+                                   "%01d%03d%02d%02d%01d", year / 10,
+                                   day, hour, minute, year % 10);
                                printf("\n%s\n", code);
                                ptr = 8;
                        }
                }
                if (encode == IRIG) {
-                       sprintf(code, "%04x%04d%06d%02d%02d%02d", 0,
-                           year, day, hour, minute, second);
+                       snprintf(code, sizeof(code),
+                           "%04x%04d%06d%02d%02d%02d", 0, year, day,
+                           hour, minute, second);
                        printf("%s\n", code);
                        ptr = 19;
                }
index db8de0656b4b43fd986f6a36fe78970711cf4427..e388f20f0738d8640b16b1bf00ed768397b39489 100644 (file)
@@ -1098,7 +1098,7 @@ main(
                printf("WWV time signal, starting point:\n");
                printf(" Year = %02d, Day of year = %03d, Time = %02d:%02d:%02d, Minute tone = %d Hz, Hour tone = %d Hz.\n",
                    Year, DayOfYear, Hour, Minute, Second, tone, HourTone);
-               sprintf(code, "%01d%03d%02d%02d%01d",
+               snprintf(code, sizeof(code), "%01d%03d%02d%02d%01d",
                    Year / 10, DayOfYear, Hour, Minute, Year % 10);
                if  (Verbose)
                        {
@@ -1371,8 +1371,9 @@ main(
                                Year++;
                        }
                        if (encode == WWV) {
-                               sprintf(code, "%01d%03d%02d%02d%01d",
-                                   Year / 10, DayOfYear, Hour, Minute, Year % 10);
+                               snprintf(code, sizeof(code),
+                                   "%01d%03d%02d%02d%01d", Year / 10,
+                                   DayOfYear, Hour, Minute, Year % 10);
                                if  (Verbose)
                                    printf("\n Year = %2.2d, Day of year = %3d, Time = %2.2d:%2.2d:%2.2d, Code = %s", 
                                                Year, DayOfYear, Hour, Minute, Second, code);
@@ -1441,17 +1442,20 @@ main(
                                ControlFunctions = 0;
 
                        /*
-                                          YearDay HourMin Sec
-                       sprintf(code, "%04x%04d%06d%02d%02d%02d",
+                                                     YearDay HourMin Sec
+                       snprintf(code, sizeof(code), "%04x%04d%06d%02d%02d%02d",
                                0, Year, DayOfYear, Hour, Minute, Second);
                        */
                        if  (IrigIncludeYear) {
-                               sprintf(ParityString, "%04X%02d%04d%02d%02d%02d",
-                                       ControlFunctions & 0x7FFF, Year, DayOfYear, Hour, Minute, Second);
-                       }
-                       else {
-                               sprintf(ParityString, "%04X%02d%04d%02d%02d%02d",
-                                       ControlFunctions & 0x7FFF,    0, DayOfYear, Hour, Minute, Second);
+                               snprintf(ParityString, sizeof(ParityString),
+                                   "%04X%02d%04d%02d%02d%02d",
+                                   ControlFunctions & 0x7FFF, Year,
+                                   DayOfYear, Hour, Minute, Second);
+                       } else {
+                               snprintf(ParityString, sizeof(ParityString),
+                                   "%04X%02d%04d%02d%02d%02d",
+                                   ControlFunctions & 0x7FFF,
+                                   0, DayOfYear, Hour, Minute, Second);
                        }
 
                        if  (IrigIncludeIeee)
@@ -1501,14 +1505,19 @@ main(
                        ControlFunctions |= ((ParityValue & 0x01) << 14);
 
                        if  (IrigIncludeYear) {
-                               /*                 YearDay HourMin Sec*/
-                               sprintf(code, "%05X%05X%02d%04d%02d%02d%02d",
-                                       StraightBinarySeconds, ControlFunctions, Year, DayOfYear, Hour, Minute, Second);
-                       }
-                       else {
-                               /*                 YearDay HourMin Sec*/
-                               sprintf(code, "%05X%05X%02d%04d%02d%02d%02d",
-                                       StraightBinarySeconds, ControlFunctions,    0, DayOfYear, Hour, Minute, Second);
+                               snprintf(code, sizeof(code),
+                                   /* YearDay HourMin Sec */
+                                   "%05X%05X%02d%04d%02d%02d%02d",
+                                   StraightBinarySeconds,
+                                   ControlFunctions, Year, DayOfYear,
+                                   Hour, Minute, Second);
+                       } else {
+                               snprintf(code, sizeof(code),
+                                   /* YearDay HourMin Sec */
+                                   "%05X%05X%02d%04d%02d%02d%02d",
+                                   StraightBinarySeconds,
+                                   ControlFunctions, 0, DayOfYear,
+                                   Hour, Minute, Second);
                        }
 
                        if  (Debug)