Experimental WWIVnet support

This commit is contained in:
Andrew Pamment 2016-03-28 14:46:48 +10:00
parent 5fafb6fee4
commit a5103db5dc
4 changed files with 46 additions and 13 deletions

5
bbs.c
View File

@ -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) {

4
bbs.h
View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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();