line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::Net::Curl::Const; |
2
|
|
|
|
|
|
|
# ABSTRACT: Access Net::Curl::* constants by name |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
53
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
362
|
|
6
|
10
|
|
|
10
|
|
54
|
use utf8; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
73
|
|
7
|
10
|
|
|
10
|
|
251
|
use warnings qw(all); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
355
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
52
|
use Carp qw(carp); |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
524
|
|
10
|
10
|
|
|
10
|
|
5863
|
use Net::Curl::Easy; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Scalar::Util qw(looks_like_number); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.047'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my (%const_info, %const_opt); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub info { |
19
|
|
|
|
|
|
|
my ($name) = @_; |
20
|
|
|
|
|
|
|
$const_info{$name} = _curl_const(CURLINFO => $name) |
21
|
|
|
|
|
|
|
unless exists $const_info{$name}; |
22
|
|
|
|
|
|
|
return $const_info{$name}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub opt { |
26
|
|
|
|
|
|
|
my ($name) = @_; |
27
|
|
|
|
|
|
|
$const_opt{$name} = _curl_const(CURLOPT => $name) |
28
|
|
|
|
|
|
|
unless exists $const_opt{$name}; |
29
|
|
|
|
|
|
|
return $const_opt{$name}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _curl_const { |
33
|
|
|
|
|
|
|
my ($suffix => $key) = @_; |
34
|
|
|
|
|
|
|
return $key if looks_like_number($key); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$key =~ s{^Net::Curl::Easy::}{}ix; |
37
|
|
|
|
|
|
|
$key =~ y{-}{_}; |
38
|
|
|
|
|
|
|
$key =~ s{\W}{}gx; |
39
|
|
|
|
|
|
|
$key = uc $key; |
40
|
|
|
|
|
|
|
$key = "${suffix}_${key}" if $key !~ m{^${suffix}_}x; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $val = eval { |
43
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict) |
44
|
|
|
|
|
|
|
no strict 'refs'; |
45
|
|
|
|
|
|
|
my $const_name = 'Net::Curl::Easy::' . $key; |
46
|
|
|
|
|
|
|
*$const_name->(); |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
carp "Invalid libcurl constant: $key" if $@; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $val; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |