Result:
found more than 948 distributions - search limited to the first 2001 files matching your query ( run in 0.772 )


Compress-Raw-Zlib

 view release on metacpan or  search on metacpan

zlib-src/zlib.h  view on Meta::CPAN

  flush options, and so can be used to determine the amount of currently
  consumed input in bits.

    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
  end of each deflate block header is reached, before any actual data in that
  block is decoded.  This allows the caller to determine the length of the
  deflate block header for later use in random access within a deflate block.
  256 is added to the value of strm->data_type when inflate() returns
  immediately after reaching the end of the deflate block header.

    inflate() should normally be called until it returns Z_STREAM_END or an

zlib-src/zlib.h  view on Meta::CPAN

   above on the use in deflateInit2() applies to the magnitude of windowBits.

     windowBits can also be greater than 15 for optional gzip decoding.  Add
   32 to windowBits to enable zlib and gzip decoding with automatic header
   detection, or add 16 to decode only the gzip format (the zlib format will
   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see
   below), inflate() will *not* automatically decode concatenated gzip members.
   inflate() will return Z_STREAM_END at the end of the gzip member.  The state
   would need to be reset to continue decoding a subsequent gzip member.  This
   *must* be done if there is more data after a gzip member, in order for the

zlib-src/zlib.h  view on Meta::CPAN

     inflateGetHeader() requests that gzip header information be stored in the
   provided gz_header structure.  inflateGetHeader() may be called after
   inflateInit2() or inflateReset(), and before the first call of inflate().
   As inflate() processes the gzip stream, head->done is zero until the header
   is completed, at which time head->done is set to one.  If a zlib stream is
   being decoded, then head->done is set to -1 to indicate that there will be
   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
   used to force inflate() to return immediately after header processing is
   complete and before any actual data is decompressed.

     The text, time, xflags, and os fields are filled in with the gzip header

 view all matches for this distribution


Compress-Snappy

 view release on metacpan or  search on metacpan

src/csnappy.h  view on Meta::CPAN

 * REQUIRES: start points to compressed data.
 * REQUIRES: n is length of available compressed data.
 *
 * Returns SNAPPY_E_HEADER_BAD on error.
 * Returns number of bytes read from input on success.
 * Stores decoded length into *result.
 */
int
csnappy_get_uncompressed_length(
	const char *start,
	uint32_t n,

 view all matches for this distribution


Compress-Stream-Zstd

 view release on metacpan or  search on metacpan

ext/zstd/CHANGELOG  view on Meta::CPAN

lib : changed : reduced usage  of stack memory
lib : fixed : several corner case bugs, by Nick Terrell
cli : new : gzstd, experimental version able to decode .gz files, by Przemyslaw Skibinski
cli : new : preserve file attributes
cli : new : added zstdless and zstdgrep tools
cli : fixed : status displays total amount decoded, even for file consisting of multiple frames (like pzstd)
cli : fixed : zstdcat
zlib_wrapper : added support for gz* functions, by Przemyslaw Skibinski
install : better compatibility with FreeBSD, by Dimitry Andric
source tree : changed : zbuff source files moved to lib/deprecated

 view all matches for this distribution


Compress-Zopfli

 view release on metacpan or  search on metacpan

zopflib/src/zopflipng/lodepng/lodepng.cpp  view on Meta::CPAN

    decode the symbol from the tree. The "readBitFromStream" code is inlined in
    the expression below because this is the biggest bottleneck while decoding
    */
    ct = codetree->tree2d[(treepos << 1) + READBIT(*bp, in)];
    ++(*bp);
    if(ct < codetree->numcodes) return ct; /*the symbol is decoded, return it*/
    else treepos = ct - codetree->numcodes; /*symbol not yet decoded, instead move tree position*/

    if(treepos >= codetree->numcodes) return (unsigned)(-1); /*error: it appeared outside the codetree*/
  }
}
#endif /*LODEPNG_COMPILE_DECODER*/

