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
1a3b2274
...
1a3b2274e8cb2a947d44e996e647556880bec5a6
authored
1999-11-06 08:52:03 +0000
by
Sean 'Shaleh' Perry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
began work on expunge
stopped an invalid pointer use in mail.C
1 parent
6b7fda6a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
23 deletions
ChangeLog
TODO
libmailbox/unixmbox.c
libmailbox/unixmbox.h
mail/mail.c
ChangeLog
View file @
1a3b227
1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org>
* libmailbox/unixmbox.*: work on expunge
use read/write along with lseek
still blows up -- getting there
* mail/mail.c: check return value of mbox_open()
1999-10-23 Alain Magloire
* ChangeLog: Cleanup according to GNU std, and remove
...
...
TODO
View file @
1a3b227
...
...
@@ -5,14 +5,13 @@
* autogen.sh (libtool) complains about libmailbox.la in noinst (JB Oct 08/99)
+ libmailbox has a nasty bug -- if the mailbox is empty, the library has no idea
what to do (Shaleh Oct 07/99)
- added more includes to libmailbox, make sure autoconf finds them
- libmailbox needs an interface to set flags for each message
- libmailbox needs an interface to set and create values in the header
+ crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99)
- clean up 'mail''s compilation
- find out why the pop3 server quits on a signal when the 'quit' command is
given
...
...
@@ -21,10 +20,16 @@
- test network code
+ add imap server code (JB && Shaleh Oct 11/99)
- add more features
- optimize everything
- test everything
+ libmailbox has a nasty bug -- if the mailbox is empty, the library has no idea
what to do (Shaleh Oct 07/99)
+ crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99)
+ add imap server code (JB && Shaleh Oct 11/99)
...
...
libmailbox/unixmbox.c
View file @
1a3b227
...
...
@@ -233,37 +233,59 @@ int
unixmbox_expunge
(
mailbox
*
mbox
)
{
unixmbox_data
*
data
;
int
i
=
0
,
size
=
0
;
int
i
=
0
;
ssize_t
size
=
0
,
size_read
=
0
;
char
*
buf
=
NULL
;
fpos_t
lastpos
;
int
file
;
int
deletion_needed
=
0
;
/* true when a deleted message has been found */
size_t
buff_size
=
0
;
size_t
tmp
=
0
;
if
(
mbox
==
NULL
)
{
errno
=
EINVAL
;
return
-
1
;
}
data
=
mbox
->
_data
;
data
->
file
=
freopen
(
mbox
->
name
,
"r+"
,
data
->
file
);
if
(
data
->
file
==
NULL
)
{
/* error handling */
}
fgetpos
(
data
->
file
,
&
lastpos
);
if
(
mbox
->
num_deleted
)
{
data
=
mbox
->
_data
;
fclose
(
data
->
file
);
/* error handling */
data
->
file
=
NULL
;
file
=
open
(
mbox
->
name
,
O_RDWR
);
/* error handling */
for
(
i
=
0
;
i
<
mbox
->
messages
;
i
++
)
{
if
(
data
->
messages
[
i
].
deleted
==
0
)
{
fgetpos
(
data
->
file
,
&
lastpos
);
fsetpos
(
data
->
file
,
&
(
data
->
messages
[
i
].
header
));
read
(
fileno
(
data
->
file
),
buf
,
data
->
messages
[
i
+
1
].
header
-
data
->
messages
[
i
].
header
);
fprintf
(
data
->
file
,
"%s"
,
buf
);
size
+=
strlen
(
buf
);
free
(
buf
);
if
(
deletion_needed
)
{
tmp
=
data
->
messages
[
i
+
1
].
header
-
data
->
messages
[
i
].
header
;
if
(
tmp
>
buff_size
)
{
buff_size
=
tmp
;
buf
=
realloc
(
buf
,
tmp
);
/* error checking */
}
lseek
(
file
,
data
->
messages
[
i
].
header
,
SEEK_SET
);
size_read
=
read
(
file
,
buf
,
tmp
);
/* error checking */
lseek
(
file
,
size
,
SEEK_SET
);
write
(
file
,
buf
,
size_read
);
/* error checking */
size
+=
size_read
;
}
}
else
{
deletion_needed
=
1
;
}
}
ftruncate
(
fileno
(
data
->
file
),
size
);
close
(
file
);
truncate
(
mbox
->
name
,
size
);
free
(
buf
);
}
return
0
;
}
...
...
@@ -280,6 +302,8 @@ unixmbox_is_deleted (mailbox * mbox, unsigned int num)
errno
=
EINVAL
;
return
-
1
;
}
if
(
mbox
->
num_deleted
==
0
)
return
0
;
data
=
mbox
->
_data
;
return
(
data
->
messages
[
num
].
deleted
==
1
);
}
...
...
libmailbox/unixmbox.h
View file @
1a3b227
...
...
@@ -42,6 +42,10 @@
#include <strings.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
typedef
struct
_unixmbox_message
{
off_t
header
;
...
...
mail/mail.c
View file @
1a3b227
...
...
@@ -19,6 +19,7 @@
#include <config.h>
#endif
#include <errno.h>
#include <mailbox.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -86,6 +87,11 @@ Report bugs to <bug-mailutils@gnu.org>.\n");
}
mbox
=
mbox_open
(
mboxname
);
if
(
mbox
==
NULL
)
{
fprintf
(
stderr
,
"Ack, %s, reading %s
\n
"
,
strerror
(
errno
),
mboxname
);
exit
(
1
);
}
printf
(
"Number of messages: %d
\n
"
,
mbox
->
messages
);
while
(
1
)
{
...
...
Please
register
or
sign in
to post a comment