if (Msg->cm_fields[which] != NULL) {
free (Msg->cm_fields[which]);
}
+ if (length < 0) { // You can set the length to -1 to have CM_SetField measure it for you
+ length = strlen(buf);
+ }
Msg->cm_fields[which] = malloc(length + 1);
memcpy(Msg->cm_fields[which], buf, length);
Msg->cm_fields[which][length] = '\0';
Msg->cm_fields[which] = *buf;
*buf = NULL;
- Msg->cm_lengths[which] = length;
+ if (length < 0) { // You can set the length to -1 to have CM_SetField measure it for you
+ Msg->cm_lengths[which] = strlen(buf);
+ }
+ else {
+ Msg->cm_lengths[which] = length;
+ }
}
free(msglist);
return -1;
}
- msg = CtdlFetchMessage(msglist[a], 1, 1);
+ msg = CtdlFetchMessage(msglist[a], 1);
if (msg != NULL) {
if (CtdlMsgCmp(msg, compare)) {
msglist[a] = 0L;
* NOTE: Caller is responsible for freeing the returned CtdlMessage struct
* using the CM_Free(); function.
*/
-struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body, int run_msg_hooks)
+struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
{
struct cdbdata *dmsgtext;
struct CtdlMessage *ret = NULL;
CM_SetField(ret, eMesageText, HKEY("\r\n\r\n (no text)\r\n"));
}
- /* Perform "before read" hooks (aborting if any return nonzero) */
- if (run_msg_hooks && (PerformMessageHooks(ret, NULL, EVT_BEFOREREAD) > 0)) {
- CM_Free(ret);
- return NULL;
- }
-
return (ret);
}
* request that we don't even bother loading the body into memory.
*/
if (headers_only == HEADERS_FAST) {
- TheMessage = CtdlFetchMessage(msg_num, 0, 1);
+ TheMessage = CtdlFetchMessage(msg_num, 0);
}
else {
- TheMessage = CtdlFetchMessage(msg_num, 1, 1);
+ TheMessage = CtdlFetchMessage(msg_num, 1);
}
if (TheMessage == NULL) {
msg = supplied_msg;
}
else {
- msg = CtdlFetchMessage(msgid, 0, 1);
+ msg = CtdlFetchMessage(msgid, 0);
}
if (msg != NULL) {
}
/* Submit this room for processing by hooks */
- PerformRoomHooks(&CC->room);
+ int total_roomhook_errors = PerformRoomHooks(&CC->room);
+ if (total_roomhook_errors) {
+ syslog(LOG_WARNING, "msgbase: room hooks returned %d errors", total_roomhook_errors);
+ }
/* Go back to the room we were in before we wandered here... */
CtdlGetRoom(&CC->room, hold_rm);