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
6de9251e
...
6de9251eb6e7ade349609e06ce08b320dfa65e64
authored
2004-06-03 21:58:51 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use new stream functions
1 parent
aa61bbaa
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
240 additions
and
308 deletions
examples/http.c
imap4d/auth_gsasl.c
imap4d/idle.c
imap4d/util.c
include/mailutils/sys/pop3.h
libsieve/extensions/spamd.c
mailbox/body.c
mailbox/file_stream.c
mailbox/filter.c
mailbox/imap/mbox.c
mailbox/mapfile_stream.c
mailbox/mbox/mbox.c
mailbox/message.c
mailbox/mime.c
mailbox/mutil.c
mailbox/pop/mbox.c
mailbox/pop/pop3_readline.c
mailbox/pop/pop3_sendline.c
mailbox/tcp.c
mh/mhn.c
examples/http.c
View file @
6de9251
...
...
@@ -33,11 +33,10 @@ char rbuf[1024];
int
main
(
void
)
{
int
ret
,
off
=
0
,
fd
;
int
ret
,
off
=
0
;
stream_t
stream
;
size_t
nb
;
fd_set
fds
;
ret
=
tcp_stream_create
(
&
stream
,
"www.gnu.org"
,
80
,
MU_STREAM_NONBLOCK
);
if
(
ret
!=
0
)
{
...
...
@@ -51,37 +50,22 @@ connect_again:
{
if
(
ret
==
EAGAIN
)
{
ret
=
stream_get_fd
(
stream
,
&
fd
);
if
(
ret
!=
0
)
{
mu_error
(
"stream_get_fd: %s"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
NULL
);
int
wflags
=
MU_STREAM_READY_WR
;
stream_wait
(
stream
,
&
wflags
,
NULL
);
goto
connect_again
;
}
mu_error
(
"stream_open: %s"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
ret
=
stream_get_fd
(
stream
,
&
fd
);
if
(
ret
!=
0
)
{
mu_error
(
"stream_get_fd: %s"
,
mu_strerror
(
ret
));
exit
(
EXIT_FAILURE
);
}
write_again:
ret
=
stream_write
(
stream
,
wbuf
+
off
,
strlen
(
wbuf
),
0
,
&
nb
);
if
(
ret
!=
0
)
{
if
(
ret
==
EAGAIN
)
{
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
select
(
fd
+
1
,
NULL
,
&
fds
,
NULL
,
NULL
);
int
wflags
=
MU_STREAM_READY_WR
;
stream_wait
(
stream
,
&
wflags
,
NULL
);
off
+=
nb
;
goto
write_again
;
}
...
...
@@ -102,9 +86,8 @@ write_again:
{
if
(
ret
==
EAGAIN
)
{
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
select
(
fd
+
1
,
&
fds
,
NULL
,
NULL
,
NULL
);
int
wflags
=
MU_STREAM_READY_RD
;
stream_wait
(
stream
,
&
wflags
,
NULL
);
}
else
{
...
...
@@ -112,7 +95,7 @@ write_again:
exit
(
EXIT_FAILURE
);
}
}
write
(
2
,
rbuf
,
nb
);
write
(
1
,
rbuf
,
nb
);
}
while
(
nb
||
ret
==
EAGAIN
);
...
...
imap4d/auth_gsasl.c
View file @
6de9251
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003
, 2004
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -25,11 +25,11 @@ static Gsasl_session_ctx *sess_ctx;
static
void
auth_gsasl_capa_init
__P
((
int
disable
));
static
int
create_gsasl_stream
(
stream_t
*
newstr
,
int
fd
,
int
flags
)
create_gsasl_stream
(
stream_t
*
newstr
,
stream_t
transport
,
int
flags
)
{
int
rc
;
rc
=
gsasl_stream_create
(
newstr
,
fd
,
sess_ctx
,
flags
);
rc
=
gsasl_stream_create
(
newstr
,
transport
,
sess_ctx
,
flags
);
if
(
rc
)
{
syslog
(
LOG_ERR
,
_
(
"cannot create SASL stream: %s"
),
...
...
@@ -62,37 +62,18 @@ gsasl_replace_streams (void *self, void *data)
return
0
;
}
#define AUTHBUFSIZE 512
static
int
auth_step_base64
(
Gsasl_session_ctx
*
sess_ctx
,
char
*
input
,
char
**
output
,
size_t
*
output_len
)
static
void
finish_session
(
void
)
{
int
rc
;
while
(
1
)
{
rc
=
gsasl_server_step_base64
(
sess_ctx
,
input
,
*
output
,
*
output_len
);
if
(
rc
==
GSASL_TOO_SMALL_BUFFER
)
{
*
output_len
+=
AUTHBUFSIZE
;
*
output
=
realloc
(
*
output
,
*
output_len
);
if
(
output
)
continue
;
}
break
;
}
return
rc
;
gsasl_server_finish
(
sess_ctx
);
}
static
int
auth_gsasl
(
struct
imap4d_command
*
command
,
char
*
auth_type
,
char
*
arg
,
char
**
username
)
char
*
auth_type
,
char
*
arg
,
char
**
username
)
{
char
*
input
=
NULL
;
char
*
output
;
size_t
output_len
;
char
*
s
;
int
rc
;
...
...
@@ -109,15 +90,8 @@ auth_gsasl (struct imap4d_command *command,
gsasl_server_application_data_set
(
sess_ctx
,
username
);
output_len
=
AUTHBUFSIZE
;
output
=
malloc
(
output_len
);
if
(
!
output
)
imap4d_bye
(
ERR_NO_MEM
);
output
[
0
]
=
'\0'
;
while
((
rc
=
auth_step_base64
(
sess_ctx
,
input
,
&
output
,
&
output_len
))
==
GSASL_NEEDS_MORE
)
output
=
NULL
;
while
((
rc
=
gsasl_step64
(
sess_ctx
,
input
,
&
output
))
==
GSASL_NEEDS_MORE
)
{
util_send
(
"+ %s
\r\n
"
,
output
);
input
=
imap4d_readline_ex
();
...
...
@@ -144,18 +118,14 @@ auth_gsasl (struct imap4d_command *command,
if
(
sess_ctx
)
{
stream_t
in
,
out
,
new_in
,
new_out
;
stream_t
tmp
,
new_in
,
new_out
;
stream_t
*
s
;
int
infd
,
outfd
;
util_get_input
(
&
in
);
stream_get_fd
(
in
,
&
infd
);
util_get_output
(
&
out
);
stream_get_fd
(
out
,
&
outfd
);
if
(
create_gsasl_stream
(
&
new_in
,
infd
,
MU_STREAM_READ
))
util_get_input
(
&
tmp
);
if
(
create_gsasl_stream
(
&
new_in
,
tmp
,
MU_STREAM_READ
))
return
RESP_NO
;
if
(
create_gsasl_stream
(
&
new_out
,
outfd
,
MU_STREAM_WRITE
))
util_get_output
(
&
tmp
);
if
(
create_gsasl_stream
(
&
new_out
,
tmp
,
MU_STREAM_WRITE
))
{
stream_destroy
(
&
new_in
,
stream_get_owner
(
new_in
));
return
RESP_NO
;
...
...
@@ -166,8 +136,8 @@ auth_gsasl (struct imap4d_command *command,
s
[
1
]
=
new_out
;
util_register_event
(
STATE_NONAUTH
,
STATE_AUTH
,
gsasl_replace_streams
,
s
);
util_atexit
(
finish_session
);
}
auth_gsasl_capa_init
(
1
);
return
RESP_OK
;
...
...
@@ -180,15 +150,7 @@ auth_gsasl_capa_init (int disable)
char
*
listmech
,
*
name
,
*
s
;
size_t
size
;
rc
=
gsasl_server_listmech
(
ctx
,
NULL
,
&
size
);
if
(
rc
!=
GSASL_OK
)
return
;
listmech
=
malloc
(
size
);
if
(
!
listmech
)
imap4d_bye
(
ERR_NO_MEM
);
rc
=
gsasl_server_listmech
(
ctx
,
listmech
,
&
size
);
rc
=
gsasl_server_mechlist
(
ctx
,
&
listmech
);
if
(
rc
!=
GSASL_OK
)
return
;
...
...
@@ -300,7 +262,7 @@ void
auth_gsasl_init
()
{
int
rc
;
rc
=
gsasl_init
(
&
ctx
);
if
(
rc
!=
GSASL_OK
)
{
...
...
@@ -321,3 +283,9 @@ auth_gsasl_init ()
auth_gsasl_capa_init
(
0
);
}
wd
()
{
int
_st
=
0
;
while
(
_st
==
0
)
_st
=
_st
;
}
...
...
imap4d/idle.c
View file @
6de9251
...
...
@@ -25,7 +25,7 @@ imap4d_idle (struct imap4d_command *command, char *arg)
if
(
util_getword
(
arg
,
&
sp
))
return
util_finish
(
command
,
RESP_BAD
,
"Too many args"
);
if
(
util_wait_input
(
0
)
==
-
1
)
return
util_finish
(
command
,
RESP_NO
,
"Cannot idle"
);
...
...
imap4d/util.c
View file @
6de9251
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2002, 2003
, 2004
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -1084,16 +1084,12 @@ util_get_output (stream_t *pstr)
void
util_set_input
(
stream_t
str
)
{
if
(
istream
)
stream_destroy
(
&
istream
,
stream_get_owner
(
istream
));
istream
=
str
;
}
void
util_set_output
(
stream_t
str
)
{
if
(
ostream
)
stream_destroy
(
&
ostream
,
stream_get_owner
(
ostream
));
ostream
=
str
;
}
...
...
@@ -1104,30 +1100,20 @@ util_set_output (stream_t str)
int
util_wait_input
(
int
timeout
)
{
int
rc
,
fd
;
fd_set
rdset
;
int
wflags
=
MU_STREAM_READY_RD
;
struct
timeval
tv
;
int
status
;
if
(
stream_get_fd
(
istream
,
&
fd
))
tv
.
tv_sec
=
timeout
;
tv
.
tv_usec
=
0
;
status
=
stream_wait
(
istream
,
&
wflags
,
&
tv
);
if
(
status
)
{
errno
=
ENOSYS
;
syslog
(
LOG_ERR
,
_
(
"cannot poll input stream: %s"
),
mu_strerror
(
status
));
return
-
1
;
}
FD_ZERO
(
&
rdset
);
FD_SET
(
fd
,
&
rdset
);
do
{
struct
timeval
tv
;
tv
.
tv_sec
=
timeout
;
tv
.
tv_usec
=
0
;
rc
=
select
(
fd
+
1
,
&
rdset
,
NULL
,
NULL
,
&
tv
);
}
while
(
rc
==
-
1
&&
errno
==
EINTR
);
return
rc
;
return
wflags
&
MU_STREAM_READY_RD
;
}
void
...
...
@@ -1147,14 +1133,9 @@ int
imap4d_init_tls_server
()
{
stream_t
stream
;
int
in_fd
;
int
out_fd
;
int
rc
;
if
(
stream_get_fd
(
istream
,
&
in_fd
)
||
stream_get_fd
(
ostream
,
&
out_fd
))
return
0
;
rc
=
tls_stream_create
(
&
stream
,
in_fd
,
out_fd
,
0
);
rc
=
tls_stream_create
(
&
stream
,
istream
,
ostream
,
0
);
if
(
rc
)
return
0
;
...
...
@@ -1166,8 +1147,6 @@ imap4d_init_tls_server ()
return
0
;
}
stream_destroy
(
&
istream
,
stream_get_owner
(
istream
));
stream_destroy
(
&
ostream
,
stream_get_owner
(
ostream
));
istream
=
ostream
=
stream
;
return
1
;
}
...
...
include/mailutils/sys/pop3.h
View file @
6de9251
...
...
@@ -91,6 +91,7 @@ struct _mu_pop3
extern
int
mu_pop3_debug_cmd
(
mu_pop3_t
);
extern
int
mu_pop3_debug_ack
(
mu_pop3_t
);
extern
int
mu_pop3_stream_create
(
mu_pop3_t
pop3
,
stream_t
*
pstream
);
extern
int
mu_pop3_carrier_is_ready
(
stream_t
carrier
,
int
flag
,
int
timeout
);
/* Check for non recoverable error.
The error is consider not recoverable if not part of the signal set:
...
...
libsieve/extensions/spamd.c
View file @
6de9251
...
...
@@ -106,10 +106,10 @@ spamd_destroy (stream_t *stream)
static
void
spamd_shutdown
(
stream_t
stream
,
int
flag
)
{
int
fd
;
mu_transport_t
trans
;
stream_flush
(
stream
);
stream_get_
fd
(
stream
,
&
fd
);
shutdown
(
fd
,
flag
);
stream_get_
transport
(
stream
,
&
trans
);
shutdown
(
(
int
)
trans
,
flag
);
}
static
void
...
...
mailbox/body.c
View file @
6de9251
...
...
@@ -36,7 +36,7 @@
#define BODY_MODIFIED 0x10000
static
int
_body_flush
__P
((
stream_t
));
static
int
_body_get_
fd
__P
((
stream_t
,
int
*
,
in
t
*
));
static
int
_body_get_
transport2
__P
((
stream_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
_body_read
__P
((
stream_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
_body_readline
__P
((
stream_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
_body_truncate
__P
((
stream_t
,
off_t
));
...
...
@@ -162,7 +162,7 @@ body_get_stream (body_t body, stream_t *pstream)
status
=
stream_open
(
body
->
fstream
);
if
(
status
!=
0
)
return
status
;
stream_set_
fd
(
body
->
stream
,
_body_get_fd
,
body
);
stream_set_
get_transport2
(
body
->
stream
,
_body_get_transport2
,
body
);
stream_set_read
(
body
->
stream
,
_body_read
,
body
);
stream_set_readline
(
body
->
stream
,
_body_readline
,
body
);
stream_set_write
(
body
->
stream
,
_body_write
,
body
);
...
...
@@ -246,15 +246,10 @@ body_set_size (body_t body, int (*_size)(body_t, size_t*) , void *owner)
/* Stub function for the body stream. */
static
int
_body_get_
fd
(
stream_t
stream
,
int
*
fd
,
int
*
fd2
)
_body_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
if
(
fd2
)
return
ENOSYS
;
else
{
body_t
body
=
stream_get_owner
(
stream
);
return
stream_get_fd
(
body
->
fstream
,
fd
);
}
body_t
body
=
stream_get_owner
(
stream
);
return
stream_get_transport2
(
body
->
fstream
,
pin
,
pout
);
}
static
int
...
...
mailbox/file_stream.c
View file @
6de9251
...
...
@@ -39,6 +39,7 @@
#include <mailutils/argcv.h>
#include <mailutils/nls.h>
#include <mailutils/list.h>
#include <mailutils/mutil.h>
struct
_file_stream
{
...
...
@@ -319,22 +320,32 @@ _file_flush (stream_t stream)
return
0
;
}
int
_file_wait
(
stream_t
stream
,
int
*
pflags
,
struct
timeval
*
tvp
)
{
struct
_file_stream
*
fs
=
stream_get_owner
(
stream
);
if
(
!
fs
->
file
)
return
EINVAL
;
return
mu_fd_wait
(
fileno
(
fs
->
file
),
pflags
,
tvp
);
}
static
int
_file_get_fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
_file_get_transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
struct
_file_stream
*
fs
=
stream_get_owner
(
stream
);
int
status
=
0
;
if
(
pfd2
)
return
ENOSYS
;
if
(
pfd
)
if
(
pin
)
{
if
(
fs
->
file
)
*
p
fd
=
fileno
(
fs
->
file
)
;
*
p
in
=
(
mu_transport_t
)
fs
->
file
;
else
status
=
EINVAL
;
}
if
(
pout
)
*
pout
=
NULL
;
return
status
;
}
...
...
@@ -493,10 +504,10 @@ file_stream_create (stream_t *stream, const char* filename, int flags)
return
ENOMEM
;
if
((
fs
->
filename
=
strdup
(
filename
))
==
NULL
)
{
free
(
fs
);
return
ENOMEM
;
}
{
free
(
fs
);
return
ENOMEM
;
}
ret
=
stream_create
(
stream
,
flags
|
MU_STREAM_NO_CHECK
,
fs
);
if
(
ret
!=
0
)
...
...
@@ -508,7 +519,7 @@ file_stream_create (stream_t *stream, const char* filename, int flags)
stream_set_open
(
*
stream
,
_file_open
,
fs
);
stream_set_close
(
*
stream
,
_file_close
,
fs
);
stream_set_
fd
(
*
stream
,
_file_get_fd
,
fs
);
stream_set_
get_transport2
(
*
stream
,
_file_get_transport2
,
fs
);
stream_set_read
(
*
stream
,
_file_read
,
fs
);
stream_set_readline
(
*
stream
,
_file_readline
,
fs
);
stream_set_write
(
*
stream
,
_file_write
,
fs
);
...
...
@@ -517,6 +528,7 @@ file_stream_create (stream_t *stream, const char* filename, int flags)
stream_set_flush
(
*
stream
,
_file_flush
,
fs
);
stream_set_destroy
(
*
stream
,
_file_destroy
,
fs
);
stream_set_strerror
(
*
stream
,
_file_strerror
,
fs
);
stream_set_wait
(
*
stream
,
_file_wait
,
fs
);
return
0
;
}
...
...
@@ -572,10 +584,11 @@ stdio_stream_create (stream_t *stream, FILE *file, int flags)
stream_set_open
(
*
stream
,
NULL
,
fs
);
stream_set_close
(
*
stream
,
_file_close
,
fs
);
stream_set_
fd
(
*
stream
,
_file_get_fd
,
fs
);
stream_set_
get_transport2
(
*
stream
,
_file_get_transport2
,
fs
);
stream_set_flush
(
*
stream
,
_file_flush
,
fs
);
stream_set_destroy
(
*
stream
,
_file_destroy
,
fs
);
stream_set_wait
(
*
stream
,
_file_wait
,
fs
);
return
0
;
}
...
...
@@ -936,14 +949,14 @@ _prog_flush (stream_t stream)
}
static
int
_prog_get_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
_prog_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
int
rc
;
struct
_prog_stream
*
fs
=
stream_get_owner
(
stream
);
if
((
rc
=
stream_get_
fd
(
fs
->
in
,
pfd
))
!=
0
)
if
((
rc
=
stream_get_
transport
(
fs
->
in
,
pin
))
!=
0
)
return
rc
;
return
stream_get_
fd
(
fs
->
out
,
pfd2
);
return
stream_get_
transport
(
fs
->
out
,
pout
);
}
int
...
...
@@ -992,7 +1005,7 @@ _prog_stream_create (struct _prog_stream **pfs,
stream_set_open
(
*
stream
,
_prog_open
,
fs
);
stream_set_close
(
*
stream
,
_prog_close
,
fs
);
stream_set_
fd
(
*
stream
,
_prog_get_fd
,
fs
);
stream_set_
get_transport2
(
*
stream
,
_prog_get_transport2
,
fs
);
stream_set_flush
(
*
stream
,
_prog_flush
,
fs
);
stream_set_destroy
(
*
stream
,
_prog_destroy
,
fs
);
...
...
mailbox/filter.c
View file @
6de9251
...
...
@@ -112,15 +112,10 @@ filter_flush (stream_t stream)
}
static
int
filter_get_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
filter_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
if
(
pfd2
)
return
ENOSYS
;
else
{
filter_t
filter
=
stream_get_owner
(
stream
);
return
stream_get_fd
(
filter
->
stream
,
pfd
);
}
filter_t
filter
=
stream_get_owner
(
stream
);
return
stream_get_transport2
(
filter
->
stream
,
pin
,
pout
);
}
static
int
...
...
@@ -252,7 +247,7 @@ filter_create (stream_t *pstream, stream_t stream, const char *name,
stream_set_read
(
*
pstream
,
filter_read
,
filter
);
stream_set_readline
(
*
pstream
,
filter_readline
,
filter
);
stream_set_write
(
*
pstream
,
filter_write
,
filter
);
stream_set_
fd
(
*
pstream
,
filter_get_fd
,
filter
);
stream_set_
get_transport2
(
*
pstream
,
filter_get_transport2
,
filter
);
stream_set_truncate
(
*
pstream
,
filter_truncate
,
filter
);
stream_set_size
(
*
pstream
,
filter_size
,
filter
);
stream_set_flush
(
*
pstream
,
filter_flush
,
filter
);
...
...
mailbox/imap/mbox.c
View file @
6de9251
...
...
@@ -76,7 +76,8 @@ static int imap_copy_message __P ((mailbox_t, message_t));
static
int
imap_submessage_size
__P
((
msg_imap_t
,
size_t
*
));
static
int
imap_message_size
__P
((
message_t
,
size_t
*
));
static
int
imap_message_lines
__P
((
message_t
,
size_t
*
));
static
int
imap_message_fd
__P
((
stream_t
,
int
*
,
int
*
));
static
int
imap_message_get_transport2
__P
((
stream_t
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
));
static
int
imap_message_read
__P
((
stream_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
imap_message_uid
__P
((
message_t
,
size_t
*
));
...
...
@@ -104,11 +105,12 @@ static int imap_body_read __P ((stream_t, char *, size_t, off_t,
size_t
*
));
static
int
imap_body_size
__P
((
body_t
,
size_t
*
));
static
int
imap_body_lines
__P
((
body_t
,
size_t
*
));
static
int
imap_body_
fd
__P
((
stream_t
,
int
*
,
int
*
));
static
int
imap_body_
get_transport2
__P
((
stream_t
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
));
/* Helpers. */
static
int
imap_get_fd2
__P
((
msg_imap_t
msg_imap
,
int
*
pfd1
,
int
*
pfd2
));
static
int
imap_get_transport2
__P
((
msg_imap_t
msg_imap
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
));
static
int
imap_get_message0
__P
((
msg_imap_t
,
message_t
*
));
static
int
fetch_operation
__P
((
f_imap_t
,
msg_imap_t
,
char
*
,
size_t
,
size_t
*
));
static
void
free_subparts
__P
((
msg_imap_t
));
...
...
@@ -521,7 +523,7 @@ imap_get_message0 (msg_imap_t msg_imap, message_t *pmsg)
}
stream_setbufsiz
(
stream
,
128
);
stream_set_read
(
stream
,
imap_message_read
,
msg
);
stream_set_
fd
(
stream
,
imap_message_fd
,
msg
);
stream_set_
get_transport2
(
stream
,
imap_message_get_transport2
,
msg
);
message_set_stream
(
msg
,
stream
,
msg_imap
);
message_set_size
(
msg
,
imap_message_size
,
msg_imap
);
message_set_lines
(
msg
,
imap_message_lines
,
msg_imap
);
...
...
@@ -570,7 +572,7 @@ imap_get_message0 (msg_imap_t msg_imap, message_t *pmsg)
}
stream_setbufsiz
(
stream
,
128
);
stream_set_read
(
stream
,
imap_body_read
,
body
);
stream_set_
fd
(
stream
,
imap_body_fd
,
body
);
stream_set_
get_transport2
(
stream
,
imap_body_get_transport2
,
body
);
body_set_size
(
body
,
imap_body_size
,
msg
);
body_set_lines
(
body
,
imap_body_lines
,
msg
);
body_set_stream
(
body
,
stream
,
msg
);
...
...
@@ -1333,11 +1335,11 @@ imap_message_uid (message_t msg, size_t *puid)
}
static
int
imap_message_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
imap_message_
get_transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
message_t
msg
=
stream_get_owner
(
stream
);
msg_imap_t
msg_imap
=
message_get_owner
(
msg
);
return
imap_get_
fd2
(
msg_imap
,
pfd
,
pfd2
);
return
imap_get_
transport2
(
msg_imap
,
pin
,
pout
);
}
/* Mime. */
...
...
@@ -2005,24 +2007,25 @@ imap_body_read (stream_t stream, char *buffer, size_t buflen, off_t offset,
}
static
int
imap_body_fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
imap_body_get_transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
msg_imap_t
msg_imap
=
message_get_owner
(
msg
);
return
imap_get_
fd2
(
msg_imap
,
pfd
,
pfd2
);
return
imap_get_
transport2
(
msg_imap
,
pin
,
pout
);
}
static
int
imap_get_
fd2
(
msg_imap_t
msg_imap
,
int
*
pfd1
,
int
*
pfd2
)
imap_get_
transport2
(
msg_imap_t
msg_imap
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
if
(
msg_imap
&&
msg_imap
->
m_imap
&&
msg_imap
->
m_imap
->
f_imap
&&
msg_imap
->
m_imap
->
f_imap
->
folder
)
return
stream_get_
fd
2
(
msg_imap
->
m_imap
->
f_imap
->
folder
->
stream
,
pfd1
,
pfd2
);
return
stream_get_
transport
2
(
msg_imap
->
m_imap
->
f_imap
->
folder
->
stream
,
pin
,
pout
);
return
EINVAL
;
}
...
...
mailbox/mapfile_stream.c
View file @
6de9251
...
...
@@ -236,15 +236,15 @@ _mapfile_flush (stream_t stream)
}
static
int
_mapfile_get_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
_mapfile_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
struct
_mapfile_stream
*
mfs
=
stream_get_owner
(
stream
);
if
(
p
fd2
)
return
ENOSYS
;
if
(
p
out
)
*
pout
=
NULL
;
if
(
p
fd
)
*
p
fd
=
mfs
->
fd
;
if
(
p
in
)
*
p
in
=
mfs
->
fd
;
return
0
;
}
...
...
@@ -377,7 +377,7 @@ mapfile_stream_create (stream_t *stream, const char* filename, int flags)
stream_set_open
(
*
stream
,
_mapfile_open
,
fs
);
stream_set_close
(
*
stream
,
_mapfile_close
,
fs
);
stream_set_
fd
(
*
stream
,
_mapfile_get_fd
,
fs
);
stream_set_
get_transport2
(
*
stream
,
_mapfile_get_transport2
,
fs
);
stream_set_read
(
*
stream
,
_mapfile_read
,
fs
);
stream_set_readline
(
*
stream
,
_mapfile_readline
,
fs
);
stream_set_write
(
*
stream
,
_mapfile_write
,
fs
);
...
...
mailbox/mbox/mbox.c
View file @
6de9251
...
...
@@ -78,8 +78,8 @@ static int mbox_append_message0 __P ((mailbox_t, message_t, off_t *,
static
int
mbox_message_uid
__P
((
message_t
,
size_t
*
));
static
int
mbox_header_fill
__P
((
header_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
mbox_get_body_
fd
__P
((
stream_t
,
int
*
,
in
t
*
));
static
int
mbox_get_
fd
__P
((
mbox_message_t
,
in
t
*
));
static
int
mbox_get_body_
transport
__P
((
stream_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
mbox_get_
transport2
__P
((
mbox_message_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
mbox_get_attr_flags
__P
((
attribute_t
,
int
*
));
static
int
mbox_set_attr_flags
__P
((
attribute_t
,
int
));
static
int
mbox_unset_attr_flags
__P
((
attribute_t
,
int
));
...
...
@@ -829,27 +829,20 @@ mbox_message_uid (message_t msg, size_t *puid)
}
static
int
mbox_get_body_
fd
(
stream_t
is
,
int
*
pfd
,
int
*
pfd2
)
mbox_get_body_
transport
(
stream_t
is
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
if
(
pfd2
)
return
ENOSYS
;
else
{
body_t
body
=
stream_get_owner
(
is
);
message_t
msg
=
body_get_owner
(
body
);
mbox_message_t
mum
=
message_get_owner
(
msg
);
return
mbox_get_fd
(
mum
,
pfd
);
}
body_t
body
=
stream_get_owner
(
is
);
message_t
msg
=
body_get_owner
(
body
);
mbox_message_t
mum
=
message_get_owner
(
msg
);
return
mbox_get_transport2
(
mum
,
pin
,
pout
);
}
static
int
mbox_get_
fd
(
mbox_message_t
mum
,
int
*
pfd
)
mbox_get_
transport2
(
mbox_message_t
mum
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
int
status
;
if
(
mum
==
NULL
)
return
EINVAL
;
status
=
stream_get_fd
(
mum
->
mud
->
mailbox
->
stream
,
pfd
);
return
status
;
return
stream_get_transport2
(
mum
->
mud
->
mailbox
->
stream
,
pin
,
pout
);
}
static
int
...
...
@@ -1252,7 +1245,7 @@ mbox_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg)
}
stream_set_read
(
stream
,
mbox_body_read
,
body
);
stream_set_readline
(
stream
,
mbox_body_readline
,
body
);
stream_set_
fd
(
stream
,
mbox_get_body_fd
,
body
);
stream_set_
get_transport2
(
stream
,
mbox_get_body_transport
,
body
);
stream_set_size
(
stream
,
mbox_stream_size
,
body
);
body_set_stream
(
body
,
stream
,
msg
);
body_set_size
(
body
,
mbox_body_size
,
msg
);
...
...
mailbox/message.c
View file @
6de9251
...
...
@@ -56,7 +56,8 @@ static int message_read __P ((stream_t is, char *buf, size_t buflen,
off_t
off
,
size_t
*
pnread
));
static
int
message_write
__P
((
stream_t
os
,
const
char
*
buf
,
size_t
buflen
,
off_t
off
,
size_t
*
pnwrite
));
static
int
message_get_fd
__P
((
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
));
static
int
message_get_transport2
__P
((
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
));
static
int
message_sender
__P
((
envelope_t
envelope
,
char
*
buf
,
size_t
len
,
size_t
*
pnwrite
));
static
int
message_date
__P
((
envelope_t
envelope
,
char
*
buf
,
size_t
len
,
...
...
@@ -404,7 +405,7 @@ message_get_stream (message_t msg, stream_t *pstream)
return
status
;
stream_set_read
(
stream
,
message_read
,
msg
);
stream_set_write
(
stream
,
message_write
,
msg
);
stream_set_
fd
(
stream
,
message_get_fd
,
msg
);
stream_set_
get_transport2
(
stream
,
message_get_transport2
,
msg
);
stream_set_size
(
stream
,
message_stream_size
,
msg
);
stream_set_flags
(
stream
,
MU_STREAM_RDWR
);
msg
->
stream
=
stream
;
...
...
@@ -893,9 +894,8 @@ message_write (stream_t os, const char *buf, size_t buflen,
return
status
;
}
/* Implements the stream_get_fd () on the message stream. */
static
int
message_get_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd2
)
message_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
pin
,
mu_transport_t
*
pout
)
{
message_t
msg
=
stream_get_owner
(
stream
);
body_t
body
;
...
...
@@ -903,8 +903,8 @@ message_get_fd (stream_t stream, int *pfd, int *pfd2)
if
(
msg
==
NULL
)
return
EINVAL
;
if
(
p
fd2
)
return
ENOSYS
;
if
(
p
out
)
*
pout
=
NULL
;
/* Probably being lazy, then create a body for the stream. */
if
(
msg
->
body
==
NULL
)
...
...
@@ -918,7 +918,7 @@ message_get_fd (stream_t stream, int *pfd, int *pfd2)
body
=
msg
->
body
;
body_get_stream
(
body
,
&
is
);
return
stream_get_
fd
(
is
,
pfd
);
return
stream_get_
transport2
(
is
,
pin
,
pout
);
}
/* Implements the stream_stream_size () on the message stream. */
...
...
mailbox/mime.c
View file @
6de9251
...
...
@@ -433,17 +433,12 @@ _mimepart_body_read (stream_t stream, char *buf, size_t buflen, off_t off,
}
static
int
_mimepart_body_
fd
(
stream_t
stream
,
int
*
fd
,
int
*
fd
2
)
_mimepart_body_
transport
(
stream_t
stream
,
mu_transport_t
*
tr1
,
mu_transport_t
*
tr
2
)
{
if
(
fd2
)
return
ENOSYS
;
else
{
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
struct
_mime_part
*
mime_part
=
message_get_owner
(
msg
);
return
stream_get_fd
(
mime_part
->
mime
->
stream
,
fd
);
}
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
struct
_mime_part
*
mime_part
=
message_get_owner
(
msg
);
return
stream_get_transport2
(
mime_part
->
mime
->
stream
,
tr1
,
tr2
);
}
static
int
...
...
@@ -662,22 +657,17 @@ _mime_body_read (stream_t stream, char *buf, size_t buflen, off_t off,
}
static
int
_mime_body_
fd
(
stream_t
stream
,
int
*
fd
,
int
*
fd
2
)
_mime_body_
transport
(
stream_t
stream
,
mu_transport_t
*
tr1
,
mu_transport_t
*
tr
2
)
{
if
(
fd2
)
return
ENOSYS
;
else
{
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
mime_t
mime
=
message_get_owner
(
msg
);
stream_t
msg_stream
=
NULL
;
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
mime_t
mime
=
message_get_owner
(
msg
);
stream_t
msg_stream
=
NULL
;
if
(
mime
->
nmtp_parts
==
0
||
mime
->
cur_offset
==
0
)
return
EINVAL
;
message_get_stream
(
mime
->
mtp_parts
[
mime
->
cur_part
]
->
msg
,
&
msg_stream
);
return
stream_get_fd
(
msg_stream
,
fd
);
}
if
(
mime
->
nmtp_parts
==
0
||
mime
->
cur_offset
==
0
)
return
EINVAL
;
message_get_stream
(
mime
->
mtp_parts
[
mime
->
cur_part
]
->
msg
,
&
msg_stream
);
return
stream_get_transport2
(
msg_stream
,
tr1
,
tr2
);
}
static
int
...
...
@@ -870,7 +860,7 @@ mime_get_part (mime_t mime, size_t part, message_t * msg)
body
))
==
0
)
{
stream_set_read
(
stream
,
_mimepart_body_read
,
body
);
stream_set_
fd
(
stream
,
_mimepart_body_fd
,
body
);
stream_set_
get_transport2
(
stream
,
_mimepart_body_transport
,
body
);
body_set_stream
(
body
,
stream
,
mime_part
->
msg
);
message_set_body
(
mime_part
->
msg
,
body
,
mime_part
);
mime_part
->
body_created
=
1
;
...
...
@@ -945,7 +935,7 @@ mime_get_message (mime_t mime, message_t * msg)
==
0
)
{
stream_set_read
(
body_stream
,
_mime_body_read
,
body
);
stream_set_
fd
(
body_stream
,
_mime_body_fd
,
body
);
stream_set_
get_transport2
(
body_stream
,
_mime_body_transport
,
body
);
body_set_stream
(
body
,
body_stream
,
mime
->
msg
);
*
msg
=
mime
->
msg
;
return
0
;
...
...
mailbox/mutil.c
View file @
6de9251
...
...
@@ -50,6 +50,7 @@
#include <mailutils/message.h>
#include <mailutils/envelope.h>
#include <mailutils/nls.h>
#include <mailutils/stream.h>
#include <registrar0.h>
...
...
@@ -1177,3 +1178,41 @@ mu_scheme_autodetect_p (const char *scheme, const char **path)
return
0
;
}
int
mu_fd_wait
(
int
fd
,
int
*
pflags
,
struct
timeval
*
tvp
)
{
fd_set
rdset
,
wrset
;
int
rc
;
FD_ZERO
(
&
rdset
);
FD_ZERO
(
&
wrset
);
if
((
*
pflags
)
&
MU_STREAM_READY_RD
)
FD_SET
(
fd
,
&
rdset
);
if
((
*
pflags
)
&
MU_STREAM_READY_WR
)
FD_SET
(
fd
,
&
wrset
);
do
{
if
(
tvp
)
{
struct
timeval
tv
=
*
tvp
;
rc
=
select
(
fd
+
1
,
&
rdset
,
&
wrset
,
NULL
,
&
tv
);
}
else
rc
=
select
(
fd
+
1
,
&
rdset
,
&
wrset
,
NULL
,
NULL
);
}
while
(
rc
==
-
1
&&
errno
==
EINTR
);
if
(
rc
<
0
)
return
errno
;
*
pflags
=
0
;
if
(
rc
>
0
)
{
if
(
FD_ISSET
(
fd
,
&
rdset
))
*
pflags
|=
MU_STREAM_READY_RD
;
if
(
FD_ISSET
(
fd
,
&
wrset
))
*
pflags
|=
MU_STREAM_READY_WR
;
}
return
0
;
}
...
...
mailbox/pop/mbox.c
View file @
6de9251
...
...
@@ -130,16 +130,16 @@ int _pop_apop __P ((authority_t));
static
int
pop_get_size
__P
((
mailbox_t
,
off_t
*
));
/* We use pop_top for retreiving headers. */
/* static int pop_header_read (header_t, char *, size_t, off_t, size_t *); */
static
int
pop_body_
fd
__P
((
stream_t
,
int
*
,
in
t
*
));
static
int
pop_body_
transport
__P
((
stream_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
pop_body_size
__P
((
body_t
,
size_t
*
));
static
int
pop_body_lines
__P
((
body_t
,
size_t
*
));
static
int
pop_body_read
__P
((
stream_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
pop_message_read
__P
((
stream_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
pop_message_size
__P
((
message_t
,
size_t
*
));
static
int
pop_message_
fd
__P
((
stream_t
,
int
*
,
in
t
*
));
static
int
pop_message_
transport
__P
((
stream_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
pop_top
__P
((
header_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
pop_retr
__P
((
pop_message_t
,
char
*
,
size_t
,
off_t
,
size_t
*
));
static
int
pop_get_
fd
__P
((
pop_message_t
,
in
t
*
));
static
int
pop_get_
transport2
__P
((
pop_message_t
,
mu_transport_t
*
,
mu_transport_
t
*
));
static
int
pop_get_attribute
__P
((
attribute_t
,
int
*
));
static
int
pop_set_attribute
__P
((
attribute_t
,
int
));
static
int
pop_unset_attribute
__P
((
attribute_t
,
int
));
...
...
@@ -932,7 +932,7 @@ pop_get_message (mailbox_t mbox, size_t msgno, message_t *pmsg)
/* Help for the readline()s */
stream_setbufsiz
(
stream
,
128
);
stream_set_read
(
stream
,
pop_message_read
,
msg
);
stream_set_
fd
(
stream
,
pop_message_fd
,
msg
);
stream_set_
get_transport2
(
stream
,
pop_message_transport
,
msg
);
message_set_stream
(
msg
,
stream
,
mpm
);
message_set_size
(
msg
,
pop_message_size
,
mpm
);
}
...
...
@@ -982,7 +982,7 @@ pop_get_message (mailbox_t mbox, size_t msgno, message_t *pmsg)
/* Helps for the readline()s */
stream_setbufsiz
(
stream
,
128
);
stream_set_read
(
stream
,
pop_body_read
,
body
);
stream_set_
fd
(
stream
,
pop_body_fd
,
body
);
stream_set_
get_transport2
(
stream
,
pop_body_transport
,
body
);
body_set_size
(
body
,
pop_body_size
,
msg
);
body_set_lines
(
body
,
pop_body_lines
,
msg
);
body_set_stream
(
body
,
stream
,
msg
);
...
...
@@ -1414,39 +1414,28 @@ pop_unset_attribute (attribute_t attr, int flags)
/* Stub to call the fd from body object. */
static
int
pop_body_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd1
)
pop_body_
transport
(
stream_t
stream
,
mu_transport_t
*
ptr
,
mu_transport_t
*
ptr2
)
{
if
(
pfd1
)
return
ENOSYS
;
else
{
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
pop_message_t
mpm
=
message_get_owner
(
msg
);
return
pop_get_fd
(
mpm
,
pfd
);
}
body_t
body
=
stream_get_owner
(
stream
);
message_t
msg
=
body_get_owner
(
body
);
pop_message_t
mpm
=
message_get_owner
(
msg
);
return
pop_get_transport2
(
mpm
,
ptr
,
ptr2
);
}
/* Stub to call the fd from message object. */
static
int
pop_message_
fd
(
stream_t
stream
,
int
*
pfd
,
int
*
pfd
2
)
pop_message_
transport
(
stream_t
stream
,
mu_transport_t
*
ptr
,
mu_transport_t
*
ptr
2
)
{
if
(
pfd2
)
return
ENOSYS
;
else
{
message_t
msg
=
stream_get_owner
(
stream
);
pop_message_t
mpm
=
message_get_owner
(
msg
);
return
pop_get_fd
(
mpm
,
pfd
);
}
message_t
msg
=
stream_get_owner
(
stream
);
pop_message_t
mpm
=
message_get_owner
(
msg
);
return
pop_get_transport2
(
mpm
,
ptr
,
ptr2
);
}
/* Finally return the fd. */
static
int
pop_get_
fd
(
pop_message_t
mpm
,
int
*
pfd
)
pop_get_
transport2
(
pop_message_t
mpm
,
mu_transport_t
*
ptr
,
mu_transport_t
*
ptr2
)
{
if
(
mpm
&&
mpm
->
mpd
&&
mpm
->
mpd
->
mbox
)
return
stream_get_
fd
(
mpm
->
mpd
->
mbox
->
stream
,
pfd
);
return
stream_get_
transport2
(
mpm
->
mpd
->
mbox
->
stream
,
ptr
,
ptr2
);
return
EINVAL
;
}
...
...
mailbox/pop/pop3_readline.c
View file @
6de9251
...
...
@@ -29,28 +29,23 @@
#include <mailutils/sys/pop3.h>
#include <mailutils/error.h>
static
int
mu_pop3_carrier_is_read
_ready
(
stream_t
carrier
,
int
timeout
)
int
mu_pop3_carrier_is_read
y
(
stream_t
carrier
,
int
flag
,
int
timeout
)
{
int
fd
=
-
1
;
int
ready
=
0
;
stream_get_fd
(
carrier
,
&
fd
);
if
(
fd
>=
0
)
struct
timeval
tv
,
*
tvp
=
NULL
;
int
wflags
=
flag
;
int
status
;
if
(
timeout
>=
0
)
{
struct
timeval
tv
;
fd_set
fset
;
FD_ZERO
(
&
fset
);
FD_SET
(
fd
,
&
fset
);
tv
.
tv_sec
=
timeout
/
100
;
tv
.
tv_usec
=
(
timeout
%
1000
)
*
1000
;
ready
=
select
(
fd
+
1
,
&
fset
,
NULL
,
NULL
,
(
timeout
==
-
1
)
?
NULL
:
&
tv
);
ready
=
(
ready
==
-
1
)
?
0
:
1
;
tvp
=
&
tv
;
}
return
ready
;
status
=
stream_wait
(
carrier
,
&
wflags
,
tvp
);
if
(
status
)
return
0
;
/* FIXME: provide a way to return error code! */
return
wflags
&
flag
;
}
/* Read a complete line from the pop server. Transform CRLF to LF, remove
...
...
@@ -70,7 +65,9 @@ mu_pop3_getline (mu_pop3_t pop3)
since on linux tv is modified when error. */
if
(
pop3
->
timeout
)
{
int
ready
=
mu_pop3_carrier_is_read_ready
(
pop3
->
carrier
,
pop3
->
timeout
);
int
ready
=
mu_pop3_carrier_is_ready
(
pop3
->
carrier
,
MU_STREAM_READY_RD
,
pop3
->
timeout
);
if
(
ready
==
0
)
return
ETIMEDOUT
;
}
...
...
mailbox/pop/pop3_sendline.c
View file @
6de9251
...
...
@@ -31,8 +31,6 @@
#include <errno.h>
#include <mailutils/sys/pop3.h>
static
int
mu_pop3_carrier_is_write_ready
(
stream_t
carrier
,
int
timeout
);
/* A socket may write less then expected but stream.c:stream_write() will
always try to send the entire buffer unless an error is reported. We have
to cope with nonblocking, it is done by keeping track with the pop3->ptr
...
...
@@ -50,7 +48,9 @@ mu_pop3_send (mu_pop3_t pop3)
since on linux tv is modified when error. */
if
(
pop3
->
timeout
)
{
int
ready
=
mu_pop3_carrier_is_write_ready
(
pop3
->
carrier
,
pop3
->
timeout
);
int
ready
=
mu_pop3_carrier_is_ready
(
pop3
->
carrier
,
MU_STREAM_READY_RD
,
pop3
->
timeout
);
if
(
ready
==
0
)
return
ETIMEDOUT
;
}
...
...
@@ -119,28 +119,3 @@ mu_pop3_sendline (mu_pop3_t pop3, const char *line)
return
mu_pop3_send
(
pop3
);
}
static
int
mu_pop3_carrier_is_write_ready
(
stream_t
carrier
,
int
timeout
)
{
int
fd
=
-
1
;
int
ready
=
0
;
stream_get_fd
(
carrier
,
&
fd
);
if
(
fd
>=
0
)
{
struct
timeval
tv
;
fd_set
fset
;
FD_ZERO
(
&
fset
);
FD_SET
(
fd
,
&
fset
);
tv
.
tv_sec
=
timeout
/
100
;
tv
.
tv_usec
=
(
timeout
%
1000
)
*
1000
;
ready
=
select
(
fd
+
1
,
NULL
,
&
fset
,
NULL
,
(
timeout
==
-
1
)
?
NULL
:
&
tv
);
ready
=
(
ready
==
-
1
)
?
0
:
1
;
}
return
ready
;
}
...
...
mailbox/tcp.c
View file @
6de9251
...
...
@@ -37,6 +37,7 @@
#include <mailutils/errno.h>
#include <mailutils/stream.h>
#include <mailutils/mutil.h>
#define TCP_STATE_INIT 1
#define TCP_STATE_RESOLVE 2
...
...
@@ -150,18 +151,17 @@ _tcp_open (stream_t stream)
static
int
_tcp_get_
fd
(
stream_t
stream
,
int
*
fd
,
int
*
fd
2
)
_tcp_get_
transport2
(
stream_t
stream
,
mu_transport_t
*
tr
,
mu_transport_t
*
tr
2
)
{
struct
_tcp_instance
*
tcp
=
stream_get_owner
(
stream
);
if
(
fd
==
NULL
)
return
MU_ERR_OUT_PTR_NULL
;
if
(
tcp
->
fd
==
-
1
)
return
EINVAL
;
if
(
fd2
)
return
ENOSYS
;
*
fd
=
tcp
->
fd
;
if
(
tr
)
*
tr
=
(
mu_transport_t
)
tcp
->
fd
;
if
(
tr2
)
*
tr2
=
NULL
;
return
0
;
}
...
...
@@ -218,6 +218,15 @@ _tcp_destroy (stream_t stream)
}
int
_tcp_wait
(
stream_t
stream
,
int
*
pflags
,
struct
timeval
*
tvp
)
{
struct
_tcp_instance
*
tcp
=
stream_get_owner
(
stream
);
if
(
tcp
->
fd
==
-
1
)
return
EINVAL
;
return
mu_fd_wait
(
tcp
->
fd
,
pflags
,
tvp
);
}
int
tcp_stream_create
(
stream_t
*
stream
,
const
char
*
host
,
int
port
,
int
flags
)
{
struct
_tcp_instance
*
tcp
;
...
...
@@ -254,8 +263,9 @@ tcp_stream_create (stream_t * stream, const char* host, int port, int flags)
stream_set_close
(
*
stream
,
_tcp_close
,
tcp
);
stream_set_read
(
*
stream
,
_tcp_read
,
tcp
);
stream_set_write
(
*
stream
,
_tcp_write
,
tcp
);
stream_set_
fd
(
*
stream
,
_tcp_get_fd
,
tcp
);
stream_set_
get_transport2
(
*
stream
,
_tcp_get_transport2
,
tcp
);
stream_set_destroy
(
*
stream
,
_tcp_destroy
,
tcp
);
stream_set_wait
(
*
stream
,
_tcp_wait
,
tcp
);
return
0
;
}
...
...
mh/mhn.c
View file @
6de9251
...
...
@@ -1366,11 +1366,13 @@ show_handler (message_t msg, msg_part_t part, char *type, char *encoding,
int
fd
=
1
;
char
*
tempfile
=
NULL
;
int
ismime
;
mu_transport_t
trans
;
if
(
message_is_multipart
(
msg
,
&
ismime
)
==
0
&&
ismime
)
return
0
;
stream_get_fd
(
out
,
&
fd
);
stream_get_transport
(
out
,
&
trans
);
fd
=
trans
;
if
(
mode_options
&
OPT_PAUSE
)
flags
|=
MHN_CONFIRM
;
...
...
Please
register
or
sign in
to post a comment