]> hydra-www.ietfng.org Git - instirc/commitdiff
Add a small script for generating bot instance tags
authornwf <nwf@cs.jhu.edu>
Fri, 22 May 2009 04:18:47 +0000 (00:18 -0400)
committernwf <nwf@cs.jhu.edu>
Fri, 22 May 2009 04:18:47 +0000 (00:18 -0400)
Ignore-this: 12ffbe543cfe9bb04015b175c4ece455

darcs-hash:20090522041847-4d648-92ac3bca3c1ce81494f29bb7d9f6064d6a864479.gz

bottag.pl [new file with mode: 0644]

diff --git a/bottag.pl b/bottag.pl
new file mode 100644 (file)
index 0000000..8132c4d
--- /dev/null
+++ b/bottag.pl
@@ -0,0 +1,30 @@
+use Instance::Definitions qw( %known_types
+                    @debug_code_chars
+                    $instance_huffman_table1
+                    $MESSAGE_START $MESSAGE_END );
+require Instance::MasterCoder;
+require Instance::HuffmanCoder;
+use Instance::Protoutils qw( dump_message );
+
+my $mc = Instance::MasterCoder->new(\@debug_code_chars, $MESSAGE_START, $MESSAGE_END);
+my $hc = Instance::HuffmanCoder->new($mc, $instance_huffman_table1);
+
+while(my $text = <>) {
+  chomp $text;
+
+  my $enc = $hc->encode($text);
+  my $tlv = $mc->tlv_wrap( $known_types{'InstanceLabelHuffman1'}, $enc);
+
+  my @tlvs = ( );
+
+  push @tlvs, $tlv;
+
+  $enc = $mc->tencode(3);
+  $tlv = $mc->tlv_wrap( $known_types{'MiscMessageFlags'}, $enc);
+
+  push @tlvs, $tlv;
+
+  my $mesg = $mc->tlvs_to_message(\@tlvs) . $mesg_suffix;
+
+  print $text, ":", $mesg, "\n";
+}