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
098c5436
...
098c54364e0fd5ed46be0f2303bc1286c15bfde6
authored
2002-01-23 04:34:07 +0000
by
Sam Roberts
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
New function: list_do(), calls a function on each item in the list.
1 parent
299e098a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
include/mailutils/list.h
mailbox/list.c
include/mailutils/list.h
View file @
098c543
...
...
@@ -44,6 +44,11 @@ extern int list_count __P ((list_t, size_t *pcount));
extern
int
list_remove
__P
((
list_t
,
void
*
item
));
extern
int
list_get
__P
((
list_t
,
size_t
_index
,
void
**
pitem
));
typedef
int
list_action_t
__P
((
void
*
item
,
void
*
cbdata
));
extern
int
list_do
__P
((
list_t
list
,
list_action_t
*
action
,
void
*
cbdata
));
#ifdef __cplusplus
}
#endif
...
...
mailbox/list.c
View file @
098c543
...
...
@@ -179,3 +179,21 @@ list_get (list_t list, size_t indx, void **pitem)
monitor_unlock
(
list
->
monitor
);
return
status
;
}
int
list_do
(
list_t
list
,
list_action_t
*
action
,
void
*
cbdata
)
{
struct
list_data
*
current
;
int
status
=
0
;
if
(
list
==
NULL
||
action
==
NULL
)
return
EINVAL
;
monitor_rdlock
(
list
->
monitor
);
for
(
current
=
list
->
head
.
next
;
current
!=
&
(
list
->
head
);
current
=
current
->
next
)
{
if
((
status
=
action
(
current
->
item
,
cbdata
)))
break
;
}
monitor_unlock
(
list
->
monitor
);
return
status
;
}
...
...
Please
register
or
sign in
to post a comment