[comp.lang.perl] h to ph/pl scripts

seeger@thedon.cis.ufl.edu (F. L. Charles Seeger III) (10/25/90)

I've run into some minor trouble in translating SunOS 4.1 system include
files into ph and pl equivalents with the distributed scripts.  Before
reinventing any wheels, has anyone made some improvements on these?

Apologies in advance from this green perl user if this is a problem with
a well known solution.

TIA,
Chuck
--
  Charles Seeger    E301 CSE Building             Office: +1 904 392 1508
  CIS Department    University of Florida         Fax:    +1 904 392 1220
  seeger@ufl.edu    Gainesville, FL 32611-2024

tchrist@convex.COM (Tom Christiansen) (10/25/90)

In article <25082@uflorida.cis.ufl.EDU> seeger@thedon.cis.ufl.edu (F. L. Charles Seeger III) writes:
>I've run into some minor trouble in translating SunOS 4.1 system include
>files into ph and pl equivalents with the distributed scripts.  Before
>reinventing any wheels, has anyone made some improvements on these?
>
>Apologies in advance from this green perl user if this is a problem with
>a well known solution.

Converting .h -> .ph -> .pl files is definitely not what a green user
wants to be doing.  I don't think there is a well-known, generalized
solution to the problem.  As Larry says in the h2ph man page, "It's only
intended as a rough tool.  You may need to dicker with the files
produced."

I've been playing with h2pl/mkvars a bunch lately.  I've changed it to
recurse correctly on do $files in the .ph files; this way, for example,
the .pl version of errno.ph includes the evaluated contents of what's in
sys/errno.ph .    I have also added a some of system-dependent knowledge
of what include files need what first.  I have to muck with it for each
system I use it on, as inlcude files vary.

On my Sun running 4.1 I ended up having to translate these files, plus
their equivalent pl versions:

    errno.ph          sys/file.ph       sys/stat.ph       sys/ttydev.ph
    fcntl.ph          sys/filio.ph      sys/stdtypes.ph   sys/types.ph
    sgtty.ph          sys/ioccom.ph     sys/sysmacros.ph  syscall.ph
    signal.ph         sys/ioctl.ph      sys/termios.ph    sysexits.ph
    sizeof.ph         sys/resource.ph   sys/time.ph       vm/faultcode.ph
    sys/errno.ph      sys/signal.ph     sys/ttold.ph
    sys/fcntl.ph      sys/socket.ph     sys/ttychars.ph
    sys/fcntlcom.ph   sys/sockio.ph     sys/ttycom.ph

The way I get that list is a pick my favorites (errno, socket, ioctl,
syscall, sysexits, signal) and iterate until all the dangling include
references go away.  

I will include sizeof.ph, sys/ioctl.ph, and sys/ioctl.pl for SunOS 4.1
at the this posting.  If you want the current working version of 
the h2pl stuff, or if you would like all the above files for SunOS 4.1,
send me mail.  I intend to have the h2pl system updated and releasable
relatively RSN, but not before I finish the FAQs.

--tom

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	sizeof.ph
#	sys
# This archive created: Wed Oct 24 19:44:20 1990
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'sizeof.ph'" '(297 characters)'
if test -f 'sizeof.ph'
then
	echo shar: "will not over-write existing file 'sizeof.ph'"
else
sed 's/^	X//' << \SHAR_EOF > 'sizeof.ph'
	X$sizeof{'int'} = 4;
	X$sizeof{'struct arpreq'} = 36;
	X$sizeof{'struct ifconf'} = 8;
	X$sizeof{'struct ifreq'} = 32;
	X$sizeof{'struct ltchars'} = 6;
	X$sizeof{'struct nit_ioc'} = 36;
	X$sizeof{'struct rtentry'} = 48;
	X$sizeof{'struct sgttyb'} = 6;
	X$sizeof{'struct tchars'} = 6;
	X$sizeof{'struct ttysize'} = 8;
