* Did most of the migration from save_message() to CtdlSaveMsg(). The
authorArt Cancro <ajc@citadel.org>
Thu, 16 Sep 1999 03:23:27 +0000 (03:23 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 16 Sep 1999 03:23:27 +0000 (03:23 +0000)
  latter builds a "struct CtdlMessage" (so we can run server-side handlers
  against it later on), then serializes it and stores to disk.
* BROKEN BUILD ALERT!!  cmd_ent3() and CtdlWriteObject() are still not
  migrated.  They are stubbed out and will MALFUNCTION if used right now!!

citadel/ChangeLog
citadel/control.c
citadel/file_ops.c
citadel/msgbase.c
citadel/msgbase.h
citadel/network/mail.sysinfo
citadel/room_ops.c
citadel/serv_chat.c
citadel/server.h
citadel/user_ops.c

index e67eccb47355e56b4aaa97f447230c282da02989..e261df362e0767ac54ac6c737795261b2b2498f2 100644 (file)
@@ -1,4 +1,11 @@
 $Log$
+Revision 1.365  1999/09/16 03:23:23  ajc
+* Did most of the migration from save_message() to CtdlSaveMsg().  The
+  latter builds a "struct CtdlMessage" (so we can run server-side handlers
+  against it later on), then serializes it and stores to disk.
+* BROKEN BUILD ALERT!!  cmd_ent3() and CtdlWriteObject() are still not
+  migrated.  They are stubbed out and will MALFUNCTION if used right now!!
+
 Revision 1.364  1999/09/07 01:42:42  ajc
 * cmd_msg3() now uses serialize_message() for its output.  All message
   commands will eventually exist as a "struct CtdlMessage" at some point
@@ -1243,4 +1250,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 1dbcae80b5245e3e270efa931e6da9d96ebdbb9b..f21e3d88a7c2eccefc6a0bcd3d0dcabb9845e214 100644 (file)
@@ -236,7 +236,7 @@ void cmd_conf(char *argbuf) {
                    }
                put_config();
                snprintf(buf,sizeof buf,
-                        "Global system configuration edited by %s",
+                        "Global system configuration edited by %s\n",
                         CC->curr_user);
                aide_message(buf);
 
index 297164554d157478ef9a5272b73dd4c5be62caf7..955228e0b2e0cd05fe02adfce14728ca8c1d10d4 100644 (file)
@@ -523,7 +523,7 @@ void abort_upl(struct CitContext *who)
 void cmd_ucls(char *cmd)
 {
        FILE *fp;
-       time_t now;
+       char upload_notice[512];
        
        if (CC->upload_fp == NULL) {
                cprintf("%d You don't have an upload file open.\n",ERROR);
@@ -549,21 +549,11 @@ void cmd_ucls(char *cmd)
                        }
 
                /* put together an upload notice */
-               time(&now);
-               fp=fopen(CC->temp,"wb");
-               putc(255,fp);
-               putc(MES_NORMAL,fp);
-               putc(0,fp);
-               fprintf(fp,"Pcit%ld",CC->usersupp.usernum); putc(0,fp);
-               fprintf(fp,"T%ld",(long)now); putc(0,fp);
-               fprintf(fp,"A%s",CC->curr_user); putc(0,fp);
-               fprintf(fp,"O%s",CC->quickroom.QRname); putc(0,fp);
-               fprintf(fp,"N%s",NODENAME); putc(0,fp); putc('M',fp);
-               fprintf(fp,"NEW UPLOAD: '%s'\n %s\n",CC->upl_file,CC->upl_comment);
-               putc(0,fp);
-               fclose(fp);
-               save_message(CC->temp, "", "", MES_LOCAL, 1);
-
+               sprintf(upload_notice,
+                       "NEW UPLOAD: '%s'\n %s\n",
+                       CC->upl_file,CC->upl_comment);
+               quickie_message(CC->curr_user, CC->quickroom.QRname,
+                               upload_notice);
                }
        else {
                abort_upl(CC);
index 00bfd373e113c6f4b941629b5ca5341dc056b008..1af533f8e49b2953f50a3ca8a31e79b6a416c245 100644 (file)
@@ -35,6 +35,9 @@
 
 extern struct config config;
 
+/* FIX dumb stub function */
+void save_message(char *junk, char *more_junk, char *foo, int wahw, int ee) {
+}
 
 /*
  * This function is self explanatory.
@@ -357,7 +360,7 @@ void memfmout(int width, char *mptr, char subst)
        strcpy(buffer, "");
        c = 1;                  /* c is the current pos */
 
-      FMTA:if (subst) {
+FMTA:  if (subst) {
                while (ch = *mptr, ((ch != 0) && (strlen(buffer) < 126))) {
                        ch = *mptr++;
                        buffer[strlen(buffer) + 1] = 0;
@@ -370,8 +373,9 @@ void memfmout(int width, char *mptr, char subst)
                buffer[strlen(buffer) + 1] = 0;
                a = buffer[0];
                strcpy(buffer, &buffer[1]);
-       } else
+       } else {
                ch = *mptr++;
+       }
 
        old = real;
        real = ch;
@@ -564,6 +568,22 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum)
        return (ret);
 }
 
+
+/*
+ * Returns 1 if the supplied pointer points to a valid Citadel message.
+ * If the pointer is NULL or the magic number check fails, returns 0.
+ */
+int is_valid_message(struct CtdlMessage *msg) {
+       if (msg == NULL)
+               return 0;
+       if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
+               lprintf(3, "is_valid_message() -- self-check failed\n");
+               return 0;
+       }
+       return 1;
+}
+
+
 /*
  * 'Destructor' for struct CtdlMessage
  */
