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


Catmandu-Store-REST

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/REST/API.pm  view on Meta::CPAN

    my $url = $self->mk_url($id);

    my $response = $self->client->get($url);

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } elsif ($response->code == 404) {
        return {};
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->url,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return {};
    }
}

lib/Catmandu/Store/REST/API.pm  view on Meta::CPAN

    my $json_data = encode_json($data);
    
    my $response = $self->client->post($url, Content_Type => 'application/json', Content => $json_data);

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->url,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return {};
    }
}

lib/Catmandu/Store/REST/API.pm  view on Meta::CPAN

    my $json_data = encode_json($data);
    
    my $response = $self->client->put($url, Content_Type => 'application/json', Content => $json_data);

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->url,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return {};
    }
}

lib/Catmandu/Store/REST/API.pm  view on Meta::CPAN

    my $url = $self->mk_url($id);

    my $response = $self->client->delete($url);
    
    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->url,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return {};
    }
}

 view all matches for this distribution


Catmandu-Store-RKD

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/RKD/API/Search.pm  view on Meta::CPAN

    } else {
        $url = $self->url;
    }
    my $response = $self->engine->get($url);
    if ($response->is_success) {
        return $response->decoded_content;
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content,
            });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-VIAF

 view release on metacpan or  search on metacpan

lib/Catmandu/VIAF/API/ID.pm  view on Meta::CPAN

                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content
            });
            return {};
        }
    }
    my $rdf = $response->decoded_content;
    my $document = sprintf('<?xml version="1.0" encoding="UTF-8"?>%s', $rdf);
    my $parser = Catmandu::VIAF::API::Parse->new(items => $document);
    return $parser->xml();
}

 view all matches for this distribution


Chart-Plotly

 view release on metacpan or  search on metacpan

examples/bitcoin.pl  view on Meta::CPAN

    $ua->agent('Mozilla/5.0');    # LWP UserAgent banned by default... Don't shoot the messenger...
    $ua->default_header( 'Content-Type' => 'application/json' );
    my $response = $ua->get('https://api.pro.coinbase.com/products/BTC-EUR/candles');

    if ( $response->is_success() ) {
        my $data = from_json( $response->decoded_content );
        my ( @x, @open, @close, @high, @low );
        for my $candle (@$data) {
            push @x, DateTime->from_epoch( epoch => $candle->[0] );
            push @low,   $candle->[1];
            push @high,  $candle->[2];

 view all matches for this distribution


Chat-iFly

 view release on metacpan or  search on metacpan

lib/Chat/iFly.pm  view on Meta::CPAN


sub _process_response {
    my $self = shift;
    my $response = shift;
    if ($response->is_success) {
        return $response->decoded_content;
    }
    else {
        warn $response->decoded_content;
        ouch $response->code, $response->message, $response->decoded_content;
    }
}

=head1 PREREQS

 view all matches for this distribution


CheerLights-API

 view release on metacpan or  search on metacpan

CheerLights/API.pm  view on Meta::CPAN

    my ($url) = @_;
    my $ua = LWP::UserAgent->new;
    my $response = $ua->get($url);

    if ($response->is_success) {
        return $response->decoded_content;
    } else {
        warn "Failed to fetch URL: " . $response->status_line;
        return;
    }
}

 view all matches for this distribution


Chef-REST-Client

 view release on metacpan or  search on metacpan

lib/Chef/Encoder.pm  view on Meta::CPAN

returns base64 encoded value of data

=head4 B<decode>

it accepts data as parameter $obj->decode( 'data' => $data )
returns base64 decoded value of data

=cut

#-------------------------------#
#  class Chef::Encoder::base64  #

 view all matches for this distribution


Chess-PGN-Extract

 view release on metacpan or  search on metacpan

lib/Chess/PGN/Extract.pm  view on Meta::CPAN

  $out =~ s/\n//g;
  $out =~ s/}/},/g;
  chop $out;
  $out = "[" . $out . "]";

  my $decoded = try {
    decode_json ($out);
  } catch {
    croak ("JSON parse error: $out");
  };

lib/Chess/PGN/Extract.pm  view on Meta::CPAN

    else {
      my $invalid_game = dump ($_);
      STDERR->print ("Invalid PGN omitted: $invalid_game\n");
      0;
    }
  } @$decoded;

  foreach (@games) {
    delete $_->{chash};
    delete $_->{fhash};
  }

 view all matches for this distribution


Chess-Plisco

 view release on metacpan or  search on metacpan

lib/Chess/Plisco.pod  view on Meta::CPAN

Generates a string representation of all bitboards in ASCII art plus some
additional information.

=item B<dumpInfo(INFO)>

Returns a string with the decoded position information as retured by
L</info>.

=item B<movesCoordinateNotation(MOVES)>

Takes an array of moves (as integers) and converts it into an array of moves

 view all matches for this distribution