SHAR_EOF
if test 297 -ne "`wc -c < 'sizeof.ph'`"
then
	echo shar: "error transmitting 'sizeof.ph'" '(should have been 297 characters)'
fi
chmod 664 'sizeof.ph'
fi
if test ! -d 'sys'
then
	echo shar: "creating directory 'sys'"
	mkdir 'sys'
fi
echo shar: "entering directory 'sys'"
cd 'sys'
echo shar: "extracting 'ioctl.ph'" '(2127 characters)'
if test -f 'ioctl.ph'
then
	echo shar: "will not over-write existing file 'ioctl.ph'"
else
sed 's/^	X//' << \SHAR_EOF > 'ioctl.ph'
	Xif (!defined &_sys_ioctl_h) {
	X    eval 'sub _sys_ioctl_h {1;}';
	X    do 'sys/ttychars.ph' || die "Can't include sys/ttychars.ph: $!";
	X    do 'sys/ttydev.ph' || die "Can't include sys/ttydev.ph: $!";
	X    do 'sys/ttold.ph' || die "Can't include sys/ttold.ph: $!";
	X    eval 'sub TANDEM { (&O_TANDEM);}';
	X    eval 'sub CBREAK { (&O_CBREAK);}';
	X    eval 'sub LCASE { (&O_LCASE);}';
	X    eval 'sub ECHO { (&O_ECHO);}';
	X    eval 'sub CRMOD { (&O_CRMOD);}';
	X    eval 'sub RAW { (&O_RAW);}';
	X    eval 'sub ODDP { (&O_ODDP);}';
	X    eval 'sub EVENP { (&O_EVENP);}';
	X    eval 'sub ANYP { (&O_ANYP);}';
	X    eval 'sub NLDELAY { (&O_NLDELAY);}';
	X    eval 'sub NL0 { (&O_NL0);}';
	X    eval 'sub NL1 { (&O_NL1);}';
	X    eval 'sub NL2 { (&O_NL2);}';
	X    eval 'sub NL3 { (&O_NL3);}';
	X    eval 'sub TBDELAY { (&O_TBDELAY);}';
	X    eval 'sub TAB0 { (&O_TAB0);}';
	X    eval 'sub TAB1 { (&O_TAB1);}';
	X    eval 'sub TAB2 { (&O_TAB2);}';
	X    eval 'sub XTABS { (&O_XTABS);}';
	X    eval 'sub CRDELAY { (&O_CRDELAY);}';
	X    eval 'sub CR0 { (&O_CR0);}';
	X    eval 'sub CR1 { (&O_CR1);}';
	X    eval 'sub CR2 { (&O_CR2);}';
	X    eval 'sub CR3 { (&O_CR3);}';
	X    eval 'sub VTDELAY { (&O_VTDELAY);}';
	X    eval 'sub FF0 { (&O_FF0);}';
	X    eval 'sub FF1 { (&O_FF1);}';
	X    eval 'sub BSDELAY { (&O_BSDELAY);}';
	X    eval 'sub BS0 { (&O_BS0);}';
	X    eval 'sub BS1 { (&O_BS1);}';
	X    eval 'sub ALLDELAY { (&O_ALLDELAY);}';
	X    eval 'sub CRTBS { (&O_CRTBS);}';
	X    eval 'sub PRTERA { (&O_PRTERA);}';
	X    eval 'sub CRTERA { (&O_CRTERA);}';
	X    eval 'sub TILDE { (&O_TILDE);}';
	X    eval 'sub MDMBUF { (&O_MDMBUF);}';
	X    eval 'sub LITOUT { (&O_LITOUT);}';
	X    eval 'sub TOSTOP { (&O_TOSTOP);}';
	X    eval 'sub FLUSHO { (&O_FLUSHO);}';
	X    eval 'sub NOHANG { (&O_NOHANG);}';
	X    eval 'sub L001000 { (&O_L001000);}';
	X    eval 'sub CRTKIL { (&O_CRTKIL);}';
	X    eval 'sub PASS8 { (&O_PASS8);}';
	X    eval 'sub CTLECH { (&O_CTLECH);}';
	X    eval 'sub PENDIN { (&O_PENDIN);}';
	X    eval 'sub DECCTQ { (&O_DECCTQ);}';
	X    eval 'sub NOFLSH { (&O_NOFLSH);}';
	X    do 'sys/filio.ph' || die "Can't include sys/filio.ph: $!";
	X    do 'sys/sockio.ph' || die "Can't include sys/sockio.ph: $!";
	X}
	X1;
