12fdedba35b6929f0b859071495454912cee016c
[mmh] / mts / smtp / smtp.h
1
2 /*
3  * smtp.h -- definitions for the nmh SMTP Interface
4  *
5  * $Id$
6  */
7
8 /* various modes for SMTP */
9 #define S_MAIL  0
10 #define S_SEND  1
11 #define S_SOML  2
12 #define S_SAML  3
13
14 /* length is the length of the string in text[], which is also NUL
15  * terminated, so s.text[s.length] should always be 0.
16  */
17 struct smtp {
18     int code;
19     int length;
20     char text[BUFSIZ];
21 };
22
23 /*
24  * prototypes
25  */
26 /* int client (); */
27 int sm_init (char *, char *, char *, int, int, int, int, int, int, char *, char *, int);
28 int sm_winit (int, char *);
29 int sm_wadr (char *, char *, char *);
30 int sm_waend (void);
31 int sm_wtxt (char *, int);
32 int sm_wtend (void);
33 int sm_end (int);
34 char *rp_string (int);
35
36 /* The remainder of this file is derived from "mmdf.h" */
37
38 /*
39  *     Copyright (C) 1979,1980,1981,1982,1983  University of Delaware
40  *     Used by permission, May, 1984.
41  */
42
43 /*
44  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
45  *     
46  *
47  *     Copyright (C) 1979,1980,1981,1982,1983  University of Delaware
48  *     
49  *     Department of Electrical Engineering
50  *     University of Delaware
51  *     Newark, Delaware  19711
52  *
53  *     Phone:  (302) 738-1163
54  *     
55  *     
56  *     This program module was developed as part of the University
57  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
58  *     
59  *     Acquisition, use, and distribution of this module and its listings
60  *     are subject restricted to the terms of a license agreement.
61  *     Documents describing systems using this module must cite its source.
62  *
63  *     The above statements must be retained with all copies of this
64  *     program and may not be removed without the consent of the
65  *     University of Delaware.
66  *     
67  */
68
69 /*                      Reply Codes for MMDF
70  *
71  *  Based on: "Revised FTP Reply Codes", by Jon Postel & Nancy Neigus Arpanet
72  *      RFC 640 / NIC 30843, in the "Arpanet Protocol Handbook", E.  Feinler
73  *      and J. Postel (eds.), NIC 7104, Network Information Center, SRI
74  *      International:  Menlo Park, CA.  (NTIS AD-A0038901)
75  *
76  *  Actual values are different, but scheme is same.  Codes must fit into
77  *  8-bits (to pass on exit() calls); fields are packed 2-3-3 and interpreted
78  *  as octal numbers.
79  *
80  *  Basic format:
81  *
82  *      0yz: positive completion; entire action done
83  *      1yz: positive intermediate; only part done
84  *      2yz: Transient negative completion; may work later
85  *      3yz: Permanent negative completion; you lose forever
86  *
87  *      x0z: syntax
88  *      x1z: general; doesn't fit any other category
89  *      x2z: connections; truly transfer-related
90  *      x3z: user/authentication/account
91  *      x4x: mail
92  *      x5z: file system
93  *
94  *      3-bit z field is unique to the reply.  In the following,
95  *      the RP_xVAL defines are available for masking to obtain a field.
96  */
97
98 /*
99  * FIELD DEFINITIONS & BASIC VALUES
100  */
101
102 /* FIELD 1:  Basic degree of success (2-bits) */
103
104 #define RP_BTYP '\200'      /* good vs. bad; on => bad            */
105 #define RP_BVAL '\300'      /* basic degree of success            */
106
107 #define RP_BOK  '\000'      /* went fine; all done                */
108 #define RP_BPOK '\100'      /* only the first part got done       */
109 #define RP_BTNO '\200'      /* temporary failure; try later       */
110 #define RP_BNO  '\300'      /* not now, nor never; you lose       */
111
112 /* FIELD 2:  Basic domain of discourse (3-bits) */
113
114 #define RP_CVAL '\070'      /* basic category (domain) of reply   */
115
116 #define RP_CSYN '\000'      /* purely a matter of form            */
117 #define RP_CGEN '\010'      /* couldn't find anywhere else for it */
118 #define RP_CCON '\020'      /* data-transfer-related issue        */
119 #define RP_CUSR '\030'      /* pertaining to the user             */
120 #define RP_CMAI '\040'      /* specific to mail semantics         */
121 #define RP_CFIL '\050'      /* file system                        */
122 #define RP_CLIO '\060'      /* local i/o system                   */
123
124 /* FIELD 3:  Specific value for this reply (3-bits) */
125
126 #define RP_SVAL '\007'      /* specific value of reply            */
127
128
129 /*
130  * SPECIFIC SUCCESS VALUES
131  */
132
133 /*
134  * Complete Success
135  */
136
137 /* done (e.g., w/transaction) */
138 #define RP_DONE (RP_BOK | RP_CGEN | '\000')
139
140 /* general-purpose OK */
141 #define RP_OK   (RP_BOK | RP_CGEN | '\001')
142
143 /* message is accepted (w/text) */
144 #define RP_MOK  (RP_BOK | RP_CMAI | '\000')
145
146
147 /*
148  * Partial Success
149  */
150
151 /* you are the requestor */
152 #define RP_MAST (RP_BPOK| RP_CGEN | '\000')
153
154 /* you are the requestee */
155 #define RP_SLAV (RP_BPOK| RP_CGEN | '\001')
156
157 /* message address is accepted */
158 #define RP_AOK  (RP_BPOK| RP_CMAI | '\000')
159
160
161 /*
162  * SPECIFIC FALURE VALUES
163  */
164
165 /*
166  * Partial Failure
167  */
168
169 /* not now; maybe later */
170 #define RP_AGN  (RP_BTNO | RP_CGEN | '\000')
171
172 /* timeout */
173 #define RP_TIME (RP_BTNO | RP_CGEN | '\001')
174
175 /* no-op; nothing done, this time */
176 #define RP_NOOP (RP_BTNO | RP_CGEN | '\002')
177
178 /* encountered an end of file */
179 #define RP_EOF  (RP_BTNO | RP_CGEN | '\003')
180
181 /* channel went bad */
182 #define RP_NET  (RP_BTNO | RP_CCON | '\000')
183
184 /* foreign host screwed up */
185 #define RP_BHST (RP_BTNO | RP_CCON | '\001')
186
187 /* host went away */
188 #define RP_DHST (RP_BTNO | RP_CCON | '\002')
189
190 /* general net i/o problem */
191 #define RP_NIO  (RP_BTNO | RP_CCON | '\004')
192
193 /* error reading/writing file */
194 #define RP_FIO  (RP_BTNO | RP_CFIL | '\000')
195
196 /* unable to create file */
197 #define RP_FCRT (RP_BTNO | RP_CFIL | '\001')
198
199 /* unable to open file */
200 #define RP_FOPN (RP_BTNO | RP_CFIL | '\002')
201
202 /* general local i/o problem */
203 #define RP_LIO  (RP_BTNO | RP_CLIO | '\000')
204
205 /* resource currently locked */
206 #define RP_LOCK (RP_BTNO | RP_CLIO | '\001')
207
208
209 /*
210  * Complete Failure
211  */
212
213 /* bad mechanism/path; try alternate? */
214 #define RP_MECH (RP_BNO | RP_CGEN | '\000')
215
216 /* general-purpose NO */
217 #define RP_NO   (RP_BNO | RP_CGEN | '\001')
218
219 /* general prototocol error */
220 #define RP_PROT (RP_BNO | RP_CCON | '\000')
221
222 /* bad reply code (PERMANENT ERROR) */
223 #define RP_RPLY (RP_BNO | RP_CCON | '\001')
224
225 /* couldn't deliver */
226 #define RP_NDEL (RP_BNO | RP_CMAI | '\000')
227
228 /* couldn't parse the request */
229 #define RP_HUH  (RP_BNO | RP_CSYN | '\000')
230
231 /* no such command defined */
232 #define RP_NCMD (RP_BNO | RP_CSYN | '\001')
233
234 /* bad parameter */
235 #define RP_PARM (RP_BNO | RP_CSYN | '\002')
236
237 /* command not implemented */
238 #define RP_UCMD (RP_BNO | RP_CSYN | '\003')
239
240 /* unknown user */
241 #define RP_USER (RP_BNO | RP_CUSR | '\000')
242
243
244 /*
245  * Macros to access reply info
246  */
247
248 /* get the entire return value */
249 #define rp_gval(val)    ((signed char) (val))
250
251
252 /*
253  * The next three give the field's bits, within the whole value
254  */
255
256 /* get the basic part of return value */
257 #define rp_gbval(val)   (rp_gval (val) & RP_BVAL)
258
259 /* get the domain part of value */
260 #define rp_gcval(val)   (rp_gval (val) & RP_CVAL)
261
262 /* get the specific part of value */
263 #define rp_gsval(val)   (rp_gval (val) & RP_SVAL)
264
265
266 /*
267  * The next three give the numeric value withing the field
268  */
269
270 /* get the basic part right-shifted */
271 #define rp_gbbit(val)   ((rp_gval (val) >> 6) & 03)
272
273 /* get the domain part right-shifted */
274 #define rp_gcbit(val)   ((rp_gval (val) >> 3) & 07)
275
276 /* get the specific part right-shifted */
277 #define rp_gsbit(val)   (rp_gval (val) & 07)
278
279
280 /*
281  * MACHINE DEPENDENCY
282  *
283  * The following treat the value as strictly numeric.
284  * It relies on the negative values being numerically
285  * negative.
286  */
287
288 /* is return value positive? */
289 #define rp_isgood(val)  (rp_gval (val) >= 0)
290
291 /* is return value negative? */
292 #define rp_isbad(val)   (rp_gval (val) < 0)
293