NULL,
NULL,
NULL,
- NULL,
+ "cccc",
NULL
};
fclose(fp);
/* Hit the Global Address Book */
- if (CtdlDirectoryLookup(aaa, name) == 0) {
+ if (CtdlDirectoryLookup(aaa, name, sizeof aaa) == 0) {
strcpy(name, aaa);
}
}
-
+/*
+ * Back end for the MSGS command: output message number only.
+ */
void simple_listing(long msgnum, void *userdata)
{
cprintf("%ld\n", msgnum);
+/*
+ * Back end for the MSGS command: output header summary.
+ */
+void headers_listing(long msgnum, void *userdata)
+{
+ struct CtdlMessage *msg;
+
+ msg = CtdlFetchMessage(msgnum, 0);
+ if (msg < 0L) {
+ cprintf("%ld|0|||||\n", msgnum);
+ return;
+ }
+
+ cprintf("%ld|%s|%s|%s|%s|%s|\n",
+ msgnum,
+ (msg->cm_fields['T'] ? msg->cm_fields['T'] : "0"),
+ (msg->cm_fields['A'] ? msg->cm_fields['A'] : ""),
+ (msg->cm_fields['N'] ? msg->cm_fields['N'] : ""),
+ (msg->cm_fields['F'] ? msg->cm_fields['F'] : ""),
+ (msg->cm_fields['U'] ? msg->cm_fields['U'] : "")
+ );
+ CtdlFreeMessage(msg);
+}
+
+
+
/* Determine if a given message matches the fields in a message template.
* Return 0 for a successful match.
*/
int i;
int with_template = 0;
struct CtdlMessage *template = NULL;
+ int with_headers = 0;
extract_token(which, cmdbuf, 0, '|', sizeof which);
cm_ref = extract_int(cmdbuf, 1);
with_template = extract_int(cmdbuf, 2);
+ with_headers = extract_int(cmdbuf, 3);
mode = MSGS_ALL;
strcat(which, " ");
buffer_output();
}
else {
- cprintf("%d Message list...\n", LISTING_FOLLOWS);
+ cprintf("%d \n", LISTING_FOLLOWS);
}
- CtdlForEachMessage(mode, cm_ref,
- NULL, template, simple_listing, NULL);
+ CtdlForEachMessage(mode,
+ cm_ref,
+ NULL,
+ template,
+ (with_headers ? headers_listing : simple_listing),
+ NULL
+ );
if (template != NULL) CtdlFreeMessage(template);
cprintf("000\n");
}
safestrncpy(luser, mptr, sizeof luser);
safestrncpy(suser, mptr, sizeof suser);
}
+ else if (i == 'Y') {
+ cprintf("CC: %s%s", mptr, nl);
+ }
else if (i == 'U') {
cprintf("Subject: %s%s", mptr, nl);
subject_found = 1;
cprintf(">%s", nl);
if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONONLY)) {
- // cprintf("From: x@x.org (----)%s", nl);
cprintf("From: \"----\" <x@x.org>%s", nl);
}
else if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONOPT)) {
- // cprintf("From: x@x.org (anonymous)%s", nl);
cprintf("From: \"anonymous\" <x@x.org>%s", nl);
}
else if (strlen(fuser) > 0) {
- // cprintf("From: %s (%s)%s", fuser, luser, nl);
cprintf("From: \"%s\" <%s>%s", luser, fuser, nl);
}
else {
- // cprintf("From: %s@%s (%s)%s", suser, snode, luser, nl);
cprintf("From: \"%s\" <%s@%s>%s", luser, suser, snode, nl);
}
-
/*
* Save a message to disk and submit it into the delivery system.
*/
char *instr;
struct ser_ret smr;
char *hold_R, *hold_D;
+ char *collected_addresses = NULL;
lprintf(CTDL_DEBUG, "CtdlSubmitMsg() called\n");
if (is_valid_message(msg) == 0) return(-1); /* self check */
break;
case 4:
strcpy(content_type, "text/plain");
- mptr = bmstrstr(msg->cm_fields['M'],
- "Content-type: ", strncasecmp);
+ mptr = bmstrcasestr(msg->cm_fields['M'], "Content-type: ");
if (mptr != NULL) {
safestrncpy(content_type, &mptr[14],
sizeof content_type);
CtdlFreeMessage(imsg);
}
+ /*
+ * Any addresses to collect? (FIXME do something with them!!)
+ */
+ collected_addresses = harvest_collected_addresses(msg);
+ if (collected_addresses != NULL) {
+ lprintf(CTDL_DEBUG, "FIXME collected addresses: %s\n", collected_addresses);
+ free(collected_addresses);
+ }
+
return(newmsgid);
}
+
+
+
+
+
/*
* Convenience function for generating small administrative messages.
*/
struct CtdlMessage *CtdlMakeMessage(
struct ctdluser *author, /* author's user structure */
char *recipient, /* NULL if it's not mail */
+ char *recp_cc, /* NULL if it's not mail */
char *room, /* room where it's going */
int type, /* see MES_ types in header file */
int format_type, /* variformat, plain text, MIME... */
strcpy(dest_node, "");
striplt(recipient);
+ striplt(recp_cc);
snprintf(buf, sizeof buf, "cit%ld", author->usernum); /* Path */
msg->cm_fields['P'] = strdup(buf);
if (recipient[0] != 0) {
msg->cm_fields['R'] = strdup(recipient);
}
+ if (recp_cc[0] != 0) {
+ msg->cm_fields['Y'] = strdup(recp_cc);
+ }
if (dest_node[0] != 0) {
msg->cm_fields['D'] = strdup(dest_node);
}
}
-
/*
* Validate recipients, count delivery types and errors, and handle aliasing
* FIXME check for dupes!!!!!
+ * Returns 0 if all addresses are ok, -1 if no addresses were specified,
+ * or the number of addresses found invalid.
*/
struct recptypes *validate_recipients(char *recipients) {
struct recptypes *ret;
if ((ret->num_local + ret->num_internet + ret->num_ignet +
ret->num_room + ret->num_error) == 0) {
- ++ret->num_error;
+ ret->num_error = (-1);
strcpy(ret->errormsg, "No recipients specified.");
}
{
int post = 0;
char recp[SIZ];
+ char cc[SIZ];
+ char bcc[SIZ];
char masquerade_as[SIZ];
int anon_flag = 0;
int format_type = 0;
char errmsg[SIZ];
int err = 0;
struct recptypes *valid = NULL;
+ struct recptypes *valid_to = NULL;
+ struct recptypes *valid_cc = NULL;
+ struct recptypes *valid_bcc = NULL;
char subject[SIZ];
int do_confirm = 0;
long msgnum;
format_type = extract_int(entargs, 3);
extract_token(subject, entargs, 4, '|', sizeof subject);
do_confirm = extract_int(entargs, 6);
+ extract_token(cc, entargs, 7, '|', sizeof cc);
+ extract_token(bcc, entargs, 8, '|', sizeof bcc);
/* first check to make sure the request is valid. */
if (CC->user.axlevel < 2) {
strcpy(recp, "sysop");
+ strcpy(cc, "");
+ strcpy(bcc, "");
+ }
+
+ valid_to = validate_recipients(recp);
+ if (valid_to->num_error > 0) {
+ cprintf("%d Invalid recipient (To)\n", ERROR + NO_SUCH_USER);
+ free(valid_to);
+ return;
}
- valid = validate_recipients(recp);
- if (valid->num_error > 0) {
- cprintf("%d %s\n",
- ERROR + NO_SUCH_USER, valid->errormsg);
- free(valid);
+ valid_cc = validate_recipients(cc);
+ if (valid_cc->num_error > 0) {
+ cprintf("%d Invalid recipient (CC)\n", ERROR + NO_SUCH_USER);
+ free(valid_to);
+ free(valid_cc);
return;
}
- if (valid->num_internet > 0) {
+
+ valid_bcc = validate_recipients(bcc);
+ if (valid_bcc->num_error > 0) {
+ cprintf("%d Invalid recipient (BCC)\n", ERROR + NO_SUCH_USER);
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
+ return;
+ }
+
+ /* Recipient required, but none were specified */
+ if ( (valid_to->num_error < 0) && (valid_cc->num_error < 0) && (valid_bcc->num_error < 0) ) {
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
+ cprintf("%d At least one recipient is required.\n", ERROR + NO_SUCH_USER);
+ return;
+ }
+
+ if (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0) {
if (CtdlCheckInternetMailPermission(&CC->user)==0) {
cprintf("%d You do not have permission "
"to send Internet mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- free(valid);
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
return;
}
}
- if ( ( (valid->num_internet + valid->num_ignet) > 0)
+ if ( ( (valid_to->num_internet + valid_to->num_ignet + valid_cc->num_internet + valid_cc->num_ignet + valid_bcc->num_internet + valid_bcc->num_ignet) > 0)
&& (CC->user.axlevel < 4) ) {
cprintf("%d Higher access required for network mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- free(valid);
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
return;
}
- if ((RESTRICT_INTERNET == 1) && (valid->num_internet > 0)
+ if ((RESTRICT_INTERNET == 1)
+ && (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0)
&& ((CC->user.flags & US_INTERNET) == 0)
&& (!CC->internal_pgm)) {
cprintf("%d You don't have access to Internet mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- free(valid);
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
return;
}
*/
if (post == 0) {
cprintf("%d %s\n", CIT_OK,
- ((valid != NULL) ? valid->display_recp : "") );
- free(valid);
+ ((valid_to != NULL) ? valid_to->display_recp : "") );
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
return;
}
+ /* We don't need these anymore because we'll do it differently below */
+ free(valid_to);
+ free(valid_cc);
+ free(valid_bcc);
+
/* Handle author masquerading */
if (CC->fake_postname[0]) {
strcpy(masquerade_as, CC->fake_postname);
} else {
cprintf("%d send message\n", SEND_LISTING);
}
- msg = CtdlMakeMessage(&CC->user, recp,
+
+ msg = CtdlMakeMessage(&CC->user, recp, cc,
CC->room.QRname, anonymous, format_type,
masquerade_as, subject, NULL);
+ /* Put together one big recipients struct containing to/cc/bcc all in
+ * one. This is for the envelope.
+ */
+ char *all_recps = malloc(SIZ * 3);
+ strcpy(all_recps, recp);
+ if (strlen(cc) > 0) {
+ if (strlen(all_recps) > 0) {
+ strcat(all_recps, ",");
+ }
+ strcat(all_recps, cc);
+ }
+ if (strlen(bcc) > 0) {
+ if (strlen(all_recps) > 0) {
+ strcat(all_recps, ",");
+ }
+ strcat(all_recps, bcc);
+ }
+ if (strlen(all_recps) > 0) {
+ valid = validate_recipients(all_recps);
+ }
+ else {
+ valid = NULL;
+ }
+ free(all_recps);
+
if (msg != NULL) {
msgnum = CtdlSubmitMsg(msg, valid, "");
CtdlFreeMessage(msg);
}
CC->fake_postname[0] = '\0';
- free(valid);
+ if (valid != NULL) {
+ free(valid);
+ }
return;
}