1 /* $Id$ */ 2 /***************************************************************************** 3 * HPT --- FTN NetMail/EchoMail Tosser 4 ***************************************************************************** 5 * Copyright (C) 1997-1999 6 * 7 * Matthias Tichy 8 * 9 * Fido: 2:2433/1245 2:2433/1247 2:2432/605.14 10 * Internet: mtt@tichy.de 11 * 12 * Grimmestr. 12 Buchholzer Weg 4 13 * 33098 Paderborn 40472 Duesseldorf 14 * Germany Germany 15 * 16 * This file is part of HPT. 17 * 18 * HPT is free software; you can redistribute it and/or modify it 19 * under the terms of the GNU General Public License as published by the 20 * Free Software Foundation; either version 2, or (at your option) any 21 * later version. 22 * 23 * HPT is distributed in the hope that it will be useful, but 24 * WITHOUT ANY WARRANTY; without even the implied warranty of 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 * General Public License for more details. 27 * 28 * You should have received a copy of the GNU General Public License 29 * along with HPT; see the file COPYING. If not, write to the Free 30 * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 31 *****************************************************************************/ 32 #ifndef _PKT_H 33 #define _PKT_H 34 35 #include <time.h> 36 #include <stdio.h> 37 38 #include <fidoconf/fidoconf.h> 39 #include <fcommon.h> 40 41 #define HPT_PRODCODE_LOWBYTE 0xff 42 #define HPT_PRODCODE_HIGHBYTE 0x10 43 44 /* note that 128K - work buffer, not the max text length */ 45 #if !defined(__FLAT__) && defined(__DOS__) 46 /* under ms-dos without extenders message will be stripped to 30K */ 47 #define TEXTBUFFERSIZE 60*1024 /* for Dose */ 48 #define BUFFERSIZE 30*1024 /* work buffer for msg text in pktread */ 49 #else 50 #define TEXTBUFFERSIZE 512*1024 /* for real os */ 51 #define BUFFERSIZE 512*1024 /* work buffer for msg text in pktread */ 52 #endif 53 54 FILE *createPkt(char *filename, s_pktHeader *header); 55 /*DOC 56 Input: filename is the name of the pkt. 57 header contains information about writing the pkt header 58 Output: createPkt returns NULL if the pkt could not be created 59 else the pointer to a open FILE is returned. 60 FZ: createPkt creates the pkt and writes the header in a way conforming to 61 FSC0039 (2+) 62 */ 63 64 int writeMsgToPkt(FILE *pkt, s_message msg); 65 /*DOC 66 Input: pkt is a pointer to a file opened by createPkt 67 msg contains the message to be written. 68 Output: writeMsgToPkt return 0 if all is ok, else 1 is returned. 69 FZ: writeMsgToPkt appends the message to the pkt file. 70 */ 71 72 int closeCreatedPkt(FILE *pkt); 73 /*DOC 74 Input: pkt is a pointer to a file opened by createPkt 75 OutPut: closeCreatedPkt returns 0 if all is ok, else 1 is returned. 76 FZ: closeCreatedPkt appends \0\0 to the pkt and closes the file. 77 */ 78 FILE *openPktForAppending(char *fileName, s_pktHeader *header); 79 /*DOC 80 Input: fileName is the name of the pkt which should be opened. 81 header: If the pkt does not exist, header is used as pktHeader. 82 Output: openPktForAppending returns a file stream opened for writing. 83 FZ: if the fileName does exist the pkt is opened using openPkt and 84 the file position indicator is set to the \0\0 to allow appending 85 to the pkt. If the file does not exist it is created using 86 createPkt and te param header. 87 */ 88 89 s_pktHeader *openPkt(FILE *pkt); 90 /*DOC 91 Input: pkt is a pointer to a FILE which is already open. 92 openPkt will read from the current position of the filepointer 93 Output: openPkt returns a pointer to a s_pktHeader struct or NULL if 94 pkt is not a PKT which conforms to FSC0039 (2+) 95 FZ: openPkt reads the pkt and transforms the binary data to the struct. 96 it reads the data as an 2+ packet. 97 */ 98 99 int readMsgFromPkt(FILE *pkt, s_pktHeader *header, s_message **message); 100 /*DOC 101 Input: pkt is a pointer to a FILE which is already open. 102 readMsgFromPkt will read from the current position of the filepointer 103 header, when in a netmail no intl kludge is found, header will be used 104 to assume intl kludge 105 message from pkt reading into *message structure, NULL if no msg 106 Output: number of msg was read (1 or 0), or 2 if error while reading 107 FZ: readMsgFromPkt reads a message out of the pkt and transforms the data 108 to the struct. 109 */ 110 111 112 int correctDateTime(char *datetime); 113 114 typedef unsigned long flag_t; /* for at least 32 bit flags */ 115 #define FTSC_FLAWY 1 /* FTSC field has correctable errors */ 116 #define FTSC_BROKEN 2 /* FTSC field can't even be parsed */ 117 #define FTSC_SEADOG 16 /* Seadog style string in the FTSC */ 118 #define FTSC_TS_BROKEN 128 /* Only timestamp broken, date is OK */ 119 120 flag_t parse_ftsc_date(struct tm * ptm, char *pdatestr); 121 void make_ftsc_date(char *pdate, const struct tm *ptm); 122 123 #define INTL_FOUND 1 124 #define FMPT_FOUND 2 125 #define TOPT_FOUND 4 126 int parseINTL(char *msgtxt, hs_addr *from, hs_addr *to); 127 /*DOC 128 Input: msgtxt is a pointer to message text in which 129 parseINTL will try to find INTL, FMPT and TOPT kludges, 130 parse them and store result in from and to structures. 131 from and to may be initialized by default values, if 132 particular kludges aren't found or can't be parsed 133 these values will stay intact. 134 Output: bitmask constructed from INTL_FOUND, FMPT_FOUND and TOPT_FOUND 135 values. If kludge was found and successfully parsed 136 then appropriate bit is set. 137 FZ: parseINTL searches for INTL, FMPT and TOPT kludges and 138 transforms the data to the structs. 139 */ 140 141 #endif 142