diff --git a/bbs.c b/bbs.c index 2fbad09..356b6e4 100644 --- a/bbs.c +++ b/bbs.c @@ -20,6 +20,63 @@ int gSocket; int usertimeout; +struct fido_addr *parse_fido_addr(const char *str) { + struct fido_addr *ret = (struct fido_addr *)malloc(sizeof(struct fido_addr)); + int c; + int state = 0; + + ret->zone = 0; + ret->net = 0; + ret->node = 0; + ret->point = 0; + + for (c=0;czone *= 10 + (str[c] - '0'); + break; + case 1: + ret->net *= 10 + (str[c] - '0'); + break; + case 2: + ret->node *= 10 + (str[c] - '0'); + break; + case 3: + ret->point *= 10 + (str[c] - '0'); + break; + } + } + break; + default: + free(ret); + return NULL; + } + } + return ret; +} + + void timer_handler(int signum) { if (signum == SIGALRM) { if (gUser != NULL) { @@ -157,6 +214,14 @@ static int mail_area_handler(void* user, const char* section, const char* name, mc->realnames = 0; } } + } else if (strcasecmp(section, "network") == 0) { + if (strcasecmp(name, "type") == 0) { + if (strcasecmp(value, "fido") == 0) { + mc->nettype = NETWORK_FIDO; + } + } else if (strcasecmp(name, "fido node") == 0) { + mc->fidoaddr = parse_fido_addr(value); + } } else { // check if it's partially filled in for (i=0;imail_area_count;i++) { @@ -167,6 +232,14 @@ static int mail_area_handler(void* user, const char* section, const char* name, mc->mail_areas[i]->write_sec_level = atoi(value); } else if (strcasecmp(name, "path") == 0) { mc->mail_areas[i]->path = strdup(value); + } else if (strcasecmp(name, "type") == 0) { + if (strcasecmp(value, "local") == 0) { + mc->mail_areas[i]->type = TYPE_LOCAL_AREA; + } else if (strcasecmp(value, "echo") == 0) { + mc->mail_areas[i]->type = TYPE_ECHOMAIL_AREA; + } else if (strcasecmp(value, "netmail") == 0) { + mc->mail_areas[i]->type = TYPE_NETMAIL_AREA; + } } return 1; } @@ -186,6 +259,14 @@ static int mail_area_handler(void* user, const char* section, const char* name, mc->mail_areas[mc->mail_area_count]->write_sec_level = atoi(value); } else if (strcasecmp(name, "path") == 0) { mc->mail_areas[mc->mail_area_count]->path = strdup(value); + } else if (strcasecmp(name, "type") == 0) { + if (strcasecmp(value, "local") == 0) { + mc->mail_areas[mc->mail_area_count]->type = TYPE_LOCAL_AREA; + } else if (strcasecmp(value, "echo") == 0) { + mc->mail_areas[mc->mail_area_count]->type = TYPE_ECHOMAIL_AREA; + } else if (strcasecmp(value, "netmail") == 0) { + mc->mail_areas[mc->mail_area_count]->type = TYPE_NETMAIL_AREA; + } } mc->mail_area_count++; } diff --git a/bbs.h b/bbs.h index db688ff..c75c929 100644 --- a/bbs.h +++ b/bbs.h @@ -7,6 +7,19 @@ #define VERSION_MINOR 1 #define VERSION_STR "dev" +#define NETWORK_FIDO 0 + +#define TYPE_LOCAL_AREA 0 +#define TYPE_NETMAIL_AREA 1 +#define TYPE_ECHOMAIL_AREA 2 + +struct fido_addr { + unsigned short zone; + unsigned short net; + unsigned short node; + unsigned short point; +}; + struct last10_callers { char name[17]; char location[33]; @@ -25,16 +38,19 @@ struct mail_area { char *path; int read_sec_level; int write_sec_level; + int type; }; struct mail_conference { char *name; char *path; int networked; + int nettype; int realnames; int sec_level; int mail_area_count; struct mail_area **mail_areas; + struct fido_addr *fidoaddr; }; struct file_sub { @@ -95,7 +111,7 @@ struct user_record { extern void runbbs(int sock, char *config); - +extern struct fido_addr *parse_fido_addr(const char *str); extern void s_putchar(int socket, char c); extern void s_putstring(int socket, char *c); extern void s_displayansi(int socket, char *file); diff --git a/config_default/bbs.ini b/config_default/bbs.ini index 9b3a331..59b293b 100644 --- a/config_default/bbs.ini +++ b/config_default/bbs.ini @@ -11,6 +11,7 @@ Email Path = /home/andrew/MagickaBBS/msgs/email [mail conferences] Local Mail = config/localmail.ini +IllusionNet = config/illusionnet.ini [file directories] General Files = config/filesgen.ini diff --git a/config_default/illusionnet.ini b/config_default/illusionnet.ini new file mode 100644 index 0000000..040afd9 --- /dev/null +++ b/config_default/illusionnet.ini @@ -0,0 +1,15 @@ +[main] +Visible Sec Level = 10 +Networked = true +Real Names = false + +[network] +type = fido +fido node = 867:61/2 + +[General] +Read Sec Level = 10 +Write Sec Level = 10 +Path = /home/andrew/MagickaBBS/msgs/il_general +; local / echo or netmail +Type = Echo diff --git a/config_default/localmail.ini b/config_default/localmail.ini index 99f0a28..5febdec 100644 --- a/config_default/localmail.ini +++ b/config_default/localmail.ini @@ -7,8 +7,10 @@ Real Names = false Read Sec Level = 10 Write Sec Level = 10 Path = /home/andrew/MagickaBBS/msgs/general +Type = Local [Testing] Read Sec Level = 10 Write Sec Level = 10 Path = /home/andrew/MagickaBBS/msgs/testing +Type = Local diff --git a/mail_menu.c b/mail_menu.c index e7a9d55..a7c1357 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -273,7 +273,7 @@ void read_message(int socket, struct user_record *user, int mailno) { int lines = 0; char c; char *replybody; - + struct fido_addr *from_addr = NULL; jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); if (!jb) { printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); @@ -300,7 +300,12 @@ void read_message(int socket, struct user_record *user, int mailno) { to = (char *)malloc(jsp->Fields[z]->DatLen + 1); memset(to, 0, jsp->Fields[z]->DatLen + 1); memcpy(to, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen); - } + } + if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) { + memset(buffer, 0, jsp->Fields[z]->DatLen + 1); + memcpy(buffer, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen); + from_addr = parse_fido_addr(buffer); + } } @@ -378,6 +383,9 @@ void read_message(int socket, struct user_record *user, int mailno) { free(subject); free(to); free(from); + if (from_addr != NULL) { + free(from_addr); + } return; } @@ -403,7 +411,49 @@ void read_message(int socket, struct user_record *user, int mailno) { jsf.DatLen = strlen(subject); jsf.Buffer = (uchar *)subject; JAM_PutSubfield(jsp, &jsf); - + + if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) { + jmh.Attribute |= MSG_TYPEECHO; + + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { + sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); + jsf.LoID = JAMSFLD_OADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + } + } else if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { + jmh.Attribute |= MSG_TYPENET; + jmh.Attribute |= MSG_KILLSENT; + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { + sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); + jsf.LoID = JAMSFLD_OADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + + if (from_addr != NULL) { + + sprintf(buffer, "%d:%d/%d.%d", from_addr->zone, + from_addr->net, + from_addr->node, + from_addr->point); + jsf.LoID = JAMSFLD_DADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + } + } + } while (1) { z = JAM_LockMB(jb, 100); @@ -418,6 +468,9 @@ void read_message(int socket, struct user_record *user, int mailno) { free(to); free(from); printf("Failed to lock msg base!\n"); + if (from_addr != NULL) { + free(from_addr); + } return; } } @@ -447,7 +500,9 @@ void read_message(int socket, struct user_record *user, int mailno) { if (subject != NULL) { free(subject); } - + if (from_addr != NULL) { + free(from_addr); + } } int mail_menu(int socket, struct user_record *user) { @@ -480,6 +535,7 @@ int mail_menu(int socket, struct user_record *user) { ulong jam_crc; unsigned int lastmsg,currmsg; int lines; + struct fido_addr *from_addr; while (!domail) { s_displayansi(socket, "mailmenu"); @@ -510,7 +566,17 @@ int mail_menu(int socket, struct user_record *user) { break; } } - + if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { + s_putstring(socket, "\r\nADDR: "); + s_readstring(socket, buffer, 32); + from_addr = parse_fido_addr(buffer); + if (!from_addr) { + s_putstring(socket, "\r\n\r\nInvalid Address\r\n"); + break; + } else { + sprintf(buffer, "\r\nMailing to %d:%d/%d.%d\r\n", from_addr->zone, from_addr->net, from_addr->node, from_addr->point); + } + } to = strdup(buffer); s_putstring(socket, "\r\nSUBJECT: "); s_readstring(socket, buffer, 25); @@ -557,6 +623,48 @@ int mail_menu(int socket, struct user_record *user) { jsf.Buffer = (uchar *)subject; JAM_PutSubfield(jsp, &jsf); + if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) { + jmh.Attribute |= MSG_TYPEECHO; + + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { + sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); + jsf.LoID = JAMSFLD_OADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + } + } else if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { + jmh.Attribute |= MSG_TYPENET; + jmh.Attribute |= MSG_KILLSENT; + if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) { + sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, + conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); + jsf.LoID = JAMSFLD_OADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + + if (from_addr != NULL) { + + sprintf(buffer, "%d:%d/%d.%d", from_addr->zone, + from_addr->net, + from_addr->node, + from_addr->point); + jsf.LoID = JAMSFLD_DADDRESS; + jsf.HiID = 0; + jsf.DatLen = strlen(buffer); + jsf.Buffer = (uchar *)buffer; + JAM_PutSubfield(jsp, &jsf); + } + } + } while (1) { z = JAM_LockMB(jb, 100); @@ -834,6 +942,9 @@ int mail_menu(int socket, struct user_record *user) { JAM_PutSubfield(jsp, &jsf); + + + while (1) { z = JAM_LockMB(jb, 100); if (z == 0) { diff --git a/users.c b/users.c index 2b45009..2e18cf0 100644 --- a/users.c +++ b/users.c @@ -234,6 +234,22 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password) exit(-1); } + if (user->cur_mail_conf > conf.mail_conference_count) { + user->cur_mail_conf = 0; + } + if (user->cur_file_dir > conf.file_directory_count) { + user->cur_file_dir = 0; + } + + if (user->cur_mail_area > conf.mail_conferences[user->cur_mail_conf]->mail_area_count) { + user->cur_mail_area = 0; + } + + if (user->cur_file_sub > conf.file_directories[user->cur_file_sub]->file_sub_count) { + user->cur_file_sub = 0; + } + + return user; }