From 86e39b7522a96e04802ed186354e5eb4372fd0fd Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 14 Aug 2016 19:56:15 +1000 Subject: [PATCH] Move Strings into a String file so they can be customized --- Makefile.freebsd | 2 +- Makefile.linux | 2 +- Makefile.minix | 2 +- Makefile.osx | 2 +- bbs.c | 64 ++-- bbs.h | 5 +- bbs_list.c | 52 +-- chat_system.c | 4 +- config_default/bbs.ini | 1 + doors.c | 6 +- email.c | 41 ++- files.c | 48 +-- magicka.strings | 186 ++++++++++ mail_menu.c | 790 ++++++++++++++++++++--------------------- main.c | 5 + main_menu.c | 22 +- settings.c | 24 +- strings.c | 83 +++++ users.c | 58 +-- 19 files changed, 837 insertions(+), 560 deletions(-) create mode 100644 magicka.strings create mode 100644 strings.c diff --git a/Makefile.freebsd b/Makefile.freebsd index a46a2e5..36ceb6b 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a ZMODEM = Xmodem/libzmodem.a LUA = lua/liblua.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 +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 %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/Makefile.linux b/Makefile.linux index c602ab8..1f06219 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a ZMODEM = Xmodem/libzmodem.a LUA = lua/liblua.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 +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 %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/Makefile.minix b/Makefile.minix index fce46fc..3121151 100644 --- a/Makefile.minix +++ b/Makefile.minix @@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a ZMODEM = Xmodem/libzmodem.a LUA = lua/liblua.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 +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 %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/Makefile.osx b/Makefile.osx index 08dcefa..d480794 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -5,7 +5,7 @@ JAMLIB = jamlib/jamlib.a ZMODEM = Xmodem/libzmodem.a LUA = lua/liblua.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 +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 %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/bbs.c b/bbs.c index 1c92801..d64f53b 100644 --- a/bbs.c +++ b/bbs.c @@ -132,7 +132,7 @@ void timer_handler(int signum) { gUser->timeleft--; if (gUser->timeleft <= 0) { - s_printf("\r\n\r\nSorry, you're out of time today..\r\n"); + s_printf(get_string(0)); disconnect("Out of Time"); } @@ -142,7 +142,7 @@ void timer_handler(int signum) { usertimeout--; } if (usertimeout <= 0) { - s_printf("\r\n\r\nTimeout waiting for input..\r\n"); + s_printf(get_string(1)); disconnect("Timeout"); } } @@ -372,8 +372,8 @@ void display_last10_callers(struct user_record *user) { struct tm l10_time; FILE *fptr = fopen("last10.dat", "rb"); - s_printf("\r\n\e[1;37mLast 10 callers:\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\r\n"); + s_printf(get_string(2)); + s_printf(get_string(3)); if (fptr != NULL) { @@ -390,10 +390,10 @@ void display_last10_callers(struct user_record *user) { for (z=0;zloginname, asctime(&timenow)); + sprintf(automsg, get_string(15), user->loginname, asctime(&timenow)); automsg[strlen(automsg) - 1] = '\r'; automsg[strlen(automsg)] = '\n'; - s_printf("\r\nEnter your message (4 lines):\r\n"); + s_printf(get_string(16)); for (i=0;i<4;i++) { s_printf("\r\n%d: ", i); s_readstring(buffer, 75); @@ -474,9 +474,9 @@ void automessage_display() { dolog("Error opening automessage.txt"); } } else { - s_printf("No automessage!\r\n"); + s_printf(get_string(17)); } - s_printf("\e[0mPress any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); } @@ -541,7 +541,7 @@ void runbbs_real(int socket, char *ip, int ssh) { } if (mynode == 0) { - s_printf("Sorry, all nodes are in use. Please try later\r\n"); + s_printf(get_string(18)); if (!ssh) { close(socket); } @@ -566,8 +566,8 @@ void runbbs_real(int socket, char *ip, int ssh) { s_displayansi("issue"); if (!ssh) { - s_printf("\e[0mEnter your Login Name or NEW to create an account\r\n"); - s_printf("Login:> "); + s_printf(get_string(19)); + s_printf(get_string(20)); s_readstring(buffer, 25); @@ -575,11 +575,11 @@ void runbbs_real(int socket, char *ip, int ssh) { user = new_user(); gUser = user; } else { - s_printf("\r\nPassword:> "); + s_printf(get_string(21)); s_readpass(password, 16); user = check_user_pass(buffer, password); if (user == NULL) { - s_printf("\r\nIncorrect Login.\r\n"); + s_printf(get_string(22)); disconnect("Incorrect Login"); } @@ -597,7 +597,7 @@ void runbbs_real(int socket, char *ip, int ssh) { if (strcasecmp(user->loginname, buffer) == 0) { fclose(nodefile); - s_printf("\r\nYou are already logged in.\r\n"); + s_printf(get_string(23)); disconnect("Already Logged in"); } fclose(nodefile); @@ -607,7 +607,7 @@ void runbbs_real(int socket, char *ip, int ssh) { } else { if (gUser != NULL) { user = gUser; - s_printf("\e[0mWelcome back %s. Press enter to log in...\r\n", gUser->loginname); + s_printf(get_string(24), gUser->loginname); s_getc(); for (i=1;i<=conf.nodes;i++) { sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i); @@ -621,14 +621,14 @@ void runbbs_real(int socket, char *ip, int ssh) { if (strcasecmp(user->loginname, buffer) == 0) { fclose(nodefile); - s_printf("\r\nYou are already logged in.\r\n"); + s_printf(get_string(23)); disconnect("Already Logged in"); } fclose(nodefile); } } } else { - s_printf("\e[0mWelcome to %s! Press enter to create an account...\r\n", conf.bbs_name); + s_printf(get_string(25), conf.bbs_name); s_getc(); gUser = new_user(); user = gUser; @@ -687,7 +687,7 @@ void runbbs_real(int socket, char *ip, int ssh) { while (stat(buffer, &s) == 0) { sprintf(buffer, "bulletin%d", i); s_displayansi(buffer); - s_printf("\e[0mPress any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); i++; sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); @@ -703,9 +703,9 @@ void runbbs_real(int socket, char *ip, int ssh) { // check email i = mail_getemailcount(user); if (i > 0) { - s_printf("\r\nYou have %d e-mail(s) in your inbox.\r\n", i); + s_printf(get_string(26), i); } else { - s_printf("\r\nYou have no e-mail.\r\n"); + s_printf(get_string(27)); } mail_scan(user); diff --git a/bbs.h b/bbs.h index 2ac7755..a739f5d 100644 --- a/bbs.h +++ b/bbs.h @@ -96,7 +96,7 @@ struct bbs_config { int ssh_port; char *ssh_dsa_key; char *ssh_rsa_key; - + char *string_file; char *irc_server; int irc_port; char *irc_channel; @@ -192,4 +192,7 @@ extern int file_menu(struct user_record *user); extern void settings_menu(struct user_record *user); extern void lua_push_cfunctions(lua_State *L); + +extern void load_strings(); +extern char *get_string(int offset); #endif diff --git a/bbs_list.c b/bbs_list.c index 5a3a78a..34d70c8 100644 --- a/bbs_list.c +++ b/bbs_list.c @@ -28,22 +28,22 @@ void add_bbs(struct user_record *user) { sqlite3_stmt *res; int rc; - s_printf("\r\n\e[1;37mEnter the BBS Name: \e[0m"); + s_printf(get_string(28)); s_readstring(bbsname, 18); - s_printf("\r\n\e[1;37mEnter the Sysop's Name: \e[0m"); + s_printf(get_string(29)); s_readstring(sysop, 16); - s_printf("\r\n\e[1;37mEnter the Telnet URL: \e[0m"); + s_printf(get_string(30)); s_readstring(telnet, 38); - s_printf("\r\nYou entered:\r\n"); - s_printf("\e[1;30m----------------------------------------------\e[0m\r\n"); - s_printf("\e[1;37mBBS Name: \e[1;32m%s\r\n", bbsname); - s_printf("\e[1;37mSysop: \e[1;32m%s\r\n", sysop); - s_printf("\e[1;37mTelnet URL: \e[1;32m%s\r\n", telnet); - s_printf("\e[1;30m----------------------------------------------\e[0m\r\n"); - s_printf("Is this correct? (Y/N) :"); + s_printf(get_string(31)); + s_printf(get_string(32)); + s_printf(get_string(33), bbsname); + s_printf(get_string(34), sysop); + s_printf(get_string(35), telnet); + s_printf(get_string(36)); + s_printf(get_string(37)); c = s_getc(); if (tolower(c) == 'y') { @@ -93,9 +93,9 @@ void add_bbs(struct user_record *user) { } sqlite3_finalize(res); sqlite3_close(db); - s_printf("\r\n\e[1;32mAdded!\e[0m\r\n"); + s_printf(get_string(38)); } else { - s_printf("\r\n\e[1;31mAborted!\e[0m\r\n"); + s_printf(get_string(39)); } } @@ -109,7 +109,7 @@ void delete_bbs(struct user_record *user) { int i; char c; - s_printf("\r\nPlease enter the id of the BBS you want to delete: "); + s_printf(get_string(40)); s_readstring(buffer, 5); i = atoi(buffer); @@ -125,11 +125,11 @@ void delete_bbs(struct user_record *user) { sqlite3_bind_int(res, 2, user->id); } else { sqlite3_close(db); - s_printf("\r\nThere are no BBSes in the list yet!\r\n"); + s_printf(get_string(41)); return; } if (sqlite3_step(res) == SQLITE_ROW) { - s_printf("\r\nAre you sure you want to delete %s?\r\n", sqlite3_column_text(res, 0)); + s_printf(get_string(42), sqlite3_column_text(res, 0)); sqlite3_finalize(res); c = s_getc(); if (tolower(c) == 'y') { @@ -138,18 +138,18 @@ void delete_bbs(struct user_record *user) { sqlite3_bind_int(res, 1, i); } else { sqlite3_close(db); - s_printf("\r\nThere are no BBSes in the list yet!\r\n"); + s_printf(get_string(41)); return; } sqlite3_step(res); - s_printf("\r\n\e[1;32mDeleted!\e[0m\r\n"); + s_printf(get_string(43)); sqlite3_finalize(res); } else { - s_printf("\r\n\e[1;32mAborted!\e[0m\r\n"); + s_printf(get_string(39)); } } else { sqlite3_finalize(res); - s_printf("\r\nThat BBS entry either doesn't exist or wasn't created by you.\r\n"); + s_printf(get_string(44)); } sqlite3_close(db); } @@ -173,27 +173,27 @@ void list_bbses() { rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc != SQLITE_OK) { sqlite3_close(db); - s_printf("\r\nThere are no BBSes in the list yet!\r\n"); + s_printf(get_string(41)); return; } i = 0; - s_printf("\r\n\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(45)); while (sqlite3_step(res) == SQLITE_ROW) { - s_printf("\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%-18s \e[1;33m%-16s \e[1;32m%-37s\e[0m\r\n", sqlite3_column_int(res, 0), sqlite3_column_text(res, 1), sqlite3_column_text(res, 2), sqlite3_column_text(res, 3)); + s_printf(get_string(46), sqlite3_column_int(res, 0), sqlite3_column_text(res, 1), sqlite3_column_text(res, 2), sqlite3_column_text(res, 3)); i++; if (i == 20) { - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); i = 0; } } - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(47)); sqlite3_finalize(res); sqlite3_close(db); - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); } @@ -202,7 +202,7 @@ void bbs_list(struct user_record *user) { char c; while(!doquit) { - s_printf("\r\n\e[1;32mBBS Listings: \e[1;37m(\e[1;33mL\e[1;37m) \e[1;32mList, \e[1;37m(\e[1;33mA\e[1;37m) \e[1;32mAdd \e[1;37m(\e[1;33mD\e[1;37m) \e[1;32mDelete \e[1;37m(\e[1;33mQ\e[1;37m) \e[1;32mQuit\e[0m\r\n"); + s_printf(get_string(48)); c = s_getc(); diff --git a/chat_system.c b/chat_system.c index f9c1dce..c9b477f 100644 --- a/chat_system.c +++ b/chat_system.c @@ -121,7 +121,7 @@ void chat_system(struct user_record *user) { memset(inputbuffer, 0, 80); if (conf.irc_server == NULL) { - s_putstring("\r\nSorry, Chat is not supported on this system.\r\n"); + s_putstring(get_string(49)); return; } row_at = 0; @@ -282,7 +282,7 @@ void chat_system(struct user_record *user) { for (i=line_at+1;i<22;i++) { s_putstring("\r\n"); } - s_putstring("\e[1;45;37m Type /Quit to Exit\e[K\e[0m\r\n"); + s_putstring(get_string(50)); if (inputbuffer_at > 0) { s_putstring(inputbuffer); } diff --git a/config_default/bbs.ini b/config_default/bbs.ini index b8fcc76..b9ab499 100644 --- a/config_default/bbs.ini +++ b/config_default/bbs.ini @@ -18,6 +18,7 @@ SSH DSA Key = /home/andrew/MagickaBBS/keys/ssh_host_dsa_key SSH RSA Key = /home/andrew/MagickaBBS/keys/ssh_host_rsa_key [paths] +String File = /home/andrew/MagickaBBS/magicka.strings PID File = /home/andrew/MagickaBBS/magicka.pid ANSI Path = /home/andrew/MagickaBBS/ansis BBS Path = /home/andrew/MagickaBBS diff --git a/doors.c b/doors.c index 20ecc96..39ec7eb 100644 --- a/doors.c +++ b/doors.c @@ -241,7 +241,7 @@ void rundoor(struct user_record *user, char *cmd, int stdio) { sprintf(buffer, "%s %d %d", cmd, mynode, gSocket); system(buffer); } else { - s_printf("Non-STDIO door support on SSH is currently broken...\r\n"); + s_printf(get_string(51)); } } timeoutpaused = 0; @@ -283,7 +283,7 @@ int door_menu(struct user_record *user) { if (do_internal_menu == 1) { s_displayansi("doors"); - s_printf("\e[0m\r\nTL: %dm :> ", user->timeleft); + s_printf(get_string(52), user->timeleft); c = s_getc(); } else { @@ -305,7 +305,7 @@ int door_menu(struct user_record *user) { break; case 'g': { - s_printf("\r\nAre you sure you want to log off? (Y/N)"); + s_printf(get_string(53)); c = s_getc(); if (tolower(c) == 'y') { doquit = 1; diff --git a/email.c b/email.c index fd0684e..08826ff 100644 --- a/email.c +++ b/email.c @@ -27,24 +27,24 @@ void send_email(struct user_record *user) { char *isql = "INSERT INTO email (sender, recipient, subject, body, date, seen) VALUES(?, ?, ?, ?, ?, 0)"; char *err_msg = 0; - s_printf("\r\nTO: "); + s_printf(get_string(54)); s_readstring(buffer, 16); if (strlen(buffer) == 0) { - s_printf("\r\nAborted\r\n"); + s_printf(get_string(39)); return; } if (check_user(buffer)) { - s_printf("\r\n\r\nInvalid Username\r\n"); + s_printf(get_string(55)); return; } recipient = strdup(buffer); - s_printf("\r\nSUBJECT: "); + s_printf(get_string(56)); s_readstring(buffer, 25); if (strlen(buffer) == 0) { free(recipient); - s_printf("\r\nAborted\r\n"); + s_printf(get_string(39)); return; } subject = strdup(buffer); @@ -150,14 +150,13 @@ void show_email(struct user_record *user, int msgno) { date = (time_t)sqlite3_column_int(res, 4); - s_printf("\e[2J\e[1;32mFrom : \e[1;37m%s\r\n", sender); - s_printf("\e[1;32mSubject : \e[1;37m%s\r\n", subject); + s_printf(get_string(57), sender); + s_printf(get_string(58), subject); localtime_r(&date, &msg_date); - sprintf(buffer, "\e[1;32mDate : \e[1;37m%s", asctime(&msg_date)); + sprintf(buffer, "%s", asctime(&msg_date)); buffer[strlen(buffer) - 1] = '\0'; - strcat(buffer, "\r\n"); - s_printf(buffer); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(59), buffer); + s_printf(get_string(60)); lines = 0; chars = 0; @@ -168,7 +167,7 @@ void show_email(struct user_record *user, int msgno) { s_printf("\r\n"); lines++; if (lines == 19) { - s_printf("\e[1;37mPress a key to continue...\e[0m"); + s_printf(get_string(6)); s_getc(); lines = 0; s_printf("\e[5;1H\e[0J"); @@ -193,7 +192,7 @@ void show_email(struct user_record *user, int msgno) { } sqlite3_step(res); - s_printf("\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n"); + s_printf(get_string(61)); c = s_getc(); if (tolower(c) == 'r') { if (subject != NULL) { @@ -293,12 +292,12 @@ void list_emails(struct user_record *user) { dolog("Failed to execute statement: %s", sqlite3_errmsg(db)); sqlite3_finalize(res); sqlite3_close(db); - s_printf("\r\nYou have no email\r\n"); + s_printf(get_string(62)); return; } msgid = 0; - s_printf("\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m"); + s_printf(get_string(63)); while (sqlite3_step(res) == SQLITE_ROW) { from = strdup((char *)sqlite3_column_text(res, 0)); subject = strdup((char *)sqlite3_column_text(res, 1)); @@ -306,15 +305,15 @@ void list_emails(struct user_record *user) { date = (time_t)sqlite3_column_int(res, 3); localtime_r(&date, &msg_date); if (seen == 0) { - s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); + s_printf(get_string(64), msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); } else { - s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); + s_printf(get_string(65), msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); } free(from); free(subject); if (msgid % 22 == 0 && msgid != 0) { - s_printf("\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n"); + s_printf(get_string(66)); s_readstring(buffer, 5); if (strlen(buffer) > 0) { if (tolower(buffer[0]) == 'q') { @@ -329,14 +328,14 @@ void list_emails(struct user_record *user) { return; } } - s_printf("\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m"); + s_printf(get_string(63)); } msgid++; } if (msgid == 0) { - s_printf( "\r\nYou have no email\r\n"); + s_printf(get_string(62)); } else { - s_printf("\e[1;37mEnter \e[1;36m# \e[1;37mto read, or \e[1;36mEnter\e[1;37m to quit\e[0m\r\n"); + s_printf(get_string(67)); s_readstring(buffer, 5); if (strlen(buffer) > 0) { msgtoread = atoi(buffer) - 1; diff --git a/files.c b/files.c index 5e61761..5f6f657 100644 --- a/files.c +++ b/files.c @@ -467,7 +467,7 @@ void list_files(struct user_record *user) { if (rc != SQLITE_OK) { sqlite3_finalize(res); sqlite3_close(db); - s_printf("\r\nNo files in this area!\r\n"); + s_printf(get_string(68)); return; } @@ -492,7 +492,7 @@ void list_files(struct user_record *user) { sqlite3_close(db); if (files_c == 0) { - s_printf("\r\nNo files in this area!\r\n"); + s_printf(get_string(68)); return; } s_printf("\r\n"); @@ -510,7 +510,7 @@ void list_files(struct user_record *user) { } else { file_unit = 'b'; } - s_printf("\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[0;32m", i, files_e[i]->dlcount, file_size, file_unit, basename(files_e[i]->filename)); + s_printf(get_string(69), i, files_e[i]->dlcount, file_size, file_unit, basename(files_e[i]->filename)); lines+=3; for (j=0;jdescription);j++) { if (files_e[i]->description[j] == '\n') { @@ -519,7 +519,7 @@ void list_files(struct user_record *user) { if (lines >= 18) { lines = 0; while (1) { - s_printf("\r\n\e[0mEnter # to tag, Q to quit, Enter to continue: "); + s_printf(get_string(70)); s_readstring(buffer, 5); if (strlen(buffer) == 0) { s_printf("\r\n"); @@ -552,18 +552,18 @@ void list_files(struct user_record *user) { } tagged_files[tagged_count] = strdup(files_e[z]->filename); tagged_count++; - s_printf("\r\nTagged %s\r\n", basename(files_e[z]->filename)); + s_printf(get_string(71), basename(files_e[z]->filename)); } else { - s_printf("\r\nAlready Tagged\r\n"); + s_printf(get_string(72)); } } else { - s_printf("\r\nSorry, you don't have permission to download from this area\r\n"); + s_printf(get_string(73)); } } } } } else { - s_printf(" \e[0;32m"); + s_printf(get_string(74)); } } else { s_putchar(files_e[i]->description[j]); @@ -571,7 +571,7 @@ void list_files(struct user_record *user) { } } while (1) { - s_printf("\r\n\e[0mEnter # to tag, Enter to quit: "); + s_printf(get_string(75)); s_readstring(buffer, 5); if (strlen(buffer) == 0) { for (z=0;zfilename); tagged_count++; - s_printf("\r\nTagged %s\r\n", basename(files_e[z]->filename)); + s_printf(get_string(71), basename(files_e[z]->filename)); } else { - s_printf("\r\nAlready Tagged\r\n"); + s_printf(get_string(72)); } } else { - s_printf("\r\nSorry, you don't have permission to download from this area\r\n"); + s_printf(get_string(73)); } } } @@ -650,7 +650,7 @@ int file_menu(struct user_record *user) { if (do_internal_menu == 1) { s_displayansi("filemenu"); - s_printf("\e[0m\r\nDir: (%d) %s\r\nSub: (%d) %s\r\nTL: %dm :> ", 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); + 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 { @@ -669,22 +669,22 @@ int file_menu(struct user_record *user) { switch(tolower(c)) { case 'i': { - s_printf("\r\n\r\nFile Directories:\r\n\r\n"); + s_printf(get_string(77)); for (i=0;isec_level <= user->sec_level) { - s_printf(" %d. %s\r\n", i, conf.file_directories[i]->name); + s_printf(get_string(78), i, conf.file_directories[i]->name); } if (i != 0 && i % 20 == 0) { - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); c = s_getc(); } } - s_printf("Enter the directory number: "); + s_printf(get_string(79)); s_readstring(prompt, 5); if (tolower(prompt[0]) != 'q') { j = atoi(prompt); if (j < 0 || j >= conf.file_directory_count || conf.file_directories[j]->sec_level > user->sec_level) { - s_printf("\r\nInvalid directory number!\r\n"); + s_printf(get_string(80)); } else { s_printf("\r\n"); user->cur_file_dir = j; @@ -695,21 +695,21 @@ int file_menu(struct user_record *user) { break; case 's': { - s_printf("\r\n\r\nFile Subdirectories:\r\n\r\n"); + s_printf(get_string(81)); for (i=0;icur_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) { - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); c = s_getc(); } } - s_printf("Enter the sub directory number: "); + 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("\r\nInvalid sub directiry number!\r\n"); + s_printf(get_string(83)); } else { s_printf("\r\n"); user->cur_file_sub = j; @@ -725,7 +725,7 @@ int file_menu(struct user_record *user) { 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("Sorry, you don't have permission to upload in this Sub\r\n"); + s_printf(get_string(84)); } } break; @@ -796,7 +796,7 @@ int file_menu(struct user_record *user) { break; case 'g': { - s_printf("\r\nAre you sure you want to log off? (Y/N)"); + s_printf(get_string(53)); c = s_getc(); if (tolower(c) == 'y') { dofiles = 1; diff --git a/magicka.strings b/magicka.strings new file mode 100644 index 0000000..2fd8172 --- /dev/null +++ b/magicka.strings @@ -0,0 +1,186 @@ +\r\n\r\nSorry, you're out of time today..\r\n +\r\n\r\nTimeout waiting for input..\r\n +\r\n\e[1;37mLast 10 callers:\r\n +\e[1;30m-------------------------------------------------------------------------------\r\n +\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d\e[0m\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[1;37mPress any key to continue...\e[0m\r\n +\r\n\r\n\e[1;37mSystem Information\r\n +\e[1;30m----------------------------------------------\r\n +\e[1;32mBBS Name : \e[1;37m%s\r\n +\e[1;32mSysOp Name : \e[1;37m%s\r\n +\e[1;32mNode : \e[1;37m%d\r\n +\e[1;32mBBS Version : \e[1;37mMagicka %d.%d (%s)\r\n +\e[1;32mSystem : \e[1;37m%s (%s)\r\n +\e[1;30m----------------------------------------------\e[0m\r\n +Automessage Posted by %s @ %s +\r\nEnter your message (4 lines):\r\n +No automessage!\r\n +Sorry, all nodes are in use. Please try later\r\n +\e[0mEnter your Login Name or NEW to create an account\r\n +Login:> +\r\nPassword:> +\r\nIncorrect Login.\r\n +\r\nYou are already logged in.\r\n +\e[0mWelcome back %s. Press enter to log in...\r\n +\e[0mWelcome to %s! Press enter to create an account...\r\n +\r\nYou have %d e-mail(s) in your inbox.\r\n +\r\nYou have no e-mail.\r\n +\r\n\e[1;37mEnter the BBS Name: \e[0m +\r\n\e[1;37mEnter the Sysop's Name: \e[0m +\r\n\e[1;37mEnter the Telnet URL: \e[0m +\r\nYou entered:\r\n +\e[1;30m----------------------------------------------\e[0m\r\n +\e[1;37mBBS Name: \e[1;32m%s\r\n +\e[1;37mSysop: \e[1;32m%s\r\n +\e[1;37mTelnet URL: \e[1;32m%s\r\n +\e[1;30m----------------------------------------------\e[0m\r\n +Is this correct? (Y/N) : +\r\n\e[1;32mAdded!\e[0m\r\n +\r\n\e[1;31mAborted!\e[0m\r\n +\r\nPlease enter the id of the BBS you want to delete: +\r\nThere are no BBSes in the list yet!\r\n +\r\nAre you sure you want to delete %s?\r\n +\r\n\e[1;32mDeleted!\e[0m\r\n +\r\nThat BBS entry either doesn't exist or wasn't created by you.\r\n +\r\n\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%-18s \e[1;33m%-16s \e[1;32m%-37s\e[0m\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\r\n\e[1;32mBBS Listings: \e[1;37m(\e[1;33mL\e[1;37m) \e[1;32mList, \e[1;37m(\e[1;33mA\e[1;37m) \e[1;32mAdd \e[1;37m(\e[1;33mD\e[1;37m) \e[1;32mDelete \e[1;37m(\e[1;33mQ\e[1;37m) \e[1;32mQuit\e[0m\r\n +\r\nSorry, Chat is not supported on this system.\r\n +\e[1;45;37m Type /Quit to Exit\e[K\e[0m\r\n +Non-STDIO door support on SSH is currently broken...\r\n +\e[0m\r\nTL: %dm :> +\r\nAre you sure you want to log off? (Y/N) +\r\nTO: +\r\n\r\nInvalid Username\r\n +\r\nSUBJECT: +\e[2J\e[1;32mFrom : \e[1;37m%s\r\n +\e[1;32mSubject : \e[1;37m%s\r\n +\e[1;32mDate : \e[1;37m%s\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n +\r\nYou have no email\r\n +\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m +\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n +\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n +\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n +\e[1;37mEnter \e[1;36m# \e[1;37mto read, or \e[1;36mEnter\e[1;37m to quit\e[0m\r\n +\r\nNo files in this area!\r\n +\r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[0;32m +\r\n\e[0mEnter # to tag, Q to quit, Enter to continue: +\r\nTagged %s\r\n +\r\nAlready Tagged\r\n +\r\nSorry, you don't have permission to download from this area\r\n + \e[0;32m +\r\n\e[0mEnter # to tag, Enter to quit: +\e[0m\r\nDir: (%d) %s\r\nSub: (%d) %s\r\nTL: %dm :> +\r\n\r\nFile Directories:\r\n\r\n + %d. %s\r\n +Enter the directory number: +\r\nInvalid directory number!\r\n +\r\n\r\nFile Subdirectories:\r\n\r\n +Enter the sub directory number: +\r\nInvalid sub directory number!\r\n +Sorry, you don't have permission to upload in this Sub\r\n +\r\nUse external editor? (Y/N) +\r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m +\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s +\r\nNo message to quote!\r\n +\r\nQuote from Line: +\r\nQuote to Line: +Quoting Cancelled\r\n +\e[1;33m\r\nHELP\r\n +/S - Save Message\r\n +/A - Abort Message\r\n +/Q - Quote Message\r\n +/E - Edit (Rewrite) Line\r\n +/D - Delete Line\r\n +/I - Insert Line\r\n +/L - Relist Message\r\n\e[0m +\r\nWhich line do you want to delete? +\r\nWhich line do you want to edit? +\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m +\r\nInsert before which line? +\e[2J\e[1;32mFrom : \e[1;37m%s (%d:%d/%d.%d)\r\n +\e[2J\e[1;32mFrom : \e[1;37m%s\r\n +\e[1;32mTo : \e[1;37m%-27.27s \e[1;32mConf : \e[1;37m%-27.27s\r\n +\e[1;32mSubject : \e[1;37m%-27.27s \e[1;32mArea : \e[1;37m%-27.27s\r\n +\e[1;32mDate : \e[1;37m%s \e[1;32mMsgNo : \e[1;37m%4d of %4d\r\n +\e[1;32mAttribs : \e[1;37m%s\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\r\n\e[1;37mPress \e[1;36mR \e[1;37mto reply, \e[1;36mQ \e[1;37mto quit, \e[1;36mB \e[1;37mto go Back, \e[1;36mSPACE \e[1;37mfor Next Mesage... +\r\nSorry, you are not allowed to post in this area\r\n +\r\n\r\nReplying to: %s\r\n +Change Subject? (Y/N) +\r\nNew subject: +\r\nOk, not changing the subject line... +\r\n\r\nNo more messages\r\n +\e[0m\r\nConf: (%d) %s\r\nArea: (%d) %s\r\nTL: %dm :> +Read message [1-%d] or N for New: +\r\nADDR: +\r\n\r\nInvalid Address\r\n +\r\nMailing to %d:%d/%d.%d\r\n +\r\nMailing to @%d\r\n +Start at message [1-%d] or N for New? +\e[2J\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m +\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n +\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n +(#) Read Message # (Q) Quit (ENTER) Continue\r\n +\r\nThere is no mail in this area\r\n +\r\n\r\nMail Conferences:\r\n\r\n + %d. %s\r\n +Enter the conference number: +\r\nInvalid conference number!\r\n +\r\n\r\nMail Areas:\r\n\r\n + %d. %s\r\n +Enter the area number: +\r\nInvalid area number!\r\n +\r\nScan for new mail? (Y/N) : +\r\n\e[1;32m%d. %s\e[0m\r\n +\e[1;37m --> %d. %s (%d new)\e[0m\r\n +\r\n\e[0mTL: %dm :> +\r\n\e[1;32mText Files Collection\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +Enter the number of a text file to display or Q to quit: +\r\nSorry, there are no text files to display\r\n +\e[2J\e[1;32mYour Settings\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[0;36mP. \e[1;37mPassword (\e[1;33mNot Shown\e[1;37m)\r\n +\e[0;36mL. \e[1;37mLocation (\e[1;33m%s\e[1;37m)\r\n +\e[0;36mQ. \e[1;37mQuit to Main Menu\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\r\nEnter your current password: +\r\nEnter your new password (8 chars min): +\r\nPassword Changed!\r\n +\r\nPassword too short!\r\n +\r\nPassword Incorrect!\r\n +\r\nEnter your new location: +\e[2J\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +User Name Location Times On\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%5d\r\n +\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n +\r\nWhat is your login name: +Sorry, that name is too short.\r\n +Sorry, invalid character, can only use alpha characters.\r\n +Sorry, that name is reserved.\r\n +Sorry, that name is in use.\r\n +What is your first name: +What is your last name: +What is your e-mail address: +Where are you located: +What password would you like (at least 8 characters): +You Entered:\r\n +-------------------------------------\r\n +Login Name: +\r\nFirst Name: +\r\nLast Name: +\r\nE-mail: +\r\nLocation: +\r\n-------------------------------------\r\n +Is this Correct? (Y/N) +\e[1;37mPress any key to continue...\e[0m diff --git a/mail_menu.c b/mail_menu.c index 9872225..5baae19 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -13,8 +13,8 @@ #include "lua/lualib.h" #include "lua/lauxlib.h" -extern struct bbs_config conf; -extern struct user_record *gUser; +extern struct bbs_config conf; +extern struct user_record *gUser; extern int mynode; struct jam_msg { int msg_no; @@ -82,114 +82,114 @@ void free_message_headers(struct msg_headers *msghs) { if (msghs->msgs[i]->replyid != NULL) { free(msghs->msgs[i]->replyid); } - } - if (msghs->msg_count > 0) { - free(msghs->msgs); - } + } + if (msghs->msg_count > 0) { + free(msghs->msgs); + } free(msghs); -} - -int msg_is_to(char *addressed_to, char *address, int type, int rn, int msgconf) { - char *myname; - char *wwiv_addressee; - struct fido_addr *dest; - int j; - if (rn) { - myname = (char *)malloc(strlen(gUser->firstname) + strlen(gUser->lastname) + 2); - sprintf(myname, "%s %s", gUser->firstname, gUser->lastname); - } else { - myname = strdup(gUser->loginname); - } - if (type == NETWORK_WWIV) { - wwiv_addressee = strdup(addressed_to); - for (j=1;jwwivnode == atoi(address)) { - free(wwiv_addressee); - free(myname); - return 1; - } - } - free(wwiv_addressee); - free(myname); - return 0; - } else if (type == NETWORK_FIDO) { - if (strcasecmp(myname, addressed_to) == 0) { - dest = parse_fido_addr(address); - if (conf.mail_conferences[msgconf]->fidoaddr->zone == dest->zone && - conf.mail_conferences[msgconf]->fidoaddr->net == dest->net && - conf.mail_conferences[msgconf]->fidoaddr->node == dest->node && - conf.mail_conferences[msgconf]->fidoaddr->point == dest->point) { - free(dest); - free(myname); - return 1; - } - free(dest); - } - free(myname); - return 0; - } else { - if (strcasecmp(myname, addressed_to) == 0) { - free(myname); - return 1; - } - free(myname); - return 0; - } -} - -int msg_is_from(char *addressed_from, char *address, int type, int rn, int msgconf) { - char *myname; - struct fido_addr *orig; - int j; - if (rn) { - myname = (char *)malloc(strlen(gUser->firstname) + strlen(gUser->lastname) + 2); - sprintf(myname, "%s %s", gUser->firstname, gUser->lastname); - } else { - myname = strdup(gUser->loginname); - } - if (type == NETWORK_WWIV) { - free(myname); - return 0; - } else if (type == NETWORK_FIDO) { - if (strcasecmp(myname, addressed_from) == 0) { - orig = parse_fido_addr(address); - if (conf.mail_conferences[msgconf]->fidoaddr->zone == orig->zone && - conf.mail_conferences[msgconf]->fidoaddr->net == orig->net && - conf.mail_conferences[msgconf]->fidoaddr->node == orig->node && - conf.mail_conferences[msgconf]->fidoaddr->point == orig->point) { - free(orig); - free(myname); - return 1; - } - free(orig); - } - free(myname); - return 0; - } else { - if (strcasecmp(myname, addressed_from) == 0) { - free(myname); - return 1; - } - free(myname); - return 0; - } -} - +} + +int msg_is_to(char *addressed_to, char *address, int type, int rn, int msgconf) { + char *myname; + char *wwiv_addressee; + struct fido_addr *dest; + int j; + if (rn) { + myname = (char *)malloc(strlen(gUser->firstname) + strlen(gUser->lastname) + 2); + sprintf(myname, "%s %s", gUser->firstname, gUser->lastname); + } else { + myname = strdup(gUser->loginname); + } + if (type == NETWORK_WWIV) { + wwiv_addressee = strdup(addressed_to); + for (j=1;jwwivnode == atoi(address)) { + free(wwiv_addressee); + free(myname); + return 1; + } + } + free(wwiv_addressee); + free(myname); + return 0; + } else if (type == NETWORK_FIDO) { + if (strcasecmp(myname, addressed_to) == 0) { + dest = parse_fido_addr(address); + if (conf.mail_conferences[msgconf]->fidoaddr->zone == dest->zone && + conf.mail_conferences[msgconf]->fidoaddr->net == dest->net && + conf.mail_conferences[msgconf]->fidoaddr->node == dest->node && + conf.mail_conferences[msgconf]->fidoaddr->point == dest->point) { + free(dest); + free(myname); + return 1; + } + free(dest); + } + free(myname); + return 0; + } else { + if (strcasecmp(myname, addressed_to) == 0) { + free(myname); + return 1; + } + free(myname); + return 0; + } +} + +int msg_is_from(char *addressed_from, char *address, int type, int rn, int msgconf) { + char *myname; + struct fido_addr *orig; + int j; + if (rn) { + myname = (char *)malloc(strlen(gUser->firstname) + strlen(gUser->lastname) + 2); + sprintf(myname, "%s %s", gUser->firstname, gUser->lastname); + } else { + myname = strdup(gUser->loginname); + } + if (type == NETWORK_WWIV) { + free(myname); + return 0; + } else if (type == NETWORK_FIDO) { + if (strcasecmp(myname, addressed_from) == 0) { + orig = parse_fido_addr(address); + if (conf.mail_conferences[msgconf]->fidoaddr->zone == orig->zone && + conf.mail_conferences[msgconf]->fidoaddr->net == orig->net && + conf.mail_conferences[msgconf]->fidoaddr->node == orig->node && + conf.mail_conferences[msgconf]->fidoaddr->point == orig->point) { + free(orig); + free(myname); + return 1; + } + free(orig); + } + free(myname); + return 0; + } else { + if (strcasecmp(myname, addressed_from) == 0) { + free(myname); + return 1; + } + free(myname); + return 0; + } +} + struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user) { s_JamBase *jb; s_JamBaseHeader jbh; s_JamMsgHeader jmh; s_JamSubPacket* jsp; struct jam_msg *jamm; - int to_us; + int to_us; int i; int z; int j; @@ -277,36 +277,36 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r JAM_DelSubPacket(jsp); if (jmh.Attribute & MSG_PRIVATE) { - if (!msg_is_to(jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf) && - !msg_is_from(jamm->from, jamm->oaddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf)) { - - if (jamm->subject != NULL) { - free(jamm->subject); - } - if (jamm->from != NULL) { - free(jamm->from); - } - if (jamm->to != NULL) { - free(jamm->to); - } - if (jamm->oaddress != NULL) { - free(jamm->oaddress); - } - if (jamm->daddress != NULL) { - free(jamm->daddress); - } - if (jamm->msgid != NULL) { - free(jamm->msgid); - } - if (jamm->replyid != NULL) { - free(jamm->replyid); - } - free(jamm->msg_h); - free(jamm); - k++; - continue; + if (!msg_is_to(jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf) && + !msg_is_from(jamm->from, jamm->oaddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf)) { + + if (jamm->subject != NULL) { + free(jamm->subject); + } + if (jamm->from != NULL) { + free(jamm->from); + } + if (jamm->to != NULL) { + free(jamm->to); + } + if (jamm->oaddress != NULL) { + free(jamm->oaddress); + } + if (jamm->daddress != NULL) { + free(jamm->daddress); + } + if (jamm->msgid != NULL) { + free(jamm->msgid); + } + if (jamm->replyid != NULL) { + free(jamm->replyid); + } + free(jamm->msg_h); + free(jamm); + k++; + continue; } - } + } if (msghs->msg_count == 0) { msghs->msgs = (struct jam_msg **)malloc(sizeof(struct jam_msg *)); @@ -327,12 +327,12 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r return msghs; } -char *external_editor(struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email) { +char *external_editor(struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email) { char c; FILE *fptr; char *body = NULL; char buffer[256]; - int len; + int len; int totlen; char *body2 = NULL; char *tagline; @@ -344,8 +344,8 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot if (conf.external_editor_cmd != NULL) { - s_printf("\r\nUse external editor? (Y/N) "); - c = s_getc(); + s_printf(get_string(85)); + c = s_getc(); if (tolower(c) == 'y') { sprintf(buffer, "%s/node%d", conf.bbs_path, mynode); @@ -400,7 +400,7 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot } fclose(fptr); - rundoor(user, conf.external_editor_cmd, conf.external_editor_stdio); + rundoor(user, conf.external_editor_cmd, conf.external_editor_stdio); // readin msgtmp sprintf(buffer, "%s/node%d/MSGTMP", conf.bbs_path, mynode); @@ -478,14 +478,14 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot return body2; } } - return editor(user, quote, qfrom, email); + return editor(user, quote, qfrom, email); } -char *editor(struct user_record *user, char *quote, char *from, int email) { +char *editor(struct user_record *user, char *quote, char *from, int email) { int lines = 0; char buffer[256]; char linebuffer[80]; - int doquit = 0; + int doquit = 0; char **content = NULL; int i; char *msg; @@ -524,13 +524,13 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { } } } - s_printf("\r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m"); + s_printf(get_string(86)); + s_printf(get_string(87)); while(!doquit) { - s_printf("\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s", lines, next_line_buffer); + s_printf(get_string(88), lines, next_line_buffer); strcpy(linebuffer, next_line_buffer); - s_readstring(&linebuffer[strlen(next_line_buffer)], 70 - strlen(next_line_buffer)); + s_readstring(&linebuffer[strlen(next_line_buffer)], 70 - strlen(next_line_buffer)); memset(next_line_buffer, 0, 70); if (strlen(linebuffer) == 70 && linebuffer[69] != ' ') { @@ -538,7 +538,7 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { if (linebuffer[i] == ' ') { linebuffer[i] = '\0'; strcpy(next_line_buffer, &linebuffer[i+1]); - s_printf("\e[%dD\e[0K", 70 - i); + s_printf("\e[%dD\e[0K", 70 - i); break; } } @@ -610,20 +610,20 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { return NULL; } else if (toupper(linebuffer[1]) == 'Q') { if (quote == NULL) { - s_printf("\r\nNo message to quote!\r\n"); + s_printf(get_string(89)); } else { - s_printf("\r\n"); + s_printf("\r\n"); for (i=0;i quotelines) { qto = quotelines; @@ -632,7 +632,7 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { qfrom = 0; } if (qfrom > qto) { - s_printf("Quoting Cancelled\r\n"); + s_printf(get_string(92)); } for (i=qfrom;i<=qto;i++) { @@ -646,38 +646,38 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { lines++; } - s_printf("\r\n\e[1;32mMagicka Internal Editor, Type \e[1;37m/S \e[1;32mto save, \e[1;37m/A \e[1;32mto abort and \e[1;37m/? \e[1;32mfor help\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m"); + s_printf(get_string(86)); + s_printf(get_string(87)); for (i=0;i= lines) { - s_printf("\r\nAborted...\r\n"); + s_printf(get_string(39)); } else { for (i=z;i= lines) { - s_printf("\r\nAborted...\r\n"); + s_printf(get_string(39)); } else { - s_printf("\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m%s", z, content[z]); - s_printf("\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m", z); - s_readstring(linebuffer, 70); + s_printf(get_string(88), z, content[z]); + s_printf(get_string(103), z); + s_readstring(linebuffer, 70); free(content[z]); content[z] = strdup(linebuffer); } } } else if (toupper(linebuffer[1]) == 'I') { - s_printf("\r\nInsert before which line? "); - s_readstring(buffer, 6); + s_printf(get_string(104)); + s_readstring(buffer, 6); if (strlen(buffer) == 0) { - s_printf("\r\nAborted...\r\n"); + s_printf(get_string(39)); } else { z = atoi(buffer); if (z < 0 || z >= lines) { - s_printf("\r\nAborted...\r\n"); + s_printf(get_string(39)); } else { - s_printf("\r\n\e[1;30m[\e[1;34m%3d\e[1;30m]: \e[0m", z); - s_readstring(linebuffer, 70); + s_printf(get_string(103), z); + s_readstring(linebuffer, 70); lines++; content = (char **)realloc(content, sizeof(char *) * lines); @@ -749,9 +749,9 @@ char *editor(struct user_record *user, char *quote, char *from, int email) { return NULL; } -void read_message(struct user_record *user, struct msg_headers *msghs, int mailno) { +void read_message(struct user_record *user, struct msg_headers *msghs, int mailno) { s_JamBase *jb; - s_JamMsgHeader jmh; + s_JamMsgHeader jmh; s_JamSubPacket* jsp; s_JamSubfield jsf; s_JamLastRead jlr; @@ -770,8 +770,8 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn char c; char *replybody; struct fido_addr *from_addr = NULL; - int i, j; - char timestr[17]; + int i, j; + char timestr[17]; int doquit = 0; int skip_line = 0; int chars = 0; @@ -799,19 +799,19 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn if (msghs->msgs[mailno]->oaddress != NULL && conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { from_addr = parse_fido_addr(msghs->msgs[mailno]->oaddress); - s_printf("\e[2J\e[1;32mFrom : \e[1;37m%s (%d:%d/%d.%d)\r\n", msghs->msgs[mailno]->from, from_addr->zone, from_addr->net, from_addr->node, from_addr->point); + s_printf(get_string(105), msghs->msgs[mailno]->from, from_addr->zone, from_addr->net, from_addr->node, from_addr->point); free(from_addr); } else { - s_printf("\e[2J\e[1;32mFrom : \e[1;37m%s\r\n", msghs->msgs[mailno]->from); + s_printf(get_string(106), msghs->msgs[mailno]->from); } - s_printf("\e[1;32mTo : \e[1;37m%-27.27s \e[1;32mConf : \e[1;37m%-27.27s\r\n", msghs->msgs[mailno]->to, conf.mail_conferences[user->cur_mail_conf]->name); - s_printf("\e[1;32mSubject : \e[1;37m%-27.27s \e[1;32mArea : \e[1;37m%-27.27s\r\n", msghs->msgs[mailno]->subject, conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->name); - localtime_r((time_t *)&msghs->msgs[mailno]->msg_h->DateWritten, &msg_date); - sprintf(buffer, "\e[1;32mDate : \e[1;37m%s", asctime(&msg_date)); + s_printf(get_string(107), msghs->msgs[mailno]->to, conf.mail_conferences[user->cur_mail_conf]->name); + s_printf(get_string(108), msghs->msgs[mailno]->subject, conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->name); + localtime_r((time_t *)&msghs->msgs[mailno]->msg_h->DateWritten, &msg_date); + sprintf(buffer, "%s", asctime(&msg_date)); buffer[strlen(buffer) - 1] = '\0'; - s_printf("%s \e[1;32mMsgNo : \e[1;37m%4d of %4d\r\n", buffer, mailno + 1, msghs->msg_count); - s_printf("\e[1;32mAttribs : \e[1;37m%s\r\n", (msghs->msgs[mailno]->msg_h->Attribute & MSG_SENT ? "SENT" : "")); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(109), buffer, mailno + 1, msghs->msg_count); + s_printf(get_string(110), (msghs->msgs[mailno]->msg_h->Attribute & MSG_SENT ? "SENT" : "")); + s_printf(get_string(111)); body = (char *)malloc(msghs->msgs[mailno]->msg_h->TxtLen); @@ -861,16 +861,16 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn if (body[z] == '\r' || chars == 79) { chars = 0; if (body[z] == '\r') { - s_printf("\r\n"); + s_printf("\r\n"); } else { - s_putchar(body[z]); + s_putchar(body[z]); } lines++; if (lines >= 17) { - s_printf("\e[1;37mPress a key to continue...\e[0m"); - s_getc(); + s_printf(get_string(185)); + s_getc(); lines = 0; - s_printf("\e[7;1H\e[0J"); + s_printf("\e[7;1H\e[0J"); } } else if (body[z] == '\e' && body[z + 1] == '[') { ansi = z; @@ -879,7 +879,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn if (body[z] == 'm') { strncpy(buffer, &body[ansi], (z - ansi) + 1); buffer[z - ansi + 1] = '\0'; - s_printf("%s", buffer); + s_printf("%s", buffer); } else if (body[z] == 'A') { j = atoi(&body[ansi + 2]); if (j == 0 && ansi + 2 == z) { @@ -887,7 +887,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn } for (i=0;i= 0) { - s_printf("\e[A"); + s_printf("\e[A"); lines--; } else { break; @@ -900,7 +900,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn } for (i=0;i= 0) { - s_printf("\e[D"); + s_printf("\e[D"); chars--; } else { break; @@ -935,18 +935,18 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn } } else { chars++; - s_putchar(body[z]); + s_putchar(body[z]); } } - s_printf("\r\n\e[1;37mPress \e[1;36mR \e[1;37mto reply, \e[1;36mQ \e[1;37mto quit, \e[1;36mB \e[1;37mto go Back, \e[1;36mSPACE \e[1;37mfor Next Mesage..."); + s_printf(get_string(112)); - c = s_getc(); + c = s_getc(); if (tolower(c) == 'r') { JAM_CloseMB(jb); if (user->sec_level < conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->write_sec_level) { - s_printf("\r\nSorry, you are not allowed to post in this area\r\n"); + s_printf(get_string(113)); } else { if (msghs->msgs[mailno]->subject != NULL) { if (strncasecmp(msghs->msgs[mailno]->subject, "RE:", 3) != 0) { @@ -958,24 +958,24 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn subject = (char *)malloc(strlen(buffer) + 1); strcpy(subject, buffer); - s_printf("\r\n\r\nReplying to: %s\r\n", subject); - s_printf("Change Subject? (Y/N) "); + s_printf(get_string(114), subject); + s_printf(get_string(115)); - c = s_getc(); + c = s_getc(); if (tolower(c) == 'y') { - s_printf("\r\nNew subject: "); - s_readstring(buffer, 25); + s_printf(get_string(116)); + s_readstring(buffer, 25); if (strlen(buffer) == 0) { - s_printf("\r\nOk, not changing the subject line..."); + s_printf(get_string(117)); } else { free(subject); subject = (char *)malloc(strlen(buffer) + 1); strcpy(subject, buffer); } } - s_printf("\r\n"); + s_printf("\r\n"); if (msghs->msgs[mailno]->from != NULL) { strcpy(buffer, msghs->msgs[mailno]->from); @@ -1004,7 +1004,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn to = (char *)malloc(strlen(buffer) + 1); strcpy(to, buffer); } - replybody = external_editor(user, to, from, body, msghs->msgs[mailno]->from, subject, 0); + replybody = external_editor(user, to, from, body, msghs->msgs[mailno]->from, subject, 0); if (replybody != NULL) { jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); @@ -1232,7 +1232,7 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn } else if (c == ' ') { mailno++; if (mailno >= msghs->msg_count) { - s_printf("\r\n\r\nNo more messages\r\n"); + s_printf(get_string(118)); doquit = 1; } } else if (tolower(c) == 'b') { @@ -1243,11 +1243,11 @@ void read_message(struct user_record *user, struct msg_headers *msghs, int mailn } } -int mail_menu(struct user_record *user) { +int mail_menu(struct user_record *user) { int doquit = 0; int domail = 0; char c; - char buffer[256]; + char buffer[256]; char buffer2[256]; int i; int j; @@ -1256,7 +1256,7 @@ int mail_menu(struct user_record *user) { struct msg_headers *msghs; s_JamBase *jb; - s_JamMsgHeader jmh; + s_JamMsgHeader jmh; s_JamSubPacket* jsp; s_JamSubfield jsf; s_JamLastRead jlr; @@ -1266,11 +1266,11 @@ int mail_menu(struct user_record *user) { char *subject; char *from; char *to; - char timestr[17]; + char timestr[17]; char *msg; int closed; - struct fido_addr *from_addr = NULL; - int wwiv_to; + struct fido_addr *from_addr = NULL; + int wwiv_to; struct stat s; int do_internal_menu = 0; char *lRet; @@ -1301,12 +1301,12 @@ int mail_menu(struct user_record *user) { while (!domail) { if (do_internal_menu == 1) { - s_displayansi("mailmenu"); + s_displayansi("mailmenu"); - s_printf("\e[0m\r\nConf: (%d) %s\r\nArea: (%d) %s\r\nTL: %dm :> ", 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(); + 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); @@ -1320,15 +1320,15 @@ int mail_menu(struct user_record *user) { lua_pop(L, 1); c = lRet[0]; } - switch(tolower(c)) { - case '!': - { - mail_scan(user); - } - break; + switch(tolower(c)) { + case '!': + { + mail_scan(user); + } + break; case 'd': { - s_printf("\r\n"); + s_printf("\r\n"); // list mail in message base msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); if (msghs != NULL && msghs->msg_count > 0) { @@ -1344,9 +1344,9 @@ int mail_menu(struct user_record *user) { all_unread = 1; } JAM_CloseMB(jb); - s_printf("Read message [1-%d] or N for New: ", msghs->msg_count); - - s_readstring(buffer, 6); + s_printf(get_string(120), msghs->msg_count); + + s_readstring(buffer, 6); if (tolower(buffer[0]) == 'n') { if (all_unread == 0) { @@ -1365,7 +1365,7 @@ int mail_menu(struct user_record *user) { } if (i > 0 && i <= msghs->msg_count) { - read_message(user, msghs, i - 1); + read_message(user, msghs, i - 1); } } } @@ -1377,14 +1377,14 @@ int mail_menu(struct user_record *user) { case 'p': { if (user->sec_level < conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->write_sec_level) { - s_printf("\r\nSorry, you are not allowed to post in this area\r\n"); + s_printf(get_string(113)); break; } if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV && conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) { sprintf(buffer, "ALL"); } else { - s_printf("\r\nTO: "); - s_readstring(buffer, 16); + s_printf(get_string(54)); + s_readstring(buffer, 16); } if (strlen(buffer) == 0) { strcpy(buffer, "ALL"); @@ -1392,41 +1392,41 @@ int mail_menu(struct user_record *user) { if (conf.mail_conferences[user->cur_mail_conf]->networked == 0 && strcasecmp(buffer, "ALL") != 0) { if (check_user(buffer)) { - s_printf("\r\n\r\nInvalid Username\r\n"); + s_printf(get_string(55)); break; } } if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { - s_printf("\r\nADDR: "); - s_readstring(buffer2, 32); + s_printf(get_string(121)); + s_readstring(buffer2, 32); if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { from_addr = parse_fido_addr(buffer2); if (!from_addr) { - s_printf("\r\n\r\nInvalid Address\r\n"); + s_printf(get_string(122)); break; } else { if (from_addr->zone == 0 && from_addr->net == 0 && from_addr->node == 0 && from_addr->point == 0) { free(from_addr); - s_printf("\r\n\r\nInvalid Address\r\n"); + s_printf(get_string(122)); break; } - s_printf(buffer2, "\r\nMailing to %d:%d/%d.%d\r\n", from_addr->zone, from_addr->net, from_addr->node, from_addr->point); - } + s_printf(get_string(123), from_addr->zone, from_addr->net, from_addr->node, from_addr->point); + } } else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV) { wwiv_to = atoi(buffer2); if (wwiv_to == 0) { - s_printf("\r\n\r\nInvalid Address\r\n"); + s_printf(get_string(122)); break; } else { - s_printf("\r\nMailing to @%d\r\n", wwiv_to); + s_printf(get_string(124), wwiv_to); } } } to = strdup(buffer); - s_printf("\r\nSUBJECT: "); - s_readstring(buffer, 25); + s_printf(get_string(56)); + s_readstring(buffer, 25); if (strlen(buffer) == 0) { - s_printf("\r\nAborted!\r\n"); + s_printf(get_string(39)); free(to); if (from_addr != NULL) { free(from_addr); @@ -1435,17 +1435,17 @@ int mail_menu(struct user_record *user) { } subject = strdup(buffer); - // post a message - if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { - from = strdup(user->loginname); - } else { - from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); - sprintf(from, "%s %s", user->firstname, user->lastname); - } - msg = external_editor(user, to, from, NULL, NULL, subject, 0); - - free(from); - + // post a message + if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { + from = strdup(user->loginname); + } else { + from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); + sprintf(from, "%s %s", user->firstname, user->lastname); + } + msg = external_editor(user, to, from, NULL, NULL, subject, 0); + + free(from); + if (msg != NULL) { jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); if (!jb) { @@ -1469,7 +1469,7 @@ int mail_menu(struct user_record *user) { if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV) { sprintf(buffer, "%s #%d @%d (%s)", user->loginname, user->id, conf.mail_conferences[user->cur_mail_conf]->wwivnode, user->firstname); } else { - sprintf(buffer, "%s %s", user->firstname, user->lastname); + sprintf(buffer, "%s %s", user->firstname, user->lastname); } } @@ -1641,7 +1641,7 @@ int mail_menu(struct user_record *user) { break; case 'l': { - s_printf("\r\n"); + s_printf("\r\n"); // list mail in message base msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); if (msghs != NULL && msghs->msg_count > 0) { @@ -1657,9 +1657,9 @@ int mail_menu(struct user_record *user) { all_unread = 1; } JAM_CloseMB(jb); - s_printf("Start at message [1-%d] or N for New? ", msghs->msg_count); - - s_readstring(buffer, 6); + s_printf(get_string(125), msghs->msg_count); + + s_readstring(buffer, 6); if (tolower(buffer[0]) == 'n') { if (all_unread == 0) { k = jlr.HighReadMsg; @@ -1679,19 +1679,19 @@ int mail_menu(struct user_record *user) { } } closed = 0; - s_printf("\e[2J\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m"); + s_printf(get_string(126)); for (j=i-1;jmsg_count;j++) { localtime_r((time_t *)&msghs->msgs[j]->msg_h->DateWritten, &msg_date); if (msghs->msgs[j]->msg_no > jlr.HighReadMsg || all_unread) { - s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); + s_printf(get_string(127), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); } else { - s_printf("\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); + s_printf(get_string(128), j + 1, msghs->msgs[j]->subject, msghs->msgs[j]->from, msghs->msgs[j]->to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100); } - + if ((j - (i - 1)) != 0 && (j - (i - 1)) % 20 == 0) { - s_printf("(#) Read Message # (Q) Quit (ENTER) Continue\r\n"); - s_readstring(buffer, 6); + s_printf(get_string(129)); + s_readstring(buffer, 6); if (tolower(buffer[0]) == 'q') { closed = 1; @@ -1700,21 +1700,21 @@ int mail_menu(struct user_record *user) { z = atoi(buffer); if (z > 0 && z <= msghs->msg_count) { closed = 1; - read_message(user, msghs, z - 1); + read_message(user, msghs, z - 1); break; } } - s_printf("\e[2J\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m"); + s_printf(get_string(126)); } } if (closed == 0) { - s_printf("(#) Read Message # (ENTER) Quit\r\n"); - s_readstring(buffer, 6); + s_printf(get_string(129)); + s_readstring(buffer, 6); if (strlen(buffer) > 0) { z = atoi(buffer); if (z > 0 && z <= msghs->msg_count) { - read_message(user, msghs, z - 1); + read_message(user, msghs, z - 1); } } } @@ -1724,30 +1724,30 @@ int mail_menu(struct user_record *user) { free_message_headers(msghs); } } else { - s_printf("\r\nThere is no mail in this area\r\n"); + s_printf(get_string(130)); } } break; case 'c': { - s_printf("\r\n\r\nMail Conferences:\r\n\r\n"); + s_printf(get_string(131)); for (i=0;isec_level <= user->sec_level) { - s_printf(" %d. %s\r\n", i, conf.mail_conferences[i]->name); - } + s_printf(get_string(132), i, conf.mail_conferences[i]->name); + } if (i != 0 && i % 20 == 0) { - s_printf("Press any key to continue...\r\n"); - c = s_getc(); + s_printf(get_string(6)); + c = s_getc(); } } - s_printf("Enter the conference number: "); - s_readstring(buffer, 5); + s_printf(get_string(133)); + s_readstring(buffer, 5); if (tolower(buffer[0]) != 'q') { j = atoi(buffer); if (j < 0 || j >= conf.mail_conference_count || conf.mail_conferences[j]->sec_level > user->sec_level) { - s_printf("\r\nInvalid conference number!\r\n"); + s_printf(get_string(134)); } else { - s_printf("\r\n"); + s_printf("\r\n"); user->cur_mail_conf = j; user->cur_mail_area = 0; } @@ -1756,24 +1756,24 @@ int mail_menu(struct user_record *user) { break; case 'a': { - s_printf("\r\n\r\nMail Areas:\r\n\r\n"); + s_printf(get_string(135)); for (i=0;icur_mail_conf]->mail_area_count;i++) { if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->read_sec_level <= user->sec_level) { - s_printf(" %d. %s\r\n", i, conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->name); - } + s_printf(get_string(136), i, conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->name); + } if (i != 0 && i % 20 == 0) { - s_printf("Press any key to continue...\r\n"); - c = s_getc(); + s_printf(get_string(6)); + c = s_getc(); } } - s_printf("Enter the area number: "); - s_readstring(buffer, 5); + s_printf(get_string(137)); + s_readstring(buffer, 5); if (tolower(buffer[0]) != 'q') { j = atoi(buffer); if (j < 0 || j >= conf.mail_conferences[user->cur_mail_conf]->mail_area_count || conf.mail_conferences[user->cur_mail_conf]->mail_areas[j]->read_sec_level > user->sec_level) { - s_printf("\r\nInvalid area number!\r\n"); + s_printf(get_string(138)); } else { - s_printf("\r\n"); + s_printf("\r\n"); user->cur_mail_area = j; } } @@ -1786,8 +1786,8 @@ int mail_menu(struct user_record *user) { break; case 'g': { - s_printf("\r\nAre you sure you want to log off? (Y/N)"); - c = s_getc(); + s_printf(get_string(53)); + c = s_getc(); if (tolower(c) == 'y') { domail = 1; doquit = 1; @@ -1796,14 +1796,14 @@ int mail_menu(struct user_record *user) { break; case 'e': { - send_email(user); + send_email(user); } break; case 'r': { // Read your email... - s_printf("\r\n"); - list_emails(user); + s_printf("\r\n"); + list_emails(user); } break; case '}': @@ -1868,108 +1868,108 @@ int mail_menu(struct user_record *user) { return doquit; } -void mail_scan(struct user_record *user) { +void mail_scan(struct user_record *user) { s_JamBase *jb; s_JamBaseHeader jbh; s_JamLastRead jlr; - struct msg_headers *msghs; + struct msg_headers *msghs; char c; int i; int j; - int lines = 0; - - s_printf("\r\nScan for new mail? (Y/N) : "); - c = s_getc(); + int lines = 0; + + s_printf(get_string(139)); + c = s_getc(); if (tolower(c) == 'y') { for (i=0;isec_level > user->sec_level) { continue; } - s_printf("\r\n\e[1;32m%d. %s\e[0m\r\n", i, conf.mail_conferences[i]->name); - lines+=2; - if (lines == 22) { - s_printf("Press any key to continue...\r\n"); - s_getc(); - lines = 0; - } - for (j=0;jmail_area_count;j++) { + s_printf(get_string(140), i, conf.mail_conferences[i]->name); + lines+=2; + if (lines == 22) { + s_printf(get_string(6)); + s_getc(); + lines = 0; + } + for (j=0;jmail_area_count;j++) { if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) { continue; - } - jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path); - if (!jb) { - dolog("Unable to open message base"); - continue; - } - if (JAM_ReadMBHeader(jb, &jbh) != 0) { - JAM_CloseMB(jb); - continue; - } - if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { - if (jbh.ActiveMsgs == 0) { - JAM_CloseMB(jb); - continue; - } - if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { - msghs = read_message_headers(i, j, user); - if (msghs != NULL) { - if (msghs->msg_count > 0) { - s_printf("\e[1;37m --> %d. %s (%d new)\e[0m\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count); - lines++; - if (lines == 22) { - s_printf("Press any key to continue...\r\n"); - s_getc(); - lines = 0; - } - } - free_message_headers(msghs); - } - } else { - s_printf("\e[1;37m --> %d. %s (%d new)\e[0m\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs); - lines++; - if (lines == 22) { - s_printf("Press any key to continue...\r\n"); - s_getc(); - lines = 0; - } - } - } else { - if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) { - if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { - msghs = read_message_headers(i, j, user); - if (msghs != NULL) { - if (msghs->msg_count > 0) { - if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) { - s_printf("\e[1;37m --> %d. %s (%d new)\e[0m\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_no - jlr.HighReadMsg); - lines++; - if (lines == 22) { - s_printf("Press any key to continue...\r\n"); - s_getc(); - lines = 0; - } - } - } - free_message_headers(msghs); - } - } else { - s_printf("\e[1;37m --> %d. %s (%d new)\e[0m\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg); - lines++; - if (lines == 22) { - s_printf("Press any key to continue...\r\n"); - s_getc(); - lines = 0; - } - } - } else { - JAM_CloseMB(jb); - continue; - } - } - JAM_CloseMB(jb); + } + jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path); + if (!jb) { + dolog("Unable to open message base"); + continue; + } + if (JAM_ReadMBHeader(jb, &jbh) != 0) { + JAM_CloseMB(jb); + continue; + } + if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { + if (jbh.ActiveMsgs == 0) { + JAM_CloseMB(jb); + continue; + } + if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { + msghs = read_message_headers(i, j, user); + if (msghs != NULL) { + if (msghs->msg_count > 0) { + s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count); + lines++; + if (lines == 22) { + s_printf(get_string(6)); + s_getc(); + lines = 0; + } + } + free_message_headers(msghs); + } + } else { + s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs); + lines++; + if (lines == 22) { + s_printf(get_string(6)); + s_getc(); + lines = 0; + } + } + } else { + if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) { + if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { + msghs = read_message_headers(i, j, user); + if (msghs != NULL) { + if (msghs->msg_count > 0) { + if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) { + s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_no - jlr.HighReadMsg); + lines++; + if (lines == 22) { + s_printf(get_string(6)); + s_getc(); + lines = 0; + } + } + } + free_message_headers(msghs); + } + } else { + s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg); + lines++; + if (lines == 22) { + s_printf(get_string(6)); + s_getc(); + lines = 0; + } + } + } else { + JAM_CloseMB(jb); + continue; + } + } + JAM_CloseMB(jb); } } - s_printf("\r\nPress any key to continue...\r\n"); - s_getc(); + s_printf(get_string(6)); + s_getc(); } } diff --git a/main.c b/main.c index 52f8112..7843f4f 100644 --- a/main.c +++ b/main.c @@ -311,6 +311,8 @@ static int handler(void* user, const char* section, const char* name, conf->netmail_sem = strdup(value); } else if (strcasecmp(name, "pid file") == 0) { conf->pid_file = strdup(value); + } else if (strcasecmp(name, "string file") == 0) { + conf->string_file = strdup(value); } } else if (strcasecmp(section, "mail conferences") == 0) { if (conf->mail_conference_count == 0) { @@ -738,6 +740,7 @@ int main(int argc, char **argv) { conf.echomail_sem = NULL; conf.netmail_sem = NULL; conf.telnet_port = 0; + conf.string_file = NULL; // Load BBS data if (ini_parse(argv[1], handler, &conf) <0) { @@ -764,6 +767,8 @@ int main(int argc, char **argv) { exit(-1); } + load_strings(); + if (conf.fork) { if (stat(conf.pid_file, &s) == 0) { fprintf(stderr, "Magicka already running or stale pid file at: %s\n", conf.pid_file); diff --git a/main_menu.c b/main_menu.c index 2f1c070..a006352 100644 --- a/main_menu.c +++ b/main_menu.c @@ -47,7 +47,7 @@ void main_menu(struct user_record *user) { s_displayansi("mainmenu"); - s_printf("\r\n\e[0mTL: %dm :> ", user->timeleft); + s_printf(get_string(142), user->timeleft); c = s_getc(); } else { @@ -75,21 +75,21 @@ void main_menu(struct user_record *user) { if (conf.text_file_count > 0) { while(1) { - s_printf("\r\n\e[1;32mText Files Collection\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(143)); + s_printf(get_string(144)); for (i=0;iname); + s_printf(get_string(145), i, conf.text_files[i]->name); } - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); - s_printf("Enter the number of a text file to display or Q to quit: "); + 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("Press any key to continue..."); + s_printf(get_string(6)); s_getc(); s_printf("\r\n"); } @@ -98,8 +98,8 @@ void main_menu(struct user_record *user) { } } } else { - s_printf("\r\nSorry, there are no text files to display\r\n"); - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(148)); + s_printf(get_string(6)); s_getc(); } } @@ -127,7 +127,7 @@ void main_menu(struct user_record *user) { while (stat(buffer, &s) == 0) { sprintf(buffer, "bulletin%d", i); s_displayansi(buffer); - s_printf("\e[0mPress any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); i++; sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i); @@ -151,7 +151,7 @@ void main_menu(struct user_record *user) { break; case 'g': { - s_printf("\r\nAre you sure you want to log off? (Y/N)"); + s_printf(get_string(53)); c = s_getc(); if (tolower(c) == 'y') { doquit = 1; diff --git a/settings.c b/settings.c index ca1466d..45ba3c0 100644 --- a/settings.c +++ b/settings.c @@ -11,23 +11,23 @@ void settings_menu(struct user_record *user) { char *hash; while (!dosettings) { - s_printf("\e[2J\e[1;32mYour Settings\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); - s_printf("\e[0;36mP. \e[1;37mPassword (\e[1;33mNot Shown\e[1;37m)\r\n"); - s_printf("\e[0;36mL. \e[1;37mLocation (\e[1;33m%s\e[1;37m)\r\n", user->location); - s_printf("\e[0;36mQ. \e[1;37mQuit to Main Menu\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(149)); + s_printf(get_string(150)); + s_printf(get_string(151)); + s_printf(get_string(152), user->location); + s_printf(get_string(153)); + s_printf(get_string(154)); c = s_getc(); switch(tolower(c)) { case 'p': { - s_printf("\r\nEnter your current password: "); + s_printf(get_string(155)); s_readpass(buffer, 16); hash = hash_sha256(buffer, user->salt); if (strcmp(hash, user->password) == 0) { - s_printf("\r\nEnter your new password (8 chars min): "); + s_printf(get_string(156)); s_readstring(buffer, 16); if (strlen(buffer) >= 8) { free(user->password); @@ -37,18 +37,18 @@ void settings_menu(struct user_record *user) { user->password = hash_sha256(buffer, user->salt); save_user(user); - s_printf("\r\nPassword Changed!\r\n"); + s_printf(get_string(157)); } else { - s_printf("\r\nPassword too short!\r\n"); + s_printf(get_string(158)); } } else { - s_printf("\r\nPassword Incorrect!\r\n"); + s_printf(get_string(159)); } } break; case 'l': { - s_printf("\r\nEnter your new location: "); + s_printf(get_string(160)); s_readstring(buffer, 32); free(user->location); user->location = (char *)malloc(strlen(buffer) + 1); diff --git a/strings.c b/strings.c new file mode 100644 index 0000000..f08ef2c --- /dev/null +++ b/strings.c @@ -0,0 +1,83 @@ +#include "bbs.h" +#include +#include +#include + +extern struct bbs_config conf; + +char *undefined = "Undefined String"; +char **strings; +int string_count; + +void chomp(char *string) { + while ((string[strlen(string)-1] == '\r' || string[strlen(string)-1] == '\n') && strlen(string)) { + string[strlen(string)-1] = '\0'; + } +} + +char *parse_newlines(char *string) { + char *newstring = (char *)malloc(strlen(string) + 1); + int pos = 0; + int i; + for (i=0;i= string_count) { + return undefined; + } + + return strings[offset]; +} + +void load_strings() { + FILE *fptr; + char buffer[1024]; + + if (conf.string_file == NULL) { + fprintf(stderr, "Strings file can not be undefined!\n"); + exit(-1); + } + + fptr = fopen(conf.string_file, "r"); + if (!fptr) { + fprintf(stderr, "Unable to open strings file!\n"); + exit(-1); + } + + string_count = 0; + + fgets(buffer, 1024, fptr); + while (!feof(fptr)) { + chomp(buffer); + if (string_count == 0) { + strings = (char **)malloc(sizeof(char *)); + } else { + strings = (char **)realloc(strings, sizeof(char *) * (string_count + 1)); + } + strings[string_count] = parse_newlines(buffer); + string_count++; + fgets(buffer, 1024, fptr); + } + fclose(fptr); +} diff --git a/users.c b/users.c index 62fc331..4fefdda 100644 --- a/users.c +++ b/users.c @@ -345,25 +345,25 @@ void list_users(struct user_record *user) { sqlite3_close(db); exit(1); } - s_printf("\e[2J\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); - s_printf("User Name Location Times On\r\n"); - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(161)); + s_printf(get_string(162)); + s_printf(get_string(163)); i = 0; while (sqlite3_step(res) == SQLITE_ROW) { - s_printf("\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%5d\r\n", sqlite3_column_text(res, 0), sqlite3_column_text(res, 1), sqlite3_column_int(res, 2)); + s_printf(get_string(164), sqlite3_column_text(res, 0), sqlite3_column_text(res, 1), sqlite3_column_int(res, 2)); i++; if (i == 20) { - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); i = 0; } } - s_printf("\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"); + s_printf(get_string(165)); sqlite3_finalize(res); sqlite3_close(db); - s_printf("Press any key to continue...\r\n"); + s_printf(get_string(6)); s_getc(); } @@ -422,17 +422,17 @@ struct user_record *new_user() { passok = 0; nameok = 0; do { - s_printf("\r\nWhat is your login name: "); + s_printf(get_string(166)); s_readstring(buffer, 16); s_printf("\r\n"); if (strlen(buffer) < 3) { - s_printf("Sorry, that name is too short.\r\n"); + s_printf(get_string(167)); continue; } for (i=0;i= 97 && tolower(buffer[i]) <= 122)) { - s_printf("Sorry, invalid character, can only use alpha characters.\r\n"); + s_printf(get_string(168)); nameok = 1; break; } @@ -442,77 +442,77 @@ struct user_record *new_user() { continue; } if (strcasecmp(buffer, "unknown") == 0) { - s_printf("Sorry, that name is reserved.\r\n"); + s_printf(get_string(169)); continue; } if (strcasecmp(buffer, "all") == 0) { - s_printf("Sorry, that name is reserved.\r\n"); + s_printf(get_string(169)); continue; } if (strcasecmp(buffer, "new") == 0) { - s_printf("Sorry, that name is reserved.\r\n"); + s_printf(get_string(169)); continue; } user->loginname = strdup(buffer); nameok = check_user(user->loginname); if (!nameok) { - s_printf("Sorry, that name is in use.\r\n"); + s_printf(get_string(170)); free(user->loginname); memset(buffer, 0, 256); } } while (!nameok); - s_printf("What is your first name: "); + s_printf(get_string(171)); memset(buffer, 0, 256); s_readstring(buffer, 32); s_printf("\r\n"); user->firstname = strdup(buffer); - s_printf("What is your last name: "); + s_printf(get_string(172)); memset(buffer, 0, 256); s_readstring(buffer, 32); s_printf("\r\n"); user->lastname = strdup(buffer); - s_printf("What is your e-mail address: "); + s_printf(get_string(173)); memset(buffer, 0, 256); s_readstring(buffer, 64); s_printf("\r\n"); user->email = strdup(buffer); - s_printf("Where are you located: "); + s_printf(get_string(174)); memset(buffer, 0, 256); s_readstring(buffer, 32); s_printf("\r\n"); user->location = strdup(buffer); do { - s_printf("What password would you like (at least 8 characters): "); + s_printf(get_string(175)); memset(buffer, 0, 256); s_readstring(buffer, 16); s_printf("\r\n"); if (strlen(buffer) >= 8) { passok = 1; } else { - s_printf("Password too short!\r\n"); + s_printf(get_string(158)); } } while (!passok); gen_salt(&user->salt); user->password = hash_sha256(buffer, user->salt); - s_printf("You Entered:\r\n"); - s_printf("-------------------------------------\r\n"); - s_printf("Login Name: "); + s_printf(get_string(176)); + s_printf(get_string(177)); + s_printf(get_string(178)); s_printf(user->loginname); - s_printf("\r\nFirst Name: "); + s_printf(get_string(179)); s_printf(user->firstname); - s_printf("\r\nLast Name: "); + s_printf(get_string(180)); s_printf(user->lastname); - s_printf("\r\nE-mail: "); + s_printf(get_string(181)); s_printf(user->email); - s_printf("\r\nLocation: "); + s_printf(get_string(182)); s_printf(user->location); - s_printf("\r\n-------------------------------------\r\n"); - s_printf("Is this Correct? (Y/N)"); + s_printf(get_string(183)); + s_printf(get_string(184)); c = s_getchar(); while (tolower(c) != 'y' && tolower(c) != 'n') { c = s_getchar();