mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Refactor
This commit is contained in:
parent
01ddf53ee9
commit
56131a2709
2 changed files with 21 additions and 8 deletions
|
@ -7,7 +7,8 @@ use IPC::Open2;
|
|||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
sshOpts openSSHConnection closeSSHConnection
|
||||
readN readInt writeInt writeString writeStrings
|
||||
readN readInt readString readStrings
|
||||
writeInt writeString writeStrings
|
||||
connectToRemoteNix
|
||||
);
|
||||
|
||||
|
@ -83,6 +84,24 @@ sub readInt {
|
|||
}
|
||||
|
||||
|
||||
sub readString {
|
||||
my ($from) = @_;
|
||||
my $len = readInt($from);
|
||||
my $s = readN($len, $from);
|
||||
readN(8 - $len % 8, $from) if $len % 8; # skip padding
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
sub readStrings {
|
||||
my ($from) = @_;
|
||||
my $n = readInt($from);
|
||||
my @res;
|
||||
push @res, readString($from) while $n--;
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
sub writeInt {
|
||||
my ($n, $to) = @_;
|
||||
syswrite($to, pack("L<x4", $n)) or die;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue