home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / perl / h2pl / README < prev    next >
INI File  |  1992-04-11  |  3KB  |  72 lines

  1. [This file of Tom Christiansen's has been edited to change makelib to h2ph
  2. and .h to .ph where appropriate--law.]
  3.  
  4. This directory contains files to help you convert the *.ph files generated my
  5. h2ph out of the perl source directory into *.pl files with all the
  6. indirection of the subroutine calls removed.  The .ph version will be more
  7. safely portable, because if something isn't defined on the new system, like
  8. &TIOCGETP, then you'll get a fatal run-time error on the system lacking that
  9. function.  Using the .pl version means that the subsequent scripts will give
  10. you a 0 $TIOCGETP and God only knows what may then happen.   Still, I like the
  11. .pl stuff because they're faster to load.
  12.  
  13. FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff
  14. into the perl library directory, often /usr/local/lib/perl.  For example,
  15.     # h2ph sys/ioctl.h
  16. takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection)
  17. the file /usr/local/lib/perl/sys/ioctl.ph, which looks like this
  18.  
  19.     eval 'sub TIOCM_RTS {0004;}';
  20.     eval 'sub TIOCM_ST {0010;}';
  21.     eval 'sub TIOCM_SR {0020;}';
  22.     eval 'sub TIOCM_CTS {0040;}';
  23.     eval 'sub TIOCM_CAR {0100;}';
  24.  
  25. and much worse, rather than what Larry's ioctl.pl from the perl source dir has, 
  26. which is:
  27.  
  28.     $TIOCM_RTS = 0004;
  29.     $TIOCM_ST = 0010;
  30.     $TIOCM_SR = 0020;
  31.     $TIOCM_CTS = 0040;
  32.     $TIOCM_CAR = 0100;
  33.  
  34. [Workaround for fixed bug in makedir/h2ph deleted--law.]
  35.  
  36. The more complicated ioctl subs look like this:
  37.  
  38.     eval 'sub TIOCGSIZE {&TIOCGWINSZ;}';
  39.     eval 'sub TIOCGWINSZ {&_IOR("t", 104, \'struct winsize\');}';
  40.     eval 'sub TIOCSETD {&_IOW("t", 1, \'int\');}';
  41.     eval 'sub TIOCGETP {&_IOR("t", 8,\'struct sgttyb\');}';
  42.  
  43. The _IO[RW] routines use a %sizeof array, which (presumably) 
  44. is keyed on the type name with the value being the size in bytes.  
  45.  
  46. To build %sizeof, try running this in this directory:
  47.  
  48.     % ./getioctlsizes 
  49.  
  50. Which will tell you which things the %sizeof array needs
  51. to hold.  You can try to build a sizeof.ph file with:
  52.  
  53.     % ./getioctlsizes | ./mksizes > sizeof.ph
  54.  
  55. Note that mksizes hardcodes the #include files for all the types, so it will
  56. probably require customization.  Once you have sizeof.ph, install it in the
  57. perl library directory.  Run my tcbreak script to see whether you can do
  58. ioctls in perl now.  You'll get some kind of fatal run-time error if you
  59. can't.  That script should be included in this directory.
  60.  
  61. If this works well, now you can try to convert the *.ph files into
  62. *.pl files.  Try this:
  63.  
  64.     foreach file ( sysexits.ph sys/{errno.ph,ioctl.ph} )
  65.     ./mkvars $file > t/$file:r.pl
  66.     end
  67.  
  68. The last one will be the hardest.  If it works, should be able to 
  69. run tcbreak2 and have it work the same as tcbreak.
  70.  
  71. Good luck.
  72.