* 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>
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],
ntp_request.h \
ntp_rfc2553.h \
ntp_select.h \
- ntp_sprintf.h \
ntp_stdlib.h \
ntp_string.h \
ntp_syscall.h \
+++ /dev/null
-/*
- * 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
#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
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) ==
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;
* 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
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 *
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
# include <sys/ppsclock.h>
#endif
-#include "ntp_sprintf.h"
-
#ifndef HAVE_STRUCT_PPSCLOCKEV
struct ppsclockev {
# ifdef HAVE_STRUCT_TIMESPEC
* 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
{
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);
* 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,
}
}
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,
}
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);
* 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:
* 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
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));
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);
}
}
(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
* 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
#define HW_WANT_RPL_VSNPRINTF 1
#define HW_WANT_RPL_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_SNPRINTF 1
typedef char *caddr_t;
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 */
#include <stdlib.h>
#include <stddef.h>
#include <winioctl.h>
+
+#include "ntp_stdlib.h"
#include "hopf_PCI_io.h"
+++ /dev/null
-#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 */
+++ /dev/null
-/*
- * 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 */
<File
RelativePath="..\..\..\include\ntp_select.h">
</File>
- <File
- RelativePath="..\..\..\include\ntp_sprintf.h">
- </File>
<File
RelativePath="..\..\..\include\ntp_stdlib.h">
</File>
RelativePath="..\..\..\include\ntp_select.h"
>
</File>
- <File
- RelativePath="..\..\..\include\ntp_sprintf.h"
- >
- </File>
<File
RelativePath="..\..\..\include\ntp_stdlib.h"
>
RelativePath="..\..\..\..\include\ntp_select.h"
>
</File>
- <File
- RelativePath="..\..\..\..\include\ntp_sprintf.h"
- >
- </File>
<File
RelativePath="..\..\..\..\include\ntp_stdlib.h"
>
RelativePath="..\..\..\..\ntpd\refclock_true.c"
>
</File>
+ <File
+ RelativePath="..\..\..\..\ntpd\refclock_tt560.c"
+ >
+ </File>
<File
RelativePath="..\..\..\..\ntpd\refclock_ulink.c"
>
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.
#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;
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++) {
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;
}
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)
{
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);
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)
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)