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
1aa9ef09
...
1aa9ef0957ab1eb11d2574e49767c8846fa7406c
authored
2001-08-04 14:33:37 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fixed handling of default mailbox in the absence of other mailbox arguments.
1 parent
b8615cc0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
36 deletions
guimb/collect.c
guimb/main.c
guimb/collect.c
View file @
1aa9ef0
...
...
@@ -28,7 +28,24 @@ char *temp_filename;
FILE
*
temp_file
;
mailbox_t
mbox
;
/* Open temporary file for collecting incoming message */
void
collect_open_default
()
{
size_t
nmesg
;
if
(
mailbox_create
(
&
mbox
,
default_mailbox
)
!=
0
||
mailbox_open
(
mbox
,
MU_STREAM_RDWR
)
!=
0
)
{
util_error
(
"can't open default mailbox %s: %s"
,
default_mailbox
,
strerror
(
errno
));
exit
(
1
);
}
/* Suck in the messages */
mailbox_messages_count
(
mbox
,
&
nmesg
);
}
/* Open temporary file for collecting incoming messages */
void
collect_open_mailbox_file
()
{
...
...
@@ -84,6 +101,9 @@ collect_create_mailbox ()
size_t
count
;
size_t
nmesg
;
if
(
!
temp_file
)
return
;
fclose
(
temp_file
);
if
(
mailbox_create
(
&
mbox
,
temp_filename
)
!=
0
...
...
@@ -111,33 +131,34 @@ collect_output ()
size_t
i
,
count
=
0
;
mailbox_t
outbox
=
NULL
;
int
saved_umask
;
if
(
!
output_mailbox
)
if
(
!
temp_filename
)
{
mailbox_expunge
(
mbox
);
return
0
;
}
if
(
!
default_mailbox
)
{
if
(
!
user_name
)
return
0
;
asprintf
(
&
outpu
t_mailbox
,
"%s/%s"
,
_PATH_MAILDIR
,
user_name
);
if
(
!
outpu
t_mailbox
)
asprintf
(
&
defaul
t_mailbox
,
"%s/%s"
,
_PATH_MAILDIR
,
user_name
);
if
(
!
defaul
t_mailbox
)
{
fprintf
(
stderr
,
"guimb: not enough memory
\n
"
);
return
1
;
}
}
if
(
store_mailbox
)
unlink
(
output_mailbox
);
if
(
user_name
)
{
saved_umask
=
umask
(
077
);
}
saved_umask
=
umask
(
077
);
if
(
mailbox_create_default
(
&
outbox
,
outpu
t_mailbox
)
!=
0
if
(
mailbox_create_default
(
&
outbox
,
defaul
t_mailbox
)
!=
0
||
mailbox_open
(
outbox
,
MU_STREAM_RDWR
|
MU_STREAM_CREAT
)
!=
0
)
{
mailbox_destroy
(
&
outbox
);
fprintf
(
stderr
,
"guimb: can't open output mailbox %s: %s
\n
"
,
outpu
t_mailbox
,
strerror
(
errno
));
defaul
t_mailbox
,
strerror
(
errno
));
return
1
;
}
...
...
@@ -171,6 +192,9 @@ collect_drop_mailbox ()
{
mailbox_close
(
mbox
);
mailbox_destroy
(
&
mbox
);
unlink
(
temp_filename
);
free
(
temp_filename
);
if
(
temp_filename
)
{
unlink
(
temp_filename
);
free
(
temp_filename
);
}
}
...
...
guimb/main.c
View file @
1aa9ef0
...
...
@@ -35,8 +35,7 @@ char *program_file;
char
*
program_expr
;
int
debug_guile
;
char
*
user_name
;
char
*
output_mailbox
;
int
store_mailbox
;
char
*
default_mailbox
;
static
void
usage
(
void
);
static
int
g_size
;
...
...
@@ -87,8 +86,7 @@ main (int argc, char *argv[])
usage
();
exit
(
0
);
case
'm'
:
output_mailbox
=
optarg
;
store_mailbox
=
1
;
default_mailbox
=
optarg
;
break
;
case
'u'
:
user_name
=
optarg
;
...
...
@@ -133,23 +131,26 @@ main (int argc, char *argv[])
list_append
(
lst
,
smtp_record
);
}
collect_open_mailbox_file
();
if
(
store_mailbox
&&
!
argv
[
optind
])
if
(
default_mailbox
&&
!
argv
[
optind
])
{
append_arg
(
outpu
t_mailbox
);
collect_
append_file
(
output_mailbox
);
append_arg
(
defaul
t_mailbox
);
collect_
open_default
(
);
}
if
(
argv
[
optind
])
else
{
for
(;
argv
[
optind
];
optind
++
)
collect_open_mailbox_file
();
if
(
argv
[
optind
])
{
append_arg
(
argv
[
optind
]);
collect_append_file
(
argv
[
optind
]);
for
(;
argv
[
optind
];
optind
++
)
{
append_arg
(
argv
[
optind
]);
collect_append_file
(
argv
[
optind
]);
}
}
else
collect_append_file
(
"-"
);
}
else
if
(
!
store_mailbox
)
collect_append_file
(
"-"
);
append_arg
(
NULL
);
g_argc
--
;
...
...
@@ -175,12 +176,11 @@ static char usage_str[] =
"Any arguments between -{ and -} are passed to the Scheme program verbatim.
\n
"
"When both --file and --expression are specified, file is evaluated first.
\n
"
"If no mailboxes are specified, the standard input is read.
\n\n
"
"The semantics of the default mailbox differs depending on whether
\n
"
"more mailbox arguments are specified in the command line. If they
\n
"
"are, any messages that are not deleted after executing the script
\n
"
"are appended to the default mailbox. Otherwise its contents is read,
\n
"
"processed and *replaced* by messages that remain undeleted after
\n
"
"executing the script.
\n
"
;
"The semantics of the default mailbox depends on whether more mailbox
\n
"
"arguments are specified in the command line. If they are, any messages
\n
"
"that are not deleted after executing the script are appended to the default
\n
"
"mailbox. Otherwise its contents is read, processed and *replaced* by
\n
"
"messages that remain undeleted after executing the script.
\n
"
;
void
usage
()
...
...
Please
register
or
sign in
to post a comment