1 /* 2 ** Adapted for MSGAPI by Fedor Lizunkov 2:5020/960@FidoNet 3 */ 4 5 #ifndef __API_JAMP_H 6 #define __API_JAMP_H 7 8 #include "compiler.h" 9 10 #include "msgapi.h" 11 12 static sword _XPENTRY JamCloseArea(MSGA * jm); 13 static MSGH *_XPENTRY JamOpenMsg(MSGA * jm, word mode, dword msgnum); 14 static sword _XPENTRY JamCloseMsg(MSGH * msgh); 15 static dword _XPENTRY JamReadMsg(MSGH * msgh, XMSG * msg, dword offset, dword bytes, byte * text, dword clen, byte * ctxt); 16 static sword _XPENTRY JamWriteMsg(MSGH * msgh, word append, XMSG * msg, byte * text, dword textlen, dword totlen, dword clen, byte * ctxt); 17 static sword _XPENTRY JamKillMsg(MSGA * jm, dword msgnum); 18 static sword _XPENTRY JamLock(MSGA * jm); 19 static sword _XPENTRY JamUnlock(MSGA * jm); 20 static sword _XPENTRY JamSetCurPos(MSGH * msgh, dword pos); 21 static dword _XPENTRY JamGetCurPos(MSGH * msgh); 22 static UMSGID _XPENTRY JamMsgnToUid(MSGA * jm, dword msgnum); 23 static dword _XPENTRY JamUidToMsgn(MSGA * jm, UMSGID umsgid, word type); 24 static dword _XPENTRY JamGetHighWater(MSGA * jm); 25 static sword _XPENTRY JamSetHighWater(MSGA * jm, dword hwm); 26 static dword _XPENTRY JamGetTextLen(MSGH * msgh); 27 static dword _XPENTRY JamGetCtrlLen(MSGH * msgh); 28 static UMSGID _XPENTRY JamGetNextUid(HAREA ha); 29 static dword _XPENTRY JamGetHash(HAREA mh, dword msgnum); 30 31 #define fop_wpb (O_CREAT | O_TRUNC | O_RDWR | O_BINARY) 32 #define fop_rpb (O_RDWR | O_BINARY) 33 #define fop_cpb (O_CREAT | O_EXCL | O_RDWR | O_BINARY) 34 35 static sword MSGAPI Jam_OpenBase(MSGA *jm, word *mode, unsigned char *basename); 36 int Jam_OpenFile(JAMBASE *jambase, word *mode, mode_t permissions); 37 void Jam_CloseFile(JAMBASE *jambase); 38 static MSGH *Jam_OpenMsg(MSGA * jm, word mode, dword msgnum); 39 JAMSUBFIELD2ptr Jam_GetSubField(struct _msgh *msgh, dword *SubPos, word what); 40 dword Jam_HighMsg(JAMBASEptr jambase); 41 void Jam_ActiveMsgs(MSGA *jm); 42 static int near Jam_Lock(MSGA *jm, int force); 43 static void near Jam_Unlock(MSGA * jm); 44 dword Jam_PosHdrMsg(MSGA * jm, dword msgnum, JAMIDXREC *jamidx, JAMHDR *jamhdr); 45 static dword Jam_JamAttrToMsg(MSGH *msgh); 46 sword Jam_WriteHdrInfo(JAMBASEptr jambase); 47 void Jam_WriteHdr(MSGA *jm, JAMHDR *jamhdr, dword msgnum); 48 JAMHDR *Jam_GetHdr(MSGA *jm, dword msgnum); 49 dword Jam_Crc32(unsigned char* buff, dword len); 50 char *Jam_GetKludge(MSGA *jm, dword msgnum, word what); 51 static void MSGAPI ConvertXmsgToJamHdr(MSGH *msgh, XMSG *msg, JAMHDRptr jamhdr, JAMSUBFIELD2LISTptr *subfield); 52 static void MSGAPI ConvertCtrlToSubf(JAMHDRptr jamhdr, JAMSUBFIELD2LISTptr *subfield, dword clen, unsigned char *ctxt); 53 unsigned char *DelimText(JAMHDRptr jamhdr, JAMSUBFIELD2LISTptr *subfield, 54 unsigned char *text, size_t textlen); 55 void DecodeSubf(MSGH *msgh); 56 57 struct _msgh 58 { 59 MSGA *sq; 60 dword id; /* Must always equal MSGH_ID */ 61 62 dword bytes_written; 63 dword cur_pos; 64 65 /* For JAM only! */ 66 67 JAMIDXREC Idx; /* Message index */ 68 JAMHDR Hdr; /* Message header */ 69 JAMSUBFIELD2LISTptr SubFieldPtr; /* Pointer to Subfield structure */ 70 71 dword seek_idx; 72 dword seek_hdr; 73 74 dword clen; 75 byte *ctrl; 76 dword lclen; 77 byte *lctrl; 78 dword msgnum; 79 80 word mode; 81 }; 82 83 84 static struct _apifuncs jm_funcs = 85 { 86 JamCloseArea, 87 JamOpenMsg, 88 JamCloseMsg, 89 JamReadMsg, 90 JamWriteMsg, 91 JamKillMsg, 92 JamLock, 93 JamUnlock, 94 JamSetCurPos, 95 JamGetCurPos, 96 JamMsgnToUid, 97 JamUidToMsgn, 98 JamGetHighWater, 99 JamSetHighWater, 100 JamGetTextLen, 101 JamGetCtrlLen, 102 JamGetNextUid, 103 JamGetHash 104 }; 105 106 107 108 109 #endif 110