1 |
// smtp.h -*- C++ -*- socket library |
2 |
// Copyright (C) 1992,1993,1994 Gnanasekaran Swaminathan <gs4t@virginia.edu> |
3 |
// |
4 |
// Permission is granted to use at your own risk and distribute this software |
5 |
// in source and binary forms provided the above copyright |
6 |
// notice and this paragraph are preserved on all copies. |
7 |
// This software is provided "as is" with no express or implied warranty. |
8 |
// |
9 |
// Version: 17Oct95 1.10 |
10 |
|
11 |
#ifndef SMTP_H |
12 |
#define SMTP_H |
13 |
|
14 |
#include <protocol.h> |
15 |
|
16 |
class smtp: public protocol { |
17 |
public: |
18 |
class smtpbuf : public protocol::protocolbuf { |
19 |
ostream* o; // send all the responses to o |
20 |
|
21 |
void send_cmd (const char* cmd, const char* s = 0, |
22 |
const char* p = 0); |
23 |
void get_response (); |
24 |
|
25 |
smtpbuf (smtpbuf&); |
26 |
smtpbuf& operator = (smtpbuf&); |
27 |
public: |
28 |
smtpbuf (ostream* out = 0) |
29 |
: protocol::protocolbuf (protocol::tcp), o (out) {} |
30 |
|
31 |
void send_buf (const char* buf, int buflen); |
32 |
|
33 |
void helo (); |
34 |
void quit () { send_cmd ("QUIT"); } |
35 |
void turn () { send_cmd ("TURN"); } |
36 |
void rset () { send_cmd ("RSET"); } |
37 |
void noop () { send_cmd ("NOOP"); } |
38 |
void vrfy (const char* s) { send_cmd ("VRFY ", s); } |
39 |
void expn (const char* s) { send_cmd ("EXPN ", s); } |
40 |
|
41 |
void data () { send_cmd ("DATA"); } |
42 |
void data (const char* buf, int buflen); |
43 |
void data (const char* filename); // filename = 0 => stdin |
44 |
|
45 |
void mail (const char* reverse_path); |
46 |
void rcpt (const char* forward_path); |
47 |
void help (const char* s = 0); |
48 |
|
49 |
virtual void serve_clients (int portno = -1); |
50 |
virtual const char* rfc_name () const { return "smtp"; } |
51 |
virtual const char* rfc_doc () const { return "rfc821"; } |
52 |
}; |
53 |
|
54 |
protected: |
55 |
smtp(): ios (0) {} |
56 |
|
57 |
public: |
58 |
smtp (ostream* out): ios (0) { ios::init (new smtpbuf (out)); } |
59 |
~smtp () { delete ios::rdbuf (); ios::init (0); } |
60 |
|
61 |
int get_response (char* buf, int len); |
62 |
|
63 |
smtpbuf* rdbuf () { return (smtpbuf*) protocol::rdbuf (); } |
64 |
smtpbuf* operator -> () { return rdbuf (); } |
65 |
}; |
66 |
|
67 |
extern ostream& operator << (ostream& o, smtp& s); |
68 |
|
69 |
#endif // SMTP_H |