summaryrefslogtreecommitdiffstats
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-12-06 14:43:47 +0100
committerMartin Mares <mj@ucw.cz>1999-12-06 14:43:47 +0100
commita9c986f98116fef5c35d956e7a867be0735f3268 (patch)
tree562d1ca09b07381080c6e4a22dc288784aa5094d /sysdep/unix
parent34350a52700955d50895058d01b5407aea970e9b (diff)
downloadbird-a9c986f98116fef5c35d956e7a867be0735f3268.tar
bird-a9c986f98116fef5c35d956e7a867be0735f3268.zip
Added tracked_fopen() which is a fopen registered in resource database.
Will be used for log files.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index f465da4..7d6a6f2 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -51,6 +51,51 @@ random_u32(void)
}
/*
+ * Tracked Files
+ */
+
+struct rfile {
+ resource r;
+ FILE *f;
+};
+
+static void
+rf_free(resource *r)
+{
+ struct rfile *a = (struct rfile *) r;
+
+ fclose(a->f);
+}
+
+static void
+rf_dump(resource *r)
+{
+ struct rfile *a = (struct rfile *) r;
+
+ debug("(FILE *%p)\n", a->f);
+}
+
+static struct resclass rf_class = {
+ "FILE",
+ sizeof(struct rfile),
+ rf_free,
+ rf_dump
+};
+
+void *
+rfopen(pool *p, char *name, char *mode)
+{
+ FILE *f = fopen(name, mode);
+
+ if (f)
+ {
+ struct rfile *r = ralloc(p, &rf_class);
+ r->f = f;
+ }
+ return f;
+}
+
+/*
* Timers
*/