From 2976a0e461da9777b23851eb37e285cbf1b8d6b1 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 30 Jul 2015 13:33:43 +0100 Subject: Add generation of private header and cause class files to include it --- src/utils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 7bab058..9e50a93 100644 --- a/src/utils.c +++ b/src/utils.c @@ -7,16 +7,27 @@ #include "options.h" #include "utils.h" -FILE *genb_fopen(const char *fname, const char *mode) +/* exported function documented in utils.h */ +char *genb_fpath(const char *fname) { char *fpath; int fpathl; - FILE *filef; fpathl = strlen(options->outdirname) + strlen(fname) + 2; fpath = malloc(fpathl); snprintf(fpath, fpathl, "%s/%s", options->outdirname, fname); + return fpath; +} + +/* exported function documented in utils.h */ +FILE *genb_fopen(const char *fname, const char *mode) +{ + char *fpath; + FILE *filef; + + fpath = genb_fpath(fname); + filef = fopen(fpath, mode); if (filef == NULL) { fprintf(stderr, "Error: unable to open file %s (%s)\n", @@ -29,6 +40,7 @@ FILE *genb_fopen(const char *fname, const char *mode) return filef; } + #ifdef NEED_STRNDUP char *strndup(const char *s, size_t n) -- cgit v1.2.3