FreeBSD/contrib/ntp/ntpd/refclock_arc.c
/*
Normal event handler.

Take first character off queue and send to clock if not a null.

Shift characters down and put a null on the end.

We assume that there is no parallelism so no race condition, but even
if there is nothing bad will happen except that we might send some bad
data to the clock once in a while.
*/
Normal event handler.
Take first character off queue and send to clock if not a null.

Shift characters down and put a null on the end.

We assume that there is no parallelism so no race condition, but even
if there is nothing bad will happen except that we might send some bad
data to the clock once in a while.
Normal event handler . Take first character off queue and send to clock if not a null . Shift characters down and put a null on the end . We assume that there is no parallelism so no race condition but even if there is nothing bad will happen except that we might send some bad data to the clock once in a while .
static void
arc_event_handler(
	struct peer *peer
	)
{
	struct refclockproc *pp = peer->procptr;
	register struct arcunit *up = pp->unitptr;
	int i;
	char c;
#ifdef DEBUG
	if(debug > 2) { printf("arc: arc_event_handler() called.\n"); }
#endif
	c = up->cmdqueue[0];       
	for(i = 0; i < CMDQUEUELEN; ++i)
	{ up->cmdqueue[i] = up->cmdqueue[i+1]; }
	if(c != '\0') {
		if(write(pp->io.fd, &c, 1) != 1) {
			msyslog(LOG_NOTICE, "ARCRON: write to fd %d failed", pp->io.fd);
		}
#ifdef DEBUG
		else if(debug) { printf("arc: sent `%2.2x', fd %d.\n", c, pp->io.fd); }
#endif
	}
	ENQUEUE(up);
}
static void arc_event_handler ( struct peer * peer ) { struct refclockproc * pp = peer -> procptr ; register struct arcunit * up = pp -> unitptr ; int i ; char c ; #ifdef DEBUG if ( debug > 2 ) { printf ( " \n " ) ; } #endif c = up -> cmdqueue [ 0 ] ; for ( i = 0 ; i < CMDQUEUELEN ; ++ i ) { up -> cmdqueue [ i ] = up -> cmdqueue [ i + 1 ] ; } if ( c != ' \0 ' ) { if ( write ( pp -> io . fd , & c , 1 ) != 1 ) { msyslog ( LOG_NOTICE , " " , pp -> io . fd ) ; } #ifdef DEBUG else if ( debug ) { printf ( " \n " , c , pp -> io . fd ) ; } #endif } ENQUEUE ( up ) ; }
Normal event handler.
Normal event handler .
/* Next char to be sent. */ /* Shift down characters, shifting trailing \0 in at end. */ /* Don't send '\0' characters. */