create_data_file.php 472 B

123456789101112131415161718
  1. #!/usr/bin/env php
  2. /* This is a generated file, do not modify */
  3. /* Usage: php create_data_file.php /path/to/magic.mgc > data_file.c */
  4. <?php
  5. $dta = file_get_contents( $argv[1] );
  6. $dta_l = strlen($dta);
  7. $j = 0;
  8. echo "const unsigned char php_magic_database[$dta_l] = {\n";
  9. for ($i = 0; $i < $dta_l; $i++) {
  10. printf("0x%02X, ", ord($dta[$i]));
  11. if ($j % 16 == 15) {
  12. echo "\n";
  13. }
  14. $j++;
  15. }
  16. echo "};\n";
  17. ?>