11 our @ISA = qw(Exporter);
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
17 # This allows declaration use Amiga::Classes::ARexx ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
20 our %EXPORT_TAGS = ( 'all' => [ qw(
24 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
29 our $VERSION = '0.04';
32 XSLoader::load('Amiga::ARexx', $VERSION);
37 my $self = bless {}, $class;
38 return $self->__init(@_);
47 if(exists $params{'HostName'})
49 $self->{'__hostname'} = $params{'HostName'};
50 } else { croak "HostName required";}
52 $self->{'__host'} = Amiga::ARexx::Host_init($self->{'__hostname'});
53 if (defined $self->{'__host'} && $self->{'__host'} != 0)
58 croak "Unabel to initialise Arexx Host";
68 if ((exists $params{'TimeOut'}) && (defined $params{'TimeOut'}))
70 $timeout = $params{'TimeOut'};
71 $timeout += 0; # force number
73 Amiga::ARexx::Host_wait($self->{'__host'},$timeout);
80 return Amiga::ARexx::Host_signal($self->{'__host'});
89 if(defined $self->{'__host'})
91 $msg = Amiga::ARexx::Host_getmsg($self->{'__host'});
94 $msgobj = Amiga::ARexx::Msg->new('Message' => $msg);
103 if(exists $self->{'__host'} && defined $self->{'__host'})
105 Amiga::ARexx::Host_delete($self->{'__host'});
106 delete $self->{'__host'};
112 my ($port,$command) = @_;
115 my $result = Amiga::ARexx::_DoRexx($port,$command,$rc,$rc2);
116 return ($rc,$rc2,$result);
119 package Amiga::ARexx::Msg;
128 my $self = bless {}, $class;
129 return $self->__init(@_);
137 if(exists $params{'Message'})
139 $self->{'__msg'} = $params{'Message'};
140 } else { croak "Message required";}
142 $self->{'__message'} = Amiga::ARexx::Msg_argstr($self->{'__msg'});
149 return $self->{'__message'};
154 my ($self,$rc,$rc2,$result) = @_;
155 if(exists $self->{'__msg'} && defined $self->{'__msg'})
157 Amiga::ARexx::Msg_reply($self->{'__msg'},$rc,$rc2,$result);
163 my ($self,$varname,$value) = @_;
164 if(exists $self->{'__msg'} && defined $self->{'__msg'})
166 Amiga::ARexx::Msg_setvar($self->{'__msg'},$varname,$value);
172 my ($self,$varname) = @_;
173 if(exists $self->{'__msg'} && defined $self->{'__msg'})
175 return Amiga::ARexx::Msg_getvar($self->{'__msg'},$varname);
182 if(exists $self->{'__msg'} && defined $self->{'__msg'})
184 Amiga::ARexx::Msg_delete($self->{'__msg'});
185 delete $self->{'__msg'};
189 # Preloaded methods go here.
191 # Autoload methods go after =cut, and are processed by the autosplit program.
195 # Below is stub documentation for your module. You'd better edit it!
199 Amiga::ARexx - Perl extension for ARexx support
203 This a perl class / module to enable you to use ARexx with
204 your perlscript. Creating a function host or executing scripts in other hosts.
205 The API is loosley modeled on the python arexx module supplied by with AmigaOS4.1
212 my $host = Amiga::ARexx->new('HostName' => "PERLREXX" );
214 # Wait for and process rexxcommands
221 my $msg = $host->getmsg();
228 print $msg->message . "\n";
234 $result = "quitting!";
241 $msg->reply($rc,$rc2,$result);
243 $msg = $host->getmsg();
248 # Send a command to a host
250 my $port = "SOMEHOST";
251 my $command = "SOMECOMMAND";
252 my ($rc,$rc2,$result) = Amiga::ARexx->DoRexx($port,$command);
258 The interface to the arexx.class in entirely encapsulated within the perl class, there
259 is no need to access the low level methods directly and they are not exported by default.
261 =head1 Amiga::ARexx METHODS
265 my $host = Amiga::ARexx->new( HostName => "PERLREXX");
268 Create an ARexx host for your script / program.
272 The HostName for the hosts command port. This is madatory, the program will fail if not
278 $host->wait('TimeOut' => $timeoutinusecs );
280 Wait for a message to arive at the port.
284 optional time out in microseconds.
289 $msg = $host->getmsg();
292 Fetch an ARexx message from the host port. Returns an objrct of class Amiga::ARexx::Msg
296 $signal = $host->signal()
298 Retrieve the signal mask for the host port for use with Amiga::Exec Wait()
302 ($rc,$rc2,$result) = DoRexx("desthost","commandstring");
304 Send the "commandstring" to host "desthost" for execution. Commandstring might be a specific command or scriptname.
306 =head1 Amiga::ARexx::Msg METHODS
310 $m = $msg->message();
312 Retreive the message "command" as a string;
317 $msg->reply($rc,$rc2,$result)
319 Reply the message returning the results of any command. Set $rc = 0 for success and $result to the result string if appropriate.
321 Set $rc to non zero for error and $rc2 for an additional error code if appropriate.
325 $msg->setvar($varname,$value)
327 Set a variable in the language context sending this message.
331 $value = $msg->getvar($varname)
333 Get the value of a variable in the language context sending this message.
340 =head2 Exportable constants
346 Andy Broad <andy@broad.ology.org.uk>
348 =head1 COPYRIGHT AND LICENSE
350 Copyright (C) 2013 by Andy Broad.