]> code.citadel.org Git - citadel.git/commitdiff
msgbase.c: generate an 'I' field when requested (i.e. on locally
authorArt Cancro <ajc@citadel.org>
Fri, 18 Dec 1998 00:58:46 +0000 (00:58 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 18 Dec 1998 00:58:46 +0000 (00:58 +0000)
          originating messages.  this was breaking parts of the network)

citadel/ChangeLog
citadel/msgbase.c

index 30297f1c0b1f4ead2e3e27c626dfb3121037e41a..72c2b3c56015717f877d2bb229595048b2931c6a 100644 (file)
@@ -1,6 +1,8 @@
 Thu Dec 17 00:17:04 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Started removing the word "beta" from the docs and code.
          Preparing for an actual release.
+       * msgbase.c: generate an 'I' field when requested (i.e. on locally
+         originating messages.  this was breaking parts of the network)
 
 1998-12-15 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * msgbase.c: remove extra call to alias() which was causing
index abda41ed4fff5ecf93147fde3fa549721749792d..02df56809290049a6c9f2db0c96fb54cb1d2ea07 100644 (file)
@@ -652,23 +652,47 @@ long send_message(char *message_in_memory,        /* pointer to buffer */
                int generate_id) {              /* 1 to generate an I field */
 
        long newmsgid;
+       char *actual_message;
+       size_t actual_length;
+       long retval;
+       char msgidbuf[32];
 
        /* Get a new message number */
        newmsgid = get_new_message_number();
 
-       /* Write our little bundle of joy into the message base */
+       if (generate_id) {
+               sprintf(msgidbuf, "I%ld", newmsgid);
+               actual_length = message_length + strlen(msgidbuf) + 1;
+               actual_message = malloc(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;
+               }
 
+       /* Write our little bundle of joy into the message base */
        begin_critical_section(S_MSGMAIN);
        if ( cdb_store(CDB_MSGMAIN, &newmsgid, sizeof(long),
-                       message_in_memory, message_length) < 0 ) {
+                       actual_message, actual_length) < 0 ) {
                lprintf(2, "Can't store message\n");
-               end_critical_section(S_MSGMAIN);
-               return 0L;
+               retval = 0L;
+               }
+       else {
+               retval = newmsgid;
                }
        end_critical_section(S_MSGMAIN);
 
+       if (generate_id) {
+               free(actual_message);
+               }
+
        /* Finally, return the pointers */
-       return(newmsgid);
+       return(retval);
        }