zopflib/src/zopflipng/lodepng/lodepng.cpp  view on Meta::CPAN

  unsigned error = 0;
  unsigned i;

  unsigned length, string2_begin;
  char *key = 0;
  ucvector decoded;

  ucvector_init(&decoded);

  while(!error) /*not really a while loop, only used to break on error*/
  {
    for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
    if(length + 2 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/

zopflib/src/zopflipng/lodepng/lodepng.cpp  view on Meta::CPAN

    string2_begin = length + 2;
    if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/

    length = chunkLength - string2_begin;
    /*will fail if zlib error, e.g. if length is too small*/
    error = zlib_decompress(&decoded.data, &decoded.size,
                            (unsigned char*)(&data[string2_begin]),
                            length, zlibsettings);
    if(error) break;
    ucvector_push_back(&decoded, 0);

    error = lodepng_add_text(info, key, (char*)decoded.data);

    break;
  }

  lodepng_free(key);
  ucvector_cleanup(&decoded);

  return error;
}

/*international text chunk (iTXt)*/

zopflib/src/zopflipng/lodepng/lodepng.cpp  view on Meta::CPAN

  unsigned error = 0;
  unsigned i;

  unsigned length, begin, compressed;
  char *key = 0, *langtag = 0, *transkey = 0;
  ucvector decoded;
  ucvector_init(&decoded);

  while(!error) /*not really a while loop, only used to break on error*/
  {
    /*Quick check if the chunk length isn't too small. Even without check
    it'd still fail with other error checks below if it's too short. This just gives a different error code.*/

zopflib/src/zopflipng/lodepng/lodepng.cpp  view on Meta::CPAN

    length = chunkLength < begin ? 0 : chunkLength - begin;

    if(compressed)
    {
      /*will fail if zlib error, e.g. if length is too small*/
      error = zlib_decompress(&decoded.data, &decoded.size,
                              (unsigned char*)(&data[begin]),
                              length, zlibsettings);
      if(error) break;
      if(decoded.allocsize < decoded.size) decoded.allocsize = decoded.size;
      ucvector_push_back(&decoded, 0);
    }
    else
    {
      if(!ucvector_resize(&decoded, length + 1)) CERROR_BREAK(error, 83 /*alloc fail*/);

      decoded.data[length] = 0;
      for(i = 0; i != length; ++i) decoded.data[i] = data[begin + i];
    }

    error = lodepng_add_itext(info, key, langtag, transkey, (char*)decoded.data);

    break;
  }

  lodepng_free(key);
  lodepng_free(langtag);
  lodepng_free(transkey);
  ucvector_cleanup(&decoded);

  return error;
}

static unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)

 view all matches for this distribution


Compress-Zstd

 view release on metacpan or  search on metacpan

ext/zstd/CHANGELOG  view on Meta::CPAN

lib : changed : reduced usage  of stack memory
lib : fixed : several corner case bugs, by Nick Terrell
cli : new : gzstd, experimental version able to decode .gz files, by Przemyslaw Skibinski
cli : new : preserve file attributes
cli : new : added zstdless and zstdgrep tools
cli : fixed : status displays total amount decoded, even for file consisting of multiple frames (like pzstd)
cli : fixed : zstdcat
zlib_wrapper : added support for gz* functions, by Przemyslaw Skibinski
install : better compatibility with FreeBSD, by Dimitry Andric
source tree : changed : zbuff source files moved to lib/deprecated

 view all matches for this distribution


Compression-Util

 view release on metacpan or  search on metacpan

examples/bzip2_decompressor.pl  view on Meta::CPAN

            my @zrle;
            my $code = '';

            my $sel_idx = 0;
            my $tree    = $huffman_trees[$sels->[$sel_idx]];
            my $decoded = 50;

            while (!eof($fh)) {
                $code .= read_bit($fh, \$buffer);

                if (length($code) > $MaxHuffmanBits) {

examples/bzip2_decompressor.pl  view on Meta::CPAN

                    }

                    push @zrle, $sym;
                    $code = '';

                    if (--$decoded <= 0) {
                        if (++$sel_idx <= $#$sels) {
                            $tree = $huffman_trees[$sels->[$sel_idx]];
                        }
                        else {
                            die "No more selectors";    # should not happen
                        }
                        $decoded = 50;
                    }
                }
            }

            ##say STDERR "ZRLE: (@zrle)";

 view all matches for this distribution


Conclave-OTK

 view release on metacpan or  search on metacpan

