~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to ipc/tests/IpcCat.pl

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2015-08-26 20:07:19 UTC
  • mfrom: (0.12.19)
  • Revision ID: package-import@ubuntu.com-20150826200719-t3qktwtjhs7qzjq1
Tags: 2:1.8.2-0ubuntu0.14.04.1
* New upstream release v1.8.2 to support Thunderbird 38
  - Fixes LP: #1489103 - Per-account settings missing after Thunderbird
    update

* Depend on gnupg2 instead of gnupg. Whilst this enigmail version still
  works with gnupg 1.4.*, it pops up an alert warning that it will be the
  last version to do so
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
#
 
3
#  This Source Code Form is subject to the terms of the Mozilla Public
 
4
#  License, v. 2.0. If a copy of the MPL was not distributed with this
 
5
#  file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
6
#
 
7
 
 
8
 
 
9
#  Helper tool to read or write data to/from stdin/stdout
 
10
#
 
11
#  Usage:
 
12
#  IpcCat {write|read|dump|getenv} arg
 
13
#
 
14
#  Parameters:
 
15
#    write:  read from stdin and write to file <arg>
 
16
#    read:   read from file <arg> and write to stdout
 
17
#    dump:   read from stdin; write to stdout
 
18
#    getenv: print value of environment variable <arg>
 
19
#
 
20
#  Exit codes:
 
21
#    0:    success
 
22
#    > 0:  failure
 
23
 
 
24
use Env;
 
25
 
 
26
sub readFile {
 
27
  my $fn = $_[0];
 
28
  open IN, $fn or die $!;
 
29
 
 
30
  my $r = "";
 
31
  while (<IN>) {
 
32
    $r .= $_;
 
33
  }
 
34
  close IN;
 
35
 
 
36
  return $r;
 
37
}
 
38
 
 
39
if ($#ARGV < 0) {
 
40
  exit(1);
 
41
}
 
42
 
 
43
#$| = 1; # disable buffering of output
 
44
 
 
45
# wait a little before doing anything
 
46
select(undef, undef, undef, 0.1);
 
47
 
 
48
if ($ARGV[0] =~ /^dump$/i) {
 
49
  print STDERR "Starting dump\n";
 
50
 
 
51
  my $buf = readFile("-");
 
52
  print $buf;
 
53
  print STDERR sprintf("Dumped %d bytes\n", length($buf));
 
54
}
 
55
elsif ($ARGV[0] =~ /^read$/i) {
 
56
  print STDERR "Starting read\n";
 
57
 
 
58
  my $buf = readFile($ARGV[1]);
 
59
  print $buf;
 
60
 
 
61
  print STDERR sprintf("Read %d bytes\n", length($buf));
 
62
}
 
63
elsif ($ARGV[0] =~ /^write$/i) {
 
64
  my $of = $ARGV[1];
 
65
  open(OF, ">$of") or die $!;
 
66
  print STDERR "Starting write\n";
 
67
 
 
68
  my $buf = readFile("-");
 
69
 
 
70
  print OF $buf;
 
71
  close(OF);
 
72
 
 
73
  print STDERR sprintf("Wrote %d bytes\n", length($buf));
 
74
}
 
75
elsif ($ARGV[0] =~ /^getenv$/i) {
 
76
  print STDERR sprintf("Reading environment variable %s\n", $ARGV[1]);
 
77
  print STDOUT $ENV{$ARGV[1]};
 
78
}
 
79
else {
 
80
  print STDERR "Invalid arguments\n";
 
81
  exit(1);
 
82
}
 
83
 
 
84
exit(0);
 
85