123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- #ifndef __JAM_H__
- #define __JAM_H__
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <stdint.h>
- #define JAM_BAD_PARAM 1
- #define JAM_IO_ERROR 2
- #define JAM_LOCK_FAILED 3
- #define JAM_NOT_LOCKED 4
- #define JAM_NO_MEMORY 5
- #define JAM_NO_USER 6
- #define JAM_NO_MESSAGE 7
- #define JAM_CORRUPT_MSG 8
- #define JAM_NO_CRC 0xffffffff
- #define EXT_HDRFILE ".jhr"
- #define EXT_TXTFILE ".jdt"
- #define EXT_IDXFILE ".jdx"
- #define EXT_LRDFILE ".jlr"
- #define CURRENTREVLEV 1
- #define HEADERSIGNATURE "JAM\0"
- typedef struct {
- char Signature[4];
- uint32_t DateCreated;
- uint32_t ModCounter;
- uint32_t ActiveMsgs;
- uint32_t PasswordCRC;
- uint32_t BaseMsgNum;
- char RSRVD[1000];
- } s_JamBaseHeader;
- #define MSG_LOCAL 0x00000001L
- #define MSG_INTRANSIT 0x00000002L
- #define MSG_PRIVATE 0x00000004L
- #define MSG_READ 0x00000008L
- #define MSG_SENT 0x00000010L
- #define MSG_KILLSENT 0x00000020L
- #define MSG_ARCHIVESENT 0x00000040L
- #define MSG_HOLD 0x00000080L
- #define MSG_CRASH 0x00000100L
- #define MSG_IMMEDIATE 0x00000200L
- #define MSG_DIRECT 0x00000400L
- #define MSG_GATE 0x00000800L
- #define MSG_FILEREQUEST 0x00001000L
- #define MSG_FILEATTACH 0x00002000L
- #define MSG_TRUNCFILE 0x00004000L
- #define MSG_KILLFILE 0x00008000L
- #define MSG_RECEIPTREQ 0x00010000L
- #define MSG_CONFIRMREQ 0x00020000L
- #define MSG_ORPHAN 0x00040000L
- #define MSG_ENCRYPT 0x00080000L
- #define MSG_COMPRESS 0x00100000L
- #define MSG_ESCAPED 0x00200000L
- #define MSG_FPU 0x00400000L
- #define MSG_TYPELOCAL 0x00800000L
- #define MSG_TYPEECHO 0x01000000L
- #define MSG_TYPENET 0x02000000L
- #define MSG_NODISP 0x20000000L
- #define MSG_LOCKED 0x40000000L
- #define MSG_DELETED 0x80000000L
- typedef struct {
- char Signature[4];
- uint16_t Revision;
- uint16_t ReservedWord;
- uint32_t SubfieldLen;
- uint32_t TimesRead;
- uint32_t MsgIdCRC;
- uint32_t ReplyCRC;
- uint32_t ReplyTo;
- uint32_t Reply1st;
- uint32_t ReplyNext;
- uint32_t DateWritten;
- uint32_t DateReceived;
- uint32_t DateProcessed;
- uint32_t MsgNum;
- uint32_t Attribute;
- uint32_t Attribute2;
- uint32_t TxtOffset;
- uint32_t TxtLen;
- uint32_t PasswordCRC;
- uint32_t Cost;
- } s_JamMsgHeader;
- #define JAMSFLD_OADDRESS 0
- #define JAMSFLD_DADDRESS 1
- #define JAMSFLD_SENDERNAME 2
- #define JAMSFLD_RECVRNAME 3
- #define JAMSFLD_MSGID 4
- #define JAMSFLD_REPLYID 5
- #define JAMSFLD_SUBJECT 6
- #define JAMSFLD_PID 7
- #define JAMSFLD_TRACE 8
- #define JAMSFLD_ENCLFILE 9
- #define JAMSFLD_ENCLFWALIAS 10
- #define JAMSFLD_ENCLFREQ 11
- #define JAMSFLD_ENCLFILEWC 12
- #define JAMSFLD_ENCLINDFILE 13
- #define JAMSFLD_EMBINDAT 1000
- #define JAMSFLD_FTSKLUDGE 2000
- #define JAMSFLD_SEENBY2D 2001
- #define JAMSFLD_PATH2D 2002
- #define JAMSFLD_FLAGS 2003
- #define JAMSFLD_TZUTCINFO 2004
- #define JAMSFLD_UNKNOWN 0xffff
- typedef struct {
- uint16_t LoID;
- uint16_t HiID;
- uint32_t DatLen;
- char* Buffer;
- } s_JamSubfield;
- typedef struct {
- uint16_t LoID;
- uint16_t HiID;
- uint32_t DatLen;
- } s_JamSaveSubfield;
- typedef struct {
- uint32_t UserCRC;
- uint32_t HdrOffset;
- } s_JamIndex;
- typedef struct {
- uint32_t UserCRC;
- uint32_t UserID;
- uint32_t LastReadMsg;
- uint32_t HighReadMsg;
- } s_JamLastRead;
- typedef struct {
- FILE* HdrFile_PS;
- FILE* TxtFile_PS;
- FILE* IdxFile_PS;
- FILE* LrdFile_PS;
- int Errno_I;
- int Locked_I;
- uint32_t LastUserPos_I;
- uint32_t LastUserId_I;
- } s_JamBase;
- typedef struct {
- s_JamSubfield** Fields;
- uint32_t NumFields;
- uint32_t NumAlloc;
- } s_JamSubPacket;
- int JAM_OpenMB ( char* Basename_PC,
- s_JamBase** NewArea_PPS );
-
- int JAM_CloseMB ( s_JamBase* Area_PS );
- int JAM_CreateMB ( char* Basename_PC,
- uint32_t BaseMsg_I,
- s_JamBase** NewArea_PPS );
- int JAM_RemoveMB ( s_JamBase* Area_PS,
- char* Basename_PC );
- int JAM_LockMB ( s_JamBase* Area_PS,
- int Timeout_I );
- int JAM_UnlockMB ( s_JamBase* Area_PS );
- int JAM_ReadMBHeader ( s_JamBase* Area_PS,
- s_JamBaseHeader* Header_PS );
-
- int JAM_WriteMBHeader ( s_JamBase* Area_PS,
- s_JamBaseHeader* Header_PS );
-
- int JAM_FindUser ( s_JamBase* Area_PS,
- uint32_t UserCrc_I,
- uint32_t StartMsg_I,
- uint32_t* MsgNo_PI );
- int JAM_GetMBSize ( s_JamBase* Area_PS,
- uint32_t* Messages_PI );
- int JAM_ReadMsgHeader ( s_JamBase* Area_PS,
- uint32_t MsgNo_I,
- s_JamMsgHeader* Header_PS,
- s_JamSubPacket** SubfieldPack_PPS );
-
- int JAM_ReadMsgText ( s_JamBase* Area_PS,
- uint32_t Offset_I,
- uint32_t Length_I,
- char* Buffer_PC );
-
- int JAM_AddMessage ( s_JamBase* Area_PS,
- s_JamMsgHeader* Header_PS,
- s_JamSubPacket* SubPack_PS,
- char* Text_PC,
- uint32_t TextLen_I );
-
- int JAM_AddEmptyMessage ( s_JamBase* Area_PS );
- int JAM_DeleteMessage ( s_JamBase* Base_PS,
- uint32_t MsgNo_I );
- int JAM_ChangeMsgHeader ( s_JamBase* Area_PS,
- uint32_t MsgNo_I,
- s_JamMsgHeader* Header_PS );
- int JAM_ClearMsgHeader ( s_JamMsgHeader* Header_PS );
- int JAM_Errno ( s_JamBase* Area_PS );
- int JAM_ReadLastRead ( s_JamBase* Area_PS,
- uint32_t User_I,
- s_JamLastRead* Record_PS );
- int JAM_WriteLastRead ( s_JamBase* Area_PS,
- uint32_t User_I,
- s_JamLastRead* Record_PS );
- s_JamSubPacket* JAM_NewSubPacket ( void );
- int JAM_DelSubPacket ( s_JamSubPacket* SubPack_PS );
- s_JamSubfield* JAM_GetSubfield ( s_JamSubPacket* SubPack_PS );
- s_JamSubfield* JAM_GetSubfield_R ( s_JamSubPacket* SubPack_PS ,
- uint32_t* Count_PI);
- int JAM_PutSubfield ( s_JamSubPacket* SubPack_PS,
- s_JamSubfield* Field_PS );
- uint32_t JAM_Crc32 ( char* Buffer_PC, uint32_t Length_I );
- #endif
|