]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added tracked_fopen() which is a fopen registered in resource database.
authorMartin Mares <mj@ucw.cz>
Mon, 6 Dec 1999 13:43:47 +0000 (13:43 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 6 Dec 1999 13:43:47 +0000 (13:43 +0000)
Will be used for log files.

sysdep/unix/io.c

index f465da454b1273c4b6ed501ef9ef3c10a367aa64..7d6a6f22e23cbe97040e61c4ca0748530e9edda0 100644 (file)
@@ -50,6 +50,51 @@ random_u32(void)
   return (rand_low & 0xffff) | ((rand_high & 0xffff) << 16);
 }
 
+/*
+ *     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
  */