diff --git a/bbs.c b/bbs.c index e0cdc0d..efc24d5 100644 --- a/bbs.c +++ b/bbs.c @@ -352,7 +352,7 @@ static int handler(void* user, const char* section, const char* name, } } else if (strcasecmp(name, "automessage write level") == 0) { conf->automsgwritelvl = atoi(value); - } + } } else if (strcasecmp(section, "paths") == 0){ if (strcasecmp(name, "ansi path") == 0) { conf->ansi_path = strdup(value); @@ -362,6 +362,10 @@ static int handler(void* user, const char* section, const char* name, conf->log_path = strdup(value); } else if (strcasecmp(name, "script path") == 0) { conf->script_path = strdup(value); + } else if (strcasecmp(name, "echomail semaphore") == 0) { + conf->echomail_sem = strdup(value); + } else if (strcasecmp(name, "netmail semaphore") == 0) { + conf->netmail_sem = strdup(value); } } else if (strcasecmp(section, "mail conferences") == 0) { if (conf->mail_conference_count == 0) { @@ -766,6 +770,8 @@ void runbbs(int socket, char *config_path, char *ip) { conf.log_path = NULL; conf.script_path = NULL; conf.automsgwritelvl = 10; + conf.echomail_sem = NULL; + conf.netmail_sem = NULL; // Load BBS data if (ini_parse(config_path, handler, &conf) <0) { diff --git a/bbs.h b/bbs.h index 072d3e2..5024608 100644 --- a/bbs.h +++ b/bbs.h @@ -87,7 +87,8 @@ struct bbs_config { char *bbs_path; char *log_path; char *script_path; - + char *echomail_sem; + char *netmail_sem; char *default_tagline; char *irc_server; diff --git a/config_default/bbs.ini b/config_default/bbs.ini index 5a3feb9..3a4c4e3 100644 --- a/config_default/bbs.ini +++ b/config_default/bbs.ini @@ -16,6 +16,8 @@ ANSI Path = /home/andrew/MagickaBBS/ansis BBS Path = /home/andrew/MagickaBBS Log Path = /home/andrew/MagickaBBS/logs Script Path = /home/andrew/MagickaBBS/scripts +Echomail Semaphore = /home/andrew/MagickaBBS/echomail.out +Netmail Semaphore = /home/andrew/MagickaBBS/netmail.out [mail conferences] Local Mail = config/localmail.ini diff --git a/mail_menu.c b/mail_menu.c index f666fcf..639d85a 100644 --- a/mail_menu.c +++ b/mail_menu.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "jamlib/jam.h" #include "bbs.h" #include "lua/lua.h" @@ -720,6 +721,7 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh int skip_line = 0; int chars = 0; int ansi; + int sem_fd; jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); if (!jb) { @@ -1134,6 +1136,18 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh } if (JAM_AddMessage(jb, &jmh, jsp, (char *)replybody, strlen(replybody))) { printf("Failed to add message\n"); + } else { + if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { + if (conf.netmail_sem != NULL) { + sem_fd = open(conf.netmail_sem, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + close(sem_fd); + } + } else if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) { + if (conf.echomail_sem != NULL) { + sem_fd = open(conf.echomail_sem, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + close(sem_fd); + } + } } JAM_UnlockMB(jb); @@ -1220,6 +1234,7 @@ int mail_menu(int socket, struct user_record *user) { char *lRet; lua_State *L; int result; + int sem_fd; if (conf.script_path != NULL) { sprintf(buffer, "%s/mailmenu.lua", conf.script_path); @@ -1499,6 +1514,18 @@ int mail_menu(int socket, struct user_record *user) { if (JAM_AddMessage(jb, &jmh, jsp, (char *)msg, strlen(msg))) { printf("Failed to add message\n"); + } else { + if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { + if (conf.netmail_sem != NULL) { + sem_fd = open(conf.netmail_sem, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + close(sem_fd); + } + } else if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) { + if (conf.echomail_sem != NULL) { + sem_fd = open(conf.echomail_sem, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + close(sem_fd); + } + } } JAM_UnlockMB(jb);