/*
 *  $Header: /home/faui43/inf4/i4guru/kardel/RCS/dcf77.h,v 1.2 1992/03/13 16:49:24 kardel Exp $
 *
 *  $Id: dcf77.h,v 1.2 1992/03/13 16:49:24 kardel Exp $
 *
 *  Copyright (c) 1989,1990,1991,1992
 *  Frank Kardel Friedrich-Alexander Universitaet Erlangen-Nuernberg
 *                                    
 *  This code can be modified and used freely provided that the
 *  credits remain intact.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * $Log: dcf77.h,v $
 * Revision 1.2  1992/03/13  16:49:24  kardel
 * legal terms changed
 *
 * Revision 1.1  1991/12/16  10:59:51  kardel
 * Initial revision
 *
 */

#ifndef lint
  static char dcfhrcsid[]="$Id: dcf77.h,v 1.2 1992/03/13 16:49:24 kardel Exp $ FAU";
#endif

#define DCFB_ANNOUNCE           0x0001
#define DCFB_POWERUP            0x0002
#define DCFB_NOSYNC             0x0004
#define DCFB_DST                0x0008
#define DCF_STATEFLAGS         (DCFB_ANNOUNCE|DCFB_POWERUP|DCFB_NOSYNC|\
				 DCFB_DST)

#define DCF_POWERUP(x)           ((x) & DCFB_POWERUP)
#define DCF_NOSYNC(x)            (((x) & (DCFB_POWERUP|DCFB_NOSYNC)) == DCFB_NOSYNC)
#define DCF_SYNC(x)              (((x) & (DCFB_POWERUP|DCFB_NOSYNC)) == 0)
#define DCF_ANNOUNCE(x)          (((x) & DCFB_ANNOUNCE) && !DCF_POWERUP(x))
#define DCF_DST(x)               (!DCF_POWERUP(x) && ((x) & DCFB_DST))

#define DCF_SYNC_ALWAYS        0x0010
#define DCF_SYNC_NOSYNC        0x0020
#define DCF_SYNC_DCF           0x0040
#define DCF_STAT_FILTER        0x0080
#define DCF_MODEFLAGS          (DCF_SYNC_DCF|DCF_SYNC_NOSYNC|DCF_SYNC_ALWAYS|DCF_STAT_FILTER)

struct dcfctl
{
  time_t dcf_maxdelta;
  long   dcf_musecdisp;
  int    dcf_flags;
};

typedef struct dcfctl dcfctl_t;

#define DCFIOC_GETSTAT         (('A'<<8)|1)
#define DCFIOC_SETSTAT         (('A'<<8)|2)

struct dcftime
{
  struct timeval dcf_time;	/* DCF timestamp */
  struct timeval dcf_stime;	/* received timestamp */
  int            dcf_flags;	/* current flags */
  long           dcf_usecerror;	/* sampled/filtered usec error */
  long           dcf_usecdisp;	/* sample usecdispersion */
};

typedef struct dcftime dcftime_t;
