Added mail semaphores
This commit is contained in:
parent
f7ad928a57
commit
3fba296e73
6
bbs.c
6
bbs.c
@ -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) {
|
||||
|
3
bbs.h
3
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;
|
||||
|
@ -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
|
||||
|
27
mail_menu.c
27
mail_menu.c
@ -5,6 +5,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#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);
|
||||
|
Reference in New Issue
Block a user