freebsd-dev/gnu/usr.bin/perl/h2pl/mksizes
Garrett Wollman 7d22abd50c Convince Perl to that is is part of the system, as /usr/bin/perl (binary)
and /usr/share/perl (library).  The latter was chosen as analogous to other
directories already present in /usr/share, like /usr/share/groff_font and
(particularly) /usr/share/mk.
1994-10-27 23:16:54 +00:00

43 lines
710 B
Perl

#!/usr/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;