1<?php 2 3$cache = false; 4 5$urls = [ 6 "drawing_wand" => "https://imagemagick.org/api/drawing-wand.php", 7 "pixel_iterator" => "https://imagemagick.org/api/pixel-iterator.php", 8 "pixel_wand" => "https://imagemagick.org/api/pixel-wand.php", 9 "wand_view" => "https://imagemagick.org/api/wand-view.php", 10 "magick_image" => "https://imagemagick.org/api/magick-image.php", 11 "magick_property" => "https://imagemagick.org/api/magick-property.php", 12 "magick_wand" => "https://imagemagick.org/api/magick-wand.php", 13]; 14 15function getFileName($type) 16{ 17 return __DIR__ . "/found_" . $type . "_methods.txt"; 18} 19 20$methods = []; 21 22if ($cache === false) { 23 24 foreach ($urls as $type => $url) { 25 $html = file_get_contents($url); 26 27 $pattern = '#<a href=".+" id="(.+)">\1</a>#iu'; 28 $count = preg_match_all($pattern, $html, $matches); 29 30 foreach ($matches[1] as $matchDetail) { 31 $methods[$matchDetail] = false; 32 } 33 34 file_put_contents(getFileName($type), implode("\n", $matches[1])); 35 } 36} 37else { 38 foreach ($urls as $type => $url) { 39 $filename = getFileName($type); 40 $lines = file($filename); 41 42 foreach ($lines as $line) { 43 $line = trim($line); 44 if (strlen($line) > 0) { 45 $methods[$line] = false; 46 } 47 } 48 } 49 50} 51 52 53 54$tests = [ 55 "draw", 56 "pixel", 57 "wand" 58]; 59 60$unsupportedMethods = [ 61 "MagickSetImageEndian", // nope. 62 "MagickGetImageEndian", //nope, nope, nope 63 "MagickDestroyImage", //this shouldn't be needed. It's covered by clear? 64 "MagickGetImageFuzz", // I'm not aware of any operations that use the built in fuzz 65 "MagickSetImageFuzz", // I'm not aware of any operations that use the built in fuzz 66 "MagickGetImageChannelDistortions", //Don't understand 67 "MagickGetImageChannelFeatures", //Don't understand 68 "MagickConstituteImage", //duplicate functionality. 69 "MagickCompositeLayers", //duplicate functionality. 70 71 //Pixel 72 "PixelGetException", // not a user function 73 "NewPixelWands", // Probably not needed. 74 "IsDrawingWand", //Not needed 75 "ClonePixelWands", // Hopefully not needed 76 "DestroyPixelWands", //Shouldn't be needed? 77 "PixelGetMagickColor", // We don't expose MagickPixelPacket currently 78 "PixelSetMagickColor", // We don't expose MagickPixelPacket currently 79 "ClonePixelWands", //Shouldn't be needed. 80 "DestroyPixelWands", //shouldn't be needed. 81 "PixelGetColorAsNormalizedString", //stahp 82 "PixelGetExceptionType", // This should be everywhere? 83 "PixelGetQuantumColor", //pixelpackets are not exposed. 84 "PixelSetQuantumColor", //pixelpackets are not exposed. 85 86 // Draw 87 "DrawAllocateWand", // not a user function 88 "IsDrawingWand", //Not needed 89 90 91 // TODO - add these when someone asks for them or they are required 92 "SetWandViewIterator", 93 "TransferWandViewIterator", 94 "UpdateWandViewIterator", 95 "ClonePixelIterator", 96 "CloneWandView", 97 "DestroyWandView", 98 "GetWandViewException", 99 "GetWandViewExtent", 100 "GetWandViewIterator", 101 "GetWandViewPixels", 102 "GetWandViewWand", 103 "DrawCloneExceptionInfo", 104 "DrawGetExceptionType", 105 106 107 108 109 // TODO - these should not be needed in PHP land 110 "IsMagickWand", 111 "IsMagickWandInstantiated", 112 "IsPixelIterator", 113 "IsWandView", 114 115 116 117 118 119]; 120 121 122//$methods = []; 123// 124//foreach ($tests as $test) { 125// $lines = file($test."_methods.txt"); 126// if ($lines === false) { 127// echo "Couldn't read file for $test \n"; 128// exit(-1); 129// } 130// 131// foreach ($lines as $line) { 132// $methods[trim($line)] = false; 133// } 134//} 135 136 137 138$files = glob("../*.c"); 139 140$contents = []; 141 142$excludeSourceFiles = [ 143 "#.*shim.s*#" 144]; 145 146foreach ($files as $file) { 147 //Don't look in some source files. 148 foreach ($excludeSourceFiles as $excludeSourceFile) { 149 if (preg_match($excludeSourceFile, $file) !== 0) { 150 echo "Excluding file $file\n"; 151 continue 2; 152 } 153 } 154 155 echo "Check file $file \n"; 156 157 $contents = file_get_contents($file); 158 159 if ($contents == false) { 160 echo "Failed to read $file\n"; 161 exit(0); 162 } 163 164 foreach ($methods as $name => $found) { 165 if ($found == true) { 166 continue; 167 } 168 169 $position = strpos($contents, $name); 170 171 if ($position !== false) { 172 $methods[$name] = true; 173 } 174 } 175} 176 177//exit(0); 178ksort($methods); 179foreach ($methods as $name => $found) { 180 if (in_array($name, $unsupportedMethods) == true) { 181 continue; 182 } 183 184 if ($found == false) { 185 echo "Missing: $name\n"; 186 } 187} 188 189 190 191 192 193 194 195 196 197