Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
920d53a6
...
920d53a6ad0a8199420adc4eea619aa87c205d0f
authored
2004-07-01 03:59:35 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
use iterator_t instead of a list_t
1 parent
95b548f1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
109 deletions
mailbox/pop/Makefile.am
mailbox/pop/pop3_capa.c
mailbox/pop/pop3_lista.c
mailbox/pop/pop3_uidla.c
mailbox/pop/Makefile.am
View file @
920d53a
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2003 Free Software Foundation, Inc.
## Copyright (C) 2003
, 2004
Free Software Foundation, Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
...
...
@@ -37,6 +37,7 @@ libmu_pop_la_SOURCES = \
pop3_dele.c
\
pop3_destroy.c
\
pop3_disconnect.c
\
pop3_iterator.c
\
pop3_lista.c
\
pop3_list.c
\
pop3_noop.c
\
...
...
mailbox/pop/pop3_capa.c
View file @
920d53a
...
...
@@ -32,13 +32,13 @@
It is the responsability of the caller to destroy the list(list_destroy).
*/
int
mu_pop3_capa
(
mu_pop3_t
pop3
,
list_t
*
plist
)
mu_pop3_capa
(
mu_pop3_t
pop3
,
iterator_t
*
piterator
)
{
int
status
;
int
status
=
0
;
if
(
pop3
==
NULL
)
return
EINVAL
;
if
(
p
list
==
NULL
)
if
(
p
iterator
==
NULL
)
return
MU_ERR_OUT_PTR_NULL
;
switch
(
pop3
->
state
)
...
...
@@ -60,37 +60,13 @@ mu_pop3_capa (mu_pop3_t pop3, list_t *plist)
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
mu_pop3_debug_ack
(
pop3
);
MU_POP3_CHECK_OK
(
pop3
);
status
=
list_create
(
plist
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
list_set_destroy_item
(
*
plist
,
free
);
status
=
mu_pop3_iterator_create
(
pop3
,
piterator
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_CAPA_RX
;
case
MU_POP3_CAPA_RX
:
{
/* CAPA line are 512 octets maximum according to RFC 2449.
But do not use the stack and malloc. */
char
*
capability
;
size_t
n
=
0
;
capability
=
malloc
(
512
);
if
(
capability
==
NULL
)
{
MU_POP3_CHECK_ERROR
(
pop3
,
ENOMEM
);
}
while
((
status
=
mu_pop3_readline
(
pop3
,
capability
,
512
,
&
n
))
==
0
&&
n
>
0
)
{
/* Nuke the trailing newline */
if
(
capability
[
n
-
1
]
==
'\n'
)
capability
[
n
-
1
]
=
'\0'
;
/* add to the list. */
list_append
(
*
plist
,
strdup
(
capability
));
n
=
0
;
}
free
(
capability
);
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_NO_STATE
;
break
;
}
/* The iterator_t will read the stream and set the state to MU_POP3_NO_STATE when done. */
break
;
/* They must deal with the error first by reopening. */
case
MU_POP3_ERROR
:
...
...
mailbox/pop/pop3_lista.c
View file @
920d53a
...
...
@@ -26,13 +26,13 @@
#include <mailutils/sys/pop3.h>
int
mu_pop3_list_all
(
mu_pop3_t
pop3
,
list_t
*
plist
)
mu_pop3_list_all
(
mu_pop3_t
pop3
,
iterator_t
*
piterator
)
{
int
status
;
int
status
=
0
;
if
(
pop3
==
NULL
)
return
EINVAL
;
if
(
p
list
==
NULL
)
if
(
p
iterator
==
NULL
)
return
MU_ERR_OUT_PTR_NULL
;
switch
(
pop3
->
state
)
...
...
@@ -54,43 +54,13 @@ mu_pop3_list_all (mu_pop3_t pop3, list_t *plist)
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
mu_pop3_debug_ack
(
pop3
);
MU_POP3_CHECK_OK
(
pop3
);
status
=
list_create
(
plist
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
list_set_destroy_item
(
*
plist
,
free
);
status
=
mu_pop3_iterator_create
(
pop3
,
piterator
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_LIST_RX
;
case
MU_POP3_LIST_RX
:
{
/* LIST line should not be over 512 octets maximum according to RFC 2449.
But do not use the stack and malloc. */
char
*
lista
;
size_t
n
=
0
;
lista
=
malloc
(
512
);
if
(
lista
==
NULL
)
{
/* MU_POP3_CHECK_ERROR(pop3, ENOMEM);
Do not use the macro we need to clear the list if errors. */
pop3
->
io
.
ptr
=
pop3
->
io
.
buf
;
pop3
->
state
=
MU_POP3_ERROR
;
list_destroy
(
plist
);
return
ENOMEM
;
}
while
((
status
=
mu_pop3_readline
(
pop3
,
lista
,
512
,
&
n
))
==
0
&&
n
>
0
)
{
/* Nuke the trailing newline */
if
(
lista
[
n
-
1
]
==
'\n'
)
lista
[
n
-
1
]
=
'\0'
;
/* add to the list. */
list_append
(
*
plist
,
strdup
(
lista
));
n
=
0
;
}
free
(
lista
);
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_NO_STATE
;
break
;
}
/* The iterator_t will read the stream and set the state to MU_POP3_NO_STATE when done. */
break
;
/* They must deal with the error first by reopening. */
case
MU_POP3_ERROR
:
...
...
mailbox/pop/pop3_uidla.c
View file @
920d53a
...
...
@@ -25,13 +25,13 @@
#include <mailutils/sys/pop3.h>
int
mu_pop3_uidl_all
(
mu_pop3_t
pop3
,
list_t
*
plist
)
mu_pop3_uidl_all
(
mu_pop3_t
pop3
,
iterator_t
*
piterator
)
{
int
status
;
int
status
=
0
;
if
(
pop3
==
NULL
)
return
EINVAL
;
if
(
p
list
==
NULL
)
if
(
p
iterator
==
NULL
)
return
MU_ERR_OUT_PTR_NULL
;
switch
(
pop3
->
state
)
...
...
@@ -53,45 +53,13 @@ mu_pop3_uidl_all (mu_pop3_t pop3, list_t *plist)
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
mu_pop3_debug_ack
(
pop3
);
MU_POP3_CHECK_OK
(
pop3
);
status
=
list_create
(
plist
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
list_set_destroy_item
(
*
plist
,
free
);
status
=
mu_pop3_iterator_create
(
pop3
,
piterator
);
MU_POP3_CHECK_ERROR
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_UIDL_RX
;
case
MU_POP3_UIDL_RX
:
{
/* UIDL line are 512 octets maximum according to RFC 1939.
But do not use the stack and malloc. */
char
*
uidla
;
size_t
n
=
0
;
uidla
=
malloc
(
512
);
if
(
uidla
==
NULL
)
{
/* MU_POP3_CHECK_ERROR(pop3, ENOMEM)
Do not use the macro since we have to remove the list
if things go wrong.
*/
pop3
->
io
.
ptr
=
pop3
->
io
.
buf
;
pop3
->
state
=
MU_POP3_ERROR
;
list_destroy
(
plist
);
return
ENOMEM
;
}
while
((
status
=
mu_pop3_readline
(
pop3
,
uidla
,
512
,
&
n
))
==
0
&&
n
>
0
)
{
/* Nuke the trailing newline */
if
(
uidla
[
n
-
1
]
==
'\n'
)
uidla
[
n
-
1
]
=
'\0'
;
/* add to the list. */
list_append
(
*
plist
,
strdup
(
uidla
));
n
=
0
;
}
free
(
uidla
);
MU_POP3_CHECK_EAGAIN
(
pop3
,
status
);
pop3
->
state
=
MU_POP3_NO_STATE
;
break
;
}
/* The iterator_t will read the stream and set the state to MU_POP3_NO_STATE when done. */
break
;
/* They must deal with the error first by reopening. */
case
MU_POP3_ERROR
:
...
...
@@ -104,4 +72,3 @@ mu_pop3_uidl_all (mu_pop3_t pop3, list_t *plist)
return
status
;
}
...
...
Please
register
or
sign in
to post a comment