More work on menusystem

This commit is contained in:
Andrew Pamment 2017-04-12 22:34:08 +10:00
parent a1190bc1d7
commit 109f59302a
24 changed files with 772 additions and 888 deletions

View File

@ -29,7 +29,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -34,7 +34,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -30,7 +30,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -34,7 +34,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && ./configure cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -29,7 +29,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -34,7 +34,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses cd deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -8,7 +8,7 @@ ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a CDK = deps/cdk-5-20161210/libcdk.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd

View File

@ -34,7 +34,7 @@ $(CDK):
cd deps/cdk-5.0-20161210/ && ./configure cd deps/cdk-5.0-20161210/ && ./configure
cd deps/cdk-5.0-20161210/ && $(MAKE) cd deps/cdk-5.0-20161210/ && $(MAKE)
OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o OBJ = deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o menus.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

BIN
ansis_default/logoff.ans Normal file

Binary file not shown.

25
bbs.c
View File

@ -822,18 +822,16 @@ tryagain:
record_last10_callers(user); record_last10_callers(user);
// main menu // main menu
if (conf->root_menu != NULL) { menu_system(conf.root_menu);
menu_system(conf->root_menu);
} else { do_logout();
main_menu(user);
}
dolog("%s is logging out, on node %d", user->loginname, mynode); dolog("%s is logging out, on node %d", user->loginname, mynode);
broadcast("%s is logging out, on node %d", user->loginname, mynode); broadcast("%s is logging out, on node %d", user->loginname, mynode);
disconnect("Log out"); disconnect("Log out");
} }
int do_logout() { void do_logout() {
char buffer[256]; char buffer[256];
struct stat s; struct stat s;
lua_State *L; lua_State *L;
@ -861,28 +859,15 @@ int do_logout() {
} }
if (do_internal_logout == 1) { if (do_internal_logout == 1) {
s_printf(get_string(53));
c = s_getc();
if (tolower(c) == 'y') {
s_displayansi("goodbye"); s_displayansi("goodbye");
ret = 1;
} else {
ret = 0;
}
} else { } else {
lua_getglobal(L, "logout"); lua_getglobal(L, "logout");
result = lua_pcall(L, 0, 1, 0); result = lua_pcall(L, 0, 0, 0);
if (result) { if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1)); dolog("Failed to run script: %s", lua_tostring(L, -1));
lua_close(L);
return 0;
} }
ret = lua_tointeger(L, -1);
lua_pop(L, 1);
lua_close(L); lua_close(L);
} }
return ret;
} }
void runbbs(int socket, char *ip) { void runbbs(int socket, char *ip) {

25
bbs.h
View File

@ -141,6 +141,7 @@ struct bbs_config {
struct fido_addr *main_aka; struct fido_addr *main_aka;
char *root_menu; char *root_menu;
char *menu_path;
char *external_editor_cmd; char *external_editor_cmd;
int external_editor_stdio; int external_editor_stdio;
int fork; int fork;
@ -236,7 +237,7 @@ extern char s_getc();
extern void disconnect(char *calledby); extern void disconnect(char *calledby);
extern void display_info(); extern void display_info();
extern void display_last10_callers(struct user_record *user); extern void display_last10_callers(struct user_record *user);
extern int do_logout(); extern void do_logout();
extern void gen_salt(char **s); extern void gen_salt(char **s);
extern char *hash_sha256(char *pass, char *salt); extern char *hash_sha256(char *pass, char *salt);
@ -248,21 +249,26 @@ extern void list_users(struct user_record *user);
extern void display_bulletins(); extern void display_bulletins();
extern void display_textfiles(); extern void display_textfiles();
extern void main_menu(struct user_record *user);
extern s_JamBase *open_jam_base(char *path); extern s_JamBase *open_jam_base(char *path);
extern void free_message_headers(struct msg_headers *msghs); extern void free_message_headers(struct msg_headers *msghs);
extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user); extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user);
extern void mail_scan(struct user_record *user); extern void mail_scan(struct user_record *user);
extern int mail_menu(struct user_record *user);
extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email); extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email);
extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email); extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email);
extern int msg_is_to(struct user_record *user, char *addressed_to, char *address, int type, int rn, int msgconf); extern int msg_is_to(struct user_record *user, char *addressed_to, char *address, int type, int rn, int msgconf);
extern int msg_is_from(struct user_record *user, char *addressed_from, char *address, int type, int rn, int msgconf); extern int msg_is_from(struct user_record *user, char *addressed_from, char *address, int type, int rn, int msgconf);
extern unsigned long generate_msgid(); extern unsigned long generate_msgid();
extern void read_mail(struct user_record *user); extern void read_mail(struct user_record *user);
extern void list_messages(struct user_record *user);
extern void choose_conference(struct user_record *user);
extern void choose_area(struct user_record *user);
extern void next_mail_conf(struct user_record *user);
extern void prev_mail_conf(struct user_record *user);
extern void next_mail_area(struct user_record *user);
extern void prev_mail_area(struct user_record *user);
extern void post_message(struct user_record *user);
extern int door_menu(struct user_record *user);
extern void rundoor(struct user_record *user, char *cmd, int stdio); extern void rundoor(struct user_record *user, char *cmd, int stdio);
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw); extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw);
@ -274,13 +280,22 @@ extern int mail_getemailcount(struct user_record *user);
extern void send_email(struct user_record *user); extern void send_email(struct user_record *user);
extern void list_emails(struct user_record *user); extern void list_emails(struct user_record *user);
extern int file_menu(struct user_record *user);
extern void download_zmodem(struct user_record *user, char *filename); extern void download_zmodem(struct user_record *user, char *filename);
extern void settings_menu(struct user_record *user); extern void settings_menu(struct user_record *user);
extern void upload_zmodem(struct user_record *user, char *upload_p); extern void upload_zmodem(struct user_record *user, char *upload_p);
extern int ttySetRaw(int fd, struct termios *prevTermios); extern int ttySetRaw(int fd, struct termios *prevTermios);
extern int do_upload(struct user_record *user, char *final_path); extern int do_upload(struct user_record *user, char *final_path);
extern int do_download(struct user_record *user, char *file); extern int do_download(struct user_record *user, char *file);
extern void choose_directory(struct user_record *user);
extern void choose_subdir(struct user_record *user);
extern void list_files(struct user_record *user);
extern void upload(struct user_record *user);
extern void download(struct user_record *user);
extern void clear_tagged_files();
extern void next_file_dir(struct user_record *user);
extern void prev_file_dir(struct user_record *user);
extern void next_file_sub(struct user_record *user);
extern void prev_file_sub(struct user_record *user);
extern void lua_push_cfunctions(lua_State *L); extern void lua_push_cfunctions(lua_State *L);

