summaryrefslogtreecommitdiff
path: root/sysdep/unix/io.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-11-13 18:13:11 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-11-18 14:03:50 +0100
commitc68ba7d093e1fcf01fceb341438fc5dc95f93ac5 (patch)
treec823dff2a455da9635a4c669f0a7ea50fd91153a /sysdep/unix/io.c
parentd0b4597842ba1f65e5280529fca243ce5b5043fa (diff)
Unix: Refactor tracked files
We need access to resource in order to free it.
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r--sysdep/unix/io.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 4455fc19..8c9052a3 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -55,6 +55,7 @@
this to gen small latencies */
#define MAX_RX_STEPS 4
+
/*
* Tracked Files
*/
@@ -89,17 +90,29 @@ static struct resclass rf_class = {
NULL
};
-void *
-tracked_fopen(pool *p, char *name, char *mode)
+struct rfile *
+rf_open(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;
+ if (!f)
+ return NULL;
+
+ struct rfile *r = ralloc(p, &rf_class);
+ r->f = f;
+ return r;
+}
+
+void *
+rf_file(struct rfile *f)
+{
+ return f->f;
+}
+
+int
+rf_fileno(struct rfile *f)
+{
+ return fileno(f->f);
}