more places where we can use cm_lengths;
[citadel.git] / citadel / modules / wiki / serv_wiki.c
index e9db40985e506b7650d3ff87add358e6f5657963..ccfc77b7e66495e3c274d32a9a825798a6a1056f 100644 (file)
@@ -45,6 +45,7 @@
 #include "config.h"
 #include "control.h"
 #include "user_ops.h"
+#include "room_ops.h"
 #include "database.h"
 #include "msgbase.h"
 #include "euidindex.h"
@@ -69,7 +70,7 @@ char *wwm = "9999999999.WikiWaybackMachine";
  * 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;
@@ -109,8 +110,8 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
        /* Make sure we're saving a real wiki page rather than a wiki history page.
         * This is important in order to avoid recursing infinitely into this hook.
         */
-       if (    (strlen(msg->cm_fields[eExclusiveID]) >= 9)
-               && (!strcasecmp(&msg->cm_fields[eExclusiveID][strlen(msg->cm_fields[eExclusiveID])-9], "_HISTORY_"))
+       if (    (msg->cm_lengths[eExclusiveID] >= 9)
+               && (!strcasecmp(&msg->cm_fields[eExclusiveID][msg->cm_lengths[eExclusiveID]-9], "_HISTORY_"))
        ) {
                syslog(LOG_DEBUG, "History page not being historied\n");
                return(0);
@@ -151,13 +152,13 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
 
        if (old_msg != NULL) {
                fp = fopen(diff_old_filename, "w");
-               rv = fwrite(old_msg->cm_fields[eMesageText], strlen(old_msg->cm_fields[eMesageText]), 1, fp);
+               rv = fwrite(old_msg->cm_fields[eMesageText], old_msg->cm_lengths[eMesageText], 1, fp);
                fclose(fp);
                CM_Free(old_msg);
        }
 
        fp = fopen(diff_new_filename, "w");
-       rv = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
+       rv = fwrite(msg->cm_fields[eMesageText], msg->cm_lengths[eMesageText], 1, fp);
        fclose(fp);
 
        snprintf(diff_cmd, sizeof diff_cmd,
@@ -541,7 +542,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
        CtdlMakeTempFileName(temp, sizeof temp);
        fp = fopen(temp, "w");
        if (fp != NULL) {
-               r = fwrite(msg->cm_fields[eMesageText], strlen(msg->cm_fields[eMesageText]), 1, fp);
+               r = fwrite(msg->cm_fields[eMesageText], msg->cm_lengths[eMesageText], 1, fp);
                fclose(fp);
        }
        else {