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
d95188f6
...
d95188f6ff2624b1d10c4f3e95e1e818ddb285bc
authored
2002-11-21 13:47:33 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(imap4d_append0): Simplified a lot.
1 parent
1f6860f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
32 deletions
imap4d/append.c
imap4d/append.c
View file @
d95188f
...
...
@@ -58,27 +58,41 @@ imap4d_append (struct imap4d_command *command, char *arg)
return
util_finish
(
command
,
RESP_NO
,
"[TRYCREATE] failed"
);
}
static
int
_append_date
(
envelope_t
envelope
,
char
*
buf
,
size_t
len
,
size_t
*
pnwrite
)
{
message_t
msg
=
envelope_get_owner
(
envelope
);
struct
tm
**
tm
=
message_get_owner
(
msg
);
strftime
(
buf
,
len
,
"%a %b %d %H:%M:%S %Y"
,
*
tm
);
return
0
;
}
static
int
_append_sender
(
envelope_t
envelope
,
char
*
buf
,
size_t
len
,
size_t
*
pnwrite
)
{
strncpy
(
buf
,
"GNU-imap4d"
,
len
);
return
0
;
}
int
imap4d_append0
(
mailbox_t
mbox
,
int
flags
,
char
*
text
)
{
mailbox_t
tmp
;
stream_t
stream
;
int
rc
=
0
;
size_t
len
=
0
;
message_t
msg
;
message_t
msg
=
0
;
struct
tm
*
tm
;
time_t
t
;
char
date
[
80
];
if
(
mailbox_create
(
&
tmp
,
"/dev/null"
))
return
1
;
if
(
mailbox_open
(
tmp
,
MU_STREAM_READ
)
!=
0
)
envelope_t
env
;
if
(
message_create
(
&
msg
,
&
tm
))
return
1
;
if
(
memory_stream_create
(
&
stream
,
0
,
MU_STREAM_RDWR
)
||
stream_open
(
stream
))
{
m
ailbox_close
(
tmp
);
m
essage_destroy
(
&
msg
,
&
tm
);
return
1
;
}
...
...
@@ -98,34 +112,34 @@ imap4d_append0 (mailbox_t mbox, int flags, char *text)
time
(
&
t
);
}
tm
=
gmtime
(
&
t
);
strftime
(
date
,
sizeof
(
date
),
"From GNU-imap4d %a %b %e %H:%M:%S %Y%n"
,
tm
);
stream_write
(
stream
,
date
,
strlen
(
date
),
0
,
&
len
);
stream_write
(
stream
,
text
,
strlen
(
text
),
len
,
&
len
);
message_set_stream
(
msg
,
stream
,
&
tm
);
mailbox_set_stream
(
tmp
,
stream
);
mailbox_messages_count
(
tmp
,
&
len
);
if
(
len
==
1
)
envelope_create
(
&
env
,
msg
);
envelope_set_date
(
env
,
_append_date
,
msg
);
envelope_set_sender
(
env
,
_append_sender
,
msg
);
message_set_envelope
(
msg
,
env
,
&
tm
);
rc
=
mailbox_append_message
(
mbox
,
msg
);
if
(
rc
==
0
&&
flags
)
{
mailbox_get_message
(
tmp
,
1
,
&
msg
);
mailbox_append_message
(
mbox
,
msg
);
if
(
flags
)
{
size_t
num
=
0
;
attribute_t
attr
=
NULL
;
mailbox_messages_count
(
mbox
,
&
num
);
mailbox_get_message
(
mbox
,
num
,
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
attribute_set_flags
(
attr
,
flags
);
}
size_t
num
=
0
;
attribute_t
attr
=
NULL
;
mailbox_messages_count
(
mbox
,
&
num
);
mailbox_get_message
(
mbox
,
num
,
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
attribute_set_flags
(
attr
,
flags
);
}
else
rc
=
1
;
mailbox_close
(
tmp
);
mailbox_destroy
(
&
tmp
);
message_destroy
(
&
msg
,
&
tm
);
return
rc
;
}
int
wd
()
{
volatile
int
_s
=
0
;
while
(
!
_s
)
;
}
...
...
Please
register
or
sign in
to post a comment