1 /* GNU Mailutils -- a suite of utilities for electronic mail
2    Copyright (C) 2003-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 <stdlib.h>
23 #include <errno.h>
24 #include <mailutils/errno.h>
25 #include <mailutils/sys/pop3.h>
26 #include <mailutils/list.h>
27 
28 /* Initialise a mu_pop3_t handle.  */
29 
30 int
mu_pop3_create(mu_pop3_t * ppop3)31 mu_pop3_create (mu_pop3_t *ppop3)
32 {
33   mu_pop3_t pop3;
34 
35   /* Sanity check.  */
36   if (ppop3 == NULL)
37     return EINVAL;
38 
39   pop3 = calloc (1, sizeof *pop3);
40   if (pop3 == NULL)
41     return ENOMEM;
42 
43   pop3->state = MU_POP3_NO_STATE; /* Init with no state.  */
44   pop3->timeout = (10 * 60) * 100; /* The default Timeout is 10 minutes.  */
45   MU_POP3_FCLR (pop3, MU_POP3_ACK); /* No Ack received.  */
46 
47   *ppop3 = pop3;
48   return 0; /* Okdoke.  */
49 }
50 
51 int
_mu_pop3_init(mu_pop3_t pop3)52 _mu_pop3_init (mu_pop3_t pop3)
53 {
54   if (pop3 == NULL)
55     return EINVAL;
56   if (pop3->carrier == 0)
57     {
58       mu_list_destroy (&pop3->capa);
59       pop3->flags = 0;
60     }
61   return 0;
62 }
63 
64 
65