We need access to resource in order to free it.
log_file:
text {
- FILE *f = tracked_fopen(new_config->pool, $1, "a");
- if (!f) cf_error("Unable to open log file `%s': %m", $1);
- $$ = f;
+ struct rfile *f = rf_open(new_config->pool, $1, "a");
+ if (!f) cf_error("Unable to open log file '%s': %m", $1);
+ $$ = rf_file(f);
}
| SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
| STDERR { $$ = stderr; }
mrtdump_base:
MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
| MRTDUMP text ';' {
- FILE *f = tracked_fopen(new_config->pool, $2, "a");
+ struct rfile *f = rf_open(new_config->pool, $2, "a");
if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
- new_config->mrtdump_file = fileno(f);
+ new_config->mrtdump_file = rf_fileno(f);
}
;
this to gen small latencies */
#define MAX_RX_STEPS 4
+
/*
* Tracked Files
*/
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);
}
struct pool;
struct iface;
struct birdsock;
+struct rfile;
/* main.c */
void io_loop(void);
void io_log_dump(void);
int sk_open_unix(struct birdsock *s, char *name);
-void *tracked_fopen(struct pool *, char *name, char *mode);
+struct rfile *rf_open(struct pool *, char *name, char *mode);
+void *rf_file(struct rfile *f);
+int rf_fileno(struct rfile *f);
void test_old_bird(char *path);
/* krt.c bits */