+ /* Begin by fetching the current version of the page. We're going to patch
+ * backwards through the diffs until we get the one we want.
+ */
+ msgnum = locate_message_by_euid(pagename, &CC->room);
+ if (msgnum > 0L) {
+ msg = CtdlFetchMessage(msgnum, 1);
+ }
+ else {
+ msg = NULL;
+ }
+
+ if ((msg != NULL) && (msg->cm_fields['M'] == NULL)) {
+ CtdlFreeMessage(msg);
+ msg = NULL;
+ }
+
+ if (msg == NULL) {
+ cprintf("%d Page '%s' was not found.\n", ERROR+MESSAGE_NOT_FOUND, pagename);
+ return;
+ }
+
+ /* Output it to a file... */
+
+ CtdlMakeTempFileName(temp, sizeof temp);
+ fp = fopen(temp, "w");
+ if (fp != NULL) {
+ r = fwrite(msg->cm_fields['M'], strlen(msg->cm_fields['M']), 1, fp);
+ fclose(fp);
+ }
+ else {
+ CtdlLogPrintf(CTDL_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
+ }
+ CtdlFreeMessage(msg);
+
+ /* Now go get the revision history and patch backwards through the diffs until
+ * we get to the revision we want.
+ */
+