Chipcard-PCSC

 view release on metacpan or  search on metacpan

Card/Card.pm  view on Meta::CPAN

	if (defined ($self->{hCard}))
	{
		warn ("PCSCCard object $self deleted but still connected");
	}
} # DESTROY

# Usage:
# $text = ISO7816Error($sw)
#
# return the text version of the ISO 7816-4 error given in $sw
sub ISO7816Error($)
{
	my $sw = shift;

	# default error message
	my $text = "Error not defined by ISO 7816";

	return "wrong SW size for: $sw" unless (length($sw) == 5);

	# split the two error bytes
	my ($sw1, $sw2) = split / /, $sw;

PCSC.pm  view on Meta::CPAN


);
$VERSION = 'v1.4.16';

bootstrap Chipcard::PCSC $VERSION;

# Preloaded methods go here.

# We start with some basic conversion function here. They are global to
# the package and should not be used through an object instance
sub array_to_ascii($)
{
	my $byte_array_ref = shift;

	confess ("wrong type") unless ref ($byte_array_ref);
	confess ('usage Chipcard::PCSC::array_to_ascii($string)') unless defined $byte_array_ref;

	# return an empty string for an empty list
	return "" if (! @{$byte_array_ref});

	my $return_string;

PCSC.pm  view on Meta::CPAN

	# format the string with the array's contents
	foreach $tmpVal (@{$byte_array_ref}) {
		$return_string .= sprintf ("%02X ", $tmpVal);
	};

	# remove the trailing space or do nothing if the string is empty
	chop $return_string;
	return $return_string;
}

sub ascii_to_array($)
{
	my $ascii_string = shift;
	my @return_array;
	my $tmpVal;

	confess ('usage Chipcard::PCSC::ascii_to_array($string)') unless defined $ascii_string;

	foreach $tmpVal (split / /, $ascii_string) {
		croak ("ascii_to_array: wrong value ($tmpVal)") unless ($tmpVal =~ m/^[0-9a-f][0-9a-f]$/i);
		push @return_array, hex ($tmpVal);

PCSC.pm  view on Meta::CPAN

	# Apply default values when required
	$scope = $Chipcard::PCSC::SCARD_SCOPE_SYSTEM unless (defined ($scope));
	$remote_host = 0 unless (defined ($remote_host));

	$container->{hContext} = _EstablishContext ($scope, $remote_host, 0);

	return undef unless (defined($container->{hContext}));
	return bless $container, $class;
}

sub ListReaders($)
{
	my $self = shift;
	confess ("wrong type") unless ref $self;

	my $group = shift;
	# group is null if not given
#	$group = 0 unless (defined ($group));

	return _ListReaders ($self->{hContext}, $group);
}

sub GetStatusChange($)
{
	my $self = shift;
	confess ("wrong type") unless ref $self;

	my $readers_state = shift;
	my $nTimeout = shift;

	# The default timeout value is something supposed to be infinite
	$nTimeout = 0xFFFFFFFF unless (defined ($nTimeout));

	return _GetStatusChange ($self->{hContext}, $nTimeout, $readers_state);
}

sub Cancel($)
{
	my $self = shift;
	confess ("wrong type") unless ref $self;

	return _Cancel ($self->{hContext});
}

sub DESTROY($)
{
	my $self = shift;
	confess ("wrong type") unless ref $self;

	# Release Chipcard::PCSC context when the object is about to be destroyed
	my $return_val = _ReleaseContext ($self->{hContext});

	# die in case of an error
	confess ("Can't release context $self->{hContext}: $!") unless (defined ($return_val));
}



( run in 0.301 second using v1.01-cache-2.11-cpan-1f129e94a17 )