| 1 | # Copyrights 2002-2023 by [Mark Overmeer]. | ||
| 2 | # For other contributors see ChangeLog. | ||
| 3 | # See the manual pages for details on the licensing terms. | ||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||
| 5 | # This code is part of distribution Mail-Box-Parser-C. Meta-POD processed | ||
| 6 | # with OODoc into POD and HTML manual-pages. See README.md | ||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||
| 8 | |||
| 9 | package Mail::Box::Parser::C; | ||
| 10 | use vars '$VERSION'; | ||
| 11 | $VERSION = '3.011'; | ||
| 12 | |||
| 13 | use base qw/Mail::Box::Parser Exporter DynaLoader/; | ||
| 14 | |||
| 15 | our $VERSION = '3.011'; | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | use warnings; | ||
| 19 | |||
| 20 | use Carp; | ||
| 21 | |||
| 22 | |||
| 23 | use Mail::Message::Field; | ||
| 24 | |||
| 25 | our %EXPORT_TAGS = | ||
| 26 | ( field => [ qw( ) ] | ||
| 27 | , head => [ qw( ) ] | ||
| 28 | , body => [ qw( ) ] | ||
| 29 | ); | ||
| 30 | |||
| 31 | |||
| 32 | our @EXPORT_OK = @{$EXPORT_TAGS{field}}; | ||
| 33 | |||
| 34 | bootstrap Mail::Box::Parser::C $VERSION; | ||
| 35 | |||
| 36 | ## Defined in the library | ||
| 37 | sub open_filename($$$); | ||
| 38 | sub open_filehandle($$$); | ||
| 39 | sub get_filehandle($); | ||
| 40 | sub close_file($); | ||
| 41 | sub push_separator($$); | ||
| 42 | sub pop_separator($); | ||
| 43 | sub get_position($); | ||
| 44 | sub set_position($$); | ||
| 45 | sub read_header($); | ||
| 46 | sub fold_header_line($$); | ||
| 47 | sub in_dosmode($); | ||
| 48 | sub read_separator($); | ||
| 49 | sub body_as_string($$$); | ||
| 50 | sub body_as_list($$$); | ||
| 51 | sub body_as_file($$$$); | ||
| 52 | sub body_delayed($$$); | ||
| 53 | |||
| 54 | # Not used yet. | ||
| 55 | #fold_header_line(char *original, int wrap) | ||
| 56 | #in_dosmode(int boxnr) | ||
| 57 | |||
| 58 | |||
| 59 | sub pushSeparator($) | ||
| 60 | { my ($self, $sep) = @_; | ||
| 61 | push_separator $self->{MBPC_boxnr}, $sep; | ||
| 62 | } | ||
| 63 | |||
| 64 | sub popSeparator() { pop_separator shift->{MBPC_boxnr} } | ||
| 65 | |||
| 66 | sub filePosition(;$) | ||
| 67 | { my $boxnr = shift->{MBPC_boxnr}; | ||
| 68 | @_ ? set_position($boxnr, shift) : get_position($boxnr); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub readHeader() { read_header shift->{MBPC_boxnr} } | ||
| 72 | |||
| 73 | sub readSeparator() { read_separator shift->{MBPC_boxnr} } | ||
| 74 | |||
| 75 | sub bodyAsString(;$$) | ||
| 76 | { my ($self, $exp_chars, $exp_lines) = @_; | ||
| 77 | $exp_chars = -1 unless defined $exp_chars; | ||
| 78 | $exp_lines = -1 unless defined $exp_lines; | ||
| 79 | body_as_string $self->{MBPC_boxnr}, $exp_chars, $exp_lines; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub bodyAsList(;$$) | ||
| 83 | { my ($self, $exp_chars, $exp_lines) = @_; | ||
| 84 | $exp_chars = -1 unless defined $exp_chars; | ||
| 85 | $exp_lines = -1 unless defined $exp_lines; | ||
| 86 | body_as_list $self->{MBPC_boxnr}, $exp_chars, $exp_lines; | ||
| 87 | } | ||
| 88 | |||
| 89 | sub bodyAsFile($;$$) | ||
| 90 | { my ($self, $file, $exp_chars, $exp_lines) = @_; | ||
| 91 | $exp_chars = -1 unless defined $exp_chars; | ||
| 92 | $exp_lines = -1 unless defined $exp_lines; | ||
| 93 | body_as_file $self->{MBPC_boxnr}, $file, $exp_chars, $exp_lines; | ||
| 94 | } | ||
| 95 | |||
| 96 | #------------------------------------------ | ||
| 97 | |||
| 98 | |||
| 99 | sub bodyDelayed(;$$) | ||
| 100 | { my ($self, $exp_chars, $exp_lines) = @_; | ||
| 101 | $exp_chars = -1 unless defined $exp_chars; | ||
| 102 | $exp_lines = -1 unless defined $exp_lines; | ||
| 103 | body_delayed $self->{MBPC_boxnr}, $exp_chars, $exp_lines; | ||
| 104 | } | ||
| 105 | |||
| 106 | sub openFile($) | ||
| 107 | { my ($self, $args) = @_; | ||
| 108 | my $boxnr; | ||
| 109 | my %log = $self->logSettings; | ||
| 110 | |||
| 111 | if(my $file = $args->{file}) | ||
| 112 | { my $name = $args->{filename} || "$file"; | ||
| 113 | $boxnr = open_filehandle($file, $name, $log{trace}); | ||
| 114 | } | ||
| 115 | else | ||
| 116 | { $boxnr = open_filename($args->{filename}, $args->{mode}, $log{trace}); | ||
| 117 | } | ||
| 118 | |||
| 119 | $self->{MBPC_boxnr} = $boxnr; | ||
| 120 | defined $boxnr ? $self : undef; | ||
| 121 | } | ||
| 122 | |||
| 123 | sub closeFile() { | ||
| 124 | my $boxnr = delete shift->{MBPC_boxnr}; | ||
| 125 | return unless defined $boxnr; | ||
| 126 | close_file $boxnr; | ||
| 127 | } | ||
| 128 | |||
| 129 | 1; | ||
| 130 |