Mon Dec 14 00:46:21 2009 UTC ()
fix bogus ctype casts


(christos)
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/ntp_refclock.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/ntp_request.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_arc.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_heath.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_nmea.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_oncore.c
diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_parse.c

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/ntp_refclock.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/ntp_refclock.c 2009/12/13 16:55:38 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/ntp_refclock.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ntp_refclock.c,v 1.1.1.1 2009/12/13 16:55:38 kardel Exp $ */ 1/* $NetBSD: ntp_refclock.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * ntp_refclock - processing support for reference clocks 4 * ntp_refclock - processing support for reference clocks
5 */ 5 */
6#ifdef HAVE_CONFIG_H 6#ifdef HAVE_CONFIG_H
7# include <config.h> 7# include <config.h>
8#endif 8#endif
9 9
10#include "ntpd.h" 10#include "ntpd.h"
11#include "ntp_io.h" 11#include "ntp_io.h"
12#include "ntp_unixtime.h" 12#include "ntp_unixtime.h"
13#include "ntp_tty.h" 13#include "ntp_tty.h"
14#include "ntp_refclock.h" 14#include "ntp_refclock.h"

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/ntp_request.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/ntp_request.c 2009/12/13 16:55:40 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/ntp_request.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ntp_request.c,v 1.1.1.1 2009/12/13 16:55:40 kardel Exp $ */ 1/* $NetBSD: ntp_request.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * ntp_request.c - respond to information requests 4 * ntp_request.c - respond to information requests
5 */ 5 */
6 6
7#ifdef HAVE_CONFIG_H 7#ifdef HAVE_CONFIG_H
8# include <config.h> 8# include <config.h>
9#endif 9#endif
10 10
11#include "ntpd.h" 11#include "ntpd.h"
12#include "ntp_io.h" 12#include "ntp_io.h"
13#include "ntp_request.h" 13#include "ntp_request.h"
14#include "ntp_control.h" 14#include "ntp_control.h"
@@ -401,27 +401,26 @@ get_packet_mode(struct recvbuf *rbufp) @@ -401,27 +401,26 @@ get_packet_mode(struct recvbuf *rbufp)
401 return (INFO_MODE(inpkt->rm_vn_mode)); 401 return (INFO_MODE(inpkt->rm_vn_mode));
402} 402}
403 403
404 404
405/* 405/*
406 * process_private - process private mode (7) packets 406 * process_private - process private mode (7) packets
407 */ 407 */
408void 408void
409process_private( 409process_private(
410 struct recvbuf *rbufp, 410 struct recvbuf *rbufp,
411 int mod_okay 411 int mod_okay
412 ) 412 )
413{ 413{
414 static u_long quiet_until; 
415 struct req_pkt *inpkt; 414 struct req_pkt *inpkt;
416 struct req_pkt_tail *tailinpkt; 415 struct req_pkt_tail *tailinpkt;
417 sockaddr_u *srcadr; 416 sockaddr_u *srcadr;
418 struct interface *inter; 417 struct interface *inter;
419 struct req_proc *proc; 418 struct req_proc *proc;
420 int ec; 419 int ec;
421 short temp_size; 420 short temp_size;
422 l_fp ftmp; 421 l_fp ftmp;
423 double dtemp; 422 double dtemp;
424 size_t recv_len; 423 size_t recv_len;
425 size_t noslop_len; 424 size_t noslop_len;
426 size_t mac_len; 425 size_t mac_len;
427 426
@@ -440,34 +439,28 @@ process_private( @@ -440,34 +439,28 @@ process_private(
440 * Do some sanity checks on the packet. Return a format 439 * Do some sanity checks on the packet. Return a format
441 * error if it fails. 440 * error if it fails.
442 */ 441 */
443 ec = 0; 442 ec = 0;
444 if ( (++ec, ISRESPONSE(inpkt->rm_vn_mode)) 443 if ( (++ec, ISRESPONSE(inpkt->rm_vn_mode))
445 || (++ec, ISMORE(inpkt->rm_vn_mode)) 444 || (++ec, ISMORE(inpkt->rm_vn_mode))
446 || (++ec, INFO_VERSION(inpkt->rm_vn_mode) > NTP_VERSION) 445 || (++ec, INFO_VERSION(inpkt->rm_vn_mode) > NTP_VERSION)
447 || (++ec, INFO_VERSION(inpkt->rm_vn_mode) < NTP_OLDVERSION) 446 || (++ec, INFO_VERSION(inpkt->rm_vn_mode) < NTP_OLDVERSION)
448 || (++ec, INFO_SEQ(inpkt->auth_seq) != 0) 447 || (++ec, INFO_SEQ(inpkt->auth_seq) != 0)
449 || (++ec, INFO_ERR(inpkt->err_nitems) != 0) 448 || (++ec, INFO_ERR(inpkt->err_nitems) != 0)
450 || (++ec, INFO_MBZ(inpkt->mbz_itemsize) != 0) 449 || (++ec, INFO_MBZ(inpkt->mbz_itemsize) != 0)
451 || (++ec, rbufp->recv_length < REQ_LEN_HDR) 450 || (++ec, rbufp->recv_length < REQ_LEN_HDR)
452 ) { 451 ) {
453 NLOG(NLOG_SYSEVENT) 452 msyslog(LOG_ERR, "process_private: INFO_ERR_FMT: test %d failed, pkt from %s", ec, stoa(srcadr));
454 if (current_time >= quiet_until) { 453 req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
455 msyslog(LOG_ERR, 
456 "process_private: drop test %d" 
457 " failed, pkt from %s", 
458 ec, stoa(srcadr)); 
459 quiet_until = current_time + 60; 
460 } 
461 return; 454 return;
462 } 455 }
463 456
464 reqver = INFO_VERSION(inpkt->rm_vn_mode); 457 reqver = INFO_VERSION(inpkt->rm_vn_mode);
465 458
466 /* 459 /*
467 * Get the appropriate procedure list to search. 460 * Get the appropriate procedure list to search.
468 */ 461 */
469 if (inpkt->implementation == IMPL_UNIV) 462 if (inpkt->implementation == IMPL_UNIV)
470 proc = univ_codes; 463 proc = univ_codes;
471 else if ((inpkt->implementation == IMPL_XNTPD) || 464 else if ((inpkt->implementation == IMPL_XNTPD) ||
472 (inpkt->implementation == IMPL_XNTPD_OLD)) 465 (inpkt->implementation == IMPL_XNTPD_OLD))
473 proc = ntp_codes; 466 proc = ntp_codes;
@@ -1173,27 +1166,27 @@ sys_stats( @@ -1173,27 +1166,27 @@ sys_stats(
1173static void 1166static void
1174mem_stats( 1167mem_stats(
1175 sockaddr_u *srcadr, 1168 sockaddr_u *srcadr,
1176 struct interface *inter, 1169 struct interface *inter,
1177 struct req_pkt *inpkt 1170 struct req_pkt *inpkt
1178 ) 1171 )
1179{ 1172{
1180 register struct info_mem_stats *ms; 1173 register struct info_mem_stats *ms;
1181 register int i; 1174 register int i;
1182 1175
1183 /* 1176 /*
1184 * Importations from the peer module 1177 * Importations from the peer module
1185 */ 1178 */
1186 extern int peer_hash_count[NTP_HASH_SIZE]; 1179 extern int peer_hash_count[];
1187 extern int peer_free_count; 1180 extern int peer_free_count;
1188 extern u_long peer_timereset; 1181 extern u_long peer_timereset;
1189 extern u_long findpeer_calls; 1182 extern u_long findpeer_calls;
1190 extern u_long peer_allocations; 1183 extern u_long peer_allocations;
1191 extern u_long peer_demobilizations; 1184 extern u_long peer_demobilizations;
1192 extern int total_peer_structs; 1185 extern int total_peer_structs;
1193 1186
1194 ms = (struct info_mem_stats *)prepare_pkt(srcadr, inter, inpkt, 1187 ms = (struct info_mem_stats *)prepare_pkt(srcadr, inter, inpkt,
1195 sizeof(struct info_mem_stats)); 1188 sizeof(struct info_mem_stats));
1196 1189
1197 ms->timereset = htonl((u_int32)(current_time - peer_timereset)); 1190 ms->timereset = htonl((u_int32)(current_time - peer_timereset));
1198 ms->totalpeermem = htons((u_short)total_peer_structs); 1191 ms->totalpeermem = htons((u_short)total_peer_structs);
1199 ms->freepeermem = htons((u_short)peer_free_count); 1192 ms->freepeermem = htons((u_short)peer_free_count);

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_arc.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_arc.c 2009/12/13 16:55:44 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_arc.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_arc.c,v 1.1.1.1 2009/12/13 16:55:44 kardel Exp $ */ 1/* $NetBSD: refclock_arc.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * refclock_arc - clock driver for ARCRON MSF/DCF/WWVB receivers 4 * refclock_arc - clock driver for ARCRON MSF/DCF/WWVB receivers
5 */ 5 */
6 6
7#ifdef HAVE_CONFIG_H 7#ifdef HAVE_CONFIG_H
8#include <config.h> 8#include <config.h>
9#endif 9#endif
10 10
11#if defined(REFCLOCK) && defined(CLOCK_ARCRON_MSF) 11#if defined(REFCLOCK) && defined(CLOCK_ARCRON_MSF)
12 12
13static const char arc_version[] = { "V1.3 2003/02/21" }; 13static const char arc_version[] = { "V1.3 2003/02/21" };
14 14
@@ -821,35 +821,35 @@ send_slow( @@ -821,35 +821,35 @@ send_slow(
821 return(0); /* FAILED! */ 821 return(0); /* FAILED! */
822 } 822 }
823 823
824 /* Copy in the command to be sent. */ 824 /* Copy in the command to be sent. */
825 while(*s && spaceleft > 0) { up->cmdqueue[CMDQUEUELEN - spaceleft--] = *s++; } 825 while(*s && spaceleft > 0) { up->cmdqueue[CMDQUEUELEN - spaceleft--] = *s++; }
826 826
827 return(1); 827 return(1);
828} 828}
829 829
830 830
831static int 831static int
832get2(char *p, int *val) 832get2(char *p, int *val)
833{ 833{
834 if (!isdigit((int)p[0]) || !isdigit((int)p[1])) return 0; 834 if (!isdigit((unsigned char)p[0]) || !isdigit((unsigned char)p[1])) return 0;
835 *val = (p[0] - '0') * 10 + p[1] - '0'; 835 *val = (p[0] - '0') * 10 + p[1] - '0';
836 return 1; 836 return 1;
837} 837}
838 838
839static int 839static int
840get1(char *p, int *val) 840get1(char *p, int *val)
841{ 841{
842 if (!isdigit((int)p[0])) return 0; 842 if (!isdigit((unsigned char)p[0])) return 0;
843 *val = p[0] - '0'; 843 *val = p[0] - '0';
844 return 1; 844 return 1;
845} 845}
846 846
847/* Macro indicating action we will take for different quality values. */ 847/* Macro indicating action we will take for different quality values. */
848#define quality_action(q) \ 848#define quality_action(q) \
849(((q) == QUALITY_UNKNOWN) ? "UNKNOWN, will use clock anyway" : \ 849(((q) == QUALITY_UNKNOWN) ? "UNKNOWN, will use clock anyway" : \
850 (((q) < MIN_CLOCK_QUALITY_OK) ? "TOO POOR, will not use clock" : \ 850 (((q) < MIN_CLOCK_QUALITY_OK) ? "TOO POOR, will not use clock" : \
851 "OK, will use clock")) 851 "OK, will use clock"))
852 852
853/* 853/*
854 * arc_receive - receive data from the serial interface 854 * arc_receive - receive data from the serial interface
855 */ 855 */
@@ -921,27 +921,27 @@ arc_receive( @@ -921,27 +921,27 @@ arc_receive(
921 c = rbufp->recv_buffer[0]; 921 c = rbufp->recv_buffer[0];
922 if((pp->a_lastcode[0] == 'o') && 922 if((pp->a_lastcode[0] == 'o') &&
923#ifndef ARCRON_MULTIPLE_SAMPLES 923#ifndef ARCRON_MULTIPLE_SAMPLES
924 (pp->lencode == 1) && 924 (pp->lencode == 1) &&
925#endif 925#endif
926 ((pp->lencode != 1) || (c != '\r')) && 926 ((pp->lencode != 1) || (c != '\r')) &&
927 (arc_last_offset >= 1)) { 927 (arc_last_offset >= 1)) {
928 /* Note that the timestamp should be corrected if >1 char rcvd. */ 928 /* Note that the timestamp should be corrected if >1 char rcvd. */
929 l_fp timestamp; 929 l_fp timestamp;
930 timestamp = rbufp->recv_time; 930 timestamp = rbufp->recv_time;
931#ifdef DEBUG 931#ifdef DEBUG
932 if(debug) { /* Show \r as `R', other non-printing char as `?'. */ 932 if(debug) { /* Show \r as `R', other non-printing char as `?'. */
933 printf("arc: stamp -->%c<-- (%d chars rcvd)\n", 933 printf("arc: stamp -->%c<-- (%d chars rcvd)\n",
934 ((c == '\r') ? 'R' : (isgraph((int)c) ? c : '?')), 934 ((c == '\r') ? 'R' : (isgraph((unsigned char)c) ? c : '?')),
935 rbufp->recv_length); 935 rbufp->recv_length);
936 } 936 }
937#endif 937#endif
938 938
939 /* 939 /*
940 Now correct timestamp by offset of last byte received---we 940 Now correct timestamp by offset of last byte received---we
941 subtract from the receive time the delay implied by the 941 subtract from the receive time the delay implied by the
942 extra characters received. 942 extra characters received.
943 943
944 Reject the input if the resulting code is too long, but 944 Reject the input if the resulting code is too long, but
945 allow for the trailing \r, normally not used but a good 945 allow for the trailing \r, normally not used but a good
946 handle for tty_clk or somesuch kernel timestamper. 946 handle for tty_clk or somesuch kernel timestamper.
947 */ 947 */

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_heath.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_heath.c 2009/12/13 16:55:48 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_heath.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_heath.c,v 1.1.1.1 2009/12/13 16:55:48 kardel Exp $ */ 1/* $NetBSD: refclock_heath.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * refclock_heath - clock driver for Heath GC-1000 4 * refclock_heath - clock driver for Heath GC-1000
5 * (but no longer the GC-1001 Model II, which apparently never worked) 5 * (but no longer the GC-1001 Model II, which apparently never worked)
6 */ 6 */
7 7
8#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
9# include <config.h> 9# include <config.h>
10#endif 10#endif
11 11
12#if defined(REFCLOCK) && defined(CLOCK_HEATH) 12#if defined(REFCLOCK) && defined(CLOCK_HEATH)
13 13
14#include "ntpd.h" 14#include "ntpd.h"
@@ -369,27 +369,27 @@ heath_receive( @@ -369,27 +369,27 @@ heath_receive(
369 } else { 369 } else {
370 if (day > day2tab[month - 1]) { 370 if (day > day2tab[month - 1]) {
371 refclock_report(peer, CEVNT_BADTIME); 371 refclock_report(peer, CEVNT_BADTIME);
372 return; 372 return;
373 } 373 }
374 for (i = 0; i < month - 1; i++) 374 for (i = 0; i < month - 1; i++)
375 day += day2tab[i]; 375 day += day2tab[i];
376 } 376 }
377 pp->day = day; 377 pp->day = day;
378 378
379 /* 379 /*
380 * Determine synchronization and last update 380 * Determine synchronization and last update
381 */ 381 */
382 if (!isdigit((int)dsec)) 382 if (!isdigit((unsigned char)dsec))
383 pp->leap = LEAP_NOTINSYNC; 383 pp->leap = LEAP_NOTINSYNC;
384 else { 384 else {
385 pp->nsec = (dsec - '0') * 100000000; 385 pp->nsec = (dsec - '0') * 100000000;
386 pp->leap = LEAP_NOWARNING; 386 pp->leap = LEAP_NOWARNING;
387 } 387 }
388 if (!refclock_process(pp)) 388 if (!refclock_process(pp))
389 refclock_report(peer, CEVNT_BADTIME); 389 refclock_report(peer, CEVNT_BADTIME);
390} 390}
391 391
392 392
393/* 393/*
394 * heath_poll - called by the transmit procedure 394 * heath_poll - called by the transmit procedure
395 */ 395 */

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c 2009/12/13 16:55:46 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_neoclock4x.c,v 1.1.1.1 2009/12/13 16:55:46 kardel Exp $ */ 1/* $NetBSD: refclock_neoclock4x.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * 4 *
5 * Refclock_neoclock4x.c 5 * Refclock_neoclock4x.c
6 * - NeoClock4X driver for DCF77 or FIA Timecode 6 * - NeoClock4X driver for DCF77 or FIA Timecode
7 * 7 *
8 * Date: 2006-01-11 v1.15 8 * Date: 2006-01-11 v1.15
9 * 9 *
10 * see http://www.linum.com/redir/jump/id=neoclock4x&action=redir 10 * see http://www.linum.com/redir/jump/id=neoclock4x&action=redir
11 * for details about the NeoClock4X device 11 * for details about the NeoClock4X device
12 * 12 *
13 * Copyright (C) 2002-2004 by Linum Software GmbH <neoclock4x@linum.com> 13 * Copyright (C) 2002-2004 by Linum Software GmbH <neoclock4x@linum.com>
14 * 14 *
@@ -784,45 +784,45 @@ neoclock4x_control(int unit, @@ -784,45 +784,45 @@ neoclock4x_control(int unit,
784 snprintf(tt, 79, "serialnumber=\"%s\"", up->serial); 784 snprintf(tt, 79, "serialnumber=\"%s\"", up->serial);
785 } 785 }
786} 786}
787 787
788static int 788static int
789neol_hexatoi_len(const char str[], 789neol_hexatoi_len(const char str[],
790 int *result, 790 int *result,
791 int maxlen) 791 int maxlen)
792{ 792{
793 int hexdigit; 793 int hexdigit;
794 int i; 794 int i;
795 int n = 0; 795 int n = 0;
796 796
797 for(i=0; isxdigit((int)str[i]) && i < maxlen; i++) 797 for(i=0; isxdigit((unsigned char)str[i]) && i < maxlen; i++)
798 { 798 {
799 hexdigit = isdigit((int)str[i]) ? toupper(str[i]) - '0' : toupper(str[i]) - 'A' + 10; 799 hexdigit = isdigit((unsigned char)str[i]) ? toupper((unsigned char)str[i]) - '0' : toupper((unsigned char)str[i]) - 'A' + 10;
800 n = 16 * n + hexdigit; 800 n = 16 * n + hexdigit;
801 } 801 }
802 *result = n; 802 *result = n;
803 return (n); 803 return (n);
804} 804}
805 805
806static int 806static int
807neol_atoi_len(const char str[], 807neol_atoi_len(const char str[],
808 int *result, 808 int *result,
809 int maxlen) 809 int maxlen)
810{ 810{
811 int digit; 811 int digit;
812 int i; 812 int i;
813 int n = 0; 813 int n = 0;
814 814
815 for(i=0; isdigit((int)str[i]) && i < maxlen; i++) 815 for(i=0; isdigit((unsigned char)str[i]) && i < maxlen; i++)
816 { 816 {
817 digit = str[i] - '0'; 817 digit = str[i] - '0';
818 n = 10 * n + digit; 818 n = 10 * n + digit;
819 } 819 }
820 *result = n; 820 *result = n;
821 return (n); 821 return (n);
822} 822}
823 823
824/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. 824/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
825 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 825 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
826 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. 826 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
827 * 827 *
828 * [For the Julian calendar (which was used in Russia before 1917, 828 * [For the Julian calendar (which was used in Russia before 1917,

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_nmea.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_nmea.c 2009/12/13 16:55:55 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_nmea.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_nmea.c,v 1.1.1.1 2009/12/13 16:55:55 kardel Exp $ */ 1/* $NetBSD: refclock_nmea.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * refclock_nmea.c - clock driver for an NMEA GPS CLOCK 4 * refclock_nmea.c - clock driver for an NMEA GPS CLOCK
5 * Michael Petry Jun 20, 1994 5 * Michael Petry Jun 20, 1994
6 * based on refclock_heathn.c 6 * based on refclock_heathn.c
7 * 7 *
8 * Updated to add support for Accord GPS Clock 8 * Updated to add support for Accord GPS Clock
9 * Venu Gopal Dec 05, 2007 9 * Venu Gopal Dec 05, 2007
10 * neo.venu@gmail.com, venugopal_d@pgad.gov.in 10 * neo.venu@gmail.com, venugopal_d@pgad.gov.in
11 * 11 *
12 * Updated to process 'time1' fudge factor 12 * Updated to process 'time1' fudge factor
13 * Venu Gopal May 05, 2008 13 * Venu Gopal May 05, 2008
14 * 14 *
@@ -16,26 +16,27 @@ @@ -16,26 +16,27 @@
16 * from serial timecode fudge time2. 16 * from serial timecode fudge time2.
17 * Dave Hart July 1, 2009 17 * Dave Hart July 1, 2009
18 * hart@ntp.org, davehart@davehart.com 18 * hart@ntp.org, davehart@davehart.com
19 */ 19 */
20#ifdef HAVE_CONFIG_H 20#ifdef HAVE_CONFIG_H
21#include <config.h> 21#include <config.h>
22#endif 22#endif
23 23
24#if defined(REFCLOCK) && defined(CLOCK_NMEA) 24#if defined(REFCLOCK) && defined(CLOCK_NMEA)
25 25
26#include <sys/stat.h> 26#include <sys/stat.h>
27#include <stdio.h> 27#include <stdio.h>
28#include <ctype.h> 28#include <ctype.h>
 29#include <sys/socket.h>
29 30
30#include "ntpd.h" 31#include "ntpd.h"
31#include "ntp_io.h" 32#include "ntp_io.h"
32#include "ntp_unixtime.h" 33#include "ntp_unixtime.h"
33#include "ntp_refclock.h" 34#include "ntp_refclock.h"
34#include "ntp_stdlib.h" 35#include "ntp_stdlib.h"
35 36
36#ifdef HAVE_PPSAPI 37#ifdef HAVE_PPSAPI
37# include "ppsapi_timepps.h" 38# include "ppsapi_timepps.h"
38#include "refclock_atom.h" 39#include "refclock_atom.h"
39#endif /* HAVE_PPSAPI */ 40#endif /* HAVE_PPSAPI */
40 41
41#ifdef SYS_WINNT 42#ifdef SYS_WINNT
@@ -633,56 +634,56 @@ nmea_receive( @@ -633,56 +634,56 @@ nmea_receive(
633 pp->leap = LEAP_NOWARNING; 634 pp->leap = LEAP_NOWARNING;
634 635
635 /* Now point at the time field */ 636 /* Now point at the time field */
636 dp = field_parse(cp, 1); 637 dp = field_parse(cp, 1);
637 break; 638 break;
638 639
639 default: 640 default:
640 return; 641 return;
641 } 642 }
642 643
643 /* 644 /*
644 * Check time code format of NMEA 645 * Check time code format of NMEA
645 */ 646 */
646 if (!isdigit((int)dp[0]) || 647 if (!isdigit((unsigned char)dp[0]) ||
647 !isdigit((int)dp[1]) || 648 !isdigit((unsigned char)dp[1]) ||
648 !isdigit((int)dp[2]) || 649 !isdigit((unsigned char)dp[2]) ||
649 !isdigit((int)dp[3]) || 650 !isdigit((unsigned char)dp[3]) ||
650 !isdigit((int)dp[4]) || 651 !isdigit((unsigned char)dp[4]) ||
651 !isdigit((int)dp[5])) { 652 !isdigit((unsigned char)dp[5])) {
652 653
653 DPRINTF(1, ("NMEA time code %c%c%c%c%c%c non-numeric", 654 DPRINTF(1, ("NMEA time code %c%c%c%c%c%c non-numeric",
654 dp[0], dp[1], dp[2], dp[3], dp[4], dp[5])); 655 dp[0], dp[1], dp[2], dp[3], dp[4], dp[5]));
655 refclock_report(peer, CEVNT_BADTIME); 656 refclock_report(peer, CEVNT_BADTIME);
656 return; 657 return;
657 } 658 }
658 659
659 /* 660 /*
660 * Convert time and check values. 661 * Convert time and check values.
661 */ 662 */
662 pp->hour = ((dp[0] - '0') * 10) + dp[1] - '0'; 663 pp->hour = ((dp[0] - '0') * 10) + dp[1] - '0';
663 pp->minute = ((dp[2] - '0') * 10) + dp[3] - '0'; 664 pp->minute = ((dp[2] - '0') * 10) + dp[3] - '0';
664 pp->second = ((dp[4] - '0') * 10) + dp[5] - '0'; 665 pp->second = ((dp[4] - '0') * 10) + dp[5] - '0';
665 /*  666 /*
666 * Default to 0 milliseconds, if decimal convert milliseconds in 667 * Default to 0 milliseconds, if decimal convert milliseconds in
667 * one, two or three digits 668 * one, two or three digits
668 */ 669 */
669 pp->nsec = 0;  670 pp->nsec = 0;
670 if (dp[6] == '.') { 671 if (dp[6] == '.') {
671 if (isdigit((int)dp[7])) { 672 if (isdigit((unsigned char)dp[7])) {
672 pp->nsec = (dp[7] - '0') * 100000000; 673 pp->nsec = (dp[7] - '0') * 100000000;
673 if (isdigit((int)dp[8])) { 674 if (isdigit((unsigned char)dp[8])) {
674 pp->nsec += (dp[8] - '0') * 10000000; 675 pp->nsec += (dp[8] - '0') * 10000000;
675 if (isdigit((int)dp[9])) { 676 if (isdigit((unsigned char)dp[9])) {
676 pp->nsec += (dp[9] - '0') * 1000000; 677 pp->nsec += (dp[9] - '0') * 1000000;
677 } 678 }
678 } 679 }
679 } 680 }
680 } 681 }
681 682
682 /* 683 /*
683 * Manipulating GPS timestamp in GPZDG as the seconds field 684 * Manipulating GPS timestamp in GPZDG as the seconds field
684 * is valid for next PPS tick. Just rolling back the second, 685 * is valid for next PPS tick. Just rolling back the second,
685 * minute and hour fields appopriately 686 * minute and hour fields appopriately
686 */ 687 */
687 if (cmdtypezdg) { 688 if (cmdtypezdg) {
688 if (pp->second == 0) { 689 if (pp->second == 0) {

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_oncore.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_oncore.c 2009/12/13 16:55:54 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_oncore.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_oncore.c,v 1.1.1.1 2009/12/13 16:55:54 kardel Exp $ */ 1/* $NetBSD: refclock_oncore.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * ---------------------------------------------------------------------------- 4 * ----------------------------------------------------------------------------
5 * "THE BEER-WARE LICENSE" (Revision 42): 5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you 6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think 7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
9 * ---------------------------------------------------------------------------- 9 * ----------------------------------------------------------------------------
10 * 10 *
11 * refclock_oncore.c 11 * refclock_oncore.c
12 * 12 *
13 * Driver for some of the various the Motorola Oncore GPS receivers. 13 * Driver for some of the various the Motorola Oncore GPS receivers.
14 * should work with Basic, PVT6, VP, UT, UT+, GT, GT+, SL, M12, M12+T 14 * should work with Basic, PVT6, VP, UT, UT+, GT, GT+, SL, M12, M12+T
@@ -1223,61 +1223,61 @@ oncore_read_config( @@ -1223,61 +1223,61 @@ oncore_read_config(
1223 return; 1223 return;
1224 } 1224 }
1225 1225
1226 mode = mask = 0; 1226 mode = mask = 0;
1227 lat_flg = long_flg = ht_flg = 0; 1227 lat_flg = long_flg = ht_flg = 0;
1228 while (fgets(line, 100, fd)) { 1228 while (fgets(line, 100, fd)) {
1229 1229
1230 /* Remove comments */ 1230 /* Remove comments */
1231 if ((cp = strchr(line, '#'))) 1231 if ((cp = strchr(line, '#')))
1232 *cp = '\0'; 1232 *cp = '\0';
1233 1233
1234 /* Remove trailing space */ 1234 /* Remove trailing space */
1235 for (i = strlen(line); 1235 for (i = strlen(line);
1236 i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]); 1236 i > 0 && isascii((unsigned char)line[i - 1]) && isspace((unsigned char)line[i - 1]);
1237 ) 1237 )
1238 line[--i] = '\0'; 1238 line[--i] = '\0';
1239 1239
1240 /* Remove leading space */ 1240 /* Remove leading space */
1241 for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++) 1241 for (cc = line; *cc && isascii((unsigned char)*cc) && isspace((unsigned char)*cc); cc++)
1242 continue; 1242 continue;
1243 1243
1244 /* Stop if nothing left */ 1244 /* Stop if nothing left */
1245 if (!*cc) 1245 if (!*cc)
1246 continue; 1246 continue;
1247 1247
1248 /* Uppercase the command and find the arg */ 1248 /* Uppercase the command and find the arg */
1249 for (ca = cc; *ca; ca++) { 1249 for (ca = cc; *ca; ca++) {
1250 if (isascii((int)*ca)) { 1250 if (isascii((unsigned char)*ca)) {
1251 if (islower((int)*ca)) { 1251 if (islower((unsigned char)*ca)) {
1252 *ca = toupper(*ca); 1252 *ca = toupper((unsigned char)*ca);
1253 } else if (isspace((int)*ca) || (*ca == '=')) 1253 } else if (isspace((unsigned char)*ca) || (*ca == '='))
1254 break; 1254 break;
1255 } 1255 }
1256 } 1256 }
1257 1257
1258 /* Remove space (and possible =) leading the arg */ 1258 /* Remove space (and possible =) leading the arg */
1259 for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++) 1259 for (; *ca && isascii((unsigned char)*ca) && (isspace((unsigned char)*ca) || (*ca == '=')); ca++)
1260 continue; 1260 continue;
1261 1261
1262 if (!strncmp(cc, "STATUS", (size_t) 6) || !strncmp(cc, "SHMEM", (size_t) 5)) { 1262 if (!strncmp(cc, "STATUS", (size_t) 6) || !strncmp(cc, "SHMEM", (size_t) 5)) {
1263 instance->shmem_fname = estrdup(ca); 1263 instance->shmem_fname = estrdup(ca);
1264 continue; 1264 continue;
1265 } 1265 }
1266 1266
1267 /* Uppercase argument as well */ 1267 /* Uppercase argument as well */
1268 for (cp = ca; *cp; cp++) 1268 for (cp = ca; *cp; cp++)
1269 if (isascii((int)*cp) && islower((int)*cp)) 1269 if (isascii((unsigned char)*cp) && islower((unsigned char)*cp))
1270 *cp = toupper(*cp); 1270 *cp = toupper((unsigned char)*cp);
1271 1271
1272 if (!strncmp(cc, "LAT", (size_t) 3)) { 1272 if (!strncmp(cc, "LAT", (size_t) 3)) {
1273 f1 = f2 = f3 = 0; 1273 f1 = f2 = f3 = 0;
1274 sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3); 1274 sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3);
1275 sign = 1; 1275 sign = 1;
1276 if (f1 < 0) { 1276 if (f1 < 0) {
1277 f1 = -f1; 1277 f1 = -f1;
1278 sign = -1; 1278 sign = -1;
1279 } 1279 }
1280 instance->ss_lat = sign*1000*(fabs(f3) + 60*(fabs(f2) + 60*f1)); /*miliseconds*/ 1280 instance->ss_lat = sign*1000*(fabs(f3) + 60*(fabs(f2) + 60*f1)); /*miliseconds*/
1281 lat_flg++; 1281 lat_flg++;
1282 } else if (!strncmp(cc, "LON", (size_t) 3)) { 1282 } else if (!strncmp(cc, "LON", (size_t) 3)) {
1283 f1 = f2 = f3 = 0; 1283 f1 = f2 = f3 = 0;
@@ -2887,27 +2887,27 @@ oncore_msg_Cj_id( @@ -2887,27 +2887,27 @@ oncore_msg_Cj_id(
2887 2887
2888 /* next, the Firmware Version and Revision numbers */ 2888 /* next, the Firmware Version and Revision numbers */
2889 2889
2890 instance->version = atoi((char *) &instance->Cj[83]); 2890 instance->version = atoi((char *) &instance->Cj[83]);
2891 instance->revision = atoi((char *) &instance->Cj[111]); 2891 instance->revision = atoi((char *) &instance->Cj[111]);
2892 2892
2893 /* from model number decide which Oncore this is, 2893 /* from model number decide which Oncore this is,
2894 and then the number of channels */ 2894 and then the number of channels */
2895 2895
2896 for (cp= (char *) &instance->Cj[160]; *cp == ' '; cp++) /* start right after 'Model #' */ 2896 for (cp= (char *) &instance->Cj[160]; *cp == ' '; cp++) /* start right after 'Model #' */
2897 ; 2897 ;
2898 cp1 = cp; 2898 cp1 = cp;
2899 cp2 = Model; 2899 cp2 = Model;
2900 for (; !isspace((int)*cp) && cp-cp1 < 20; cp++, cp2++) 2900 for (; !isspace((unsigned char)*cp) && cp-cp1 < 20; cp++, cp2++)
2901 *cp2 = *cp; 2901 *cp2 = *cp;
2902 *cp2 = '\0'; 2902 *cp2 = '\0';
2903 2903
2904 cp = 0; 2904 cp = 0;
2905 if (!strncmp(Model, "PVT6", (size_t) 4)) { 2905 if (!strncmp(Model, "PVT6", (size_t) 4)) {
2906 cp = "PVT6"; 2906 cp = "PVT6";
2907 instance->model = ONCORE_PVT6; 2907 instance->model = ONCORE_PVT6;
2908 } else if (Model[0] == 'A') { 2908 } else if (Model[0] == 'A') {
2909 cp = "Basic"; 2909 cp = "Basic";
2910 instance->model = ONCORE_BASIC; 2910 instance->model = ONCORE_BASIC;
2911 } else if (Model[0] == 'B' || !strncmp(Model, "T8", (size_t) 2)) { 2911 } else if (Model[0] == 'B' || !strncmp(Model, "T8", (size_t) 2)) {
2912 cp = "VP"; 2912 cp = "VP";
2913 instance->model = ONCORE_VP; 2913 instance->model = ONCORE_VP;

cvs diff -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/refclock_parse.c (expand / switch to unified diff)

--- src/external/bsd/ntp/dist/ntpd/refclock_parse.c 2009/12/13 16:56:00 1.1.1.1
+++ src/external/bsd/ntp/dist/ntpd/refclock_parse.c 2009/12/14 00:46:21 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refclock_parse.c,v 1.1.1.1 2009/12/13 16:56:00 kardel Exp $ */ 1/* $NetBSD: refclock_parse.c,v 1.2 2009/12/14 00:46:21 christos Exp $ */
2 2
3/* 3/*
4 * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.81 2009/05/01 10:15:29 kardel RELEASE_20090105_A 4 * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.81 2009/05/01 10:15:29 kardel RELEASE_20090105_A
5 * 5 *
6 * refclock_parse.c,v 4.81 2009/05/01 10:15:29 kardel RELEASE_20090105_A 6 * refclock_parse.c,v 4.81 2009/05/01 10:15:29 kardel RELEASE_20090105_A
7 * 7 *
8 * generic reference clock driver for several DCF/GPS/MSF/... receivers 8 * generic reference clock driver for several DCF/GPS/MSF/... receivers
9 * 9 *
10 * PPS notes: 10 * PPS notes:
11 * On systems that support PPSAPI (RFC2783) PPSAPI is the 11 * On systems that support PPSAPI (RFC2783) PPSAPI is the
12 * preferred interface. 12 * preferred interface.
13 * 13 *
14 * Optionally make use of a STREAMS module for input processing where 14 * Optionally make use of a STREAMS module for input processing where
@@ -1480,27 +1480,27 @@ mkreadable( @@ -1480,27 +1480,27 @@ mkreadable(
1480 1480
1481 if (blen < 4) 1481 if (blen < 4)
1482 return (char *)0; /* don't bother with mini buffers */ 1482 return (char *)0; /* don't bother with mini buffers */
1483 1483
1484 endb = buffer + blen - 4; 1484 endb = buffer + blen - 4;
1485 1485
1486 blen--; /* account for '\0' */ 1486 blen--; /* account for '\0' */
1487 1487
1488 while (blen && srclen--) 1488 while (blen && srclen--)
1489 { 1489 {
1490 if (!hex && /* no binary only */ 1490 if (!hex && /* no binary only */
1491 (*src != '\\') && /* no plain \ */ 1491 (*src != '\\') && /* no plain \ */
1492 (*src != '"') && /* no " */ 1492 (*src != '"') && /* no " */
1493 isprint((int)*src)) /* only printables */ 1493 isprint((unsigned char)*src)) /* only printables */
1494 { /* they are easy... */ 1494 { /* they are easy... */
1495 *buffer++ = *src++; 1495 *buffer++ = *src++;
1496 blen--; 1496 blen--;
1497 } 1497 }
1498 else 1498 else
1499 { 1499 {
1500 if (blen < 4) 1500 if (blen < 4)
1501 { 1501 {
1502 while (blen--) 1502 while (blen--)
1503 { 1503 {
1504 *buffer++ = '.'; 1504 *buffer++ = '.';
1505 } 1505 }
1506 *buffer = '\0'; 1506 *buffer = '\0';