perl/h2pl/README
<<
>>
Prefs
   1[This file of Tom Christiansen's has been edited to change makelib to h2ph
   2and .h to .ph where appropriate--law.]
   3
   4This directory contains files to help you convert the *.ph files generated my
   5h2ph out of the perl source directory into *.pl files with all the
   6indirection of the subroutine calls removed.  The .ph version will be more
   7safely 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
   9function.  Using the .pl version means that the subsequent scripts will give
  10you 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
  13FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff
  14into the perl library directory, often /usr/local/lib/perl.  For example,
  15    # h2ph sys/ioctl.h
  16takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection)
  17the 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
  25and much worse, rather than what Larry's ioctl.pl from the perl source dir has, 
  26which 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
  36The 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
  43The _IO[RW] routines use a %sizeof array, which (presumably) 
  44is keyed on the type name with the value being the size in bytes.  
  45
  46To build %sizeof, try running this in this directory:
  47
  48    % ./getioctlsizes 
  49
  50Which will tell you which things the %sizeof array needs
  51to hold.  You can try to build a sizeof.ph file with:
  52
  53    % ./getioctlsizes | ./mksizes > sizeof.ph
  54
  55Note that mksizes hardcodes the #include files for all the types, so it will
  56probably require customization.  Once you have sizeof.ph, install it in the
  57perl library directory.  Run my tcbreak script to see whether you can do
  58ioctls in perl now.  You'll get some kind of fatal run-time error if you
  59can't.  That script should be included in this directory.
  60
  61If 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
  68The last one will be the hardest.  If it works, should be able to 
  69run tcbreak2 and have it work the same as tcbreak.
  70
  71Good luck.
  72
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.