6 my $address_family = "";
14 while($line and ($line =~ /^#/ or $line =~ /^\s*$/)) {
17 if (!$line) { return 0; }
19 while ($line =~ m/^(.*)\\$/) {
28 my $cmd = "$_[1]" ? "$_[1]\\b\\s*" : "";;
29 my $indentexp = (@_ == 3) ? "$_[2]\\s+" : "";
31 if ($line =~ /^${indentexp}${cmd}(([^\s](.*[^\s])?)?)\s*$/) {
38 sub get_address_family {
39 $address_family = $_[0] if ($address_family eq "");
42 sub get_architecture {
44 die("architecture declaration appears too late") if (keys %methods);
45 print "#include \"arch${arch}.h\"\n\n\n";
50 my $indent = ($line =~ /(\s*)[^\s]/) ? $1 : "";
52 die "Duplicate method $method\n" if ($methods{$method}++);
55 if (match($line, "description", $indent)) {
58 if (match($line, "options", $indent)) {
61 if (match($line, "up", $indent)) {
62 get_commands(${method}, "up");
64 print "static int ${method}_up(interface_defn ifd) { return 0; }\n"
66 if (match($line, "down", $indent)) {
67 get_commands(${method}, "down");
69 print "static int ${method}_down(interface_defn ifd) { return 0; }\n"
74 my $indent = ($line =~ /(\s*)[^\s]/) ? $1 : "";
76 1 while (nextline && match($line, "", $indent));
81 my $function = "${method}_${mode}";
82 my $indent = ($line =~ /(\s*)[^\s]/) ? $1 : "";
84 print "static int ${function}(interface_defn *ifd, execfn *exec) {\n";
86 while (nextline && match($line, "", $indent)) {
87 if ( $match =~ /^(.*[^\s])\s+if\s*\((.*)\)\s*$/ ) {
88 print "if ( $2 ) {\n";
89 print " if (!execute(\"$1\", ifd, exec)) return 0;\n";
91 } elsif ( $match =~ /^(.*[^\s])\s+elsif\s*\((.*)\)\s*$/ ) {
92 print "else if ( $2 ) {\n";
93 print " if (!execute(\"$1\", ifd, exec)) return 0;\n";
95 } elsif ( $match =~ /^(.*[^\s])\s*$/ ) {
97 print " if (!execute(\"$1\", ifd, exec)) return 0;\n";
107 print "#include \"header.h\"\n\n\n";
110 if (match($line, "address_family")) {
111 get_address_family $match;
114 if (match($line, "architecture")) {
115 get_architecture $match;
118 if (match($line, "method")) {
124 die("Unknown command \"$line\"");
126 print "static method methods[] = {\n";
128 foreach $method (keys %methods) {
132 ${method}_up, ${method}_down,
139 address_family addr_${address_family} = {
141 sizeof(methods)/sizeof(struct method),