3 # Copyright (c) 1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
9 use IPC::SysV qw(IPC_STAT IPC_SET IPC_RMID);
11 use vars qw($VERSION);
15 $VERSION = eval $VERSION;
18 package IPC::Msg::stat;
20 use Class::Struct qw(struct);
22 struct 'IPC::Msg::stat' => [
39 @_ == 3 || croak 'new IPC::Msg ( KEY , FLAGS )';
42 my $id = msgget($_[0],$_[1]);
57 msgctl($$self,IPC_STAT,$data) or
59 IPC::Msg::stat->new->unpack($data);
70 croak 'Bad arg count' if @_ % 2;
76 while(($key,$val) = each %arg);
79 msgctl($$self,IPC_SET,$ds->pack);
84 (msgctl($$self,IPC_RMID,0), undef $$self)[0];
88 @_ <= 5 && @_ >= 3 or croak '$msg->rcv( BUF, LEN, TYPE, FLAGS )';
91 msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or
94 ($type,$_[0]) = unpack("l! a*",$buf);
99 @_ <= 4 && @_ >= 3 or croak '$msg->snd( TYPE, BUF, FLAGS )';
101 msgsnd($$self,pack("l! a*",$_[0],$_[1]), $_[2] || 0);
111 IPC::Msg - SysV Msg IPC object class
115 use IPC::SysV qw(IPC_PRIVATE S_IRWXU);
118 $msg = new IPC::Msg(IPC_PRIVATE, S_IRWXU);
120 $msg->snd(pack("l! a*",$msgtype,$msg));
130 A class providing an object based interface to SysV IPC message queues.
136 =item new ( KEY , FLAGS )
138 Creates a new message queue associated with C<KEY>. A new queue is
145 C<KEY> is equal to C<IPC_PRIVATE>
149 C<KEY> does not already have a message queue
150 associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
154 On creation of a new message queue C<FLAGS> is used to set the
159 Returns the system message queue identifier.
161 =item rcv ( BUF, LEN [, TYPE [, FLAGS ]] )
163 Read a message from the queue. Returns the type of the message read.
164 See L<msgrcv>. The BUF becomes tainted.
168 Remove and destroy the message queue from the system.
172 =item set ( NAME => VALUE [, NAME => VALUE ...] )
174 C<set> will set the following values of the C<stat> structure associated
175 with the message queue.
179 mode (oly the permission bits)
182 C<set> accepts either a stat object, as returned by the C<stat> method,
183 or a list of I<name>-I<value> pairs.
185 =item snd ( TYPE, MSG [, FLAGS ] )
187 Place a message on the queue with the data from C<MSG> and with type C<TYPE>.
192 Returns an object of type C<IPC::Msg::stat> which is a sub-class of
193 C<Class::Struct>. It provides the following fields. For a description
194 of these fields see you system documentation.
213 L<IPC::SysV> L<Class::Struct>
217 Graham Barr <gbarr@pobox.com>
221 Copyright (c) 1997 Graham Barr. All rights reserved.
222 This program is free software; you can redistribute it and/or modify it
223 under the same terms as Perl itself.