Hey all, I started putzing around with my mail system today in order to allow my players to add subjects to their mails when sending from computer terminals, and to do this, I modified the struct header_data_type. It now looks like this: struct header_data_type { long next_block; long from; long to; time_t mail_time; char subject[MAX_SUBJECT_LENGTH]; }; In the store_mail function, I changed it so that it copies up to 64 characters(MAX_SUBJECT_LENGTH = 64) of d->mailsubj (a char[64] in descriptor_data) into the header_data and then assigns the final character of the subject to '\0' to terminate the string. strncpy(header.header_data.subject, d->mailsubj, MAX_SUBJECT_LENGTH); strncpy(header.txt, msg_txt, HEADER_BLOCK_DATASIZE); header.txt[HEADER_BLOCK_DATASIZE] = '\0'; header.header_data.subject[MAX_SUBJECT_LENGTH] = '\0'; When I began testing this, I ran into a problem. The first 15 characters of the first sentence(which is, to my understanding, stored in header_data_type) vanished into thin air. I threw in a couple of log statements to find out the size of BLOCK_SIZE, HEADER_BLOCK_DATASIZE, and DATA_BLOCK_DATASIZE, which are defined as follows: /* size of mail file allocation blocks */ #define BLOCK_SIZE 100 /* size of the data part of a header block */ #define HEADER_BLOCK_DATASIZE \ (BLOCK_SIZE - sizeof(long) - sizeof(struct header_data_type) - sizeof(char)) /* size of the data part of a data block */ #define DATA_BLOCK_DATASIZE (BLOCK_SIZE - sizeof(long) - sizeof(char)) Here's what the values came out as: Jan 29 21:41:48 :: 100 = block_size, 15 = header_block_datasize, 95 = data_block_datasize I doubt that the 2 number 15's are unrelated, but I am unable to figure out how to get the first 15 characters back -- Here's an example mail I sent: Recipient: Gowron Subject of message: Subject goes here A fee of 100 credits has been deducted from your bank account. Transceiver assembly contacted. Write message, termination signal is '@' on a new line. ] This is line 1, sentence 1. This is line 1, sentence 2. This is line 1, sentence 3. ] This is line 2, sentence 1. This is line 2, sentence 2. This is line 2, sentence 3. ] This is line 3, sentence 1. This is line 3, sentence 2. This is line 3, sentence 3. ] @ Message sent! Mail received: * * * * Midgaard Mail System * * * * Date: Sat Jan 29 21:56:16 2000 To: gowron From: gowron Subj: Subject goes here sentence 1. This is line 1, sentence 2. This is line 1, sentence 3. This is line 2, sentence 1. This is line 2, sentence 2. This is line 3, sentence 3. This is line 3, sentence 1. This is line 3, sentence 2. This is line 3, sentence 3. As you can see, the first 15 characters of the message aren't there. Has anyone got any ideas as to what I can do to get around this? Thanks, -Phillip Phillip Ames | AOL IM: Grathol | ICQ: 8778335 | ------------------------------------------------------ "I will break you into pieces, hold you up for all the world to see, what makes you think you are better than me?" -Everclear, Like A California King, 1997 ________________________________________________________________ YOU'RE PAYING TOO MUCH FOR THE INTERNET! Juno now offers FREE Internet Access! Try it today - there's no risk! For your FREE software, visit: http://dl.www.juno.com/get/tagj. +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT