+/*
+ * Serialize a struct CtdlMessage into the format used on disk and network.
+ *
+ * This function loads up a "struct ser_ret" (defined in server.h) which
+ * contains the length of the serialized message and a pointer to the
+ * serialized message in memory. THE LATTER MUST BE FREED BY THE CALLER.
+ */
+void dump_message(struct CtdlMessage *msg, /* unserialized msg */
+ long Siz) /* how many chars ? */
+{
+ size_t wlen;
+ int i;
+ static char *forder = FORDER;
+ char *buf;
+
+ /*
+ * Check for valid message format
+ */
+ if (is_valid_message(msg) == 0) {
+ lprintf(CTDL_ERR, "dump_message() aborting due to invalid message\n");
+ return;
+ }
+
+ buf = (char*) malloc (Siz + 1);
+
+ wlen = 3;
+
+ for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) {
+ snprintf (buf, Siz, " msg[%c] = %s ...\n", (char) forder[i],
+ msg->cm_fields[(int)forder[i]]);
+ client_write (buf, strlen(buf));
+ }
+
+ return;
+}
+
+