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(name, "type") == 0) {
if (strcasecmp(value, "fido") == 0) { if (strcasecmp(value, "fido") == 0) {
mc->nettype = NETWORK_FIDO; mc->nettype = NETWORK_FIDO;
} else if (strcasecmp(value, "wwiv") == 0) {
mc->nettype = NETWORK_WWIV;
} }
} else if (strcasecmp(name, "fido node") == 0) { } else if (strcasecmp(name, "fido node") == 0) {
mc->fidoaddr = parse_fido_addr(value); mc->fidoaddr = parse_fido_addr(value);
} else if (strcasecmp(name, "wwiv node") == 0) {
mc->wwivnode = atoi(value);
} }
} else { } else {
// check if it's partially filled in // 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]->path = strdup(value);
conf->mail_conferences[conf->mail_conference_count]->tagline = NULL; 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]->mail_area_count = 0;
conf->mail_conferences[conf->mail_conference_count]->nettype = 0;
conf->mail_conference_count++; conf->mail_conference_count++;
} else if (strcasecmp(section, "file directories") == 0) { } else if (strcasecmp(section, "file directories") == 0) {
if (conf->file_directory_count == 0) { if (conf->file_directory_count == 0) {

4
bbs.h
View File

@ -7,7 +7,8 @@
#define VERSION_MINOR 1 #define VERSION_MINOR 1
#define VERSION_STR "dev" #define VERSION_STR "dev"
#define NETWORK_FIDO 0 #define NETWORK_FIDO 1
#define NETWORK_WWIV 2
#define TYPE_LOCAL_AREA 0 #define TYPE_LOCAL_AREA 0
#define TYPE_NETMAIL_AREA 1 #define TYPE_NETMAIL_AREA 1
@ -57,6 +58,7 @@ struct mail_conference {
int mail_area_count; int mail_area_count;
struct mail_area **mail_areas; struct mail_area **mail_areas;
struct fido_addr *fidoaddr; struct fido_addr *fidoaddr;
int wwivnode;
}; };
struct file_sub { 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) { if (inet_pton(AF_INET, conf.irc_server, &servaddr.sin_addr) != 0) {
hostname_to_ip(conf.irc_server, buffer); 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; return;
} }
} }

View File

@ -396,17 +396,32 @@ void read_message(int socket, struct user_record *user, int mailno) {
free(from); free(from);
} }
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) {
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); from = (char *)malloc(strlen(user->loginname) + 1);
strcpy(from, user->loginname); strcpy(from, user->loginname);
}
} else {
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 { } else {
from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); from = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
sprintf(from, "%s %s", user->firstname, user->lastname); sprintf(from, "%s %s", user->firstname, user->lastname);
} }
}
if (to != NULL) { if (to != NULL) {
free(to); free(to);
} }
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); to = (char *)malloc(strlen(buffer) + 1);
strcpy(to, buffer); strcpy(to, buffer);
}
replybody = editor(socket, user, body, to); replybody = editor(socket, user, body, to);
if (replybody != NULL) { if (replybody != NULL) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
@ -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"); s_putstring(socket, "\r\nSorry, you are not allowed to post in this area\r\n");
break; 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_putstring(socket, "\r\nTO: "); s_putstring(socket, "\r\nTO: ");
s_readstring(socket, buffer, 16); s_readstring(socket, buffer, 16);
}
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
strcpy(buffer, "ALL"); strcpy(buffer, "ALL");
} }
@ -655,9 +673,17 @@ int mail_menu(int socket, struct user_record *user) {
jmh.DateWritten = (uint32_t)time(NULL); jmh.DateWritten = (uint32_t)time(NULL);
jmh.Attribute |= MSG_LOCAL; jmh.Attribute |= MSG_LOCAL;
if (conf.mail_conferences[user->cur_mail_conf]->realnames == 0) { 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 { } else {
sprintf(buffer, "%s %s", user->firstname, user->lastname); strcpy(buffer, user->loginname);
}
} else {
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(); jsp = JAM_NewSubPacket();