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
5d2d4888
...
5d2d48884172f2d05844a8863ca12c1f47878468
authored
2001-05-30 09:08:18 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
UID SEARCH support
1 parent
f0e16cef
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
9 deletions
imap4d/search.c
imap4d/uid.c
imap4d/search.c
View file @
5d2d488
...
...
@@ -157,6 +157,7 @@ struct parsebuf
char
tokbuf
[
MAXTOKEN
+
1
];
/* Token buffer for short tokens */
char
*
arg
;
/* Rest of command line to be parsed */
int
isuid
;
/* UIDs instead of msgnos are required */
char
*
err_mesg
;
/* Error message if a parse error occured */
struct
mem_chain
*
alloc
;
/* Chain of objects allocated during parsing */
...
...
@@ -190,49 +191,77 @@ static void do_search __P((struct parsebuf *pb));
int
imap4d_search
(
struct
imap4d_command
*
command
,
char
*
arg
)
{
char
*
sp
;
char
*
str
;
struct
parsebuf
parsebuf
;
int
rc
;
char
buffer
[
64
];
if
(
!
(
command
->
states
&
state
))
return
util_finish
(
command
,
RESP_BAD
,
"Wrong state"
);
rc
=
imap4d_search0
(
arg
,
0
,
buffer
,
sizeof
buffer
);
return
util_finish
(
command
,
rc
,
buffer
);
}
int
imap4d_search0
(
char
*
arg
,
int
isuid
,
char
*
replybuf
,
size_t
replysize
)
{
char
*
sp
;
char
*
str
;
struct
parsebuf
parsebuf
;
memset
(
&
parsebuf
,
0
,
sizeof
(
parsebuf
));
parsebuf
.
arg
=
arg
;
parsebuf
.
err_mesg
=
NULL
;
parsebuf
.
alloc
=
NULL
;
parsebuf
.
isuid
=
isuid
;
if
(
!
parse_gettoken
(
&
parsebuf
,
0
))
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
{
snprintf
(
replybuf
,
replysize
,
"Too few args"
);
return
RESP_BAD
;
}
if
(
strcasecmp
(
parsebuf
.
token
,
"CHARSET"
)
==
0
)
{
if
(
!
parse_gettoken
(
&
parsebuf
,
0
))
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
{
snprintf
(
replybuf
,
replysize
,
"Too few args"
);
return
RESP_BAD
;
}
/* Currently only ASCII is supported */
if
(
strcmp
(
parsebuf
.
token
,
"US-ASCII"
))
return
util_finish
(
command
,
RESP_NO
,
"Charset not supported"
);
{
snprintf
(
replybuf
,
replysize
,
"Charset not supported"
);
return
RESP_NO
;
}
if
(
!
parse_gettoken
(
&
parsebuf
,
0
))
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
{
snprintf
(
replybuf
,
replysize
,
"Too few args"
);
return
RESP_BAD
;
}
}
/* Compile the expression */
if
(
parse_search_key_list
(
&
parsebuf
))
{
parse_free_mem
(
&
parsebuf
);
return
util_finish
(
command
,
RESP_BAD
,
"%s (near %s)"
,
snprintf
(
replybuf
,
replysize
,
"%s (near %s)"
,
parsebuf
.
err_mesg
,
*
parsebuf
.
arg
?
parsebuf
.
arg
:
"end"
);
return
RESP_BAD
;
}
put_code
(
&
parsebuf
,
NULL
);
/* Execute compiled expression */
do_search
(
&
parsebuf
);
parse_free_mem
(
&
parsebuf
);
return
util_finish
(
command
,
RESP_OK
,
"Completed"
);
snprintf
(
replybuf
,
replysize
,
"Completed"
);
return
RESP_OK
;
}
/* For each message from the mailbox execute the query from `pb' and
...
...
@@ -251,8 +280,17 @@ do_search (struct parsebuf *pb)
{
if
(
mailbox_get_message
(
mbox
,
pb
->
msgno
,
&
pb
->
msg
)
==
0
&&
search_run
(
pb
))
{
if
(
pb
->
isuid
)
{
size_t
uid
;
message_get_uid
(
pb
->
msg
,
&
uid
);
util_send
(
" %d"
,
uid
);
}
else
util_send
(
" %d"
,
pb
->
msgno
);
}
}
util_send
(
"
\r\n
"
);
}
...
...
imap4d/uid.c
View file @
5d2d488
...
...
@@ -48,6 +48,10 @@ imap4d_uid (struct imap4d_command *command, char *arg)
{
rc
=
imap4d_store0
(
sp
,
1
,
buffer
,
sizeof
buffer
);
}
else
if
(
strcasecmp
(
cmd
,
"SEARCH"
)
==
0
)
{
rc
=
imap4d_search0
(
sp
,
1
,
buffer
,
sizeof
buffer
);
}
else
{
snprintf
(
buffer
,
sizeof
buffer
,
"Error uknown uid command"
);
...
...
Please
register
or
sign in
to post a comment