#!/usr/bin/perl system("grep 'define NETSNMP_DS_' ../../../include/net-snmp/agent/ds_agent.h > default_store.h"); #gcc -E ../../include/net-snmp/library/default_store.h | grep -v default_store.h >> default_store.h system("h2xs -b 5.5.0 -n NetSNMP::agent::default_store -O default_store.h"); open(ORIG,"default_store.xs"); open(NEW1,"NetSNMP-agent-default_store/fallback/const-c.inc") || die "can't open inc file 1"; open(NEW2,"NetSNMP-agent-default_store/fallback/const-xs.inc") || die "can't open inc file 2"; open(OUT,">default_store_new.xs"); # get up to the include from the original file while() { print OUT; last if (/include ; print OUT "\n\n/* autogenerated by \"gen\" from const-xs.inc */\n\n"; print OUT "MODULE = NetSNMP::agent::default_store PACKAGE = NetSNMP::agent::default_store\n\n"; print OUT ; #print OUT "\n\n/* autogenerated by \"gen\" from tail of old .xs file */\n\n"; print OUT "\n\n\n"; close(OUT); # # generate test # open(H,"default_store.h"); open(ORIG,"test.pl"); open(OUT,">test.pl.new"); while() { print OUT; last if (/\%tests =/); } while() { if (/define\s+(\w+)\s+(\d+)/) { printf OUT (" %-40s => %d,\n", "\"$1\"", $2); $tokenlist .= " $1\n"; } } while() { last if (/\);/); } print OUT; print OUT ; close(OUT); # # modify the perl module itself # open(H,"default_store.h"); open(ORIG,"default_store.pm"); open(OUT,">default_store_new.pm"); # first list while() { print OUT; last if (/\%EXPORT_TAGS =/); } print OUT $tokenlist; while() { last if (/\) \] \);/); } print OUT; # second list while() { print OUT; last if (/\@EXPORT =/); } print OUT $tokenlist; while() { last if (/\);/); } print OUT; # last section while() { print OUT; last if (/head2 Exportable constants/); } print OUT "\n"; print OUT $tokenlist; while() { last if (/^\s*$/); } print OUT "\n"; print OUT; # tail end print OUT ; close(OUT); # # install new files # print "updated test.pl\n"; rename("test.pl.new","test.pl"); rename("default_store_new.pm", "default_store.pm"); print "updated default_store.pm\n"; rename("default_store_new.xs", "default_store.xs"); print "updated default_store.xs\n"; # # remove the temp files. # system("rm -rf NetSNMP-agent-default_store"); unlink("default_store.h");