xref: /PHP-5.4/scripts/dev/extern_c.php (revision 76745016)
1<?php
2
3function scan_dir($dir) {
4	if (!is_dir($dir)) return;
5
6	foreach (glob("$dir/*") as $file) {
7		if (is_dir($file)) {
8			if (basename($file) != "CVS") {
9				scan_dir($file);
10			}
11		} else if (fnmatch("*.h", $file)) {
12			scan_file($file);
13		}
14	}
15}
16
17function scan_file($file) {
18	$flag = false;
19
20	foreach (file($file) as $nr => $line) {
21		if (ereg("^[[:space:]]*BEGIN_EXTERN_C", $line)) {
22#		    echo "$file:".($nr+1)." $line";
23			$flag = true;
24		} else if (ereg("^[[:space:]]*END_EXTERN_C", $line)) {
25#		    echo "$file:".($nr+1)." $line";
26			$flag = false;
27		} else if (  (ereg("^[[:space:]]*PHPAPI[[:space:]]*", $line))
28					 ||(ereg("^[[:space:]]*ZEND_API[[:space:]]*", $line))) {
29		  if (strstr($line,"(")) {
30			  if (!$flag) echo "$file:".($nr+1)." $line";
31		  }
32		}
33	}
34}
35
36array_shift($_SERVER["argv"]);
37
38if (count($_SERVER["argv"])) {
39	foreach ($_SERVER["argv"] as $dir) {
40		scan_dir($dir);
41	}
42} else {
43	scan_dir(".");
44}
45?>