Use fopen_bbs_path in a couple of places.
Just an example of how it may be used. Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
parent
2f79c4a590
commit
bdde1aa621
54
src/bbs.c
54
src/bbs.c
@ -725,15 +725,10 @@ void record_last10_callers(struct user_record *user) {
|
||||
void display_last10_callers(struct user_record *user) {
|
||||
struct last10_callers callers[10];
|
||||
|
||||
char last10_path[PATH_MAX];
|
||||
|
||||
int i, z;
|
||||
int i = 0;
|
||||
struct tm l10_time;
|
||||
|
||||
snprintf(last10_path, PATH_MAX, "%s/last10v2.dat", conf.bbs_path);
|
||||
|
||||
FILE *fptr = fopen(last10_path, "rb");
|
||||
time_t l10_timet;
|
||||
FILE *fptr = fopen_bbs_path("last10v2.dat", "rb");
|
||||
|
||||
s_printf("\e[2J\e[1;1H");
|
||||
|
||||
@ -741,7 +736,6 @@ void display_last10_callers(struct user_record *user) {
|
||||
s_printf(get_string(3));
|
||||
|
||||
if (fptr != NULL) {
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (fread(&callers[i], sizeof(struct last10_callers), 1, fptr) < 1) {
|
||||
break;
|
||||
@ -749,12 +743,10 @@ void display_last10_callers(struct user_record *user) {
|
||||
}
|
||||
|
||||
fclose(fptr);
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
for (z = 0; z < i; z++) {
|
||||
l10_timet = callers[z].time;
|
||||
for (int z = 0; z < i; z++) {
|
||||
time_t l10_timet = callers[z].time;
|
||||
localtime_r(&l10_timet, &l10_time);
|
||||
if (conf.date_style == 1) {
|
||||
s_printf(get_string(4), callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100, (callers[z].calls == 1 ? 'N' : ' '));
|
||||
@ -789,7 +781,6 @@ void automessage_write() {
|
||||
FILE *fptr;
|
||||
char automsg[450];
|
||||
char buffer[76];
|
||||
char automsg_path[PATH_MAX];
|
||||
int i;
|
||||
struct tm timenow;
|
||||
time_t timen;
|
||||
@ -813,9 +804,7 @@ void automessage_write() {
|
||||
strlcat(automsg, "\r\n", sizeof automsg);
|
||||
}
|
||||
|
||||
snprintf(automsg_path, PATH_MAX, "%s/automessage.txt", conf.bbs_path);
|
||||
|
||||
fptr = fopen(automsg_path, "w");
|
||||
fptr = fopen_bbs_path("automessage.txt", "w");
|
||||
if (fptr) {
|
||||
fwrite(automsg, strlen(automsg), 1, fptr);
|
||||
fclose(fptr);
|
||||
@ -826,32 +815,23 @@ void automessage_write() {
|
||||
}
|
||||
|
||||
void automessage_display() {
|
||||
struct stat s;
|
||||
FILE *fptr;
|
||||
char buffer[90];
|
||||
char automsg_path[PATH_MAX];
|
||||
int i;
|
||||
s_printf("\r\n\r\n");
|
||||
|
||||
snprintf(automsg_path, PATH_MAX, "%s/automessage.txt", conf.bbs_path);
|
||||
|
||||
if (stat(automsg_path, &s) == 0) {
|
||||
fptr = fopen(automsg_path, "r");
|
||||
if (fptr) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
memset(buffer, 0, 90);
|
||||
fgets(buffer, 88, fptr);
|
||||
buffer[strlen(buffer) - 1] = '\r';
|
||||
buffer[strlen(buffer)] = '\n';
|
||||
|
||||
s_printf(buffer);
|
||||
}
|
||||
fclose(fptr);
|
||||
} else {
|
||||
dolog("Error opening automessage.txt");
|
||||
}
|
||||
} else {
|
||||
FILE *fptr = fopen_bbs_path("automessage.txt", "r");
|
||||
if (fptr == NULL) {
|
||||
dolog("Error opening automessage.txt");
|
||||
s_printf(get_string(17));
|
||||
} else {
|
||||
for (i = 0; i < 5; i++) {
|
||||
memset(buffer, 0, 90);
|
||||
fgets(buffer, 88, fptr);
|
||||
buffer[strlen(buffer) - 1] = '\r';
|
||||
buffer[strlen(buffer)] = '\n';
|
||||
s_printf(buffer);
|
||||
}
|
||||
fclose(fptr);
|
||||
}
|
||||
s_printf(get_string(6));
|
||||
s_getc();
|
||||
|
Reference in New Issue
Block a user