1 # Functions for reading and writing autoreply files
3 # read_autoreply(file, &simple)
4 # Fills in the autoreply parts of a simple alias structure from a file
7 local ($file, $simple) = @_;
11 if (/^Reply-Tracking:\s*(.*)/) {
12 $simple->{'replies'} = $1;
14 elsif (/^Reply-Period:\s*(.*)/) {
15 $simple->{'period'} = $1;
17 elsif (/^No-Autoreply:\s*(.*)/) {
18 $simple->{'no_autoreply'} = $1;
20 elsif (/^No-Autoreply-Regexp:\s*(.*)/) {
21 push(@{$simple->{'no_autoreply_regexp'}}, $1);
23 elsif (/^Autoreply-File:\s*(.*)/) {
24 push(@{$simple->{'autoreply_file'}}, $1);
26 elsif (/^Autoreply-Start:\s*(\d+)/) {
27 $simple->{'autoreply_start'} = $1;
29 elsif (/^Autoreply-End:\s*(\d+)/) {
30 $simple->{'autoreply_end'} = $1;
32 elsif (/^From:\s*(.*)/) {
33 $simple->{'from'} = $1;
35 elsif (/^Charset:\s*(\S+)/) {
36 $simple->{'charset'} = $1;
43 $simple->{'autotext'} = join("", @lines);
46 # write_autoreply(&file, &simple)
47 # Writes the autoreply parts of a simple alias structure to a file
50 local ($file, $simple) = @_;
51 &open_tempfile(AUTO, ">$file");
52 if ($simple->{'replies'}) {
54 "Reply-Tracking: $simple->{'replies'}\n");
56 if ($simple->{'period'}) {
58 "Reply-Period: $simple->{'period'}\n");
60 if ($simple->{'no_autoreply'}) {
62 "No-Autoreply: $simple->{'no_autoreply'}\n");
64 foreach my $r (@{$simple->{'no_autoreply_regexp'}}) {
65 &print_tempfile(AUTO, "No-Autoreply-Regexp: $r\n");
67 foreach my $f (@{$simple->{'autoreply_file'}}) {
68 &print_tempfile(AUTO, "Autoreply-File: $f\n");
70 if ($simple->{'autoreply_start'}) {
72 "Autoreply-Start: $simple->{'autoreply_start'}\n");
74 if ($simple->{'autoreply_end'}) {
76 "Autoreply-End: $simple->{'autoreply_end'}\n");
78 if ($simple->{'from'}) {
79 &print_tempfile(AUTO, "From: $simple->{'from'}\n");
81 if ($simple->{'charset'}) {
82 &print_tempfile(AUTO, "Charset: $simple->{'charset'}\n");
84 &print_tempfile(AUTO, $simple->{'autotext'});
85 &close_tempfile(AUTO);