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
150e71a6
...
150e71a689dab8ba9b7f9c0f85e659becba1a0a3
authored
2003-02-08 15:57:24 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(open_source): Removed in favor of mh_open_msg_file().
1 parent
35ae733d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
87 deletions
mh/refile.c
mh/refile.c
View file @
150e71a
...
...
@@ -198,92 +198,6 @@ refile (mailbox_t mbox, message_t msg, size_t num, void *data)
}
}
mailbox_t
open_source
(
char
*
file_name
)
{
struct
stat
st
;
char
*
buffer
;
int
fd
;
size_t
len
=
0
;
mailbox_t
tmp
;
stream_t
stream
;
char
*
p
;
if
(
stat
(
file_name
,
&
st
)
<
0
)
{
mh_error
(
_
(
"can't stat file %s: %s"
),
file_name
,
strerror
(
errno
));
return
NULL
;
}
buffer
=
xmalloc
(
st
.
st_size
+
1
);
fd
=
open
(
file_name
,
O_RDONLY
);
if
(
fd
==
-
1
)
{
mh_error
(
_
(
"can't open file %s: %s"
),
file_name
,
strerror
(
errno
));
return
NULL
;
}
if
(
read
(
fd
,
buffer
,
st
.
st_size
)
!=
st
.
st_size
)
{
mh_error
(
_
(
"error reading file %s: %s"
),
file_name
,
strerror
(
errno
));
return
NULL
;
}
buffer
[
st
.
st_size
]
=
0
;
close
(
fd
);
if
(
mailbox_create
(
&
tmp
,
"/dev/null"
)
||
mailbox_open
(
tmp
,
MU_STREAM_READ
)
!=
0
)
{
mh_error
(
_
(
"can't create temporary mailbox"
));
return
NULL
;
}
if
(
memory_stream_create
(
&
stream
,
0
,
MU_STREAM_RDWR
)
||
stream_open
(
stream
))
{
mailbox_close
(
tmp
);
mh_error
(
_
(
"can't create temporary stream"
));
return
NULL
;
}
for
(
p
=
buffer
;
*
p
&&
isspace
(
*
p
);
p
++
)
;
if
(
strncmp
(
p
,
"From "
,
5
))
{
struct
tm
*
tm
;
time_t
t
;
char
date
[
80
];
time
(
&
t
);
tm
=
gmtime
(
&
t
);
strftime
(
date
,
sizeof
(
date
),
"From GNU-MH-refile %a %b %e %H:%M:%S %Y%n"
,
tm
);
stream_write
(
stream
,
date
,
strlen
(
date
),
0
,
&
len
);
}
stream_write
(
stream
,
p
,
strlen
(
p
),
len
,
&
len
);
mailbox_set_stream
(
tmp
,
stream
);
if
(
mailbox_messages_count
(
tmp
,
&
len
)
||
len
<
1
)
{
mh_error
(
_
(
"input file %s is not a valid message file"
),
file_name
);
return
NULL
;
}
else
if
(
len
>
1
)
{
mh_error
(
ngettext
(
"input file %s contains %lu message"
,
"input file %s contains %lu messages"
,
len
),
(
unsigned
long
)
len
);
return
NULL
;
}
free
(
buffer
);
return
tmp
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -305,7 +219,7 @@ main (int argc, char **argv)
mh_error
(
_
(
"both message set and source file given"
));
exit
(
1
);
}
mbox
=
open_sourc
e
(
source_file
);
mbox
=
mh_open_msg_fil
e
(
source_file
);
mh_msgset_parse
(
mbox
,
&
msgset
,
0
,
NULL
,
"first"
);
}
else
...
...
Please
register
or
sign in
to post a comment