Revert "Update to 7.44.0"
[platform/upstream/curl.git] / lib / smtp.h
1 #ifndef HEADER_CURL_SMTP_H
2 #define HEADER_CURL_SMTP_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 2009 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at http://curl.haxx.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  ***************************************************************************/
24
25 #include "pingpong.h"
26
27 /****************************************************************************
28  * SMTP unique setup
29  ***************************************************************************/
30 typedef enum {
31   SMTP_STOP,        /* do nothing state, stops the state machine */
32   SMTP_SERVERGREET, /* waiting for the initial greeting immediately after
33                        a connect */
34   SMTP_EHLO,
35   SMTP_HELO,
36   SMTP_STARTTLS,
37   SMTP_UPGRADETLS,  /* asynchronously upgrade the connection to SSL/TLS
38                        (multi mode only) */
39   SMTP_AUTH_PLAIN,
40   SMTP_AUTH_LOGIN,
41   SMTP_AUTH_LOGIN_PASSWD,
42   SMTP_AUTH_CRAMMD5,
43   SMTP_AUTH_DIGESTMD5,
44   SMTP_AUTH_DIGESTMD5_RESP,
45   SMTP_AUTH_NTLM,
46   SMTP_AUTH_NTLM_TYPE2MSG,
47   SMTP_AUTH_GSSAPI,
48   SMTP_AUTH_GSSAPI_TOKEN,
49   SMTP_AUTH_GSSAPI_NO_DATA,
50   SMTP_AUTH_XOAUTH2,
51   SMTP_AUTH_CANCEL,
52   SMTP_AUTH_FINAL,
53   SMTP_COMMAND,     /* VRFY, EXPN, NOOP, RSET and HELP */
54   SMTP_MAIL,        /* MAIL FROM */
55   SMTP_RCPT,        /* RCPT TO */
56   SMTP_DATA,
57   SMTP_POSTDATA,
58   SMTP_QUIT,
59   SMTP_LAST         /* never used */
60 } smtpstate;
61
62 /* This SMTP struct is used in the SessionHandle. All SMTP data that is
63    connection-oriented must be in smtp_conn to properly deal with the fact that
64    perhaps the SessionHandle is changed between the times the connection is
65    used. */
66 struct SMTP {
67   curl_pp_transfer transfer;
68   char *custom;            /* Custom Request */
69   struct curl_slist *rcpt; /* Recipient list */
70   size_t eob;              /* Number of bytes of the EOB (End Of Body) that
71                               have been received so far */
72   bool trailing_crlf;      /* Specifies if the tailing CRLF is present */
73 };
74
75 /* smtp_conn is used for struct connection-oriented data in the connectdata
76    struct */
77 struct smtp_conn {
78   struct pingpong pp;
79   smtpstate state;         /* Always use smtp.c:state() to change state! */
80   bool ssldone;            /* Is connect() over SSL done? */
81   char *domain;            /* Client address/name to send in the EHLO */
82   unsigned int authmechs;  /* Accepted authentication mechanisms */
83   unsigned int prefmech;   /* Preferred authentication mechanism */
84   unsigned int authused;   /* Auth mechanism used for the connection */
85   bool tls_supported;      /* StartTLS capability supported by server */
86   bool size_supported;     /* If server supports SIZE extension according to
87                               RFC 1870 */
88   bool auth_supported;     /* AUTH capability supported by server */
89   bool mutual_auth;        /* Mutual authentication enabled (GSSAPI only) */
90 };
91
92 extern const struct Curl_handler Curl_handler_smtp;
93 extern const struct Curl_handler Curl_handler_smtps;
94
95 /* this is the 5-bytes End-Of-Body marker for SMTP */
96 #define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a"
97 #define SMTP_EOB_LEN 5
98 #define SMTP_EOB_FIND_LEN 3
99
100 /* if found in data, replace it with this string instead */
101 #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e"
102 #define SMTP_EOB_REPL_LEN 4
103
104 CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread);
105
106 #endif /* HEADER_CURL_SMTP_H */