Clean up some of the page generation logic in www_msgs.c.
More application of stralloc. Needs to be tested. :-) Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
parent
0a91165b07
commit
37bcd31ff2
434
src/www_msgs.c
434
src/www_msgs.c
@ -91,9 +91,7 @@ char *www_msgs_arealist(struct user_record *user) {
|
||||
|
||||
char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip) {
|
||||
struct msg_headers *mhrs;
|
||||
char *page;
|
||||
int max_len;
|
||||
int len;
|
||||
stralloc page = EMPTY_STRALLOC;
|
||||
char buffer[4096];
|
||||
int i;
|
||||
struct tm msg_date;
|
||||
@ -109,51 +107,32 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
|
||||
return NULL;
|
||||
}
|
||||
page = (char *)malloz(4096);
|
||||
max_len = 4096;
|
||||
len = 0;
|
||||
|
||||
sprintf(buffer, "<div class=\"content-header\"><h2>%s - %s</h2></div>\n", conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_copys(&page, "<div class=\"content-header\"><h2>");
|
||||
stralloc_cats(&page, conf.mail_conferences[conference]->name);
|
||||
stralloc_cats(&page, " - ");
|
||||
stralloc_cats(&page, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||
stralloc_cats(&page, "</h2></div>\n");
|
||||
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
||||
sprintf(buffer, "<div class=\"button\"><a href=\"%smsgs/new/%d/%d\">New Message</a></div>\n", conf.www_url, conference, area);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<div class=\"button\"><a href=\"");
|
||||
stralloc_cats(&page, conf.www_url);
|
||||
stralloc_cats(&page, "msgs/new/");
|
||||
stralloc_cat_long(&page, conference);
|
||||
stralloc_append1(&page, '/');
|
||||
stralloc_cat_long(&page, area);
|
||||
stralloc_cats(&page, "\">New Message</a></div>\n");
|
||||
}
|
||||
mhrs = read_message_headers(conference, area, user, 0);
|
||||
|
||||
if (mhrs == NULL) {
|
||||
sprintf(buffer, "<h3>No Messages</h3>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
return page;
|
||||
stralloc_cats(&page, "<h3>No Messages</h3>\n");
|
||||
}
|
||||
|
||||
sprintf(buffer, "<div class=\"div-table\">\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<div class=\"div-table\">\n");
|
||||
|
||||
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
||||
if (!jb) {
|
||||
free(page);
|
||||
free(page.s);
|
||||
free_message_headers(mhrs);
|
||||
return NULL;
|
||||
}
|
||||
@ -177,21 +156,21 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
subject = www_sanitize(mhrs->msgs[i]->subject);
|
||||
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
||||
if (conf.date_style == 1) {
|
||||
sprintf(buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
}
|
||||
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
||||
if (conf.date_style == 1) {
|
||||
sprintf(buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
}
|
||||
} else {
|
||||
if (conf.date_style == 1) {
|
||||
sprintf(buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,46 +178,28 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
free(from);
|
||||
free(subject);
|
||||
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
stralloc_cats(&page, buffer);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
}
|
||||
sprintf(buffer, "</div>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
if (skip + 50 <= mhrs->msg_count) {
|
||||
sprintf(buffer, "<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n", conf.www_url, conference, area, skip + 50);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
snprintf(buffer, sizeof buffer,
|
||||
"<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n",
|
||||
conf.www_url, conference, area, skip + 50);
|
||||
stralloc_cats(&page, buffer);
|
||||
}
|
||||
|
||||
if (skip > 0) {
|
||||
if (skip - 50 < 0) {
|
||||
sprintf(buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
||||
}
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, buffer);
|
||||
}
|
||||
stralloc_0(&page);
|
||||
|
||||
free_message_headers(mhrs);
|
||||
return page;
|
||||
return page.s;
|
||||
}
|
||||
|
||||
char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg) {
|
||||
@ -262,9 +223,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
int z;
|
||||
struct tm msg_date;
|
||||
time_t date;
|
||||
char *page;
|
||||
int max_len;
|
||||
int len;
|
||||
stralloc page = EMPTY_STRALLOC;
|
||||
char buffer[4096];
|
||||
int chars;
|
||||
int i;
|
||||
@ -281,7 +240,9 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (conf.mail_conferences[conference]->sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->read_sec_level <= user->sec_level) {
|
||||
if (!(conf.mail_conferences[conference]->sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->read_sec_level <= user->sec_level)) {
|
||||
return NULL;
|
||||
}
|
||||
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
||||
if (!jb) {
|
||||
return NULL;
|
||||
@ -340,27 +301,13 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
!msg_is_to(user, to, daddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference) &&
|
||||
!msg_is_from(user, from, oaddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference)) {
|
||||
|
||||
if (subject != NULL) {
|
||||
free(subject);
|
||||
}
|
||||
if (from != NULL) {
|
||||
free(from);
|
||||
}
|
||||
if (to != NULL) {
|
||||
free(to);
|
||||
}
|
||||
if (oaddress != NULL) {
|
||||
free(oaddress);
|
||||
}
|
||||
if (daddress != NULL) {
|
||||
free(daddress);
|
||||
}
|
||||
if (msgid != NULL) {
|
||||
free(msgid);
|
||||
}
|
||||
if (replyid != NULL) {
|
||||
free(replyid);
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return NULL;
|
||||
@ -385,224 +332,124 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
|
||||
page = (char *)malloz(4096);
|
||||
max_len = 4096;
|
||||
len = 0;
|
||||
|
||||
sprintf(buffer, "<div class=\"content-header\"><a href=\"%smsgs/%d/%d\"><h2>%s - %s</h2></a></div>\n", conf.www_url, conference, area, conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_copys(&page, "<div class=\"content-header\"><a href=\"");
|
||||
stralloc_cats(&page, conf.www_url);
|
||||
stralloc_cats(&page, "msgs/");
|
||||
stralloc_cat_long(&page, conference);
|
||||
stralloc_append1(&page, '/');
|
||||
stralloc_cat_long(&page, area);
|
||||
stralloc_cats(&page, "\"><h2>");
|
||||
stralloc_cats(&page, conf.mail_conferences[conference]->name);
|
||||
stralloc_cats(&page, " - ");
|
||||
stralloc_cats(&page, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||
stralloc_cats(&page, "</h2></a></div>\n");
|
||||
|
||||
if (msgbase_is_flagged(user, conference, area, msg)) {
|
||||
sprintf(buffer, "<div class=\"msg-view-header-flagged\">\n");
|
||||
stralloc_cats(&page, "<div class=\"msg-view-header-flagged\">\n");
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-header\">\n");
|
||||
stralloc_cats(&page, "<div class=\"msg-view-header\">\n");
|
||||
}
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
subject_s = www_sanitize(subject);
|
||||
sprintf(buffer, "<div class=\"msg-view-subject\">%s</div>\n", subject_s);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
stralloc_cats(&page, "<div class=\"msg-view-subject\">");
|
||||
stralloc_cats(&page, subject_s);
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
free(subject_s);
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
from_s = www_sanitize(from);
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_LOCAL_AREA && oaddress != NULL) {
|
||||
|
||||
if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (@%s)</div>\n", from_s, oaddress);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (@%s)</div>\n", from_s, oaddress);
|
||||
} else if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
||||
nodeno = parse_fido_addr(oaddress);
|
||||
if (nodeno != NULL) {
|
||||
nodename = nl_get_bbsname(nodeno, conf.mail_conferences[conference]->domain);
|
||||
if (strcmp(nodename, "Unknown") == 0) {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (<span class=\"bbsname\">%s</span> - %s)</div>\n", from_s, nodename, oaddress);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (<span class=\"bbsname\">%s</span> - %s)</div>\n", from_s, nodename, oaddress);
|
||||
}
|
||||
free(nodename);
|
||||
free(nodeno);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
}
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||
}
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s</div>\n", from_s);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s</div>\n", from_s);
|
||||
}
|
||||
free(from_s);
|
||||
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, buffer);
|
||||
|
||||
to_s = www_sanitize(to);
|
||||
sprintf(buffer, "<div class=\"msg-view-to\">To: %s</div>\n", to_s);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
stralloc_cats(&page, "<div class=\"msg-view-to\">To: ");
|
||||
stralloc_cats(&page, to_s);
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
free(to_s);
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
date = (time_t)jmh.DateWritten;
|
||||
gmtime_r(&date, &msg_date);
|
||||
if (conf.date_style == 1) {
|
||||
sprintf(buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||
} else {
|
||||
sprintf(buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||
}
|
||||
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, buffer);
|
||||
|
||||
sprintf(buffer, "<div class=\"msg-view-options\"><a href=\"%smsgs/flag/%d/%d/%d\"><img src=\"%sstatic/flag.png\" /></a></div>", conf.www_url, conference, area, msg, conf.www_url);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-options\"><a href=\"%smsgs/flag/%d/%d/%d\"><img src=\"%sstatic/flag.png\" /></a></div>", conf.www_url, conference, area, msg, conf.www_url);
|
||||
stralloc_cats(&page, buffer);
|
||||
|
||||
sprintf(buffer, "</div>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
sprintf(buffer, "<div id=\"msgbody\">\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
stralloc_cats(&page, "<div id=\"msgbody\">\n");
|
||||
|
||||
aha_text = (char *)malloz(jmh.TxtLen + 1);
|
||||
|
||||
memcpy(aha_text, body, jmh.TxtLen);
|
||||
aha_text[jmh.TxtLen] = '\0';
|
||||
aha_text = strndup(body, jmh.TxtLen);
|
||||
aha_out = aha(aha_text);
|
||||
while (len + strlen(aha_out) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, aha_out);
|
||||
len += strlen(aha_out);
|
||||
stralloc_cats(&page, aha_out);
|
||||
|
||||
free(aha_out);
|
||||
free(aha_text);
|
||||
|
||||
sprintf(buffer, "</div>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
|
||||
sprintf(buffer, "<div class=\"msg-reply-form\">\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<div class=\"msg-reply-form\">\n");
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->write_sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
||||
sprintf(buffer, "<h3>Reply</h3>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
sprintf(buffer, "<form action=\"%smsgs/\" method=\"POST\" enctype=\"application/x-www-form-urlencoded;charset=UTF-8\">\n", conf.www_url);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<h3>Reply</h3>\n");
|
||||
stralloc_cats(&page, "<form action=\"");
|
||||
stralloc_cats(&page, conf.www_url);
|
||||
stralloc_cats(&page, "msgs/\" method=\"POST\" enctype=\"application/x-www-form-urlencoded;charset=UTF-8\">\n");
|
||||
|
||||
sprintf(buffer, "<input type=\"hidden\" name=\"conference\" value=\"%d\" />\n", conference);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
sprintf(buffer, "<input type=\"hidden\" name=\"area\" value=\"%d\" />\n", area);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<input type=\"hidden\" name=\"conference\" value=\"");
|
||||
stralloc_cat_long(&page, conference);
|
||||
stralloc_cats(&page, "\" />\n");
|
||||
|
||||
sprintf(buffer, "<input type=\"hidden\" name=\"replyid\" value=\"%s\" />\n", msgid);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<input type=\"hidden\" name=\"area\" value=\"");
|
||||
stralloc_cat_long(&page, area);
|
||||
stralloc_cats(&page, "\" />\n");
|
||||
|
||||
sprintf(buffer, "To : <input type=\"text\" name=\"recipient\" value=\"%s\" /><br />\n", from);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<input type=\"hidden\" name=\"replyid\" value=\"");
|
||||
stralloc_cats(&page, msgid);
|
||||
stralloc_cats(&page, "\" />\n");
|
||||
|
||||
stralloc_cats(&page, "To : <input type=\"text\" name=\"recipient\" value=\"");
|
||||
stralloc_cats(&page, from);
|
||||
stralloc_cats(&page, "\" /><br />\n");
|
||||
|
||||
stralloc_cats(&page, "Subject : <input type=\"text\" name=\"subject\" value=\"");
|
||||
if (strncasecmp(subject, "re:", 3) == 0) {
|
||||
sprintf(buffer, "Subject : <input type=\"text\" name=\"subject\" value=\"%s\" /><br />\n", subject);
|
||||
} else {
|
||||
sprintf(buffer, "Subject : <input type=\"text\" name=\"subject\" value=\"RE: %s\" /><br />\n", subject);
|
||||
stralloc_cats(&page, "RE: ");
|
||||
}
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, subject);
|
||||
stralloc_cats(&page, "\" /><br />\n");
|
||||
|
||||
sprintf(buffer, "<textarea name=\"body\" rows=\"25\" cols=\"79\" wrap=\"soft\" id=\"replybody\">");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, "<textarea name=\"body\" rows=\"25\" cols=\"79\" wrap=\"soft\" id=\"replybody\">");
|
||||
|
||||
sprintf(buffer, " %c> ", from[0]);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_append1(&page, ' ');
|
||||
stralloc_append1(&page, from[0]);
|
||||
stralloc_cats(&page, "> ");
|
||||
|
||||
replybody = (char *)malloz(strlen(body) + 1);
|
||||
|
||||
@ -629,80 +476,34 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
|
||||
for (i = 0; i < strlen(body2); i++) {
|
||||
if (body2[i] == '\r') {
|
||||
sprintf(buffer, "\n %c> ", from[0]);
|
||||
snprintf(buffer, sizeof buffer, "\n %c> ", from[0]);
|
||||
chars = 0;
|
||||
} else if (chars == 73) {
|
||||
sprintf(buffer, "\n %c> %c", from[0], body2[i]);
|
||||
snprintf(buffer, sizeof buffer, "\n %c> %c", from[0], body2[i]);
|
||||
chars = 1;
|
||||
} else {
|
||||
sprintf(buffer, "%c", body2[i]);
|
||||
snprintf(buffer, sizeof buffer, "%c", body2[i]);
|
||||
chars++;
|
||||
}
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_cats(&page, buffer);
|
||||
}
|
||||
free(body2);
|
||||
sprintf(buffer, "</textarea>\n<br />");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
stralloc_cats(&page, "</textarea>\n<br />");
|
||||
stralloc_cats(&page, "<input type=\"submit\" name=\"submit\" value=\"Reply\" />\n<br />");
|
||||
stralloc_cats(&page, "</form>\n");
|
||||
stralloc_cats(&page, "</div>\n");
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
stralloc_0(&page);
|
||||
|
||||
sprintf(buffer, "<input type=\"submit\" name=\"submit\" value=\"Reply\" />\n<br />");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
sprintf(buffer, "</form>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
sprintf(buffer, "</div>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
}
|
||||
if (subject != NULL) {
|
||||
free(subject);
|
||||
}
|
||||
if (from != NULL) {
|
||||
free(from);
|
||||
}
|
||||
if (to != NULL) {
|
||||
free(to);
|
||||
}
|
||||
if (oaddress != NULL) {
|
||||
free(oaddress);
|
||||
}
|
||||
if (daddress != NULL) {
|
||||
free(daddress);
|
||||
}
|
||||
if (msgid != NULL) {
|
||||
free(msgid);
|
||||
}
|
||||
if (replyid != NULL) {
|
||||
free(replyid);
|
||||
}
|
||||
return page;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return page.s;
|
||||
}
|
||||
|
||||
static char *www_wordwrap(char *content, int cutoff) {
|
||||
@ -899,12 +700,14 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
|
||||
if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
||||
if (conf.mail_conferences[conference]->fidoaddr->point) {
|
||||
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d",
|
||||
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
conf.mail_conferences[conference]->fidoaddr->net,
|
||||
conf.mail_conferences[conference]->fidoaddr->node,
|
||||
conf.mail_conferences[conference]->fidoaddr->point);
|
||||
} else {
|
||||
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d",
|
||||
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
conf.mail_conferences[conference]->fidoaddr->net,
|
||||
conf.mail_conferences[conference]->fidoaddr->node);
|
||||
}
|
||||
@ -914,7 +717,8 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
sprintf(buffer, "%d:%d/%d.%d %08lx", conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d %08lx",
|
||||
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||
conf.mail_conferences[conference]->fidoaddr->net,
|
||||
conf.mail_conferences[conference]->fidoaddr->node,
|
||||
conf.mail_conferences[conference]->fidoaddr->point,
|
||||
@ -936,7 +740,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(replyid));
|
||||
}
|
||||
} else if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
||||
sprintf(buffer, "%d", conf.mail_conferences[conference]->maginode);
|
||||
snprintf(buffer, sizeof buffer, "%d", conf.mail_conferences[conference]->maginode);
|
||||
jsf.LoID = JAMSFLD_OADDRESS;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
|
Reference in New Issue
Block a user