diff options
author | 2017-02-05 00:31:51 +0000 | |
---|---|---|
committer | 2017-02-05 00:31:51 +0000 | |
commit | b8851fcc53cbe24fd20b090f26dd149e353f6174 (patch) | |
tree | 4b7c1695865f00ab7a0da30b5632d514848ea3a2 /gnu/usr.bin/perl/cpan/Win32API-File | |
parent | Add option PCIVERBOSE. (diff) | |
download | wireguard-openbsd-b8851fcc53cbe24fd20b090f26dd149e353f6174.tar.xz wireguard-openbsd-b8851fcc53cbe24fd20b090f26dd149e353f6174.zip |
Fix merge issues, remove excess files - match perl-5.24.1 dist
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Win32API-File')
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/File.pm | 24 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/File.xs | 11 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/Makefile.PL | 386 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/buffers.h | 846 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/cFile.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/cFile.pc | 336 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/const2perl.h | 386 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/inc/ExtUtils/Myconst2perl.pm (renamed from gnu/usr.bin/perl/cpan/Win32API-File/ExtUtils/Myconst2perl.pm) | 724 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32API-File/t/file.t | 854 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32API-File/t/tie.t | 79 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32API-File/typemap | 280 |
11 files changed, 1955 insertions, 1973 deletions
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/File.pm b/gnu/usr.bin/perl/cpan/Win32API-File/File.pm index 03b736eb77a..10c5d2ff662 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/File.pm +++ b/gnu/usr.bin/perl/cpan/Win32API-File/File.pm @@ -10,7 +10,7 @@ use Fcntl qw( O_RDONLY O_RDWR O_WRONLY O_APPEND O_BINARY O_TEXT ); use vars qw( $VERSION @ISA ); use vars qw( @EXPORT @EXPORT_OK @EXPORT_FAIL %EXPORT_TAGS ); -$VERSION= '0.1201'; +$VERSION= '0.1203'; use base qw( Exporter DynaLoader Tie::Handle IO::File ); @@ -317,8 +317,8 @@ sub OsFHandleOpen { if ($@) { return tie *{$fh}, __PACKAGE__, $osfh; } - return undef if $fd < 0; - return open( $fh, $pref."&=".$fd ); + return undef unless $fd; + return open( $fh, $pref."&=".(0+$fd) ); } sub GetOsFHandle { @@ -946,7 +946,7 @@ This is a Perl-friendly wrapper around C<CreateFile>. On failure, C<$hObject> gets set to a false value and C<regLastError()> and C<$^E> are set to the reason for the failure. Otherwise, -C<$hObject> gets set to a Win32 native file handle which is alwasy +C<$hObject> gets set to a Win32 native file handle which is always a true value [returns C<"0 but true"> in the impossible(?) case of the handle having a value of C<0>]. @@ -1163,7 +1163,7 @@ indicate the type of access desired. C<GENERIC_READ> is the default. =item Create => $uCreate -C<$sCreate> should be a string constaing zero or one character from +C<$sCreate> should be a string containing zero or one character from C<"ktn"> and zero or one character from C<"ce">. These stand for "Keep if exists", "Truncate if exists", "New file only", "Create if none", and "Existing file only". These are translated into a @@ -1205,7 +1205,7 @@ Examples: =item C<@roots= getLogicalDrives()> Returns the paths to the root directories of all logical drives -currently defined. This includes all types of drive lettters, such +currently defined. This includes all types of drive letters, such as floppies, CD-ROMs, hard disks, and network shares. A typical return value on a poorly equipped computer would be C<("A:\\","C:\\")>. @@ -1229,7 +1229,7 @@ same file name. If C<$bFailIfExists> is true and C<$sNewFileName> is the path to a file that already exists, then C<CopyFile> will fail. If -C<$bFailIfExists> is falsea, then the copy of the C<$sOldFileNmae> +C<$bFailIfExists> is false, then the copy of the C<$sOldFileNmae> file will overwrite the C<$sNewFileName> file if it already exists. Like most routines, returns a true value if successful and a false @@ -1301,7 +1301,7 @@ on that partition. The raw floppy disk. Doesn't work under Windows 95. This allows you to read or write raw sectors of the floppy disk and to use C<DeviceIoControl> to perform miscellaneous queries and operations -to the floopy disk or drive. +to the floppy disk or drive. Locking this for exclusive access prevents all access to the floppy. @@ -1327,7 +1327,7 @@ If another process currently has read, write, and/or delete access to the file and you don't allow that level of sharing, then your call to C<CreateFile> will fail. If you requested read, write, and/or delete access and another process already has the file open but doesn't allow -that level of sharing, thenn your call to C<createFile> will fail. Once +that level of sharing, then your call to C<createFile> will fail. Once you have the file open, if another process tries to open it with read, write, and/or delete access and you don't allow that level of sharing, then that process won't be allowed to open the file. @@ -2197,7 +2197,7 @@ Only bits set in C<$uMask> will be modified by C<SetHandleInformation>. C<$uFlags> is an unsigned value having zero or more of the bits C<HANDLE_FLAG_INHERIT> and C<HANDLE_FLAG_PROTECT_FROM_CLOSE> set. -For each bit set in C<$uMask>, the cooresponding bit in the handle's +For each bit set in C<$uMask>, the corresponding bit in the handle's flags is set to the value of the corresponding bit in C<$uFlags>. If C<$uOldFlags> were the value of the handle's flags before the @@ -2673,7 +2673,7 @@ value for any partitions you wish to have changed, added, or deleted. Change the type of the partition. C<$opOutBuf> should be C<[]>. C<$pInBuf> should be a C<SET_PARTITION_INFORMATION> data structure -which is just a single byte containing the new parition type [see +which is just a single byte containing the new partition type [see the C<":PARTITION_"> export class for a list of known types]: $pInBuf= pack( "C", $uPartitionType ); @@ -2831,7 +2831,7 @@ driver of size C<$uLogBufferSize>: =item DISK_LOGGING_STOP -Stop loggin each disk request: +Stop logging each disk request: $pInBuf= pack( "C L L", 1, 0, 0 ); diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/File.xs b/gnu/usr.bin/perl/cpan/Win32API-File/File.xs index cff488f8a6f..83971d00002 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/File.xs +++ b/gnu/usr.bin/perl/cpan/Win32API-File/File.xs @@ -148,7 +148,7 @@ CreateFileA( sPath, uAccess, uShare, pSecAttr, uCreate, uFlags, hModel ) HANDLE hModel CODE: RETVAL= CreateFileA( sPath, uAccess, uShare, - pSecAttr, uCreate, uFlags, hModel ); + (LPSECURITY_ATTRIBUTES)pSecAttr, uCreate, uFlags, hModel ); if( INVALID_HANDLE_VALUE == RETVAL ) { SaveErr( 1 ); XSRETURN_NO; @@ -170,7 +170,7 @@ CreateFileW( swPath, uAccess, uShare, pSecAttr, uCreate, uFlags, hModel ) HANDLE hModel CODE: RETVAL= CreateFileW( swPath, uAccess, uShare, - pSecAttr, uCreate, uFlags, hModel ); + (LPSECURITY_ATTRIBUTES)pSecAttr, uCreate, uFlags, hModel ); if( INVALID_HANDLE_VALUE == RETVAL ) { SaveErr( 1 ); XSRETURN_NO; @@ -246,7 +246,7 @@ DeviceIoControl( hDevice, uIoControlCode, pInBuf, lInBuf, opOutBuf, lOutBuf, olR } grow_buf_l( opOutBuf,ST(4),char *, lOutBuf,ST(5) ); RETVAL= DeviceIoControl( hDevice, uIoControlCode, pInBuf, lInBuf, - opOutBuf, lOutBuf, &olRetBytes, pOverlapped ); + opOutBuf, lOutBuf, &olRetBytes, (LPOVERLAPPED)pOverlapped ); SaveErr( !RETVAL ); OUTPUT: RETVAL @@ -553,7 +553,8 @@ ReadFile( hFile, opBuffer, lBytes, olBytesRead, pOverlapped ) if( 0 == lBytes && autosize(ST(2)) ) { lBytes= SvLEN( ST(1) ) - 1; } - RETVAL= ReadFile( hFile, opBuffer, lBytes, &olBytesRead, pOverlapped ); + RETVAL= ReadFile( hFile, opBuffer, lBytes, &olBytesRead, + (LPOVERLAPPED)pOverlapped ); SaveErr( !RETVAL ); OUTPUT: RETVAL @@ -640,7 +641,7 @@ WriteFile( hFile, pBuffer, lBytes, ouBytesWritten, pOverlapped ) "Win32API::File::WriteFile", SvCUR(ST(1)), lBytes ); } RETVAL= WriteFile( hFile, pBuffer, lBytes, - &ouBytesWritten, pOverlapped ); + &ouBytesWritten, (LPOVERLAPPED)pOverlapped ); SaveErr( !RETVAL ); OUTPUT: RETVAL diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/Makefile.PL b/gnu/usr.bin/perl/cpan/Win32API-File/Makefile.PL index 4b5f959ac4f..b0a0dc04239 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/Makefile.PL +++ b/gnu/usr.bin/perl/cpan/Win32API-File/Makefile.PL @@ -1,193 +1,193 @@ -#!/usr/bin/perl -w -use 5.001; #not tested -use ExtUtils::MakeMaker; -use Config; -use strict; -# See lib/ExtUtils/MakeMaker.pm for details of how to influence -# the contents of the Makefile that is written. -unless ($^O eq "MSWin32" || $^O eq "cygwin" || $^O eq "interix") { #not tested on Interix - die "OS unsupported\n"; -} - -WriteMakefile1( - 'NAME' => 'Win32API::File', - 'VERSION_FROM' => 'File.pm', # finds $VERSION - ( $Config{archname} =~ /-object\b/i ? ( 'CAPI' => 'TRUE' ) : () ), - 'AUTHOR' => 'Tye McQueen <tye@metronet.com>', - 'ABSTRACT_FROM' => 'File.pm', - 'postamble' => { IMPORT_LIST => [qw(/._/ !/[a-z]/ :MEDIA_TYPE)], - IFDEF => "!/[a-z\\d]/", - CPLUSPLUS => 1, - WRITE_PERL => 1, - #PERL_FILE_LIST => ['File.pm'], #added by Chorny - #C_FILE_LIST => ['File.xs'], #added by Chorny - # Comment out next line to rebuild constants defs: - NO_REBUILD => 1, - }, - ( ! $Config{libperl} ? () : ( LIBPERL_A => $Config{libperl} ) ), - 'INSTALLDIRS' => (($] >= 5.008009 and $] < 5.012) ? 'perl' : 'site'), - 'LICENSE' => 'perl', - 'MIN_PERL_VERSION' => 5.001, - 'PREREQ_PM' => { - 'Math::BigInt' => 0, - 'Win32' => 0, - 'Carp' => 0, - 'IO::File' => 0, - }, - TEST_REQUIRES => { - 'File::Spec' => 0, - 'Test::More' => 0, - }, - - META_MERGE => { - resources => { - repository => 'http://github.com/chorny/Win32API-File', - }, - }, - $^O =~/win/i ? ( - dist => { - TAR => 'ptar', - TARFLAGS => '-c -C -f', - }, - ) : (), -); - -# Replacement for MakeMaker's "const2perl section" for versions -# of MakeMaker prior to the addition of this functionality: -sub MY::postamble -{ - my( $self, %attribs )= @_; - - # Don't do anything if MakeMaker has const2perl - # that already took care of all of this: - return unless %attribs; - - # Don't require these here if we just C<return> above: - eval "use ExtUtils::Myconst2perl qw(ParseAttribs); 1" or die "$@"; - eval "use ExtUtils::MakeMaker qw(neatvalue); 1" or die "$@"; - - # If only one module, can skip one level of indirection: - my $hvAttr= \%attribs; - if( $attribs{IMPORT_LIST} ) { - $hvAttr= { $self->{NAME} => \%attribs }; - } - - my( $module, @m, $_final, @clean, @realclean ); - foreach $module ( keys %$hvAttr ) { - my( $outfile, @perlfiles, @cfiles, $bin, $obj, $final, $noreb ); - - # Translate user-friendly options into coder-friendly specifics: - ParseAttribs( $module, $hvAttr->{$module}, { OUTFILE => \$outfile, - C_FILE_LIST => \@perlfiles, PERL_FILE_LIST => \@cfiles, - OBJECT => \$obj, BINARY => \$bin, FINAL_PERL => \$final, - NO_REBUILD => \$noreb } ); - die "IFDEF option in Makefile.PL must be string, not code ref.\n" - if ref $hvAttr->{$module}->{IFDEF}; - die qq{IFDEF option in Makefile.PL must not contain quotes (").\n} - if ref $hvAttr->{$module}->{IFDEF}; - - # How to create F<$outfile> via ExtUtils::Myconst2perl::Myconst2perl: - push @m, " -$outfile: @perlfiles @cfiles Makefile" . ' - $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Myconst2perl \\ - -e "my %attribs;" \\ - '; - $m[-1] =~ s/^/##/gm if $noreb; - my( $key, $value ); - while( ( $key, $value )= each %{$hvAttr->{$module}} ) { - push @m, '-e "$$attribs{' . $key . '}= ' # try {{ }} for dmake - . neatvalue($value) . qq[;" \\\n\t ]; - $m[-1] =~ s/^/##/gm if $noreb; - } - push @m, '-e "Myconst2perl(' . neatvalue($module) . ",%attribs)\"\n"; - - # If requested extra work to generate Perl instead of XS code: - if( $bin ) { - my @path= split /::/, $module; - my $_final= $final; - $_final =~ s/\W/_/g; - - # How to compile F<$outfile> and then run it to produce F<$final>: - push @m, " -$bin: $outfile" . ' - $(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(PERLTYPE) $(LARGE) \\ - $(SPLIT) $(DEFINE_VERSION) $(XS_DEFINE_VERSION) -I$(PERL_INC) \\ - $(DEFINE)' . $outfile . " " - . $self->catfile(qw[ $(PERL_INC) $(LIBPERL_A) ]) . " -o $bin - -$final: $bin - " . $self->catfile(".",$bin) . " >$final\n"; - $m[-1] =~ s/^/##/gm if $noreb; - - # Make sure the rarely-used $(INST_ARCHLIB) directory exists: - push @m, $self->dir_target('$(INST_ARCHLIB)'); - - ##warn qq{$path[-1].pm should C<require "}, - ## join("/",@path,$final), qq{">.\n}; - # Install F<$final> whenever regular pm_to_blib target is built: - push @m, " -pm_to_blib: ${_final}_to_blib - -${_final}_to_blib: $final - " . '@$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \\ - "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \\ - -e "pm_to_blib({ ',neatvalue($final),',', - neatvalue($self->catfile('$(INST_ARCHLIB)',@path,$final)), ' },', - neatvalue($self->catfile(qw[$(INST_LIB) auto])), ')" - @$(TOUCH) ', $_final, "_to_blib - -realclean :: - $self->{RM_RF} ", $self->catfile('$(INST_ARCHLIB)', $path[0]), "\n"; - - push( @clean, $outfile, $bin, $obj, $_final . "_to_blib" ); - push( @realclean, $final ) unless $noreb; - } else { - - ##my $name= ( split /::/, $module )[-1]; - ##warn qq{$name.xs should C<#include "$final"> }, - ## qq{in the C<BOOT:> section\n}; - push( @realclean, $outfile ) unless $noreb; - } - } - - push @m, " -clean :: - $self->{RM_F} @clean\n" if @clean; - push @m, " -realclean :: - $self->{RM_F} @realclean\n" if @realclean; - return join('',@m); -} - - -sub WriteMakefile1 { #Compatibility code for old versions of EU::MM. Written by Alexandr Ciornii, version 0.23. Added by eumm-upgrade. - my %params=@_; - my $eumm_version=$ExtUtils::MakeMaker::VERSION; - $eumm_version=eval $eumm_version; - die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; - die "License not specified" if not exists $params{LICENSE}; - if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' and $eumm_version < 6.5705) { - $params{META_ADD}->{author}=$params{AUTHOR}; - $params{AUTHOR}=join(', ',@{$params{AUTHOR}}); - } - if ($params{TEST_REQUIRES} and $eumm_version < 6.64) { - $params{BUILD_REQUIRES}={ %{$params{BUILD_REQUIRES} || {}} , %{$params{TEST_REQUIRES}} }; - delete $params{TEST_REQUIRES}; - } - if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { - #EUMM 6.5502 has problems with BUILD_REQUIRES - $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; - delete $params{BUILD_REQUIRES}; - } - delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; - delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; - delete $params{META_MERGE} if $eumm_version < 6.46; - delete $params{META_ADD} if $eumm_version < 6.46; - delete $params{LICENSE} if $eumm_version < 6.31; - delete $params{AUTHOR} if $] < 5.005; - delete $params{ABSTRACT_FROM} if $] < 5.005; - delete $params{BINARY_LOCATION} if $] < 5.005; - - WriteMakefile(%params); -} - +#!/usr/bin/perl -w
+use 5.001; #not tested
+use ExtUtils::MakeMaker;
+use Config;
+use strict;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+unless ($^O eq "MSWin32" || $^O eq "cygwin" || $^O eq "interix") { #not tested on Interix
+ die "OS unsupported\n";
+}
+
+WriteMakefile1(
+ 'NAME' => 'Win32API::File',
+ 'VERSION_FROM' => 'File.pm', # finds $VERSION
+ ( $Config{archname} =~ /-object\b/i ? ( 'CAPI' => 'TRUE' ) : () ),
+ 'AUTHOR' => 'Tye McQueen <tye@metronet.com>',
+ 'ABSTRACT_FROM' => 'File.pm',
+ 'postamble' => { IMPORT_LIST => [qw(/._/ !/[a-z]/ :MEDIA_TYPE)],
+ IFDEF => "!/[a-z\\d]/",
+ CPLUSPLUS => 1,
+ WRITE_PERL => 1,
+ #PERL_FILE_LIST => ['File.pm'], #added by Chorny
+ #C_FILE_LIST => ['File.xs'], #added by Chorny
+ # Comment out next line to rebuild constants defs:
+ NO_REBUILD => 1,
+ },
+ ( ! $Config{libperl} ? () : ( LIBPERL_A => $Config{libperl} ) ),
+ 'INSTALLDIRS' => (($] >= 5.008009 and $] < 5.012) ? 'perl' : 'site'),
+ 'LICENSE' => 'perl',
+ 'MIN_PERL_VERSION' => 5.001,
+ 'PREREQ_PM' => {
+ 'Math::BigInt' => 0,
+ 'Win32' => 0,
+ 'Carp' => 0,
+ 'IO::File' => 0,
+ },
+ TEST_REQUIRES => {
+ 'File::Spec' => 0,
+ 'Test::More' => 0,
+ },
+
+ META_MERGE => {
+ resources => {
+ repository => 'http://github.com/chorny/Win32API-File',
+ },
+ },
+ $^O =~/win/i ? (
+ dist => {
+ TAR => 'ptar',
+ TARFLAGS => '-c -C -f',
+ },
+ ) : (),
+);
+
+# Replacement for MakeMaker's "const2perl section" for versions
+# of MakeMaker prior to the addition of this functionality:
+sub MY::postamble
+{
+ my( $self, %attribs )= @_;
+
+ # Don't do anything if MakeMaker has const2perl
+ # that already took care of all of this:
+ return unless %attribs;
+
+ # Don't require these here if we just C<return> above:
+ eval "use lib 'inc'; use ExtUtils::Myconst2perl qw(ParseAttribs); 1" or die "$@";
+ eval "use ExtUtils::MakeMaker qw(neatvalue); 1" or die "$@";
+
+ # If only one module, can skip one level of indirection:
+ my $hvAttr= \%attribs;
+ if( $attribs{IMPORT_LIST} ) {
+ $hvAttr= { $self->{NAME} => \%attribs };
+ }
+
+ my( $module, @m, $_final, @clean, @realclean );
+ foreach $module ( keys %$hvAttr ) {
+ my( $outfile, @perlfiles, @cfiles, $bin, $obj, $final, $noreb );
+
+ # Translate user-friendly options into coder-friendly specifics:
+ ParseAttribs( $module, $hvAttr->{$module}, { OUTFILE => \$outfile,
+ C_FILE_LIST => \@perlfiles, PERL_FILE_LIST => \@cfiles,
+ OBJECT => \$obj, BINARY => \$bin, FINAL_PERL => \$final,
+ NO_REBUILD => \$noreb } );
+ die "IFDEF option in Makefile.PL must be string, not code ref.\n"
+ if ref $hvAttr->{$module}->{IFDEF};
+ die qq{IFDEF option in Makefile.PL must not contain quotes (").\n}
+ if ref $hvAttr->{$module}->{IFDEF};
+
+ # How to create F<$outfile> via ExtUtils::Myconst2perl::Myconst2perl:
+ push @m, "
+$outfile: @perlfiles @cfiles Makefile" . '
+ $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Myconst2perl \\
+ -e "my %attribs;" \\
+ ';
+ $m[-1] =~ s/^/##/gm if $noreb;
+ my( $key, $value );
+ while( ( $key, $value )= each %{$hvAttr->{$module}} ) {
+ push @m, '-e "$$attribs{' . $key . '}= ' # try {{ }} for dmake
+ . neatvalue($value) . qq[;" \\\n\t ];
+ $m[-1] =~ s/^/##/gm if $noreb;
+ }
+ push @m, '-e "Myconst2perl(' . neatvalue($module) . ",%attribs)\"\n";
+
+ # If requested extra work to generate Perl instead of XS code:
+ if( $bin ) {
+ my @path= split /::/, $module;
+ my $_final= $final;
+ $_final =~ s/\W/_/g;
+
+ # How to compile F<$outfile> and then run it to produce F<$final>:
+ push @m, "
+$bin: $outfile" . '
+ $(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(PERLTYPE) $(LARGE) \\
+ $(SPLIT) $(DEFINE_VERSION) $(XS_DEFINE_VERSION) -I$(PERL_INC) \\
+ $(DEFINE)' . $outfile . " "
+ . $self->catfile(qw[ $(PERL_INC) $(LIBPERL_A) ]) . " -o $bin
+
+$final: $bin
+ " . $self->catfile(".",$bin) . " >$final\n";
+ $m[-1] =~ s/^/##/gm if $noreb;
+
+ # Make sure the rarely-used $(INST_ARCHLIB) directory exists:
+ push @m, $self->dir_target('$(INST_ARCHLIB)');
+
+ ##warn qq{$path[-1].pm should C<require "},
+ ## join("/",@path,$final), qq{">.\n};
+ # Install F<$final> whenever regular pm_to_blib target is built:
+ push @m, "
+pm_to_blib: ${_final}_to_blib
+
+${_final}_to_blib: $final
+ " . '@$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \\
+ "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \\
+ -e "pm_to_blib({ ',neatvalue($final),',',
+ neatvalue($self->catfile('$(INST_ARCHLIB)',@path,$final)), ' },',
+ neatvalue($self->catfile(qw[$(INST_LIB) auto])), ')"
+ @$(TOUCH) ', $_final, "_to_blib
+
+realclean ::
+ $self->{RM_RF} ", $self->catfile('$(INST_ARCHLIB)', $path[0]), "\n";
+
+ push( @clean, $outfile, $bin, $obj, $_final . "_to_blib" );
+ push( @realclean, $final ) unless $noreb;
+ } else {
+
+ ##my $name= ( split /::/, $module )[-1];
+ ##warn qq{$name.xs should C<#include "$final"> },
+ ## qq{in the C<BOOT:> section\n};
+ push( @realclean, $outfile ) unless $noreb;
+ }
+ }
+
+ push @m, "
+clean ::
+ $self->{RM_F} @clean\n" if @clean;
+ push @m, "
+realclean ::
+ $self->{RM_F} @realclean\n" if @realclean;
+ return join('',@m);
+}
+
+
+sub WriteMakefile1 { #Compatibility code for old versions of EU::MM. Written by Alexandr Ciornii, version 0.23. Added by eumm-upgrade.
+ my %params=@_;
+ my $eumm_version=$ExtUtils::MakeMaker::VERSION;
+ $eumm_version=eval $eumm_version;
+ die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
+ die "License not specified" if not exists $params{LICENSE};
+ if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' and $eumm_version < 6.5705) {
+ $params{META_ADD}->{author}=$params{AUTHOR};
+ $params{AUTHOR}=join(', ',@{$params{AUTHOR}});
+ }
+ if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
+ $params{BUILD_REQUIRES}={ %{$params{BUILD_REQUIRES} || {}} , %{$params{TEST_REQUIRES}} };
+ delete $params{TEST_REQUIRES};
+ }
+ if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
+ #EUMM 6.5502 has problems with BUILD_REQUIRES
+ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
+ delete $params{BUILD_REQUIRES};
+ }
+ delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
+ delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
+ delete $params{META_MERGE} if $eumm_version < 6.46;
+ delete $params{META_ADD} if $eumm_version < 6.46;
+ delete $params{LICENSE} if $eumm_version < 6.31;
+ delete $params{AUTHOR} if $] < 5.005;
+ delete $params{ABSTRACT_FROM} if $] < 5.005;
+ delete $params{BINARY_LOCATION} if $] < 5.005;
+
+ WriteMakefile(%params);
+}
+
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/buffers.h b/gnu/usr.bin/perl/cpan/Win32API-File/buffers.h index cc114e5e58b..8877a16c1fa 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/buffers.h +++ b/gnu/usr.bin/perl/cpan/Win32API-File/buffers.h @@ -1,423 +1,423 @@ -/* buffers.h -- Version 1.11 */ - -/* The following abbreviations are used at start of parameter names - * to indicate the type of data: - * s string (char * or WCHAR *) [PV] - * sw wide string (WCHAR *) [PV] - * p pointer (usually to some structure) [PV] - * a array (packed array as in C) (usually of some structure) [PV] - * called a "vector" or "vect" in some places. - * n generic number [IV, UV, or NV] - * iv signed integral value [IV] - * u unsigned integral value [UV] - * d floating-point number (double) [NV] - * b boolean (bool) [IV] - * c count of items [UV] - * l length (in bytes) [UV] - * lw length in WCHARs [UV] - * h a handle [IV] - * r record (structure) [PV] - * sv Perl scalar (s, i, u, d, n, or rv) [SV] - * rv Perl reference (usually to scalar) [RV] - * hv reference to Perl hash [HV] - * av reference to Perl array [AV] - * cv Perl code reference [PVCV] - * - * Unusual combined types: - * pp single pointer (to non-Perl data) packed into string [PV] - * pap vector of pointers (to non-Perl data) packed into string [PV] - * - * Whether a parameter is for input data, output data, or both is usually - * not reflected by the data type prefix. In cases where this is not - * obvious nor reflected in the variable name proper, you can use - * the following in front of the data type prefix: - * i an input parameter given to API (usually omitted) - * o an Output parameter taken from API - * io Input given to API then overwritten with Output taken from API - */ - -/* Buffer arguments are usually followed by an argument (or two) specifying - * their size and/or returning the size of data written. The size can be - * measured in bytes ["lSize"] or in characters [for (char *) buffers such as - * for *A() routines, these sizes are also called "lSize", but are called - * "lwSize" for (WCHAR *) buffers, UNICODE strings, such as for *W() routines]. - * - * Before calling the actual C function, you must make sure the Perl variable - * actually has a big enough buffer allocated, and, if the user didn't want - * to specify a buffer size, set the buffer size to be correct. This is what - * the grow_*() macros are for. They also handle special meanings of the - * buffer size argument [described below]. - * - * Once the actual C function returns, you must set the Perl variable to know - * the size of the written data. This is what the trunc_*() macros are for. - * - * The size sometimes does and sometimes doesn't include the trailing '\0' - * [or L'\0'], so we always add or subtract 1 in the appropriate places so - * we don't care about this detail. - * - * A call may 1) request a pointer to the buffer size which means that - * the buffer size will be overwritten with the size of the data written; - * 2) have an extra argument which is a pointer to the place to write the - * size of the written data; 3) provide the size of the written data in - * the function's return value; 4) format the data so that the length - * can be determined by examining the data [such as with '\0'-terminated - * strings]; or 5) write fixed-length data [usually sizeof(STRUCT)]. - * This obviously determines what you should use in the trunc_*() macro - # to specify the size of the output value. - * - * The user can pass in an empty list reference, C<[]>, to indicate C<NULL> - * for the pointer to the buffer which means that they don't want that data. - * - * The user can pass in C<[]> or C<0> to indicate that they don't care about - * the buffer size [we aren't programming in C here, after all] and just try - * to get the data. This will work if either the buffer already allocated for - * the SV [scalar value] is large enough to hold the data or the API provides - * an easy way to determine the required size [and the XS code uses it]. - * - * If the user passes in a numeric value for a buffer size, then the XS - * code makes sure that the buffer is at least large enough to hold a value - * of that size and then passes in how large the buffer is. So the buffer - * size passed to the API call is the larger of the size requested by the - * user and the size of the buffer aleady allocated to the SV. - * - * The user can also pass in a string consisting of a leading "=" followed - * by digits for a buffer size. This means just use the size specified after - * the equals sign, even if the allocated buffer is larger. The XS code will - * still allocate a large enough buffer before the first call. - * - * If the function is nice enough to tell us that a buffer was too small - * [usually via ERROR_MORE_DATA] _and_ how large the buffer needs to be, - * then the XS code should enlarge the buffer(s) and repeat the call [once]. - * This resizing is _not_ done for buffers whose size was specified with a - * leading "=". - * - * Only grow_buf() and perhaps trunc_buf() can be used in a typemap file. - * The other macros would be used in the parameter declarations or INPUT: - * section [grow_*()], the INIT: section [init_*()], or the OUTPUT: section - * [trunc_*()]. - * - * Buffer arguments should be initialised with C<= NO_INIT> [or C<= NULL;>]. - * - * See also the F<typemap> file. C<oDWORD>, for example, is for an output- - * only parameter of type C<DWORD> and you should simply C<#define> it to be - * C<DWORD>. In F<typemap>, C<oDWORD> is treated differently than C<DWORD> - * in two ways. - * - * First, if C<undef> is passed in, a C<DWORD> could generate a warning - * when it gets converted to 0 while C<oDWORD> will never generate such a - * warning for C<undef>. This first difference doesn't apply if specific - * initialization is specified for the variable, as in C<= init_buf_l($var);>. - * In particular, the init_*() macros also convert C<undef> to 0 without - * ever producing a warning. - * - * Second, passing in a read-only SV for a C<oDWORD> parameter will generate - * a fatal error on output when we try to update the SV. For C<DWORD>, we - * won't update a read-only SV since passing in a literal constant for a - * buffer size is a useful thing to do even though it prevents us from - * returning the size of data written via that SV. Since we should use a - * trunc_*() macro to output the actual data, the user should be able to - * determine the size of data written based on the size of the scalar we - * output anyway. - * - * This second difference doesn't apply unless the parameter is listed in - * the OUTPUT: section without specific output instructions. We define - * no macros for outputting buffer length parameters so be careful to use - * C<oDWORD> [for example] for them if and only if they are output-only. - * - * Note that C<oDWORD> is the same as C<DWORD> in that, if a defined value - * is passed in, it is used [and can generate a warning if the value is - * "not numeric"]. So although C<oDWORD> is for output-only parameters, - * we still initialize the C variable before calling the API. This is good - * in case the parameter isn't always strictly output-only due to upgrades, - * bugs, etc. - * - * Here is a made-up example that shows several cases: - * - * # Actual GetDataW() returns length of data written to ioswName, not bool. - * bool - * GetDataW( ioswName, ilwName, oswText, iolwText, opJunk, opRec, ilRec, olRec ) - * WCHAR * ioswName = NO_INIT - * DWORD ilwName = NO_INIT - * WCHAR * oswText = NO_INIT - * DWORD &iolwText = init_buf_l($arg); - * void * opJunk = NO_INIT - * BYTE * opRec = NO_INIT - * DWORD ilRec = init_buf_l($arg); - * oDWORD &olRec - * PREINIT: - * DWORD olwName; - * INIT: - * grow_buf_lw( ioswName,ST(0), ilwName,ST(1) ); - * grow_buf_lw( oswText,ST(2), iolwText,ST(3) ); - * grow_buf_typ( opJunk,ST(4),void *, LONG_STRUCT_TYPEDEF ); - * grow_buf_l( opRec,ST(5),BYTE *, ilRec,ST(6) ); - * CODE: - * olwName= GetDataW( ioswName, ilwName, oswText, &iolwText, - * (LONG_STRUCT_TYPEDEF *)opJunk, opRec, &iolRec ); - * if( 0 == olwName && ERROR_MORE_DATA == GetLastError() - * && ( autosize(ST(1)) || autosize(ST(3)) || autosize(ST(6)) ) ) { - * if( autosize(ST(1)) ) - * grow_buf_lw( ioswName,ST(0), ilwName,ST(1) ); - * if( autosize(ST(3)) ) - * grow_buf_lw( oswText,ST(2), iolwText,ST(3) ); - * if( autosize(ST(6)) ) - * grow_buf_l( opRec,ST(5),BYTE *, iolRec,ST(6) ); - * olwName= GetDataW( ioswName, ilwName, oswText, &iolwText, - * (LONG_STRUCT_TYPEDEF *)opJunk, opRec, &iolRec ); - * } - * RETVAL= 0 != olwName; - * OUTPUT: - * RETVAL - * ioswName trunc_buf_lw( RETVAL, ioswName,ST(0), olwName ); - * oswText trunc_buf_lw( RETVAL, oswText,ST(2), iolwText ); - * iolwText - * opJunk trunc_buf_typ(RETVAL,opJunk,ST(4),LONG_STRUCT_TYPEDEF); - * opRec trunc_buf_l( RETVAL, opRec,ST(5), olRec ); - * olRec - * - * The above example would be more complex and less efficient if we used - * C<DWORD * iolwText> in place of C<DWORD &iolwText>. The only possible - * advantage would be that C<NULL> would be passed in for C<iolwText> if - * _both_ C<$oswText> and C<$iolwText> were specified as C<[]>. The *_pl*() - * macros are defined [and C<DWORD *> specified in F<typemap>] so we can - * handle those cases but it is usually better to use the *_l*() macros - * instead by specifying C<&> instead of C<*>. Using C<&> instead of C<*> - * is usually better when dealing with scalars, even if they aren't buffer - * sizes. But you must use C<*> if it is important for that parameter to - * be able to pass C<NULL> to the underlying API. - * - * In Win32API::, we try to use C<*> for buffer sizes of optional buffers - * and C<&> for buffer sizes of required buffers. - * - * For parameters that are pointers to things other than buffers or buffer - * sizes, we use C<*> for "important" parameters [so that using C<[]> - * generates an error rather than fetching the value and just throwing it - * away], and for optional parameters [in case specifying C<NULL> is or - * becomes important]. Otherwise we use C<&> [for "unimportant" but - * required parameters] so the user can specify C<[]> if they don't care - * about it. The output handle of an "open" routine is "important". - */ - -#ifndef Debug -# define Debug(list) /*Nothing*/ -#endif - -/*#ifndef CAST - *# ifdef __cplusplus - *# define CAST(type,expr) static_cast<type>(expr) - *# else*/ -# define CAST(type,expr) (type)(expr) -/*# endif - *#endif*/ - -/* Is an argument C<[]>, meaning we should pass C<NULL>? */ -#define null_arg(sv) ( SvROK(sv) && SVt_PVAV == SvTYPE(SvRV(sv)) \ - && -1 == av_len((AV*)SvRV(sv)) ) - -#define PV_or_null(sv) ( null_arg(sv) ? NULL : SvPV_nolen(sv) ) - -/* Minimum buffer size to use when no buffer existed: */ -#define MIN_GROW_SIZE 128 - -#ifdef Debug -/* Used in Debug() messages to show which macro call is involved: */ -#define string(arg) #arg -#endif - -/* Simplify using SvGROW() for byte-sized buffers: */ -#define lSvGROW(sv,n) SvGROW( sv, 0==(n) ? MIN_GROW_SIZE : (n)+1 ) - -/* Simplify using SvGROW() for WCHAR-sized buffers: */ -#define lwSvGROW(sv,n) CAST( WCHAR *, \ - SvGROW( sv, sizeof(WCHAR)*( 0==(n) ? MIN_GROW_SIZE : (n)+1 ) ) ) - -/* Whether the buffer size we got lets us change what buffer size we use: */ -#define autosize(sv) (!( SvOK(sv) && ! SvROK(sv) \ - && SvPV_nolen(sv) && '=' == *SvPV_nolen(sv) )) - -/* Get the IV/UV for a parameter that might be C<[]> or C<undef>: */ -#define optIV(sv) ( null_arg(sv) ? 0 : !SvOK(sv) ? 0 : SvIV(sv) ) -#define optUV(sv) ( null_arg(sv) ? 0 : !SvOK(sv) ? 0 : SvUV(sv) ) - -/* Allocate temporary storage that will automatically be freed later: */ -#ifndef TempAlloc /* Can be C<#define>d to be C<_alloca>, for example */ -# define TempAlloc( size ) sv_grow( sv_newmortal(), size ) -#endif - -/* Initialize a buffer size argument of type (DWORD *): */ -#define init_buf_pl( plSize, svSize, tpSize ) STMT_START { \ - if( null_arg(svSize) ) \ - plSize= NULL; \ - else { \ - STRLEN n_a; \ - *( plSize= CAST( tpSize, TempAlloc(sizeof(*plSize)) ) )= \ - autosize(svSize) ? optUV(svSize) \ - : strtoul( 1+SvPV(svSize,n_a), NULL, 10 ); \ - } } STMT_END -/* In INPUT section put ": init_buf_pl($var,$arg,$type);" after var name. */ - -/* Initialize a buffer size argument of type DWORD: */ -#define init_buf_l( svSize ) \ - ( null_arg(svSize) ? 0 : autosize(svSize) ? optUV(svSize) \ - : strtoul( 1+SvPV_nolen(svSize), NULL, 10 ) ) -/* In INPUT section put "= init_buf_l($arg);" after variable name. */ - -/* Lengths in WCHARs are initialized the same as lengths in bytes: */ -#define init_buf_plw init_buf_pl -#define init_buf_lw init_buf_l - -/* grow_buf_pl() and grow_buf_plw() are included so you can define - * parameters of type C<DWORD *>, for example. In practice, it is - * usually better to define such parameters as "DWORD &". */ - -/* Grow a buffer where we have a pointer to its size in bytes: */ -#define grow_buf_pl( sBuf,svBuf,tpBuf, plSize,svSize,tpSize ) STMT_START { \ - Debug(("grow_buf_pl( %s==0x%lX,[%s:%ld/%ld, %s==0x%lX:%ld,[%s )\n",\ - string(sBuf),sBuf,strchr(string(svBuf),'('),SvPOK(svBuf)? \ - SvCUR(svBuf):-1,SvPOK(svBuf)?SvLEN(svBuf):-1,string(plSize), \ - plSize,plSize?*plSize:-1,strchr(string(svSize),'('))); \ - if( null_arg(svBuf) ) { \ - sBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( NULL == plSize ) \ - *( plSize= CAST(tpSize,TempAlloc(sizeof(*plSize))) )= 0;\ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - sBuf= CAST( tpBuf, lSvGROW( svBuf, *plSize ) ); \ - if( autosize(svSize) ) *plSize= SvLEN(svBuf) - 1; \ - Debug(("more buf_pl( %s==0x%lX,[%s:%ld/%ld, %s==0x%lX:%ld,[%s )\n",\ - string(sBuf),sBuf,strchr(string(svBuf),'('),SvPOK(svBuf)? \ - SvCUR(svBuf):-1,SvPOK(svBuf)?SvLEN(svBuf):-1,string(plSize),\ - plSize,plSize?*plSize:-1,strchr(string(svSize),'('))); \ - } } STMT_END - -/* Grow a buffer where we have a pointer to its size in WCHARs: */ -#define grow_buf_plw( sBuf,svBuf, plwSize,svSize,tpSize ) STMT_START { \ - if( null_arg(svBuf) ) { \ - sBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( NULL == plwSize ) \ - *( plwSize= CAST(tpSize,TempAlloc(sizeof(*plwSize))) )= 0;\ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - sBuf= lwSvGROW( svBuf, *plwSize ); \ - if( autosize(svSize) ) \ - *plwSize= SvLEN(svBuf)/sizeof(WCHAR) - 1; \ - } } STMT_END - -/* Grow a buffer where we have its size in bytes: */ -#define grow_buf_l( sBuf,svBuf,tpBuf, lSize,svSize ) STMT_START { \ - if( null_arg(svBuf) ) { \ - sBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - sBuf= CAST( tpBuf, lSvGROW( svBuf, lSize ) ); \ - if( autosize(svSize) ) lSize= SvLEN(svBuf) - 1; \ - } } STMT_END - -/* Grow a buffer where we have its size in WCHARs: */ -#define grow_buf_lw( swBuf,svBuf, lwSize,svSize ) STMT_START { \ - if( null_arg(svBuf) ) { \ - swBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - swBuf= lwSvGROW( svBuf, lwSize ); \ - if( autosize(svSize) ) \ - lwSize= SvLEN(svBuf)/sizeof(WCHAR) - 1; \ - } } STMT_END - -/* Grow a buffer that contains the declared fixed data type: */ -#define grow_buf( pBuf,svBuf, tpBuf ) STMT_START { \ - if( null_arg(svBuf) ) { \ - pBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(*pBuf) ) ); \ - } } STMT_END - -/* Grow a buffer that contains a fixed data type other than that declared: */ -#define grow_buf_typ( pBuf,svBuf,tpBuf, Type ) STMT_START { \ - if( null_arg(svBuf) ) { \ - pBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(Type) ) ); \ - } } STMT_END - -/* Grow a buffer that contains a list of items of the declared data type: */ -#define grow_vect( pBuf,svBuf,tpBuf, cItems ) STMT_START { \ - if( null_arg(svBuf) ) { \ - pBuf= NULL; \ - } else { \ - STRLEN n_a; \ - if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \ - (void) SvPV_force( svBuf, n_a ); \ - pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(*pBuf)*cItems ) ); \ - } } STMT_END - -/* If call succeeded, set data length to returned length (in bytes): */ -#define trunc_buf_l( bOkay, sBuf,svBuf, lSize ) STMT_START { \ - if( bOkay && NULL != sBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, lSize ); \ - } } STMT_END - -/* Same as above except we have a pointer to the returned length: */ -#define trunc_buf_pl( bOkay, sBuf,svBuf, plSize ) \ - trunc_buf_l( bOkay, sBuf,svBuf, *plSize ) - -/* If call succeeded, set data length to returned length (in WCHARs): */ -#define trunc_buf_lw( bOkay, sBuf,svBuf, lwSize ) STMT_START { \ - if( bOkay && NULL != sBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, (lwSize)*sizeof(WCHAR) ); \ - } } STMT_END - -/* Same as above except we have a pointer to the returned length: */ -#define trunc_buf_plw( bOkay, swBuf,svBuf, plwSize ) \ - trunc_buf_lw( bOkay, swBuf,svBuf, *plwSize ) - -/* Set data length for a buffer that contains the declared fixed data type: */ -#define trunc_buf( bOkay, pBuf,svBuf ) STMT_START { \ - if( bOkay && NULL != pBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, sizeof(*pBuf) ); \ - } } STMT_END - -/* Set data length for a buffer that contains some other fixed data type: */ -#define trunc_buf_typ( bOkay, pBuf,svBuf, Type ) STMT_START { \ - if( bOkay && NULL != pBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, sizeof(Type) ); \ - } } STMT_END - -/* Set length for buffer that contains list of items of the declared type: */ -#define trunc_vect( bOkay, pBuf,svBuf, cItems ) STMT_START { \ - if( bOkay && NULL != pBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, sizeof(*pBuf)*cItems ); \ - } } STMT_END - -/* Set data length for a buffer where a '\0'-terminate string was stored: */ -#define trunc_buf_z( bOkay, sBuf,svBuf ) STMT_START { \ - if( bOkay && NULL != sBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, strlen(sBuf) ); \ - } } STMT_END - -/* Set data length for a buffer where a L'\0'-terminate string was stored: */ -#define trunc_buf_zw( bOkay, sBuf,svBuf ) STMT_START { \ - if( bOkay && NULL != sBuf ) { \ - SvPOK_only( svBuf ); \ - SvCUR_set( svBuf, wcslen(sBuf)*sizeof(WCHAR) ); \ - } } STMT_END +/* buffers.h -- Version 1.11 */
+
+/* The following abbreviations are used at start of parameter names
+ * to indicate the type of data:
+ * s string (char * or WCHAR *) [PV]
+ * sw wide string (WCHAR *) [PV]
+ * p pointer (usually to some structure) [PV]
+ * a array (packed array as in C) (usually of some structure) [PV]
+ * called a "vector" or "vect" in some places.
+ * n generic number [IV, UV, or NV]
+ * iv signed integral value [IV]
+ * u unsigned integral value [UV]
+ * d floating-point number (double) [NV]
+ * b boolean (bool) [IV]
+ * c count of items [UV]
+ * l length (in bytes) [UV]
+ * lw length in WCHARs [UV]
+ * h a handle [IV]
+ * r record (structure) [PV]
+ * sv Perl scalar (s, i, u, d, n, or rv) [SV]
+ * rv Perl reference (usually to scalar) [RV]
+ * hv reference to Perl hash [HV]
+ * av reference to Perl array [AV]
+ * cv Perl code reference [PVCV]
+ *
+ * Unusual combined types:
+ * pp single pointer (to non-Perl data) packed into string [PV]
+ * pap vector of pointers (to non-Perl data) packed into string [PV]
+ *
+ * Whether a parameter is for input data, output data, or both is usually
+ * not reflected by the data type prefix. In cases where this is not
+ * obvious nor reflected in the variable name proper, you can use
+ * the following in front of the data type prefix:
+ * i an input parameter given to API (usually omitted)
+ * o an Output parameter taken from API
+ * io Input given to API then overwritten with Output taken from API
+ */
+
+/* Buffer arguments are usually followed by an argument (or two) specifying
+ * their size and/or returning the size of data written. The size can be
+ * measured in bytes ["lSize"] or in characters [for (char *) buffers such as
+ * for *A() routines, these sizes are also called "lSize", but are called
+ * "lwSize" for (WCHAR *) buffers, UNICODE strings, such as for *W() routines].
+ *
+ * Before calling the actual C function, you must make sure the Perl variable
+ * actually has a big enough buffer allocated, and, if the user didn't want
+ * to specify a buffer size, set the buffer size to be correct. This is what
+ * the grow_*() macros are for. They also handle special meanings of the
+ * buffer size argument [described below].
+ *
+ * Once the actual C function returns, you must set the Perl variable to know
+ * the size of the written data. This is what the trunc_*() macros are for.
+ *
+ * The size sometimes does and sometimes doesn't include the trailing '\0'
+ * [or L'\0'], so we always add or subtract 1 in the appropriate places so
+ * we don't care about this detail.
+ *
+ * A call may 1) request a pointer to the buffer size which means that
+ * the buffer size will be overwritten with the size of the data written;
+ * 2) have an extra argument which is a pointer to the place to write the
+ * size of the written data; 3) provide the size of the written data in
+ * the function's return value; 4) format the data so that the length
+ * can be determined by examining the data [such as with '\0'-terminated
+ * strings]; or 5) write fixed-length data [usually sizeof(STRUCT)].
+ * This obviously determines what you should use in the trunc_*() macro
+ # to specify the size of the output value.
+ *
+ * The user can pass in an empty list reference, C<[]>, to indicate C<NULL>
+ * for the pointer to the buffer which means that they don't want that data.
+ *
+ * The user can pass in C<[]> or C<0> to indicate that they don't care about
+ * the buffer size [we aren't programming in C here, after all] and just try
+ * to get the data. This will work if either the buffer already allocated for
+ * the SV [scalar value] is large enough to hold the data or the API provides
+ * an easy way to determine the required size [and the XS code uses it].
+ *
+ * If the user passes in a numeric value for a buffer size, then the XS
+ * code makes sure that the buffer is at least large enough to hold a value
+ * of that size and then passes in how large the buffer is. So the buffer
+ * size passed to the API call is the larger of the size requested by the
+ * user and the size of the buffer already allocated to the SV.
+ *
+ * The user can also pass in a string consisting of a leading "=" followed
+ * by digits for a buffer size. This means just use the size specified after
+ * the equals sign, even if the allocated buffer is larger. The XS code will
+ * still allocate a large enough buffer before the first call.
+ *
+ * If the function is nice enough to tell us that a buffer was too small
+ * [usually via ERROR_MORE_DATA] _and_ how large the buffer needs to be,
+ * then the XS code should enlarge the buffer(s) and repeat the call [once].
+ * This resizing is _not_ done for buffers whose size was specified with a
+ * leading "=".
+ *
+ * Only grow_buf() and perhaps trunc_buf() can be used in a typemap file.
+ * The other macros would be used in the parameter declarations or INPUT:
+ * section [grow_*()], the INIT: section [init_*()], or the OUTPUT: section
+ * [trunc_*()].
+ *
+ * Buffer arguments should be initialised with C<= NO_INIT> [or C<= NULL;>].
+ *
+ * See also the F<typemap> file. C<oDWORD>, for example, is for an output-
+ * only parameter of type C<DWORD> and you should simply C<#define> it to be
+ * C<DWORD>. In F<typemap>, C<oDWORD> is treated differently than C<DWORD>
+ * in two ways.
+ *
+ * First, if C<undef> is passed in, a C<DWORD> could generate a warning
+ * when it gets converted to 0 while C<oDWORD> will never generate such a
+ * warning for C<undef>. This first difference doesn't apply if specific
+ * initialization is specified for the variable, as in C<= init_buf_l($var);>.
+ * In particular, the init_*() macros also convert C<undef> to 0 without
+ * ever producing a warning.
+ *
+ * Second, passing in a read-only SV for a C<oDWORD> parameter will generate
+ * a fatal error on output when we try to update the SV. For C<DWORD>, we
+ * won't update a read-only SV since passing in a literal constant for a
+ * buffer size is a useful thing to do even though it prevents us from
+ * returning the size of data written via that SV. Since we should use a
+ * trunc_*() macro to output the actual data, the user should be able to
+ * determine the size of data written based on the size of the scalar we
+ * output anyway.
+ *
+ * This second difference doesn't apply unless the parameter is listed in
+ * the OUTPUT: section without specific output instructions. We define
+ * no macros for outputting buffer length parameters so be careful to use
+ * C<oDWORD> [for example] for them if and only if they are output-only.
+ *
+ * Note that C<oDWORD> is the same as C<DWORD> in that, if a defined value
+ * is passed in, it is used [and can generate a warning if the value is
+ * "not numeric"]. So although C<oDWORD> is for output-only parameters,
+ * we still initialize the C variable before calling the API. This is good
+ * in case the parameter isn't always strictly output-only due to upgrades,
+ * bugs, etc.
+ *
+ * Here is a made-up example that shows several cases:
+ *
+ * # Actual GetDataW() returns length of data written to ioswName, not bool.
+ * bool
+ * GetDataW( ioswName, ilwName, oswText, iolwText, opJunk, opRec, ilRec, olRec )
+ * WCHAR * ioswName = NO_INIT
+ * DWORD ilwName = NO_INIT
+ * WCHAR * oswText = NO_INIT
+ * DWORD &iolwText = init_buf_l($arg);
+ * void * opJunk = NO_INIT
+ * BYTE * opRec = NO_INIT
+ * DWORD ilRec = init_buf_l($arg);
+ * oDWORD &olRec
+ * PREINIT:
+ * DWORD olwName;
+ * INIT:
+ * grow_buf_lw( ioswName,ST(0), ilwName,ST(1) );
+ * grow_buf_lw( oswText,ST(2), iolwText,ST(3) );
+ * grow_buf_typ( opJunk,ST(4),void *, LONG_STRUCT_TYPEDEF );
+ * grow_buf_l( opRec,ST(5),BYTE *, ilRec,ST(6) );
+ * CODE:
+ * olwName= GetDataW( ioswName, ilwName, oswText, &iolwText,
+ * (LONG_STRUCT_TYPEDEF *)opJunk, opRec, &iolRec );
+ * if( 0 == olwName && ERROR_MORE_DATA == GetLastError()
+ * && ( autosize(ST(1)) || autosize(ST(3)) || autosize(ST(6)) ) ) {
+ * if( autosize(ST(1)) )
+ * grow_buf_lw( ioswName,ST(0), ilwName,ST(1) );
+ * if( autosize(ST(3)) )
+ * grow_buf_lw( oswText,ST(2), iolwText,ST(3) );
+ * if( autosize(ST(6)) )
+ * grow_buf_l( opRec,ST(5),BYTE *, iolRec,ST(6) );
+ * olwName= GetDataW( ioswName, ilwName, oswText, &iolwText,
+ * (LONG_STRUCT_TYPEDEF *)opJunk, opRec, &iolRec );
+ * }
+ * RETVAL= 0 != olwName;
+ * OUTPUT:
+ * RETVAL
+ * ioswName trunc_buf_lw( RETVAL, ioswName,ST(0), olwName );
+ * oswText trunc_buf_lw( RETVAL, oswText,ST(2), iolwText );
+ * iolwText
+ * opJunk trunc_buf_typ(RETVAL,opJunk,ST(4),LONG_STRUCT_TYPEDEF);
+ * opRec trunc_buf_l( RETVAL, opRec,ST(5), olRec );
+ * olRec
+ *
+ * The above example would be more complex and less efficient if we used
+ * C<DWORD * iolwText> in place of C<DWORD &iolwText>. The only possible
+ * advantage would be that C<NULL> would be passed in for C<iolwText> if
+ * _both_ C<$oswText> and C<$iolwText> were specified as C<[]>. The *_pl*()
+ * macros are defined [and C<DWORD *> specified in F<typemap>] so we can
+ * handle those cases but it is usually better to use the *_l*() macros
+ * instead by specifying C<&> instead of C<*>. Using C<&> instead of C<*>
+ * is usually better when dealing with scalars, even if they aren't buffer
+ * sizes. But you must use C<*> if it is important for that parameter to
+ * be able to pass C<NULL> to the underlying API.
+ *
+ * In Win32API::, we try to use C<*> for buffer sizes of optional buffers
+ * and C<&> for buffer sizes of required buffers.
+ *
+ * For parameters that are pointers to things other than buffers or buffer
+ * sizes, we use C<*> for "important" parameters [so that using C<[]>
+ * generates an error rather than fetching the value and just throwing it
+ * away], and for optional parameters [in case specifying C<NULL> is or
+ * becomes important]. Otherwise we use C<&> [for "unimportant" but
+ * required parameters] so the user can specify C<[]> if they don't care
+ * about it. The output handle of an "open" routine is "important".
+ */
+
+#ifndef Debug
+# define Debug(list) /*Nothing*/
+#endif
+
+/*#ifndef CAST
+ *# ifdef __cplusplus
+ *# define CAST(type,expr) static_cast<type>(expr)
+ *# else*/
+# define CAST(type,expr) (type)(expr)
+/*# endif
+ *#endif*/
+
+/* Is an argument C<[]>, meaning we should pass C<NULL>? */
+#define null_arg(sv) ( SvROK(sv) && SVt_PVAV == SvTYPE(SvRV(sv)) \
+ && -1 == av_len((AV*)SvRV(sv)) )
+
+#define PV_or_null(sv) ( null_arg(sv) ? NULL : SvPV_nolen(sv) )
+
+/* Minimum buffer size to use when no buffer existed: */
+#define MIN_GROW_SIZE 128
+
+#ifdef Debug
+/* Used in Debug() messages to show which macro call is involved: */
+#define string(arg) #arg
+#endif
+
+/* Simplify using SvGROW() for byte-sized buffers: */
+#define lSvGROW(sv,n) SvGROW( sv, 0==(n) ? MIN_GROW_SIZE : (n)+1 )
+
+/* Simplify using SvGROW() for WCHAR-sized buffers: */
+#define lwSvGROW(sv,n) CAST( WCHAR *, \
+ SvGROW( sv, sizeof(WCHAR)*( 0==(n) ? MIN_GROW_SIZE : (n)+1 ) ) )
+
+/* Whether the buffer size we got lets us change what buffer size we use: */
+#define autosize(sv) (!( SvOK(sv) && ! SvROK(sv) \
+ && SvPV_nolen(sv) && '=' == *SvPV_nolen(sv) ))
+
+/* Get the IV/UV for a parameter that might be C<[]> or C<undef>: */
+#define optIV(sv) ( null_arg(sv) ? 0 : !SvOK(sv) ? 0 : SvIV(sv) )
+#define optUV(sv) ( null_arg(sv) ? 0 : !SvOK(sv) ? 0 : SvUV(sv) )
+
+/* Allocate temporary storage that will automatically be freed later: */
+#ifndef TempAlloc /* Can be C<#define>d to be C<_alloca>, for example */
+# define TempAlloc( size ) sv_grow( sv_newmortal(), size )
+#endif
+
+/* Initialize a buffer size argument of type (DWORD *): */
+#define init_buf_pl( plSize, svSize, tpSize ) STMT_START { \
+ if( null_arg(svSize) ) \
+ plSize= NULL; \
+ else { \
+ STRLEN n_a; \
+ *( plSize= CAST( tpSize, TempAlloc(sizeof(*plSize)) ) )= \
+ autosize(svSize) ? optUV(svSize) \
+ : strtoul( 1+SvPV(svSize,n_a), NULL, 10 ); \
+ } } STMT_END
+/* In INPUT section put ": init_buf_pl($var,$arg,$type);" after var name. */
+
+/* Initialize a buffer size argument of type DWORD: */
+#define init_buf_l( svSize ) \
+ ( null_arg(svSize) ? 0 : autosize(svSize) ? optUV(svSize) \
+ : strtoul( 1+SvPV_nolen(svSize), NULL, 10 ) )
+/* In INPUT section put "= init_buf_l($arg);" after variable name. */
+
+/* Lengths in WCHARs are initialized the same as lengths in bytes: */
+#define init_buf_plw init_buf_pl
+#define init_buf_lw init_buf_l
+
+/* grow_buf_pl() and grow_buf_plw() are included so you can define
+ * parameters of type C<DWORD *>, for example. In practice, it is
+ * usually better to define such parameters as "DWORD &". */
+
+/* Grow a buffer where we have a pointer to its size in bytes: */
+#define grow_buf_pl( sBuf,svBuf,tpBuf, plSize,svSize,tpSize ) STMT_START { \
+ Debug(("grow_buf_pl( %s==0x%lX,[%s:%ld/%ld, %s==0x%lX:%ld,[%s )\n",\
+ string(sBuf),sBuf,strchr(string(svBuf),'('),SvPOK(svBuf)? \
+ SvCUR(svBuf):-1,SvPOK(svBuf)?SvLEN(svBuf):-1,string(plSize), \
+ plSize,plSize?*plSize:-1,strchr(string(svSize),'('))); \
+ if( null_arg(svBuf) ) { \
+ sBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( NULL == plSize ) \
+ *( plSize= CAST(tpSize,TempAlloc(sizeof(*plSize))) )= 0;\
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ sBuf= CAST( tpBuf, lSvGROW( svBuf, *plSize ) ); \
+ if( autosize(svSize) ) *plSize= SvLEN(svBuf) - 1; \
+ Debug(("more buf_pl( %s==0x%lX,[%s:%ld/%ld, %s==0x%lX:%ld,[%s )\n",\
+ string(sBuf),sBuf,strchr(string(svBuf),'('),SvPOK(svBuf)? \
+ SvCUR(svBuf):-1,SvPOK(svBuf)?SvLEN(svBuf):-1,string(plSize),\
+ plSize,plSize?*plSize:-1,strchr(string(svSize),'('))); \
+ } } STMT_END
+
+/* Grow a buffer where we have a pointer to its size in WCHARs: */
+#define grow_buf_plw( sBuf,svBuf, plwSize,svSize,tpSize ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ sBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( NULL == plwSize ) \
+ *( plwSize= CAST(tpSize,TempAlloc(sizeof(*plwSize))) )= 0;\
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ sBuf= lwSvGROW( svBuf, *plwSize ); \
+ if( autosize(svSize) ) \
+ *plwSize= SvLEN(svBuf)/sizeof(WCHAR) - 1; \
+ } } STMT_END
+
+/* Grow a buffer where we have its size in bytes: */
+#define grow_buf_l( sBuf,svBuf,tpBuf, lSize,svSize ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ sBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ sBuf= CAST( tpBuf, lSvGROW( svBuf, lSize ) ); \
+ if( autosize(svSize) ) lSize= SvLEN(svBuf) - 1; \
+ } } STMT_END
+
+/* Grow a buffer where we have its size in WCHARs: */
+#define grow_buf_lw( swBuf,svBuf, lwSize,svSize ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ swBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ swBuf= lwSvGROW( svBuf, lwSize ); \
+ if( autosize(svSize) ) \
+ lwSize= SvLEN(svBuf)/sizeof(WCHAR) - 1; \
+ } } STMT_END
+
+/* Grow a buffer that contains the declared fixed data type: */
+#define grow_buf( pBuf,svBuf, tpBuf ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ pBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(*pBuf) ) ); \
+ } } STMT_END
+
+/* Grow a buffer that contains a fixed data type other than that declared: */
+#define grow_buf_typ( pBuf,svBuf,tpBuf, Type ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ pBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(Type) ) ); \
+ } } STMT_END
+
+/* Grow a buffer that contains a list of items of the declared data type: */
+#define grow_vect( pBuf,svBuf,tpBuf, cItems ) STMT_START { \
+ if( null_arg(svBuf) ) { \
+ pBuf= NULL; \
+ } else { \
+ STRLEN n_a; \
+ if( ! SvOK(svBuf) ) sv_setpvn(svBuf,"",0); \
+ (void) SvPV_force( svBuf, n_a ); \
+ pBuf= CAST( tpBuf, SvGROW( svBuf, sizeof(*pBuf)*cItems ) ); \
+ } } STMT_END
+
+/* If call succeeded, set data length to returned length (in bytes): */
+#define trunc_buf_l( bOkay, sBuf,svBuf, lSize ) STMT_START { \
+ if( bOkay && NULL != sBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, lSize ); \
+ } } STMT_END
+
+/* Same as above except we have a pointer to the returned length: */
+#define trunc_buf_pl( bOkay, sBuf,svBuf, plSize ) \
+ trunc_buf_l( bOkay, sBuf,svBuf, *plSize )
+
+/* If call succeeded, set data length to returned length (in WCHARs): */
+#define trunc_buf_lw( bOkay, sBuf,svBuf, lwSize ) STMT_START { \
+ if( bOkay && NULL != sBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, (lwSize)*sizeof(WCHAR) ); \
+ } } STMT_END
+
+/* Same as above except we have a pointer to the returned length: */
+#define trunc_buf_plw( bOkay, swBuf,svBuf, plwSize ) \
+ trunc_buf_lw( bOkay, swBuf,svBuf, *plwSize )
+
+/* Set data length for a buffer that contains the declared fixed data type: */
+#define trunc_buf( bOkay, pBuf,svBuf ) STMT_START { \
+ if( bOkay && NULL != pBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, sizeof(*pBuf) ); \
+ } } STMT_END
+
+/* Set data length for a buffer that contains some other fixed data type: */
+#define trunc_buf_typ( bOkay, pBuf,svBuf, Type ) STMT_START { \
+ if( bOkay && NULL != pBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, sizeof(Type) ); \
+ } } STMT_END
+
+/* Set length for buffer that contains list of items of the declared type: */
+#define trunc_vect( bOkay, pBuf,svBuf, cItems ) STMT_START { \
+ if( bOkay && NULL != pBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, sizeof(*pBuf)*cItems ); \
+ } } STMT_END
+
+/* Set data length for a buffer where a '\0'-terminate string was stored: */
+#define trunc_buf_z( bOkay, sBuf,svBuf ) STMT_START { \
+ if( bOkay && NULL != sBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, strlen(sBuf) ); \
+ } } STMT_END
+
+/* Set data length for a buffer where a L'\0'-terminate string was stored: */
+#define trunc_buf_zw( bOkay, sBuf,svBuf ) STMT_START { \
+ if( bOkay && NULL != sBuf ) { \
+ SvPOK_only( svBuf ); \
+ SvCUR_set( svBuf, wcslen(sBuf)*sizeof(WCHAR) ); \
+ } } STMT_END
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/cFile.h b/gnu/usr.bin/perl/cpan/Win32API-File/cFile.h index 23e7ed89f56..badb1b98c1b 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/cFile.h +++ b/gnu/usr.bin/perl/cpan/Win32API-File/cFile.h @@ -1 +1 @@ -/* Would contain C code to generate Perl constants if not using cFile.pc */ +/* Would contain C code to generate Perl constants if not using cFile.pc */
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/cFile.pc b/gnu/usr.bin/perl/cpan/Win32API-File/cFile.pc index b44fbe85741..cd4c55233e4 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/cFile.pc +++ b/gnu/usr.bin/perl/cpan/Win32API-File/cFile.pc @@ -1,168 +1,168 @@ -# Generated by cFile_pc.cxx. -# Package Win32API::File with options: -# CPLUSPLUS => q[1] -# IFDEF => q[!/[a-z\d]/] -# IMPORT_LIST => [q[/._/], q[!/[a-z]/], q[:MEDIA_TYPE]] -# WRITE_PERL => q[1] -# Perl files eval'd: -# File.pm => last if /^\s*(bootstrap|XSLoader::load)\b/ -# C files included: -# File.xs => last if m#/[/*]\s*CONSTS_DEFINED\b|^\s*MODULE\b# -sub CREATE_ALWAYS () { 2 } -sub CREATE_NEW () { 1 } -sub DDD_EXACT_MATCH_ON_REMOVE () { 4 } -sub DDD_RAW_TARGET_PATH () { 1 } -sub DDD_REMOVE_DEFINITION () { 2 } -sub DRIVE_CDROM () { 5 } -sub DRIVE_FIXED () { 3 } -sub DRIVE_NO_ROOT_DIR () { 1 } -sub DRIVE_RAMDISK () { 6 } -sub DRIVE_REMOTE () { 4 } -sub DRIVE_REMOVABLE () { 2 } -sub DRIVE_UNKNOWN () { 0 } -sub F3_120M_512 () { 13 } -sub F3_1Pt44_512 () { 2 } -sub F3_20Pt8_512 () { 4 } -sub F3_2Pt88_512 () { 3 } -sub F3_720_512 () { 5 } -sub F5_160_512 () { 10 } -sub F5_180_512 () { 9 } -sub F5_1Pt2_512 () { 1 } -sub F5_320_1024 () { 8 } -sub F5_320_512 () { 7 } -sub F5_360_512 () { 6 } -sub FILE_ADD_FILE () { 2 } -sub FILE_ADD_SUBDIRECTORY () { 4 } -sub FILE_ALL_ACCESS () { 2032127 } -sub FILE_APPEND_DATA () { 4 } -sub FILE_ATTRIBUTE_ARCHIVE () { 32 } -sub FILE_ATTRIBUTE_COMPRESSED () { 2048 } -sub FILE_ATTRIBUTE_DEVICE () { 0x00000040 } -sub FILE_ATTRIBUTE_DIRECTORY () { 0x00000010 } -sub FILE_ATTRIBUTE_ENCRYPTED () { 0x00004000 } -sub FILE_ATTRIBUTE_HIDDEN () { 2 } -sub FILE_ATTRIBUTE_NORMAL () { 128 } -sub FILE_ATTRIBUTE_NOT_CONTENT_INDEXED () { 0x00002000 } -sub FILE_ATTRIBUTE_OFFLINE () { 4096 } -sub FILE_ATTRIBUTE_READONLY () { 1 } -sub FILE_ATTRIBUTE_REPARSE_POINT () { 0x00000400 } -sub FILE_ATTRIBUTE_SPARSE_FILE () { 0x00000200 } -sub FILE_ATTRIBUTE_SYSTEM () { 4 } -sub FILE_ATTRIBUTE_TEMPORARY () { 256 } -sub FILE_BEGIN () { 0 } -sub FILE_CREATE_PIPE_INSTANCE () { 4 } -sub FILE_CURRENT () { 1 } -sub FILE_DELETE_CHILD () { 64 } -sub FILE_END () { 2 } -sub FILE_EXECUTE () { 32 } -sub FILE_FLAG_BACKUP_SEMANTICS () { 33554432 } -sub FILE_FLAG_DELETE_ON_CLOSE () { 67108864 } -sub FILE_FLAG_NO_BUFFERING () { 536870912 } -sub FILE_FLAG_OPEN_REPARSE_POINT () { 0x200000 } -sub FILE_FLAG_OVERLAPPED () { 1073741824 } -sub FILE_FLAG_POSIX_SEMANTICS () { 16777216 } -sub FILE_FLAG_RANDOM_ACCESS () { 268435456 } -sub FILE_FLAG_SEQUENTIAL_SCAN () { 134217728 } -sub FILE_FLAG_WRITE_THROUGH () { 0x80000000 } -sub FILE_GENERIC_EXECUTE () { 1179808 } -sub FILE_GENERIC_READ () { 1179785 } -sub FILE_GENERIC_WRITE () { 1179926 } -sub FILE_LIST_DIRECTORY () { 1 } -sub FILE_READ_ATTRIBUTES () { 128 } -sub FILE_READ_DATA () { 1 } -sub FILE_READ_EA () { 8 } -sub FILE_SHARE_DELETE () { 4 } -sub FILE_SHARE_READ () { 1 } -sub FILE_SHARE_WRITE () { 2 } -sub FILE_TRAVERSE () { 32 } -sub FILE_TYPE_CHAR () { 2 } -sub FILE_TYPE_DISK () { 1 } -sub FILE_TYPE_PIPE () { 3 } -sub FILE_TYPE_UNKNOWN () { 0 } -sub FILE_WRITE_ATTRIBUTES () { 256 } -sub FILE_WRITE_DATA () { 2 } -sub FILE_WRITE_EA () { 16 } -sub FS_CASE_IS_PRESERVED () { 2 } -sub FS_CASE_SENSITIVE () { 1 } -sub FS_FILE_COMPRESSION () { 16 } -sub FS_PERSISTENT_ACLS () { 8 } -sub FS_UNICODE_STORED_ON_DISK () { 4 } -sub FS_VOL_IS_COMPRESSED () { 32768 } -sub FSCTL_SET_REPARSE_POINT () { (9 << 16 | 0 << 14 | 41 << 2 | 0) } -sub FSCTL_GET_REPARSE_POINT () { (9 << 16 | 0 << 14 | 42 << 2 | 0) } -sub FSCTL_DELETE_REPARSE_POINT () { (9 << 16 | 0 << 14 | 43 << 2 | 0) } -sub FixedMedia () { 12 } -sub GENERIC_ALL () { 268435456 } -sub GENERIC_EXECUTE () { 536870912 } -sub GENERIC_READ () { 0x80000000 } -sub GENERIC_WRITE () { 1073741824 } -sub HANDLE_FLAG_INHERIT () { 1 } -sub HANDLE_FLAG_PROTECT_FROM_CLOSE () { 2 } -sub INVALID_FILE_ATTRIBUTES () { 0xFFFFFFFF } -sub INVALID_HANDLE_VALUE () { 0xffffffff } -sub IOCTL_DISK_FORMAT_TRACKS () { 507928 } -sub IOCTL_DISK_FORMAT_TRACKS_EX () { 507948 } -sub IOCTL_DISK_GET_DRIVE_GEOMETRY () { 458752 } -sub IOCTL_DISK_GET_DRIVE_LAYOUT () { 475148 } -sub IOCTL_DISK_GET_MEDIA_TYPES () { 461824 } -sub IOCTL_DISK_GET_PARTITION_INFO () { 475140 } -sub IOCTL_DISK_HISTOGRAM_DATA () { 458804 } -sub IOCTL_DISK_HISTOGRAM_RESET () { 458808 } -sub IOCTL_DISK_HISTOGRAM_STRUCTURE () { 458800 } -sub IOCTL_DISK_IS_WRITABLE () { 458788 } -sub IOCTL_DISK_LOGGING () { 458792 } -sub IOCTL_DISK_PERFORMANCE () { 458784 } -sub IOCTL_DISK_REASSIGN_BLOCKS () { 507932 } -sub IOCTL_DISK_REQUEST_DATA () { 458816 } -sub IOCTL_DISK_REQUEST_STRUCTURE () { 458812 } -sub IOCTL_DISK_SET_DRIVE_LAYOUT () { 507920 } -sub IOCTL_DISK_SET_PARTITION_INFO () { 507912 } -sub IOCTL_DISK_VERIFY () { 458772 } -sub IOCTL_STORAGE_CHECK_VERIFY () { 2967552 } -sub IOCTL_STORAGE_EJECT_MEDIA () { 2967560 } -sub IOCTL_STORAGE_FIND_NEW_DEVICES () { 2967576 } -sub IOCTL_STORAGE_GET_MEDIA_TYPES () { 2952192 } -sub IOCTL_STORAGE_LOAD_MEDIA () { 2967564 } -sub IOCTL_STORAGE_MEDIA_REMOVAL () { 2967556 } -sub IOCTL_STORAGE_RELEASE () { 2967572 } -sub IOCTL_STORAGE_RESERVE () { 2967568 } -sub MOVEFILE_COPY_ALLOWED () { 2 } -sub MOVEFILE_DELAY_UNTIL_REBOOT () { 4 } -sub MOVEFILE_REPLACE_EXISTING () { 1 } -sub MOVEFILE_WRITE_THROUGH () { 8 } -sub OPEN_ALWAYS () { 4 } -sub OPEN_EXISTING () { 3 } -sub PARTITION_ENTRY_UNUSED () { 0 } -sub PARTITION_EXTENDED () { 5 } -sub PARTITION_FAT32 () { 11 } -sub PARTITION_FAT32_XINT13 () { 12 } -sub PARTITION_FAT_12 () { 1 } -sub PARTITION_FAT_16 () { 4 } -sub PARTITION_HUGE () { 6 } -sub PARTITION_IFS () { 7 } -sub PARTITION_NTFT () { 128 } -sub PARTITION_PREP () { 65 } -sub PARTITION_UNIX () { 99 } -sub PARTITION_XENIX_1 () { 2 } -sub PARTITION_XENIX_2 () { 3 } -sub PARTITION_XINT13 () { 14 } -sub PARTITION_XINT13_EXTENDED () { 15 } -sub RemovableMedia () { 11 } -sub SECURITY_ANONYMOUS () { 0 } -sub SECURITY_CONTEXT_TRACKING () { 262144 } -sub SECURITY_DELEGATION () { 196608 } -sub SECURITY_EFFECTIVE_ONLY () { 524288 } -sub SECURITY_IDENTIFICATION () { 65536 } -sub SECURITY_IMPERSONATION () { 131072 } -sub SECURITY_SQOS_PRESENT () { 1048576 } -sub SEM_FAILCRITICALERRORS () { 1 } -sub SEM_NOALIGNMENTFAULTEXCEPT () { 4 } -sub SEM_NOGPFAULTERRORBOX () { 2 } -sub SEM_NOOPENFILEERRORBOX () { 32768 } -sub TRUNCATE_EXISTING () { 5 } -sub Unknown () { 0 } -sub VALID_NTFT () { 192 } -sub STD_ERROR_HANDLE () { 0xfffffff4 } -sub STD_INPUT_HANDLE () { 0xfffffff6 } -sub STD_OUTPUT_HANDLE () { 0xfffffff5 } -1; +# Generated by cFile_pc.cxx.
+# Package Win32API::File with options:
+# CPLUSPLUS => q[1]
+# IFDEF => q[!/[a-z\d]/]
+# IMPORT_LIST => [q[/._/], q[!/[a-z]/], q[:MEDIA_TYPE]]
+# WRITE_PERL => q[1]
+# Perl files eval'd:
+# File.pm => last if /^\s*(bootstrap|XSLoader::load)\b/
+# C files included:
+# File.xs => last if m#/[/*]\s*CONSTS_DEFINED\b|^\s*MODULE\b#
+sub CREATE_ALWAYS () { 2 }
+sub CREATE_NEW () { 1 }
+sub DDD_EXACT_MATCH_ON_REMOVE () { 4 }
+sub DDD_RAW_TARGET_PATH () { 1 }
+sub DDD_REMOVE_DEFINITION () { 2 }
+sub DRIVE_CDROM () { 5 }
+sub DRIVE_FIXED () { 3 }
+sub DRIVE_NO_ROOT_DIR () { 1 }
+sub DRIVE_RAMDISK () { 6 }
+sub DRIVE_REMOTE () { 4 }
+sub DRIVE_REMOVABLE () { 2 }
+sub DRIVE_UNKNOWN () { 0 }
+sub F3_120M_512 () { 13 }
+sub F3_1Pt44_512 () { 2 }
+sub F3_20Pt8_512 () { 4 }
+sub F3_2Pt88_512 () { 3 }
+sub F3_720_512 () { 5 }
+sub F5_160_512 () { 10 }
+sub F5_180_512 () { 9 }
+sub F5_1Pt2_512 () { 1 }
+sub F5_320_1024 () { 8 }
+sub F5_320_512 () { 7 }
+sub F5_360_512 () { 6 }
+sub FILE_ADD_FILE () { 2 }
+sub FILE_ADD_SUBDIRECTORY () { 4 }
+sub FILE_ALL_ACCESS () { 2032127 }
+sub FILE_APPEND_DATA () { 4 }
+sub FILE_ATTRIBUTE_ARCHIVE () { 32 }
+sub FILE_ATTRIBUTE_COMPRESSED () { 2048 }
+sub FILE_ATTRIBUTE_DEVICE () { 0x00000040 }
+sub FILE_ATTRIBUTE_DIRECTORY () { 0x00000010 }
+sub FILE_ATTRIBUTE_ENCRYPTED () { 0x00004000 }
+sub FILE_ATTRIBUTE_HIDDEN () { 2 }
+sub FILE_ATTRIBUTE_NORMAL () { 128 }
+sub FILE_ATTRIBUTE_NOT_CONTENT_INDEXED () { 0x00002000 }
+sub FILE_ATTRIBUTE_OFFLINE () { 4096 }
+sub FILE_ATTRIBUTE_READONLY () { 1 }
+sub FILE_ATTRIBUTE_REPARSE_POINT () { 0x00000400 }
+sub FILE_ATTRIBUTE_SPARSE_FILE () { 0x00000200 }
+sub FILE_ATTRIBUTE_SYSTEM () { 4 }
+sub FILE_ATTRIBUTE_TEMPORARY () { 256 }
+sub FILE_BEGIN () { 0 }
+sub FILE_CREATE_PIPE_INSTANCE () { 4 }
+sub FILE_CURRENT () { 1 }
+sub FILE_DELETE_CHILD () { 64 }
+sub FILE_END () { 2 }
+sub FILE_EXECUTE () { 32 }
+sub FILE_FLAG_BACKUP_SEMANTICS () { 33554432 }
+sub FILE_FLAG_DELETE_ON_CLOSE () { 67108864 }
+sub FILE_FLAG_NO_BUFFERING () { 536870912 }
+sub FILE_FLAG_OPEN_REPARSE_POINT () { 0x200000 }
+sub FILE_FLAG_OVERLAPPED () { 1073741824 }
+sub FILE_FLAG_POSIX_SEMANTICS () { 16777216 }
+sub FILE_FLAG_RANDOM_ACCESS () { 268435456 }
+sub FILE_FLAG_SEQUENTIAL_SCAN () { 134217728 }
+sub FILE_FLAG_WRITE_THROUGH () { 0x80000000 }
+sub FILE_GENERIC_EXECUTE () { 1179808 }
+sub FILE_GENERIC_READ () { 1179785 }
+sub FILE_GENERIC_WRITE () { 1179926 }
+sub FILE_LIST_DIRECTORY () { 1 }
+sub FILE_READ_ATTRIBUTES () { 128 }
+sub FILE_READ_DATA () { 1 }
+sub FILE_READ_EA () { 8 }
+sub FILE_SHARE_DELETE () { 4 }
+sub FILE_SHARE_READ () { 1 }
+sub FILE_SHARE_WRITE () { 2 }
+sub FILE_TRAVERSE () { 32 }
+sub FILE_TYPE_CHAR () { 2 }
+sub FILE_TYPE_DISK () { 1 }
+sub FILE_TYPE_PIPE () { 3 }
+sub FILE_TYPE_UNKNOWN () { 0 }
+sub FILE_WRITE_ATTRIBUTES () { 256 }
+sub FILE_WRITE_DATA () { 2 }
+sub FILE_WRITE_EA () { 16 }
+sub FS_CASE_IS_PRESERVED () { 2 }
+sub FS_CASE_SENSITIVE () { 1 }
+sub FS_FILE_COMPRESSION () { 16 }
+sub FS_PERSISTENT_ACLS () { 8 }
+sub FS_UNICODE_STORED_ON_DISK () { 4 }
+sub FS_VOL_IS_COMPRESSED () { 32768 }
+sub FSCTL_SET_REPARSE_POINT () { (9 << 16 | 0 << 14 | 41 << 2 | 0) }
+sub FSCTL_GET_REPARSE_POINT () { (9 << 16 | 0 << 14 | 42 << 2 | 0) }
+sub FSCTL_DELETE_REPARSE_POINT () { (9 << 16 | 0 << 14 | 43 << 2 | 0) }
+sub FixedMedia () { 12 }
+sub GENERIC_ALL () { 268435456 }
+sub GENERIC_EXECUTE () { 536870912 }
+sub GENERIC_READ () { 0x80000000 }
+sub GENERIC_WRITE () { 1073741824 }
+sub HANDLE_FLAG_INHERIT () { 1 }
+sub HANDLE_FLAG_PROTECT_FROM_CLOSE () { 2 }
+sub INVALID_FILE_ATTRIBUTES () { 0xFFFFFFFF }
+sub INVALID_HANDLE_VALUE () { 0xffffffff }
+sub IOCTL_DISK_FORMAT_TRACKS () { 507928 }
+sub IOCTL_DISK_FORMAT_TRACKS_EX () { 507948 }
+sub IOCTL_DISK_GET_DRIVE_GEOMETRY () { 458752 }
+sub IOCTL_DISK_GET_DRIVE_LAYOUT () { 475148 }
+sub IOCTL_DISK_GET_MEDIA_TYPES () { 461824 }
+sub IOCTL_DISK_GET_PARTITION_INFO () { 475140 }
+sub IOCTL_DISK_HISTOGRAM_DATA () { 458804 }
+sub IOCTL_DISK_HISTOGRAM_RESET () { 458808 }
+sub IOCTL_DISK_HISTOGRAM_STRUCTURE () { 458800 }
+sub IOCTL_DISK_IS_WRITABLE () { 458788 }
+sub IOCTL_DISK_LOGGING () { 458792 }
+sub IOCTL_DISK_PERFORMANCE () { 458784 }
+sub IOCTL_DISK_REASSIGN_BLOCKS () { 507932 }
+sub IOCTL_DISK_REQUEST_DATA () { 458816 }
+sub IOCTL_DISK_REQUEST_STRUCTURE () { 458812 }
+sub IOCTL_DISK_SET_DRIVE_LAYOUT () { 507920 }
+sub IOCTL_DISK_SET_PARTITION_INFO () { 507912 }
+sub IOCTL_DISK_VERIFY () { 458772 }
+sub IOCTL_STORAGE_CHECK_VERIFY () { 2967552 }
+sub IOCTL_STORAGE_EJECT_MEDIA () { 2967560 }
+sub IOCTL_STORAGE_FIND_NEW_DEVICES () { 2967576 }
+sub IOCTL_STORAGE_GET_MEDIA_TYPES () { 2952192 }
+sub IOCTL_STORAGE_LOAD_MEDIA () { 2967564 }
+sub IOCTL_STORAGE_MEDIA_REMOVAL () { 2967556 }
+sub IOCTL_STORAGE_RELEASE () { 2967572 }
+sub IOCTL_STORAGE_RESERVE () { 2967568 }
+sub MOVEFILE_COPY_ALLOWED () { 2 }
+sub MOVEFILE_DELAY_UNTIL_REBOOT () { 4 }
+sub MOVEFILE_REPLACE_EXISTING () { 1 }
+sub MOVEFILE_WRITE_THROUGH () { 8 }
+sub OPEN_ALWAYS () { 4 }
+sub OPEN_EXISTING () { 3 }
+sub PARTITION_ENTRY_UNUSED () { 0 }
+sub PARTITION_EXTENDED () { 5 }
+sub PARTITION_FAT32 () { 11 }
+sub PARTITION_FAT32_XINT13 () { 12 }
+sub PARTITION_FAT_12 () { 1 }
+sub PARTITION_FAT_16 () { 4 }
+sub PARTITION_HUGE () { 6 }
+sub PARTITION_IFS () { 7 }
+sub PARTITION_NTFT () { 128 }
+sub PARTITION_PREP () { 65 }
+sub PARTITION_UNIX () { 99 }
+sub PARTITION_XENIX_1 () { 2 }
+sub PARTITION_XENIX_2 () { 3 }
+sub PARTITION_XINT13 () { 14 }
+sub PARTITION_XINT13_EXTENDED () { 15 }
+sub RemovableMedia () { 11 }
+sub SECURITY_ANONYMOUS () { 0 }
+sub SECURITY_CONTEXT_TRACKING () { 262144 }
+sub SECURITY_DELEGATION () { 196608 }
+sub SECURITY_EFFECTIVE_ONLY () { 524288 }
+sub SECURITY_IDENTIFICATION () { 65536 }
+sub SECURITY_IMPERSONATION () { 131072 }
+sub SECURITY_SQOS_PRESENT () { 1048576 }
+sub SEM_FAILCRITICALERRORS () { 1 }
+sub SEM_NOALIGNMENTFAULTEXCEPT () { 4 }
+sub SEM_NOGPFAULTERRORBOX () { 2 }
+sub SEM_NOOPENFILEERRORBOX () { 32768 }
+sub TRUNCATE_EXISTING () { 5 }
+sub Unknown () { 0 }
+sub VALID_NTFT () { 192 }
+sub STD_ERROR_HANDLE () { 0xfffffff4 }
+sub STD_INPUT_HANDLE () { 0xfffffff6 }
+sub STD_OUTPUT_HANDLE () { 0xfffffff5 }
+1;
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/const2perl.h b/gnu/usr.bin/perl/cpan/Win32API-File/const2perl.h index dbd94c10a8f..738e415f94f 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/const2perl.h +++ b/gnu/usr.bin/perl/cpan/Win32API-File/const2perl.h @@ -1,193 +1,193 @@ -/* const2perl.h -- For converting C constants into Perl constant subs - * (usually via XS code but can just write Perl code to stdout). */ - - -/* #ifndef _INCLUDE_CONST2PERL_H - * #define _INCLUDE_CONST2PERL_H 1 */ - -#ifndef CONST2WRITE_PERL /* Default is "const to .xs": */ - -# define newconst( sName, sFmt, xValue, newSV ) \ - newCONSTSUB( mHvStash, sName, newSV ) - -# define noconst( const ) av_push( mAvExportFail, newSVpv(#const,0) ) - -# define setuv(u) do { \ - mpSvNew= newSViv(0); sv_setuv(mpSvNew,u); \ - } while( 0 ) - -#else - -/* #ifdef __cplusplus - * # undef printf - * # undef fprintf - * # undef stderr - * # define stderr (&_iob[2]) - * # undef iobuf - * # undef malloc - * #endif */ - -# include <stdio.h> /* Probably already included, but shouldn't hurt */ -# include <errno.h> /* Possibly already included, but shouldn't hurt */ - -# define newconst( sName, sFmt, xValue, newSV ) \ - printf( "sub %s () { " sFmt " }\n", sName, xValue ) - -# define noconst( const ) printf( "push @EXPORT_FAIL, '%s';\n", #const ) - -# define setuv(u) /* Nothing */ - -# ifndef IVdf -# define IVdf "ld" -# endif -# ifndef UVuf -# define UVuf "lu" -# endif -# ifndef UVxf -# define UVxf "lX" -# endif -# ifndef NV_DIG -# define NV_DIG 15 -# endif - -static char * -escquote( const char *sValue ) -{ - Size_t lLen= 1+2*strlen(sValue); - char *sEscaped= (char *) malloc( lLen ); - char *sNext= sEscaped; - if( NULL == sEscaped ) { - fprintf( stderr, "Can't allocate %"UVuf"-byte buffer (errno=%d)\n", - U_V(lLen), _errno ); - exit( 1 ); - } - while( '\0' != *sValue ) { - switch( *sValue ) { - case '\'': - case '\\': - *(sNext++)= '\\'; - } - *(sNext++)= *(sValue++); - } - *sNext= *sValue; - return( sEscaped ); -} - -#endif - - -#ifdef __cplusplus - -class _const2perl { - public: - char msBuf[64]; /* Must fit sprintf of longest NV */ -#ifndef CONST2WRITE_PERL - HV *mHvStash; - AV *mAvExportFail; - SV *mpSvNew; - _const2perl::_const2perl( char *sModName ) { - mHvStash= gv_stashpv( sModName, TRUE ); - SV **pSv= hv_fetch( mHvStash, "EXPORT_FAIL", 11, TRUE ); - GV *gv; - char *sVarName= (char *) malloc( 15+strlen(sModName) ); - strcpy( sVarName, sModName ); - strcat( sVarName, "::EXPORT_FAIL" ); - gv= gv_fetchpv( sVarName, 1, SVt_PVAV ); - mAvExportFail= GvAVn( gv ); - } -#else - _const2perl::_const2perl( char *sModName ) { - ; /* Nothing to do */ - } -#endif /* CONST2WRITE_PERL */ - void mkconst( char *sName, unsigned long uValue ) { - setuv(uValue); - newconst( sName, "0x%"UVxf, uValue, mpSvNew ); - } - void mkconst( char *sName, unsigned int uValue ) { - setuv(uValue); - newconst( sName, "0x%"UVxf, uValue, mpSvNew ); - } - void mkconst( char *sName, unsigned short uValue ) { - setuv(uValue); - newconst( sName, "0x%"UVxf, uValue, mpSvNew ); - } - void mkconst( char *sName, long iValue ) { - newconst( sName, "%"IVdf, iValue, newSViv(iValue) ); - } - void mkconst( char *sName, int iValue ) { - newconst( sName, "%"IVdf, iValue, newSViv(iValue) ); - } - void mkconst( char *sName, short iValue ) { - newconst( sName, "%"IVdf, iValue, newSViv(iValue) ); - } - void mkconst( char *sName, double nValue ) { - newconst( sName, "%s", - Gconvert(nValue,NV_DIG,0,msBuf), newSVnv(nValue) ); - } - void mkconst( char *sName, char *sValue ) { - newconst( sName, "'%s'", escquote(sValue), newSVpv(sValue,0) ); - } - void mkconst( char *sName, const void *pValue ) { - setuv((UV)pValue); - newconst( sName, "0x%"UVxf, (UV)(pValue), mpSvNew ); - } -/*#ifdef HAS_QUAD - * HAS_QUAD only means pack/unpack deal with them, not that SVs can. - * void mkconst( char *sName, Quad_t *qValue ) { - * newconst( sName, "0x%"QVxf, qValue, newSVqv(qValue) ); - * } - *#endif / * HAS_QUAD */ -}; - -#define START_CONSTS( sModName ) _const2perl const2( sModName ); -#define const2perl( const ) const2.mkconst( #const, const ) - -#else /* __cplusplus */ - -# ifndef CONST2WRITE_PERL -# define START_CONSTS( sModName ) \ - HV *mHvStash= gv_stashpv( sModName, TRUE ); \ - AV *mAvExportFail; \ - SV *mpSvNew; \ - { char *sVarName= malloc( 15+strlen(sModName) ); \ - GV *gv; \ - strcpy( sVarName, sModName ); \ - strcat( sVarName, "::EXPORT_FAIL" ); \ - gv= gv_fetchpv( sVarName, 1, SVt_PVAV ); \ - mAvExportFail= GvAVn( gv ); \ - } -# else -# define START_CONSTS( sModName ) /* Nothing */ -# endif - -#define const2perl( const ) do { \ - if( const < 0 ) { \ - newconst( #const, "%"IVdf, const, newSViv((IV)const) ); \ - } else { \ - setuv( (UV)const ); \ - newconst( #const, "0x%"UVxf, const, mpSvNew ); \ - } \ - } while( 0 ) - -#endif /* __cplusplus */ - - -//Example use: -//#include <const2perl.h> -// { -// START_CONSTS( "Package::Name" ) /* No ";" */ -//#ifdef $const -// const2perl( $const ); -//#else -// noconst( $const ); -//#endif -// } -// sub ? { my( $sConstName )= @_; -// return $sConstName; # "#ifdef $sConstName" -// return FALSE; # Same as above -// return "HAS_QUAD"; # "#ifdef HAS_QUAD" -// return "#if 5.04 <= VERSION"; -// return "#if 0"; -// return 1; # No #ifdef -/* #endif / * _INCLUDE_CONST2PERL_H */ +/* const2perl.h -- For converting C constants into Perl constant subs
+ * (usually via XS code but can just write Perl code to stdout). */
+
+
+/* #ifndef _INCLUDE_CONST2PERL_H
+ * #define _INCLUDE_CONST2PERL_H 1 */
+
+#ifndef CONST2WRITE_PERL /* Default is "const to .xs": */
+
+# define newconst( sName, sFmt, xValue, newSV ) \
+ newCONSTSUB( mHvStash, sName, newSV )
+
+# define noconst( const ) av_push( mAvExportFail, newSVpv(#const,0) )
+
+# define setuv(u) do { \
+ mpSvNew= newSViv(0); sv_setuv(mpSvNew,u); \
+ } while( 0 )
+
+#else
+
+/* #ifdef __cplusplus
+ * # undef printf
+ * # undef fprintf
+ * # undef stderr
+ * # define stderr (&_iob[2])
+ * # undef iobuf
+ * # undef malloc
+ * #endif */
+
+# include <stdio.h> /* Probably already included, but shouldn't hurt */
+# include <errno.h> /* Possibly already included, but shouldn't hurt */
+
+# define newconst( sName, sFmt, xValue, newSV ) \
+ printf( "sub %s () { " sFmt " }\n", sName, xValue )
+
+# define noconst( const ) printf( "push @EXPORT_FAIL, '%s';\n", #const )
+
+# define setuv(u) /* Nothing */
+
+# ifndef IVdf
+# define IVdf "ld"
+# endif
+# ifndef UVuf
+# define UVuf "lu"
+# endif
+# ifndef UVxf
+# define UVxf "lX"
+# endif
+# ifndef NV_DIG
+# define NV_DIG 15
+# endif
+
+static char *
+escquote( const char *sValue )
+{
+ Size_t lLen= 1+2*strlen(sValue);
+ char *sEscaped= (char *) malloc( lLen );
+ char *sNext= sEscaped;
+ if( NULL == sEscaped ) {
+ fprintf( stderr, "Can't allocate %"UVuf"-byte buffer (errno=%d)\n",
+ U_V(lLen), _errno );
+ exit( 1 );
+ }
+ while( '\0' != *sValue ) {
+ switch( *sValue ) {
+ case '\'':
+ case '\\':
+ *(sNext++)= '\\';
+ }
+ *(sNext++)= *(sValue++);
+ }
+ *sNext= *sValue;
+ return( sEscaped );
+}
+
+#endif
+
+
+#ifdef __cplusplus
+
+class _const2perl {
+ public:
+ char msBuf[64]; /* Must fit sprintf of longest NV */
+#ifndef CONST2WRITE_PERL
+ HV *mHvStash;
+ AV *mAvExportFail;
+ SV *mpSvNew;
+ _const2perl::_const2perl( char *sModName ) {
+ mHvStash= gv_stashpv( sModName, TRUE );
+ SV **pSv= hv_fetch( mHvStash, "EXPORT_FAIL", 11, TRUE );
+ GV *gv;
+ char *sVarName= (char *) malloc( 15+strlen(sModName) );
+ strcpy( sVarName, sModName );
+ strcat( sVarName, "::EXPORT_FAIL" );
+ gv= gv_fetchpv( sVarName, 1, SVt_PVAV );
+ mAvExportFail= GvAVn( gv );
+ }
+#else
+ _const2perl::_const2perl( char *sModName ) {
+ ; /* Nothing to do */
+ }
+#endif /* CONST2WRITE_PERL */
+ void mkconst( char *sName, unsigned long uValue ) {
+ setuv(uValue);
+ newconst( sName, "0x%"UVxf, uValue, mpSvNew );
+ }
+ void mkconst( char *sName, unsigned int uValue ) {
+ setuv(uValue);
+ newconst( sName, "0x%"UVxf, uValue, mpSvNew );
+ }
+ void mkconst( char *sName, unsigned short uValue ) {
+ setuv(uValue);
+ newconst( sName, "0x%"UVxf, uValue, mpSvNew );
+ }
+ void mkconst( char *sName, long iValue ) {
+ newconst( sName, "%"IVdf, iValue, newSViv(iValue) );
+ }
+ void mkconst( char *sName, int iValue ) {
+ newconst( sName, "%"IVdf, iValue, newSViv(iValue) );
+ }
+ void mkconst( char *sName, short iValue ) {
+ newconst( sName, "%"IVdf, iValue, newSViv(iValue) );
+ }
+ void mkconst( char *sName, double nValue ) {
+ newconst( sName, "%s",
+ Gconvert(nValue,NV_DIG,0,msBuf), newSVnv(nValue) );
+ }
+ void mkconst( char *sName, char *sValue ) {
+ newconst( sName, "'%s'", escquote(sValue), newSVpv(sValue,0) );
+ }
+ void mkconst( char *sName, const void *pValue ) {
+ setuv((UV)pValue);
+ newconst( sName, "0x%"UVxf, (UV)(pValue), mpSvNew );
+ }
+/*#ifdef HAS_QUAD
+ * HAS_QUAD only means pack/unpack deal with them, not that SVs can.
+ * void mkconst( char *sName, Quad_t *qValue ) {
+ * newconst( sName, "0x%"QVxf, qValue, newSVqv(qValue) );
+ * }
+ *#endif / * HAS_QUAD */
+};
+
+#define START_CONSTS( sModName ) _const2perl const2( sModName );
+#define const2perl( const ) const2.mkconst( #const, const )
+
+#else /* __cplusplus */
+
+# ifndef CONST2WRITE_PERL
+# define START_CONSTS( sModName ) \
+ HV *mHvStash= gv_stashpv( sModName, TRUE ); \
+ AV *mAvExportFail; \
+ SV *mpSvNew; \
+ { char *sVarName= malloc( 15+strlen(sModName) ); \
+ GV *gv; \
+ strcpy( sVarName, sModName ); \
+ strcat( sVarName, "::EXPORT_FAIL" ); \
+ gv= gv_fetchpv( sVarName, 1, SVt_PVAV ); \
+ mAvExportFail= GvAVn( gv ); \
+ }
+# else
+# define START_CONSTS( sModName ) /* Nothing */
+# endif
+
+#define const2perl( const ) do { \
+ if( const < 0 ) { \
+ newconst( #const, "%"IVdf, const, newSViv((IV)const) ); \
+ } else { \
+ setuv( (UV)const ); \
+ newconst( #const, "0x%"UVxf, const, mpSvNew ); \
+ } \
+ } while( 0 )
+
+#endif /* __cplusplus */
+
+
+//Example use:
+//#include <const2perl.h>
+// {
+// START_CONSTS( "Package::Name" ) /* No ";" */
+//#ifdef $const
+// const2perl( $const );
+//#else
+// noconst( $const );
+//#endif
+// }
+// sub ? { my( $sConstName )= @_;
+// return $sConstName; # "#ifdef $sConstName"
+// return FALSE; # Same as above
+// return "HAS_QUAD"; # "#ifdef HAS_QUAD"
+// return "#if 5.04 <= VERSION";
+// return "#if 0";
+// return 1; # No #ifdef
+/* #endif / * _INCLUDE_CONST2PERL_H */
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/ExtUtils/Myconst2perl.pm b/gnu/usr.bin/perl/cpan/Win32API-File/inc/ExtUtils/Myconst2perl.pm index 17dace772bf..7aa54657c7b 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/ExtUtils/Myconst2perl.pm +++ b/gnu/usr.bin/perl/cpan/Win32API-File/inc/ExtUtils/Myconst2perl.pm @@ -1,362 +1,362 @@ -# This should eventually become part of MakeMaker as ExtUtils::Mkconst2perl. -# Documentation for this is very skimpy at this point. Full documentation -# will be added to ExtUtils::Mkconst2perl when it is created. -package # Hide from PAUSE - ExtUtils::Myconst2perl; - -use strict; -use Config; - -use vars qw( @ISA @EXPORT @EXPORT_OK $VERSION ); -BEGIN { - require Exporter; - push @ISA, 'Exporter'; - @EXPORT= qw( &Myconst2perl ); - @EXPORT_OK= qw( &ParseAttribs ); - $VERSION= 1.00; -} - -use Carp; -use File::Basename; -use ExtUtils::MakeMaker qw( neatvalue ); - -# Return the extension to use for a file of C++ source code: -sub _cc -{ - # Some day, $Config{_cc} might be defined for us: - return $Config{_cc} if $Config{_cc}; - return ".cxx"; # Seems to be the most widely accepted extension. -} - -=item ParseAttribs - -Parses user-firendly options into coder-firendly specifics. - -=cut - -sub ParseAttribs -{ - # Usage: ParseAttribs( "Package::Name", \%opts, {opt=>\$var} ); - my( $pkg, $hvAttr, $hvRequests )= @_; - my( $outfile, @perlfiles, %perlfilecodes, @cfiles, %cfilecodes ); - my @importlist= @{$hvAttr->{IMPORT_LIST}}; - my $perlcode= $hvAttr->{PERL_PE_CODE} || - 'last if /^\s*(bootstrap|XSLoader::load)\b/'; - my $ccode= $hvAttr->{C_PE_CODE} || - 'last if m#/[/*]\s*CONSTS_DEFINED\b|^\s*MODULE\b#'; - my $ifdef= $hvAttr->{IFDEF} || 0; - my $writeperl= !! $hvAttr->{WRITE_PERL}; - my $export= !! $hvAttr->{DO_EXPORT}; - my $importto= $hvAttr->{IMPORT_TO} || "_constants"; - my $cplusplus= $hvAttr->{CPLUSPLUS}; - $cplusplus= "" if ! defined $cplusplus; - my $object= ""; - my $binary= ""; - my $final= ""; - my $norebuild= ""; - my $subroutine= ""; - my $base; - my %params= ( - PERL_PE_CODE => \$perlcode, - PERL_FILE_LIST => \@perlfiles, - PERL_FILE_CODES => \%perlfilecodes, - PERL_FILES => sub { map {($_,$perlfilecodes{$_})} @perlfiles }, - C_PE_CODE => \$ccode, - C_FILE_LIST => \@cfiles, - C_FILE_CODES => \%cfilecodes, - C_FILES => sub { map {($_,$cfilecodes{$_})} @cfiles }, - DO_EXPORT => \$export, - IMPORT_TO => \$importto, - IMPORT_LIST => \@importlist, - SUBROUTINE => \$subroutine, - IFDEF => \$ifdef, - WRITE_PERL => \$writeperl, - CPLUSPLUS => \$cplusplus, - BASEFILENAME => \$base, - OUTFILE => \$outfile, - OBJECT => \$object, - BINARY => \$binary, - FINAL_PERL => \$final, - NO_REBUILD => \$norebuild, - ); - { my @err= grep {! defined $params{$_}} keys %$hvAttr; - carp "ExtUtils::Myconst2perl::ParseAttribs: ", - "Unsupported option(s) (@err).\n" - if @err; - } - $norebuild= $hvAttr->{NO_REBUILD} if exists $hvAttr->{NO_REBUILD}; - my $module= ( split /::/, $pkg )[-1]; - $base= "c".$module; - $base= $hvAttr->{BASEFILENAME} if exists $hvAttr->{BASEFILENAME}; - my $ext= ! $cplusplus ? ($Config{_c}||".c") - : $cplusplus =~ /^[.]/ ? $cplusplus : _cc(); - if( $writeperl ) { - $outfile= $base . "_pc" . $ext; - $object= $base . "_pc" . ($Config{_o}||$Config{obj_ext}); - $object= $hvAttr->{OBJECT} if $hvAttr->{OBJECT}; - $binary= $base . "_pc" . ($Config{_exe}||$Config{exe_ext}); - $binary= $hvAttr->{BINARY} if $hvAttr->{BINARY}; - $final= $base . ".pc"; - $final= $hvAttr->{FINAL_PERL} if $hvAttr->{FINAL_PERL}; - $subroutine= "main"; - } elsif( $cplusplus ) { - $outfile= $base . $ext; - $object= $base . ($Config{_o}||$Config{obj_ext}); - $object= $hvAttr->{OBJECT} if $hvAttr->{OBJECT}; - $subroutine= "const2perl_" . $pkg; - $subroutine =~ s/\W/_/g; - } else { - $outfile= $base . ".h"; - } - $outfile= $hvAttr->{OUTFILE} if $hvAttr->{OUTFILE}; - if( $hvAttr->{PERL_FILES} ) { - carp "ExtUtils::Myconst2perl: PERL_FILES option not allowed ", - "with PERL_FILE_LIST nor PERL_FILE_CODES.\n" - if $hvAttr->{PERL_FILE_LIST} || $hvAttr->{PERL_FILE_CODES}; - %perlfilecodes= @{$hvAttr->{PERL_FILES}}; - my $odd= 0; - @perlfiles= grep {$odd= !$odd} @{$hvAttr->{PERL_FILES}}; - } else { - if( $hvAttr->{PERL_FILE_LIST} ) { - @perlfiles= @{$hvAttr->{PERL_FILE_LIST}}; - } elsif( $hvAttr->{PERL_FILE_CODES} ) { - @perlfiles= keys %{$hvAttr->{PERL_FILE_CODES}}; - } else { - @perlfiles= ( "$module.pm" ); - } - %perlfilecodes= %{$hvAttr->{PERL_FILE_CODES}} - if $hvAttr->{PERL_FILE_CODES}; - } - for my $file ( @perlfiles ) { - $perlfilecodes{$file}= $perlcode if ! $perlfilecodes{$file}; - } - if( ! $subroutine ) { - ; # Don't process any C source code files. - } elsif( $hvAttr->{C_FILES} ) { - carp "ExtUtils::Myconst2perl: C_FILES option not allowed ", - "with C_FILE_LIST nor C_FILE_CODES.\n" - if $hvAttr->{C_FILE_LIST} || $hvAttr->{C_FILE_CODES}; - %cfilecodes= @{$hvAttr->{C_FILES}}; - my $odd= 0; - @cfiles= grep {$odd= !$odd} @{$hvAttr->{C_FILES}}; - } else { - if( $hvAttr->{C_FILE_LIST} ) { - @cfiles= @{$hvAttr->{C_FILE_LIST}}; - } elsif( $hvAttr->{C_FILE_CODES} ) { - @cfiles= keys %{$hvAttr->{C_FILE_CODES}}; - } elsif( $writeperl || $cplusplus ) { - @cfiles= ( "$module.xs" ); - } - %cfilecodes= %{$hvAttr->{C_FILE_CODES}} if $hvAttr->{C_FILE_CODES}; - } - for my $file ( @cfiles ) { - $cfilecodes{$file}= $ccode if ! $cfilecodes{$file}; - } - for my $key ( keys %$hvRequests ) { - if( ! $params{$key} ) { - carp "ExtUtils::Myconst2perl::ParseAttribs: ", - "Unsupported output ($key).\n"; - } elsif( "SCALAR" eq ref( $params{$key} ) ) { - ${$hvRequests->{$key}}= ${$params{$key}}; - } elsif( "ARRAY" eq ref( $params{$key} ) ) { - @{$hvRequests->{$key}}= @{$params{$key}}; - } elsif( "HASH" eq ref( $params{$key} ) ) { - %{$hvRequests->{$key}}= %{$params{$key}}; - } elsif( "CODE" eq ref( $params{$key} ) ) { - @{$hvRequests->{$key}}= &{$params{$key}}; - } else { - die "Impossible value in \$params{$key}"; - } - } -} - -=item Myconst2perl - -Generates a file used to implement C constants as "constant subroutines" in -a Perl module. - -Extracts a list of constants from a module's export list by C<eval>ing the -first part of the Module's F<*.pm> file and then requesting some groups of -symbols be exported/imported into a dummy package. Then writes C or C++ -code that can convert each C constant into a Perl "constant subroutine" -whose name is the constant's name and whose value is the constant's value. - -=cut - -sub Myconst2perl -{ - my( $pkg, %spec )= @_; - my( $outfile, $writeperl, $ifdef, $export, $importto, @importlist, - @perlfile, %perlcode, @cfile, %ccode, $routine ); - ParseAttribs( $pkg, \%spec, { - DO_EXPORT => \$export, - IMPORT_TO => \$importto, - IMPORT_LIST => \@importlist, - IFDEF => \$ifdef, - WRITE_PERL => \$writeperl, - OUTFILE => \$outfile, - PERL_FILE_LIST => \@perlfile, - PERL_FILE_CODES => \%perlcode, - C_FILE_LIST => \@cfile, - C_FILE_CODES => \%ccode, - SUBROUTINE => \$routine, - } ); - my $module= ( split /::/, $pkg )[-1]; - - warn "Writing $outfile...\n"; - open( STDOUT, ">$outfile" ) or die "Can't create $outfile: $!\n"; - - my $code= ""; - my $file; - foreach $file ( @perlfile ) { - warn "Reading Perl file, $file: $perlcode{$file}\n"; - open( MODULE, "<$file" ) or die "Can't read Perl file, $file: $!\n"; - eval qq[ - while( <MODULE> ) { - $perlcode{$file}; - \$code .= \$_; - } - 1; - ] or die "$file eval: $@\n"; - close( MODULE ); - } - - print - "/* $outfile - Generated by ExtUtils::Myconst2perl::Myconst2perl */\n"; - if( $routine ) { - print "/* See start of $routine() for generation parameters used */\n"; - #print "#define main _main_proto" - # " /* Ignore Perl's main() prototype */\n\n"; - if( $writeperl ) { - # Here are more reasons why the WRITE_PERL option is discouraged. - if( $Config{useperlio} ) { - print "#define PERLIO_IS_STDIO 1\n"; - } - print "#define WIN32IO_IS_STDIO 1\n"; # May cause a warning - print "#define NO_XSLOCKS 1\n"; # What a hack! - } - foreach $file ( @cfile ) { - warn "Reading C file, $file: $ccode{$file}\n"; - open( XS, "<$file" ) or die "Can't read C file, $file: $!\n"; - my $code= $ccode{$file}; - $code =~ s#\\#\\\\#g; - $code =~ s#([^\s -~])#"\\x".sprintf "%02X",unpack "C",$1#ge; - $code =~ s#[*]/#*\\/#g; - print qq[\n/* Include $file: $code */\n]; - print qq[\n#line 1 "$file"\n]; - eval qq[ - while( <XS> ) { - $ccode{$file}; - print; - } - 1; - ] or die "$file eval: $@\n"; - close( XS ); - } - #print qq[\n#undef main\n]; - print qq[\n#define CONST2WRITE_PERL\n]; - print qq[\n#include "const2perl.h"\n\n]; - if( $writeperl ) { - print "int\nmain( int argc, char *argv[], char *envp[] )\n"; - } else { - print "void\n$routine( void )\n"; - } - } - print "{\n"; - - { - @ExtUtils::Myconst2perl::importlist= @importlist; - my $var= '@ExtUtils::Myconst2perl::importlist'; - my $port= $export ? "export" : "import"; - my $arg2= $export ? "q[$importto]," : ""; - local( $^W )= 0; - eval $code . "{\n" - . " { package $importto;\n" - . " warn qq[\u${port}ing to $importto: $var\\n];\n" - . " \$pkg->$port( $arg2 $var );\n" - . " }\n" - . " { no strict 'refs';\n" - . " $var= sort keys %{'_constants::'}; }\n" - . " warn 0 + $var, qq[ symbols ${port}ed.\\n];\n" - . "}\n1;\n" - or die "eval: $@\n"; - } - my @syms= @ExtUtils::Myconst2perl::importlist; - - my $if; - my $const; - print qq[ START_CONSTS( "$pkg" ) /* No ";" */\n]; - { - my( $head, $tail )= ( "/*", "\n" ); - if( $writeperl ) { - $head= ' printf( "#'; - $tail= '\\n" );' . "\n"; - print $head, " Generated by $outfile.", $tail; - } - print $head, " Package $pkg with options:", $tail; - $head= " *" if ! $writeperl; - my $key; - foreach $key ( sort keys %spec ) { - my $val= neatvalue($spec{$key}); - $val =~ s/\\/\\\\/g if $writeperl; - print $head, " $key => ", $val, $tail; - } - print $head, " Perl files eval'd:", $tail; - foreach $key ( @perlfile ) { - my $code= $perlcode{$key}; - $code =~ s#\\#\\\\#g; - $code =~ s#([^ -~])#"\\".sprintf "%03o",unpack "C",$1#ge; - $code =~ s#"#\\"#g if $writeperl; - print $head, " $key => ", $code, $tail; - } - if( $writeperl ) { - print $head, " C files included:", $tail; - foreach $key ( @cfile ) { - my $code= $ccode{$key}; - $code =~ s#\\#\\\\#g; - $code =~ s#([^ -~])#"\\".sprintf "%03o",unpack "C",$1#ge; - $code =~ s#"#\\"#g; - print $head, " $key => ", $code, $tail; - } - } else { - print " */\n"; - } - } - if( ! ref($ifdef) && $ifdef =~ /[^\s\w]/ ) { - my $sub= $ifdef; - $sub= 'sub { local($_)= @_; ' . $sub . ' }' - unless $sub =~ /^\s*sub\b/; - $ifdef= eval $sub; - die "$@: $sub\n" if $@; - if( "CODE" ne ref($ifdef) ) { - die "IFDEF didn't create subroutine reference: eval $sub\n"; - } - } - foreach $const ( @syms ) { - $if= "CODE" eq ref($ifdef) ? $ifdef->($const) : $ifdef; - if( ! $if ) { - $if= ""; - } elsif( "1" eq $if ) { - $if= "#ifdef $const\n"; - } elsif( $if !~ /^#/ ) { - $if= "#ifdef $if\n"; - } else { - $if= "$if\n"; - } - print $if - . qq[ const2perl( $const );\n]; - if( $if ) { - print "#else\n" - . qq[ noconst( $const );\n] - . "#endif\n"; - } - } - if( $writeperl ) { - print - qq[ printf( "1;\\n" );\n], - qq[ return( 0 );\n]; - } - print "}\n"; -} - -1; +# This should eventually become part of MakeMaker as ExtUtils::Mkconst2perl.
+# Documentation for this is very skimpy at this point. Full documentation
+# will be added to ExtUtils::Mkconst2perl when it is created.
+package # Hide from PAUSE
+ ExtUtils::Myconst2perl;
+
+use strict;
+use Config;
+
+use vars qw( @ISA @EXPORT @EXPORT_OK $VERSION );
+BEGIN {
+ require Exporter;
+ push @ISA, 'Exporter';
+ @EXPORT= qw( &Myconst2perl );
+ @EXPORT_OK= qw( &ParseAttribs );
+ $VERSION= 1.00;
+}
+
+use Carp;
+use File::Basename;
+use ExtUtils::MakeMaker qw( neatvalue );
+
+# Return the extension to use for a file of C++ source code:
+sub _cc
+{
+ # Some day, $Config{_cc} might be defined for us:
+ return $Config{_cc} if $Config{_cc};
+ return ".cxx"; # Seems to be the most widely accepted extension.
+}
+
+=item ParseAttribs
+
+Parses user-firendly options into coder-firendly specifics.
+
+=cut
+
+sub ParseAttribs
+{
+ # Usage: ParseAttribs( "Package::Name", \%opts, {opt=>\$var} );
+ my( $pkg, $hvAttr, $hvRequests )= @_;
+ my( $outfile, @perlfiles, %perlfilecodes, @cfiles, %cfilecodes );
+ my @importlist= @{$hvAttr->{IMPORT_LIST}};
+ my $perlcode= $hvAttr->{PERL_PE_CODE} ||
+ 'last if /^\s*(bootstrap|XSLoader::load)\b/';
+ my $ccode= $hvAttr->{C_PE_CODE} ||
+ 'last if m#/[/*]\s*CONSTS_DEFINED\b|^\s*MODULE\b#';
+ my $ifdef= $hvAttr->{IFDEF} || 0;
+ my $writeperl= !! $hvAttr->{WRITE_PERL};
+ my $export= !! $hvAttr->{DO_EXPORT};
+ my $importto= $hvAttr->{IMPORT_TO} || "_constants";
+ my $cplusplus= $hvAttr->{CPLUSPLUS};
+ $cplusplus= "" if ! defined $cplusplus;
+ my $object= "";
+ my $binary= "";
+ my $final= "";
+ my $norebuild= "";
+ my $subroutine= "";
+ my $base;
+ my %params= (
+ PERL_PE_CODE => \$perlcode,
+ PERL_FILE_LIST => \@perlfiles,
+ PERL_FILE_CODES => \%perlfilecodes,
+ PERL_FILES => sub { map {($_,$perlfilecodes{$_})} @perlfiles },
+ C_PE_CODE => \$ccode,
+ C_FILE_LIST => \@cfiles,
+ C_FILE_CODES => \%cfilecodes,
+ C_FILES => sub { map {($_,$cfilecodes{$_})} @cfiles },
+ DO_EXPORT => \$export,
+ IMPORT_TO => \$importto,
+ IMPORT_LIST => \@importlist,
+ SUBROUTINE => \$subroutine,
+ IFDEF => \$ifdef,
+ WRITE_PERL => \$writeperl,
+ CPLUSPLUS => \$cplusplus,
+ BASEFILENAME => \$base,
+ OUTFILE => \$outfile,
+ OBJECT => \$object,
+ BINARY => \$binary,
+ FINAL_PERL => \$final,
+ NO_REBUILD => \$norebuild,
+ );
+ { my @err= grep {! defined $params{$_}} keys %$hvAttr;
+ carp "ExtUtils::Myconst2perl::ParseAttribs: ",
+ "Unsupported option(s) (@err).\n"
+ if @err;
+ }
+ $norebuild= $hvAttr->{NO_REBUILD} if exists $hvAttr->{NO_REBUILD};
+ my $module= ( split /::/, $pkg )[-1];
+ $base= "c".$module;
+ $base= $hvAttr->{BASEFILENAME} if exists $hvAttr->{BASEFILENAME};
+ my $ext= ! $cplusplus ? ($Config{_c}||".c")
+ : $cplusplus =~ /^[.]/ ? $cplusplus : _cc();
+ if( $writeperl ) {
+ $outfile= $base . "_pc" . $ext;
+ $object= $base . "_pc" . ($Config{_o}||$Config{obj_ext});
+ $object= $hvAttr->{OBJECT} if $hvAttr->{OBJECT};
+ $binary= $base . "_pc" . ($Config{_exe}||$Config{exe_ext});
+ $binary= $hvAttr->{BINARY} if $hvAttr->{BINARY};
+ $final= $base . ".pc";
+ $final= $hvAttr->{FINAL_PERL} if $hvAttr->{FINAL_PERL};
+ $subroutine= "main";
+ } elsif( $cplusplus ) {
+ $outfile= $base . $ext;
+ $object= $base . ($Config{_o}||$Config{obj_ext});
+ $object= $hvAttr->{OBJECT} if $hvAttr->{OBJECT};
+ $subroutine= "const2perl_" . $pkg;
+ $subroutine =~ s/\W/_/g;
+ } else {
+ $outfile= $base . ".h";
+ }
+ $outfile= $hvAttr->{OUTFILE} if $hvAttr->{OUTFILE};
+ if( $hvAttr->{PERL_FILES} ) {
+ carp "ExtUtils::Myconst2perl: PERL_FILES option not allowed ",
+ "with PERL_FILE_LIST nor PERL_FILE_CODES.\n"
+ if $hvAttr->{PERL_FILE_LIST} || $hvAttr->{PERL_FILE_CODES};
+ %perlfilecodes= @{$hvAttr->{PERL_FILES}};
+ my $odd= 0;
+ @perlfiles= grep {$odd= !$odd} @{$hvAttr->{PERL_FILES}};
+ } else {
+ if( $hvAttr->{PERL_FILE_LIST} ) {
+ @perlfiles= @{$hvAttr->{PERL_FILE_LIST}};
+ } elsif( $hvAttr->{PERL_FILE_CODES} ) {
+ @perlfiles= keys %{$hvAttr->{PERL_FILE_CODES}};
+ } else {
+ @perlfiles= ( "$module.pm" );
+ }
+ %perlfilecodes= %{$hvAttr->{PERL_FILE_CODES}}
+ if $hvAttr->{PERL_FILE_CODES};
+ }
+ for my $file ( @perlfiles ) {
+ $perlfilecodes{$file}= $perlcode if ! $perlfilecodes{$file};
+ }
+ if( ! $subroutine ) {
+ ; # Don't process any C source code files.
+ } elsif( $hvAttr->{C_FILES} ) {
+ carp "ExtUtils::Myconst2perl: C_FILES option not allowed ",
+ "with C_FILE_LIST nor C_FILE_CODES.\n"
+ if $hvAttr->{C_FILE_LIST} || $hvAttr->{C_FILE_CODES};
+ %cfilecodes= @{$hvAttr->{C_FILES}};
+ my $odd= 0;
+ @cfiles= grep {$odd= !$odd} @{$hvAttr->{C_FILES}};
+ } else {
+ if( $hvAttr->{C_FILE_LIST} ) {
+ @cfiles= @{$hvAttr->{C_FILE_LIST}};
+ } elsif( $hvAttr->{C_FILE_CODES} ) {
+ @cfiles= keys %{$hvAttr->{C_FILE_CODES}};
+ } elsif( $writeperl || $cplusplus ) {
+ @cfiles= ( "$module.xs" );
+ }
+ %cfilecodes= %{$hvAttr->{C_FILE_CODES}} if $hvAttr->{C_FILE_CODES};
+ }
+ for my $file ( @cfiles ) {
+ $cfilecodes{$file}= $ccode if ! $cfilecodes{$file};
+ }
+ for my $key ( keys %$hvRequests ) {
+ if( ! $params{$key} ) {
+ carp "ExtUtils::Myconst2perl::ParseAttribs: ",
+ "Unsupported output ($key).\n";
+ } elsif( "SCALAR" eq ref( $params{$key} ) ) {
+ ${$hvRequests->{$key}}= ${$params{$key}};
+ } elsif( "ARRAY" eq ref( $params{$key} ) ) {
+ @{$hvRequests->{$key}}= @{$params{$key}};
+ } elsif( "HASH" eq ref( $params{$key} ) ) {
+ %{$hvRequests->{$key}}= %{$params{$key}};
+ } elsif( "CODE" eq ref( $params{$key} ) ) {
+ @{$hvRequests->{$key}}= &{$params{$key}};
+ } else {
+ die "Impossible value in \$params{$key}";
+ }
+ }
+}
+
+=item Myconst2perl
+
+Generates a file used to implement C constants as "constant subroutines" in
+a Perl module.
+
+Extracts a list of constants from a module's export list by C<eval>ing the
+first part of the Module's F<*.pm> file and then requesting some groups of
+symbols be exported/imported into a dummy package. Then writes C or C++
+code that can convert each C constant into a Perl "constant subroutine"
+whose name is the constant's name and whose value is the constant's value.
+
+=cut
+
+sub Myconst2perl
+{
+ my( $pkg, %spec )= @_;
+ my( $outfile, $writeperl, $ifdef, $export, $importto, @importlist,
+ @perlfile, %perlcode, @cfile, %ccode, $routine );
+ ParseAttribs( $pkg, \%spec, {
+ DO_EXPORT => \$export,
+ IMPORT_TO => \$importto,
+ IMPORT_LIST => \@importlist,
+ IFDEF => \$ifdef,
+ WRITE_PERL => \$writeperl,
+ OUTFILE => \$outfile,
+ PERL_FILE_LIST => \@perlfile,
+ PERL_FILE_CODES => \%perlcode,
+ C_FILE_LIST => \@cfile,
+ C_FILE_CODES => \%ccode,
+ SUBROUTINE => \$routine,
+ } );
+ my $module= ( split /::/, $pkg )[-1];
+
+ warn "Writing $outfile...\n";
+ open( STDOUT, ">$outfile" ) or die "Can't create $outfile: $!\n";
+
+ my $code= "";
+ my $file;
+ foreach $file ( @perlfile ) {
+ warn "Reading Perl file, $file: $perlcode{$file}\n";
+ open( MODULE, "<$file" ) or die "Can't read Perl file, $file: $!\n";
+ eval qq[
+ while( <MODULE> ) {
+ $perlcode{$file};
+ \$code .= \$_;
+ }
+ 1;
+ ] or die "$file eval: $@\n";
+ close( MODULE );
+ }
+
+ print
+ "/* $outfile - Generated by ExtUtils::Myconst2perl::Myconst2perl */\n";
+ if( $routine ) {
+ print "/* See start of $routine() for generation parameters used */\n";
+ #print "#define main _main_proto"
+ # " /* Ignore Perl's main() prototype */\n\n";
+ if( $writeperl ) {
+ # Here are more reasons why the WRITE_PERL option is discouraged.
+ if( $Config{useperlio} ) {
+ print "#define PERLIO_IS_STDIO 1\n";
+ }
+ print "#define WIN32IO_IS_STDIO 1\n"; # May cause a warning
+ print "#define NO_XSLOCKS 1\n"; # What a hack!
+ }
+ foreach $file ( @cfile ) {
+ warn "Reading C file, $file: $ccode{$file}\n";
+ open( XS, "<$file" ) or die "Can't read C file, $file: $!\n";
+ my $code= $ccode{$file};
+ $code =~ s#\\#\\\\#g;
+ $code =~ s#([^\s -~])#"\\x".sprintf "%02X",unpack "C",$1#ge;
+ $code =~ s#[*]/#*\\/#g;
+ print qq[\n/* Include $file: $code */\n];
+ print qq[\n#line 1 "$file"\n];
+ eval qq[
+ while( <XS> ) {
+ $ccode{$file};
+ print;
+ }
+ 1;
+ ] or die "$file eval: $@\n";
+ close( XS );
+ }
+ #print qq[\n#undef main\n];
+ print qq[\n#define CONST2WRITE_PERL\n];
+ print qq[\n#include "const2perl.h"\n\n];
+ if( $writeperl ) {
+ print "int\nmain( int argc, char *argv[], char *envp[] )\n";
+ } else {
+ print "void\n$routine( void )\n";
+ }
+ }
+ print "{\n";
+
+ {
+ @ExtUtils::Myconst2perl::importlist= @importlist;
+ my $var= '@ExtUtils::Myconst2perl::importlist';
+ my $port= $export ? "export" : "import";
+ my $arg2= $export ? "q[$importto]," : "";
+ local( $^W )= 0;
+ eval $code . "{\n"
+ . " { package $importto;\n"
+ . " warn qq[\u${port}ing to $importto: $var\\n];\n"
+ . " \$pkg->$port( $arg2 $var );\n"
+ . " }\n"
+ . " { no strict 'refs';\n"
+ . " $var= sort keys %{'_constants::'}; }\n"
+ . " warn 0 + $var, qq[ symbols ${port}ed.\\n];\n"
+ . "}\n1;\n"
+ or die "eval: $@\n";
+ }
+ my @syms= @ExtUtils::Myconst2perl::importlist;
+
+ my $if;
+ my $const;
+ print qq[ START_CONSTS( "$pkg" ) /* No ";" */\n];
+ {
+ my( $head, $tail )= ( "/*", "\n" );
+ if( $writeperl ) {
+ $head= ' printf( "#';
+ $tail= '\\n" );' . "\n";
+ print $head, " Generated by $outfile.", $tail;
+ }
+ print $head, " Package $pkg with options:", $tail;
+ $head= " *" if ! $writeperl;
+ my $key;
+ foreach $key ( sort keys %spec ) {
+ my $val= neatvalue($spec{$key});
+ $val =~ s/\\/\\\\/g if $writeperl;
+ print $head, " $key => ", $val, $tail;
+ }
+ print $head, " Perl files eval'd:", $tail;
+ foreach $key ( @perlfile ) {
+ my $code= $perlcode{$key};
+ $code =~ s#\\#\\\\#g;
+ $code =~ s#([^ -~])#"\\".sprintf "%03o",unpack "C",$1#ge;
+ $code =~ s#"#\\"#g if $writeperl;
+ print $head, " $key => ", $code, $tail;
+ }
+ if( $writeperl ) {
+ print $head, " C files included:", $tail;
+ foreach $key ( @cfile ) {
+ my $code= $ccode{$key};
+ $code =~ s#\\#\\\\#g;
+ $code =~ s#([^ -~])#"\\".sprintf "%03o",unpack "C",$1#ge;
+ $code =~ s#"#\\"#g;
+ print $head, " $key => ", $code, $tail;
+ }
+ } else {
+ print " */\n";
+ }
+ }
+ if( ! ref($ifdef) && $ifdef =~ /[^\s\w]/ ) {
+ my $sub= $ifdef;
+ $sub= 'sub { local($_)= @_; ' . $sub . ' }'
+ unless $sub =~ /^\s*sub\b/;
+ $ifdef= eval $sub;
+ die "$@: $sub\n" if $@;
+ if( "CODE" ne ref($ifdef) ) {
+ die "IFDEF didn't create subroutine reference: eval $sub\n";
+ }
+ }
+ foreach $const ( @syms ) {
+ $if= "CODE" eq ref($ifdef) ? $ifdef->($const) : $ifdef;
+ if( ! $if ) {
+ $if= "";
+ } elsif( "1" eq $if ) {
+ $if= "#ifdef $const\n";
+ } elsif( $if !~ /^#/ ) {
+ $if= "#ifdef $if\n";
+ } else {
+ $if= "$if\n";
+ }
+ print $if
+ . qq[ const2perl( $const );\n];
+ if( $if ) {
+ print "#else\n"
+ . qq[ noconst( $const );\n]
+ . "#endif\n";
+ }
+ }
+ if( $writeperl ) {
+ print
+ qq[ printf( "1;\\n" );\n],
+ qq[ return( 0 );\n];
+ }
+ print "}\n";
+}
+
+1;
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/t/file.t b/gnu/usr.bin/perl/cpan/Win32API-File/t/file.t index cbc808c37ff..25450a5cf7e 100755 --- a/gnu/usr.bin/perl/cpan/Win32API-File/t/file.t +++ b/gnu/usr.bin/perl/cpan/Win32API-File/t/file.t @@ -1,427 +1,427 @@ -#!/usr/bin/perl -w -# Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl test.pl' - -######################### We start with some black magic to print on failure. - -BEGIN { - $|= 1; - - # when building perl, skip this test if Win32API::File isn't being built - if ( $ENV{PERL_CORE} ) { - require Config; - if ( $Config::Config{extensions} !~ m:(?<!\S)Win32API/File(?!\S): ) { - print "1..0 # Skip Win32API::File extension not built\n"; - exit(); - } - } - - print "1..270\n"; -} -END {print "not ok 1\n" unless $loaded;} - -# Win32API::File does an implicit "require Win32", but -# the ../lib directory in @INC will no longer work once -# we chdir() into the TEMP directory. - -use Win32; -use File::Spec; -use Carp; -use Carp::Heavy; - -use Win32API::File qw(:ALL); -$loaded = 1; -print "ok 1\n"; - -######################### End of black magic. - -$test= 1; - -use strict qw(subs); - -$temp= File::Spec->tmpdir(); -$dir= "W32ApiF.tmp"; - -$ENV{WINDIR} = $ENV{SYSTEMROOT} if not exists $ENV{WINDIR}; - -chdir( $temp ) - or die "# Can't cd to temp directory, $temp: $!\n"; -$tempdir = File::Spec->catdir($temp,$dir); -if( -d $dir ) { - print "# deleting ",File::Spec->catdir($temp,$dir,'*'),"\n" if glob "$dir/*"; - - for (glob "$dir/*") { - chmod 0777, $_; - unlink $_; - } - rmdir $dir or die "Could not rmdir $dir: $!"; -} -mkdir( $dir, 0777 ) - or die "# Can't create temp dir, $tempdir: $!\n"; -print "# chdir $tempdir\n"; -chdir( $dir ) - or die "# Can't cd to my dir, $tempdir: $!\n"; -$h1= createFile( "ReadOnly.txt", "r", { Attributes=>"r" } ); -$ok= ! $h1 && Win32API::File::_fileLastError() == 2; # could not find the file -$ok or print "# ","".fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 2 -if( ! $ok ) { CloseHandle($h1); unlink("ReadOnly.txt"); } - -$ok= $h1= createFile( "ReadOnly.txt", "wcn", { Attributes=>"r" } ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 3 - -$ok= WriteFile( $h1, "Original text\n", 0, [], [] ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 4 - -$h2= createFile( "ReadOnly.txt", "rcn" ); -$ok= ! $h2 && Win32API::File::_fileLastError() == 80; # file exists -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 5 -if( ! $ok ) { CloseHandle($h2); } - -$h2= createFile( "ReadOnly.txt", "rwke" ); -$ok= ! $h2 && Win32API::File::_fileLastError() == 5; # access is denied -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 6 -if( ! $ok ) { CloseHandle($h2); } - -$ok= $h2= createFile( "ReadOnly.txt", "r" ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 7 - -$ok= SetFilePointer( $h1, length("Original"), [], FILE_BEGIN ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 8 - -$ok= WriteFile( $h1, "ly was other text\n", 0, $len, [] ) - && $len == length("ly was other text\n"); -$ok or print "# <$len> should be <", - length("ly was other text\n"),">: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 9 - -$ok= ReadFile( $h2, $text, 80, $len, [] ) - && $len == length($text); -$ok or print "# <$len> should be <",length($text), - ">: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 10 - -$ok= $text eq "Originally was other text\n"; -if( !$ok ) { - $text =~ s/\r/\\r/g; $text =~ s/\n/\\n/g; - print "# <$text> should be <Originally was other text\\n>.\n"; -} -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 11 - -$ok= CloseHandle($h2); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 12 - -$ok= ! ReadFile( $h2, $text, 80, $len, [] ) - && Win32API::File::_fileLastError() == 6; # handle is invalid -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 13 - -CloseHandle($h1); - -$ok= $h1= createFile( "CanWrite.txt", "rw", FILE_SHARE_WRITE, - { Create=>CREATE_ALWAYS } ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 14 - -$ok= WriteFile( $h1, "Just this and not this", 10, [], [] ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 15 - -$ok= $h2= createFile( "CanWrite.txt", "wk", { Share=>"rw" } ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 16 - -$ok= OsFHandleOpen( "APP", $h2, "wat" ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 17 - -$ok= $h2 == GetOsFHandle( "APP" ); -$ok or print "# $h2 != ",GetOsFHandle("APP"),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 18 - -{ my $save= select(APP); $|= 1; select($save); } -$ok= print APP "is enough\n"; -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 19 - -SetFilePointer($h1, 0, [], FILE_BEGIN) if $^O eq 'cygwin'; - -$ok= ReadFile( $h1, $text, 0, [], [] ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 20 - -$ok= $text eq "is enough\r\n"; -if( !$ok ) { - $text =~ s/\r/\\r/g; - $text =~ s/\n/\\n/g; - print "# <$text> should be <is enough\\r\\n>\n"; -} -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 21 - -$skip = ""; -if ($^O eq 'cygwin') { - $ok = 1; - $skip = " # skip cygwin can delete open files"; -} -else { - unlink("CanWrite.txt"); - $ok = -e "CanWrite.txt" && $! =~ /permission denied/i; - $ok or print "# $!\n"; -} -print $ok ? "" : "not ", "ok ", ++$test, "$skip\n"; # ok 22 - -close(APP); # Also does C<CloseHandle($h2)> -## CloseHandle( $h2 ); -CloseHandle( $h1 ); - -$ok= ! DeleteFile( "ReadOnly.txt" ) - && Win32API::File::_fileLastError() == 5; # access is denied -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 23 - -$ok= ! CopyFile( "ReadOnly.txt", "CanWrite.txt", 1 ) - && Win32API::File::_fileLastError() == 80; # file exists -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 24 - -$ok= ! CopyFile( "CanWrite.txt", "ReadOnly.txt", 0 ) - && Win32API::File::_fileLastError() == 5; # access is denied -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 25 - -$ok= ! MoveFile( "NoSuchFile", "NoSuchDest" ) - && Win32API::File::_fileLastError() == 2; # not find the file -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 26 - -$ok= ! MoveFileEx( "NoSuchFile", "NoSuchDest", 0 ) - && Win32API::File::_fileLastError() == 2; # not find the file -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 27 - -$ok= ! MoveFile( "ReadOnly.txt", "CanWrite.txt" ) - && Win32API::File::_fileLastError() == 183; # file already exists -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 28 - -$ok= ! MoveFileEx( "ReadOnly.txt", "CanWrite.txt", 0 ) - && Win32API::File::_fileLastError() == 183; # file already exists -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 29 - -$ok= CopyFile( "ReadOnly.txt", "ReadOnly.cp", 1 ) - && CopyFile( "CanWrite.txt", "CanWrite.cp", 1 ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 30 - -$ok= ! MoveFileEx( "CanWrite.txt", "ReadOnly.cp", MOVEFILE_REPLACE_EXISTING ) - && (Win32API::File::_fileLastError() == 5 # access is denied - || Win32API::File::_fileLastError() == 183); # already exists -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 31 - -$ok= MoveFileEx( "ReadOnly.cp", "CanWrite.cp", MOVEFILE_REPLACE_EXISTING ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 32 - -$ok= MoveFile( "CanWrite.cp", "Moved.cp" ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 33 - -$ok= ! unlink( "ReadOnly.cp" ) - && $! =~ /no such file/i - && ! unlink( "CanWrite.cp" ) - && $! =~ /no such file/i; -$ok or print "# $!\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 34 - -$ok= ! DeleteFile( "Moved.cp" ) - && Win32API::File::_fileLastError() == 5; # access is denied -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 35 - -if ($^O eq 'cygwin') { - chmod( 0200 | 07777 & (stat("Moved.cp"))[2], "Moved.cp" ); -} -else { - system( "attrib -r Moved.cp" ); -} - -$ok= DeleteFile( "Moved.cp" ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 36 - -$new= SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX; -$old= SetErrorMode( $new ); -$renew= SetErrorMode( $old ); -$reold= SetErrorMode( $old ); - -$ok= $old == $reold; -$ok or print "# $old != $reold: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 37 - -$ok= ($renew&$new) == $new; -$ok or print "# $new != $renew: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 38 - -$ok= @drives= getLogicalDrives(); -$ok && print "# @drives\n"; -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 39 - -$ok= $drives[0] !~ /^[ab]/ || DRIVE_REMOVABLE == GetDriveType($drives[0]); -$ok or print "# ",DRIVE_REMOVABLE," != ",GetDriveType($drives[0]), - ": ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 40 - -$drive= substr( $ENV{WINDIR}, 0, 3 ); - -$ok= 1 == grep /^\Q$drive\E/i, @drives; -$ok or print "# No $drive found in list of drives.\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 41 - -$ok= DRIVE_FIXED == GetDriveType( $drive ); -$ok or print - "# ",DRIVE_FIXED," != ",GetDriveType($drive),": ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 42 - -$ok= GetVolumeInformation( $drive, $vol, 64, $ser, $max, $flag, $fs, 16 ); -$ok or print "# ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 43 -$vol= $ser= $max= $flag= $fs= ""; # Prevent warnings. - -chop($drive); -$ok= QueryDosDevice( $drive, $dev, 80 ); -$ok or print "# $drive: ",fileLastError(),"\n"; -if( $ok ) { - ( $text= $dev ) =~ s/\0/\\0/g; - print "# $drive => $text\n"; -} -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 44 - -$bits= GetLogicalDrives(); -$let= 25; -$bit= 1<<$let; -while( $bit & $bits ) { - $let--; - $bit >>= 1; -} -$let= pack( "C", $let + unpack("C","A") ) . ":"; -print "# Querying undefined $let.\n"; - -$ok= DefineDosDevice( 0, $let, $ENV{WINDIR} ); -$ok or print "# $let,$ENV{WINDIR}: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 45 - -$ok= -s $let."/Win.ini" == -s $ENV{WINDIR}."/Win.ini"; -$ok or print "# ", -s $let."/Win.ini", " vs. ", - -s $ENV{WINDIR}."/Win.ini", ": ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 46 - -$ok= DefineDosDevice( DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE, - $let, $ENV{WINDIR} ); -$ok or print "# $let,$ENV{WINDIR}: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 47 - -$ok= ! -f $let."/Win.ini" - && $! =~ /no such file/i; -$ok or print "# $!\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 48 - -$ok= DefineDosDevice( DDD_RAW_TARGET_PATH, $let, $dev ); -if( !$ok ) { - ( $text= $dev ) =~ s/\0/\\0/g; - print "# $let,$text: ",fileLastError(),"\n"; -} -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 49 - -my $path = $ENV{WINDIR}; -$ok= -f $let.substr($path,$^O eq 'cygwin'?2:3)."/win.ini"; -$ok or print "# ",$let.substr($path,3)."/win.ini ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 50 - -$ok= DefineDosDevice( DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE - |DDD_RAW_TARGET_PATH, $let, $dev ); -$ok or print "# $let,$dev: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 51 - -my $attrs = GetFileAttributes( $path ); -$ok= $attrs != INVALID_FILE_ATTRIBUTES; -$ok or print "# $path gave invalid attribute value, attrs=$attrs: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 52 - -$ok= ($attrs & FILE_ATTRIBUTE_DIRECTORY); -$ok or print "# $path not a directory, attrs=$attrs: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 53 - -$path .= "/win.ini"; -$attrs = GetFileAttributes( $path ); -$ok= $attrs != INVALID_FILE_ATTRIBUTES; -$ok or print "# $path gave invalid attribute value, attrs=$attrs: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 54 - -$ok= !($attrs & FILE_ATTRIBUTE_DIRECTORY); -$ok or print "# $path is a directory, attrs=$attrs: ",fileLastError(),"\n"; -print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 55 - -# DefineDosDevice -# GetFileType -# GetVolumeInformation -# QueryDosDevice -#Add a drive letter that points to our temp directory -#Add a drive letter that points to the drive our directory is in - -#winnt.t: -# get first drive letters and use to test disk and storage IOCTLs -# "//./PhysicalDrive0" -# DeviceIoControl - -my %consts; -my @consts= @Win32API::File::EXPORT_OK; -@consts{@consts}= @consts; - -my( @noargs, %noargs )= qw( - attrLetsToBits fileLastError getLogicalDrives GetLogicalDrives ); -@noargs{@noargs}= @noargs; - -foreach $func ( @{$Win32API::File::EXPORT_TAGS{Func}} ) { - delete $consts{$func}; - if( defined( $noargs{$func} ) ) { - $ok= ! eval("$func(0,0)") && $@ =~ /(::|\s)_?${func}A?[(:\s]/; - } else { - $ok= ! eval("$func()") && $@ =~ /(::|\s)_?${func}A?[(:\s]/; - } - $ok or print "# $func: $@\n"; - print $ok ? "" : "not ", "ok ", ++$test, "\n"; -} - -foreach $func ( @{$Win32API::File::EXPORT_TAGS{FuncA}}, - @{$Win32API::File::EXPORT_TAGS{FuncW}} ) { - $ok= ! eval("$func()") && $@ =~ /::_?${func}\(/; - delete $consts{$func}; - $ok or print "# $func: $@\n"; - print $ok ? "" : "not ", "ok ", ++$test, "\n"; -} - -foreach $const ( keys(%consts) ) { - $ok= eval("my \$x= $const(); 1"); - $ok or print "# Constant $const: $@\n"; - print $ok ? "" : "not ", "ok ", ++$test, "\n"; -} - -chdir( $temp ); -if (-e "$dir/ReadOnly.txt") { - chmod 0777, "$dir/ReadOnly.txt"; - unlink "$dir/ReadOnly.txt"; -} -unlink "$dir/CanWrite.txt" if -e "$dir/CanWrite.txt"; -rmdir $dir; - -__END__ +#!/usr/bin/perl -w
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+BEGIN {
+ $|= 1;
+
+ # when building perl, skip this test if Win32API::File isn't being built
+ if ( $ENV{PERL_CORE} ) {
+ require Config;
+ if ( $Config::Config{extensions} !~ m:(?<!\S)Win32API/File(?!\S): ) {
+ print "1..0 # Skip Win32API::File extension not built\n";
+ exit();
+ }
+ }
+
+ print "1..270\n";
+}
+END {print "not ok 1\n" unless $loaded;}
+
+# Win32API::File does an implicit "require Win32", but
+# the ../lib directory in @INC will no longer work once
+# we chdir() into the TEMP directory.
+
+use Win32;
+use File::Spec;
+use Carp;
+use Carp::Heavy;
+
+use Win32API::File qw(:ALL);
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+$test= 1;
+
+use strict qw(subs);
+
+$temp= File::Spec->tmpdir();
+$dir= "W32ApiF.tmp";
+
+$ENV{WINDIR} = $ENV{SYSTEMROOT} if not exists $ENV{WINDIR};
+
+chdir( $temp )
+ or die "# Can't cd to temp directory, $temp: $!\n";
+$tempdir = File::Spec->catdir($temp,$dir);
+if( -d $dir ) {
+ print "# deleting ",File::Spec->catdir($temp,$dir,'*'),"\n" if glob "$dir/*";
+
+ for (glob "$dir/*") {
+ chmod 0777, $_;
+ unlink $_;
+ }
+ rmdir $dir or die "Could not rmdir $dir: $!";
+}
+mkdir( $dir, 0777 )
+ or die "# Can't create temp dir, $tempdir: $!\n";
+print "# chdir $tempdir\n";
+chdir( $dir )
+ or die "# Can't cd to my dir, $tempdir: $!\n";
+$h1= createFile( "ReadOnly.txt", "r", { Attributes=>"r" } );
+$ok= ! $h1 && Win32API::File::_fileLastError() == 2; # could not find the file
+$ok or print "# ","".fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 2
+if( ! $ok ) { CloseHandle($h1); unlink("ReadOnly.txt"); }
+
+$ok= $h1= createFile( "ReadOnly.txt", "wcn", { Attributes=>"r" } );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 3
+
+$ok= WriteFile( $h1, "Original text\n", 0, [], [] );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 4
+
+$h2= createFile( "ReadOnly.txt", "rcn" );
+$ok= ! $h2 && Win32API::File::_fileLastError() == 80; # file exists
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 5
+if( ! $ok ) { CloseHandle($h2); }
+
+$h2= createFile( "ReadOnly.txt", "rwke" );
+$ok= ! $h2 && Win32API::File::_fileLastError() == 5; # access is denied
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 6
+if( ! $ok ) { CloseHandle($h2); }
+
+$ok= $h2= createFile( "ReadOnly.txt", "r" );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 7
+
+$ok= SetFilePointer( $h1, length("Original"), [], FILE_BEGIN );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 8
+
+$ok= WriteFile( $h1, "ly was other text\n", 0, $len, [] )
+ && $len == length("ly was other text\n");
+$ok or print "# <$len> should be <",
+ length("ly was other text\n"),">: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 9
+
+$ok= ReadFile( $h2, $text, 80, $len, [] )
+ && $len == length($text);
+$ok or print "# <$len> should be <",length($text),
+ ">: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 10
+
+$ok= $text eq "Originally was other text\n";
+if( !$ok ) {
+ $text =~ s/\r/\\r/g; $text =~ s/\n/\\n/g;
+ print "# <$text> should be <Originally was other text\\n>.\n";
+}
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 11
+
+$ok= CloseHandle($h2);
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 12
+
+$ok= ! ReadFile( $h2, $text, 80, $len, [] )
+ && Win32API::File::_fileLastError() == 6; # handle is invalid
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 13
+
+CloseHandle($h1);
+
+$ok= $h1= createFile( "CanWrite.txt", "rw", FILE_SHARE_WRITE,
+ { Create=>CREATE_ALWAYS } );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 14
+
+$ok= WriteFile( $h1, "Just this and not this", 10, [], [] );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 15
+
+$ok= $h2= createFile( "CanWrite.txt", "wk", { Share=>"rw" } );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 16
+
+$ok= OsFHandleOpen( "APP", $h2, "wat" );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 17
+
+$ok= $h2 == GetOsFHandle( "APP" );
+$ok or print "# $h2 != ",GetOsFHandle("APP"),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 18
+
+{ my $save= select(APP); $|= 1; select($save); }
+$ok= print APP "is enough\n";
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 19
+
+SetFilePointer($h1, 0, [], FILE_BEGIN) if $^O eq 'cygwin';
+
+$ok= ReadFile( $h1, $text, 0, [], [] );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 20
+
+$ok= $text eq "is enough\r\n";
+if( !$ok ) {
+ $text =~ s/\r/\\r/g;
+ $text =~ s/\n/\\n/g;
+ print "# <$text> should be <is enough\\r\\n>\n";
+}
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 21
+
+$skip = "";
+if ($^O eq 'cygwin') {
+ $ok = 1;
+ $skip = " # skip cygwin can delete open files";
+}
+else {
+ unlink("CanWrite.txt");
+ $ok = -e "CanWrite.txt" && $! =~ /permission denied/i;
+ $ok or print "# $!\n";
+}
+print $ok ? "" : "not ", "ok ", ++$test, "$skip\n"; # ok 22
+
+close(APP); # Also does C<CloseHandle($h2)>
+## CloseHandle( $h2 );
+CloseHandle( $h1 );
+
+$ok= ! DeleteFile( "ReadOnly.txt" )
+ && Win32API::File::_fileLastError() == 5; # access is denied
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 23
+
+$ok= ! CopyFile( "ReadOnly.txt", "CanWrite.txt", 1 )
+ && Win32API::File::_fileLastError() == 80; # file exists
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 24
+
+$ok= ! CopyFile( "CanWrite.txt", "ReadOnly.txt", 0 )
+ && Win32API::File::_fileLastError() == 5; # access is denied
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 25
+
+$ok= ! MoveFile( "NoSuchFile", "NoSuchDest" )
+ && Win32API::File::_fileLastError() == 2; # not find the file
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 26
+
+$ok= ! MoveFileEx( "NoSuchFile", "NoSuchDest", 0 )
+ && Win32API::File::_fileLastError() == 2; # not find the file
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 27
+
+$ok= ! MoveFile( "ReadOnly.txt", "CanWrite.txt" )
+ && Win32API::File::_fileLastError() == 183; # file already exists
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 28
+
+$ok= ! MoveFileEx( "ReadOnly.txt", "CanWrite.txt", 0 )
+ && Win32API::File::_fileLastError() == 183; # file already exists
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 29
+
+$ok= CopyFile( "ReadOnly.txt", "ReadOnly.cp", 1 )
+ && CopyFile( "CanWrite.txt", "CanWrite.cp", 1 );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 30
+
+$ok= ! MoveFileEx( "CanWrite.txt", "ReadOnly.cp", MOVEFILE_REPLACE_EXISTING )
+ && (Win32API::File::_fileLastError() == 5 # access is denied
+ || Win32API::File::_fileLastError() == 183); # already exists
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 31
+
+$ok= MoveFileEx( "ReadOnly.cp", "CanWrite.cp", MOVEFILE_REPLACE_EXISTING );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 32
+
+$ok= MoveFile( "CanWrite.cp", "Moved.cp" );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 33
+
+$ok= ! unlink( "ReadOnly.cp" )
+ && $! =~ /no such file/i
+ && ! unlink( "CanWrite.cp" )
+ && $! =~ /no such file/i;
+$ok or print "# $!\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 34
+
+$ok= ! DeleteFile( "Moved.cp" )
+ && Win32API::File::_fileLastError() == 5; # access is denied
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 35
+
+if ($^O eq 'cygwin') {
+ chmod( 0200 | 07777 & (stat("Moved.cp"))[2], "Moved.cp" );
+}
+else {
+ system( "attrib -r Moved.cp" );
+}
+
+$ok= DeleteFile( "Moved.cp" );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 36
+
+$new= SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX;
+$old= SetErrorMode( $new );
+$renew= SetErrorMode( $old );
+$reold= SetErrorMode( $old );
+
+$ok= $old == $reold;
+$ok or print "# $old != $reold: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 37
+
+$ok= ($renew&$new) == $new;
+$ok or print "# $new != $renew: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 38
+
+$ok= @drives= getLogicalDrives();
+$ok && print "# @drives\n";
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 39
+
+$ok= $drives[0] !~ /^[ab]/ || DRIVE_REMOVABLE == GetDriveType($drives[0]);
+$ok or print "# ",DRIVE_REMOVABLE," != ",GetDriveType($drives[0]),
+ ": ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 40
+
+$drive= substr( $ENV{WINDIR}, 0, 3 );
+
+$ok= 1 == grep /^\Q$drive\E/i, @drives;
+$ok or print "# No $drive found in list of drives.\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 41
+
+$ok= DRIVE_FIXED == GetDriveType( $drive );
+$ok or print
+ "# ",DRIVE_FIXED," != ",GetDriveType($drive),": ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 42
+
+$ok= GetVolumeInformation( $drive, $vol, 64, $ser, $max, $flag, $fs, 16 );
+$ok or print "# ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 43
+$vol= $ser= $max= $flag= $fs= ""; # Prevent warnings.
+
+chop($drive);
+$ok= QueryDosDevice( $drive, $dev, 80 );
+$ok or print "# $drive: ",fileLastError(),"\n";
+if( $ok ) {
+ ( $text= $dev ) =~ s/\0/\\0/g;
+ print "# $drive => $text\n";
+}
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 44
+
+$bits= GetLogicalDrives();
+$let= 25;
+$bit= 1<<$let;
+while( $bit & $bits ) {
+ $let--;
+ $bit >>= 1;
+}
+$let= pack( "C", $let + unpack("C","A") ) . ":";
+print "# Querying undefined $let.\n";
+
+$ok= DefineDosDevice( 0, $let, $ENV{WINDIR} );
+$ok or print "# $let,$ENV{WINDIR}: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 45
+
+$ok= -s $let."/Win.ini" == -s $ENV{WINDIR}."/Win.ini";
+$ok or print "# ", -s $let."/Win.ini", " vs. ",
+ -s $ENV{WINDIR}."/Win.ini", ": ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 46
+
+$ok= DefineDosDevice( DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE,
+ $let, $ENV{WINDIR} );
+$ok or print "# $let,$ENV{WINDIR}: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 47
+
+$ok= ! -f $let."/Win.ini"
+ && $! =~ /no such file/i;
+$ok or print "# $!\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 48
+
+$ok= DefineDosDevice( DDD_RAW_TARGET_PATH, $let, $dev );
+if( !$ok ) {
+ ( $text= $dev ) =~ s/\0/\\0/g;
+ print "# $let,$text: ",fileLastError(),"\n";
+}
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 49
+
+my $path = $ENV{WINDIR};
+$ok= -f $let.substr($path,$^O eq 'cygwin'?2:3)."/win.ini";
+$ok or print "# ",$let.substr($path,3)."/win.ini ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 50
+
+$ok= DefineDosDevice( DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE
+ |DDD_RAW_TARGET_PATH, $let, $dev );
+$ok or print "# $let,$dev: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 51
+
+my $attrs = GetFileAttributes( $path );
+$ok= $attrs != INVALID_FILE_ATTRIBUTES;
+$ok or print "# $path gave invalid attribute value, attrs=$attrs: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 52
+
+$ok= ($attrs & FILE_ATTRIBUTE_DIRECTORY);
+$ok or print "# $path not a directory, attrs=$attrs: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 53
+
+$path .= "/win.ini";
+$attrs = GetFileAttributes( $path );
+$ok= $attrs != INVALID_FILE_ATTRIBUTES;
+$ok or print "# $path gave invalid attribute value, attrs=$attrs: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 54
+
+$ok= !($attrs & FILE_ATTRIBUTE_DIRECTORY);
+$ok or print "# $path is a directory, attrs=$attrs: ",fileLastError(),"\n";
+print $ok ? "" : "not ", "ok ", ++$test, "\n"; # ok 55
+
+# DefineDosDevice
+# GetFileType
+# GetVolumeInformation
+# QueryDosDevice
+#Add a drive letter that points to our temp directory
+#Add a drive letter that points to the drive our directory is in
+
+#winnt.t:
+# get first drive letters and use to test disk and storage IOCTLs
+# "//./PhysicalDrive0"
+# DeviceIoControl
+
+my %consts;
+my @consts= @Win32API::File::EXPORT_OK;
+@consts{@consts}= @consts;
+
+my( @noargs, %noargs )= qw(
+ attrLetsToBits fileLastError getLogicalDrives GetLogicalDrives );
+@noargs{@noargs}= @noargs;
+
+foreach $func ( @{$Win32API::File::EXPORT_TAGS{Func}} ) {
+ delete $consts{$func};
+ if( defined( $noargs{$func} ) ) {
+ $ok= ! eval("$func(0,0)") && $@ =~ /(::|\s)_?${func}A?[(:\s]/;
+ } else {
+ $ok= ! eval("$func()") && $@ =~ /(::|\s)_?${func}A?[(:\s]/;
+ }
+ $ok or print "# $func: $@\n";
+ print $ok ? "" : "not ", "ok ", ++$test, "\n";
+}
+
+foreach $func ( @{$Win32API::File::EXPORT_TAGS{FuncA}},
+ @{$Win32API::File::EXPORT_TAGS{FuncW}} ) {
+ $ok= ! eval("$func()") && $@ =~ /::_?${func}\(/;
+ delete $consts{$func};
+ $ok or print "# $func: $@\n";
+ print $ok ? "" : "not ", "ok ", ++$test, "\n";
+}
+
+foreach $const ( keys(%consts) ) {
+ $ok= eval("my \$x= $const(); 1");
+ $ok or print "# Constant $const: $@\n";
+ print $ok ? "" : "not ", "ok ", ++$test, "\n";
+}
+
+chdir( $temp );
+if (-e "$dir/ReadOnly.txt") {
+ chmod 0777, "$dir/ReadOnly.txt";
+ unlink "$dir/ReadOnly.txt";
+}
+unlink "$dir/CanWrite.txt" if -e "$dir/CanWrite.txt";
+rmdir $dir;
+
+__END__
diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/t/tie.t b/gnu/usr.bin/perl/cpan/Win32API-File/t/tie.t index 34b1cd73060..262550ddbdd 100755 --- a/gnu/usr.bin/perl/cpan/Win32API-File/t/tie.t +++ b/gnu/usr.bin/perl/cpan/Win32API-File/t/tie.t @@ -4,89 +4,70 @@ BEGIN { $|= 1; + use Test::More; + # when building perl, skip this test if Win32API::File isn't being built if ( $ENV{PERL_CORE} ) { - require Config; - if ( $Config::Config{extensions} !~ m:(?<!\S)Win32API/File(?!\S): ) { - print "1..0 # Skip Win32API::File extension not built\n"; - exit(); - } + require Config; + if ( $Config::Config{extensions} !~ m:(?<!\S)Win32API/File(?!\S): ) { + plan skip_all => 'Skip Win32API::File extension not built'; + exit; + } } - print "1..10\n"; + plan tests => 10; } -END { print "not ok 1\n" unless $main::loaded; } use strict; use warnings; use Win32API::File qw(:ALL); use IO::File; -$main::loaded = 1; - -print "ok 1\n"; +my $filename = 'foo.txt'; +ok(! -e $filename || unlink($filename), "unlinked $filename (if it existed)"); -unlink "foo.txt"; - -my $fh = Win32API::File->new("+> foo.txt") - or die fileLastError(); +my $fh = Win32API::File->new("+> $filename") + or die fileLastError(); my $tell = tell $fh; -print "# tell \$fh == '$tell'\n"; -print "not " unless - tell $fh == 0; -print "ok 2\n"; +is(0+$tell, 0, "tell \$fh == '$tell'"); my $text = "some text\n"; -print "not " unless - print $fh $text; -print "ok 3\n"; +ok(print($fh $text), "printed 'some text\\n'"); $tell = tell $fh; -print "# after printing 'some text\\n', tell is: '$tell'\n"; -print "not " unless - $tell == length($text) + 1; -print "ok 4\n"; +my $len = length($text) + 1; # + 1 for cr +is($tell, $len, "after printing 'some text\\n', tell is: '$tell'"); -print "not " unless - seek($fh, 0, 0) == 0; -print "ok 5\n"; +my $seek = seek($fh, 0, 0); +is(0+$seek, 0, "seek is: '$seek'"); -print "not " unless - not eof $fh; -print "ok 6\n"; +my $eof = eof $fh; +ok(! $eof, 'not eof'); my $readline = <$fh>; my $pretty_readline = $readline; -$pretty_readline =~ s/\r/\\r/g; $pretty_readline =~ s/\n/\\n/g; -print "# read line is '$pretty_readline'\n"; - -print "not " unless - $readline eq "some text\r\n"; -print "ok 7\n"; +$pretty_readline =~ s/\r/\\r/g; $pretty_readline =~ s/\n/\\n/g; +is($pretty_readline, "some text\\r\\n", "read line is '$pretty_readline'"); -print "not " unless - eof $fh; -print "ok 8\n"; +$eof = eof $fh; +ok($eof, 'reached eof'); -print "not " unless - close $fh; -print "ok 9\n"; +ok(close($fh), 'closed filehandle'); # Test out binmode (should be only LF with print, no CR). -$fh = Win32API::File->new("+> foo.txt") - or die fileLastError(); +$fh = Win32API::File->new("+> $filename") + or die fileLastError(); binmode $fh; print $fh "hello there\n"; seek $fh, 0, 0; -print "not " unless - <$fh> eq "hello there\n"; -print "ok 10\n"; +$readline = <$fh>; +is($readline, "hello there\n", "binmode worked (no CR)"); close $fh; -unlink "foo.txt"; +unlink $filename; diff --git a/gnu/usr.bin/perl/cpan/Win32API-File/typemap b/gnu/usr.bin/perl/cpan/Win32API-File/typemap index 21347121095..76c8196ffe3 100644 --- a/gnu/usr.bin/perl/cpan/Win32API-File/typemap +++ b/gnu/usr.bin/perl/cpan/Win32API-File/typemap @@ -1,140 +1,140 @@ -BOOL T_BOOL -LONG T_IV -HKEY T_UV -HANDLE T_UV -DWORD T_UV -oDWORD O_UV -UINT T_UV -REGSAM T_UV -SECURITY_INFORMATION T_UV -char * T_BUF -WCHAR * T_BUF -BYTE * T_BUF -void * T_BUF -ValEntA * T_BUF -ValEntW * T_BUF -SECURITY_DESCRIPTOR * T_BUF -SECURITY_ATTRIBUTES * T_BUF -LPOVERLAPPED T_BUF -LONG * T_IVBUF -DWORD * T_UVBUF -LPDWORD T_UVBUF -oDWORD * O_UVBUF -HKEY * T_UVBUFP -oHKEY * O_UVBUFP -FILETIME * T_SBUF - -############################################################################# -INPUT -T_BOOL - $var= null_arg($arg)||!SvTRUE($arg) ? ($type)0 : looks_like_number($arg) ? ($type)SvIV($arg) : ($type)1 -T_BUF - if( null_arg($arg) ) - $var= NULL; - else - $var= ($type) SvPV_nolen( $arg ) -T_SBUF - grow_buf( $var,$arg, $type ) -T_IV - $var= null_arg($arg) ? ($type)0 : INT2PTR($type,SvIV($arg)) -T_UV - $var= null_arg($arg) ? ($type)0 : INT2PTR($type,SvUV($arg)) -O_IV - $var= optIV($arg) -O_UV - $var= optUV($arg) -T_IVBUF - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= SvIV($arg) -T_UVBUF - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= SvUV($arg) -O_IVBUF - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= - SvOK($arg) ? SvIV($arg) : 0; -O_UVBUF - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= - SvOK($arg) ? SvUV($arg) : 0; -T_IVBUFP - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= (void *)SvIV($arg) -T_UVBUFP - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= (void *)SvUV($arg) -O_IVBUFP - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= - SvOK($arg) ? (void *)SvIV($arg) : 0; -O_UVBUFP - if( null_arg($arg) ) - $var= NULL; - else - *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= - SvOK($arg) ? (void *)SvUV($arg) : 0; - -############################################################################# -OUTPUT -T_BOOL - if( ! null_arg($arg) && ! SvREADONLY($arg) ) { - if( $var ) { - sv_setiv( $arg, (IV)$var ); - } else { - sv_setsv( $arg, &PL_sv_no ); - } - } -T_BUF - ; -T_SBUF - trunc_buf( RETVAL, $var,$arg ); -T_IV - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setiv( $arg, PTR2IV($var) ); -T_UV - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setuv( $arg, PTR2UV($var) ); -O_IV - if( ! null_arg($arg) ) - sv_setiv( $arg, PTR2IV($var) ); -O_UV - if( ! null_arg($arg) ) - sv_setuv( $arg, PTR2UV($var) ); -T_IVBUF - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setiv( $arg, (IV)*($var) ); -T_UVBUF - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setuv( $arg, (UV)*($var) ); -O_IVBUF - if( ! null_arg($arg) ) - sv_setiv( $arg, (IV)*($var) ); -O_UVBUF - if( ! null_arg($arg) ) - sv_setuv( $arg, (UV)*($var) ); -T_IVBUFP - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setiv( $arg, (IV)*($var) ); -T_UVBUFP - if( ! null_arg($arg) && ! SvREADONLY($arg) ) - sv_setuv( $arg, (UV)*($var) ); -O_IVBUFP - if( ! null_arg($arg) ) - sv_setiv( $arg, (IV)*($var) ); -O_UVBUFP - if( ! null_arg($arg) ) - sv_setuv( $arg, (UV)*($var) ); +BOOL T_BOOL
+LONG T_IV
+HKEY T_UV
+HANDLE T_UV
+DWORD T_UV
+oDWORD O_UV
+UINT T_UV
+REGSAM T_UV
+SECURITY_INFORMATION T_UV
+char * T_BUF
+WCHAR * T_BUF
+BYTE * T_BUF
+void * T_BUF
+ValEntA * T_BUF
+ValEntW * T_BUF
+SECURITY_DESCRIPTOR * T_BUF
+SECURITY_ATTRIBUTES * T_BUF
+LPOVERLAPPED T_BUF
+LONG * T_IVBUF
+DWORD * T_UVBUF
+LPDWORD T_UVBUF
+oDWORD * O_UVBUF
+HKEY * T_UVBUFP
+oHKEY * O_UVBUFP
+FILETIME * T_SBUF
+
+#############################################################################
+INPUT
+T_BOOL
+ $var= null_arg($arg)||!SvTRUE($arg) ? ($type)0 : looks_like_number($arg) ? ($type)SvIV($arg) : ($type)1
+T_BUF
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ $var= ($type) SvPV_nolen( $arg )
+T_SBUF
+ grow_buf( $var,$arg, $type )
+T_IV
+ $var= null_arg($arg) ? ($type)0 : INT2PTR($type,SvIV($arg))
+T_UV
+ $var= null_arg($arg) ? ($type)0 : INT2PTR($type,SvUV($arg))
+O_IV
+ $var= optIV($arg)
+O_UV
+ $var= optUV($arg)
+T_IVBUF
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= SvIV($arg)
+T_UVBUF
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= SvUV($arg)
+O_IVBUF
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )=
+ SvOK($arg) ? SvIV($arg) : 0;
+O_UVBUF
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )=
+ SvOK($arg) ? SvUV($arg) : 0;
+T_IVBUFP
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= (void *)SvIV($arg)
+T_UVBUFP
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )= (void *)SvUV($arg)
+O_IVBUFP
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )=
+ SvOK($arg) ? (void *)SvIV($arg) : 0;
+O_UVBUFP
+ if( null_arg($arg) )
+ $var= NULL;
+ else
+ *( $var= ($type) TempAlloc( sizeof(*($var)) ) )=
+ SvOK($arg) ? (void *)SvUV($arg) : 0;
+
+#############################################################################
+OUTPUT
+T_BOOL
+ if( ! null_arg($arg) && ! SvREADONLY($arg) ) {
+ if( $var ) {
+ sv_setiv( $arg, (IV)$var );
+ } else {
+ sv_setsv( $arg, &PL_sv_no );
+ }
+ }
+T_BUF
+ ;
+T_SBUF
+ trunc_buf( RETVAL, $var,$arg );
+T_IV
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setiv( $arg, PTR2IV($var) );
+T_UV
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setuv( $arg, PTR2UV($var) );
+O_IV
+ if( ! null_arg($arg) )
+ sv_setiv( $arg, PTR2IV($var) );
+O_UV
+ if( ! null_arg($arg) )
+ sv_setuv( $arg, PTR2UV($var) );
+T_IVBUF
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setiv( $arg, (IV)*($var) );
+T_UVBUF
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setuv( $arg, (UV)*($var) );
+O_IVBUF
+ if( ! null_arg($arg) )
+ sv_setiv( $arg, (IV)*($var) );
+O_UVBUF
+ if( ! null_arg($arg) )
+ sv_setuv( $arg, (UV)*($var) );
+T_IVBUFP
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setiv( $arg, (IV)*($var) );
+T_UVBUFP
+ if( ! null_arg($arg) && ! SvREADONLY($arg) )
+ sv_setuv( $arg, (UV)*($var) );
+O_IVBUFP
+ if( ! null_arg($arg) )
+ sv_setiv( $arg, (IV)*($var) );
+O_UVBUFP
+ if( ! null_arg($arg) )
+ sv_setuv( $arg, (UV)*($var) );
|