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
17361803
...
17361803d1890f7b3c738546ee45520191ea4d0f
authored
2002-04-10 13:25:44 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Output only those list items that match given wildcard expression.
1 parent
ee3fc423
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
imap4d/lsub.c
imap4d/lsub.c
View file @
1736180
...
...
@@ -27,10 +27,11 @@ imap4d_lsub (struct imap4d_command *command, char *arg)
char
*
sp
;
char
*
ref
;
char
*
wcard
;
char
*
file
;
char
*
file
=
NULL
;
char
*
pattern
=
NULL
;
const
char
*
delim
=
"/"
;
FILE
*
fp
;
if
(
!
(
command
->
states
&
state
))
return
util_finish
(
command
,
RESP_BAD
,
"Wrong state"
);
...
...
@@ -43,21 +44,34 @@ imap4d_lsub (struct imap4d_command *command, char *arg)
util_unquote
(
&
ref
);
util_unquote
(
&
wcard
);
/* FIXME: Get the matching in list. */
asprintf
(
&
pattern
,
"%s%s"
,
ref
,
wcard
);
if
(
!
pattern
)
return
util_finish
(
command
,
RESP_NO
,
"Not enough memory"
);
asprintf
(
&
file
,
"%s/.mailboxlist"
,
homedir
);
if
(
!
file
)
{
free
(
pattern
);
return
util_finish
(
command
,
RESP_NO
,
"Not enough memory"
);
}
fp
=
fopen
(
file
,
"r"
);
free
(
file
);
if
(
fp
)
{
char
buffer
[
124
];
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
fp
))
{
size_t
n
=
strlen
(
buffer
);
if
(
n
&&
buffer
[
n
-
1
]
==
'\n'
)
buffer
[
n
-
1
]
=
'\0'
;
util_out
(
RESP_NONE
,
"LIST ()
\"
%s
\"
%s"
,
delim
,
buffer
);
}
char
*
buf
=
NULL
;
size_t
n
=
0
;
while
(
getline
(
&
buf
,
&
n
,
fp
)
>
0
)
{
int
len
=
strlen
(
buf
);
if
(
buf
[
len
-
1
]
==
'\n'
)
buf
[
len
-
1
]
=
'\0'
;
if
(
util_wcard_match
(
buf
,
pattern
,
delim
)
!=
WCARD_NOMATCH
)
util_out
(
RESP_NONE
,
"LIST ()
\"
%s
\"
%s"
,
delim
,
buf
);
}
fclose
(
fp
);
free
(
buf
);
return
util_finish
(
command
,
RESP_OK
,
"Completed"
);
}
else
if
(
errno
==
ENOENT
)
...
...
Please
register
or
sign in
to post a comment