exiftool-vendored.exe 13.26.0 → 13.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +254 -254
  2. package/bin/README.txt +14 -14
  3. package/bin/exiftool.exe +0 -0
  4. package/bin/exiftool_files/exiftool.pl +2 -1
  5. package/bin/exiftool_files/lib/CPAN/Config.pm +98 -98
  6. package/bin/exiftool_files/lib/Config.pm +111 -111
  7. package/bin/exiftool_files/lib/Config_git.pl +12 -12
  8. package/bin/exiftool_files/lib/Config_heavy.pl +1470 -1470
  9. package/bin/exiftool_files/lib/DynaLoader.pm +761 -761
  10. package/bin/exiftool_files/lib/Errno.pm +2638 -2638
  11. package/bin/exiftool_files/lib/Image/ExifTool/Canon.pm +2 -2
  12. package/bin/exiftool_files/lib/Image/ExifTool/GIMP.pm +1 -1
  13. package/bin/exiftool_files/lib/Image/ExifTool/JPEG.pm +20 -8
  14. package/bin/exiftool_files/lib/Image/ExifTool/LigoGPS.pm +16 -2
  15. package/bin/exiftool_files/lib/Image/ExifTool/MPF.pm +5 -1
  16. package/bin/exiftool_files/lib/Image/ExifTool/Olympus.pm +1 -1
  17. package/bin/exiftool_files/lib/Image/ExifTool/Panasonic.pm +9 -1
  18. package/bin/exiftool_files/lib/Image/ExifTool/Parrot.pm +54 -7
  19. package/bin/exiftool_files/lib/Image/ExifTool/Pentax.pm +101 -1
  20. package/bin/exiftool_files/lib/Image/ExifTool/Plot.pm +36 -15
  21. package/bin/exiftool_files/lib/Image/ExifTool/QuickTime.pm +53 -5
  22. package/bin/exiftool_files/lib/Image/ExifTool/QuickTimeStream.pl +70 -14
  23. package/bin/exiftool_files/lib/Image/ExifTool/README +12 -2
  24. package/bin/exiftool_files/lib/Image/ExifTool/Sony.pm +5 -0
  25. package/bin/exiftool_files/lib/Image/ExifTool/TagLookup.pm +12 -2
  26. package/bin/exiftool_files/lib/Image/ExifTool/TagNames.pod +131 -86
  27. package/bin/exiftool_files/lib/Image/ExifTool/WriteExif.pl +2 -0
  28. package/bin/exiftool_files/lib/Image/ExifTool/WriteQuickTime.pl +3 -0
  29. package/bin/exiftool_files/lib/Image/ExifTool/Writer.pl +17 -6
  30. package/bin/exiftool_files/lib/Image/ExifTool/XMP.pm +2 -2
  31. package/bin/exiftool_files/lib/Image/ExifTool.pm +7 -3
  32. package/bin/exiftool_files/lib/Image/ExifTool.pod +11 -11
  33. package/bin/exiftool_files/lib/Win32/FindFile.pm +82 -82
  34. package/bin/exiftool_files/lib/Win32API/File/cFile.pc +168 -168
  35. package/bin/exiftool_files/lib/XSLoader.pm +372 -372
  36. package/bin/exiftool_files/lib/auto/Compress/Raw/Lzma/autosplit.ix +3 -3
  37. package/bin/exiftool_files/readme_windows.txt +16 -16
  38. package/bin/exiftool_files/windows_exiftool.txt +5 -4
  39. package/package.json +54 -53
