poage@sunny.ucdavis.edu (Tom Poage) (08/15/90)
I've been playing with `makelib' to get a number of .h files
for various ioctl's. Now, terminal control works fine from the Berkeley
universe point-of-view, i.e., ioctl.pl, but the System V-type
makelib-generated termios.h is nearly useless.
(As you might have guessed, I live--err, operate--in a dual
universe [read SunOS].)
The header termios.h has:
eval 'sub TCGETS {&_IOR("T", 8, \'struct termios\');}';
eval 'sub TCSETS {&_IOW("T", 9, \'struct termios\');}';
and another included file, ioccom.h, has:
eval 'sub IOCPARM_MASK {0xff;}';
eval 'sub IOC_OUT {0x40000000;}';
eval 'sub IOC_IN {0x80000000;}';
eval 'sub _IOR {
local($x,$y,$t) = @_;
eval "(&IOC_OUT|(($sizeof{$t} & &IOCPARM_MASK)<<16)|(ord(\'$x\')<<8)|$y)";
}';
eval 'sub _IOW {
local($x,$y,$t) = @_;
eval "(&IOC_IN|(($sizeof{$t} & &IOCPARM_MASK)<<16)|(ord(\'$x\')<<8)|$y)";
}';
Unfortunately, the associative array `sizeof' is nowhere to be found.
Is it supposed to be?
Calling TCGETS and TCSETS, among others, leads to
Inappropriate ioctl for device at ...
The work-around seems to be fairly simple:
do 'sys/termios.h';
$termios_t = "LLLLCC" . &NCCS; # struct termios.
$sizeof{'struct termios'} = length(pack($termios_t,()));
# do your ioctl's here.
My questions, if you haven't already guessed them:
Why isn't array `sizeof' defined anywhere?
Is it supposed to be user-defined?
Should `makelib' be smart enough to extract struct information?
Honorable mention of the special array `sizeof' in the manual might
be indicated.
Oh, BTW...
$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
Patch level: 18
...
Tom.
--
Tom Poage, Clinical Engineering
Universiy of California, Davis, Medical Center, Sacramento, CA
poage@sunny.ucdavis.edu {...,ucbvax,uunet}!ucdavis!sunny!poagepoage@sunny.ucdavis.edu (Tom Poage) (08/15/90)
Oops! I answered my own question. Reference to %sizeof is in
the recent patches (19 I think).
Tom.
--
Tom Poage, Clinical Engineering
Universiy of California, Davis, Medical Center, Sacramento, CA
poage@sunny.ucdavis.edu {...,ucbvax,uunet}!ucdavis!sunny!poage