pop3.h
5.15 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999-2001, 2003-2005, 2007, 2010-2012, 2014 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_POP3_H
#define _MAILUTILS_POP3_H
#include <mailutils/iterator.h>
#include <mailutils/debug.h>
#include <mailutils/stream.h>
#ifdef __cplusplus
extern "C" {
#endif
struct _mu_pop3;
typedef struct _mu_pop3 *mu_pop3_t;
#define MU_POP3_DEFAULT_PORT 110
#define MU_POP3_DEFAULT_SSL_PORT 995
int mu_pop3_create (mu_pop3_t *pop3);
void mu_pop3_destroy (mu_pop3_t *pop3);
int mu_pop3_set_carrier (mu_pop3_t pop3, mu_stream_t carrier);
int mu_pop3_get_carrier (mu_pop3_t pop3, mu_stream_t *pcarrier);
int mu_pop3_connect (mu_pop3_t pop3);
int mu_pop3_disconnect (mu_pop3_t pop3);
int mu_pop3_set_timeout (mu_pop3_t pop3, int timeout);
int mu_pop3_get_timeout (mu_pop3_t pop3, int *timeout);
#define MU_POP3_TRACE_CLR 0
#define MU_POP3_TRACE_SET 1
#define MU_POP3_TRACE_QRY 2
int mu_pop3_trace (mu_pop3_t pop3, int op);
int mu_pop3_trace_mask (mu_pop3_t pop3, int op, int lev);
int mu_pop3_apop (mu_pop3_t pop3, const char *name, const char *digest);
int mu_pop3_stls (mu_pop3_t pop3);
/* It is the responsibility of the caller to call mu_iterator_destroy() when
done with the iterator. The items returned by the iterator are of type
"const char *", no processing is done on the item except the removal of
the trailing newline. */
int mu_pop3_capa (mu_pop3_t pop3, int reread, mu_iterator_t *piter);
int mu_pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret);
int mu_pop3_dele (mu_pop3_t pop3, unsigned int mesgno);
int mu_pop3_list (mu_pop3_t pop3, unsigned int mesgno, size_t *mesg_octet);
/* Send the LIST command and prepare pop3 for receiving a multiline answer.
The caller is expected to obtain a stream via mu_pop3_stream_create,
or an iterator via mu_pop3_iterator_create and read data from them.
This function is not intended for use by a casual user, better use
mu_pop3_list_all or mu_pop3_list_all_stream. */
int mu_pop3_list_cmd (mu_pop3_t pop3);
int mu_pop3_list_all (mu_pop3_t pop3, mu_iterator_t *pitr);
int mu_pop3_list_all_stream (mu_pop3_t pop3, mu_stream_t *pstream);
int mu_pop3_noop (mu_pop3_t pop3);
int mu_pop3_pass (mu_pop3_t pop3, const char *pass);
int mu_pop3_quit (mu_pop3_t pop3);
/* A stream is returned with the multi-line answer. It is the responsibility
of the caller to call mu_stream_destroy() to dipose of the stream. */
int mu_pop3_retr (mu_pop3_t pop3, unsigned int mesgno,
mu_stream_t *pstream);
int mu_pop3_rset (mu_pop3_t pop3);
int mu_pop3_stat (mu_pop3_t pop3, size_t *count, mu_off_t *octets);
/* A stream is returned with the multi-line answer. It is the responsibility
of the caller to call mu_stream_destroy() to dipose of the stream. */
int mu_pop3_top (mu_pop3_t pop3, unsigned int mesgno,
unsigned int lines, mu_stream_t *pstream);
/* The uidl is malloc'ed and returned in puidl; it is the responsibility of
the caller to free() the uild when done. */
int mu_pop3_uidl (mu_pop3_t pop3, unsigned int mesgno, char **puidl);
/* Send the UIDL command and prepare pop3 for receiving a multiline answer.
The caller is expected to obtain a stream via mu_pop3_stream_create,
or an iterator via mu_pop3_iterator_create and read data from them.
This function is not intended for use by a casual user, better use
mu_pop3_uidl_all or mu_pop3_uidl_all_stream. */
int mu_pop3_uidl_all_cmd (mu_pop3_t pop3);
int mu_pop3_uidl_all (mu_pop3_t pop3, mu_iterator_t *piterator);
int mu_pop3_uidl_all_stream (mu_pop3_t pop3, mu_stream_t *pstream);
int mu_pop3_user (mu_pop3_t pop3, const char *user);
/* Returns the last command acknowledge. If the server supports RESP-CODE,
the message could be retrieved, but it is up to the caller to do the
parsing. */
int mu_pop3_response (mu_pop3_t pop3, size_t *nread);
const char *mu_pop3_strresp (mu_pop3_t pop3);
int mu_pop3_sget_response (mu_pop3_t pop3, const char **sptr);
int mu_pop3_aget_response (mu_pop3_t pop3, char **sptr);
int mu_pop3_get_response (mu_pop3_t pop3, char *buf, size_t len, size_t *plen);
int mu_pop3_writeline (mu_pop3_t pop3, const char *format, ...)
MU_PRINTFLIKE(2,3);
int mu_pop3_sendline (mu_pop3_t pop3, const char *line);
int mu_pop3_getline (mu_pop3_t pop3);
int mu_pop3_read_list (mu_pop3_t pop3, mu_list_t list);
int mu_pop3_stream_to_list (mu_pop3_t pop3, mu_stream_t stream,
mu_list_t list);
#ifdef __cplusplus
}
#endif
#endif /* _MAILUTILS_POP3_H */