diff options
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r-- | sysdep/unix/io.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 786c6a56..f7a9e29f 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -54,6 +54,7 @@ this to gen small latencies */ #define MAX_RX_STEPS 4 + /* * Tracked Files */ @@ -88,19 +89,32 @@ 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); } + /** * DOC: Timers * @@ -478,6 +492,20 @@ tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t) strcpy(x, "<too-long>"); } +int +tm_format_real_time(char *x, size_t max, const char *fmt, bird_clock_t t) +{ + struct tm tm; + + if (!localtime_r(&t, &tm)) + return 0; + + if (!strftime(x, max, fmt, &tm)) + return 0; + + return 1; +} + /** * DOC: Sockets |