home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 15
/
CD_ASCQ_15_070894.iso
/
vrac
/
wc40rec.zip
/
WCMSGDB.DOC
< prev
next >
Wrap
Text File
|
1994-06-01
|
6KB
|
112 lines
Wildcat 4 Message Database Notes
--------------------------------
The message database is no longer stored in a Filer database. There are two
files which make up a message database:
MSGn.IX - contains the message number index
MSGn.DAT - contains the message headers and text
The MSGn.IX file is divided into six byte records. There is one record at
the start of the file as follows:
type
TMsgIndexHeader = record
RecordSize : Word;
ActiveRecords : Word;
NextMsgNumber : Word;
end;
RecordSize will be set equal to 6. This is for sanity checking.
ActiveRecords is the number of active (not deleted) messages in the
conference. NextMsgNumber is the next message number that will be added
to the end of the file (this number must be updated every time you add
a message).
The rest of the records in the file are TMsgIndexEntry records:
type
TMsgIndexEntry = record
MsgNumber : Word;
HeaderOffset : Longint;
end;
These records contain, for each message, the message number and byte offset
in the .DAT file of the start of the corresponding message header.
The file is organized like this:
ofs MSGn.IX MSGn.DAT
0+----------------------+ +-------->+----------------------+
| index file header | | | first message header |
| | | +----------------------+
1+----------------------+ | |This is the text of |
| first message number | | |the first message. It |
| offset to header data--------+ |is stored the same way|
2+----------------------+ |it is in memory - with|
| second message number| |a single CR at the end|
| offset to header data--------+ |of each line (a CR is |
3+----------------------+ | |required at the end of|
| | | |the last line of the |
| | | |message too). |
. . +-------->+----------------------+
. . | second message header|
+----------------------+
|Immediately following |
|the previous message |
|text, the next message|
|header follows. |
+----------------------+
| |
. .
There is a new field at the start of the message header called MagicNumber.
This field will contain one of these two constants:
const
MagicHeaderActive = $001A1A1B;
MagicHeaderInactive = $011A1A1B;
Active messages must have MagicHeaderActive in the MagicNumber field, and
inactive messages must have MagicHeaderInactive. An 'inactive' message is
only created when a message is edited and more text is added to the message
body. When this happens the message can no longer reside in its original
location, so its old header is marked inactive and the new message header
and text is written at the end of the MSGn.DAT file. Note that in particular,
deleted messages are NOT marked as inactive.
When adding a new message to the database, the message header and text will
simply be appended to the MSGn.DAT file and the offset in the MSGn.IX file
will point to the offset at which the new text was added.
Unlike Wildcat 3, there is no longer a Ctrl-Z at the end of the message text.
The end of the message is determined from the MsgBytes field in the message
header. Each line must be terminated with a CR (including the last line).
Failure to make sure this is exactly right may cause Wildcat or other programs
to not read the messages correctly.
The unread messages are stored in a completely new way. There is a field
in the user database (see WCUSERDB.DOC) called cuFirstUnread. This is the
message NUMBER (not offset) of the first unread message in the corresponding
conference for the user. Each message has a PrevUnread and NextUnread field
that holds the message NUMBER of the previous unread message and the next
unread message, respectively, for that user. This is a doubly linked circular
list, which means that the last unread message's NextUnread points to the first
unread message, and the first unread message's PrevUnread points to the last
unread message. This is to aid in quickly adding new unread messages to the
end of the database.
When messages are read by the recipient, the forward and back links need to
be updated to be consistent with the new state of the unread messages chain.
This process may require modifying up to three message headers plus the
cuFirstUnread field of the user record.
When messages are deleted, they are not unhooked from the unread chain.
They just need to have their mfDeleted bit set in the message flags.
Message records are not removed from the file when they are deleted -
this is done by WcRepair or WcPack.
Writing and modification file access to the MSGn.IX file or MSGn.DAT file is
controlled through locking the first byte of the MSGn.IX file. This is best
done with the BTIsamLockRecord and BTIsamUnlockRecord in Filer.