Back to index

php5  5.3.10
extern_c.php
Go to the documentation of this file.
00001 <?php
00002 
00003 function scan_dir($dir) {
00004        if (!is_dir($dir)) return;
00005 
00006        foreach (glob("$dir/*") as $file) {
00007               if (is_dir($file)) {
00008                      if (basename($file) != "CVS") {
00009                             scan_dir($file);
00010                      }
00011               } else if (fnmatch("*.h", $file)) {
00012                      scan_file($file); 
00013               }
00014        }
00015 }
00016        
00017 function scan_file($file) {
00018        $flag = false;
00019        
00020        foreach (file($file) as $nr => $line) {
00021               if (ereg("^[[:space:]]*BEGIN_EXTERN_C", $line)) {
00022 #                 echo "$file:".($nr+1)." $line";
00023                      $flag = true;
00024               } else if (ereg("^[[:space:]]*END_EXTERN_C", $line)) {
00025 #                 echo "$file:".($nr+1)." $line";
00026                      $flag = false;
00027               } else if (  (ereg("^[[:space:]]*PHPAPI[[:space:]]*", $line)) 
00028                                     ||(ereg("^[[:space:]]*ZEND_API[[:space:]]*", $line))) {
00029                 if (strstr($line,"(")) { 
00030                        if (!$flag) echo "$file:".($nr+1)." $line";
00031                 }
00032               }
00033        }
00034 }
00035 
00036 array_shift($_SERVER["argv"]);
00037 
00038 if (count($_SERVER["argv"])) {
00039        foreach ($_SERVER["argv"] as $dir) {
00040               scan_dir($dir);
00041        }
00042 } else {
00043        scan_dir(".");
00044 }
00045 ?>