1 /*
2  *	binkleyforce -- unix FTN mailer project
3  *
4  *	Copyright (c) 1998-2000 Alexander Belkin, 2:5020/1398.11
5  *
6  *	This program is free software; you can redistribute it and/or modify
7  *	it under the terms of the GNU General Public License as published by
8  *	the Free Software Foundation; either version 2 of the License, or
9  *	(at your option) any later version.
10  *
11  *	$Id: prot_emsi.h,v 1.1.1.1 2004/09/09 09:52:40 kstepanenkov Exp $
12  */
13 
14 #ifndef _S_EMSI_H_
15 #define _S_EMSI_H_
16 
17 /*
18  * EMSI limits
19  */
20 #define EMSI_MAXDAT        16384
21 #define EMSI_MAXNFLAG      20
22 #define EMSI_MAXPASSWD     30
23 #define EMSI_MAXMPID       30
24 #define EMSI_MAXMNAME      120
25 #define EMSI_MAXMVER       120
26 #define EMSI_MAXMREG       120
27 #define EMSI_MAXSYSNAME    120
28 #define EMSI_MAXLOCATION   120
29 #define EMSI_MAXSYSOP      120
30 #define EMSI_MAXPHONE      120
31 #define EMSI_MAXFLAGS      120
32 #define EMSI_MAXOHTIME     120
33 #define EMSI_MAXFRTIME     120
34 #define EMSI_MAXXDATETIME  60
35 #define EMSI_MAXADDONS     120
36 
37 /*
38  * EMSI XXn flags that affect only address number n in AKA list
39  */
40 #define EMSI_FLAG_PU       0x0001 /* Pickup FILES for this address               */
41 #define EMSI_FLAG_HA       0x0002 /* Hold all FILES for this address             */
42 #define EMSI_FLAG_PM       0x0004 /* PickUp Mail ONLY for this address           */
43 #define EMSI_FLAG_NF       0x0008 /* No TIC'S, associated files or file attaches */
44                                   /* for this address                            */
45 #define EMSI_FLAG_NX       0x0010 /* No compressed mail pickup desired,          */
46                                   /* for this address                            */
47 #define EMSI_FLAG_NR       0x0020 /* File requests not accepted by caller        */
48                                   /* for this address                            */
49 #define EMSI_FLAG_HN       0x0040 /* Hold all traffic EXCEPT Mail (ARCmail and   */
50                                   /* Packets) for this address                   */
51 #define EMSI_FLAG_HX       0x0080 /* Hold compressed mail for this address       */
52 #define EMSI_FLAG_HF       0x0100 /* Hold tic's and associated files and file    */
53                                   /* attaches other than mail for this address   */
54 #define EMSI_FLAG_HR       0x0200 /* Hold file requests (not processed at this   */
55                                   /* time)for this address                       */
56 
57 /*
58  *  Defines for state machine
59  */
60 #define	SME		-1
61 #define	SM0		0
62 #define	SM1		1
63 #define	SM2		2
64 #define	SM3		3
65 #define	SM4		4
66 #define	SM5		5
67 #define	SM6		6
68 #define	SM7		7
69 #define	SM8		8
70 #define	SM9		9
71 
72 struct states
73 {
74 const	char *st_name;
75 	int (*proc)();
76 };
77 typedef struct states s_states;
78 
79 struct linkcodes
80 {
81 	/*
82 	 * EMSI-I (FSC-0056) and EMSI-II (FSC-0088) flags
83 	 * for XXn flags see s_emsiaddr structure
84 	 */
85 
86 	UINT32 N81:1,   /* Communication parameter emulation :) (EMSI-I)     */
87 	       PUP:1,   /* Pickup FILES for primary address only             */
88 	       PUA:1,   /* Pickup FILES for all presented addresses          */
89 	       NPU:1,   /* No FILE pickup desired. (calling system)          */
90 	       HAT:1,   /* Hold all FILES          (answering system)        */
91 	       PMO:1,   /* PickUp Mail (ARCmail and Packets) ONLY            */
92 	       NFE:1,   /* No TIC'S, associated files or files attaches      */
93 	                /* desired                                           */
94 	       NXP:1,   /* No compressed mail pickup desired                 */
95 	       NRQ:1,   /* File requests not accepted by caller              */
96 	                /* This flag is presented if file request processing */
97 	                /* is disabled TEMPORARILY for any reason            */
98 	       HNM:1,   /* Hold all traffic EXCEPT Mail(ARCmail and Packets) */
99 	       HXT:1,   /* Hold compressed mail traffic.                     */
100 	       HFE:1,   /* Hold tic's and associated files                   */
101 	                /* and file attaches other than mail                 */
102 	       HRQ:1,   /* Hold file requests (not processed at this time)   */
103 	                /* this flag is presented if file request processing */
104 	                /* is disabled TEMPORARILY for any reason            */
105 	       FNC:1,   /* Convert file names to "msdos" format              */
106 	       RMA:1,   /* System is able to process multiple file requests  */
107 	       RH1:1;   /* Under Hydra batch 1 contain file requests only,   */
108 	                /* while batch 2 is reserved for all other files     */
109 };
110 typedef struct linkcodes s_linkcodes;
111 
112 struct compcodes
113 {
114 	UINT16 NCP:1,   /* No compatible protocols (failure) */
115 	       ZMO:1,   /* Zmodem w/1,024 byte data packets  */
116 	       ZAP:1,   /* ZedZap    (Zmodem variant)        */
117 	       DZA:1,   /* DirectZAP (Zmodem variant)        */
118 	       JAN:1,   /* Janus                             */
119 	       HYD:1;   /* Hydra                             */
120 
121 	UINT16 FRQ:1,   /* The system will accept and process FREQs */
122 	       NRQ:1,   /* No file requests accepted by this system */
123 	       ARC:1,   /* ARCmail 0.60-capable                     */
124 	       XMA:1,   /* Supports other forms of compressed mail  */
125 	       FNC:1,   /* Filename conversion into 8.3 format      */
126 	       EII:1,   /* EMSI-II flags are supported              */
127 	       DFB:1,   /* Can fall-back to FTS1/WAZOO negotiation  */
128 	       CHT:1,   /* Chat during transmittion available       */
129 	       BBS:1,   /* Site has public BBS available            */
130 	       HFR:1;   /* Remote will automaticaly hold requested  */
131 	                /* files for us                             */
132 };
133 typedef struct compcodes s_compcodes;
134 
135 struct emsi
136 {
137 	/*
138 	 * Keep here all unknown EMSI_DAT addons
139 	 */
140 	char        addons[EMSI_MAXADDONS+1];
141 
142 	/*
143 	 * {EMSI_DAT} (main handshake information)
144 	 */
145 	bool        have_emsi;
146 	s_sysaddr  *addrs;		 /* dynamicaly allocated array       */
147 	int         anum;		 /* number of used entries in it     */
148 	char        passwd[EMSI_MAXPASSWD+1];
149 	s_linkcodes linkcodes;		/* XXn linkcodes contained in eaddr  */
150 	s_compcodes compcodes;
151 	char        m_pid[EMSI_MAXMPID+1];
152 	char        m_name[EMSI_MAXMNAME+1];
153 	char        m_ver[EMSI_MAXMVER+1];
154 	char        m_reg[EMSI_MAXMREG+1];
155 
156 	/*
157 	 * {IDENT} (system information)
158 	 */
159 	bool        have_ident;
160 	char        sname[EMSI_MAXSYSNAME+1];
161 	char        location[EMSI_MAXLOCATION+1];
162 	char        sysop[EMSI_MAXSYSOP+1];
163 	char        phone[EMSI_MAXPHONE+1];
164 	int         speed;
165 	char        flags[EMSI_MAXFLAGS+1];
166 
167 	/*
168 	 * {TRAF} (size of netmail and arcmail files on hold)
169 	 */
170 	bool        have_traf;
171 	size_t      netmail_size;
172 	size_t      arcmail_size;
173 
174 	/*
175 	 * {MOH#} (size of files on hold? :))
176 	 */
177 	bool        have_moh;
178 	size_t      files_size;
179 
180 	/*
181 	 * {OHFR} (site's work and freq time intervals)
182 	 */
183 	bool        have_ohfr;
184 	char        oh_time[EMSI_MAXOHTIME+1];
185 	char        fr_time[EMSI_MAXFRTIME+1];
186 
187 	/*
188 	 * {TZUTC} (site's time zone)
189 	 */
190 	bool        have_tzutc;
191 	int         tzutc;
192 
193 	/*
194 	 * {XDATETIME} (site's date and time in extended format)
195 	 */
196 	bool        have_xdatetime;
197 	char        xdatetime[EMSI_MAXXDATETIME+1];
198 
199 	/*
200 	 * {TRX#} (site's current time)
201 	 */
202 	bool        have_trx;
203 	time_t      time;
204 };
205 typedef struct emsi s_emsi;
206 
207 /* prot_emsi.c */
208 int emsi_send_emsidat(s_emsi *local_emsi);
209 int emsi_recv_emsidat(s_emsi *remote_emsi);
210 void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
211                       e_protocol protocol);
212 
213 /* prot_emsi_api.c */
214 extern s_handshake_protocol handshake_protocol_emsi;
215 
216 /* prot_emsi_misc.c */
217 char *emsi_createdat(s_emsi *emsi);
218 int   emsi_parsedat(char *emsi_dat, s_emsi *emsi);
219 void  emsi_logdat(s_emsi *emsi);
220 
221 #endif
222