aboutsummaryrefslogtreecommitdiff
path: root/ntpd/ntp_filegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'ntpd/ntp_filegen.c')
-rw-r--r--ntpd/ntp_filegen.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/ntpd/ntp_filegen.c b/ntpd/ntp_filegen.c
index 59a1d91bae6e..932d1b6f1231 100644
--- a/ntpd/ntp_filegen.c
+++ b/ntpd/ntp_filegen.c
@@ -13,7 +13,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <stdio.h>
@@ -55,6 +55,25 @@ static int valid_fileref P((char *, char *));
static FILEGEN *filegen_unregister P((char *));
#endif /* UNUSED */
+static void filegen_init P((char *, const char *, FILEGEN *));
+
+/*
+ * filegen_init
+ */
+
+static void
+filegen_init(char *prefix, const char *basename, FILEGEN *fp)
+{
+ fp->fp = NULL;
+ fp->prefix = prefix; /* Yes, this is TOTALLY lame! */
+ fp->basename = (char*)emalloc(strlen(basename) + 1);
+ strcpy(fp->basename, basename);
+ fp->id = 0;
+ fp->type = FILEGEN_DAY;
+ fp->flag = FGEN_FLAG_LINK; /* not yet enabled !!*/
+}
+
+
/*
* open a file generation according to the current settings of gen
* will also provide a link to basename if requested to do so
@@ -169,7 +188,8 @@ filegen_open(
free(savename);
} else {
/*
- * there is at least a second link tpo this file
+ * there is at least a second link to
+ * this file.
* just remove the conflicting one
*/
if (
@@ -335,6 +355,11 @@ filegen_setup(
* reopen new file generation file on change of generation id
*/
if (gen->fp == NULL || gen->id != new_gen) {
+#if DEBUG
+ if (debug)
+ printf("filegen %0x %lu %lu %lu\n", gen->type, now,
+ gen->id, new_gen);
+#endif
filegen_open(gen, new_gen);
}
}
@@ -477,6 +502,7 @@ filegen_get(
void
filegen_register(
+ char *prefix,
const char *name,
FILEGEN *filegen
)
@@ -487,6 +513,9 @@ filegen_register(
if (debug > 3)
printf("filegen_register(\"%s\",%x)\n", name, (u_int)filegen);
#endif
+
+ filegen_init(prefix, name, filegen);
+
while (*f) {
if ((*f)->name == name || strcmp(name, (*f)->name) == 0) {
#ifdef XXX /* this gives the Alpha compiler fits */