(*
**	JAM(mbp) - The Joaquim-Andrew-Mats Message Base Proposal
**
**	Turbo Pascal API
**
**	Written by Joaquim Homrighausen.
**
**	----------------------------------------------------------------------
**
**	jam.pas (JAMmb)
**
**	Prototypes and definitions for the JAM message base format
**
**	Copyright 1993 Joaquim Homrighausen, Andrew Milner, Mats Birch, and
**	Mats Wallin. ALL RIGHTS RESERVED.
**
**	93-06-28	JoHo
**	Initial coding
*)
UNIT JAM;

{$IFNDEF VER55}
	{$A-,B-,E-,D+,L+,F-,I-,N-,O-,R-,S-,V-,X+}
{$ELSE}
	{$A-,B-,E-,D+,L+,F-,I-,N-,O-,R-,S-,V-}
{$ENDIF}

INTERFACE

{-Some generic types}

TYPE
	JAMBUFPTR			=	^JAMBUF;
	JAMBUF				=	array[1..$fffe] of char;
	FILENAMETYPE	=	string[200];
	ASCIIZ				=	array[1..255] of char;
	ARRAY4				=	array[1..4] of char;

{-File extensions}

CONST
	EXT_HDRFILE		=	'.JHR';
	EXT_TXTFILE		=	'.JDT';
	EXT_IDXFILE		=	'.JDX';
	EXT_LRDFILE		=	'.JLR';
	HEADERSIG			: ARRAY4 = ('J','A','M',#0);

{-Current revision level}

	CurrentRevLev	=	1;

{-Header file information block, stored first in all .JHR files}

TYPE
	JAMHDRINFO		=	RECORD
		Signature		:	ARRAY4;      {<J><A><M> followed by <NUL>}
		DateCreated	:	LONGINT;     {Creation date}
		ModCounter	:	LONGINT;     {Last processed counter}
		ActiveMsgs	:	LONGINT;     {Number of active (not deleted) messages}
		PasswordCRC	:	LONGINT;     {CRC-32 of password to access, or -1 if none}
		BaseMsgNum	:	LONGINT;     {Lowest message number in index file}
		Reserved		:	ARRAY[1..1000] of CHAR;
	END;{JAMHDRINFO}

{-Message status bits}

CONST
	MSG_LOCAL				=	$00000001; {Msg created locally}
	MSG_INTRANSIT		=	$00000002; {Msg is in-transit}
	MSG_PRIVATE			=	$00000004; {Private}
	MSG_READ        =	$00000008; {Read by addressee}
	MSG_SENT        =	$00000010; {Sent to remote}
	MSG_KILLSENT    =	$00000020; {Kill when sent}
	MSG_ARCHIVESENT =	$00000040; {Archive when sent}
	MSG_HOLD        =	$00000080; {Hold for pick-up}
	MSG_CRASH       =	$00000100; {Crash}
	MSG_IMMEDIATE   =	$00000200; {Send Msg now, ignore restrictions}
	MSG_DIRECT      =	$00000400; {Send directly to destination}
	MSG_GATE        =	$00000800; {Send via gateway}
	MSG_FILEREQUEST =	$00001000; {File request}
	MSG_FILEATTACH  =	$00002000; {File(s) attached to Msg}
	MSG_TRUNCFILE   =	$00004000; {Truncate file(s) when sent}
	MSG_KILLFILE    =	$00008000; {Delete file(s) when sent}
  MSG_RECEIPTREQ  = $00010000; {Return receipt requested}
  MSG_CONFIRMREQ  = $00020000; {Confirmation receipt requested}
  MSG_ORPHAN      = $00040000; {Unknown destination}
  MSG_ENCRYPT     = $00080000; {Msg text is encrypted}
  MSG_COMPRESS    = $00100000; {Msg text is compressed}
  MSG_ESCAPED     = $00200000; {Msg text is seven bit ASCII}
  MSG_FPU         = $00400000; {Force pickup}
  MSG_TYPELOCAL   = $00800000; {Msg is for local use only (not for export)}
  MSG_TYPEECHO    = $01000000; {Msg is for conference distribution}
  MSG_TYPENET     = $02000000; {Msg is direct network mail}
	MSG_NODISP      =	$20000000; {Msg may not be displayed to user}
	MSG_LOCKED      =	$40000000; {Msg is locked, no editing possible}
	MSG_DELETED     =	$80000000; {Msg is deleted}

{-Message header}

TYPE
	JAMHDR					=	RECORD
		Signature			:	ARRAY4;    {<J><A><M> followed by <NUL>}
		Revision			:	WORD;      {CurrentRevLev}
		ReservedWord	:	WORD;      {Reserved for future use}
		SubfieldLen		:	LONGINT;   {Length of subfields}
		TimesRead			:	LONGINT;   {Number of times message read}
		MsgIdCRC			:	LONGINT;   {CRC-32 of MSGID line}
		ReplyCRC			:	LONGINT;   {CRC-32 of REPLY line}
		ReplyTo				:	LONGINT;   {This msg is a reply to..}
		Reply1st			:	LONGINT;   {First reply to this msg}
		ReplyNext			:	LONGINT;   {Next msg in reply chain}
		DateWritten		:	LONGINT;   {When msg was written}
		DateReceived	:	LONGINT;   {When msg was received/read}
		DateProcessed	:	LONGINT;   {When msg was processed by packer}
		MsgNum				:	LONGINT;   {Message number (1-based)}
		Attribute			:	LONGINT;   {Msg attribute, see "Status bits"}
		Attribute2		:	LONGINT;   {Reserved for future use}
		TxtOffset			:	LONGINT;   {Offset of text in text file}
		TxtLen				:	LONGINT;   {Length of message text}
		PasswordCRC		:	LONGINT;   {CRC-32 of password to access msg}
		Cost					:	LONGINT;   {Cost of message}
	END;{JAMHDR}

{-Message header subfield types}

CONST
	JAMSFLD_OADDRESS		=	0;
	JAMSFLD_DADDRESS		=	1;
	JAMSFLD_SENDERNAME	=	2;
	JAMSFLD_RECVRNAME		=	3;
	JAMSFLD_MSGID				=	4;
	JAMSFLD_REPLYID			=	5;
	JAMSFLD_SUBJECT			=	6;
	JAMSFLD_PID					=	7;
	JAMSFLD_TRACE				=	8;
	JAMSFLD_ENCLFILE		=	9;
	JAMSFLD_ENCLFWALIAS	=	10;
	JAMSFLD_ENCLFREQ		=	11;
	JAMSFLD_ENCLFILEWC	=	12;
	JAMSFLD_ENCLINDFILE	=	13;
	JAMSFLD_EMBINDAT		=	1000;
	JAMSFLD_FTSKLUDGE		=	2000;
	JAMSFLD_SEENBY2D		=	2001;
	JAMSFLD_PATH2D			=	2002;
	JAMSFLD_FLAGS				=	2003;
	JAMSFLD_TZUTCINFO		=	2004;
	JAMSFLD_UNKNOWN			=	$ffff;

{-Message header subfield}

TYPE
	JAMSUBFIELDPTR	=	^JAMSUBFIELD;
	JAMSUBFIELD			=	RECORD
		LoID					:	WORD;      {Field ID, 0 - $ffff}
		HiID					:	WORD;      {Reserved for future use}
		DatLen				:	LONGINT;   {Length of buffer that follows}
		Buffer				:	JAMBUFPTR; {Data buffer}
	END;{JAMSUBFIELD}
	JAMBINSUBFIELDPTR	=	^JAMSUBFIELD;
	JAMBINSUBFIELD	=	RECORD
		LoID					:	WORD;      {Field ID, 0 - $ffff}
		HiID					:	WORD;      {Reserved for future use}
		DatLen				:	LONGINT;   {Length of buffer that follows}
	END;{JAMSUBFIELD}

{-Message index record}

	JAMIDXREC				=	RECORD
		UserCRC				:	LONGINT;   {CRC-32 of destination username (lowercase)}
		HdrOffset			:	LONGINT;   {Offset of header in .JHR file}
	END;{JAMIDXREC}

{-Lastread structure, one per user}

	JAMLREAD				=	RECORD
		UserCRC				:	LONGINT;   {CRC-32 of username (lowercase)}
		UserID				:	LONGINT;   {Unique UserID}
		LastReadMsg		:	LONGINT;   {Last read message number}
		HighReadMsg		:	LONGINT;   {Highest read message number}
	END;{JAMLREAD}

IMPLEMENTATION
END.

(* end of file "jam.pas" *)

