From a5103db5dcbf40c3bc7a4e80759978e9d9e03f6f Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Mon, 28 Mar 2016 14:46:48 +1000 Subject: [PATCH] Experimental WWIVnet support --- bbs.c | 5 +++++ bbs.h | 4 +++- chat_system.c | 2 +- mail_menu.c | 48 +++++++++++++++++++++++++++++++++++++----------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/bbs.c b/bbs.c index a1e4a90..411d627 100644 --- a/bbs.c +++ b/bbs.c @@ -220,9 +220,13 @@ static int mail_area_handler(void* user, const char* section, const char* name, if (strcasecmp(name, "type") == 0) { if (strcasecmp(value, "fido") == 0) { mc->nettype = NETWORK_FIDO; + } else if (strcasecmp(value, "wwiv") == 0) { + mc->nettype = NETWORK_WWIV; } } else if (strcasecmp(name, "fido node") == 0) { mc->fidoaddr = parse_fido_addr(value); + } else if (strcasecmp(name, "wwiv node") == 0) { + mc->wwivnode = atoi(value); } } else { // check if it's partially filled in @@ -318,6 +322,7 @@ static int handler(void* user, const char* section, const char* name, conf->mail_conferences[conf->mail_conference_count]->path = strdup(value); conf->mail_conferences[conf->mail_conference_count]->tagline = NULL; conf->mail_conferences[conf->mail_conference_count]->mail_area_count = 0; + conf->mail_conferences[conf->mail_conference_count]->nettype = 0; conf->mail_conference_count++; } else if (strcasecmp(section, "file directories") == 0) { if (conf->file_directory_count == 0) { diff --git a/bbs.h b/bbs.h index 18bed68..6160a30 100644 --- a/bbs.h +++ b/bbs.h @@ -7,7 +7,8 @@ #define VERSION_MINOR 1 #define VERSION_STR "dev" -#define NETWORK_FIDO 0 +#define NETWORK_FIDO 1 +#define NETWORK_WWIV 2 #define TYPE_LOCAL_AREA 0 #define TYPE_NETMAIL_AREA 1 @@ -57,6 +58,7 @@ struct mail_conference { int mail_area_count; struct mail_area **mail_areas; struct fido_addr *fidoaddr; + int wwivnode; }; struct file_sub { diff --git a/chat_system.c b/chat_system.c index 23bc154..85f9a95 100644 --- a/chat_system.c +++ b/chat_system.c @@ -134,7 +134,7 @@ void chat_system(int sock, struct user_record *user) { } if (inet_pton(AF_INET, conf.irc_server, &servaddr.sin_addr) != 0) { hostname_to_ip(conf.irc_server, buffer); - if (!inet_pton(AF_INET, conf.irc_server, &servaddr.sin_addr)) { + if (!inet_pton(AF_INET, buffer, &servaddr.sin_addr)) { return; } } diff --git a/mail_menu.c b/mail_menu.c index a6417fb..07038f2 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -396,17 +396,32 @@ void read_message(int socket, struct user_record *user, int mailno) { free(from); } if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { - from = (char *)malloc(strlen(user->loginname) + 1); - strcpy(from, user->loginname); + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV) { + from = (char *)malloc(strlen(user->loginname) + 20); + sprintf(from, "%s #%d @%d", user->loginname, user->id, conf.mail_conferences[user->cur_mail_conf]->wwivnode); + } else { + from = (char *)malloc(strlen(user->loginname) + 1); + strcpy(from, user->loginname); + } } else { - from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); - sprintf(from, "%s %s", user->firstname, user->lastname); + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV) { + from = (char *)malloc(strlen(user->loginname) + 23 + strlen(user->firstname)); + sprintf(from, "%s #%d @%d (%s)", user->loginname, user->id, conf.mail_conferences[user->cur_mail_conf]->wwivnode, user->firstname); + } else { + from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); + sprintf(from, "%s %s", user->firstname, user->lastname); + } } if (to != NULL) { free(to); } - to = (char *)malloc(strlen(buffer) + 1); - strcpy(to, buffer); + 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) { + to = (char *)malloc(4); + strcpy(to, "ALL"); + } else { + to = (char *)malloc(strlen(buffer) + 1); + strcpy(to, buffer); + } replybody = editor(socket, user, body, to); if (replybody != NULL) { jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); @@ -609,9 +624,12 @@ int mail_menu(int socket, struct user_record *user) { s_putstring(socket, "\r\nSorry, you are not allowed to post in this area\r\n"); break; } - s_putstring(socket, "\r\nTO: "); - s_readstring(socket, buffer, 16); - + 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_putstring(socket, "\r\nTO: "); + s_readstring(socket, buffer, 16); + } if (strlen(buffer) == 0) { strcpy(buffer, "ALL"); } @@ -655,9 +673,17 @@ int mail_menu(int socket, struct user_record *user) { jmh.DateWritten = (uint32_t)time(NULL); jmh.Attribute |= MSG_LOCAL; if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { - strcpy(buffer, user->loginname); + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_WWIV) { + sprintf(buffer, "%s #%d @%d", user->loginname, user->id, conf.mail_conferences[user->cur_mail_conf]->wwivnode); + } else { + strcpy(buffer, user->loginname); + } } else { - sprintf(buffer, "%s %s", user->firstname, user->lastname); + 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(from, "%s %s", user->firstname, user->lastname); + } } jsp = JAM_NewSubPacket();