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
4d68dc11
...
4d68dc112dfd2c8213b5448c1c6038a374fe12eb
authored
2001-04-25 04:39:33 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implemented STORE in IMAP4
1 parent
7401733c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
6 deletions
ChangeLog
imap4d/status.c
imap4d/store.c
include/mailutils/attribute.h
mailbox/attribute.c
ChangeLog
View file @
4d68dc1
2001-04-25 Alain Magloire
* imap4d/store.c: First implementation.
* mailbox/attribute.c (attribute_unsee_flags): New function.
2001-04-23 Sergey Poznyakoff
* mailbox/mbx_mbox.c (mbx_expunge): It assumes that mbox_get_message()
...
...
imap4d/status.c
View file @
4d68dc1
...
...
@@ -41,12 +41,8 @@ imap4d_status (struct imap4d_command *command, char *arg)
return
util_finish
(
command
,
RESP_BAD
,
"Wrong state"
);
name
=
util_getword
(
arg
,
&
sp
);
if
(
!
name
||
!
sp
)
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
util_unquote
(
&
name
);
if
(
*
name
==
'\0'
||
*
sp
==
'\0'
)
if
(
!
name
||
*
name
==
'\0'
||
!
sp
||
*
sp
==
'\0'
)
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
if
(
strcasecmp
(
name
,
"INBOX"
)
==
0
)
...
...
imap4d/store.c
View file @
4d68dc1
...
...
@@ -20,11 +20,131 @@
/*
* Now you're messing with a sumbitch
*/
static
int
get_attribute_type
__P
((
const
char
*
,
int
*
));
int
imap4d_store
(
struct
imap4d_command
*
command
,
char
*
arg
)
{
char
*
msgset
;
char
*
data
;
char
*
sp
=
NULL
;
int
status
;
int
ack
=
0
;
size_t
i
,
n
=
0
;
int
*
set
=
NULL
;
enum
value_type
{
STORE_SET
,
STORE_ADD
,
STORE_UNSET
}
how
;
if
(
!
(
command
->
states
&
state
))
return
util_finish
(
command
,
RESP_BAD
,
"Wrong state"
);
return
util_finish
(
command
,
RESP_NO
,
"Not supported"
);
msgset
=
util_getword
(
arg
,
&
sp
);
data
=
util_getword
(
NULL
,
&
sp
);
if
(
!
msgset
||
!
data
||
!
sp
||
*
sp
==
'\0'
)
return
util_finish
(
command
,
RESP_BAD
,
"Too few args"
);
/* The parsing of the data-item is a little slugish. */
if
(
strcasecmp
(
data
,
"FLAGS"
)
==
0
)
{
ack
=
1
;
how
=
STORE_SET
;
}
else
if
(
strcasecmp
(
data
,
"+FLAGS"
)
==
0
)
{
ack
=
1
;
how
=
STORE_ADD
;
}
else
if
(
strcasecmp
(
data
,
"-FLAGS"
)
==
0
)
{
ack
=
1
;
how
=
STORE_UNSET
;
}
else
if
(
strcasecmp
(
data
,
"FLAGS.SILENT"
)
==
0
)
{
ack
=
0
;
how
=
STORE_SET
;
}
else
if
(
strcasecmp
(
data
,
"+FLAGS.SILENT"
)
==
0
)
{
ack
=
0
;
how
=
STORE_ADD
;
}
else
if
(
strcasecmp
(
data
,
"-FLAGS.SILENT"
)
==
0
)
{
ack
=
0
;
how
=
STORE_UNSET
;
}
else
return
util_finish
(
command
,
RESP_BAD
,
"Bogus data item"
);
/* Get the message numbers in set[]. */
status
=
util_msgset
(
msgset
,
&
set
,
&
n
,
0
);
if
(
status
!=
0
)
return
util_finish
(
command
,
RESP_BAD
,
"Bogus number set"
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
message_t
msg
=
NULL
;
attribute_t
attr
=
NULL
;
char
*
items
=
strdup
(
sp
);
/* Don't use the orignal list. */
char
*
flags
=
strdup
(
""
);
int
first
=
1
;
mailbox_get_message
(
mbox
,
set
[
i
],
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
/* Get the fetch command names. */
while
(
*
items
&&
*
items
!=
')'
)
{
int
type
=
0
;
char
item
[
64
]
=
""
;
util_token
(
item
,
sizeof
(
item
),
&
items
);
if
(
get_attribute_type
(
item
,
&
type
))
{
if
(
how
==
STORE_ADD
)
attribute_set_flags
(
attr
,
type
);
else
if
(
how
==
STORE_UNSET
)
attribute_unset_flags
(
attr
,
type
);
else
if
(
how
==
STORE_SET
)
{
if
(
first
)
{
attribute_set_flags
(
attr
,
0
);
first
=
0
;
}
attribute_set_flags
(
attr
,
type
);
}
flags
=
realloc
(
flags
,
strlen
(
flags
)
+
strlen
(
item
)
+
2
);
if
(
*
flags
)
strcat
(
flags
,
" "
);
strcat
(
flags
,
item
);
}
}
if
(
ack
&&
*
flags
)
util_out
(
RESP_NONE
,
"%d FETCH FLAGS (%s)"
,
set
[
i
],
flags
);
free
(
items
);
free
(
flags
);
}
free
(
set
);
return
util_finish
(
command
,
RESP_OK
,
"Completed"
);
}
static
int
get_attribute_type
(
const
char
*
item
,
int
*
type
)
{
if
(
strcasecmp
(
item
,
"
\\
Answered"
)
==
0
)
*
type
=
MU_ATTRIBUTE_ANSWERED
;
else
if
(
strcasecmp
(
item
,
"
\\
Deleted"
)
==
0
)
*
type
=
MU_ATTRIBUTE_DELETED
;
else
if
(
strcasecmp
(
item
,
"
\\
Draft"
)
==
0
)
*
type
=
MU_ATTRIBUTE_DRAFT
;
else
if
(
strcasecmp
(
item
,
"
\\
Flagged"
)
==
0
)
*
type
=
MU_ATTRIBUTE_FLAGGED
;
else
if
(
strcasecmp
(
item
,
"
\\
Recent"
)
==
0
)
*
type
=
MU_ATTRIBUTE_RECENT
;
else
if
(
strcasecmp
(
item
,
"
\\
Seen"
)
==
0
)
*
type
=
MU_ATTRIBUTE_SEEN
;
else
return
0
;
return
1
;
}
...
...
include/mailutils/attribute.h
View file @
4d68dc1
...
...
@@ -79,6 +79,7 @@ extern int attribute_unset_read __P ((attribute_t));
extern
int
attribute_get_flags
__P
((
attribute_t
,
int
*
));
extern
int
attribute_set_flags
__P
((
attribute_t
,
int
));
extern
int
attribute_unset_flags
__P
((
attribute_t
,
int
));
extern
int
attribute_set_set_flags
__P
((
attribute_t
,
int
(
*
_set_flags
)
__P
((
attribute_t
,
int
)),
void
*
));
...
...
mailbox/attribute.c
View file @
4d68dc1
...
...
@@ -102,6 +102,17 @@ attribute_set_flags (attribute_t attr, int flags)
}
int
attribute_unset_flags
(
attribute_t
attr
,
int
flags
)
{
if
(
attr
==
NULL
)
return
EINVAL
;
if
(
attr
->
_unset_flags
)
attr
->
_unset_flags
(
attr
,
flags
);
attr
->
flags
&=
~
flags
;
return
0
;
}
int
attribute_set_get_flags
(
attribute_t
attr
,
int
(
*
_get_flags
)
(
attribute_t
,
int
*
),
void
*
owner
)
{
...
...
Please
register
or
sign in
to post a comment