FreeBSD/contrib/ntp/ntpd/refclock_tpro.c
/*
 * tpro_start - open the TPRO device and initialize data for processing
 */
open the TPRO device and initialize data for processing
open the TPRO device and initialize data for processing
static int
tpro_start(
	int unit,
	struct peer *peer
	)
{
	register struct tprounit *up;
	struct refclockproc *pp;
	char device[20];
	int fd;
	snprintf(device, sizeof(device), DEVICE, unit);
	fd = open(device, O_RDONLY | O_NDELAY, 0777);
	if (fd == -1) {
		msyslog(LOG_ERR, "tpro_start: open of %s: %m", device);
		return (0);
	}
	up = emalloc_zero(sizeof(*up));
	pp = peer->procptr;
	pp->io.clock_recv = noentry;
	pp->io.srcclock = peer;
	pp->io.datalen = 0;
	pp->io.fd = fd;
	pp->unitptr = up;
	peer->precision = PRECISION;
	pp->clockdesc = DESCRIPTION;
	memcpy((char *)&pp->refid, REFID, 4);
	return (1);
}
static int tpro_start ( int unit , struct peer * peer ) { register struct tprounit * up ; struct refclockproc * pp ; char device [ 20 ] ; int fd ; snprintf ( device , sizeof ( device ) , DEVICE , unit ) ; fd = open ( device , O_RDONLY | O_NDELAY , 0777 ) ; if ( fd == -1 ) { msyslog ( LOG_ERR , " " , device ) ; return ( 0 ) ; } up = emalloc_zero ( sizeof ( * up ) ) ; pp = peer -> procptr ; pp -> io . clock_recv = noentry ; pp -> io . srcclock = peer ; pp -> io . datalen = 0 ; pp -> io . fd = fd ; pp -> unitptr = up ; peer -> precision = PRECISION ; pp -> clockdesc = DESCRIPTION ; memcpy ( ( char * ) & pp -> refid , REFID , 4 ) ; return ( 1 ) ; }
tpro_start - open the TPRO device and initialize data for processing
tpro_start - open the TPRO device and initialize data for processing
/*
	 * Open TPRO device
	 */ /*
	 * Allocate and initialize unit structure
	 */ /*
	 * Initialize miscellaneous peer variables
	 */