line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################################################ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Version 2.x, Copyright (C) 2007-2013, Marcus Holland-Moritz . |
4
|
|
|
|
|
|
|
# Version 1.x, Copyright (C) 1997, Graham Barr . |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
################################################################################ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package IPC::Msg; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
450
|
use IPC::SysV qw(IPC_STAT IPC_SET IPC_RMID); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
14
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
15
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
16
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
118
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '2.09'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Figure out if we have support for native sized types |
21
|
|
|
|
|
|
|
my $N = do { my $foo = eval { pack "L!", 0 }; $@ ? '' : '!' }; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
package IPC::Msg::stat; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
554
|
use Class::Struct qw(struct); |
|
1
|
|
|
|
|
1801
|
|
|
1
|
|
|
|
|
5
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
struct 'IPC::Msg::stat' => [ |
29
|
|
|
|
|
|
|
uid => '$', |
30
|
|
|
|
|
|
|
gid => '$', |
31
|
|
|
|
|
|
|
cuid => '$', |
32
|
|
|
|
|
|
|
cgid => '$', |
33
|
|
|
|
|
|
|
mode => '$', |
34
|
|
|
|
|
|
|
qnum => '$', |
35
|
|
|
|
|
|
|
qbytes => '$', |
36
|
|
|
|
|
|
|
lspid => '$', |
37
|
|
|
|
|
|
|
lrpid => '$', |
38
|
|
|
|
|
|
|
stime => '$', |
39
|
|
|
|
|
|
|
rtime => '$', |
40
|
|
|
|
|
|
|
ctime => '$', |
41
|
|
|
|
|
|
|
]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
1
|
50
|
|
1
|
1
|
4
|
@_ == 3 || croak 'IPC::Msg->new( KEY , FLAGS )'; |
46
|
1
|
|
|
|
|
2
|
my $class = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
22
|
my $id = msgget($_[0],$_[1]); |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
20
|
defined($id) |
51
|
|
|
|
|
|
|
? bless \$id, $class |
52
|
|
|
|
|
|
|
: undef; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub id { |
56
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
57
|
0
|
|
|
|
|
0
|
$$self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub stat { |
61
|
2
|
|
|
2
|
1
|
1370
|
my $self = shift; |
62
|
2
|
|
|
|
|
4
|
my $data = ""; |
63
|
2
|
50
|
|
|
|
9
|
msgctl($$self,IPC_STAT,$data) or |
64
|
|
|
|
|
|
|
return undef; |
65
|
2
|
|
|
|
|
47
|
IPC::Msg::stat->new->unpack($data); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub set { |
69
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
70
|
0
|
|
|
|
|
0
|
my $ds; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
0
|
if(@_ == 1) { |
73
|
0
|
|
|
|
|
0
|
$ds = shift; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else { |
76
|
0
|
0
|
|
|
|
0
|
croak 'Bad arg count' if @_ % 2; |
77
|
0
|
|
|
|
|
0
|
my %arg = @_; |
78
|
0
|
0
|
|
|
|
0
|
$ds = $self->stat |
79
|
|
|
|
|
|
|
or return undef; |
80
|
0
|
|
|
|
|
0
|
my($key,$val); |
81
|
0
|
|
|
|
|
0
|
$ds->$key($val) |
82
|
|
|
|
|
|
|
while(($key,$val) = each %arg); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
msgctl($$self,IPC_SET,$ds->pack); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub remove { |
89
|
1
|
|
|
1
|
1
|
852
|
my $self = shift; |
90
|
1
|
|
|
|
|
7
|
(msgctl($$self,IPC_RMID,0), undef $$self)[0]; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub rcv { |
94
|
1
|
50
|
33
|
1
|
1
|
8
|
@_ <= 5 && @_ >= 3 or croak '$msg->rcv( BUF, LEN, TYPE, FLAGS )'; |
95
|
1
|
|
|
|
|
3
|
my $self = shift; |
96
|
1
|
|
|
|
|
1
|
my $buf = ""; |
97
|
1
|
50
|
50
|
|
|
18
|
msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or |
|
|
|
50
|
|
|
|
|
98
|
|
|
|
|
|
|
return; |
99
|
1
|
|
|
|
|
3
|
my $type; |
100
|
1
|
|
|
|
|
8
|
($type,$_[0]) = unpack("l$N a*",$buf); |
101
|
1
|
|
|
|
|
2
|
$type; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub snd { |
105
|
1
|
50
|
33
|
1
|
1
|
8
|
@_ <= 4 && @_ >= 3 or croak '$msg->snd( TYPE, BUF, FLAGS )'; |
106
|
1
|
|
|
|
|
3
|
my $self = shift; |
107
|
1
|
|
50
|
|
|
25
|
msgsnd($$self,pack("l$N a*",$_[0],$_[1]), $_[2] || 0); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |