diff options
Diffstat (limited to 'contrib/perl5/h2pl')
-rw-r--r-- | contrib/perl5/h2pl/README | 71 | ||||
-rw-r--r-- | contrib/perl5/h2pl/cbreak.pl | 34 | ||||
-rw-r--r-- | contrib/perl5/h2pl/cbreak2.pl | 33 | ||||
-rw-r--r-- | contrib/perl5/h2pl/eg/sizeof.ph | 14 | ||||
-rw-r--r-- | contrib/perl5/h2pl/eg/sys/errno.pl | 92 | ||||
-rw-r--r-- | contrib/perl5/h2pl/eg/sys/ioctl.pl | 186 | ||||
-rw-r--r-- | contrib/perl5/h2pl/eg/sysexits.pl | 16 | ||||
-rw-r--r-- | contrib/perl5/h2pl/getioctlsizes | 13 | ||||
-rw-r--r-- | contrib/perl5/h2pl/mksizes | 42 | ||||
-rw-r--r-- | contrib/perl5/h2pl/mkvars | 31 | ||||
-rw-r--r-- | contrib/perl5/h2pl/tcbreak | 17 | ||||
-rw-r--r-- | contrib/perl5/h2pl/tcbreak2 | 17 |
12 files changed, 0 insertions, 566 deletions
diff --git a/contrib/perl5/h2pl/README b/contrib/perl5/h2pl/README deleted file mode 100644 index 5fe8ae7..0000000 --- a/contrib/perl5/h2pl/README +++ /dev/null @@ -1,71 +0,0 @@ -[This file of Tom Christiansen's has been edited to change makelib to h2ph -and .h to .ph where appropriate--law.] - -This directory contains files to help you convert the *.ph files generated my -h2ph out of the perl source directory into *.pl files with all the -indirection of the subroutine calls removed. The .ph version will be more -safely portable, because if something isn't defined on the new system, like -&TIOCGETP, then you'll get a fatal run-time error on the system lacking that -function. Using the .pl version means that the subsequent scripts will give -you a 0 $TIOCGETP and God only knows what may then happen. Still, I like the -.pl stuff because they're faster to load. - -FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff -into the perl library directory, often /usr/local/lib/perl. For example, - # h2ph sys/ioctl.h -takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection) -the file /usr/local/lib/perl/sys/ioctl.ph, which looks like this - - eval 'sub TIOCM_RTS {0004;}'; - eval 'sub TIOCM_ST {0010;}'; - eval 'sub TIOCM_SR {0020;}'; - eval 'sub TIOCM_CTS {0040;}'; - eval 'sub TIOCM_CAR {0100;}'; - -and much worse, rather than what Larry's ioctl.pl from the perl source dir has, -which is: - - $TIOCM_RTS = 0004; - $TIOCM_ST = 0010; - $TIOCM_SR = 0020; - $TIOCM_CTS = 0040; - $TIOCM_CAR = 0100; - -[Workaround for fixed bug in makedir/h2ph deleted--law.] - -The more complicated ioctl subs look like this: - - eval 'sub TIOCGSIZE {&TIOCGWINSZ;}'; - eval 'sub TIOCGWINSZ {&_IOR("t", 104, \'struct winsize\');}'; - eval 'sub TIOCSETD {&_IOW("t", 1, \'int\');}'; - eval 'sub TIOCGETP {&_IOR("t", 8,\'struct sgttyb\');}'; - -The _IO[RW] routines use a %sizeof array, which (presumably) -is keyed on the type name with the value being the size in bytes. - -To build %sizeof, try running this in this directory: - - % ./getioctlsizes - -Which will tell you which things the %sizeof array needs -to hold. You can try to build a sizeof.ph file with: - - % ./getioctlsizes | ./mksizes > sizeof.ph - -Note that mksizes hardcodes the #include files for all the types, so it will -probably require customization. Once you have sizeof.ph, install it in the -perl library directory. Run my tcbreak script to see whether you can do -ioctls in perl now. You'll get some kind of fatal run-time error if you -can't. That script should be included in this directory. - -If this works well, now you can try to convert the *.ph files into -*.pl files. Try this: - - foreach file ( sysexits.ph sys/{errno.ph,ioctl.ph} ) - ./mkvars $file > t/$file:r.pl - end - -The last one will be the hardest. If it works, should be able to -run tcbreak2 and have it work the same as tcbreak. - -Good luck. diff --git a/contrib/perl5/h2pl/cbreak.pl b/contrib/perl5/h2pl/cbreak.pl deleted file mode 100644 index 422185e..0000000 --- a/contrib/perl5/h2pl/cbreak.pl +++ /dev/null @@ -1,34 +0,0 @@ -$sgttyb_t = 'C4 S'; - -sub cbreak { - &set_cbreak(1); -} - -sub cooked { - &set_cbreak(0); -} - -sub set_cbreak { - local($on) = @_; - - require 'sizeof.ph'; - require 'sys/ioctl.ph'; - - ioctl(STDIN,&TIOCGETP,$sgttyb) - || die "Can't ioctl TIOCGETP: $!"; - - @ary = unpack($sgttyb_t,$sgttyb); - if ($on) { - $ary[4] |= &CBREAK; - $ary[4] &= ~&ECHO; - } else { - $ary[4] &= ~&CBREAK; - $ary[4] |= &ECHO; - } - $sgttyb = pack($sgttyb_t,@ary); - ioctl(STDIN,&TIOCSETP,$sgttyb) - || die "Can't ioctl TIOCSETP: $!"; - -} - -1; diff --git a/contrib/perl5/h2pl/cbreak2.pl b/contrib/perl5/h2pl/cbreak2.pl deleted file mode 100644 index 8ac55a3..0000000 --- a/contrib/perl5/h2pl/cbreak2.pl +++ /dev/null @@ -1,33 +0,0 @@ -$sgttyb_t = 'C4 S'; - -sub cbreak { - &set_cbreak(1); -} - -sub cooked { - &set_cbreak(0); -} - -sub set_cbreak { - local($on) = @_; - - require 'sys/ioctl.pl'; - - ioctl(STDIN,$TIOCGETP,$sgttyb) - || die "Can't ioctl TIOCGETP: $!"; - - @ary = unpack($sgttyb_t,$sgttyb); - if ($on) { - $ary[4] |= $CBREAK; - $ary[4] &= ~$ECHO; - } else { - $ary[4] &= ~$CBREAK; - $ary[4] |= $ECHO; - } - $sgttyb = pack($sgttyb_t,@ary); - ioctl(STDIN,$TIOCSETP,$sgttyb) - || die "Can't ioctl TIOCSETP: $!"; - -} - -1; diff --git a/contrib/perl5/h2pl/eg/sizeof.ph b/contrib/perl5/h2pl/eg/sizeof.ph deleted file mode 100644 index 285bff1..0000000 --- a/contrib/perl5/h2pl/eg/sizeof.ph +++ /dev/null @@ -1,14 +0,0 @@ -$sizeof{'char'} = 1; -$sizeof{'int'} = 4; -$sizeof{'long'} = 4; -$sizeof{'struct arpreq'} = 36; -$sizeof{'struct ifconf'} = 8; -$sizeof{'struct ifreq'} = 32; -$sizeof{'struct ltchars'} = 6; -$sizeof{'struct pcntl'} = 116; -$sizeof{'struct rtentry'} = 52; -$sizeof{'struct sgttyb'} = 6; -$sizeof{'struct tchars'} = 6; -$sizeof{'struct ttychars'} = 14; -$sizeof{'struct winsize'} = 8; -$sizeof{'struct termios'} = 132; diff --git a/contrib/perl5/h2pl/eg/sys/errno.pl b/contrib/perl5/h2pl/eg/sys/errno.pl deleted file mode 100644 index d9ba3be..0000000 --- a/contrib/perl5/h2pl/eg/sys/errno.pl +++ /dev/null @@ -1,92 +0,0 @@ -$EPERM = 0x1; -$ENOENT = 0x2; -$ESRCH = 0x3; -$EINTR = 0x4; -$EIO = 0x5; -$ENXIO = 0x6; -$E2BIG = 0x7; -$ENOEXEC = 0x8; -$EBADF = 0x9; -$ECHILD = 0xA; -$EAGAIN = 0xB; -$ENOMEM = 0xC; -$EACCES = 0xD; -$EFAULT = 0xE; -$ENOTBLK = 0xF; -$EBUSY = 0x10; -$EEXIST = 0x11; -$EXDEV = 0x12; -$ENODEV = 0x13; -$ENOTDIR = 0x14; -$EISDIR = 0x15; -$EINVAL = 0x16; -$ENFILE = 0x17; -$EMFILE = 0x18; -$ENOTTY = 0x19; -$ETXTBSY = 0x1A; -$EFBIG = 0x1B; -$ENOSPC = 0x1C; -$ESPIPE = 0x1D; -$EROFS = 0x1E; -$EMLINK = 0x1F; -$EPIPE = 0x20; -$EDOM = 0x21; -$ERANGE = 0x22; -$EWOULDBLOCK = 0x23; -$EINPROGRESS = 0x24; -$EALREADY = 0x25; -$ENOTSOCK = 0x26; -$EDESTADDRREQ = 0x27; -$EMSGSIZE = 0x28; -$EPROTOTYPE = 0x29; -$ENOPROTOOPT = 0x2A; -$EPROTONOSUPPORT = 0x2B; -$ESOCKTNOSUPPORT = 0x2C; -$EOPNOTSUPP = 0x2D; -$EPFNOSUPPORT = 0x2E; -$EAFNOSUPPORT = 0x2F; -$EADDRINUSE = 0x30; -$EADDRNOTAVAIL = 0x31; -$ENETDOWN = 0x32; -$ENETUNREACH = 0x33; -$ENETRESET = 0x34; -$ECONNABORTED = 0x35; -$ECONNRESET = 0x36; -$ENOBUFS = 0x37; -$EISCONN = 0x38; -$ENOTCONN = 0x39; -$ESHUTDOWN = 0x3A; -$ETOOMANYREFS = 0x3B; -$ETIMEDOUT = 0x3C; -$ECONNREFUSED = 0x3D; -$ELOOP = 0x3E; -$ENAMETOOLONG = 0x3F; -$EHOSTDOWN = 0x40; -$EHOSTUNREACH = 0x41; -$ENOTEMPTY = 0x42; -$EPROCLIM = 0x43; -$EUSERS = 0x44; -$EDQUOT = 0x45; -$ESTALE = 0x46; -$EREMOTE = 0x47; -$EDEADLK = 0x48; -$ENOLCK = 0x49; -$MTH_UNDEF_SQRT = 0x12C; -$MTH_OVF_EXP = 0x12D; -$MTH_UNDEF_LOG = 0x12E; -$MTH_NEG_BASE = 0x12F; -$MTH_ZERO_BASE = 0x130; -$MTH_OVF_POW = 0x131; -$MTH_LRG_SIN = 0x132; -$MTH_LRG_COS = 0x133; -$MTH_LRG_TAN = 0x134; -$MTH_LRG_COT = 0x135; -$MTH_OVF_TAN = 0x136; -$MTH_OVF_COT = 0x137; -$MTH_UNDEF_ASIN = 0x138; -$MTH_UNDEF_ACOS = 0x139; -$MTH_UNDEF_ATAN2 = 0x13A; -$MTH_OVF_SINH = 0x13B; -$MTH_OVF_COSH = 0x13C; -$MTH_UNDEF_ZLOG = 0x13D; -$MTH_UNDEF_ZDIV = 0x13E; diff --git a/contrib/perl5/h2pl/eg/sys/ioctl.pl b/contrib/perl5/h2pl/eg/sys/ioctl.pl deleted file mode 100644 index 0b552ca..0000000 --- a/contrib/perl5/h2pl/eg/sys/ioctl.pl +++ /dev/null @@ -1,186 +0,0 @@ -$_IOCTL_ = 0x1; -$TIOCGSIZE = 0x40087468; -$TIOCSSIZE = 0x80087467; -$IOCPARM_MASK = 0x7F; -$IOC_VOID = 0x20000000; -$IOC_OUT = 0x40000000; -$IOC_IN = 0x80000000; -$IOC_INOUT = 0xC0000000; -$TIOCGETD = 0x40047400; -$TIOCSETD = 0x80047401; -$TIOCHPCL = 0x20007402; -$TIOCMODG = 0x40047403; -$TIOCMODS = 0x80047404; -$TIOCM_LE = 0x1; -$TIOCM_DTR = 0x2; -$TIOCM_RTS = 0x4; -$TIOCM_ST = 0x8; -$TIOCM_SR = 0x10; -$TIOCM_CTS = 0x20; -$TIOCM_CAR = 0x40; -$TIOCM_CD = 0x40; -$TIOCM_RNG = 0x80; -$TIOCM_RI = 0x80; -$TIOCM_DSR = 0x100; -$TIOCGETP = 0x40067408; -$TIOCSETP = 0x80067409; -$TIOCSETN = 0x8006740A; -$TIOCEXCL = 0x2000740D; -$TIOCNXCL = 0x2000740E; -$TIOCFLUSH = 0x80047410; -$TIOCSETC = 0x80067411; -$TIOCGETC = 0x40067412; -$TIOCSET = 0x80047413; -$TIOCBIS = 0x80047414; -$TIOCBIC = 0x80047415; -$TIOCGET = 0x40047416; -$TANDEM = 0x1; -$CBREAK = 0x2; -$LCASE = 0x4; -$ECHO = 0x8; -$CRMOD = 0x10; -$RAW = 0x20; -$ODDP = 0x40; -$EVENP = 0x80; -$ANYP = 0xC0; -$NLDELAY = 0x300; -$NL0 = 0x0; -$NL1 = 0x100; -$NL2 = 0x200; -$NL3 = 0x300; -$TBDELAY = 0xC00; -$TAB0 = 0x0; -$TAB1 = 0x400; -$TAB2 = 0x800; -$XTABS = 0xC00; -$CRDELAY = 0x3000; -$CR0 = 0x0; -$CR1 = 0x1000; -$CR2 = 0x2000; -$CR3 = 0x3000; -$VTDELAY = 0x4000; -$FF0 = 0x0; -$FF1 = 0x4000; -$BSDELAY = 0x8000; -$BS0 = 0x0; -$BS1 = 0x8000; -$ALLDELAY = 0xFF00; -$CRTBS = 0x10000; -$PRTERA = 0x20000; -$CRTERA = 0x40000; -$TILDE = 0x80000; -$MDMBUF = 0x100000; -$LITOUT = 0x200000; -$TOSTOP = 0x400000; -$FLUSHO = 0x800000; -$NOHANG = 0x1000000; -$L001000 = 0x2000000; -$CRTKIL = 0x4000000; -$L004000 = 0x8000000; -$CTLECH = 0x10000000; -$PENDIN = 0x20000000; -$DECCTQ = 0x40000000; -$NOFLSH = 0x80000000; -$TIOCCSET = 0x800E7417; -$TIOCCGET = 0x400E7418; -$TIOCLBIS = 0x8004747F; -$TIOCLBIC = 0x8004747E; -$TIOCLSET = 0x8004747D; -$TIOCLGET = 0x4004747C; -$LCRTBS = 0x1; -$LPRTERA = 0x2; -$LCRTERA = 0x4; -$LTILDE = 0x8; -$LMDMBUF = 0x10; -$LLITOUT = 0x20; -$LTOSTOP = 0x40; -$LFLUSHO = 0x80; -$LNOHANG = 0x100; -$LCRTKIL = 0x400; -$LCTLECH = 0x1000; -$LPENDIN = 0x2000; -$LDECCTQ = 0x4000; -$LNOFLSH = 0x8000; -$TIOCSBRK = 0x2000747B; -$TIOCCBRK = 0x2000747A; -$TIOCSDTR = 0x20007479; -$TIOCCDTR = 0x20007478; -$TIOCGPGRP = 0x40047477; -$TIOCSPGRP = 0x80047476; -$TIOCSLTC = 0x80067475; -$TIOCGLTC = 0x40067474; -$TIOCOUTQ = 0x40047473; -$TIOCSTI = 0x80017472; -$TIOCNOTTY = 0x20007471; -$TIOCPKT = 0x80047470; -$TIOCPKT_DATA = 0x0; -$TIOCPKT_FLUSHREAD = 0x1; -$TIOCPKT_FLUSHWRITE = 0x2; -$TIOCPKT_STOP = 0x4; -$TIOCPKT_START = 0x8; -$TIOCPKT_NOSTOP = 0x10; -$TIOCPKT_DOSTOP = 0x20; -$TIOCSTOP = 0x2000746F; -$TIOCSTART = 0x2000746E; -$TIOCREMOTE = 0x20007469; -$TIOCGWINSZ = 0x40087468; -$TIOCSWINSZ = 0x80087467; -$TIOCRESET = 0x20007466; -$OTTYDISC = 0x0; -$NETLDISC = 0x1; -$NTTYDISC = 0x2; -$FIOCLEX = 0x20006601; -$FIONCLEX = 0x20006602; -$FIONREAD = 0x4004667F; -$FIONBIO = 0x8004667E; -$FIOASYNC = 0x8004667D; -$FIOSETOWN = 0x8004667C; -$FIOGETOWN = 0x4004667B; -$STPUTTABLE = 0x8004667A; -$STGETTABLE = 0x80046679; -$SIOCSHIWAT = 0x80047300; -$SIOCGHIWAT = 0x40047301; -$SIOCSLOWAT = 0x80047302; -$SIOCGLOWAT = 0x40047303; -$SIOCATMARK = 0x40047307; -$SIOCSPGRP = 0x80047308; -$SIOCGPGRP = 0x40047309; -$SIOCADDRT = 0x8034720A; -$SIOCDELRT = 0x8034720B; -$SIOCSIFADDR = 0x8020690C; -$SIOCGIFADDR = 0xC020690D; -$SIOCSIFDSTADDR = 0x8020690E; -$SIOCGIFDSTADDR = 0xC020690F; -$SIOCSIFFLAGS = 0x80206910; -$SIOCGIFFLAGS = 0xC0206911; -$SIOCGIFBRDADDR = 0xC0206912; -$SIOCSIFBRDADDR = 0x80206913; -$SIOCGIFCONF = 0xC0086914; -$SIOCGIFNETMASK = 0xC0206915; -$SIOCSIFNETMASK = 0x80206916; -$SIOCGIFMETRIC = 0xC0206917; -$SIOCSIFMETRIC = 0x80206918; -$SIOCSARP = 0x8024691E; -$SIOCGARP = 0xC024691F; -$SIOCDARP = 0x80246920; -$PIXCONTINUE = 0x80747000; -$PIXSTEP = 0x80747001; -$PIXTERMINATE = 0x20007002; -$PIGETFLAGS = 0x40747003; -$PIXINHERIT = 0x80747004; -$PIXDETACH = 0x20007005; -$PIXGETSUBCODE = 0xC0747006; -$PIXRDREGS = 0xC0747007; -$PIXWRREGS = 0xC0747008; -$PIXRDVREGS = 0xC0747009; -$PIXWRVREGS = 0xC074700A; -$PIXRDVSTATE = 0xC074700B; -$PIXWRVSTATE = 0xC074700C; -$PIXRDCREGS = 0xC074700D; -$PIXWRCREGS = 0xC074700E; -$PIRDSDRS = 0xC074700F; -$PIXGETSIGACTION = 0xC0747010; -$PIGETU = 0xC0747011; -$PISETRWTID = 0xC0747012; -$PIXGETTHCOUNT = 0xC0747013; -$PIXRUN = 0x20007014; diff --git a/contrib/perl5/h2pl/eg/sysexits.pl b/contrib/perl5/h2pl/eg/sysexits.pl deleted file mode 100644 index f4cb777..0000000 --- a/contrib/perl5/h2pl/eg/sysexits.pl +++ /dev/null @@ -1,16 +0,0 @@ -$EX_OK = 0x0; -$EX__BASE = 0x40; -$EX_USAGE = 0x40; -$EX_DATAERR = 0x41; -$EX_NOINPUT = 0x42; -$EX_NOUSER = 0x43; -$EX_NOHOST = 0x44; -$EX_UNAVAILABLE = 0x45; -$EX_SOFTWARE = 0x46; -$EX_OSERR = 0x47; -$EX_OSFILE = 0x48; -$EX_CANTCREAT = 0x49; -$EX_IOERR = 0x4A; -$EX_TEMPFAIL = 0x4B; -$EX_PROTOCOL = 0x4C; -$EX_NOPERM = 0x4D; diff --git a/contrib/perl5/h2pl/getioctlsizes b/contrib/perl5/h2pl/getioctlsizes deleted file mode 100644 index 403fffa..0000000 --- a/contrib/perl5/h2pl/getioctlsizes +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/perl - -open (IOCTLS,'/usr/include/sys/ioctl.h') || die "ioctl open failed"; - -while (<IOCTLS>) { - if (/^\s*#\s*define\s+\w+\s+_IO(R|W|WR)\('?\w+'?,\s*\w+,\s*([^)]+)/) { - $need{$2}++; - } -} - -foreach $key ( sort keys %need ) { - print $key,"\n"; -} diff --git a/contrib/perl5/h2pl/mksizes b/contrib/perl5/h2pl/mksizes deleted file mode 100644 index cb4b8ab..0000000 --- a/contrib/perl5/h2pl/mksizes +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/local/bin/perl - -($iam = $0) =~ s%.*/%%; -$tmp = "$iam.$$"; -open (CODE,">$tmp.c") || die "$iam: cannot create $tmp.c: $!\n"; - -$mask = q/printf ("$sizeof{'%s'} = %d;\n"/; - -# write C program -select(CODE); - -print <<EO_C_PROGRAM; -#include <sys/param.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <net/if_arp.h> -#include <net/if.h> -#include <net/route.h> -#include <sys/ioctl.h> - -main() { -EO_C_PROGRAM - -while ( <> ) { - chop; - printf "\t%s, \n\t\t\"%s\", sizeof(%s));\n", $mask, $_,$_; -} - -print "\n}\n"; - -close CODE; - -# compile C program - -select(STDOUT); - -system "cc $tmp.c -o $tmp"; -die "couldn't compile $tmp.c" if $?; -system "./$tmp"; -die "couldn't run $tmp" if $?; - -unlink "$tmp.c", $tmp; diff --git a/contrib/perl5/h2pl/mkvars b/contrib/perl5/h2pl/mkvars deleted file mode 100644 index ffb0f0b..0000000 --- a/contrib/perl5/h2pl/mkvars +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl - -require 'sizeof.ph'; - -$LIB = '/usr/local/lib/perl'; - -foreach $include (@ARGV) { - printf STDERR "including %s\n", $include; - do $include; - warn "sourcing $include: $@\n" if ($@); - if (!open (INCLUDE,"$LIB/$include")) { - warn "can't open $LIB/$include: $!\n"; - next; - } - while (<INCLUDE>) { - chop; - if (/^\s*eval\s+'sub\s+(\w+)\s.*[^{]$/ || /^\s*sub\s+(\w+)\s.*[^{]$/) { - $var = $1; - $val = eval "&$var;"; - if ($@) { - warn "$@: $_"; - print <<EOT; -warn "\$$var isn't correctly set" if defined \$_main{'$var'}; -EOT - next; - } - ( $nval = sprintf ("%x",$val ) ) =~ tr/a-z/A-Z/; - printf "\$%s = 0x%s;\n", $var, $nval; - } - } -} diff --git a/contrib/perl5/h2pl/tcbreak b/contrib/perl5/h2pl/tcbreak deleted file mode 100644 index 2677cc9..0000000 --- a/contrib/perl5/h2pl/tcbreak +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl - -require 'cbreak.pl'; - -&cbreak; - -$| = 1; - -print "gimme a char: "; - -$c = getc; - -print "$c\n"; - -printf "you gave me `%s', which is 0x%02x\n", $c, ord($c); - -&cooked; diff --git a/contrib/perl5/h2pl/tcbreak2 b/contrib/perl5/h2pl/tcbreak2 deleted file mode 100644 index fcbf926..0000000 --- a/contrib/perl5/h2pl/tcbreak2 +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl - -require 'cbreak2.pl'; - -&cbreak; - -$| = 1; - -print "gimme a char: "; - -$c = getc; - -print "$c\n"; - -printf "you gave me `%s', which is 0x%02x\n", $c, ord($c); - -&cooked; |