File: encode.pl

package info (click to toggle)
snap 0.08-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 440 kB
  • ctags: 473
  • sloc: perl: 7,033; makefile: 117; sh: 70
file content (42 lines) | stat: -rw-r--r-- 756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#
# Generic file scrambling framework scripts.  See pig_latin.pl for an example
# for how to encode shared file names.
#

my $ENCODE_SUB = sub { return $_[0]; };
my $VERSION = "0.01";

$ENCODER_LOADED = 1;

push @{ $code_hash{&MSG_INIT} }, \&encode_list;

print "File Encoder Module $VERSION loaded...\n";

sub encode_list
{
  my ($sock, $text) = @_;
  my $file;

  foreach $file (sort keys %$cache)
    {
      next if ($file eq "");

      my $mangled_name = $file;

      $mangled_name =~ s/^\Q$upload\E\/?//g;
      $mangled_name =~ s/\.mp3$//;
      $mangled_name = $ENCODE_SUB->($mangled_name);

      $$cache{$file}{name} = $mangled_name . ".mp3";
    }  
}

sub set_encoder
{
  $ENCODE_SUB = $_[0];
}

sub encode
{
  return $ENCODE_SUB->($_[0]);
}