#endif
#ifdef DOSYNCTODR
-#if !defined(VMS)
-#include <sys/resource.h>
-#endif /* VMS */
+# if !defined(VMS)
+# include <sys/resource.h>
+# endif /* VMS */
#endif
#if defined(VMS)
-#include <descrip.h>
+# include <descrip.h>
#endif /* VMS */
/*
* Statistics file stuff
*/
#ifndef NTP_VAR
-#ifndef SYS_WINNT
-#define NTP_VAR "/var/NTP/" /* NOTE the trailing '/' */
-#else
-#define NTP_VAR "c:\\var\\ntp\\" /* NOTE the trailing '\\' */
-#endif /* SYS_WINNT */
+# ifndef SYS_WINNT
+# define NTP_VAR "/var/NTP/" /* NOTE the trailing '/' */
+# else
+# define NTP_VAR "c:\\var\\ntp\\" /* NOTE the trailing '\\' */
+# endif /* SYS_WINNT */
#endif
#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
+# define MAXPATHLEN 256
#endif
static char statsdir[MAXPATHLEN] = NTP_VAR;
*/
double old_drift;
+static void setup_FILEGEN P((FILEGEN *fp));
+
+/*
+ * setup_FILEGEN
+ */
+
+static void
+setup_FILEGEN(FILEGEN *fp)
+{
+ fp->fp = NULL;
+ fp->prefix = &statsdir[0];
+ fp->basename = (char*)emalloc(1);
+ fp->basename[0] = 0;
+ fp->id = 0;
+ fp->type = FILEGEN_DAY;
+ fp->flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+}
+
/*
* init_util - initialize the utilities
*/
stats_temp_file = 0;
key_file_name = 0;
-#define PEERNAME "peerstats"
-#define LOOPNAME "loopstats"
-#define CLOCKNAME "clockstats"
-#define RAWNAME "rawstats"
-#define STANAME "systats"
-#ifdef OPENSSL
-#define CRYPTONAME "cryptostats"
-#endif /* OPENSSL */
-
- peerstats.fp = NULL;
- peerstats.prefix = &statsdir[0];
- peerstats.basename = (char*)emalloc(strlen(PEERNAME)+1);
- strcpy(peerstats.basename, PEERNAME);
- peerstats.id = 0;
- peerstats.type = FILEGEN_DAY;
- peerstats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+ setup_FILEGEN(&peerstats);
filegen_register("peerstats", &peerstats);
-
- loopstats.fp = NULL;
- loopstats.prefix = &statsdir[0];
- loopstats.basename = (char*)emalloc(strlen(LOOPNAME)+1);
- strcpy(loopstats.basename, LOOPNAME);
- loopstats.id = 0;
- loopstats.type = FILEGEN_DAY;
- loopstats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+
+ setup_FILEGEN(&loopstats);
filegen_register("loopstats", &loopstats);
- clockstats.fp = NULL;
- clockstats.prefix = &statsdir[0];
- clockstats.basename = (char*)emalloc(strlen(CLOCKNAME)+1);
- strcpy(clockstats.basename, CLOCKNAME);
- clockstats.id = 0;
- clockstats.type = FILEGEN_DAY;
- clockstats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+ setup_FILEGEN(&clockstats);
filegen_register("clockstats", &clockstats);
- rawstats.fp = NULL;
- rawstats.prefix = &statsdir[0];
- rawstats.basename = (char*)emalloc(strlen(RAWNAME)+1);
- strcpy(rawstats.basename, RAWNAME);
- rawstats.id = 0;
- rawstats.type = FILEGEN_DAY;
- rawstats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+ setup_FILEGEN(&rawstats);
filegen_register("rawstats", &rawstats);
- sysstats.fp = NULL;
- sysstats.prefix = &statsdir[0];
- sysstats.basename = (char*)emalloc(strlen(STANAME)+1);
- strcpy(sysstats.basename, STANAME);
- sysstats.id = 0;
- sysstats.type = FILEGEN_DAY;
- sysstats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+ setup_FILEGEN(&sysstats);
filegen_register("sysstats", &sysstats);
#ifdef OPENSSL
- cryptostats.fp = NULL;
- cryptostats.prefix = &statsdir[0];
- cryptostats.basename = (char*)emalloc(strlen(CRYPTONAME)+1);
- strcpy(cryptostats.basename, CRYPTONAME);
- cryptostats.id = 0;
- cryptostats.type = FILEGEN_DAY;
- cryptostats.flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+ setup_FILEGEN(&cryptostats);
filegen_register("cryptostats", &cryptostats);
#endif /* OPENSSL */
-#undef PEERNAME
-#undef LOOPNAME
-#undef CLOCKNAME
-#undef RAWNAME
-#undef STANAME
-#ifdef OPENSSL
-#undef CRYPTONAME
-#endif /* OPENSSL */
}
#ifndef NO_RENAME
(void) rename(stats_temp_file, stats_drift_file);
#else
- /* we have no rename NFS of ftp in use*/
+ /* we have no rename NFS of ftp in use */
if ((fp = fopen(stats_drift_file, "w")) == NULL) {
msyslog(LOG_ERR, "can't open %s: %m",
stats_drift_file);