Chouette

 view release on metacpan or  search on metacpan

lib/Chouette.pm  view on Meta::CPAN


L<Chouette> is a framework for making asynchronous HTTP services. It makes some opinionated design choices, but is otherwise fairly flexible.

L<AnyEvent> is used as the glue to connect all the asynchronous libraries, although Chouette depends on L<Feersum> and therefore L<EV> for its event loop. It uses L<Feersum> in PSGI mode so it can use L<Plack> for request parsing, and has support for...

Chouette generally assumes that its input will be C<application/x-www-form-urlencoded>. L<Plack::Request::WithEncoding> is used so that text is properly decoded (we recommend UTF-8 of course). For output, the default is C<application/json> encoded wi...

Chouette apps can optionally load a config file and its format is C<YAML>, loaded with the L<YAML> module. L<Regexp::Assemble> is used for efficient route-dispatch.

The above aside, Chouette's main purpose is to glue together several of my own modules into a cohesive whole. These modules have been designed to work together and I have used them to build numerous services, some of which handle a considerable amoun...

 view all matches for this distribution


Circle-Common

 view release on metacpan or  search on metacpan

lib/Circle/Common.pm  view on Meta::CPAN

        $header = [ 'Content-Type' => 'application/json; charset=UTF-8' ];
    }
    my $request  = HTTP::Request->new( 'POST', $url, $header, encode_json($data) );
    my $response = $ua->request($request);
    if ( $response->is_success ) {
        return decode_json( $response->decoded_content );
    }
    else {
        carp 'http_json_post' . $response->status_line ? $response->status_line : 'unknown';
        return {
            status  => $response->status_line,
            message => $response->decoded_content,
        };
    }
}

sub http_json_get {

lib/Circle/Common.pm  view on Meta::CPAN

        $header = [ 'Content-Type' => 'application/json; charset=UTF-8' ];
    }
    my $request  = HTTP::Request->new( 'GET', $url, $header );
    my $response = $ua->request($request);
    if ( $response->is_success ) {
        return decode_json( $response->decoded_content );
    }
    else {
        carp 'http_json_get' . $response->status_line ? $response->status_line : 'unknown';
        return {
            status  => $response->status_line,
            message => $response->decoded_content,
        };
    }
}

sub get_host {

 view all matches for this distribution


Class-Param

 view release on metacpan or  search on metacpan

t/06-encoding.t  view on Meta::CPAN

};

isa_ok      my $p1 = Class::Param->new($params),       'Class::Param',           'Class::Param->new constructs a new instance';
isa_ok      my $p2 = Class::Param::Encoding->new($p1), 'Class::Param::Encoding', 'Class::Param::Encoding->new constructs a new instance';

is          $p2->get('A'),            "\x{263A}",                                '->get    A: returns right decoded value';
is          $p2->param('A'),          "\x{263A}",                                '->param  A: returns right decoded value';
is          $p2->get('B'),            "\x{2639}",                                '->get    B: returns right decoded value';
is          $p2->param('B'),          "\x{2639}",                                '->param  B: returns right decoded value';
is_deeply   $p2->get('C'),            [ "\x{263A}", "\x{2639}" ],                '->get    C: returns right decoded values';
is_deeply   [ $p2->param('C') ],      [ "\x{263A}", "\x{2639}" ],                '->param  C: returns right decoded values';
is          $p2->get('D'),            "\x{263A}",                                '->get    D: returns right decoded value';
is          $p2->param('D'),          "\x{263A}",                                '->param  D: returns right decoded value';

 view all matches for this distribution


Class-Usul

 view release on metacpan or  search on metacpan

lib/Class/Usul/Functions.pm  view on Meta::CPAN

Untaints directory path. Makes it an absolute path and returns it if it
exists. Returns undef otherwise

=head2 C<base64_decode_ns>

   $decoded_value = base64_decode_ns $encoded_value;

Decode a scalar value encode using L</base64_encode_ns>

=head2 C<base64_encode_ns>

 view all matches for this distribution


ClearPress

 view release on metacpan or  search on metacpan

lib/ClearPress/authenticator/session.pm  view on Meta::CPAN

}

