9 $AUTOLOAD =~ /^OS2::DLL::.+::(.+)$/
10 or confess("Undefined subroutine &$AUTOLOAD called");
11 return undef if $1 eq "DESTROY";
13 or confess("Can't find entry '$1' to DLL '$_[0]->{File}': $^E");
17 @libs = split(/;/, $ENV{'PERL5REXX'} || $ENV{'PERLREXX'} || $ENV{'LIBPATH'} || $ENV{'PATH'});
20 # Preloaded methods go here. Autoload methods go after __END__, and are
21 # processed by the autosplit program.
23 # Cannot autoload, the autoloader is used for the REXX functions.
27 confess 'Usage: load OS2::DLL <file> [<dirs>]' unless $#_ >= 1;
28 my ($class, $file, @where) = (@_, @libs);
29 return $dlls{$file} if $dlls{$file};
32 $handle = DynaLoader::dl_load_file("$_/$file.dll");
35 $handle = DynaLoader::dl_load_file($file) unless $handle;
36 return undef unless $handle;
37 my $packs = $INC{'OS2/REXX.pm'} ? 'OS2::DLL OS2::REXX' : 'OS2::DLL';
38 eval <<EOE or die "eval package $@";
39 package OS2::DLL::$file; \@ISA = qw($packs);
41 \$OS2::DLL::AUTOLOAD = \$AUTOLOAD;
42 goto &OS2::DLL::AUTOLOAD;
47 bless {Handle => $handle, File => $file, Queue => 'SESSION' },
54 my $file = $self->{File};
55 my $handle = $self->{Handle};
56 my $prefix = exists($self->{Prefix}) ? $self->{Prefix} : "";
57 my $queue = $self->{Queue};
59 my $name = "OS2::DLL::${file}::$_";
60 next if defined(&$name);
61 my $addr = DynaLoader::dl_find_symbol($handle, uc $prefix.$_)
62 || DynaLoader::dl_find_symbol($handle, $prefix.$_)
64 eval <<EOE or die "eval sub";
65 package OS2::DLL::$file;
68 OS2::DLL::_call('$_', $addr, '$queue', \@_);
83 OS2::DLL - access to DLLs with REXX calling convention.
87 When you use this module, the REXX variable pool is not available.
89 See documentation of L<OS2::REXX> module if you need the variable pool.
94 $emx_dll = OS2::DLL->load('emx');
95 $emx_version = $emx_dll->emx_revision();
101 $dll = load OS2::DLL NAME [, WHERE];
103 NAME is DLL name, without path and extension.
105 Directories are searched WHERE first (list of dirs), then environment
106 paths PERL5REXX, PERLREXX, PATH or, as last resort, OS/2-ish search
107 is performed in default DLL path (without adding paths and extensions).
109 The DLL is not unloaded when the variable dies.
111 Returns DLL object reference, or undef on failure.
113 =head2 Check for functions (optional):
115 BOOL = $dll->find(NAME [, NAME [, ...]]);
117 Returns true if all functions are available.
119 =head2 Call external REXX function:
121 $dll->function(arguments);
123 Returns the return string if the return code is 0, else undef.
124 Dies with error message if the function is not available.
128 If C<PERL_REXX_DEBUG> is set, emits debugging output. Looks for DLLs
129 in C<PERL5REXX>, C<PERLREXX>, C<PATH>.
133 Extracted by Ilya Zakharevich ilya@math.ohio-state.edu from L<OS2::REXX>
134 written by Andreas Kaiser ak@ananke.s.bawue.de.