Add fopen_bbs_path function

This commit is contained in:
Andrew Pamment 2018-10-20 09:50:28 +10:00
parent bdde1aa621
commit 4ba7eda791
2 changed files with 13 additions and 0 deletions

View File

@ -280,6 +280,7 @@ extern void ptr_vector_apply(struct ptr_vector *vec, void (*f)(void *arg));
extern void **ptr_vector_ptrs(struct ptr_vector *vec);
extern void **consume_ptr_vector(struct ptr_vector *vec);
extern void destroy_ptr_vector(struct ptr_vector *vec);
extern FILE *fopen_bbs_path(const char *filename, const char *mode);
extern char *str_replace(const char *orig, const char *rep, const char *with);
extern int copy_file(char *src, char *dest);

View File

@ -7,9 +7,12 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "bbs.h"
extern struct bbs_config conf;
void die(const char *msg) {
dolog(msg);
exit(-1);
@ -231,3 +234,12 @@ void destroy_ptr_vector(struct ptr_vector *vec) {
vec->capacity = 0;
vec->len = 0;
}
FILE *fopen_bbs_path(const char *filename, const char *mode) {
char buffer[PATH_MAX];
snprintf(buffer, PATH_MAX, "%s/%s", conf.bbs_path, filename);
return fopen(buffer, mode);
}