lib/Conclave/OTK/Backend/4store.pm  view on Meta::CPAN


  unless ($response->is_success) {
    print STDERR "Query failed: ", $response->status_line, "\n";
  }
  else {
    my $tsv = $response->decoded_content;
    # FIXME
    my @lines = split /\n/, $tsv;
    shift @lines;
    foreach my $triple (@lines) {
      $triple =~ s/[<>]//g;

 view all matches for this distribution


Concurrent-Object

 view release on metacpan or  search on metacpan

lib/Concurrent/Data/Serializer.pm  view on Meta::CPAN


sub deserialize {

    my ($self, $string) = @_;
    $string =~ s/\0/\n/mg;
    my $decoded = decode_base64 ($string);
    return $$self{Method} eq "Dumper" ? eval $decoded : thaw( $decoded );

}


1;

 view all matches for this distribution


Conductrics-Agent

 view release on metacpan or  search on metacpan

lib/Conductrics/Agent.pm  view on Meta::CPAN

    }

    my $response = $ua->get($uri);
    if ($response->is_success) {
	if ($response->code != 200) {
	    warn "Content: ", $response->decoded_content;  # or whatever
	    warn "Code: ", $response->code;
	    warn "Err:", $response->message;
	    warn "Something get wrong on response";
	    warn Dumper($response);
	}

	JSON::MaybeXS::decode_json($response->decoded_content);
    } else {
	warn "Content: ", $response->decoded_content;  # or whatever
	warn "Code: ", $response->code;
	warn "Err:", $response->message;
	die $response->status_line;
    }
}

 view all matches for this distribution


Conductrics-Client

 view release on metacpan or  search on metacpan

lib/Conductrics/Client.pm  view on Meta::CPAN

    $request->header(Content_Type => 'application/json');
    #use Data::Dumper;
    #print Dumper($request);
    my $response = $ua->request($request);
    if ($response->is_success) {
	return JSON::MaybeXS::decode_json($response->decoded_content);
    } else {
	warn "Content: ", $response->decoded_content;  # or whatever
	warn "Code: ", $response->code;
	warn "Err:", $response->message;
	die $response->status_line;
    }
}

lib/Conductrics/Client.pm  view on Meta::CPAN

    }

    my $request = HTTP::Request->new("DELETE", $uri);
    my $response = $ua->request($request);
    if ($response->is_success) {
	return JSON::MaybeXS::decode_json($response->decoded_content);
    } else {
	warn "Content: ", $response->decoded_content;  # or whatever
	warn "Code: ", $response->code;
	warn "Err:", $response->message;
	die $response->status_line;
    }
}

lib/Conductrics/Client.pm  view on Meta::CPAN

    unless (defined $url) {
	$url = 'http://api.conductrics.com/' . $self->ownerCode . '/schema/agent';
    }
    my $response = $ua->get($url);
    if ($response->is_success) {
	return $response->decoded_content;
    } 
    warn "Content: ", $response->decoded_content;  # or whatever
    warn "Code: ", $response->code;
    warn "Err:", $response->message;
    die $response->status_line;
}

 view all matches for this distribution


Config-App

 view release on metacpan or  search on metacpan

lib/Config/App.pm  view on Meta::CPAN

            );

            my $res = $ua->get( $input->{include} );

            if ( $res->is_success ) {
                return $res->decoded_content;
            }
            else {
                croak 'Failed to get '
                    . join( ' -> ', map { "\"$_\"" } @{ $input->{sources} } )
                    . '; '

 view all matches for this distribution


Config-IOD-Reader

 view release on metacpan or  search on metacpan

lib/Config/IOD/Base.pm  view on Meta::CPAN

    }

    \@argv;
}

