| 1 |
#!/usr/bin/php |
| 2 |
|
| 3 |
<?php |
| 4 |
/* |
| 5 |
* Written by Jared Smith and Kevin P. Fleming |
| 6 |
* |
| 7 |
* Copyright (C) 2006, Jared Smith and Digium, Inc. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
# create an array of all the different prefixes you want to match on, |
| 12 |
# as Perl-compatible regular expressions |
| 13 |
# (yes, this is a stupid example, as the second one is just a simplified |
| 14 |
# version of the first, but it's just an example) |
| 15 |
$prefixes = array('\.text\.Oct'); |
| 16 |
|
| 17 |
$fp = fopen('test.map','r'); |
| 18 |
|
| 19 |
while (!feof($fp)) |
| 20 |
{ |
| 21 |
# Loop until we find the top of section we want |
| 22 |
while ($line = fgets($fp)) |
| 23 |
{ |
| 24 |
if (preg_match('/Discarded input sections/i',$line)) |
| 25 |
{ |
| 26 |
break; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
# Now loop until we find the next section |
| 31 |
while ($line = fgets($fp)) |
| 32 |
{ |
| 33 |
if (preg_match('/Memory Configuration/i',$line)) |
| 34 |
{ |
| 35 |
# we found it! |
| 36 |
break; |
| 37 |
} |
| 38 |
foreach ($prefixes as $prefix) |
| 39 |
{ |
| 40 |
if (preg_match("/$prefix/i",$line)) |
| 41 |
{ |
| 42 |
preg_match("/Oct.*/", $line, $matches); |
| 43 |
$line2 = fgets($fp); |
| 44 |
echo "#define SKIP_".$matches[0]." 1\n"; |
| 45 |
break; |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
fclose($fp); |
| 51 |
?> |