Add fopen_bbs_path function
This commit is contained in:
parent
bdde1aa621
commit
4ba7eda791
@ -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);
|
||||
|
12
src/util.c
12
src/util.c
@ -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);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user