# return ($err, $res, $decoded_val)
sub _parse_raw_value {
    my ($self, $val, $needs_res) = @_;

    if ($val =~ /\A!/ && $self->{enable_encoding}) {

 view all matches for this distribution


Config-IOD

 view release on metacpan or  search on metacpan

lib/Config/IOD/Document.pm  view on Meta::CPAN

            $_merge->() if defined($merge) && $num_seen_section_lines > 1;
            $cur_section = $line->[COL_S_SECTION];
            $parser->{_cur_section} = $cur_section if $parser->{enable_expr}; #TMP HACK
            $res->{$cur_section} //= {};
        } elsif ($type eq 'K') {
            # the common case is that value are not decoded or
            # quoted/bracketed/braced, so we avoid calling _parse_raw_value here
            # to avoid overhead
            my $key = $line->[COL_K_KEY];
            my $val = $line->[COL_K_VALUE_RAW];
            if ($val =~ /\A["!\\[\{]/) {
                my ($err, $parse_res, $decoded_val) =
                    $parser->_parse_raw_value($val);
                die "IOD document:$linum: Invalid value: $err" if $err;
                $val = $decoded_val;
            } else {
                $val =~ s/\s*[#;].*//; # strip comment
            }

            if (exists $res->{$cur_section}{$key}) {

lib/Config/IOD/Document.pm  view on Meta::CPAN

=item * cond => code

Will only delete key if C<cond> returns true. C<cond> will be called with C<<
($self, %args) >> where the hash will contain these keys: C<linum> (int, line
number), C<parsed> (array, parsed line), C<key> (string, key name), C<value>
(NOT YET IMPLEMENTED), C<raw_value> (str, raw/undecoded value).

=back

=head2 $doc->delete_section([\%opts, ]$section) => $num_deleted

lib/Config/IOD/Document.pm  view on Meta::CPAN

=back

=head2 $doc->dump([ \%opts ]) => hoh

Return a hoh (hash of section names and hashes, where each of the second-level
hash is of keys and values), Values will be decoded and merging will be done,
but includes are not processed (even though C<include> directive is active).

Options:

=over

lib/Config/IOD/Document.pm  view on Meta::CPAN


Execute C<$code> for each key found in document, in order of occurrence.
C<$code> will be called with arguments C<< ($self, %args) >> where C<%args> will
contain these keys: C<section> (str, current section name), C<key> (str, key
name), C<value> (any, value, NOT YET IMPLEMENTED/AVAILABLE), C<raw_value> (str,
raw/undecoded value), C<linum> (int, line number, 1-based), C<parsed> (array,
parsed line).

Options:

=over

lib/Config/IOD/Document.pm  view on Meta::CPAN

If found, will return an arrayref containing directive name and arguments.
Otherwise, will return undef.

=head2 $doc->get_value($section, $key) => $value

Get value. Values are decoded and section merging is respected, but includes are
not processed.

Internally, will do a C<dump()> and cache the result so subsequent
C<get_value()> will avoid re-parsing the whole document. (The cache will
automatically be discarded is one of document-modifying methods like

 view all matches for this distribution


Config-Model-Systemd

 view release on metacpan or  search on metacpan

lib/Config/Model/models/Systemd/Common/Exec.pl  view on Meta::CPAN

Interface|https://systemd.io/CONTAINER_INTERFACE> documentation for details
about the former. For the latter, pass L<DMI/SMBIOS|https://www.dmtf.org/standards/smbios> OEM string table entries
(field type
11) with a prefix of C<io.systemd.credential:> or
C<io.systemd.credential.binary:>. In both cases a key/value pair separated by
C<=> is expected, in the latter case the right-hand side is Base64 decoded when
parsed (thus permitting binary data to be passed in). Example
L<qemu|https://www.qemu.org/docs/master/system/index.html> switch: C<-smbios
type=11,value=io.systemd.credential:xx=yy>, or C<-smbios
type=11,value=io.systemd.credential.binary:rick=TmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXA=>. Alternatively,
use the qemu C<fw_cfg> node

lib/Config/Model/models/Systemd/Common/Exec.pl  view on Meta::CPAN

Interface|https://systemd.io/CONTAINER_INTERFACE> documentation for details
about the former. For the latter, pass L<DMI/SMBIOS|https://www.dmtf.org/standards/smbios> OEM string table entries
(field type
11) with a prefix of C<io.systemd.credential:> or
C<io.systemd.credential.binary:>. In both cases a key/value pair separated by
C<=> is expected, in the latter case the right-hand side is Base64 decoded when
parsed (thus permitting binary data to be passed in). Example
L<qemu|https://www.qemu.org/docs/master/system/index.html> switch: C<-smbios
type=11,value=io.systemd.credential:xx=yy>, or C<-smbios
type=11,value=io.systemd.credential.binary:rick=TmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXA=>. Alternatively,
use the qemu C<fw_cfg> node

 view all matches for this distribution


Config-Patch

 view release on metacpan or  search on metacpan

lib/Config/Patch.pm  view on Meta::CPAN

###########################################
    my($self, $string) = @_;

    # Decode a hidden string 
    $string =~ s/^$self->{comment_char} //gm;
    my $decoded = decode_base64($string);
    return $decoded;
}

###########################################
sub replstring_extract {
###########################################

 view all matches for this distribution


Config-Tree

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Any code which imports My::Library::Config will use the same API
exported by Config::Tree to access the %volatile, @stack and %default
in My::Library::Config.

Config::Tree subclasses may wish to override _find to modify how the
variables are scanned and how the key is decoded.

A library should normally provide any default values which are
necessary and leave loading & saving to the application using it.


 view all matches for this distribution


Connector

 view release on metacpan or  search on metacpan

lib/Connector/Proxy/HTTP.pm  view on Meta::CPAN


    my $response = $self->agent()->request($req);
    # error handling
    if (!$response->is_success) {
        $self->log()->error($response->status_line);
        $self->log()->error($response->decoded_content);
        die "Unable to upload data to server";
    }

    $self->log()->debug("Set responded with: " . $response->status_line);
    $self->log()->trace($response->decoded_content) if ($self->log()->is_trace());

    return 1;
}

sub get_meta {

lib/Connector/Proxy/HTTP.pm  view on Meta::CPAN

sub _parse_result {

    my $self  = shift;
    my $response = shift;

    my $res = $response->decoded_content;
    chomp $res if ($self->chomp_result());
    return $res;
}


 view all matches for this distribution


Consul-Simple

 view release on metacpan or  search on metacpan

lib/Consul/Simple.pm  view on Meta::CPAN

    foreach my $entry (@entries) {
        #The returned entry Value is always base64 encoded
        $entry->{Value} = MIME::Base64::decode_base64($entry->{Value});

        #the idea below is to try to JSON decode it.  If that works,
        #return the JSON decoded value.  Otherwise, return it un-decoded
        my $value;
        eval {
            $value = JSON::decode_json($entry->{Value});
        };
        $value = $entry->{Value} unless $value;

 view all matches for this distribution


Contenticious

 view release on metacpan or  search on metacpan

lib/Contenticious/Content/Node/Directory.pm  view on Meta::CPAN


    # does a 'meta' file exist?
    my $meta_fn = $self->filename . '/meta';
    if (-f -r $meta_fn) {

        # open file for decoded reading
        open my $meta_fh, '<:encoding(UTF-8)', $meta_fn
            or croak "couldn't open $meta_fn: $!";

        # slurp
        my $meta_fc = do { local $/; <$meta_fh> };

 view all matches for this distribution


ControlX10-CM11

 view release on metacpan or  search on metacpan

CM11.pm  view on Meta::CPAN

This command handles the upload response to an "Interface Poll Signal"
message (0x5a) B<read> from the CM11. The module sends "ready" (0xc3) and
receives up to 10 bytes. The first two bytes are size and description of
the remaining bytes. These are used to decode the data bytes, but are not
returned by the B<receive_buffer> function. Each of the data bytes is
decoded as if it was a B<send> command from an external CM11 or equivalent
external source (such as an RF keypad).

  $data = &ControlX10::CM11::receive_buffer($serial_port);
      # $data eq "A2AK" after an external device turned off A2

CM11.pm  view on Meta::CPAN

      print "House B Inputs 1,3,5,7,9 Brightened to 85%\n";
  }

The conversion between text_data and percent makes more sense to the code
than to humans. The following table gives representative values. Others
may be received from a CM11 and will be properly decoded.

        Percent Text        Percent Text
            0    M7        50    AA
            5    ED        55    I6
           10    EC        60    NF

 view all matches for this distribution


Convert-ASCII-Armour

 view release on metacpan or  search on metacpan

lib/Convert/ASCII/Armour.pm  view on Meta::CPAN

    NzuZ
    =MxpZvjkrv5XyhkVCuXmsBQ==
    -----END COMPRESSED FOO RECORD-----


    my $decoded   = $converter->unarmour( $message ) 
                     || die $converter->errstr();
                        

=head1 DESCRIPTION

 view all matches for this distribution


Convert-ASN1-asn1c

 view release on metacpan or  search on metacpan

lib/Convert/ASN1/asn1c.pm  view on Meta::CPAN

=head2 $values = decode('pduname', $pdu);

The decode function takes the name of a template (the directory where to find
those templates can be modified with set_templatedir($dir)) and a binary pdu.

It will match the variables in the template against the decoded binary pdu and
return a reference to a hash which contains these values.

For each variable $myvalue the hash will contain four keys:

=head3 $values->{'myvalue'}

The decoded value if we could "guess" myvalues type because it was
specified as i.e. INTEGER or BIT STRING in the asn1 pdu.

=head3 $values->{'myvalue_orig'}

The original value as it was found in the unber -p output. Note that these

lib/Convert/ASN1/asn1c.pm  view on Meta::CPAN


	# we will parse the packet description
	# to find out which "nodes" in the tag tree are interesting for us
	# and we will construct a list of those interesting nodes (and how to "reach" them,
	# i.e. which parent nodes they are located under. In the second step we will
	# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
	
	foreach (@lines) {
		if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
		if (m/<\/C /) { pop @stack; }
		if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }

lib/Convert/ASN1/asn1c.pm  view on Meta::CPAN


	# we will parse the packet description
	# to find out which "nodes" in the tag tree are interesting for us
	# and we will construct a list of those interesting nodes (and how to "reach" them,
	# i.e. which parent nodes they are located under. In the second step we will
	# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
	
	foreach (@lines) {
		if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
		if (m/<\/C /) { pop @stack; }
		if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }

 view all matches for this distribution


Convert-ASN1

 view release on metacpan or  search on metacpan

examples/tsa3161  view on Meta::CPAN

	open TSAKEY, "<$filename" or &dieif(1,"cannot open TSAKeyFile '$filename'");
	binmode TSAKEY;
        my $tsa_key_pem;
	read TSAKEY, $tsa_key_pem, $size;  
	close TSAKEY;
        $tsa_key = Crypt::OpenSSL::RSA->new_private_key($tsa_key_pem) or &dieif(1,"TSAKeyFile '$filename' cannot be decoded");
  }

# some magic
my $time = Time::HiRes::gettimeofday() ;
my $now = int($time);

 view all matches for this distribution


Convert-Ascii85

 view release on metacpan or  search on metacpan

lib/Convert/Ascii85.pm  view on Meta::CPAN

=head1 SYNOPSIS

 use Convert::Ascii85;
 
 my $encoded = Convert::Ascii85::encode($data);
 my $decoded = Convert::Ascii85::decode($encoded);

 use Convert::Ascii85 qw(ascii85_encode ascii85_decode);
 
 my $encoded = ascii85_encode($data);
 my $decoded = ascii85_decode($encoded);

=head1 DESCRIPTION

This module implements the I<Ascii85> (also known as I<Base85>) algorithm for
encoding binary data as text. This is done by interpreting each group of four

 view all matches for this distribution


Convert-BER-XS

 view release on metacpan or  search on metacpan

XS.pm  view on Meta::CPAN

no subvalues, kind of like a non-reference perl scalar. If it is C<1>,
then the value is "constructed" which just means it contains a list of
subvalues which this module will en-/decode as BER tuples themselves.

The I<DATA> value is either a reference to an array of further tuples
(if the value is I<FLAGS>), some decoded representation of the value, if
this module knows how to decode it (e.g. for the integer types above) or
a binary string with the raw octets if this module doesn't know how to
interpret the namespace/tag.

Thus, you can always decode a BER data structure and at worst you get a
string in place of some nice decoded value.

See the SYNOPSIS for an example of such an encoded tuple representation.

=head2 DECODING AND ENCODING

XS.pm  view on Meta::CPAN

   $tuple = ber_encode $data, $Convert::BER::XS::SNMP_PROFILE;

=item ($tuple, $bytes) = ber_decode_prefix $bindata[, $profile]

Works like C<ber_decode>, except it doesn't croak when there is data after
the BER data, but instead returns the decoded value and the number of
bytes it decoded.

This is useful when you have BER data at the start of a buffer and other
data after, and you need to find the length.

Also, since BER is self-delimited, this can be used to decode multiple BER

XS.pm  view on Meta::CPAN

   _ber_dump $_[0], $_[1] || $DEFAULT_PROFILE, $_[2];
}

=head1 PROFILES

While any BER data can be correctly encoded and decoded out of the box, it
can be inconvenient to have to manually decode some values into a "better"
format: for instance, SNMP TimeTicks values are decoded into the raw octet
strings of their BER representation, which is quite hard to decode. With
profiles, you can change which class/tag combinations map to which decoder
function inside C<ber_decode> (and of course also which encoder functions
are used in C<ber_encode>).

This works by mapping specific class/tag combinations to an internal "ber
type".

The default profile supports the standard ASN.1 types, but no
application-specific ones. This means that class/tag combinations not in
the base set of ASN.1 are decoded into their raw octet strings.

C<Convert::BER::XS> defines two profile variables you can use out of the box:

=over

XS.pm  view on Meta::CPAN


=head2 BER Types

This lists the predefined BER types. BER types are formatters used
internally to format and encode BER values. You can assign any C<BER_TYPE>
to any C<CLASS>/C<TAG> combination tgo change how that tag is decoded or
encoded.

=over

=item C<BER_TYPE_BYTES>

XS.pm  view on Meta::CPAN


OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is
much larger than e.g. the one imposed by SNMP or other protocols, and is
about 4kB.

Constructed strings are decoded just fine, but there should be a way to
join them for convenience.

REAL values will always be encoded in decimal form and ssometimes is
forced into a perl "NV" type, potentially losing precision.

 view all matches for this distribution


Convert-BER

 view release on metacpan or  search on metacpan

BER.pod  view on Meta::CPAN

An I<opList> is a list of I<operator>-I<value> pairs. An operator can
be any of those defined below, or any defined by sub-classing
C<Convert::BER>, which will probably be derived from the primitives
given here.

The I<value>s depend on whether BER is being encoded or decoded:

=over 4

=item Encoding

BER.pod  view on Meta::CPAN

        BOOLEAN => 1,
    ) or die;

=item Decoding

The decoded I<value>s will be either 1 or 0.

    # Decode a boolean value into $bval
    $ber->decode(
        BOOLEAN => \$bval,
    ) or die;

BER.pod  view on Meta::CPAN

        INTEGER => -123456,
    ) or die;

=item Decoding

The I<value> will be the decoded integer value.

    $ber->decode(
        INTEGER => \$ival,
    ) or die;

BER.pod  view on Meta::CPAN

        BIT_STRING8 => pack('B8', '10110101'),
    ) or die;

=item Decoding

The I<value> will be the decoded packed bits.

    $ber->decode(
        BIT_STRING8 => \$bval,
    ) or die;

BER.pod  view on Meta::CPAN

        REAL => 3.14159265358979,
    ) or die;

=item Decoding

The I<value> will be the decoded floating-point value.

    $ber->decode(
        REAL => \$rval,
    );

BER.pod  view on Meta::CPAN

values in different types, like a C structure.

=head2 SEQUENCE

A SEQUENCE is a complex type that contains other types, a bit like a C
structure. Elements inside a SEQUENCE are encoded and decoded in the
order given.

=over 4

=item Encoding

BER.pod  view on Meta::CPAN


=item Decoding

I<value> should be a reference to a scalar, which will contain a
C<Convert::BER> object. This object will contain the remainder of the
current sequence or set being decoded.

    # After this, ber2 will contain the encoded INTEGER B<and> STRING.
    # sval will be ignored and left undefined, but bval will be decoded. The
    # decode of ber2 will return the integer and string values.
    $ber->decode(
        SEQUENCE => [
            BER => \$ber2,
            STRING => \$sval,

BER.pod  view on Meta::CPAN

=back

=head2 ANY

This is like the C<BER> operator except that when decoding only the
next item is decoded and placed into the C<Convert::BER> object
returned. There is no difference when encoding.

=over 4

=item Decoding

I<value> should be a reference to a scalar, which will contain a
C<Convert::BER> object. This object will only contain the next single
item in the current sequence being decoded.

    # After this, ber2 will decode further, and ival and sval
    # will be decoded.
    $ber->decode(
        INTEGER = \$ival,
        ANY => \$ber2,
        STRING => \$sval,
    );

BER.pod  view on Meta::CPAN

        ]
    );

=item Decoding

The contents of I<value> are decoded if possible, if not then decode
continues at the next I<operator>-I<value> pair.

    $ber->decode(
        SEQUENCE => [
            INTEGER => \$ival1,

BER.pod  view on Meta::CPAN

=back

=head2 CHOICE

The I<opList> is a list of alternate I<operator>-I<value> pairs. Only
one will be encoded, and only one will be decoded.

=over 4

=item Encoding

BER.pod  view on Meta::CPAN

    ) or die;

=item Decoding

A reference to a scalar at the start of the I<opList> is used to store
which alternative is decoded (0 for the first one, 1 for the second
one, etc.) Pass undef instead of the ref if you don't care about this,
or you store all the alternate values in different variables.

    # Decode the above.
    # Afterwards, $alt will be set to 2, $str will be set to 'BMP/Unicode'.

BER.pod  view on Meta::CPAN


=head2 DEFINING NEW PACKING OPERATORS

As well as defining new operators which inherit from existing
operators it is also possible to define a new operator and how data is
encoded and decoded. The interface for doing this is still changing
but will be documented here when it is done. To be continued ...

=head1 LIMITATIONS

Convert::BER cannot support tags that contain more bits than can be

 view all matches for this distribution


Convert-Base32

 view release on metacpan or  search on metacpan

lib/Convert/Base32.pm  view on Meta::CPAN

=head1 SYNOPSIS

  use Convert::Base32;

  $encoded = encode_base32("\x3a\x27\x0f\x93");
  $decoded = decode_base32($encoded);


=head1 DESCRIPTION

This module provides functions to convert string from / to Base32

lib/Convert/Base32.pm  view on Meta::CPAN

takes a string of bytes to encode and returns the encoded base32 string.

=item decode_base32($str)

Decode a base32 string by calling the decode_base32() function. This
function takes a string to decode and returns the decoded string.

This function might throw the exceptions such as "Data contains
non-base32 characters", "Length of data invalid" and "Padding
bits at the end of output buffer are not all zero".

 view all matches for this distribution


Convert-Base64

 view release on metacpan or  search on metacpan

lib/Convert/Base64.pm  view on Meta::CPAN

=head1 SYNOPSIS

  use Convert::Base64;

  $encoded = encode_base64("\x3a\x27\x0f\x93");
  $decoded = decode_base64($encoded);


=head1 DESCRIPTION

This module provides functions to convert strings to/from the Base64 encoding

lib/Convert/Base64.pm  view on Meta::CPAN


=item *

C<decode_base64>

    my $decoded = encode_base64("Zm9v");

Decode a Base64 string into a string of bytes.

=back

 view all matches for this distribution


Convert-Base81

 view release on metacpan or  search on metacpan

lib/Convert/Base81.pm  view on Meta::CPAN

=head1 SYNOPSIS

    use Convert::Base81;
 
    my $encoded = Convert::Base81::encode($data);
    my $decoded = Convert::Base81::decode($encoded);

or

    use Convert::Base81 qw(base81_encode base81_decode);
 
    my $encoded = base81_encode($data);
    my $decoded = base81_decode($encoded);

=head1 DESCRIPTION

This module implements a I<Base81> conversion for encoding binary
data as text. This is done by interpreting each group of fifteen bytes

lib/Convert/Base81.pm  view on Meta::CPAN

other whitespace are stripped from the string before decoding.

This function may be exported as C<base81_decode> into the caller's namespace.

If your original data wasn't an even multiple of fifteen in length, the
decoded data will have some padding with null bytes ('\0'), which can be removed.

    #
    # Decode the string and compare its length with the length of the original data.
    #
    my $decoded = base81_decode($data); 
    my $padding = length($decoded) - $datalen;
    chop $decoded while ($padding-- > 0);

=cut

sub decode
{

 view all matches for this distribution


Convert-Base85

 view release on metacpan or  search on metacpan

lib/Convert/Base85.pm  view on Meta::CPAN

=head1 SYNOPSIS

    use Convert::Base85;
 
    my $encoded = Convert::Base85::encode($data);
    my $decoded = Convert::Base85::decode($encoded);

or

    use Convert::Base85 qw(base85_encode base85_decode);
 
    my $encoded = base85_encode($data);
    my $decoded = base85_decode($encoded);

=head1 DESCRIPTION

This module implements a I<Base85> conversion for encoding binary
data as text. This is done by interpreting each group of sixteen bytes

lib/Convert/Base85.pm  view on Meta::CPAN

other whitespace are stripped from the string before decoding.

This function may be exported as C<base85_decode> into the caller's namespace.

If your original data wasn't an even multiple of sixteen in length, the
decoded data may have some padding with null bytes ('\0'), which can be removed.

    #
    # Decode the string and compare its length with the length of the original data.
    #
    my $decoded = base85_decode($data); 
    my $padding = length($decoded) - $datalen;
    chop $decoded while ($padding-- > 0);

=cut

sub decode
{

 view all matches for this distribution


( run in 0.772 second using v1.01-cache-2.11-cpan-0a987023a57 )