email clean up.. hope i didnt break everything
This commit is contained in:
parent
995a062f29
commit
23e30e07d7
2
bbs.h
2
bbs.h
@ -165,7 +165,7 @@ extern void main_menu(int socket, struct user_record *user);
|
|||||||
|
|
||||||
extern void mail_scan(int socket, struct user_record *user);
|
extern void mail_scan(int socket, struct user_record *user);
|
||||||
extern int mail_menu(int socket, struct user_record *user);
|
extern int mail_menu(int socket, struct user_record *user);
|
||||||
extern char *editor(int socket, struct user_record *user, char *quote, char *from);
|
extern char *editor(int socket, struct user_record *user, char *quote, char *from, int email);
|
||||||
extern char *external_editor(int socket, struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email);
|
extern char *external_editor(int socket, struct user_record *user, char *to, char *from, char *quote, char *qfrom, char *subject, int email);
|
||||||
|
|
||||||
extern int door_menu(int socket, struct user_record *user);
|
extern int door_menu(int socket, struct user_record *user);
|
||||||
|
19
email.c
19
email.c
@ -303,7 +303,7 @@ void list_emails(int socket, struct user_record *user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgid = 0;
|
msgid = 0;
|
||||||
|
s_putstring(socket, "\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m");
|
||||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||||
from = strdup((char *)sqlite3_column_text(res, 0));
|
from = strdup((char *)sqlite3_column_text(res, 0));
|
||||||
subject = strdup((char *)sqlite3_column_text(res, 1));
|
subject = strdup((char *)sqlite3_column_text(res, 1));
|
||||||
@ -311,9 +311,9 @@ void list_emails(int socket, struct user_record *user) {
|
|||||||
date = (time_t)sqlite3_column_int(res, 3);
|
date = (time_t)sqlite3_column_int(res, 3);
|
||||||
localtime_r(&date, &msg_date);
|
localtime_r(&date, &msg_date);
|
||||||
if (seen == 0) {
|
if (seen == 0) {
|
||||||
sprintf(buffer, "\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
sprintf(buffer, "\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
sprintf(buffer, "\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[0m\r\n", msgid + 1, subject, from, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
}
|
}
|
||||||
s_putstring(socket, buffer);
|
s_putstring(socket, buffer);
|
||||||
|
|
||||||
@ -321,8 +321,7 @@ void list_emails(int socket, struct user_record *user) {
|
|||||||
free(subject);
|
free(subject);
|
||||||
|
|
||||||
if (msgid % 22 == 0 && msgid != 0) {
|
if (msgid % 22 == 0 && msgid != 0) {
|
||||||
s_putstring(socket, "Enter # to read, Q to quit or Enter to continue\r\n");
|
s_putstring(socket, "\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n");
|
||||||
|
|
||||||
s_readstring(socket, buffer, 5);
|
s_readstring(socket, buffer, 5);
|
||||||
if (strlen(buffer) > 0) {
|
if (strlen(buffer) > 0) {
|
||||||
if (tolower(buffer[0]) == 'q') {
|
if (tolower(buffer[0]) == 'q') {
|
||||||
@ -330,31 +329,29 @@ void list_emails(int socket, struct user_record *user) {
|
|||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
msgtoread = atoi(buffer);
|
msgtoread = atoi(buffer) - 1;
|
||||||
sqlite3_finalize(res);
|
sqlite3_finalize(res);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
show_email(socket, user, msgtoread);
|
show_email(socket, user, msgtoread);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
s_putstring(socket, "\e[2J\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
msgid++;
|
msgid++;
|
||||||
}
|
}
|
||||||
if (msgid == 0) {
|
if (msgid == 0) {
|
||||||
s_putstring(socket, "\r\nYou have no email\r\n");
|
s_putstring(socket, "\r\nYou have no email\r\n");
|
||||||
} else {
|
} else {
|
||||||
s_putstring(socket, "Enter # to read, or Enter to quit\r\n");
|
s_putstring(socket, "\e[1;37mEnter \e[1;36m# \e[1;37mto read, or \e[1;36mEnter\e[1;37m to quit\e[0m\r\n");
|
||||||
s_readstring(socket, buffer, 5);
|
s_readstring(socket, buffer, 5);
|
||||||
if (strlen(buffer) > 0) {
|
if (strlen(buffer) > 0) {
|
||||||
msgtoread = atoi(buffer);
|
msgtoread = atoi(buffer) - 1;
|
||||||
sqlite3_finalize(res);
|
sqlite3_finalize(res);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
show_email(socket, user, msgtoread);
|
show_email(socket, user, msgtoread);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
sqlite3_finalize(res);
|
sqlite3_finalize(res);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
|
@ -376,7 +376,8 @@ char *external_editor(int socket, struct user_record *user, char *to, char *from
|
|||||||
|
|
||||||
uname(&name);
|
uname(&name);
|
||||||
|
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
|
|
||||||
|
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO && !email) {
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point == 0) {
|
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point == 0) {
|
||||||
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%d:%d/%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
|
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%d:%d/%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, 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->net,
|
||||||
@ -412,10 +413,10 @@ char *external_editor(int socket, struct user_record *user, char *to, char *from
|
|||||||
return body2;
|
return body2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return editor(socket, user, quote, qfrom);
|
return editor(socket, user, quote, qfrom, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *editor(int socket, struct user_record *user, char *quote, char *from) {
|
char *editor(int socket, struct user_record *user, char *quote, char *from, int email) {
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char linebuffer[80];
|
char linebuffer[80];
|
||||||
@ -494,7 +495,7 @@ char *editor(int socket, struct user_record *user, char *quote, char *from) {
|
|||||||
tagline = conf.default_tagline;
|
tagline = conf.default_tagline;
|
||||||
}
|
}
|
||||||
uname(&name);
|
uname(&name);
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
|
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO && !email) {
|
||||||
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point == 0) {
|
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point == 0) {
|
||||||
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%d:%d/%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
|
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%d:%d/%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, 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->net,
|
||||||
|
3
main.c
3
main.c
@ -329,6 +329,7 @@ void server(int port) {
|
|||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
|
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
|
||||||
|
remove(conf.pid_file);
|
||||||
perror("sigaction");
|
perror("sigaction");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -336,12 +337,14 @@ void server(int port) {
|
|||||||
st.sa_handler = sigterm_handler;
|
st.sa_handler = sigterm_handler;
|
||||||
sigemptyset(&st.sa_mask);
|
sigemptyset(&st.sa_mask);
|
||||||
if (sigaction(SIGTERM, &st, NULL) == -1) {
|
if (sigaction(SIGTERM, &st, NULL) == -1) {
|
||||||
|
remove(conf.pid_file);
|
||||||
perror("sigaction");
|
perror("sigaction");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_desc = socket(AF_INET, SOCK_STREAM, 0);
|
socket_desc = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (socket_desc == -1) {
|
if (socket_desc == -1) {
|
||||||
|
remove(conf.pid_file);
|
||||||
fprintf(stderr, "Couldn't create socket..\n");
|
fprintf(stderr, "Couldn't create socket..\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user