1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21
22 #include <string.h>
23 #include <errno.h>
24 #include <mailutils/sys/pop3.h>
25
26 int
mu_pop3_dele(mu_pop3_t pop3,unsigned msgno)27 mu_pop3_dele (mu_pop3_t pop3, unsigned msgno)
28 {
29 int status;
30
31 if (pop3 == NULL || msgno == 0)
32 return EINVAL;
33
34 switch (pop3->state)
35 {
36 case MU_POP3_NO_STATE:
37 status = mu_pop3_writeline (pop3, "DELE %d\r\n", msgno);
38 MU_POP3_CHECK_ERROR (pop3, status);
39 MU_POP3_FCLR (pop3, MU_POP3_ACK);
40 pop3->state = MU_POP3_DELE;
41
42 case MU_POP3_DELE:
43 status = mu_pop3_response (pop3, NULL);
44 MU_POP3_CHECK_EAGAIN (pop3, status);
45 MU_POP3_CHECK_OK (pop3);
46 pop3->state = MU_POP3_NO_STATE;
47 break;
48
49 /* They must deal with the error first by reopening. */
50 case MU_POP3_ERROR:
51 status = ECANCELED;
52 break;
53
54 default:
55 status = EINPROGRESS;
56 }
57 return status;
58 }
59