@@ -571,12 +591,8 @@ void CtdlFreeMessage(struct CtdlMessage *msg)
 {
        int i;
 
-       if (msg == NULL)
-               return;
-       if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
-               lprintf(3, "CtdlFreeMessage() -- self-check failed\n");
-               return;
-       }
+       if (is_valid_message(msg) == 0) return;
+
        for (i = 0; i < 256; ++i)
                if (msg->cm_fields[i] != NULL)
                        phree(msg->cm_fields[i]);
@@ -961,39 +977,40 @@ void cmd_opna(char *cmdbuf)
 /*
  * Message base operation to send a message to the master file
  * (returns new message number)
+ *
+ * This is the back end for CtdlSaveMsg() and should not be directly
+ * called by server-side modules.
+ *
  */
-long send_message(char *message_in_memory,
-                                                       /* pointer to buffer */
-                                                  size_t message_length,       /* length of buffer */
-                                                     int generate_id)
-{                              /* 1 to generate an I field */
-
+long send_message(struct CtdlMessage *msg,     /* pointer to buffer */
+               int generate_id,                /* generate 'I' field? */
+               FILE *save_a_copy)              /* save a copy to disk? */
+{
        long newmsgid;
-       char *actual_message;
-       size_t actual_length;
        long retval;
        char msgidbuf[32];
+        struct sermsgret smr;
 
        /* Get a new message number */
        newmsgid = get_new_message_number();
+       sprintf(msgidbuf, "%ld", newmsgid);
 
        if (generate_id) {
-               sprintf(msgidbuf, "I%ld", newmsgid);
-               actual_length = message_length + strlen(msgidbuf) + 1;
-               actual_message = mallok(actual_length);
-               memcpy(actual_message, message_in_memory, 3);
-               memcpy(&actual_message[3], msgidbuf, (strlen(msgidbuf) + 1));
-               memcpy(&actual_message[strlen(msgidbuf) + 4],
-                      &message_in_memory[3], message_length - 3);
-       } else {
-               actual_message = message_in_memory;
-               actual_length = message_length;
+               msg->cm_fields['I'] = strdoop(msgidbuf);
        }
+       
+        serialize_message(&smr, msg);
+
+        if (smr.len == 0) {
+                cprintf("%d Unable to serialize message\n",
+                        ERROR+INTERNAL_ERROR);
+                return (-1L);
+        }
 
        /* Write our little bundle of joy into the message base */
        begin_critical_section(S_MSGMAIN);
        if (cdb_store(CDB_MSGMAIN, &newmsgid, sizeof(long),
-                     actual_message, actual_length) < 0) {
+                     smr.ser, smr.len) < 0) {
                lprintf(2, "Can't store message\n");
                retval = 0L;
        } else {
@@ -1001,40 +1018,24 @@ long send_message(char *message_in_memory,
        }
        end_critical_section(S_MSGMAIN);
 
-       if (generate_id) {
-               phree(actual_message);
+       /* If the caller specified that a copy should be saved to a particular
+        * file handle, do that now too.
+        */
+       if (save_a_copy != NULL) {
+               fwrite(smr.ser, smr.len, 1, save_a_copy);
        }
-       /* Finally, return the pointers */
-       return (retval);
-}
-
 
+       /* Free the memory we used for the serialized message */
+        phree(smr.ser);
 
-/*
- * this is a simple file copy routine.
- */
-void copy_file(char *from, char *to)
-{
-       FILE *ffp, *tfp;
-       int a;
-
-       ffp = fopen(from, "r");
-       if (ffp == NULL)
-               return;
-       tfp = fopen(to, "w");
-       if (tfp == NULL) {
-               fclose(ffp);
-               return;
-       }
-       while (a = getc(ffp), a >= 0) {
-               putc(a, tfp);
-       }
-       fclose(ffp);
-       fclose(tfp);
-       return;
+       /* Return the *local* message ID to the caller
+        * (even if we're storing an incoming network message)
+        */
+       return(retval);
 }
 
 
+
 /*
  * Serialize a struct CtdlMessage into the format used on disk and network.
  * 
@@ -1051,16 +1052,17 @@ void serialize_message(struct sermsgret *ret,           /* return values */
 
        lprintf(9, "serialize_message() called\n");
 
-       if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
-               lprintf(3, "serialize_message() -- self-check failed\n");
-               return;
-       }
+       if (is_valid_message(msg) == 0) return;         /* self check */
+
+       lprintf(9, "magic number check OK.\n");
 
        ret->len = 3;
        for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL)
                ret->len = ret->len +
                        strlen(msg->cm_fields[(int)forder[i]]) + 2;
 