SHAR_EOF
if test 2127 -ne "`wc -c < 'ioctl.ph'`"
then
	echo shar: "error transmitting 'ioctl.ph'" '(should have been 2127 characters)'
fi
chmod 664 'ioctl.ph'
fi
echo shar: "extracting 'ioctl.pl'" '(6332 characters)'
if test -f 'ioctl.pl'
then
	echo shar: "will not over-write existing file 'ioctl.pl'"
else
sed 's/^	X//' << \SHAR_EOF > 'ioctl.pl'
	X$_sys_ioctl_h = 0x1;
	X$_sys_ttychars_h = 0x1;
	X$CERASE = 0x7F;
	X$CQUIT = 0x1C;
	X$CBRK = 0xFF;
	X$__sys_ttydev_h = 0x1;
	X$B0 = 0x0;
	X$B50 = 0x1;
	X$B75 = 0x2;
	X$B110 = 0x3;
	X$B134 = 0x4;
	X$B150 = 0x5;
	X$B200 = 0x6;
	X$B300 = 0x7;
	X$B600 = 0x8;
	X$B1200 = 0x9;
	X$B1800 = 0xA;
	X$B2400 = 0xB;
	X$B4800 = 0xC;
	X$B9600 = 0xD;
	X$B19200 = 0xE;
	X$B38400 = 0xF;
	X$EXTA = 0xE;
	X$EXTB = 0xF;
	X$DONE = 0x80;
	X$IENABLE = 0x40;
	X$DMSET = 0x0;
	X$DMBIS = 0x1;
	X$DMBIC = 0x2;
	X$DMGET = 0x3;
	X$_sys_ttold_h = 0x1;
	X$_SGTTYB_ = 0x1;
	X$__sys_ioccom_h = 0x1;
	X$_IOCPARM_MASK = 0xFF;
	X$_IOC_VOID = 0x20000000;
	X$_IOC_OUT = 0x40000000;
	X$_IOC_IN = 0x80000000;
	X$_IOC_INOUT = 0xC0000000;
	X$TIOCGETD = 0x40047400;
	X$TIOCSETD = 0x80047401;
	X$TIOCHPCL = 0x20007402;
	X$TIOCMODG = 0x40047403;
	X$TIOCMODS = 0x80047404;
	X$TIOCGETP = 0x40067408;
	X$TIOCSETP = 0x80067409;
	X$TIOCSETN = 0x8006740A;
	X$TIOCEXCL = 0x2000740D;
	X$TIOCNXCL = 0x2000740E;
	X$TIOCFLUSH = 0x80047410;
	X$TIOCSETC = 0x80067411;
	X$TIOCGETC = 0x40067412;
	X$O_TANDEM = 0x1;
	X$O_CBREAK = 0x2;
	X$O_LCASE = 0x4;
	X$O_ECHO = 0x8;
	X$O_CRMOD = 0x10;
	X$O_RAW = 0x20;
	X$O_ODDP = 0x40;
	X$O_EVENP = 0x80;
	X$O_ANYP = 0xC0;
	X$O_NLDELAY = 0x300;
	X$O_NL0 = 0x0;
	X$O_NL1 = 0x100;
	X$O_NL2 = 0x200;
	X$O_NL3 = 0x300;
	X$O_TBDELAY = 0xC00;
	X$O_TAB0 = 0x0;
	X$O_TAB1 = 0x400;
	X$O_TAB2 = 0x800;
	X$O_XTABS = 0xC00;
	X$O_CRDELAY = 0x3000;
	X$O_CR0 = 0x0;
	X$O_CR1 = 0x1000;
	X$O_CR2 = 0x2000;
	X$O_CR3 = 0x3000;
	X$O_VTDELAY = 0x4000;
	X$O_FF0 = 0x0;
	X$O_FF1 = 0x4000;
	X$O_BSDELAY = 0x8000;
	X$O_BS0 = 0x0;
	X$O_BS1 = 0x8000;
	X$O_ALLDELAY = 0xFF00;
	X$O_CRTBS = 0x10000;
	X$O_PRTERA = 0x20000;
	X$O_CRTERA = 0x40000;
	X$O_TILDE = 0x80000;
	X$O_MDMBUF = 0x100000;
	X$O_LITOUT = 0x200000;
	X$O_TOSTOP = 0x400000;
	X$O_FLUSHO = 0x800000;
	X$O_NOHANG = 0x1000000;
	X$O_L001000 = 0x2000000;
	X$O_CRTKIL = 0x4000000;
	X$O_PASS8 = 0x8000000;
	X$O_CTLECH = 0x10000000;
	X$O_PENDIN = 0x20000000;
	X$O_DECCTQ = 0x40000000;
	X$O_NOFLSH = 0x80000000;
	X$TIOCLBIS = 0x8004747F;
	X$TIOCLBIC = 0x8004747E;
	X$TIOCLSET = 0x8004747D;
	X$TIOCLGET = 0x4004747C;
	X$LCRTBS = 0x1;
	X$LPRTERA = 0x2;
	X$LCRTERA = 0x4;
	X$LTILDE = 0x8;
	X$LMDMBUF = 0x10;
	X$LLITOUT = 0x20;
	X$LTOSTOP = 0x40;
	X$LFLUSHO = 0x80;
	X$LNOHANG = 0x100;
	X$LCRTKIL = 0x400;
	X$LPASS8 = 0x800;
	X$LCTLECH = 0x1000;
	X$LPENDIN = 0x2000;
	X$LDECCTQ = 0x4000;
	X$LNOFLSH = 0x8000;
	X$TIOCSBRK = 0x2000747B;
	X$TIOCCBRK = 0x2000747A;
	X$TIOCSDTR = 0x20007479;
	X$TIOCCDTR = 0x20007478;
	X$TIOCSLTC = 0x80067475;
	X$TIOCGLTC = 0x40067474;
	X$TIOCSTOP = 0x2000746F;
	X$TIOCSTART = 0x2000746E;
	X$_O_TIOCCONS = 0x20007468;
	X$_O_TIOCSSIZE = 0x80007467;
	X$_O_TIOCGSIZE = 0x40007466;
	X$TIOCSETX = 0x80047422;
	X$TIOCGETX = 0x40047423;
	X$NOPOST = 0x1;
	X$NOISIG = 0x2;
	X$STOPB = 0x4;
	X$OTTYDISC = 0x0;
	X$NETLDISC = 0x1;
	X$NTTYDISC = 0x2;
	X$TABLDISC = 0x3;
	X$NTABLDISC = 0x4;
	X$MOUSELDISC = 0x5;
	X$KBDLDISC = 0x6;
	X$__sys_ttycom_h = 0x1;
	X$TIOCGWINSZ = 0x40087468;
	X$TIOCSWINSZ = 0x80087467;
	X$TIOCSSIZE = 0x80007425;
	X$TIOCGSIZE = 0x40007426;
	X$TIOCSCTTY = 0x20007484;
	X$TIOCGPGRP = 0x40047477;
	X$TIOCGETPGRP = 0x40047483;
	X$TIOCSPGRP = 0x80047476;
	X$TIOCSETPGRP = 0x80047482;
	X$TIOCOUTQ = 0x40047473;
	X$TIOCSTI = 0x80017472;
	X$TIOCNOTTY = 0x20007471;
	X$TIOCPKT = 0x80047470;
	X$TIOCPKT_DATA = 0x0;
	X$TIOCPKT_FLUSHREAD = 0x1;
	X$TIOCPKT_FLUSHWRITE = 0x2;
	X$TIOCPKT_STOP = 0x4;
	X$TIOCPKT_START = 0x8;
	X$TIOCPKT_NOSTOP = 0x10;
	X$TIOCPKT_DOSTOP = 0x20;
	X$TIOCPKT_IOCTL = 0x40;
	X$TIOCMSET = 0x8004746D;
	X$TIOCMBIS = 0x8004746C;
	X$TIOCMBIC = 0x8004746B;
	X$TIOCMGET = 0x4004746A;
	X$TIOCM_LE = 0x1;
	X$TIOCM_DTR = 0x2;
	X$TIOCM_RTS = 0x4;
	X$TIOCM_ST = 0x8;
	X$TIOCM_SR = 0x10;
	X$TIOCM_CTS = 0x20;
	X$TIOCM_CAR = 0x40;
	X$TIOCM_CD = 0x40;
	X$TIOCM_RNG = 0x80;
	X$TIOCM_RI = 0x80;
	X$TIOCM_DSR = 0x100;
	X$TIOCREMOTE = 0x80047469;
	X$TIOCUCNTL = 0x80047466;
	X$TIOCTCNTL = 0x80047420;
	X$TIOCSIGNAL = 0x80047421;
	X$TIOCCONS = 0x20007424;
	X$TIOCSSOFTCAR = 0x80047465;
	X$TIOCGSOFTCAR = 0x40047464;
	X$TIOCISPACE = 0x40047480;
	X$TIOCISIZE = 0x40047481;
	X$TANDEM = 0x1;
	X$CBREAK = 0x2;
	X$LCASE = 0x4;
	X$ECHO = 0x8;
	X$CRMOD = 0x10;
	X$RAW = 0x20;
	X$ODDP = 0x40;
	X$EVENP = 0x80;
	X$ANYP = 0xC0;
	X$NLDELAY = 0x300;
	X$NL0 = 0x0;
	X$NL1 = 0x100;
	X$NL2 = 0x200;
	X$NL3 = 0x300;
	X$TBDELAY = 0xC00;
	X$TAB0 = 0x0;
	X$TAB1 = 0x800;
	X$TAB2 = 0x1000;
	X$XTABS = 0x1800;
	X$CRDELAY = 0x3000;
	X$CR0 = 0x0;
	X$CR1 = 0x200;
	X$CR2 = 0x400;
	X$CR3 = 0x600;
	X$VTDELAY = 0x4000;
	X$FF0 = 0x0;
	X$FF1 = 0x8000;
	X$BSDELAY = 0x8000;
	X$BS0 = 0x0;
	X$BS1 = 0x2000;
	X$ALLDELAY = 0xFF00;
	X$CRTBS = 0x10000;
	X$PRTERA = 0x20000;
	X$CRTERA = 0x40000;
	X$TILDE = 0x80000;
	X$MDMBUF = 0x100000;
	X$LITOUT = 0x200000;
	X$TOSTOP = 0x100;
	X$FLUSHO = 0x2000;
	X$NOHANG = 0x1000000;
	X$L001000 = 0x2000000;
	X$CRTKIL = 0x4000000;
	X$PASS8 = 0x8000000;
	X$CTLECH = 0x10000000;
	X$PENDIN = 0x4000;
	X$DECCTQ = 0x40000000;
	X$NOFLSH = 0x80;
	X$_sys_filio_h = 0x1;
	X$__sys_ioccom_h = 0x1;
	X$_IOCPARM_MASK = 0xFF;
	X$_IOC_VOID = 0x20000000;
	X$_IOC_OUT = 0x40000000;
	X$_IOC_IN = 0x80000000;
	X$_IOC_INOUT = 0xC0000000;
	X$FIOCLEX = 0x20006601;
	X$FIONCLEX = 0x20006602;
	X$FIONREAD = 0x4004667F;
	X$FIONBIO = 0x8004667E;
	X$FIOASYNC = 0x8004667D;
	X$FIOSETOWN = 0x8004667C;
	X$FIOGETOWN = 0x4004667B;
	X$_sys_sockio_h = 0x1;
	X$__sys_ioccom_h = 0x1;
	X$_IOCPARM_MASK = 0xFF;
	X$_IOC_VOID = 0x20000000;
	X$_IOC_OUT = 0x40000000;
	X$_IOC_IN = 0x80000000;
	X$_IOC_INOUT = 0xC0000000;
	X$SIOCSHIWAT = 0x80047300;
	X$SIOCGHIWAT = 0x40047301;
	X$SIOCSLOWAT = 0x80047302;
	X$SIOCGLOWAT = 0x40047303;
	X$SIOCATMARK = 0x40047307;
	X$SIOCSPGRP = 0x80047308;
	X$SIOCGPGRP = 0x40047309;
	X$SIOCADDRT = 0x8030720A;
	X$SIOCDELRT = 0x8030720B;
	X$SIOCSIFADDR = 0x8020690C;
	X$SIOCGIFADDR = 0xC020690D;
	X$SIOCSIFDSTADDR = 0x8020690E;
	X$SIOCGIFDSTADDR = 0xC020690F;
	X$SIOCSIFFLAGS = 0x80206910;
	X$SIOCGIFFLAGS = 0xC0206911;
	X$SIOCSIFMEM = 0x80206912;
	X$SIOCGIFMEM = 0xC0206913;
	X$SIOCGIFCONF = 0xC0086914;
	X$SIOCSIFMTU = 0x80206915;
	X$SIOCGIFMTU = 0xC0206916;
	X$SIOCGIFBRDADDR = 0xC0206917;
	X$SIOCSIFBRDADDR = 0x80206918;
	X$SIOCGIFNETMASK = 0xC0206919;
	X$SIOCSIFNETMASK = 0x8020691A;
	X$SIOCGIFMETRIC = 0xC020691B;
	X$SIOCSIFMETRIC = 0x8020691C;
	X$SIOCSARP = 0x8024691E;
	X$SIOCGARP = 0xC024691F;
	X$SIOCDARP = 0x80246920;
	X$SIOCUPPER = 0x80206928;
	X$SIOCLOWER = 0x80206929;
	X$SIOCSETSYNC = 0x8020692C;
	X$SIOCGETSYNC = 0xC020692D;
	X$SIOCSSDSTATS = 0xC020692E;
	X$SIOCSSESTATS = 0xC020692F;
	X$SIOCSPROMISC = 0x80046930;
	X$SIOCADDMULTI = 0x80206931;
	X$SIOCDELMULTI = 0x80206932;
	X$SIOCFDRESET = 0x80206933;
	X$SIOCFDSLEEP = 0x80206934;
	X$SIOCSTRTFMWAR = 0x80206935;
	X$SIOCLDNSTRTFW = 0x80206936;
	X$SIOCGETFDSTAT = 0x80206937;
	X$SIOCFDNMIINT = 0x80206938;
	X$SIOCFDEXUSER = 0x80206939;
	X$SIOCFDGNETMAP = 0x8020693A;
	X$SIOCFDGIOCTL = 0x8020693B;
	X$SIOCSNIT = 0x80007000;
	X$SIOCGNIT = 0xC0007001;
SHAR_EOF
if test 6332 -ne "`wc -c < 'ioctl.pl'`"
then
	echo shar: "error transmitting 'ioctl.pl'" '(should have been 6332 characters)'
fi
chmod 664 'ioctl.pl'
fi
chmod 775 .
echo shar: "done with directory 'sys'"
cd ..
exit 0
#	End of shell archive