#include "config.h"
#include "control.h"
#include "user_ops.h"
+#include "room_ops.h"
#include "database.h"
#include "msgbase.h"
#include "euidindex.h"
* Before allowing a wiki page save to execute, we have to perform version control.
* This involves fetching the old version of the page if it exists.
*/
-int wiki_upload_beforesave(struct CtdlMessage *msg) {
+int wiki_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
struct CitContext *CCC = CC;
long old_msgnum = (-1L);
struct CtdlMessage *old_msg = NULL;
if (msg->cm_format_type != 4) return(0);
/* If there's no EUID we can't do this. Reject the post. */
- if (msg->cm_fields[eExclusiveID] == NULL) return(1);
+ if (CM_IsEmpty(msg, eExclusiveID)) return(1);
history_page_len = snprintf(history_page, sizeof history_page,
"%s_HISTORY_", msg->cm_fields[eExclusiveID]);
}
/* If there's no message text, obviously this is all b0rken and shouldn't happen at all */
- if (msg->cm_fields[eMesageText] == NULL) return(0);
+ if (CM_IsEmpty(msg, eMesageText)) return(0);
/* Set the message subject identical to the page name */
CM_CopyField(msg, eMsgSubject, eExclusiveID);
old_msg = NULL;
}
- if ((old_msg != NULL) && (old_msg->cm_fields[eMesageText] == NULL)) { /* old version is corrupt? */
- CtdlFreeMessage(old_msg);
+ if ((old_msg != NULL) && (CM_IsEmpty(old_msg, eMesageText))) { /* old version is corrupt? */
+ CM_Free(old_msg);
old_msg = NULL;
}
/* If no changes were made, don't bother saving it again */
if ((old_msg != NULL) && (!strcmp(msg->cm_fields[eMesageText], old_msg->cm_fields[eMesageText]))) {
- CtdlFreeMessage(old_msg);
+ CM_Free(old_msg);
return(1);
}
fp = fopen(diff_old_filename, "w");
rv = fwrite(old_msg->cm_fields[eMesageText], strlen(old_msg->cm_fields[eMesageText]), 1, fp);
fclose(fp);
- CtdlFreeMessage(old_msg);
+ CM_Free(old_msg);
}
fp = fopen(diff_new_filename, "w");
}
free(diffbuf);
- CtdlFreeMessage(history_msg);
+ CM_Free(history_msg);
return(0);
}
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
- CtdlFreeMessage(msg);
+ if ((msg != NULL) && CM_IsEmpty(msg, eMesageText)) {
+ CM_Free(msg);
msg = NULL;
}
mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_history_callback, NULL, NULL, NULL, 0);
cprintf("000\n");
- CtdlFreeMessage(msg);
+ CM_Free(msg);
return;
}
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
- CtdlFreeMessage(msg);
+ if ((msg != NULL) && CM_IsEmpty(msg, eMesageText)) {
+ CM_Free(msg);
msg = NULL;
}
else {
syslog(LOG_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
}
- CtdlFreeMessage(msg);
+ CM_Free(msg);
/* Get the revision history */
msg = NULL;
}
- if ((msg != NULL) && (msg->cm_fields[eMesageText] == NULL)) {
- CtdlFreeMessage(msg);
+ if ((msg != NULL) && CM_IsEmpty(msg, eMesageText)) {
+ CM_Free(msg);
msg = NULL;
}
striplt(hecbd.stop_when);
mime_parser(msg->cm_fields[eMesageText], NULL, *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
- CtdlFreeMessage(msg);
+ CM_Free(msg);
/* Were we successful? */
if (hecbd.done == 0) {
/* Theoretically it is impossible to get here, but throw an error anyway */
msgnum = (-1L);
}
- CtdlFreeMessage(msg);
+ CM_Free(msg);
if (msgnum >= 0L) {
cprintf("%d %ld\n", CIT_OK, msgnum); /* Give the client a msgnum */
}