View File

@ -27,7 +27,7 @@ Broadcast Address = 192.168.1.255
IP Guard Enable = true IP Guard Enable = true
IP Guard Timeout = 120 IP Guard Timeout = 120
IP Guard Tries = 4 IP Guard Tries = 4
Root Menu = /home/andrew/MagickaBBS/menus/root.mnu Root Menu = main.mnu
[paths] [paths]
Config Path = /home/andrew/MagickaBBS/config Config Path = /home/andrew/MagickaBBS/config
@ -40,6 +40,7 @@ Log Path = /home/andrew/MagickaBBS/logs
Script Path = /home/andrew/MagickaBBS/scripts Script Path = /home/andrew/MagickaBBS/scripts
Echomail Semaphore = /home/andrew/MagickaBBS/echomail.out Echomail Semaphore = /home/andrew/MagickaBBS/echomail.out
Netmail Semaphore = /home/andrew/MagickaBBS/netmail.out Netmail Semaphore = /home/andrew/MagickaBBS/netmail.out
Menu Path = /home/andrew/MagickaBBS/menus
[mail conferences] [mail conferences]
Local Mail = config/localmail.ini Local Mail = config/localmail.ini

82
doors.c
View File

@ -382,85 +382,3 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
} }
timeoutpaused = 0; timeoutpaused = 0;
} }
int door_menu(struct user_record *user) {
int doquit = 0;
int dodoors = 0;
char buffer[256];
int i;
char c;
struct stat s;
int do_internal_menu = 0;
char *lRet;
lua_State *L;
int result;
if (conf.script_path != NULL) {
sprintf(buffer, "%s/doors.lua", conf.script_path);
if (stat(buffer, &s) == 0) {
L = luaL_newstate();
luaL_openlibs(L);
lua_push_cfunctions(L);
luaL_loadfile(L, buffer);
do_internal_menu = 0;
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
while (!dodoors) {
if (do_internal_menu == 1) {
s_displayansi("doors");
s_printf(get_string(52), user->timeleft);
c = s_getc();
} else {
lua_getglobal(L, "menu");
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
lua_close(L);
continue;
}
lRet = (char *)lua_tostring(L, -1);
lua_pop(L, 1);
c = lRet[0];
}
switch(tolower(c)) {
case 'q':
dodoors = 1;
break;
case 'g':
{
doquit = do_logout();
dodoors = doquit;
}
break;
default:
{
for (i=0;i<conf.door_count;i++) {
if (tolower(c) == tolower(conf.doors[i]->key)) {
dolog("%s is launched door %s, on node %d", user->loginname, conf.doors[i]->name, mynode);
rundoor(user, conf.doors[i]->command, conf.doors[i]->stdio);
dolog("%s is returned from door %s, on node %d", user->loginname, conf.doors[i]->name, mynode);
break;
}
}
}
break;
}
}
if (do_internal_menu == 0) {
lua_close(L);
}
return doquit;
}

178
files.c
View File

@ -1072,70 +1072,40 @@ void list_files(struct user_record *user) {
} }
} }
int file_menu(struct user_record *user) { void choose_subdir(struct user_record *user) {
int doquit = 0;
int dofiles = 0;
char c;
int i; int i;
char c;
int j; int j;
char prompt[256]; char prompt[6];
struct stat s;
int do_internal_menu = 0;
char *lRet;
lua_State *L;
int result;
if (conf.script_path != NULL) { s_printf(get_string(81));
sprintf(prompt, "%s/filemenu.lua", conf.script_path); for (i=0;i<conf.file_directories[user->cur_file_dir]->file_sub_count;i++) {
if (stat(prompt, &s) == 0) { s_printf(" %d. %s\r\n", i, conf.file_directories[user->cur_file_dir]->file_subs[i]->name);
L = luaL_newstate();
luaL_openlibs(L);
lua_push_cfunctions(L);
luaL_loadfile(L, prompt);
do_internal_menu = 0;
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
while (!dofiles) { if (i != 0 && i % 20 == 0) {
if (do_internal_menu == 1) { s_printf(get_string(6));
s_displayansi("filemenu");
s_printf(get_string(76), user->cur_file_dir, conf.file_directories[user->cur_file_dir]->name, user->cur_file_sub, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->name, user->timeleft);
c = s_getc();
} else {
lua_getglobal(L, "menu");
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
lua_close(L);
continue;
}
lRet = (char *)lua_tostring(L, -1);
lua_pop(L, 1);
c = lRet[0];
}
switch(tolower(c)) {
case 27:
{
c = s_getc();
if (c == 91) {
c = s_getc(); c = s_getc();
} }
} }
break; s_printf(get_string(82));
case 'i': s_readstring(prompt, 5);
{ if (tolower(prompt[0]) != 'q') {
j = atoi(prompt);
if (j < 0 || j >= conf.file_directories[user->cur_file_dir]->file_sub_count) {
s_printf(get_string(83));
} else {
s_printf("\r\n");
user->cur_file_sub = j;
}
}
}
void choose_directory(struct user_record *user) {
int i;
char c;
int j;
char prompt[6];
s_printf(get_string(77)); s_printf(get_string(77));
for (i=0;i<conf.file_directory_count;i++) { for (i=0;i<conf.file_directory_count;i++) {
if (conf.file_directories[i]->sec_level <= user->sec_level) { if (conf.file_directories[i]->sec_level <= user->sec_level) {
@ -1158,49 +1128,10 @@ int file_menu(struct user_record *user) {
user->cur_file_sub = 0; user->cur_file_sub = 0;
} }
} }
} }
break;
case 's':
{
s_printf(get_string(81));
for (i=0;i<conf.file_directories[user->cur_file_dir]->file_sub_count;i++) {
s_printf(" %d. %s\r\n", i, conf.file_directories[user->cur_file_dir]->file_subs[i]->name);
if (i != 0 && i % 20 == 0) { void clear_tagged_files() {
s_printf(get_string(6)); int i;
c = s_getc();
}
}
s_printf(get_string(82));
s_readstring(prompt, 5);
if (tolower(prompt[0]) != 'q') {
j = atoi(prompt);
if (j < 0 || j >= conf.file_directories[user->cur_file_dir]->file_sub_count) {
s_printf(get_string(83));
} else {
s_printf("\r\n");
user->cur_file_sub = j;
}
}
}
break;
case 'l':
list_files(user);
break;
case 'u':
{
if (user->sec_level >= conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->upload_sec_level) {
upload(user);
} else {
s_printf(get_string(84));
}
}
break;
case 'd':
download(user);
break;
case 'c':
{
// Clear tagged files // Clear tagged files
if (tagged_count > 0) { if (tagged_count > 0) {
for (i=0;i<tagged_count;i++) { for (i=0;i<tagged_count;i++) {
@ -1209,11 +1140,10 @@ int file_menu(struct user_record *user) {
free(tagged_files); free(tagged_files);
tagged_count = 0; tagged_count = 0;
} }
} }
break;
case '}':
{
void next_file_dir(struct user_record *user) {
int i;
for (i=user->cur_file_dir;i<conf.file_directory_count;i++) { for (i=user->cur_file_dir;i<conf.file_directory_count;i++) {
if (i + 1 == conf.file_directory_count) { if (i + 1 == conf.file_directory_count) {
i = -1; i = -1;
@ -1224,10 +1154,10 @@ int file_menu(struct user_record *user) {
break; break;
} }
} }
} }
break;
case '{': void prev_file_dir(struct user_record *user) {
{ int i;
for (i=user->cur_file_dir;i>=0;i--) { for (i=user->cur_file_dir;i>=0;i--) {
if (i - 1 == -1) { if (i - 1 == -1) {
i = conf.file_directory_count; i = conf.file_directory_count;
@ -1238,39 +1168,23 @@ int file_menu(struct user_record *user) {
break; break;
} }
} }
} }
break;
case ']': void next_file_sub(struct user_record *user) {
{ int i;
i=user->cur_file_sub; i=user->cur_file_sub;
if (i + 1 == conf.file_directories[user->cur_file_dir]->file_sub_count) { if (i + 1 == conf.file_directories[user->cur_file_dir]->file_sub_count) {
i = -1; i = -1;
} }
user->cur_file_sub = i + 1; user->cur_file_sub = i + 1;
} }
break;
case '[': void prev_file_sub(struct user_record *user) {
{ int i;
i=user->cur_file_sub; i=user->cur_file_sub;
if (i - 1 == -1) { if (i - 1 == -1) {
i = conf.file_directories[user->cur_file_dir]->file_sub_count; i = conf.file_directories[user->cur_file_dir]->file_sub_count;
} }
user->cur_file_sub = i - 1; user->cur_file_sub = i - 1;
}
break;
case 'q':
dofiles = 1;
break;
case 'g':
{
doquit = do_logout();
dofiles = doquit;
}
break;
}
}
if (do_internal_menu == 0) {
lua_close(L);
}
return doquit;
} }

View File

@ -1793,7 +1793,7 @@ void read_mail(struct user_record *user) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
break; return;
} else { } else {
all_unread = 0; all_unread = 0;
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
@ -1841,6 +1841,8 @@ void post_message(struct user_record *user) {
struct fido_addr *from_addr = NULL; struct fido_addr *from_addr = NULL;
char buffer[256]; char buffer[256];
char buffer2[256]; char buffer2[256];
int z;
int sem_fd;
s_JamBase *jb; s_JamBase *jb;
s_JamMsgHeader jmh; s_JamMsgHeader jmh;
@ -2055,7 +2057,7 @@ void post_message(struct user_record *user) {
} }
if (z != 0) { if (z != 0) {
JAM_CloseMB(jb); JAM_CloseMB(jb);
break; return;
} }
if (JAM_AddMessage(jb, &jmh, jsp, (char *)msg, strlen(msg))) { if (JAM_AddMessage(jb, &jmh, jsp, (char *)msg, strlen(msg))) {
@ -2084,109 +2086,21 @@ void post_message(struct user_record *user) {
free(subject); free(subject);
} }
int mail_menu(struct user_record *user) { void list_messages(struct user_record *user) {
int doquit = 0;
int domail = 0;
char c;
char buffer[256];
char buffer2[256];
int i;
int j;
int z;
int k;
struct msg_headers *msghs; struct msg_headers *msghs;
s_JamBase *jb; s_JamBase *jb;
s_JamMsgHeader jmh; int all_unread;
s_JamSubPacket* jsp;
s_JamSubfield jsf;
s_JamLastRead jlr; s_JamLastRead jlr;
char buffer[256];
struct tm msg_date; int i;
int k;
char *subject; int j;
char *from;
char *to;
char *msg;
int closed;
struct fido_addr *from_addr = NULL;
struct stat s;
int do_internal_menu = 0;
char *lRet;
lua_State *L;
int result;
int sem_fd;
int all_unread = 0;
int redraw;
int start; int start;
int closed;
int redraw;
struct tm msg_date;
char c;
if (conf.script_path != NULL) {
sprintf(buffer, "%s/mailmenu.lua", conf.script_path);
if (stat(buffer, &s) == 0) {
L = luaL_newstate();
luaL_openlibs(L);
lua_push_cfunctions(L);
luaL_loadfile(L, buffer);
do_internal_menu = 0;
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
while (!domail) {
if (do_internal_menu == 1) {
s_displayansi("mailmenu");
s_printf(get_string(119), user->cur_mail_conf, conf.mail_conferences[user->cur_mail_conf]->name, user->cur_mail_area, conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->name, user->timeleft);
c = s_getc();
} else {
lua_getglobal(L, "menu");
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
lua_close(L);
continue;
}
lRet = (char *)lua_tostring(L, -1);
lua_pop(L, 1);
c = lRet[0];
}
switch(tolower(c)) {
case 27:
{
c = s_getc();
if (c == 91) {
c = s_getc();
}
}
break;
case '!':
{
mail_scan(user);
}
break;
case 'd':
{
read_mail(user);
}
break;
case 'p':
{
post_message(user);
}
break;
case 'l':
{
s_printf("\r\n"); s_printf("\r\n");
// list mail in message base // list mail in message base
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
@ -2194,7 +2108,7 @@ int mail_menu(struct user_record *user) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
break; return;
} else { } else {
all_unread = 0; all_unread = 0;
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
@ -2341,10 +2255,15 @@ int mail_menu(struct user_record *user) {
} else { } else {
s_printf(get_string(130)); s_printf(get_string(130));
} }
} }
break;
case 'c': void choose_conference(struct user_record *user) {
{ int i;
int j;
char c;
char buffer[6];
s_printf(get_string(131)); s_printf(get_string(131));
for (i=0;i<conf.mail_conference_count;i++) { for (i=0;i<conf.mail_conference_count;i++) {
if (conf.mail_conferences[i]->sec_level <= user->sec_level) { if (conf.mail_conferences[i]->sec_level <= user->sec_level) {
@ -2367,10 +2286,14 @@ int mail_menu(struct user_record *user) {
user->cur_mail_area = 0; user->cur_mail_area = 0;
} }
} }
} }
break;
case 'a': void choose_area(struct user_record *user) {
{ int i;
int j;
char c;
char buffer[6];
s_printf(get_string(135)); s_printf(get_string(135));
for (i=0;i<conf.mail_conferences[user->cur_mail_conf]->mail_area_count;i++) { for (i=0;i<conf.mail_conferences[user->cur_mail_conf]->mail_area_count;i++) {
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->read_sec_level <= user->sec_level) { if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->read_sec_level <= user->sec_level) {
@ -2392,33 +2315,11 @@ int mail_menu(struct user_record *user) {
user->cur_mail_area = j; user->cur_mail_area = j;
} }
} }
} }
break;
case 'q': void next_mail_conf(struct user_record *user) {
{ int i;
domail = 1;
}
break;
case 'g':
{
doquit = do_logout();
domail = doquit;
}
break;
case 'e':
{
send_email(user);
}
break;
case 'r':
{
// Read your email...
s_printf("\r\n");
list_emails(user);
}
break;
case '}':
{
for (i=user->cur_mail_conf;i<conf.mail_conference_count;i++) { for (i=user->cur_mail_conf;i<conf.mail_conference_count;i++) {
if (i + 1 == conf.mail_conference_count) { if (i + 1 == conf.mail_conference_count) {
i = -1; i = -1;
@ -2429,10 +2330,10 @@ int mail_menu(struct user_record *user) {
break; break;
} }
} }
} }
break;
case '{': void prev_mail_conf(struct user_record *user) {
{ int i;
for (i=user->cur_mail_conf;i>=0;i--) { for (i=user->cur_mail_conf;i>=0;i--) {
if (i - 1 == -1) { if (i - 1 == -1) {
i = conf.mail_conference_count; i = conf.mail_conference_count;
@ -2443,10 +2344,10 @@ int mail_menu(struct user_record *user) {
break; break;
} }
} }
} }
break;
case ']': void next_mail_area(struct user_record *user) {
{ int i;
for (i=user->cur_mail_area;i<conf.mail_conferences[user->cur_mail_conf]->mail_area_count;i++) { for (i=user->cur_mail_area;i<conf.mail_conferences[user->cur_mail_conf]->mail_area_count;i++) {
if (i + 1 == conf.mail_conferences[user->cur_mail_conf]->mail_area_count) { if (i + 1 == conf.mail_conferences[user->cur_mail_conf]->mail_area_count) {
i = -1; i = -1;
@ -2456,10 +2357,10 @@ int mail_menu(struct user_record *user) {
break; break;
} }
} }
} }
break;
case '[': void prev_mail_area(struct user_record *user) {
{ int i;
for (i=user->cur_mail_area;i>=0;i--) { for (i=user->cur_mail_area;i>=0;i--) {
if (i - 1 == -1) { if (i - 1 == -1) {
i = conf.mail_conferences[user->cur_mail_conf]->mail_area_count; i = conf.mail_conferences[user->cur_mail_conf]->mail_area_count;
@ -2469,24 +2370,6 @@ int mail_menu(struct user_record *user) {
break; break;
} }
} }
}
break;
case 'b':
{
bwave_create_packet();
}
break;
case 'u':
{
bwave_upload_reply();
}
break;
}
}
if (do_internal_menu == 0) {
lua_close(L);
}
return doquit;
} }
void mail_scan(struct user_record *user) { void mail_scan(struct user_record *user) {

7
main.c
View File

@ -505,6 +505,8 @@ static int handler(void* user, const char* section, const char* name,
conf->www_path = strdup(value); conf->www_path = strdup(value);
} else if (strcasecmp(name, "config path") == 0) { } else if (strcasecmp(name, "config path") == 0) {
conf->config_path = strdup(value); conf->config_path = strdup(value);
} else if (strcasecmp(name, "menu path") == 0) {
conf->menu_path = strdup(value);
} }
} else if (strcasecmp(section, "mail conferences") == 0) { } else if (strcasecmp(section, "mail conferences") == 0) {
if (conf->mail_conference_count == 0) { if (conf->mail_conference_count == 0) {
@ -1168,6 +1170,11 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
if (conf.root_menu == NULL) {
fprintf(stderr, "Root Menu must be set in your bbs ini!\n");
exit(-1);
}
// Load mail Areas // Load mail Areas
for (i=0;i<conf.mail_conference_count;i++) { for (i=0;i<conf.mail_conference_count;i++) {
if (ini_parse(conf.mail_conferences[i]->path, mail_area_handler, conf.mail_conferences[i]) <0) { if (ini_parse(conf.mail_conferences[i]->path, mail_area_handler, conf.mail_conferences[i]) <0) {

View File

@ -13,7 +13,7 @@ extern struct bbs_config conf;
void display_bulletins() { void display_bulletins() {
int i; int i;
char buffer[PATH_MAX]; char buffer[PATH_MAX];
struct stat s;
i = 0; i = 0;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
@ -63,133 +63,3 @@ void display_textfiles() {
s_getc(); s_getc();
} }
} }
void main_menu(struct user_record *user) {
int doquit = 0;
char c;
char buffer[256];
int i;
struct stat s;
int do_internal_menu = 0;
char *lRet;
lua_State *L;
int result;
if (conf.script_path != NULL) {
sprintf(buffer, "%s/mainmenu.lua", conf.script_path);
if (stat(buffer, &s) == 0) {
L = luaL_newstate();
luaL_openlibs(L);
lua_push_cfunctions(L);
luaL_loadfile(L, buffer);
do_internal_menu = 0;
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
} else {
do_internal_menu = 1;
}
while (!doquit) {
if (do_internal_menu == 1) {
s_displayansi("mainmenu");
s_printf(get_string(142), user->timeleft);
c = s_getc();
} else {
lua_getglobal(L, "menu");
result = lua_pcall(L, 0, 1, 0);
if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1));
do_internal_menu = 1;
lua_close(L);
continue;
}
lRet = (char *)lua_tostring(L, -1);
lua_pop(L, 1);
c = lRet[0];
}
switch(tolower(c)) {
case 27:
{
c = s_getc();
if (c == 91) {
c = s_getc();
}
}
break;
case 'o':
{
automessage_write(user);
}
break;
case 'a':
{
display_textfiles();
}
break;
case 'c':
{
chat_system(user);
}
break;
case 'l':
{
bbs_list(user);
}
break;
case 'u':
{
list_users(user);
}
break;
case 'b':
{
display_bulletins();
}
break;
case '1':
{
display_last10_callers(user);
}
break;
case 'd':
{
doquit = door_menu(user);
}
break;
case 'm':
{
doquit = mail_menu(user);
}
break;
case 'g':
{
doquit = do_logout();
}
break;
case 't':
{
doquit = file_menu(user);
}
break;
case 's':
{
settings_menu(user);
}
break;
}
}
if (do_internal_menu == 0) {
lua_close(L);
}
}

207
menus.c
View File

@ -1,3 +1,11 @@
#include <stdio.h>
#include <strings.h>
#include <sys/stat.h>
#include "bbs.h"
#include "lua/lua.h"
#include "lua/lualib.h"
#include "lua/lauxlib.h"
#define MENU_SUBMENU 1 #define MENU_SUBMENU 1
#define MENU_LOGOFF 2 #define MENU_LOGOFF 2
#define MENU_PREVMENU 3 #define MENU_PREVMENU 3
@ -13,6 +21,30 @@
#define MENU_MAILSCAN 13 #define MENU_MAILSCAN 13
#define MENU_READMAIL 14 #define MENU_READMAIL 14
#define MENU_POSTMESSAGE 15 #define MENU_POSTMESSAGE 15
#define MENU_CHOOSEMAILCONF 16
#define MENU_CHOOSEMAILAREA 17
#define MENU_SENDEMAIL 18
#define MENU_LISTEMAIL 19
#define MENU_NEXTMAILCONF 20
#define MENU_PREVMAILCONF 21
#define MENU_NEXTMAILAREA 22
#define MENU_PREVMAILAREA 23
#define MENU_BLUEWAVEDOWN 24
#define MENU_BLUEWAVEUP 25
#define MENU_CHOOSEFILEDIR 26
#define MENU_CHOOSEFILESUB 27
#define MENU_LISTFILES 28
#define MENU_UPLOAD 29
#define MENU_DOWNLOAD 30
#define MENU_CLEARTAGGEDFILES 31
#define MENU_NEXTFILEDIR 32
#define MENU_PREVFILEDIR 33
#define MENU_NEXTFILESUB 34
#define MENU_PREVFILESUB 35
extern struct bbs_config conf;
extern struct user_record *gUser;
extern int mynode;
struct menu_item { struct menu_item {
char hotkey; char hotkey;
@ -22,15 +54,27 @@ struct menu_item {
int menu_system(char *menufile) { int menu_system(char *menufile) {
FILE *fptr; FILE *fptr;
char buffer[256]; char buffer[PATH_MAX];
int menu_items = 0; int menu_items = 0;
struct menu_item **menu; struct menu_item **menu;
char *lua_script; char *lua_script;
int do_lua_menu; int do_lua_menu;
char *ansi_file; char *ansi_file;
fptr = fopen(menufile, "r");
int i; int i;
int j; int j;
struct stat s;
char *lRet;
lua_State *L;
int result;
int doquit = 0;
char c;
if (menufile[0] == '/') {
snprintf(buffer, PATH_MAX, "%s.mnu", menufile);
} else {
snprintf(buffer, PATH_MAX, "%s/%s.mnu", conf.menu_path, menufile);
}
fptr = fopen(buffer, "r");
if (!fptr) { if (!fptr) {
s_printf("Error opening menu file! %s\r\n", menufile); s_printf("Error opening menu file! %s\r\n", menufile);
@ -40,10 +84,11 @@ int menu_system(char *menufile) {
lua_script = NULL; lua_script = NULL;
ansi_file = NULL; ansi_file = NULL;
while (1) {
fgets(buffer, 256, fptr); fgets(buffer, 256, fptr);
while (!feof(fptr)) {
chomp(buffer); chomp(buffer);
if (strncasecmp(buffer, "HOTKEY", 6) == 0) { if (strncasecmp(buffer, "HOTKEY", 6) == 0) {
@ -57,10 +102,12 @@ int menu_system(char *menufile) {
menu[menu_items-1]->hotkey = buffer[7]; menu[menu_items-1]->hotkey = buffer[7];
menu[menu_items-1]->data = NULL; menu[menu_items-1]->data = NULL;
} else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) { } else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) {
if (strncasemp(&buffer[8], "SUBMENU", 7) == 0) { if (strncasecmp(&buffer[8], "SUBMENU", 7) == 0) {
menu[menu_items-1]->command = MENU_SUBMENU; menu[menu_items-1]->command = MENU_SUBMENU;
} else if (strncasecmp(&buffer[8], "LOGOFF", 6) == 0) { } else if (strncasecmp(&buffer[8], "LOGOFF", 6) == 0) {
menu[menu_items-1]->command = MENU_LOGOFF; menu[menu_items-1]->command = MENU_LOGOFF;
} else if (strncasecmp(&buffer[8], "PREVMENU", 8) == 0) {
menu[menu_items-1]->command = MENU_PREVMENU;
} else if (strncasecmp(&buffer[8], "AUTOMESSAGE_WRITE", 17) == 0) { } else if (strncasecmp(&buffer[8], "AUTOMESSAGE_WRITE", 17) == 0) {
menu[menu_items-1]->command = MENU_AUTOMESSAGEWRITE; menu[menu_items-1]->command = MENU_AUTOMESSAGEWRITE;
} else if (strncasecmp(&buffer[8], "TEXTFILES", 9) == 0) { } else if (strncasecmp(&buffer[8], "TEXTFILES", 9) == 0) {
@ -85,6 +132,46 @@ int menu_system(char *menufile) {
menu[menu_items-1]->command = MENU_READMAIL; menu[menu_items-1]->command = MENU_READMAIL;
} else if (strncasecmp(&buffer[8], "POSTMESSAGE", 11) == 0) { } else if (strncasecmp(&buffer[8], "POSTMESSAGE", 11) == 0) {
menu[menu_items-1]->command = MENU_POSTMESSAGE; menu[menu_items-1]->command = MENU_POSTMESSAGE;
} else if (strncasecmp(&buffer[8], "CHOOSEMAILCONF", 14) == 0) {
menu[menu_items-1]->command = MENU_CHOOSEMAILCONF;
} else if (strncasecmp(&buffer[8], "CHOOSEMAILAREA", 14) == 0) {
menu[menu_items-1]->command = MENU_CHOOSEMAILAREA;
} else if (strncasecmp(&buffer[8], "SENDEMAIL", 9) == 0) {
menu[menu_items-1]->command = MENU_SENDEMAIL;
} else if (strncasecmp(&buffer[8], "LISTEMAIL", 9) == 0) {
menu[menu_items-1]->command = MENU_LISTEMAIL;
} else if (strncasecmp(&buffer[8], "NEXTMAILCONF", 12) == 0) {
menu[menu_items-1]->command = MENU_NEXTMAILCONF;
} else if (strncasecmp(&buffer[8], "PREVMAILCONF", 12) == 0) {
menu[menu_items-1]->command = MENU_PREVMAILCONF;
} else if (strncasecmp(&buffer[8], "NEXTMAILAREA", 12) == 0) {
menu[menu_items-1]->command = MENU_NEXTMAILAREA;
} else if (strncasecmp(&buffer[8], "PREVMAILAREA", 12) == 0) {
menu[menu_items-1]->command = MENU_PREVMAILAREA;
} else if (strncasecmp(&buffer[8], "BLUEWAVEDOWNLOAD", 16) == 0) {
menu[menu_items-1]->command = MENU_BLUEWAVEDOWN;
} else if (strncasecmp(&buffer[8], "BLUEWAVEUPLOAD", 14) == 0) {
menu[menu_items-1]->command = MENU_BLUEWAVEUP;
} else if (strncasecmp(&buffer[8], "CHOOSEFILEDIR", 13) == 0) {
menu[menu_items-1]->command = MENU_CHOOSEFILEDIR;
} else if (strncasecmp(&buffer[8], "CHOOSEFILESUB", 13) == 0) {
menu[menu_items-1]->command = MENU_CHOOSEFILESUB;
} else if (strncasecmp(&buffer[8], "LISTFILES", 9) == 0) {
menu[menu_items-1]->command = MENU_LISTFILES;
} else if (strncasecmp(&buffer[8], "UPLOAD", 6) == 0) {
menu[menu_items-1]->command = MENU_UPLOAD;
} else if (strncasecmp(&buffer[8], "DOWNLOAD", 8) == 0) {
menu[menu_items-1]->command = MENU_DOWNLOAD;
} else if (strncasecmp(&buffer[8], "CLEARTAGGED", 11) == 0) {
menu[menu_items-1]->command = MENU_CLEARTAGGEDFILES;
} else if (strncasecmp(&buffer[8], "NEXTFILEDIR", 11) == 0) {
menu[menu_items-1]->command = MENU_NEXTFILEDIR;
} else if (strncasecmp(&buffer[8], "PREVFILEDIR", 11) == 0) {
menu[menu_items-1]->command = MENU_PREVFILEDIR;
} else if (strncasecmp(&buffer[8], "NEXTFILESUB", 11) == 0) {
menu[menu_items-1]->command = MENU_NEXTFILESUB;
} else if (strncasecmp(&buffer[8], "PREVFILESUB", 11) == 0) {
menu[menu_items-1]->command = MENU_PREVFILESUB;
} }
} else if (strncasecmp(buffer, "DATA", 4) == 0) { } else if (strncasecmp(buffer, "DATA", 4) == 0) {
menu[menu_items-1]->data = strdup(&buffer[5]); menu[menu_items-1]->data = strdup(&buffer[5]);
@ -99,26 +186,29 @@ int menu_system(char *menufile) {
} }
ansi_file = strdup(&buffer[9]); ansi_file = strdup(&buffer[9]);
} }
fgets(buffer, 256, fptr);
} }
fclose(fptr); fclose(fptr);
do_lua_menu = 0; do_lua_menu = 0;
if (lua_script != NULL) {
if (conf.script_path != NULL && lua_script[0] != '/') { if (conf.script_path != NULL && lua_script[0] != '/') {
snprintf(buffer, 256 "%s/%s", conf.script_path, lua_script); snprintf(buffer, PATH_MAX, "%s/%s.lua", conf.script_path, lua_script);
do_lua_menu = 1; do_lua_menu = 1;
} else if (lua_script[0] == '/') { } else if (lua_script[0] == '/') {
snprintf(buffer, 256 "%s", lua_script); snprintf(buffer, PATH_MAX, "%s.lua", lua_script);
do_lua_menu = 1; do_lua_menu = 1;
} }
if (do_lua_menu) if (do_lua_menu) {
if (stat(buffer, &s) == 0) { if (stat(buffer, &s) == 0) {
L = luaL_newstate(); L = luaL_newstate();
luaL_openlibs(L); luaL_openlibs(L);
lua_push_cfunctions(L); lua_push_cfunctions(L);
luaL_loadfile(L, buffer); luaL_loadfile(L, buffer);
do_internal_menu = 0; do_lua_menu = 1;
result = lua_pcall(L, 0, 1, 0); result = lua_pcall(L, 0, 1, 0);
if (result) { if (result) {
dolog("Failed to run script: %s", lua_tostring(L, -1)); dolog("Failed to run script: %s", lua_tostring(L, -1));
@ -128,6 +218,7 @@ int menu_system(char *menufile) {
do_lua_menu = 0; do_lua_menu = 0;
} }
} }
}
while (!doquit) { while (!doquit) {
@ -135,7 +226,7 @@ int menu_system(char *menufile) {
if (ansi_file != NULL) { if (ansi_file != NULL) {
s_displayansi(ansi_file); s_displayansi(ansi_file);
} }
s_printf(get_string(142), user->timeleft); s_printf(get_string(142), gUser->timeleft);
c = s_getc(); c = s_getc();
} else { } else {
lua_getglobal(L, "menu"); lua_getglobal(L, "menu");
@ -152,7 +243,7 @@ int menu_system(char *menufile) {
} }
for (i=0;i<menu_items;i++) { for (i=0;i<menu_items;i++) {
if (menu[i]->hotkey == c) { if (tolower(menu[i]->hotkey) == tolower(c)) {
switch(menu[i]->command) { switch(menu[i]->command) {
case MENU_SUBMENU: case MENU_SUBMENU:
doquit = menu_system(menu[i]->data); doquit = menu_system(menu[i]->data);
@ -169,7 +260,7 @@ int menu_system(char *menufile) {
} }
for (i=0;i<menu_items;i++) { for (i=0;i<menu_items;i++) {
if (menu[i]->data != NULL) { if (menu[i]->data != NULL) {
free(menu[i]->data) free(menu[i]->data);
} }
free(menu[i]); free(menu[i]);
} }
@ -189,7 +280,7 @@ int menu_system(char *menufile) {
} }
for (i=0;i<menu_items;i++) { for (i=0;i<menu_items;i++) {
if (menu[i]->data != NULL) { if (menu[i]->data != NULL) {
free(menu[i]->data) free(menu[i]->data);
} }
free(menu[i]); free(menu[i]);
} }
@ -207,56 +298,120 @@ int menu_system(char *menufile) {
} }
for (i=0;i<menu_items;i++) { for (i=0;i<menu_items;i++) {
if (menu[i]->data != NULL) { if (menu[i]->data != NULL) {
free(menu[i]->data) free(menu[i]->data);
} }
free(menu[i]); free(menu[i]);
} }
free(menu); free(menu);
return 0; return 0;
case MENU_AUTOMESSAGEWRITE: case MENU_AUTOMESSAGEWRITE:
automessage_write(user); automessage_write(gUser);
break; break;
case MENU_TEXTFILES: case MENU_TEXTFILES:
display_textfiles(); display_textfiles();
break; break;
case MENU_CHATSYSTEM: case MENU_CHATSYSTEM:
chat_system(user); chat_system(gUser);
break; break;
case MENU_BBSLIST: case MENU_BBSLIST:
bbs_list(user); bbs_list(gUser);
break; break;
case MENU_LISTUSERS: case MENU_LISTUSERS:
list_users(user); list_users(gUser);
break; break;
case MENU_BULLETINS: case MENU_BULLETINS:
display_bulletins(); display_bulletins();
break; break;
case MENU_LAST10: case MENU_LAST10:
display_last10_callers(user); display_last10_callers(gUser);
break; break;
case MENU_SETTINGS: case MENU_SETTINGS:
settings_menu(user); settings_menu(gUser);
break; break;
case MENU_DOOR: case MENU_DOOR:
{ {
for (j=0;j<conf.door_count;j++) { for (j=0;j<conf.door_count;j++) {
if (strcasecmp(menu[i]->data, conf.doors[j]->name) == 0) { if (strcasecmp(menu[i]->data, conf.doors[j]->name) == 0) {
dolog("%s launched door %s, on node %d", user->loginname, conf.doors[j]->name, mynode); dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
rundoor(user, conf.doors[j]->command, conf.doors[j]->stdio); rundoor(gUser, conf.doors[j]->command, conf.doors[j]->stdio);
dolog("%s returned from door %s, on node %d", user->loginname, conf.doors[j]->name, mynode); dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
break; break;
} }
} }
} }
break; break;
case MENU_MAILSCAN: case MENU_MAILSCAN:
mail_scan(user); mail_scan(gUser);
break; break;
case MENU_READMAIL: case MENU_READMAIL:
read_mail(user); read_mail(gUser);
break; break;
case MENU_POSTMESSAGE: case MENU_POSTMESSAGE:
post_message(user); post_message(gUser);
break;
case MENU_CHOOSEMAILCONF:
choose_conference(gUser);
break;
case MENU_CHOOSEMAILAREA:
choose_area(gUser);
break;
case MENU_SENDEMAIL:
send_email(gUser);
break;
case MENU_LISTEMAIL:
list_emails(gUser);
break;
case MENU_NEXTMAILCONF:
next_mail_conf(gUser);
break;
case MENU_PREVMAILCONF:
prev_mail_conf(gUser);
break;
case MENU_NEXTMAILAREA:
next_mail_area(gUser);
break;
case MENU_PREVMAILAREA:
prev_mail_area(gUser);
break;
case MENU_BLUEWAVEDOWN:
bwave_create_packet();
break;
case MENU_BLUEWAVEUP:
bwave_upload_reply();
break;
case MENU_CHOOSEFILEDIR:
choose_directory(gUser);
break;
case MENU_CHOOSEFILESUB:
choose_subdir(gUser);
break;
case MENU_LISTFILES:
list_files(gUser);
break;
case MENU_UPLOAD:
if (gUser->sec_level >= conf.file_directories[gUser->cur_file_dir]->file_subs[gUser->cur_file_sub]->upload_sec_level) {
upload(gUser);
} else {
s_printf(get_string(84));
}
break;
case MENU_DOWNLOAD:
download(gUser);
break;
case MENU_CLEARTAGGEDFILES:
clear_tagged_files();
break;
case MENU_NEXTFILEDIR:
next_file_dir(gUser);
break;
case MENU_PREVFILEDIR:
prev_file_dir(gUser);
break;
case MENU_NEXTFILESUB:
next_file_sub(gUser);
break;
case MENU_PREVFILESUB:
prev_file_sub(gUser);
break; break;
} }
break; break;

9
menus_default/doors.mnu Normal file
View File

@ -0,0 +1,9 @@
LUASCRIPT doors
ANSIFILE doors
HOTKEY Q
COMMAND PREVMENU
HOTKEY G
COMMAND SUBMENU
DATA logoff

39
menus_default/file.mnu Normal file
View File

@ -0,0 +1,39 @@
LUASCRIPT filemenu
ANSIFILE filemenu
HOTKEY I
COMMAND CHOOSEFILEDIR
HOTKEY S
COMMAND CHOOSEFILESUB
HOTKEY L
COMMAND LISTFILES
HOTKEY U
COMMAND UPLOAD
HOTKEY D
COMMAND DOWNLOAD
HOTKEY C
COMMAND CLEARTAGGED
HOTKEY }
COMMAND NEXTFILEDIR
HOTKEY {
COMMAND PREVFILEDIR
HOTKEY ]
COMMAND NEXTFILESUB
HOTKEY [
COMMAND PREVFILESUB
HOTKEY Q
COMMAND PREVMENU
HOTKEY G
COMMAND SUBMENU
DATA logoff

7
menus_default/logoff.mnu Normal file
View File

@ -0,0 +1,7 @@
ANSIFILE logoff
HOTKEY Y
COMMAND LOGOFF
HOTKEY N
COMMAND PREVMENU

48
menus_default/mail.mnu Normal file
View File

@ -0,0 +1,48 @@
LUASCRIPT mailmenu
ANSIFILE mailmenu
HOTKEY !
COMMAND MAILSCAN
HOTKEY D
COMMAND READMAIL
HOTKEY P
COMMAND POSTMESSAGE
HOTKEY L
COMMAND LISTMESSAGES
HOTKEY C
COMMAND CHOOSEMAILCONF
HOTKEY Q
COMMAND PREVMENU
HOTKEY G
COMMAND SUBMENU
DATA logoff
HOTKEY E
COMMAND SENDEMAIL
HOTKEY R
COMMAND LISTEMAIL
HOTKEY }
COMMAND NEXTMAILCONF
HOTKEY {
COMMAND PREVMAILCONF
HOTKEY ]
COMMAND NEXTMAILAREA
HOTKEY [
COMMAND PREVMAILAREA
HOTKEY B
COMMAND BLUEWAVEDOWNLOAD
HOTKEY U
COMMAND BLUEWAVEUPLOAD

42
menus_default/main.mnu Normal file
View File

@ -0,0 +1,42 @@
LUASCRIPT mainmenu
ANSIFILE mainmenu
HOTKEY O
COMMAND AUTOMESSAGE_WRITE
HOTKEY A
COMMAND TEXTFILES
HOTKEY C
COMMAND CHATSYSTEM
HOTKEY L
COMMAND BBSLIST
HOTKEY U
COMMAND LISTUSERS
HOTKEY B
COMMAND BULLETINS
HOTKEY 1
COMMAND LAST10CALLERS
HOTKEY D
COMMAND SUBMENU
DATA doors
HOTKEY M
COMMAND SUBMENU
DATA mail
HOTKEY T
COMMAND SUBMENU
DATA file
HOTKEY S
COMMAND SETTINGS
HOTKEY G
COMMAND SUBMENU
DATA logoff

View File

@ -1,13 +1,4 @@
function logout() function logout()
bbs_write_string("\r\n\r\nAre you sure you want to logoff (Y/N) ? ");
cmd = bbs_read_char();
if (cmd == "n" or cmd == "N") then
return 0;
end
bbs_display_ansi("goodbye"); bbs_display_ansi("goodbye");
return 1; return 1;
end end