This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
magicka/main_menu.c

122 lines
2.4 KiB
C
Raw Normal View History

2016-03-22 01:48:59 +00:00
#include <stdio.h>
#include <string.h>
2016-03-27 00:33:43 +00:00
#include <stdlib.h>
2016-03-22 01:48:59 +00:00
#include <ctype.h>
2016-03-23 06:31:00 +00:00
#include <sys/stat.h>
2016-03-22 01:48:59 +00:00
#include "bbs.h"
#include "lua/lua.h"
#include "lua/lualib.h"
#include "lua/lauxlib.h"
2016-03-22 01:48:59 +00:00
extern struct bbs_config conf;
2017-04-22 01:53:44 +00:00
extern struct user_record *gUser;
extern int mynode;
2016-03-22 01:48:59 +00:00
2017-04-12 06:38:33 +00:00
void display_bulletins() {
int i;
char buffer[PATH_MAX];
2017-04-12 12:34:08 +00:00
struct stat s;
2017-04-12 06:38:33 +00:00
i = 0;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
while (stat(buffer, &s) == 0) {
sprintf(buffer, "bulletin%d", i);
s_displayansi(buffer);
s_printf(get_string(6));
s_getc();
i++;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
}
}
2017-04-22 01:53:44 +00:00
void active_nodes() {
int i;
struct stat s;
char buffer[PATH_MAX];
FILE *fptr;
for (i=0;i<conf.nodes;i++) {
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, i+1);
if (stat(buffer, &s) == 0) {
fptr = fopen(buffer, "r");
if (fptr) {
fgets(buffer, PATH_MAX, fptr);
fclose(fptr);
chomp(buffer);
s_printf(get_string(216), i+1, buffer);
}
}
}
}
void send_node_msg() {
char buffer[PATH_MAX];
char msg[257];
int nodetomsg = 0;
struct stat s;
FILE *fptr;
2017-04-22 02:08:31 +00:00
s_printf(get_string(217));
2017-04-22 01:53:44 +00:00
active_nodes();
s_readstring(buffer, 4);
nodetomsg = atoi(buffer);
if (nodetomsg < 1 || nodetomsg > conf.nodes) {
s_printf(get_string(218));
return;
}
s_printf(get_string(219));
s_readstring(msg, 256);
snprintf(buffer, PATH_MAX, "%s/node%d", conf.bbs_path, nodetomsg);
if (stat(buffer, &s) != 0) {
mkdir(buffer, 0755);
}
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, nodetomsg);
fptr = fopen(buffer, "a");
if (fptr) {
fprintf(fptr, get_string(220), gUser->loginname, mynode, msg);
fclose(fptr);
}
}
2017-04-12 06:38:33 +00:00
void display_textfiles() {
int i;
char buffer[5];
if (conf.text_file_count > 0) {
while(1) {
s_printf(get_string(143));
s_printf(get_string(144));
for (i=0;i<conf.text_file_count;i++) {
s_printf(get_string(145), i, conf.text_files[i]->name);
}
s_printf(get_string(146));
s_printf(get_string(147));
s_readstring(buffer, 4);
if (tolower(buffer[0]) != 'q') {
i = atoi(buffer);
if (i >= 0 && i < conf.text_file_count) {
s_printf("\r\n");
s_displayansi_p(conf.text_files[i]->path);
s_printf(get_string(6));
s_getc();
s_printf("\r\n");
}
} else {
break;
}
}
} else {
s_printf(get_string(148));
s_printf(get_string(6));
s_getc();
}
2017-04-12 12:34:08 +00:00
}