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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
24 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
]
;
envelope_t
env
;
if
(
mailbox_create
(
&
tmp
,
"/dev/null"
))
return
1
;
if
(
mailbox_open
(
tmp
,
MU_STREAM_READ
)
!=
0
)
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,20 +112,16 @@ 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
);
mailbox_set_stream
(
tmp
,
stream
);
mailbox_messages_count
(
tmp
,
&
len
);
if
(
len
==
1
)
{
mailbox_get_message
(
tmp
,
1
,
&
msg
);
mailbox_append_message
(
mbox
,
msg
);
if
(
flags
)
message_set_stream
(
msg
,
stream
,
&
tm
);
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
)
{
size_t
num
=
0
;
attribute_t
attr
=
NULL
;
...
...
@@ -120,12 +130,16 @@ imap4d_append0 (mailbox_t mbox, int flags, char *text)
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