+       lprintf(9, "message is %d bytes\n", ret->len);
+
        lprintf(9, "calling malloc\n");
        ret->ser = mallok(ret->len);
        if (ret->ser == NULL) {
@@ -1087,41 +1089,52 @@ void serialize_message(struct sermsgret *ret,           /* return values */
 
 
 
-
-
-
-
 /*
- * message base operation to save a message and install its pointers
+ * Save a message to disk
  */
-void save_message(char *mtmp,  /* file containing proper message */
-                 char *rec,    /* Recipient (if mail) */
-                 char *force,  /* if non-zero length, force a room */
-                 int mailtype, /* local or remote type, see citadel.h */
-                 int generate_id)
-{                              /* set to 1 to generate an 'I' field */
+void CtdlSaveMsg(struct CtdlMessage *msg,      /* message to save */
+               char *rec,                      /* Recipient (mail) */
+               char *force,                    /* force a particular room? */
+               int mailtype,                   /* local or remote type */
+               int generate_id)                /* 1 = generate 'I' field */
+{
        char aaa[100];
        char hold_rm[ROOMNAMELEN];
        char actual_rm[ROOMNAMELEN];
        char force_room[ROOMNAMELEN];
        char content_type[256]; /* We have to learn this */
-       char ch, rch;
        char recipient[256];
        long newmsgid;
-       char *message_in_memory;
        char *mptr;
-       struct stat statbuf;
-       size_t templen;
-       FILE *fp;
        struct usersupp userbuf;
        int a;
-       static int seqnum = 0;
        int successful_local_recipients = 0;
        struct quickroom qtemp;
        struct SuppMsgInfo smi;
+       FILE *network_fp = NULL;
+       static int seqnum = 1;
 
-       lprintf(9, "save_message(%s,%s,%s,%d,%d)\n",
-               mtmp, rec, force, mailtype, generate_id);
+       lprintf(9, "CtdlSaveMsg() called\n");
+       if (is_valid_message(msg) == 0) return;         /* self check */
+
+       /* If this message has no timestamp, we take the liberty of
+        * giving it one, right now.
+        */
+       if (msg->cm_fields['T'] == NULL) {
+               sprintf(aaa, "%ld", time(NULL));
+               msg->cm_fields['T'] = strdoop(aaa);
+       }
+
+       /* If this message has no path, we generate one.
+        */
+       if (msg->cm_fields['P'] == NULL) {
+               msg->cm_fields['P'] = strdoop(msg->cm_fields['A']);
+               for (a=0; a<strlen(msg->cm_fields['P']); ++a) {
+                       if (isspace(msg->cm_fields['P'][a])) {
+                               msg->cm_fields['P'][a] = ' ';
+                       }
+               }
+       }
 
        strcpy(force_room, force);
 
@@ -1131,26 +1144,9 @@ void save_message(char *mtmp,    /* file containing proper message */
                if (!isprint(recipient[a]))
                        strcpy(&recipient[a], &recipient[a + 1]);
 
-       /* Measure the message */
-       stat(mtmp, &statbuf);
-       templen = statbuf.st_size;
-
-       /* Now read it into memory */
-       message_in_memory = (char *) mallok(templen);
-       if (message_in_memory == NULL) {
-               lprintf(2, "Can't allocate memory to save message!\n");
-               return;
-       }
-       fp = fopen(mtmp, "rb");
-       fread(message_in_memory, templen, 1, fp);
-       fclose(fp);
-
        /* Learn about what's inside, because it's what's inside that counts */
-       mptr = message_in_memory;
-       ++mptr;                 /* advance past 0xFF header */
-       ++mptr;                 /* advance past anon flag */
-       ch = *mptr++;
-       switch (ch) {
+
+       switch (msg->cm_format_type) {
        case 0:
                strcpy(content_type, "text/x-citadel-variformat");
                break;
@@ -1160,11 +1156,7 @@ void save_message(char *mtmp,    /* file containing proper message */
        case 4:
                strcpy(content_type, "text/plain");
                /* advance past header fields */
-               while (ch = *mptr++, (ch != 'M' && ch != 0)) {
-                       do {
-                               rch = *mptr++;
-                       } while (rch > 0);
-               }
+               mptr = msg->cm_fields['M'];
                a = strlen(mptr);
                while (--a) {
                        if (!strncasecmp(mptr, "Content-type: ", 14)) {
@@ -1183,9 +1175,22 @@ void save_message(char *mtmp,    /* file containing proper message */
                }
        }
 
+       /* Network mail - send a copy to the network program. */
+       if ((strlen(recipient) > 0) && (mailtype != MES_LOCAL)) {
+               sprintf(aaa, "./network/spoolin/netmail.%04lx.%04x.%04x",
+                       (long) getpid(), CC->cs_pid, ++seqnum);
+               lprintf(9, "Saving a copy to %s\n", aaa);
+               network_fp = fopen(aaa, "ab+");
+               if (network_fp == NULL)
+                       lprintf(2, "ERROR: %s\n", strerror(errno));
+       }
+
        /* Save it to disk */
-       newmsgid = send_message(message_in_memory, templen, generate_id);
-       phree(message_in_memory);
+       newmsgid = send_message(msg, generate_id, network_fp);
+       if (network_fp != NULL) {
+               fclose(network_fp);
+               system("exec nohup ./netproc -i >/dev/null 2>&1 &");
+       }
        if (newmsgid <= 0L)
                return;
 
@@ -1229,13 +1234,7 @@ void save_message(char *mtmp,    /* file containing proper message */
                lputroom(&CC->quickroom);
                ++successful_local_recipients;
        }
-       /* Network mail - send a copy to the network program. */
-       if ((strlen(recipient) > 0) && (mailtype != MES_LOCAL)) {
-               sprintf(aaa, "./network/spoolin/netmail.%04lx.%04x.%04x",
-                       (long) getpid(), CC->cs_pid, ++seqnum);
-               copy_file(mtmp, aaa);
-               system("exec nohup ./netproc -i >/dev/null 2>&1 &");
-       }
+
        /* Bump this user's messages posted counter. */
        lgetuser(&CC->usersupp, CC->curr_user);
        CC->usersupp.posted = CC->usersupp.posted + 1;
@@ -1261,7 +1260,6 @@ void save_message(char *mtmp,     /* file containing proper message */
        if (strlen(hold_rm) > 0) {
                usergoto(hold_rm, 0);
        }
-       unlink(mtmp);           /* delete the temporary file */
 
        /* Write a supplemental message info record.  This doesn't have to
         * be a critical section because nobody else knows about this message
@@ -1275,23 +1273,26 @@ void save_message(char *mtmp,   /* file containing proper message */
 }
 
 
+
 /*
- * Generate an administrative message and post it in the Aide> room.
+ * Convenience function for generating small administrative messages.
  */
-void aide_message(char *text)
+void quickie_message(char *from, char *room, char *text)
 {
-       FILE *fp;
+       struct CtdlMessage *msg;
 
-       fp = fopen(CC->temp, "wb");
-       fprintf(fp, "%c%c%c", 255, MES_NORMAL, 0);
-       fprintf(fp, "Psysop%c", 0);
-       fprintf(fp, "T%ld%c", (long) time(NULL), 0);
-       fprintf(fp, "ACitadel%c", 0);
-       fprintf(fp, "OAide%c", 0);
-       fprintf(fp, "N%s%c", NODENAME, 0);
-       fprintf(fp, "M%s\n%c", text, 0);
-       fclose(fp);
-       save_message(CC->temp, "", AIDEROOM, MES_LOCAL, 1);
+       msg = mallok(sizeof(struct CtdlMessage));
+       memset(msg, 0, sizeof(struct CtdlMessage));
+       msg->cm_magic = CTDLMESSAGE_MAGIC;
+       msg->cm_anon_type = MES_NORMAL;
+       msg->cm_format_type = 0;
+       msg->cm_fields['A'] = strdoop(from);
+       msg->cm_fields['O'] = strdoop(room);
+       msg->cm_fields['N'] = strdoop(NODENAME);
+       msg->cm_fields['M'] = strdoop(text);
+
+       CtdlSaveMsg(msg, "", room, MES_LOCAL, 1);
+       CtdlFreeMessage(msg);
        syslog(LOG_NOTICE, text);
 }
 
@@ -1300,8 +1301,7 @@ void aide_message(char *text)
  * Build a binary message to be saved on disk.
  */
 
-void make_message(
-       char *filename,                 /* temporary file name */
+struct CtdlMessage *make_message(
        struct usersupp *author,        /* author's usersupp structure */
        char *recipient,                /* NULL if it's not mail */
        char *room,                     /* room where it's going */
@@ -1311,12 +1311,19 @@ void make_message(
        char *fake_name)                /* who we're masquerading as */
 {
 
-       FILE *fp;
        int a;
-       time_t now;
        char dest_node[32];
        char buf[256];
-       size_t msglen = 0;
+       size_t message_len = 0;
+       size_t buffer_len = 0;
+       char *ptr;
+       struct CtdlMessage *msg;
+
+       msg = mallok(sizeof(struct CtdlMessage));
+       memset(msg, 0, sizeof(struct CtdlMessage));
+       msg->cm_magic = CTDLMESSAGE_MAGIC;
+       msg->cm_anon_type = type;
+       msg->cm_format_type = format_type;
 
        /* Don't confuse the poor folks if it's not routed mail. */
        strcpy(dest_node, "");
@@ -1332,53 +1339,74 @@ void make_message(
                }
        }
 
-       /* if net_type is MES_INTERNET, set the dest node to 'internet' */ if (net_type == MES_INTERNET) {
+       /* if net_type is MES_INTERNET, set the dest node to 'internet' */
+       if (net_type == MES_INTERNET) {
                strcpy(dest_node, "internet");
        }
 
        while (isspace(recipient[strlen(recipient) - 1]))
                recipient[strlen(recipient) - 1] = 0;
 
-       time(&now);
-       fp = fopen(filename, "w");
-       putc(255, fp);
-       putc(type, fp);         /* Normal or anonymous, see MES_ flags */
-       putc(format_type, fp);  /* Formatted or unformatted */
-       fprintf(fp, "Pcit%ld%c", author->usernum, 0);   /* path */
-       fprintf(fp, "T%ld%c", (long) now, 0);   /* date/time */
-
-       if (fake_name[0])
-               fprintf(fp, "A%s%c", fake_name, 0);
+       sprintf(buf, "cit%ld", author->usernum);                /* Path */
+       msg->cm_fields['P'] = strdoop(buf);
+
+       sprintf(buf, "%ld", time(NULL));                        /* timestamp */
+       msg->cm_fields['T'] = strdoop(buf);
+
+       if (fake_name[0])                                       /* author */
+               msg->cm_fields['A'] = strdoop(fake_name);
        else
-               fprintf(fp, "A%s%c", author->fullname, 0);      /* author */
+               msg->cm_fields['A'] = strdoop(author->fullname);
 
-       if (CC->quickroom.QRflags & QR_MAILBOX) {       /* room */
-               fprintf(fp, "O%s%c", &CC->quickroom.QRname[11], 0);
-       } else {
-               fprintf(fp, "O%s%c", CC->quickroom.QRname, 0);
-       }
+       if (CC->quickroom.QRflags & QR_MAILBOX)                 /* room */
+               msg->cm_fields['O'] = strdoop(&CC->quickroom.QRname[11]);
+       else
+               msg->cm_fields['O'] = strdoop(CC->quickroom.QRname);
 
-       fprintf(fp, "N%s%c", NODENAME, 0);      /* nodename */
-       fprintf(fp, "H%s%c", HUMANNODE, 0);     /* human nodename */
+       msg->cm_fields['N'] = strdoop(NODENAME);                /* nodename */
+       msg->cm_fields['H'] = strdoop(HUMANNODE);               /* hnodename */
 
        if (recipient[0] != 0)
-               fprintf(fp, "R%s%c", recipient, 0);
+               msg->cm_fields['R'] = strdoop(recipient);
        if (dest_node[0] != 0)
-               fprintf(fp, "D%s%c", dest_node, 0);
+               msg->cm_fields['D'] = strdoop(dest_node);
 
-       putc('M', fp);
+       msg->cm_fields['M'] = mallok(4096);
+       if (msg->cm_fields['M'] == NULL) {
+               while (client_gets(buf), strcmp(buf, "000")) ;; /* flush */
+               return(msg);
+       } else {
+               buffer_len = 4096;
+               msg->cm_fields['M'][0] = 0;
+               message_len = 0;
+       }
 
+       /* read in the lines of message text one by one */
        while (client_gets(buf), strcmp(buf, "000")) {
-               if (msglen < config.c_maxmsglen) 
-                       fprintf(fp, "%s\n", buf);
-               else
-                       lprintf(7, "Message exceeded %d byte limit\n",
-                               config.c_maxmsglen);
-               msglen = msglen + strlen(buf) + 1;
+
+               /* augment the buffer if we have to */
+               if ((message_len + strlen(buf) + 2) > buffer_len) {
+                       ptr = reallok(msg->cm_fields['M'], (buffer_len * 2) );
+                       if (ptr == NULL) {      /* flush if can't allocate */
+                               while (client_gets(buf), strcmp(buf, "000")) ;;
+                               return(msg);
+                       } else {
+                               buffer_len = (buffer_len * 2);
+                               msg->cm_fields['M'] = ptr;
+                       }
+               }
+
+               strcat(msg->cm_fields['M'], buf);
+               strcat(msg->cm_fields['M'], "\n");
+
+               /* if we've hit the max msg length, flush the rest */
+               if (message_len >= config.c_maxmsglen) {
+                       while (client_gets(buf), strcmp(buf, "000")) ;;
+                       return(msg);
+               }
        }
 
-       putc(0, fp);
-       fclose(fp);
+       return(msg);
 }
 
 
@@ -1395,7 +1423,7 @@ void cmd_ent0(char *entargs)
        int anon_flag = 0;
        int format_type = 0;
        char newusername[256];
-
+       struct CtdlMessage *msg;
        int a, b;
        int e = 0;
        int mtsflag = 0;
@@ -1482,7 +1510,7 @@ void cmd_ent0(char *entargs)
                        return;
                }
                /* Check to make sure the user exists; also get the correct
-                  * upper/lower casing of the name. 
+                * upper/lower casing of the name. 
                 */
                a = getuser(&tempUS, buf);
                if (a != 0) {
@@ -1512,19 +1540,22 @@ SKFALL: b = MES_NORMAL;
 
        cprintf("%d send message\n", SEND_LISTING);
 
+       /* Read in the message from the client. */
        if (CC->fake_postname[0])
-               make_message(CC->temp, &CC->usersupp, buf,
+               msg = make_message(&CC->usersupp, buf,
                        CC->quickroom.QRname, b, e, format_type,
                        CC->fake_postname);
        else if (CC->fake_username[0])
-               make_message(CC->temp, &CC->usersupp, buf,
+               msg = make_message(&CC->usersupp, buf,
                        CC->quickroom.QRname, b, e, format_type,
                        CC->fake_username);
        else
-               make_message(CC->temp, &CC->usersupp, buf,
+               msg = make_message(&CC->usersupp, buf,
                        CC->quickroom.QRname, b, e, format_type, "");
 
-       save_message(CC->temp, buf, (mtsflag ? AIDEROOM : ""), e, 1);
+       if (msg != NULL)
+               CtdlSaveMsg(msg, buf, (mtsflag ? AIDEROOM : ""), e, 1);
+               CtdlFreeMessage(msg);
        CC->fake_postname[0] = '\0';
        return;
 }
@@ -1550,7 +1581,9 @@ void cmd_ent3(char *entargs)
                        ERROR);
                return;
        }
-       /* See if there's a recipient, but make sure it's a real one */ extract(recp, entargs, 1);
+
+       /* See if there's a recipient, but make sure it's a real one */
+       extract(recp, entargs, 1);
        for (a = 0; a < strlen(recp); ++a)
                if (!isprint(recp[a]))
                        strcpy(&recp[a], &recp[a + 1]);
index c54b4a41920539602607d7224aeeb5bddd91f2f2..44062be5f913a2ac781ed5cec1293ad63470ee2b 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-
+#define aide_message(text)      quickie_message("Citadel",AIDEROOM,text)
 
 struct sermsgret {
        size_t len;
@@ -14,6 +14,7 @@ struct sermsgret {
 #define MSGS_LAST       4
 #define MSGS_GT         5
 
+
 struct ma_info {
        char prefix[256];       /* Prefix for a multipart/alternative */
        int is_ma;              /* Set to 1 if we are using this stuff */
@@ -36,15 +37,12 @@ void cmd_msg2 (char *cmdbuf);
 void cmd_msg3 (char *cmdbuf);
 void cmd_msg4 (char *cmdbuf);
 void cmd_opna (char *cmdbuf);
-long int send_message (char *message_in_memory, size_t message_length,
-                      int generate_id);
+long send_message (struct CtdlMessage *, int, FILE *);
 void loadtroom (void);
-void copy_file (char *from, char *to);
-void save_message (char *, char *, char *, int, int);
-void aide_message (char *text);
-void make_message (char *filename, struct usersupp *author, char *recipient,
-                  char *room, int type, int net_type, int format_type,
-                  char *fake_name);
+void CtdlSaveMsg(struct CtdlMessage *, char *, char *, int, int);
+void quickie_message (char *, char *, char *);
+struct CtdlMessage *make_message (struct usersupp *, char *,
+                  char *, int, int, int, char *);
 void cmd_ent0 (char *entargs);
 void cmd_ent3 (char *entargs);
 void cmd_dele (char *delstr);
@@ -61,4 +59,4 @@ void CtdlWriteObject(char *, char *, char *, int, int, int);
 struct CtdlMessage *CtdlFetchMessage(long msgnum);
 void CtdlFreeMessage(struct CtdlMessage *msg);
 void serialize_message(struct sermsgret *, struct CtdlMessage *);
-
+int is_valid_message(struct CtdlMessage *);
index 14bbc2bacbbd7f160a3fc3814bb6b090a91e458f..32f41df907dad32593bc4d623218eb5be4719ea9 100644 (file)
@@ -9,3 +9,5 @@ phonenum US 800 555 1212
 humannode My System
 lastcontact 935635337 Wed Aug 25 22:42:17 1999
 
+test
+bin Mail
index 06ddfc7f4b7eb4eaed720a22cfb1b90e253813e4..a39adfa404503116209ba0b6a110391da5319c9d 100644 (file)
@@ -1044,7 +1044,7 @@ void cmd_setr(char *args)
                        CC->quickroom.QRdirname);
                system(buf);
        }
-       sprintf(buf, "%s> edited by %s", CC->quickroom.QRname, CC->curr_user);
+       sprintf(buf, "%s> edited by %s\n", CC->quickroom.QRname, CC->curr_user);
        aide_message(buf);
        cprintf("%d Ok\n", OK);
 }
@@ -1112,7 +1112,7 @@ void cmd_seta(char *new_ra)
         * the room table, otherwise it would deadlock!
         */
        if (post_notice == 1) {
-               sprintf(buf, "%s is now room aide for %s>",
+               sprintf(buf, "%s is now room aide for %s>\n",
                        usbuf.fullname, CC->quickroom.QRname);
                aide_message(buf);
        }
@@ -1221,7 +1221,7 @@ void cmd_kill(char *argbuf)
                usergoto(BASEROOM, 0);  /* Return to the Lobby */
 
                /* tell the world what we did */
-               sprintf(aaa, "%s> killed by %s",
+               sprintf(aaa, "%s> killed by %s\n",
                        deleted_room_name, CC->curr_user);
                aide_message(aaa);
                cprintf("%d '%s' deleted.\n", OK, deleted_room_name);
@@ -1402,6 +1402,7 @@ void cmd_cre8(char *args)
                strcat(aaa, "\n Password: ");
                strcat(aaa, new_room_pass);
        }
+       strcat(aaa, "\n");
        aide_message(aaa);
 
        cprintf("%d '%s' has been created.\n", OK, qrbuf.QRname);
index b6f1e59e22f70231e01c257e81931459098aea97..197ace6dd1e19c32be44b4e9401ce581b3b5e0d4 100644 (file)
@@ -496,7 +496,11 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
        }
        end_critical_section(S_SESSION_TABLE);
 
-       /* Log the page to disk if configured to do so */
+       /* Log the page to disk if configured to do so 
+
+
+       ****** FIX FIX FIX   add this back in *************
+
        if ((strlen(config.c_logpages) > 0) && (do_send) ) {
                fp = fopen(CC->temp, "wb");
                fprintf(fp, "%c%c%c", 255, MES_NORMAL, 0);
@@ -511,6 +515,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
                save_message(CC->temp, "", config.c_logpages, MES_LOCAL, 1);
                unlink(CC->temp);
        }
+       *************************************/
        return (message_sent);
 }
 
index 07cf699a848c2b2cd4eaac8c9f3982f23214369b..02d650786882b7255ff253d4b6c5ed8107b62ffa 100644 (file)
@@ -353,5 +353,5 @@ struct CtdlMessage {
 /* Preferred field order */
 /*               *********                     Important fields */
 /*                        ****************     Semi-important fields */
-/*                                        *    Message text (must be last) */
+/*                                        *    Message text (MUST be last) */
 #define FORDER "IPTAONHRDBCEFGJKLQSUVWXYZM"
index 60dfcc6b346e6fd4619bdc217ff239056505e3f5..5815f1a2aafea9a454a6a2065e4f40464df12870 100644 (file)
@@ -790,7 +790,7 @@ void cmd_invt_kick(char *iuser, int op)
        lputuser(&USscratch);
 
        /* post a message in Aide> saying what we just did */
-       sprintf(bbb,"%s %s %s> by %s",
+       sprintf(bbb,"%s %s %s> by %s\n",
                iuser,
                ((op == 1) ? "invited to" : "kicked out of"),
                CC->quickroom.QRname,