sub decode_token {
  my ($self, $token) = @_;

  my $decoded = q[];
  eval {
    $decoded = decode_base64($token);
  } or do {
    carp q[Failed to decode token];
    return;
  };

  my $decrypted = q[];
  eval {
    $decrypted = $self->cipher->decrypt($decoded);
  } or do {
    carp q[Failed to decrypt token];
    return;
  };

 view all matches for this distribution


CloudFlare-Client

 view release on metacpan or  search on metacpan

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

    CloudFlare::Client::Exception::Connection::->throw(
        status  => $res->status_line,
        message => 'HTTPS request failed',)
        unless $res->is_success;
    # Handle errors from CF
    Readonly my $info => decode_json($res->decoded_content);
    CloudFlare::Client::Exception::Upstream::->throw(
        errorCode => $info->{err_code},
        message   => $info->{msg},)
        unless $info->{result} eq 'success';

 view all matches for this distribution


Clustericious

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

1.19      2016-03-28 12:13:34 -0400
  - make hypnotoad test a dev only test

1.18      2016-03-24 15:49:47 -0400
  - Documentation fixes
  - Fix bug where errors from mojo were not being decoded correctly
    in PlugAuth plugin
  - make plackup test a dev only test

1.17      2016-03-14 12:18:27 -0400
  - removed stragler deprecated use of auth_ua

 view all matches for this distribution


Cmd-Dwarf

 view release on metacpan or  search on metacpan

examples/helloworld/app/lib/Dwarf/Module/SocialMedia/Amazon.pm  view on Meta::CPAN

	if ($res->code !~ /^2/) {
		$self->on_error->('Amazon OAuth Error: Could not get access token.');
		return;
	}

	my $decoded = decode_json $res->{_content};
	my $access_token = $decoded->{access_token};

	$self->access_token($access_token);
}

sub _make_request {

examples/helloworld/app/lib/Dwarf/Module/SocialMedia/Amazon.pm  view on Meta::CPAN

	return $self->validate($res);
}

sub validate {
	my ($self, $res) = @_;
	my $content = eval { decode_json($res->decoded_content) };
	if ($@) {
		warn "Couldn't decode JSON: $@";
		$content = $res->decoded_content;
	}

	# [todo] 
	# 	check error status codes

 view all matches for this distribution


CodeGen-Cpppp

 view release on metacpan or  search on metacpan

lib/CodeGen/Cpppp/CParser.pm  view on Meta::CPAN

  [ $type, $value, $offset, $length, $error=undef ]
  
  $type:   'directive', 'comment', 'string', 'char', 'real', 'integer',
           'keyword', 'ident', 'unknown', or any punctuation character
  
  $value:  for constants, this is the decoded string or numeric value
           for directives and comments, it is the body text
           for punctuation, it is a copy of $type
           for unknown, it is the exact character that didn't parse
  
  $src_pos: the character offset within the source $string

 view all matches for this distribution


Coerce-Types-Standard

 view release on metacpan or  search on metacpan

lib/Coerce/Types/Standard.pm  view on Meta::CPAN


=back

=head2 HTML

Accepts a String and coerces it into entity encoded/decoded string, the default behaviour here is to entity encode the given string.

	HTML->coerce('okay&'); 
	*-*-*-*-*-*-*
	okay&amp;

 view all matches for this distribution


CohortExplorer

 view release on metacpan or  search on metacpan

lib/CohortExplorer/Application/Opal/Datasource.pm  view on Meta::CPAN

             Accept => "application/json"
 );
 my $res  = $ua->request($req);
 my $code = $res->code;
 if ( $code == 200 ) {
  my $json = decode_json( $res->decoded_content );
  if ( $json->{type} ne 'mongodb' ) {

   # Successful authentication returns tables and views accessible to the user
   my %view = map { $_ => 1 } @{ $json->{view} || [] };
   my @tables = @{ $json->{table} || [] };

lib/CohortExplorer/Application/Opal/Datasource.pm  view on Meta::CPAN

  );
  my $entity_res = $ua->request($entity_req);

  # Get the first identifier
  if ( $entity_res->code == 200 ) {
   my $decoded_json = decode_json( $entity_res->decoded_content );
   my $var_req =
     HTTP::Request->new(   GET => $url
                         . "/ws/datasource/$ds_name/table/$t/valueSet/"
                         . ( $decoded_json->[0]->{identifier} || '' ) );
   $var_req->header(
             Authorization => "X-Opal-Auth "
               . MIME::Base64::encode( join ':', @opts{qw/username password/} ),
             Accept => "application/json"
   );
   my $var_res = $ua->request($var_req);

   # Get all variables with accessible values
   if ( $var_res->code == 200 ) {
    $decoded_json = decode_json( $var_res->decoded_content );
    push @{ $param{allowed_variables} },
      map { "$t.$_" } @{ $decoded_json->{variables} };
   }
   else {
    die "Failed to fetch variable list via $url (error "
      . $var_res->code . ")\n";
   }

 view all matches for this distribution


CommonMark

 view release on metacpan or  search on metacpan

t/03_render.t  view on Meta::CPAN


is(CommonMark->markdown_to_html("\x{263A}"), "<p>\x{263A}</p>\n",
   'render functions return encoded utf8');

is(CommonMark->markdown_to_html("\xC2\xA9"), "<p>\xC2\xA9</p>\n",
   'render functions expect decoded utf8');

 view all matches for this distribution


Compiler-Parser

 view release on metacpan or  search on metacpan

t/app/Plack/Request.t  view on Meta::CPAN


Returns the protocol (HTTP/1.0 or HTTP/1.1) used for the current request.

=item request_uri

Returns the raw, undecoded request URI path. You probably do B<NOT>
want to use this to dispatch requests.

=item path_info

Returns B<PATH_INFO> in the environment. Use this to get the local

t/app/Plack/Request.t  view on Meta::CPAN

  $req->logger->({ level => 'debug', message => "This is a debug message" });

=item cookies

Returns a reference to a hash containing the cookies. Values are
strings that are sent by clients and are URI decoded.

If there are multiple cookies with the same name in the request, this
method will ignore the duplicates and return only the first value. If
that causes issues for you, you may have to use modules like
CGI::Simple::Cookie to parse C<$request->header('Cookies')> by

t/app/Plack/Request.t  view on Meta::CPAN

Returns a L<Hash::MultiValue> hash reference containing (merged) GET
and POST parameters.

=item content, raw_body

Returns the request content in an undecoded byte string for POST requests.

=item uri

Returns an URI object for the current request. The URI is constructed
using various environment values such as C<SCRIPT_NAME>, C<PATH_INFO>,

 view all matches for this distribution


Compress-Deflate7

 view release on metacpan or  search on metacpan

7zip/C/LzmaDec.c  view on Meta::CPAN

StopCompilingDueBUG
#endif

#define LZMA_DIC_MIN (1 << 12)

/* First LZMA-symbol is always decoded.
And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
Out:
  Result:
    SZ_OK - OK
    SZ_ERROR_DATA - Error

 view all matches for this distribution


Compress-LZ4

 view release on metacpan or  search on metacpan

src/lz4.c  view on Meta::CPAN

        op=cpy;   /* correction */
    }

    /* end of decoding */
    if (endOnInput)
       return (int) (((char*)op)-dest);     /* Nb of output bytes decoded */
    else
       return (int) (((const char*)ip)-source);   /* Nb of input bytes read */

    /* Overflow error detected */
_output_error:

src/lz4.c  view on Meta::CPAN

}

