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
58d01e1e
...
58d01e1e081f2767ac07e9735c20d7f74c1bc637
authored
2011-11-19 20:52:46 +0200
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Imap client: fix status implementation.
1 parent
35718326
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
34 deletions
libproto/imap/status.c
libproto/imap/status.c
View file @
58d01e1
...
...
@@ -87,41 +87,32 @@ _status_mapper (void **itmv, size_t itmc, void *call_data)
return
0
;
}
static
int
_parse_status_response
(
mu_imap_t
imap
,
const
char
*
mboxname
,
struct
mu_imap_stat
*
ps
)
struct
status_data
{
struct
imap_list_element
*
response
,
*
elt
;
size_t
count
;
int
rc
;
rc
=
mu_list_get
(
imap
->
untagged_resp
,
0
,
(
void
*
)
&
response
);
if
(
rc
)
return
rc
;
const
char
*
mboxname
;
struct
mu_imap_stat
*
ps
;
};
mu_list_count
(
response
->
v
.
list
,
&
count
);
if
(
count
!=
3
)
return
MU_ERR_PARSE
;
rc
=
mu_list_get
(
response
->
v
.
list
,
0
,
(
void
*
)
&
elt
);
if
(
rc
)
return
rc
;
if
(
!
_mu_imap_list_element_is_string
(
elt
,
"STATUS"
))
return
MU_ERR_NOENT
;
rc
=
mu_list_get
(
response
->
v
.
list
,
1
,
(
void
*
)
&
elt
);
if
(
rc
)
return
rc
;
if
(
!
_mu_imap_list_element_is_string
(
elt
,
mboxname
))
return
MU_ERR_NOENT
;
rc
=
mu_list_get
(
response
->
v
.
list
,
2
,
(
void
*
)
&
elt
);
if
(
rc
)
return
rc
;
if
(
elt
->
type
!=
imap_eltype_list
)
return
MU_ERR_PARSE
;
static
void
_status_response_action
(
mu_imap_t
imap
,
mu_list_t
response
,
void
*
data
)
{
struct
status_data
*
sd
=
data
;
struct
imap_list_element
*
elt
;
ps
->
flags
=
0
;
return
mu_list_gmap
(
elt
->
v
.
list
,
_status_mapper
,
2
,
ps
);
elt
=
_mu_imap_list_at
(
response
,
0
);
if
(
elt
&&
_mu_imap_list_element_is_string
(
elt
,
"STATUS"
))
{
elt
=
_mu_imap_list_at
(
response
,
1
);
if
(
elt
&&
_mu_imap_list_element_is_string
(
elt
,
sd
->
mboxname
))
{
elt
=
_mu_imap_list_at
(
response
,
2
);
if
(
elt
&&
elt
->
type
==
imap_eltype_list
)
{
sd
->
ps
->
flags
=
0
;
mu_list_gmap
(
elt
->
v
.
list
,
_status_mapper
,
2
,
sd
->
ps
);
}
}
}
}
int
...
...
@@ -197,8 +188,11 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
switch
(
imap
->
resp_code
)
{
case
MU_IMAP_OK
:
memset
(
&
imap
->
mbox_stat
,
0
,
sizeof
(
imap
->
mbox_stat
));
status
=
_parse_status_response
(
imap
,
mboxname
,
ps
);
{
struct
status_data
sd
=
{
mboxname
,
ps
};
status
=
mu_imap_foreach_response
(
imap
,
_status_response_action
,
&
sd
);
}
break
;
case
MU_IMAP_NO
:
...
...
Please
register
or
sign in
to post a comment