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
e63412d7
...
e63412d72863c077b519e4df0b7627beefe0e2ed
authored
2000-07-04 02:38:06 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
file_stream.c mbx_unix.c mbx_unixscan.c include/public/io.h
1 parent
5059666f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
5 deletions
mailbox/file_stream.c
mailbox/include/public/io.h
mailbox/mbx_unix.c
mailbox/mbx_unixscan.c
mailbox/file_stream.c
View file @
e63412d
...
...
@@ -136,7 +136,7 @@ static int
_file_truncate
(
stream_t
stream
,
off_t
len
)
{
struct
_file_stream
*
fs
=
stream
->
owner
;
if
(
ftruncate
(
fileno
(
fs
->
file
),
len
)
==
-
1
)
if
(
ftruncate
(
fileno
(
fs
->
file
),
len
)
!=
0
)
return
errno
;
return
0
;
}
...
...
@@ -146,6 +146,7 @@ _file_size (stream_t stream, off_t *psize)
{
struct
_file_stream
*
fs
=
stream
->
owner
;
struct
stat
stbuf
;
fflush
(
fs
->
file
);
if
(
fstat
(
fileno
(
fs
->
file
),
&
stbuf
)
==
-
1
)
return
errno
;
if
(
psize
)
...
...
@@ -170,6 +171,16 @@ _file_get_fd (stream_t stream, int *pfd)
}
static
int
_file_close
(
stream_t
stream
)
{
struct
_file_stream
*
fs
=
stream
->
owner
;
if
(
fs
->
file
)
if
(
fclose
(
fs
->
file
)
!=
0
)
return
errno
;
return
0
;
}
static
int
_file_open
(
stream_t
stream
,
const
char
*
filename
,
int
port
,
int
flags
)
{
struct
_file_stream
*
fs
=
stream
->
owner
;
...
...
@@ -288,12 +299,12 @@ file_stream_create (stream_t *stream)
ret
=
stream_create
(
stream
,
MU_STREAM_NO_CHECK
,
fs
);
if
(
ret
!=
0
)
{
fclose
(
fs
->
file
);
free
(
fs
);
return
ret
;
}
stream_set_open
(
*
stream
,
_file_open
,
fs
);
stream_set_close
(
*
stream
,
_file_close
,
fs
);
stream_set_fd
(
*
stream
,
_file_get_fd
,
fs
);
stream_set_read
(
*
stream
,
_file_read
,
fs
);
stream_set_readline
(
*
stream
,
_file_readline
,
fs
);
...
...
mailbox/include/public/io.h
View file @
e63412d
...
...
@@ -101,6 +101,7 @@ extern int stream_set_flags __P ((stream_t, int flags, void *owner));
/* misc */
extern
int
file_stream_create
__P
((
stream_t
*
stream
));
extern
int
mapfile_stream_create
__P
((
stream_t
*
stream
));
extern
int
encoder_stream_create
__P
((
stream_t
*
stream
,
stream_t
iostream
,
const
char
*
encoding
));
extern
int
decoder_stream_create
__P
((
stream_t
*
stream
,
stream_t
iostream
,
...
...
mailbox/mbx_unix.c
View file @
e63412d
...
...
@@ -346,7 +346,7 @@ static int
mailbox_unix_open
(
mailbox_t
mbox
,
int
flags
)
{
mailbox_unix_data_t
mud
;
int
status
;
int
status
=
0
;
if
(
mbox
==
NULL
||
(
mud
=
(
mailbox_unix_data_t
)
mbox
->
data
)
==
NULL
)
...
...
@@ -359,6 +359,13 @@ mailbox_unix_open (mailbox_t mbox, int flags)
/* get a stream */
if
(
mbox
->
stream
==
NULL
)
{
/* FIXME: for small mbox we shout try to mmap() */
status
=
(
flags
&
MU_STREAM_CREAT
)
||
(
flags
&
MU_STREAM_APPEND
);
if
(
status
==
0
)
status
=
mapfile_stream_create
(
&
(
mbox
->
stream
));
if
(
status
!=
0
)
{
status
=
file_stream_create
(
&
(
mbox
->
stream
));
if
(
status
!=
0
)
return
status
;
...
...
@@ -369,6 +376,16 @@ mailbox_unix_open (mailbox_t mbox, int flags)
stream_destroy
(
&
(
mbox
->
stream
),
mbox
);
return
status
;
}
}
else
{
status
=
stream_open
(
mbox
->
stream
,
mbox
->
name
,
0
,
flags
);
if
(
status
!=
0
)
{
stream_destroy
(
&
(
mbox
->
stream
),
mbox
);
return
status
;
}
}
/* Authentication */
if
(
mbox
->
auth
)
...
...
@@ -765,10 +782,10 @@ mailbox_unix_expunge (mailbox_t mbox)
clearerr
(
tempfile
);
/* flush/truncation */
stream_flush
(
mbox
->
stream
);
status
=
stream_truncate
(
mbox
->
stream
,
total
);
if
(
status
!=
0
)
goto
bailout
;
stream_flush
(
mbox
->
stream
);
/* Don't remove the tmp mbox in case of errors */
remove
(
tmpmbox
);
...
...
mailbox/mbx_unixscan.c
View file @
e63412d
...
...
@@ -344,7 +344,6 @@ mailbox_unix_scan0 (mailbox_t mbox, size_t msgno, size_t *pcount, int do_notif)
total
,
&
n
))
==
0
&&
n
!=
0
)
{
int
nl
;
STRLEN
(
buf
,
n
);
total
+=
n
;
nl
=
(
*
buf
==
'\n'
)
?
1
:
0
;
...
...
Please
register
or
sign in
to post a comment