From d6ad6e2db2ac879b46571d2fc2c16841ec19dfc6 Mon Sep 17 00:00:00 2001 From: nwf Date: Sun, 3 May 2009 01:17:08 -0400 Subject: [PATCH] MSCC Coder work continued Ignore-this: 99a78afd914e44ac2b47a62a39aca98c * Definitions for MSCC intra-message type tags * Coder now does both hash and appears-as message coding darcs-hash:20090503051708-4d648-cc6ba014468c5337bbef75ec932f83b3576b35e7.gz --- Definitions.pm | 6 ++++++ MSCCCoder.pm | 18 ++++++++++++++++-- MSCCCoder_filter.pl | 6 ++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Definitions.pm b/Definitions.pm index 353e8cb..fb808f7 100644 --- a/Definitions.pm +++ b/Definitions.pm @@ -59,4 +59,10 @@ our $instance_huffman_table1 = [ our $instance_suffix = ""; # Oh backtick, how we miss thee ################################################################# + +our $MSCC_TYPE_AA = 0; +our $MSCC_TYPE_HASH = 1; + +################################################################# + 1; diff --git a/MSCCCoder.pm b/MSCCCoder.pm index ef035c8..e6e7558 100644 --- a/MSCCCoder.pm +++ b/MSCCCoder.pm @@ -37,7 +37,21 @@ sub new ($$) { ################################################################# -sub encode($$) { +sub encode_aa($$) { + my ($self, $msg) = @_; + chomp $msg; + return $self->{'tc'}->encode($1) if ($msg =~ /^# Appears as (.*)$/i); + return ""; +} + +sub decode_aa($$) { + my ($self, $msg) = @_; + return "# Appears as " . ($self->{'tc'}->decode($msg)); +} + +################################################################# + +sub encode_hash($$) { my ($self, $msg) = @_; my $mc = $$self{'mc'}; @@ -80,7 +94,7 @@ sub encode($$) { } -sub decode($$) { +sub decode_hash($$) { my ($self, $msg) = @_; my $mc = $self->{'mc'}; diff --git a/MSCCCoder_filter.pl b/MSCCCoder_filter.pl index 4d3f5c5..325d1b2 100644 --- a/MSCCCoder_filter.pl +++ b/MSCCCoder_filter.pl @@ -9,11 +9,9 @@ use Instance::Definitions qw( @debug_code_chars $MESSAGE_START $MESSAGE_END ); my $mc = Instance::MasterCoder->new(\@debug_code_chars, $MESSAGE_START, $MESSAGE_END); my $msccc = Instance::MSCCCoder->new($mc); -print "FOO ", $mc->{'code_chars'}[0], "\n"; - while(my $in = <>) { chomp $in; - my $enc = $msccc->encode($in); - my $dec = $msccc->decode($enc); + my $enc = $msccc->encode_hash($in); + my $dec = $msccc->decode_hash($enc); print $in, " ==> ", $enc, " ==> ", $dec, "\n"; } -- 2.50.1