summaryrefslogtreecommitdiff
path: root/h2pl/mksizes
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:06:03 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:06:03 +0000
commit450a55e4ae4b31d34735cf512c9f6c2f3a39ddad (patch)
tree752aeabe6e76da59a339e47582e399d4e5c184fe /h2pl/mksizes
parent154e51a4a1b0258759b5e901183403af515a35b9 (diff)
downloadperl-450a55e4ae4b31d34735cf512c9f6c2f3a39ddad.tar.gz
perl 3.0 patch #23 patch #19, continued
See patch #19.
Diffstat (limited to 'h2pl/mksizes')
-rw-r--r--h2pl/mksizes42
1 files changed, 42 insertions, 0 deletions
diff --git a/h2pl/mksizes b/h2pl/mksizes
new file mode 100644
index 0000000000..cb4b8ab86e
--- /dev/null
+++ b/h2pl/mksizes
@@ -0,0 +1,42 @@
+#!/usr/local/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;