text
stringlengths
0
834k
my $lua_package_path_config = '';
if (@inc_dirs) {
my $package_path = """";
my $package_path2 = """";
my $package_cpath = """";
for my $dir (@inc_dirs) {
#if (!-d $dir) {
#die ""Search directory $dir is not found.\n"";
#next;
#}
if ($is_win32) {
$package_path .= File::Spec->catfile($dir, ""?.lua;"");
$package_path2 .= File::Spec->catfile($dir, ""?/init.lua;"");
$package_cpath .= File::Spec->catfile($dir, ""?.so;"");
} else {
$package_path .= ""$dir/?.ljbc;$dir/?.lua;$dir/?/init.ljbc;$dir/?/init.lua;"";
$package_cpath .= ""$dir/?.so;"";
}
}
$lua_package_path_config = <<_EOC_;
lua_package_path ""$package_path;"";
lua_package_cpath ""$package_cpath;"";
_EOC_
}
my $luafile = shift;
if (!defined $src and !defined $luafile) {
die qq{Neither Lua input file nor -e """" option specified.\n};
}
my $conns = $conns_num || 64;
my @nameservers;
if (@ns > 0) {
unshift @nameservers, @ns;
} else {
# try to read the nameservers used by the system resolver:
if (open my $in, ""/etc/resolv.conf"") {
while (<$in>) {
if (/^\s*nameserver\s+(\d+(?:\.\d+){3})(?:\s+|$)/) {
unshift @nameservers, $1;
if (@nameservers > 10) {
last;
}
}
}
close $in;
}
}
if (!@nameservers) {
# default to Google's open DNS servers
unshift @nameservers, ""8.8.8.8"", ""8.8.4.4"";
}
if (!$resolve_ipv6) {
push @nameservers, ""ipv6=off"";
}
#warn ""@nameservers\n"";
my $prefix_dir;
if ($^O eq 'msys') {
# to work around a bug in msys perl (at least 5.8.8 msys 64int)
$prefix_dir = ""resty_cli_temp"";
if (-d $prefix_dir) {
system(""rm -rf $prefix_dir"") == 0 or die $!;
}
mkdir $prefix_dir or die ""failed to mkdir $prefix_dir: $!"";
} else {
if ($is_win32 || !-d '/tmp') {
require File::Temp;
$prefix_dir = File::Temp::tempdir(CLEANUP => 1);
if ($^O eq 'MSWin32') {
require Win32;
$prefix_dir = Win32::GetLongPathName($prefix_dir);
}
} else {
my $tmpdir = '/tmp/resty_';
my $N = 1000;
for (my $i = 0; $i < $N; $i++) {
my $name;
for (my $j = 0; $j < 10; $j++) {
my $code = 65 + int rand 26;
if (int rand 2 == 0) {
$code += 32;
}
$name .= chr $code;
}