home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
1.x
/
plum12.lzh
/
plum12
/
chksock
< prev
next >
Wrap
Text File
|
1997-09-25
|
3KB
|
117 lines
#!/bin/perl -w
$| = 1;
print 'Ñ╜Ñ▒Ñ├Ñ╚ñ╬Ñ┴ѺÑ├Ñ»ñ≥╣╘ñññ▐ñ╣íú', "\n";
print 'perlñ╬Ñ╨í╝Ñ╕ÑτÑ≤ñ╧', sprintf('%1.3f', $]), 'ñ╟ñ╣íú', "\n";
if ($] >= 5) {
print 'Socket.pmñ≥├╡ñ╖ñ╞ñññ▐ñ╣...';
eval("use Socket");
if ($@) {
print '╕½ñ─ñ½ñΩñ▐ñ╗ñ≤ñ╟ñ╖ñ┐íú', "\n";
} else {
print '╕½ñ─ñ½ñΩñ▐ñ╖ñ┐íú', "\n";
if (&AF_INET && &PF_INET && &SOCK_STREAM) {
print 'Socket.pmñ¼═°═╤ñ╟ñ¡ñ▐ñ╣íú', "\n";
exit;
} else {
print 'ñ│ñ╬Socket.pmñ╧═°═╤ñ╟ñ¡ñ▐ñ╗ñ≤íú', "\n";
}
}
}
print 'sys/socket.phñ≥├╡ñ╖ñ╞ñññ▐ñ╣...';
$sys_socket_ph = '';
foreach $inc (@INC) {
if (-r "$inc/sys/socket.ph") {
print "$inc/sys/socket.ph", 'ñ╟ñ╣íú', "\n";
$sys_socket_ph = "$inc/sys/socket.ph";
eval "do 'sys/socket.ph'";
if (defined(&AF_INET) && defined(&PF_INET) && defined(&SOCK_STREAM)) {
print $sys_socket_ph, 'ñ¼═°═╤ñ╟ñ¡ñ▐ñ╣íú', "\n";
exit;
} else {
print 'ñ│ñ╬socket.phñ╧═°═╤ñ╟ñ¡ñ▐ñ╗ñ≤íú', "\n";
}
}
}
if (!$sys_socket_ph) {
print '╕½ñ─ñ½ñΩñ▐ñ╗ñ≤ñ╟ñ╖ñ┐íú', "\n";
}
print 'sys/socket.phñ≥║ε└«ñ╖ñ▐ñ╣íú', "\n";
if (!-d 'sys') {
print 'sysÑ╟ÑúÑ∞Ñ»Ñ╚ÑΩñ≥║ε└«ñ╖ñ▐ñ╣íú', "\n";
$umask = 022;
eval '$umask = umask';
mkdir('sys', ($umask ^ 0777) | 0700);
}
print 'h2phñ≥├╡ñ╖ñ╞ñññ▐ñ╣...';
$PATH = $ENV{'PATH'};
$PATH .= ':/usr/bin:/usr/local/bin:/usr/sbin:.';
foreach $path (split(/\:/, $PATH)) {
if (-x "$path/h2ph") {
print "$path/h2ph", 'ñ╟ñ╣íú', "\n";
$h2ph = "$path/h2ph";
last;
}
}
if ($h2ph) {
system("$h2ph < /usr/include/sys/socket.h > sys/socket.ph");
print 'sys/socket.phñ≥║ε└«ñ╖ñ▐ñ╖ñ┐íú', "\n";
eval "do 'sys/socket.ph'";
if (defined(&AF_INET) && defined(&PF_INET) && defined(&SOCK_STREAM)) {
print 'sys/socket.phñ¼═°═╤ñ╟ñ¡ñ▐ñ╣íú', "\n";
exit;
} else {
print 'ñ│ñ╬socket.phñ╧═°═╤ñ╟ñ¡ñ▐ñ╗ñ≤íú', "\n";
}
} else {
print '╕½ñ─ñ½ñΩñ▐ñ╗ñ≤ñ╟ñ╖ñ┐íú', "\n";
}
if (open(MKSOCK, '>./mksock.c')) {
$dir = '.';
} elsif (open(MKSOCK, ">$HOME/mksock.c")) {
$dir = $HOME;
} elsif (open(MKSOCK, '>/tmp/mksock.c')) {
$dir = '/tmp';
} elsif (defined($ENV{'TMP'}) && open(MKSOCK, ">$ENV{'TMP'}/mksock.c")) {
$dir = "$ENV{'TMP'}";
} else {
print 'Ñ╒ÑíÑñÑδñ¼║ε└«ñ╟ñ¡ñ▐ñ╗ñ≤íú', "\n";
exit;
}
print MKSOCK <<EOF;
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
main()
{
printf("sub AF_INET {%d;}\\n", AF_INET);
printf("sub PF_INET {%d;}\\n", PF_INET);
printf("sub SOCK_STREAM {%d;}\\n", SOCK_STREAM);
printf("1;\\n");
}
EOF
close(MKSOCK);
print 'CÑ│Ñ≤Ñ╤ÑñÑΘñ≥├╡ñ╖ñ╞ñññ▐ñ╣...';
foreach $path (split(/\:/, $PATH)) {
if (-x "$path/cc") {
$cc = "$path/cc";
last;
} elsif (-x "$path/gcc") {
$cc = "$path/gcc";
last;
}
}
if (!$cc) {
print 'CÑ│Ñ≤Ñ╤ÑñÑΘñ¼╕½ñ─ñ½ñΩñ▐ñ╗ñ≤íú', "\n";
exit;
}
print $cc, 'ñ╟ñ╣íú', "\n";
system("$cc -o $dir/mksock $dir/mksock.c");
system("$dir/mksock > sys/socket.ph");
unlink("$dir/mksock.c");
unlink("$dir/mksock");
print 'sys/socket.phñ≥║ε└«ñ╖ñ▐ñ╖ñ┐íú', "\n";
print 'sys/socket.phñ¼═°═╤ñ╟ñ¡ñ▐ñ╣íú', "\n";
exit;