Re: [MAIL] Problems w/dropped words

From: Peter Ajamian (pajamian@cheapsam.com)
Date: 01/29/00


Phillip A Ames wrote:
>
> 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

Contrary to what you indicated, the header block does store some of the
actual message data.  Because each block has to be 100 characters the
balance after the header is used to store the first part of the data so
as not to waste the space, the amount left and the size of this space is
determined by the size of the header.  In your particular case there are
15 characters of data left in the header block that are used to store
data, if my guess is correct you wrote your new display function so it
starts displaying the message from the first data block, you need to
re-write it so it displays the data portion of the header block first.

Regards, Peter


     +------------------------------------------------------------+
     | 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