summaryrefslogtreecommitdiff
path: root/include/mailutils/sys/smtp.h
blob: 92eccb1e8fff69cd3a2c81dcb2d52a47b456e581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 2010, 2011 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef _MAILUTILS_SYS_SMTP_H
# define _MAILUTILS_SYS_SMTP_H

# include <sys/types.h>
# include <sys/socket.h>
# include <mailutils/types.h>
# include <mailutils/smtp.h>
# include <mailutils/stream.h>

# define _MU_SMTP_ESMTP   0x01 /* Connection supports ESMTP */
# define _MU_SMTP_TRACE   0x02 /* Session trace required/enabled */
# define _MU_SMTP_ERR     0x04 /* Object in error state */
# define _MU_SMTP_MLREPL  0x08 /* Last reply was multi-line */
# define _MU_SMTP_TLS     0x10 /* TLS initiated */ 
# define _MU_SMTP_AUTH    0x20 /* Authorization passed */
# define _MU_SMTP_CLNPASS 0x40 /* Password has been de-obfuscated */
# define _MU_SMTP_SAVEBUF 0x80 /* Buffering state saved */

#define MU_SMTP_XSCRIPT_MASK(n) (0x100<<(n))

enum mu_smtp_state
  {
    MU_SMTP_INIT,
    MU_SMTP_EHLO,
    MU_SMTP_MAIL,
    MU_SMTP_RCPT,
    MU_SMTP_MORE,
    MU_SMTP_DOT,
    MU_SMTP_QUIT,
    MU_SMTP_CLOS
  };

struct _mu_smtp
{
  int flags;
  
  mu_stream_t carrier;
  enum mu_smtp_state state;
  mu_list_t capa;
  mu_list_t authimpl;          /* List of implemented authentication mechs */
  
  /* User-supplied data */
  char *param[MU_SMTP_MAX_PARAM];
  mu_list_t authmech;          /* List of allowed authentication mechs */
  mu_secret_t secret;
  
  /* I/O buffers */
  char replcode[4];
  char *replptr;
  
  char *rdbuf;
  size_t rdsize;

  char *flbuf;
  size_t flsize;
  
  mu_list_t mlrepl;
  struct mu_buffer_query savebuf;
};

#define MU_SMTP_FSET(p,f) ((p)->flags |= (f))
#define MU_SMTP_FISSET(p,f) ((p)->flags & (f))  
#define MU_SMTP_FCLR(p,f) ((p)->flags &= ~(f))

#define MU_SMTP_CHECK_ERROR(smtp, status)	\
  do						\
    {						\
      if (status != 0)				\
	{					\
          smtp->flags |= _MU_SMTP_ERR;		\
          return status;			\
	}					\
    }						\
  while (0)

int _mu_smtp_trace_enable (mu_smtp_t smtp);
int _mu_smtp_trace_disable (mu_smtp_t smtp);
int _mu_smtp_xscript_level (mu_smtp_t smtp, int xlev);
int _mu_smtp_gsasl_auth (mu_smtp_t smtp);
int _mu_smtp_mech_impl (mu_smtp_t smtp, mu_list_t list);
int _mu_smtp_data_begin (mu_smtp_t smtp);
int _mu_smtp_data_end (mu_smtp_t smtp);

int _mu_smtp_get_streams (mu_smtp_t smtp, mu_stream_t *streams);
int _mu_smtp_set_streams (mu_smtp_t smtp, mu_stream_t *streams);


#endif

Return to:

Send suggestions and report system problems to the System administrator.