mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 08:38:42 +00:00
Added tracked_fopen() which is a fopen registered in resource database.
Will be used for log files.
This commit is contained in:
parent
34350a5270
commit
a9c986f981
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user