From d002d681d79542d450167f0780ee440017e9c7f3 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 14 Feb 2018 14:36:26 +1000 Subject: [PATCH] Change AUTOMESSAGE_WRITE to AUTOMESSAGE and add prompt. --- STRINGS.CHANGES | 6 +++++- dist/magicka.strings | 1 + src/bbs.c | 24 +++++++++++++++++++++--- src/bbs.h | 3 ++- src/menus.c | 10 +++++----- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/STRINGS.CHANGES b/STRINGS.CHANGES index 0c8b7ad..3811468 100644 --- a/STRINGS.CHANGES +++ b/STRINGS.CHANGES @@ -9,7 +9,11 @@ Changes from v0.9-alpha -> v0.10-alpha LINE: 275 NEW OLDSTRING: (NONE) -NEWSTRING: \r\n\e[1;31mError executing archiver.\r\n\e[0m +NEWSTRING: "\r\n\e[1;31mError executing archiver.\r\n\e[0m" + +LINE: 276 NEW +OLDSTRING: (NONE) +NEWSTRING: "\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m" Changes from v0.8-alpha -> v0.9-alpha -------------------------------------------------------------- diff --git a/dist/magicka.strings b/dist/magicka.strings index 9131aa4..9d2bd9e 100644 --- a/dist/magicka.strings +++ b/dist/magicka.strings @@ -273,3 +273,4 @@ File exists!\r\n \e[8;28H\e[1;31;40mNo BBSes in the list! \e[10;22H\e[1;37mPress \e[1;33mA \e[1;37m to Add yours or \e[1;33mQ \e[1;37mto Quit\e[0m \r\n\e[1;31mError executing archiver.\r\n\e[0m +\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m diff --git a/src/bbs.c b/src/bbs.c index cdf383f..f726944 100644 --- a/src/bbs.c +++ b/src/bbs.c @@ -668,7 +668,7 @@ void display_info() { s_getc(); } -void automessage_write(struct user_record *user) { +void automessage_write() { FILE *fptr; char automsg[450]; char buffer[76]; @@ -679,11 +679,11 @@ void automessage_write(struct user_record *user) { memset(automsg, 0, 450); memset(buffer, 0, 76); - if (user->sec_level >= conf.automsgwritelvl) { + if (gUser->sec_level >= conf.automsgwritelvl) { timen = time(NULL); localtime_r(&timen, &timenow); - sprintf(automsg, get_string(15), user->loginname, asctime(&timenow)); + sprintf(automsg, get_string(15), gUser->loginname, asctime(&timenow)); automsg[strlen(automsg) - 1] = '\r'; automsg[strlen(automsg)] = '\n'; @@ -733,6 +733,24 @@ void automessage_display() { s_getc(); } +void automessage() { + char c; + s_printf(get_string(275)); + c = s_getchar(); + s_printf("\r\n"); + switch(tolower(c)) { + case 'v': + automessage_display(); + break; + case 'u': + automessage_write(); + break; + default: + break; + } + return; +} + void runbbs_real(int socket, char *ip, int ssh) { char buffer[PATH_MAX]; char password[17]; diff --git a/src/bbs.h b/src/bbs.h index 0f41b60..2771019 100644 --- a/src/bbs.h +++ b/src/bbs.h @@ -242,8 +242,9 @@ struct msg_headers { extern char *str_replace(const char *orig, const char *rep, const char *with); extern int copy_file(char *src, char *dest); extern int recursive_delete(const char *dir); -extern void automessage_write(struct user_record *user); +extern void automessage_write(); extern void automessage_display(); +extern void automessage(); extern void dolog(char *fmt, ...); extern void dolog_www(char *ipaddr, char *fmt, ...); extern void runbbs_ssh(char *ipaddress); diff --git a/src/menus.c b/src/menus.c index 68dc8c6..7b01a44 100644 --- a/src/menus.c +++ b/src/menus.c @@ -11,7 +11,7 @@ #define MENU_SUBMENU 1 #define MENU_LOGOFF 2 #define MENU_PREVMENU 3 -#define MENU_AUTOMESSAGEWRITE 4 +#define MENU_AUTOMESSAGE 4 #define MENU_TEXTFILES 5 #define MENU_CHATSYSTEM 6 #define MENU_BBSLIST 7 @@ -133,8 +133,8 @@ int menu_system(char *menufile) { 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) { - menu[menu_items-1]->command = MENU_AUTOMESSAGEWRITE; + } else if (strncasecmp(&buffer[8], "AUTOMESSAGE", 11) == 0) { + menu[menu_items-1]->command = MENU_AUTOMESSAGE; } else if (strncasecmp(&buffer[8], "TEXTFILES", 9) == 0) { menu[menu_items-1]->command = MENU_TEXTFILES; } else if (strncasecmp(&buffer[8], "CHATSYSTEM", 10) == 0) { @@ -388,8 +388,8 @@ int menu_system(char *menufile) { } free(menu); return 0; - case MENU_AUTOMESSAGEWRITE: - automessage_write(gUser); + case MENU_AUTOMESSAGE: + automessage(); break; case MENU_TEXTFILES: display_textfiles();