/*!
 * LZ4_setStreamDecode() :
 * Use this function to instruct where to find the dictionary.
 * This function is not necessary if previous data is still available where it was decoded.
 * Loading a size of 0 is allowed (same effect as no dictionary).
 * Return : 1 if OK, 0 if error
 */
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize)
{

src/lz4.c  view on Meta::CPAN

}

/*
*_continue() :
    These decoding functions allow decompression of multiple blocks in "streaming" mode.
    Previously decoded blocks must still be available at the memory position where they were decoded.
    If it's not possible, save the relevant part of decoded data into a safe buffer,
    and indicate where it stands using LZ4_setStreamDecode()
*/
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
{
    LZ4_streamDecode_t_internal* lz4sd = &LZ4_streamDecode->internal_donotuse;

 view all matches for this distribution


Compress-LZ4Frame

 view release on metacpan or  search on metacpan

lz4.c  view on Meta::CPAN

        op = cpy;   /* correction */
    }

    /* end of decoding */
    if (endOnInput)
       return (int) (((char*)op)-dst);     /* Nb of output bytes decoded */
    else
       return (int) (((const char*)ip)-src);   /* Nb of input bytes read */

    /* Overflow error detected */
_output_error:

lz4.c  view on Meta::CPAN

}

/*!
 * LZ4_setStreamDecode() :
 * Use this function to instruct where to find the dictionary.
 * This function is not necessary if previous data is still available where it was decoded.
 * Loading a size of 0 is allowed (same effect as no dictionary).
 * Return : 1 if OK, 0 if error
 */
int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize)
{

lz4.c  view on Meta::CPAN

}

/*
*_continue() :
    These decoding functions allow decompression of multiple blocks in "streaming" mode.
    Previously decoded blocks must still be available at the memory position where they were decoded.
    If it's not possible, save the relevant part of decoded data into a safe buffer,
    and indicate where it stands using LZ4_setStreamDecode()
*/
LZ4_FORCE_O2_GCC_PPC64LE
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
{

 view all matches for this distribution


Compress-PPMd

 view release on metacpan or  search on metacpan

PPMd.pm  view on Meta::CPAN

  my $encoder=Compress::PPMd::Encoder->new();
  my $encoded=$encoder->encode($text);
  my $encoded2=$encoder->encode($text2);

  my $decoder=Compress::PPMd::Decoder->new();
  my $decoded=$encoder->decode($encoded);
  my $decoded2=$encoder->decode($encoded2);


=head1 ABSTRACT

This package is a Perl wrapper around Dmitry Shkarin PPMd compression

 view all matches for this distribution


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


( run in 0.473 second using v1.01-cache-2.11-cpan-26ccb49234f )