Add fopen_node_path

This commit is contained in:
Andrew Pamment 2018-10-24 20:08:52 +10:00
parent eb8e509ac0
commit 03c8db54ab
2 changed files with 10 additions and 1 deletions

View File

@ -281,6 +281,7 @@ extern void **ptr_vector_ptrs(struct ptr_vector *vec);
extern void **consume_ptr_vector(struct ptr_vector *vec); extern void **consume_ptr_vector(struct ptr_vector *vec);
extern void destroy_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 FILE *fopen_bbs_path(const char *filename, const char *mode);
extern FILE *fopen_node_path(const char *filename, const char *mode);
extern char *str_replace(const char *orig, const char *rep, const char *with); extern char *str_replace(const char *orig, const char *rep, const char *with);
extern int copy_file(char *src, char *dest); extern int copy_file(char *src, char *dest);

View File

@ -12,6 +12,7 @@
#include "bbs.h" #include "bbs.h"
extern struct bbs_config conf; extern struct bbs_config conf;
extern int mynode;
void die(const char *msg) { void die(const char *msg) {
dolog(msg); dolog(msg);
@ -241,5 +242,12 @@ FILE *fopen_bbs_path(const char *filename, const char *mode) {
snprintf(buffer, PATH_MAX, "%s/%s", conf.bbs_path, filename); snprintf(buffer, PATH_MAX, "%s/%s", conf.bbs_path, filename);
return fopen(buffer, mode); return fopen(buffer, mode);
}
FILE *fopen_node_path(const char *filename, const char *mode) {
char buffer[PATH_MAX];
snprintf(buffer, PATH_MAX, "%s/node%d/%s", conf.bbs_path, mynode, filename);
return fopen(buffer, mode);
} }