@@ -1,761 +1,761 @@
1
-
2
- # Generated from DynaLoader_pm.PL, this file is unique for every OS
3
-
4
- package DynaLoader;
5
-
6
- # And Gandalf said: 'Many folk like to know beforehand what is to
7
- # be set on the table; but those who have laboured to prepare the
8
- # feast like to keep their secret; for wonder makes the words of
9
- # praise louder.'
10
-
11
- # (Quote from Tolkien suggested by Anno Siegel.)
12
- #
13
- # See pod text at end of file for documentation.
14
- # See also ext/DynaLoader/README in source tree for other information.
15
- #
16
- # Tim.Bunce@ig.co.uk, August 1994
17
-
18
- BEGIN {
19
- $VERSION = '1.47_01';
20
- }
21
-
22
- use Config;
23
-
24
- # enable debug/trace messages from DynaLoader perl code
25
- $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
26
-
27
- #
28
- # Flags to alter dl_load_file behaviour. Assigned bits:
29
- # 0x01 make symbols available for linking later dl_load_file's.
30
- # (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
31
- # (ignored under VMS; effect is built-in to image linking)
32
- # (ignored under Android; the linker always uses RTLD_LOCAL)
33
- #
34
- # This is called as a class method $module->dl_load_flags. The
35
- # definition here will be inherited and result on "default" loading
36
- # behaviour unless a sub-class of DynaLoader defines its own version.
37
- #
38
-
39
- sub dl_load_flags { 0x00 }
40
-
41
- ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
42
-
43
-
44
- $do_expand = 0;
45
-
46
- @dl_require_symbols = (); # names of symbols we need
47
- @dl_library_path = (); # path to look for files
48
-
49
- #XSLoader.pm may have added elements before we were required
50
- #@dl_shared_objects = (); # shared objects for symbols we have
51
- #@dl_librefs = (); # things we have loaded
52
- #@dl_modules = (); # Modules we have loaded
53
-
54
- # Initialise @dl_library_path with the 'standard' library path
55
- # for this platform as determined by Configure.
56
-
57
- push(@dl_library_path, split(' ', $Config::Config{libpth}));
58
-
59
-
60
- my $ldlibpthname = $Config::Config{ldlibpthname};
61
- my $ldlibpthname_defined = defined $Config::Config{ldlibpthname};
62
- my $pthsep = $Config::Config{path_sep};
63
-
64
- # Add to @dl_library_path any extra directories we can gather from environment
65
- # during runtime.
66
-
67
- if ($ldlibpthname_defined &&
68
- exists $ENV{$ldlibpthname}) {
69
- push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname}));
70
- }
71
-
72
- # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH.
73
-
74
- if ($ldlibpthname_defined &&
75
- $ldlibpthname ne 'LD_LIBRARY_PATH' &&
76
- exists $ENV{LD_LIBRARY_PATH}) {
77
- push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH}));
78
- }
79
-
80
-
81
- # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
82
- # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
83
- boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
84
- !defined(&dl_error);
85
-
86
- if ($dl_debug) {
87
- print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
88
- print STDERR "DynaLoader not linked into this perl\n"
89
- unless defined(&boot_DynaLoader);
90
- }
91
-
92
- 1; # End of main code
93
-
94
-
95
- sub croak { require Carp; Carp::croak(@_) }
96
-
97
- sub bootstrap_inherit {
98
- my $module = $_[0];
99
- local *isa = *{"$module\::ISA"};
100
- local @isa = (@isa, 'DynaLoader');
101
- # Cannot goto due to delocalization. Will report errors on a wrong line?
102
- bootstrap(@_);
103
- }
104
-
105
- sub bootstrap {
106
- # use local vars to enable $module.bs script to edit values
107
- local(@args) = @_;
108
- local($module) = $args[0];
109
- local(@dirs, $file);
110
-
111
- unless ($module) {
112
- require Carp;
113
- Carp::confess("Usage: DynaLoader::bootstrap(module)");
114
- }
115
-
116
- # A common error on platforms which don't support dynamic loading.
117
- # Since it's fatal and potentially confusing we give a detailed message.
118
- croak("Can't load module $module, dynamic loading not available in this perl.\n".
119
- " (You may need to build a new perl executable which either supports\n".
120
- " dynamic loading or has the $module module statically linked into it.)\n")
121
- unless defined(&dl_load_file);
122
-
123
-
124
-
125
- my @modparts = split(/::/,$module);
126
- my $modfname = $modparts[-1];
127
- my $modfname_orig = $modfname; # For .bs file search
128
-
129
- # Some systems have restrictions on files names for DLL's etc.
130
- # mod2fname returns appropriate file base name (typically truncated)
131
- # It may also edit @modparts if required.
132
- $modfname = &mod2fname(\@modparts) if defined &mod2fname;
133
-
134
-
135
-
136
- my $modpname = join('/',@modparts);
137
-
138
- print STDERR "DynaLoader::bootstrap for $module ",
139
- "(auto/$modpname/$modfname.$dl_dlext)\n"
140
- if $dl_debug;
141
-
142
- my $dir;
143
- foreach (@INC) {
144
-
145
- $dir = "$_/auto/$modpname";
146
-
147
- next unless -d $dir; # skip over uninteresting directories
148
-
149
- # check for common cases to avoid autoload of dl_findfile
150
- my $try = "$dir/$modfname.$dl_dlext";
151
- last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
152
-
153
- # no luck here, save dir for possible later dl_findfile search
154
- push @dirs, $dir;
155
- }
156
- # last resort, let dl_findfile have a go in all known locations
157
- $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
158
-
159
- croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
160
- unless $file; # wording similar to error from 'require'
161
-
162
-
163
- my $bootname = "boot_$module";
164
- $bootname =~ s/\W/_/g;
165
- @dl_require_symbols = ($bootname);
166
-
167
- # Execute optional '.bootstrap' perl script for this module.
168
- # The .bs file can be used to configure @dl_resolve_using etc to
169
- # match the needs of the individual module on this architecture.
170
- # N.B. The .bs file does not following the naming convention used
171
- # by mod2fname.
172
- my $bs = "$dir/$modfname_orig";
173
- $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
174
- if (-s $bs) { # only read file if it's not empty
175
- print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
176
- eval { local @INC = ('.'); do $bs; };
177
- warn "$bs: $@\n" if $@;
178
- }
179
-
180
- my $boot_symbol_ref;
181
-
182
-
183
-
184
- # Many dynamic extension loading problems will appear to come from
185
- # this section of code: XYZ failed at line 123 of DynaLoader.pm.
186
- # Often these errors are actually occurring in the initialisation
187
- # C code of the extension XS file. Perl reports the error as being
188
- # in this perl code simply because this was the last perl code
189
- # it executed.
190
-
191
- my $flags = $module->dl_load_flags;
192
-
193
- my $libref = dl_load_file($file, $flags) or
194
- croak("Can't load '$file' for module $module: ".dl_error());
195
-
196
- push(@dl_librefs,$libref); # record loaded object
197
-
198
- $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
199
- croak("Can't find '$bootname' symbol in $file\n");
200
-
201
- push(@dl_modules, $module); # record loaded module
202
-
203
- boot:
204
- my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
205
-
206
- # See comment block above
207
-
208
- push(@dl_shared_objects, $file); # record files loaded
209
-
210
- &$xs(@args);
211
- }
212
-
213
- sub dl_findfile {
214
- # This function does not automatically consider the architecture
215
- # or the perl library auto directories.
216
- my (@args) = @_;
217
- my (@dirs, $dir); # which directories to search
218
- my (@found); # full paths to real files we have found
219
- #my $dl_ext= 'xs.dll'; # $Config::Config{'dlext'} suffix for perl extensions
220
- #my $dl_so = 'dll'; # $Config::Config{'so'} suffix for shared libraries
221
-
222
- print STDERR "dl_findfile(@args)\n" if $dl_debug;
223
-
224
- # accumulate directories but process files as they appear
225
- arg: foreach(@args) {
226
- # Special fast case: full filepath requires no search
227
-
228
-
229
- if (m:/: && -f $_) {
230
- push(@found,$_);
231
- last arg unless wantarray;
232
- next;
233
- }
234
-
235
-
236
- # Deal with directories first:
237
- # Using a -L prefix is the preferred option (faster and more robust)
238
- if ( s{^-L}{} ) { push(@dirs, $_); next; }
239
-
240
- # Otherwise we try to try to spot directories by a heuristic
241
- # (this is a more complicated issue than it first appears)
242
- if (m:/: && -d $_) { push(@dirs, $_); next; }
243
-
244
-
245
-
246
- # Only files should get this far...
247
- my(@names, $name); # what filenames to look for
248
- if ( s{^-l}{} ) { # convert -lname to appropriate library name
249
- push(@names, "lib$_.$dl_so", "lib$_.a");
250
- } else { # Umm, a bare name. Try various alternatives:
251
- # these should be ordered with the most likely first
252
- push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
253
- push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
254
-
255
- push(@names,"lib$_.$dl_so") unless m:/:;
256
- push(@names, $_);
257
- }
258
- my $dirsep = '/';
259
-
260
- foreach $dir (@dirs, @dl_library_path) {
261
- next unless -d $dir;
262
-
263
- foreach $name (@names) {
264
- my($file) = "$dir$dirsep$name";
265
- print STDERR " checking in $dir for $name\n" if $dl_debug;
266
- if ($do_expand && ($file = dl_expandspec($file))) {
267
- push @found, $file;
268
- next arg; # no need to look any further
269
- }
270
- elsif (-f $file) {
271
- push(@found, $file);
272
- next arg; # no need to look any further
273
- }
274
-
275
- }
276
- }
277
- }
278
- if ($dl_debug) {
279
- foreach(@dirs) {
280
- print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
281
- }
282
- print STDERR "dl_findfile found: @found\n";
283
- }
284
- return $found[0] unless wantarray;
285
- @found;
286
- }
287
-
288
-
289
-
290
- sub dl_expandspec {
291
- my($spec) = @_;
292
- # Optional function invoked if DynaLoader.pm sets $do_expand.
293
- # Most systems do not require or use this function.
294
- # Some systems may implement it in the dl_*.xs file in which case
295
- # this Perl version should be excluded at build time.
296
-
297
- # This function is designed to deal with systems which treat some
298
- # 'filenames' in a special way. For example VMS 'Logical Names'
299
- # (something like unix environment variables - but different).
300
- # This function should recognise such names and expand them into
301
- # full file paths.
302
- # Must return undef if $spec is invalid or file does not exist.
303
-
304
- my $file = $spec; # default output to input
305
-
306
- return undef unless -f $file;
307
- print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
308
- $file;
309
- }
310
-
311
- sub dl_find_symbol_anywhere
312
- {
313
- my $sym = shift;
314
- my $libref;
315
- foreach $libref (@dl_librefs) {
316
- my $symref = dl_find_symbol($libref,$sym,1);
317
- return $symref if $symref;
318
- }
319
- return undef;
320
- }
321
-
322
- __END__
323
-
324
- =head1 NAME
325
-
326
- DynaLoader - Dynamically load C libraries into Perl code
327
-
328
- =head1 SYNOPSIS
329
-
330
- package YourPackage;
331
- require DynaLoader;
332
- @ISA = qw(... DynaLoader ...);
333
- __PACKAGE__->bootstrap;
334
-
335
- # optional method for 'global' loading
336
- sub dl_load_flags { 0x01 }
337
-
338
-
339
- =head1 DESCRIPTION
340
-
341
- This document defines a standard generic interface to the dynamic
342
- linking mechanisms available on many platforms. Its primary purpose is
343
- to implement automatic dynamic loading of Perl modules.
344
-
345
- This document serves as both a specification for anyone wishing to
346
- implement the DynaLoader for a new platform and as a guide for
347
- anyone wishing to use the DynaLoader directly in an application.
348
-
349
- The DynaLoader is designed to be a very simple high-level
350
- interface that is sufficiently general to cover the requirements
351
- of SunOS, HP-UX, Linux, VMS and other platforms.
352
-
353
- It is also hoped that the interface will cover the needs of OS/2, NT
354
- etc and also allow pseudo-dynamic linking (using C<ld -A> at runtime).
355
-
356
- It must be stressed that the DynaLoader, by itself, is practically
357
- useless for accessing non-Perl libraries because it provides almost no
358
- Perl-to-C 'glue'. There is, for example, no mechanism for calling a C
359
- library function or supplying arguments. A C::DynaLib module
360
- is available from CPAN sites which performs that function for some
361
- common system types. And since the year 2000, there's also Inline::C,
362
- a module that allows you to write Perl subroutines in C. Also available
363
- from your local CPAN site.
364
-
365
- DynaLoader Interface Summary
366
-
367
- @dl_library_path
368
- @dl_resolve_using
369
- @dl_require_symbols
370
- $dl_debug
371
- $dl_dlext
372
- @dl_librefs
373
- @dl_modules
374
- @dl_shared_objects
375
- Implemented in:
376
- bootstrap($modulename) Perl
377
- @filepaths = dl_findfile(@names) Perl
378
- $flags = $modulename->dl_load_flags Perl
379
- $symref = dl_find_symbol_anywhere($symbol) Perl
380
-
381
- $libref = dl_load_file($filename, $flags) C
382
- $status = dl_unload_file($libref) C
383
- $symref = dl_find_symbol($libref, $symbol) C
384
- @symbols = dl_undef_symbols() C
385
- dl_install_xsub($name, $symref [, $filename]) C
386
- $message = dl_error C
387
-
388
- =over 4
389
-
390
- =item @dl_library_path
391
-
392
- The standard/default list of directories in which dl_findfile() will
393
- search for libraries etc. Directories are searched in order:
394
- $dl_library_path[0], [1], ... etc
395
-
396
- @dl_library_path is initialised to hold the list of 'normal' directories
397
- (F</usr/lib>, etc) determined by B<Configure> (C<$Config{'libpth'}>). This should
398
- ensure portability across a wide range of platforms.
399
-
400
- @dl_library_path should also be initialised with any other directories
401
- that can be determined from the environment at runtime (such as
402
- LD_LIBRARY_PATH for SunOS).
403
-
404
- After initialisation @dl_library_path can be manipulated by an
405
- application using push and unshift before calling dl_findfile().
406
- Unshift can be used to add directories to the front of the search order
407
- either to save search time or to override libraries with the same name
408
- in the 'normal' directories.
409
-
410
- The load function that dl_load_file() calls may require an absolute
411
- pathname. The dl_findfile() function and @dl_library_path can be
412
- used to search for and return the absolute pathname for the
413
- library/object that you wish to load.
414
-
415
- =item @dl_resolve_using
416
-
417
- A list of additional libraries or other shared objects which can be
418
- used to resolve any undefined symbols that might be generated by a
419
- later call to load_file().
420
-
421
- This is only required on some platforms which do not handle dependent
422
- libraries automatically. For example the Socket Perl extension
423
- library (F<auto/Socket/Socket.so>) contains references to many socket
424
- functions which need to be resolved when it's loaded. Most platforms
425
- will automatically know where to find the 'dependent' library (e.g.,
426
- F</usr/lib/libsocket.so>). A few platforms need to be told the
427
- location of the dependent library explicitly. Use @dl_resolve_using
428
- for this.
429
-
430
- Example usage:
431
-
432
- @dl_resolve_using = dl_findfile('-lsocket');
433
-
434
- =item @dl_require_symbols
435
-
436
- A list of one or more symbol names that are in the library/object file
437
- to be dynamically loaded. This is only required on some platforms.
438
-
439
- =item @dl_librefs
440
-
441
- An array of the handles returned by successful calls to dl_load_file(),
442
- made by bootstrap, in the order in which they were loaded.
443
- Can be used with dl_find_symbol() to look for a symbol in any of
444
- the loaded files.
445
-
446
- =item @dl_modules
447
-
448
- An array of module (package) names that have been bootstrap'ed.
449
-
450
- =item @dl_shared_objects
451
-
452
- An array of file names for the shared objects that were loaded.
453
-
454
- =item dl_error()
455
-
456
- Syntax:
457
-
458
- $message = dl_error();
459
-
460
- Error message text from the last failed DynaLoader function. Note
461
- that, similar to errno in unix, a successful function call does not
462
- reset this message.
463
-
464
- Implementations should detect the error as soon as it occurs in any of
465
- the other functions and save the corresponding message for later
466
- retrieval. This will avoid problems on some platforms (such as SunOS)
467
- where the error message is very temporary (e.g., dlerror()).
468
-
469
- =item $dl_debug
470
-
471
- Internal debugging messages are enabled when $dl_debug is set true.
472
- Currently setting $dl_debug only affects the Perl side of the
473
- DynaLoader. These messages should help an application developer to
474
- resolve any DynaLoader usage problems.
475
-
476
- $dl_debug is set to C<$ENV{'PERL_DL_DEBUG'}> if defined.
477
-
478
- For the DynaLoader developer/porter there is a similar debugging
479
- variable added to the C code (see dlutils.c) and enabled if Perl was
480
- built with the B<-DDEBUGGING> flag. This can also be set via the
481
- PERL_DL_DEBUG environment variable. Set to 1 for minimal information or
482
- higher for more.
483
-
484
- =item $dl_dlext
485
-
486
- When specified (localised) in a module's F<.pm> file, indicates the extension
487
- which the module's loadable object will have. For example:
488
-
489
- local $DynaLoader::dl_dlext = 'unusual_ext';
490
-
491
- would indicate that the module's loadable object has an extension of
492
- C<unusual_ext> instead of the more usual C<$Config{dlext}>. NOTE: This also
493
- requires that the module's F<Makefile.PL> specify (in C<WriteMakefile()>):
494
-
495
- DLEXT => 'unusual_ext',
496
-
497
- =item dl_findfile()
498
-
499
- Syntax:
500
-
501
- @filepaths = dl_findfile(@names)
502
-
503
- Determine the full paths (including file suffix) of one or more
504
- loadable files given their generic names and optionally one or more
505
- directories. Searches directories in @dl_library_path by default and
506
- returns an empty list if no files were found.
507
-
508
- Names can be specified in a variety of platform independent forms. Any
509
- names in the form B<-lname> are converted into F<libname.*>, where F<.*> is
510
- an appropriate suffix for the platform.
511
-
512
- If a name does not already have a suitable prefix and/or suffix then
513
- the corresponding file will be searched for by trying combinations of
514
- prefix and suffix appropriate to the platform: "$name.o", "lib$name.*"
515
- and "$name".
516
-
517
- If any directories are included in @names they are searched before
518
- @dl_library_path. Directories may be specified as B<-Ldir>. Any other
519
- names are treated as filenames to be searched for.
520
-
521
- Using arguments of the form C<-Ldir> and C<-lname> is recommended.
522
-
523
- Example:
524
-
525
- @dl_resolve_using = dl_findfile(qw(-L/usr/5lib -lposix));
526
-
527
-
528
- =item dl_expandspec()
529
-
530
- Syntax:
531
-
532
- $filepath = dl_expandspec($spec)
533
-
534
- Some unusual systems, such as VMS, require special filename handling in
535
- order to deal with symbolic names for files (i.e., VMS's Logical Names).
536
-
537
- To support these systems a dl_expandspec() function can be implemented
538
- either in the F<dl_*.xs> file or code can be added to the dl_expandspec()
539
- function in F<DynaLoader.pm>. See F<DynaLoader_pm.PL> for more information.
540
-
541
- =item dl_load_file()
542
-
543
- Syntax:
544
-
545
- $libref = dl_load_file($filename, $flags)
546
-
547
- Dynamically load $filename, which must be the path to a shared object
548
- or library. An opaque 'library reference' is returned as a handle for
549
- the loaded object. Returns undef on error.
550
-
551
- The $flags argument to alters dl_load_file behaviour.
552
- Assigned bits:
553
-
554
- 0x01 make symbols available for linking later dl_load_file's.
555
- (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
556
- (ignored under VMS; this is a normal part of image linking)
557
-
558
- (On systems that provide a handle for the loaded object such as SunOS
559
- and HPUX, $libref will be that handle. On other systems $libref will
560
- typically be $filename or a pointer to a buffer containing $filename.
561
- The application should not examine or alter $libref in any way.)
562
-
563
- This is the function that does the real work. It should use the
564
- current values of @dl_require_symbols and @dl_resolve_using if required.
565
-
566
- SunOS: dlopen($filename)
567
- HP-UX: shl_load($filename)
568
- Linux: dld_create_reference(@dl_require_symbols); dld_link($filename)
569
- VMS: lib$find_image_symbol($filename,$dl_require_symbols[0])
570
-
571
- (The dlopen() function is also used by Solaris and some versions of
572
- Linux, and is a common choice when providing a "wrapper" on other
573
- mechanisms as is done in the OS/2 port.)
574
-
575
- =item dl_unload_file()
576
-
577
- Syntax:
578
-
579
- $status = dl_unload_file($libref)
580
-
581
- Dynamically unload $libref, which must be an opaque 'library reference' as
582
- returned from dl_load_file. Returns one on success and zero on failure.
583
- This function is optional and may not necessarily be provided on all platforms.
584
-
585
- If it is defined and perl is compiled with the C macro C<DL_UNLOAD_ALL_AT_EXIT>
586
- defined, then it is called automatically when the interpreter exits for
587
- every shared object or library loaded by DynaLoader::bootstrap. All such
588
- library references are stored in @dl_librefs by DynaLoader::Bootstrap as it
589
- loads the libraries. The files are unloaded in last-in, first-out order.
590
-
591
- This unloading is usually necessary when embedding a shared-object perl (e.g.
592
- one configured with -Duseshrplib) within a larger application, and the perl
593
- interpreter is created and destroyed several times within the lifetime of the
594
- application. In this case it is possible that the system dynamic linker will
595
- unload and then subsequently reload the shared libperl without relocating any
596
- references to it from any files DynaLoaded by the previous incarnation of the
597
- interpreter. As a result, any shared objects opened by DynaLoader may point to
598
- a now invalid 'ghost' of the libperl shared object, causing apparently random
599
- memory corruption and crashes. This behaviour is most commonly seen when using
600
- Apache and mod_perl built with the APXS mechanism.
601
-
602
- SunOS: dlclose($libref)
603
- HP-UX: ???
604
- Linux: ???
605
- VMS: ???
606
-
607
- (The dlclose() function is also used by Solaris and some versions of
608
- Linux, and is a common choice when providing a "wrapper" on other
609
- mechanisms as is done in the OS/2 port.)
610
-
611
- =item dl_load_flags()
612
-
613
- Syntax:
614
-
615
- $flags = dl_load_flags $modulename;
616
-
617
- Designed to be a method call, and to be overridden by a derived class
618
- (i.e. a class which has DynaLoader in its @ISA). The definition in
619
- DynaLoader itself returns 0, which produces standard behavior from
620
- dl_load_file().
621
-
622
- =item dl_find_symbol()
623
-
624
- Syntax:
625
-
626
- $symref = dl_find_symbol($libref, $symbol)
627
-
628
- Return the address of the symbol $symbol or C<undef> if not found. If the
629
- target system has separate functions to search for symbols of different
630
- types then dl_find_symbol() should search for function symbols first and
631
- then other types.
632
-
633
- The exact manner in which the address is returned in $symref is not
634
- currently defined. The only initial requirement is that $symref can
635
- be passed to, and understood by, dl_install_xsub().
636
-
637
- SunOS: dlsym($libref, $symbol)
638
- HP-UX: shl_findsym($libref, $symbol)
639
- Linux: dld_get_func($symbol) and/or dld_get_symbol($symbol)
640
- VMS: lib$find_image_symbol($libref,$symbol)
641
-
642
-
643
- =item dl_find_symbol_anywhere()
644
-
645
- Syntax:
646
-
647
- $symref = dl_find_symbol_anywhere($symbol)
648
-
649
- Applies dl_find_symbol() to the members of @dl_librefs and returns
650
- the first match found.
651
-
652
- =item dl_undef_symbols()
653
-
654
- Example
655
-
656
- @symbols = dl_undef_symbols()
657
-
658
- Return a list of symbol names which remain undefined after load_file().
659
- Returns C<()> if not known. Don't worry if your platform does not provide
660
- a mechanism for this. Most do not need it and hence do not provide it,
661
- they just return an empty list.
662
-
663
-
664
- =item dl_install_xsub()
665
-
666
- Syntax:
667
-
668
- dl_install_xsub($perl_name, $symref [, $filename])
669
-
670
- Create a new Perl external subroutine named $perl_name using $symref as
671
- a pointer to the function which implements the routine. This is simply
672
- a direct call to newXS()/newXS_flags(). Returns a reference to the installed
673
- function.
674
-
675
- The $filename parameter is used by Perl to identify the source file for
676
- the function if required by die(), caller() or the debugger. If
677
- $filename is not defined then "DynaLoader" will be used.
678
-
679
-
680
- =item bootstrap()
681
-
682
- Syntax:
683
-
684
- bootstrap($module [...])
685
-
686
- This is the normal entry point for automatic dynamic loading in Perl.
687
-
688
- It performs the following actions:
689
-
690
- =over 8
691
-
692
- =item *
693
-
694
- locates an auto/$module directory by searching @INC
695
-
696
- =item *
697
-
698
- uses dl_findfile() to determine the filename to load
699
-
700
- =item *
701
-
702
- sets @dl_require_symbols to C<("boot_$module")>
703
-
704
- =item *
705
-
706
- executes an F<auto/$module/$module.bs> file if it exists
707
- (typically used to add to @dl_resolve_using any files which
708
- are required to load the module on the current platform)
709
-
710
- =item *
711
-
712
- calls dl_load_flags() to determine how to load the file.
713
-
714
- =item *
715
-
716
- calls dl_load_file() to load the file
717
-
718
- =item *
719
-
720
- calls dl_undef_symbols() and warns if any symbols are undefined
721
-
722
- =item *
723
-
724
- calls dl_find_symbol() for "boot_$module"
725
-
726
- =item *
727
-
728
- calls dl_install_xsub() to install it as "${module}::bootstrap"
729
-
730
- =item *
731
-
732
- calls &{"${module}::bootstrap"} to bootstrap the module (actually
733
- it uses the function reference returned by dl_install_xsub for speed)
734
-
735
- =back
736
-
737
- All arguments to bootstrap() are passed to the module's bootstrap function.
738
- The default code generated by F<xsubpp> expects $module [, $version]
739
- If the optional $version argument is not given, it defaults to
740
- C<$XS_VERSION // $VERSION> in the module's symbol table. The default code
741
- compares the Perl-space version with the version of the compiled XS code,
742
- and croaks with an error if they do not match.
743
-
744
- =back
745
-
746
-
747
- =head1 AUTHOR
748
-
749
- Tim Bunce, 11 August 1994.
750
-
751
- This interface is based on the work and comments of (in no particular
752
- order): Larry Wall, Robert Sanders, Dean Roehrich, Jeff Okamoto, Anno
753
- Siegel, Thomas Neumann, Paul Marquess, Charles Bailey, myself and others.
754
-
755
- Larry Wall designed the elegant inherited bootstrap mechanism and
756
- implemented the first Perl 5 dynamic loader using it.
757
-
758
- Solaris global loading added by Nick Ing-Simmons with design/coding
759
- assistance from Tim Bunce, January 1996.
760
-
761
- =cut
1
+
2
+ # Generated from DynaLoader_pm.PL, this file is unique for every OS
3
+
4
+ package DynaLoader;
5
+
6
+ # And Gandalf said: 'Many folk like to know beforehand what is to
7
+ # be set on the table; but those who have laboured to prepare the
8
+ # feast like to keep their secret; for wonder makes the words of
9
+ # praise louder.'
10
+
11
+ # (Quote from Tolkien suggested by Anno Siegel.)
12
+ #
13
+ # See pod text at end of file for documentation.
14
+ # See also ext/DynaLoader/README in source tree for other information.
15
+ #
16
+ # Tim.Bunce@ig.co.uk, August 1994
17
+
18
+ BEGIN {
19
+ $VERSION = '1.47_01';
20
+ }
21
+
22
+ use Config;
23
+
24
+ # enable debug/trace messages from DynaLoader perl code
25
+ $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
26
+
27
+ #
28
+ # Flags to alter dl_load_file behaviour. Assigned bits:
29
+ # 0x01 make symbols available for linking later dl_load_file's.
30
+ # (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
31
+ # (ignored under VMS; effect is built-in to image linking)
32
+ # (ignored under Android; the linker always uses RTLD_LOCAL)
33
+ #
34
+ # This is called as a class method $module->dl_load_flags. The
35
+ # definition here will be inherited and result on "default" loading
36
+ # behaviour unless a sub-class of DynaLoader defines its own version.
37
+ #
38
+
39
+ sub dl_load_flags { 0x00 }
40
+
41
+ ($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
42
+
43
+
44
+ $do_expand = 0;
45
+
46
+ @dl_require_symbols = (); # names of symbols we need
47
+ @dl_library_path = (); # path to look for files
48
+
49
+ #XSLoader.pm may have added elements before we were required
50
+ #@dl_shared_objects = (); # shared objects for symbols we have
51
+ #@dl_librefs = (); # things we have loaded
52
+ #@dl_modules = (); # Modules we have loaded
53
+
54
+ # Initialise @dl_library_path with the 'standard' library path
55
+ # for this platform as determined by Configure.
56
+
57
+ push(@dl_library_path, split(' ', $Config::Config{libpth}));
58
+
59
+
60
+ my $ldlibpthname = $Config::Config{ldlibpthname};
61
+ my $ldlibpthname_defined = defined $Config::Config{ldlibpthname};
62
+ my $pthsep = $Config::Config{path_sep};
63
+
64
+ # Add to @dl_library_path any extra directories we can gather from environment
65
+ # during runtime.
66
+
67
+ if ($ldlibpthname_defined &&
68
+ exists $ENV{$ldlibpthname}) {
69
+ push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname}));
70
+ }
71
+
72
+ # E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH.
73
+
74
+ if ($ldlibpthname_defined &&
75
+ $ldlibpthname ne 'LD_LIBRARY_PATH' &&
76
+ exists $ENV{LD_LIBRARY_PATH}) {
77
+ push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH}));
78
+ }
79
+
80
+
81
+ # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
82
+ # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
83
+ boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
84
+ !defined(&dl_error);
85
+
86
+ if ($dl_debug) {
87
+ print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
88
+ print STDERR "DynaLoader not linked into this perl\n"
89
+ unless defined(&boot_DynaLoader);
90
+ }
91
+
92
+ 1; # End of main code
93
+
94
+
95
+ sub croak { require Carp; Carp::croak(@_) }
96
+
97
+ sub bootstrap_inherit {
98
+ my $module = $_[0];
99
+ local *isa = *{"$module\::ISA"};
100
+ local @isa = (@isa, 'DynaLoader');
101
+ # Cannot goto due to delocalization. Will report errors on a wrong line?
102
+ bootstrap(@_);
103
+ }
104
+
105
+ sub bootstrap {
106
+ # use local vars to enable $module.bs script to edit values
107
+ local(@args) = @_;
108
+ local($module) = $args[0];
109
+ local(@dirs, $file);
110
+
111
+ unless ($module) {
112
+ require Carp;
113
+ Carp::confess("Usage: DynaLoader::bootstrap(module)");
114
+ }
115
+
116
+ # A common error on platforms which don't support dynamic loading.
117
+ # Since it's fatal and potentially confusing we give a detailed message.
118
+ croak("Can't load module $module, dynamic loading not available in this perl.\n".
119
+ " (You may need to build a new perl executable which either supports\n".
120
+ " dynamic loading or has the $module module statically linked into it.)\n")
121
+ unless defined(&dl_load_file);
122
+
123
+
124
+
125
+ my @modparts = split(/::/,$module);
126
+ my $modfname = $modparts[-1];
127
+ my $modfname_orig = $modfname; # For .bs file search
128
+
129
+ # Some systems have restrictions on files names for DLL's etc.
130
+ # mod2fname returns appropriate file base name (typically truncated)
131
+ # It may also edit @modparts if required.
132
+ $modfname = &mod2fname(\@modparts) if defined &mod2fname;
133
+
134
+
135
+
136
+ my $modpname = join('/',@modparts);
137
+
138
+ print STDERR "DynaLoader::bootstrap for $module ",
139
+ "(auto/$modpname/$modfname.$dl_dlext)\n"
140
+ if $dl_debug;
141
+
142
+ my $dir;
143
+ foreach (@INC) {
144
+
145
+ $dir = "$_/auto/$modpname";
146
+
147
+ next unless -d $dir; # skip over uninteresting directories
148
+
149
+ # check for common cases to avoid autoload of dl_findfile
150
+ my $try = "$dir/$modfname.$dl_dlext";
151
+ last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
152
+
153
+ # no luck here, save dir for possible later dl_findfile search
154
+ push @dirs, $dir;
155
+ }
156
+ # last resort, let dl_findfile have a go in all known locations
157
+ $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
158
+
159
+ croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
160
+ unless $file; # wording similar to error from 'require'
161
+
162
+
163
+ my $bootname = "boot_$module";
164
+ $bootname =~ s/\W/_/g;
165
+ @dl_require_symbols = ($bootname);
166
+
167
+ # Execute optional '.bootstrap' perl script for this module.
168
+ # The .bs file can be used to configure @dl_resolve_using etc to
169
+ # match the needs of the individual module on this architecture.
170
+ # N.B. The .bs file does not following the naming convention used
171
+ # by mod2fname.
172
+ my $bs = "$dir/$modfname_orig";
173
+ $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
174
+ if (-s $bs) { # only read file if it's not empty
175
+ print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
176
+ eval { local @INC = ('.'); do $bs; };
177
+ warn "$bs: $@\n" if $@;
178
+ }
179
+
180
+ my $boot_symbol_ref;
181
+
182
+
183
+
184
+ # Many dynamic extension loading problems will appear to come from
185
+ # this section of code: XYZ failed at line 123 of DynaLoader.pm.
186
+ # Often these errors are actually occurring in the initialisation
187
+ # C code of the extension XS file. Perl reports the error as being
188
+ # in this perl code simply because this was the last perl code
189
+ # it executed.
190
+
191
+ my $flags = $module->dl_load_flags;
192
+
193
+ my $libref = dl_load_file($file, $flags) or
194
+ croak("Can't load '$file' for module $module: ".dl_error());
195
+
196
+ push(@dl_librefs,$libref); # record loaded object
197
+
198
+ $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
199
+ croak("Can't find '$bootname' symbol in $file\n");
200
+
201
+ push(@dl_modules, $module); # record loaded module
202
+
203
+ boot:
204
+ my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
205
+
206
+ # See comment block above
207
+
208
+ push(@dl_shared_objects, $file); # record files loaded
209
+
210
+ &$xs(@args);
211
+ }
212
+
213
+ sub dl_findfile {
214
+ # This function does not automatically consider the architecture
215
+ # or the perl library auto directories.
216
+ my (@args) = @_;
217
+ my (@dirs, $dir); # which directories to search
218
+ my (@found); # full paths to real files we have found
219
+ #my $dl_ext= 'xs.dll'; # $Config::Config{'dlext'} suffix for perl extensions
220
+ #my $dl_so = 'dll'; # $Config::Config{'so'} suffix for shared libraries
221
+
222
+ print STDERR "dl_findfile(@args)\n" if $dl_debug;
223
+
224
+ # accumulate directories but process files as they appear
225
+ arg: foreach(@args) {
226
+ # Special fast case: full filepath requires no search
227
+
228
+
229
+ if (m:/: && -f $_) {
230
+ push(@found,$_);
231
+ last arg unless wantarray;
232
+ next;
233
+ }
234
+
235
+
236
+ # Deal with directories first:
237
+ # Using a -L prefix is the preferred option (faster and more robust)
238
+ if ( s{^-L}{} ) { push(@dirs, $_); next; }
239
+
240
+ # Otherwise we try to try to spot directories by a heuristic
241
+ # (this is a more complicated issue than it first appears)
242
+ if (m:/: && -d $_) { push(@dirs, $_); next; }
243
+
244
+
245
+
246
+ # Only files should get this far...
247
+ my(@names, $name); # what filenames to look for
248
+ if ( s{^-l}{} ) { # convert -lname to appropriate library name
249
+ push(@names, "lib$_.$dl_so", "lib$_.a");
250
+ } else { # Umm, a bare name. Try various alternatives:
251
+ # these should be ordered with the most likely first
252
+ push(@names,"$_.$dl_dlext") unless m/\.$dl_dlext$/o;
253
+ push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
254
+
255
+ push(@names,"lib$_.$dl_so") unless m:/:;
256
+ push(@names, $_);
257
+ }
258
+ my $dirsep = '/';
259
+
260
+ foreach $dir (@dirs, @dl_library_path) {
261
+ next unless -d $dir;
262
+
263
+ foreach $name (@names) {
264
+ my($file) = "$dir$dirsep$name";
265
+ print STDERR " checking in $dir for $name\n" if $dl_debug;
266
+ if ($do_expand && ($file = dl_expandspec($file))) {
267
+ push @found, $file;
268
+ next arg; # no need to look any further
269
+ }
270
+ elsif (-f $file) {
271
+ push(@found, $file);
272
+ next arg; # no need to look any further
273
+ }
274
+
275
+ }
276
+ }
277
+ }
278
+ if ($dl_debug) {
279
+ foreach(@dirs) {
280
+ print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
281
+ }
282
+ print STDERR "dl_findfile found: @found\n";
283
+ }
284
+ return $found[0] unless wantarray;
285
+ @found;
286
+ }
287
+
288
+
289
+
290
+ sub dl_expandspec {
291
+ my($spec) = @_;
292
+ # Optional function invoked if DynaLoader.pm sets $do_expand.
293
+ # Most systems do not require or use this function.
294
+ # Some systems may implement it in the dl_*.xs file in which case
295
+ # this Perl version should be excluded at build time.
296
+
297
+ # This function is designed to deal with systems which treat some
298
+ # 'filenames' in a special way. For example VMS 'Logical Names'
299
+ # (something like unix environment variables - but different).
300
+ # This function should recognise such names and expand them into
301
+ # full file paths.
302
+ # Must return undef if $spec is invalid or file does not exist.
303
+
304
+ my $file = $spec; # default output to input
305
+
306
+ return undef unless -f $file;
307
+ print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
308
+ $file;
309
+ }
310
+
311
+ sub dl_find_symbol_anywhere
312
+ {
313
+ my $sym = shift;
314
+ my $libref;
315
+ foreach $libref (@dl_librefs) {
316
+ my $symref = dl_find_symbol($libref,$sym,1);
317
+ return $symref if $symref;
318
+ }
319
+ return undef;
320
+ }
321
+
322
+ __END__
323
+
324
+ =head1 NAME
325
+
326
+ DynaLoader - Dynamically load C libraries into Perl code
327
+
328
+ =head1 SYNOPSIS
329
+
330
+ package YourPackage;
331
+ require DynaLoader;
332
+ @ISA = qw(... DynaLoader ...);
333
+ __PACKAGE__->bootstrap;
334
+
335
+ # optional method for 'global' loading
336
+ sub dl_load_flags { 0x01 }
337
+
338
+
339
+ =head1 DESCRIPTION
340
+
341
+ This document defines a standard generic interface to the dynamic
342
+ linking mechanisms available on many platforms. Its primary purpose is
343
+ to implement automatic dynamic loading of Perl modules.
344
+
345
+ This document serves as both a specification for anyone wishing to
346
+ implement the DynaLoader for a new platform and as a guide for
347
+ anyone wishing to use the DynaLoader directly in an application.
348
+
349
+ The DynaLoader is designed to be a very simple high-level
350
+ interface that is sufficiently general to cover the requirements
351
+ of SunOS, HP-UX, Linux, VMS and other platforms.
352
+
353
+ It is also hoped that the interface will cover the needs of OS/2, NT
354
+ etc and also allow pseudo-dynamic linking (using C<ld -A> at runtime).
355
+
356
+ It must be stressed that the DynaLoader, by itself, is practically
357
+ useless for accessing non-Perl libraries because it provides almost no
358
+ Perl-to-C 'glue'. There is, for example, no mechanism for calling a C
359
+ library function or supplying arguments. A C::DynaLib module
360
+ is available from CPAN sites which performs that function for some
361
+ common system types. And since the year 2000, there's also Inline::C,
362
+ a module that allows you to write Perl subroutines in C. Also available
363
+ from your local CPAN site.
364
+
365
+ DynaLoader Interface Summary
366
+
367
+ @dl_library_path
368
+ @dl_resolve_using
369
+ @dl_require_symbols
370
+ $dl_debug
371
+ $dl_dlext
372
+ @dl_librefs
373
+ @dl_modules
374
+ @dl_shared_objects
375
+ Implemented in:
376
+ bootstrap($modulename) Perl
377
+ @filepaths = dl_findfile(@names) Perl
378
+ $flags = $modulename->dl_load_flags Perl
379
+ $symref = dl_find_symbol_anywhere($symbol) Perl
380
+
381
+ $libref = dl_load_file($filename, $flags) C
382
+ $status = dl_unload_file($libref) C
383
+ $symref = dl_find_symbol($libref, $symbol) C
384
+ @symbols = dl_undef_symbols() C
385
+ dl_install_xsub($name, $symref [, $filename]) C
386
+ $message = dl_error C
387
+
388
+ =over 4
389
+
390
+ =item @dl_library_path
391
+
392
+ The standard/default list of directories in which dl_findfile() will
393
+ search for libraries etc. Directories are searched in order:
394
+ $dl_library_path[0], [1], ... etc
395
+
396
+ @dl_library_path is initialised to hold the list of 'normal' directories
397
+ (F</usr/lib>, etc) determined by B<Configure> (C<$Config{'libpth'}>). This should
398
+ ensure portability across a wide range of platforms.
399
+
400
+ @dl_library_path should also be initialised with any other directories
401
+ that can be determined from the environment at runtime (such as
402
+ LD_LIBRARY_PATH for SunOS).
403
+
404
+ After initialisation @dl_library_path can be manipulated by an
405
+ application using push and unshift before calling dl_findfile().
406
+ Unshift can be used to add directories to the front of the search order
407
+ either to save search time or to override libraries with the same name
408
+ in the 'normal' directories.
409
+
410
+ The load function that dl_load_file() calls may require an absolute
411
+ pathname. The dl_findfile() function and @dl_library_path can be
412
+ used to search for and return the absolute pathname for the
413
+ library/object that you wish to load.
414
+
415
+ =item @dl_resolve_using
416
+
417
+ A list of additional libraries or other shared objects which can be
418
+ used to resolve any undefined symbols that might be generated by a
419
+ later call to load_file().
420
+
421
+ This is only required on some platforms which do not handle dependent
422
+ libraries automatically. For example the Socket Perl extension
423
+ library (F<auto/Socket/Socket.so>) contains references to many socket
424
+ functions which need to be resolved when it's loaded. Most platforms
425
+ will automatically know where to find the 'dependent' library (e.g.,
426
+ F</usr/lib/libsocket.so>). A few platforms need to be told the
427
+ location of the dependent library explicitly. Use @dl_resolve_using
428
+ for this.
429
+
430
+ Example usage:
431
+
432
+ @dl_resolve_using = dl_findfile('-lsocket');
433
+
434
+ =item @dl_require_symbols
435
+
436
+ A list of one or more symbol names that are in the library/object file
437
+ to be dynamically loaded. This is only required on some platforms.
438
+
439
+ =item @dl_librefs
440
+
441
+ An array of the handles returned by successful calls to dl_load_file(),
442
+ made by bootstrap, in the order in which they were loaded.
443
+ Can be used with dl_find_symbol() to look for a symbol in any of
444
+ the loaded files.
445
+
446
+ =item @dl_modules
447
+
448
+ An array of module (package) names that have been bootstrap'ed.
449
+
450
+ =item @dl_shared_objects
451
+
452
+ An array of file names for the shared objects that were loaded.
453
+
454
+ =item dl_error()
455
+
456
+ Syntax:
457
+
458
+ $message = dl_error();
459
+
460
+ Error message text from the last failed DynaLoader function. Note
461
+ that, similar to errno in unix, a successful function call does not
462
+ reset this message.
463
+
464
+ Implementations should detect the error as soon as it occurs in any of
465
+ the other functions and save the corresponding message for later
466
+ retrieval. This will avoid problems on some platforms (such as SunOS)
467
+ where the error message is very temporary (e.g., dlerror()).
468
+
469
+ =item $dl_debug
470
+
471
+ Internal debugging messages are enabled when $dl_debug is set true.
472
+ Currently setting $dl_debug only affects the Perl side of the
473
+ DynaLoader. These messages should help an application developer to
474
+ resolve any DynaLoader usage problems.
475
+
476
+ $dl_debug is set to C<$ENV{'PERL_DL_DEBUG'}> if defined.
477
+
478
+ For the DynaLoader developer/porter there is a similar debugging
479
+ variable added to the C code (see dlutils.c) and enabled if Perl was
480
+ built with the B<-DDEBUGGING> flag. This can also be set via the
481
+ PERL_DL_DEBUG environment variable. Set to 1 for minimal information or
482
+ higher for more.
483
+
484
+ =item $dl_dlext
485
+
486
+ When specified (localised) in a module's F<.pm> file, indicates the extension
487
+ which the module's loadable object will have. For example:
488
+
489
+ local $DynaLoader::dl_dlext = 'unusual_ext';
490
+
491
+ would indicate that the module's loadable object has an extension of
492
+ C<unusual_ext> instead of the more usual C<$Config{dlext}>. NOTE: This also
493
+ requires that the module's F<Makefile.PL> specify (in C<WriteMakefile()>):
494
+
495
+ DLEXT => 'unusual_ext',
496
+
497
+ =item dl_findfile()
498
+
499
+ Syntax:
500
+
501
+ @filepaths = dl_findfile(@names)
502
+
503
+ Determine the full paths (including file suffix) of one or more
504
+ loadable files given their generic names and optionally one or more
505
+ directories. Searches directories in @dl_library_path by default and
506
+ returns an empty list if no files were found.
507
+
508
+ Names can be specified in a variety of platform independent forms. Any
509
+ names in the form B<-lname> are converted into F<libname.*>, where F<.*> is
510
+ an appropriate suffix for the platform.
511
+
512
+ If a name does not already have a suitable prefix and/or suffix then
513
+ the corresponding file will be searched for by trying combinations of
514
+ prefix and suffix appropriate to the platform: "$name.o", "lib$name.*"
515
+ and "$name".
516
+
517
+ If any directories are included in @names they are searched before
518
+ @dl_library_path. Directories may be specified as B<-Ldir>. Any other
519
+ names are treated as filenames to be searched for.
520
+
521
+ Using arguments of the form C<-Ldir> and C<-lname> is recommended.
522
+
523
+ Example:
524
+
525
+ @dl_resolve_using = dl_findfile(qw(-L/usr/5lib -lposix));
526
+
527
+
528
+ =item dl_expandspec()
529
+
530
+ Syntax:
531
+
532
+ $filepath = dl_expandspec($spec)
533
+
534
+ Some unusual systems, such as VMS, require special filename handling in
535
+ order to deal with symbolic names for files (i.e., VMS's Logical Names).
536
+
537
+ To support these systems a dl_expandspec() function can be implemented
538
+ either in the F<dl_*.xs> file or code can be added to the dl_expandspec()
539
+ function in F<DynaLoader.pm>. See F<DynaLoader_pm.PL> for more information.
540
+
541
+ =item dl_load_file()
542
+
543
+ Syntax:
544
+
545
+ $libref = dl_load_file($filename, $flags)
546
+
547
+ Dynamically load $filename, which must be the path to a shared object
548
+ or library. An opaque 'library reference' is returned as a handle for
549
+ the loaded object. Returns undef on error.
550
+
551
+ The $flags argument to alters dl_load_file behaviour.
552
+ Assigned bits:
553
+
554
+ 0x01 make symbols available for linking later dl_load_file's.
555
+ (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
556
+ (ignored under VMS; this is a normal part of image linking)
557
+
558
+ (On systems that provide a handle for the loaded object such as SunOS
559
+ and HPUX, $libref will be that handle. On other systems $libref will
560
+ typically be $filename or a pointer to a buffer containing $filename.
561
+ The application should not examine or alter $libref in any way.)
562
+
563
+ This is the function that does the real work. It should use the
564
+ current values of @dl_require_symbols and @dl_resolve_using if required.
565
+
566
+ SunOS: dlopen($filename)
567
+ HP-UX: shl_load($filename)
568
+ Linux: dld_create_reference(@dl_require_symbols); dld_link($filename)
569
+ VMS: lib$find_image_symbol($filename,$dl_require_symbols[0])
570
+
571
+ (The dlopen() function is also used by Solaris and some versions of
572
+ Linux, and is a common choice when providing a "wrapper" on other
573
+ mechanisms as is done in the OS/2 port.)
574
+
575
+ =item dl_unload_file()
576
+
577
+ Syntax:
578
+
579
+ $status = dl_unload_file($libref)
580
+
581
+ Dynamically unload $libref, which must be an opaque 'library reference' as
582
+ returned from dl_load_file. Returns one on success and zero on failure.
583
+ This function is optional and may not necessarily be provided on all platforms.
584
+
585
+ If it is defined and perl is compiled with the C macro C<DL_UNLOAD_ALL_AT_EXIT>
586
+ defined, then it is called automatically when the interpreter exits for
587
+ every shared object or library loaded by DynaLoader::bootstrap. All such
588
+ library references are stored in @dl_librefs by DynaLoader::Bootstrap as it
589
+ loads the libraries. The files are unloaded in last-in, first-out order.
590
+
591
+ This unloading is usually necessary when embedding a shared-object perl (e.g.
592
+ one configured with -Duseshrplib) within a larger application, and the perl
593
+ interpreter is created and destroyed several times within the lifetime of the
594
+ application. In this case it is possible that the system dynamic linker will
595
+ unload and then subsequently reload the shared libperl without relocating any
596
+ references to it from any files DynaLoaded by the previous incarnation of the
597
+ interpreter. As a result, any shared objects opened by DynaLoader may point to
598
+ a now invalid 'ghost' of the libperl shared object, causing apparently random
599
+ memory corruption and crashes. This behaviour is most commonly seen when using
600
+ Apache and mod_perl built with the APXS mechanism.
601
+
602
+ SunOS: dlclose($libref)
603
+ HP-UX: ???
604
+ Linux: ???
605
+ VMS: ???
606
+
607
+ (The dlclose() function is also used by Solaris and some versions of
608
+ Linux, and is a common choice when providing a "wrapper" on other
609
+ mechanisms as is done in the OS/2 port.)
610
+
611
+ =item dl_load_flags()
612
+
613
+ Syntax:
614
+
615
+ $flags = dl_load_flags $modulename;
616
+
617
+ Designed to be a method call, and to be overridden by a derived class
618
+ (i.e. a class which has DynaLoader in its @ISA). The definition in
619
+ DynaLoader itself returns 0, which produces standard behavior from
620
+ dl_load_file().
621
+
622
+ =item dl_find_symbol()
623
+
624
+ Syntax:
625
+
626
+ $symref = dl_find_symbol($libref, $symbol)
627
+
628
+ Return the address of the symbol $symbol or C<undef> if not found. If the
629
+ target system has separate functions to search for symbols of different
630
+ types then dl_find_symbol() should search for function symbols first and
631
+ then other types.
632
+
633
+ The exact manner in which the address is returned in $symref is not
634
+ currently defined. The only initial requirement is that $symref can
635
+ be passed to, and understood by, dl_install_xsub().
636
+
637
+ SunOS: dlsym($libref, $symbol)
638
+ HP-UX: shl_findsym($libref, $symbol)
639
+ Linux: dld_get_func($symbol) and/or dld_get_symbol($symbol)
640
+ VMS: lib$find_image_symbol($libref,$symbol)
641
+
642
+
643
+ =item dl_find_symbol_anywhere()
644
+
645
+ Syntax:
646
+
647
+ $symref = dl_find_symbol_anywhere($symbol)
648
+
649
+ Applies dl_find_symbol() to the members of @dl_librefs and returns
650
+ the first match found.
651
+
652
+ =item dl_undef_symbols()
653
+
654
+ Example
655
+
656
+ @symbols = dl_undef_symbols()
657
+
658
+ Return a list of symbol names which remain undefined after load_file().
659
+ Returns C<()> if not known. Don't worry if your platform does not provide
660
+ a mechanism for this. Most do not need it and hence do not provide it,
661
+ they just return an empty list.
662
+
663
+
664
+ =item dl_install_xsub()
665
+
666
+ Syntax:
667
+
668
+ dl_install_xsub($perl_name, $symref [, $filename])
669
+
670
+ Create a new Perl external subroutine named $perl_name using $symref as
671
+ a pointer to the function which implements the routine. This is simply
672
+ a direct call to newXS()/newXS_flags(). Returns a reference to the installed
673
+ function.
674
+
675
+ The $filename parameter is used by Perl to identify the source file for
676
+ the function if required by die(), caller() or the debugger. If
677
+ $filename is not defined then "DynaLoader" will be used.
678
+
679
+
680
+ =item bootstrap()
681
+
682
+ Syntax:
683
+
684
+ bootstrap($module [...])
685
+
686
+ This is the normal entry point for automatic dynamic loading in Perl.
687
+
688
+ It performs the following actions:
689
+
690
+ =over 8
691
+
692
+ =item *
693
+
694
+ locates an auto/$module directory by searching @INC
695
+
696
+ =item *
697
+
698
+ uses dl_findfile() to determine the filename to load
699
+
700
+ =item *
701
+
702
+ sets @dl_require_symbols to C<("boot_$module")>
703
+
704
+ =item *
705
+
706
+ executes an F<auto/$module/$module.bs> file if it exists
707
+ (typically used to add to @dl_resolve_using any files which
708
+ are required to load the module on the current platform)
709
+
710
+ =item *
711
+
712
+ calls dl_load_flags() to determine how to load the file.
713
+
714
+ =item *
715
+
716
+ calls dl_load_file() to load the file
717
+
718
+ =item *
719
+
720
+ calls dl_undef_symbols() and warns if any symbols are undefined
721
+
722
+ =item *
723
+
724
+ calls dl_find_symbol() for "boot_$module"
725
+
726
+ =item *
727
+
728
+ calls dl_install_xsub() to install it as "${module}::bootstrap"
729
+
730
+ =item *
731
+
732
+ calls &{"${module}::bootstrap"} to bootstrap the module (actually
733
+ it uses the function reference returned by dl_install_xsub for speed)
734
+
735
+ =back
736
+
737
+ All arguments to bootstrap() are passed to the module's bootstrap function.
738
+ The default code generated by F<xsubpp> expects $module [, $version]
739
+ If the optional $version argument is not given, it defaults to
740
+ C<$XS_VERSION // $VERSION> in the module's symbol table. The default code
741
+ compares the Perl-space version with the version of the compiled XS code,
742
+ and croaks with an error if they do not match.
743
+
744
+ =back
745
+
746
+
747
+ =head1 AUTHOR
748
+
749
+ Tim Bunce, 11 August 1994.
750
+
751
+ This interface is based on the work and comments of (in no particular
752
+ order): Larry Wall, Robert Sanders, Dean Roehrich, Jeff Okamoto, Anno
753
+ Siegel, Thomas Neumann, Paul Marquess, Charles Bailey, myself and others.
754
+
755
+ Larry Wall designed the elegant inherited bootstrap mechanism and
756
+ implemented the first Perl 5 dynamic loader using it.
757
+
758
+ Solaris global loading added by Nick Ing-Simmons with design/coding
759
+ assistance from Tim Bunce, January 1996.
760
+
761
+ =cut