示例#1
0
<?php 
/**
 * The apache httpd project contains the most-complete list
 * of file extension to mime type mapping on the planet.
 * We use it to update our own list.
 */
$url = 'http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co';
if ($argc >= 2) {
    $url = $argv[1];
}
//which MIME type to choose if an extension has several
$duplicateResolution = array('sub' => 'text/vnd.dvb.subtitle', 'wmz' => 'application/x-msmetafile');
$map = loadMapFromUrl($url);
$map = addExistingMap($map);
$code = generateCodeFromMap($map);
writeCode($code);
function writeCode($code)
{
    $file = __DIR__ . '/../MIME/Type/Extension.php';
    $new = preg_replace('#public \\$extensionToType = array\\(.+?\\);#s', "public \$extensionToType = array(\n" . $code . "    );", file_get_contents($file));
    file_put_contents($file, $new);
    logMsg('Code updated');
}
/**
 * Generate PHP source code suitable for a class property array definition
 *
 * @return string PHP code for array($code)
 */
function generateCodeFromMap($map)
{
    asort($map);
示例#2
0
文件: pasm.php 项目: ibjon93/pm0
        case 'sto':
            writeCode($fout, 4, $line[1], $line[2]);
            break;
        case 'cal':
            writeCode($fout, 5, $line[1], $labels[trim($line[2])]);
            break;
        case 'inc':
            writeCode($fout, 6, 0, $line[1]);
            break;
        case 'jmp':
            writeCode($fout, 7, 0, $labels[trim($line[1])]);
            break;
        case 'jpc':
            writeCode($fout, 8, 0, $labels[trim($line[1])]);
            break;
        case 'soi':
            writeCode($fout, 9, 0, 1);
            break;
        case 'sio':
            writeCode($fout, 10, 0, 2);
            break;
        case '':
            break;
        default:
            fprintf($fout, "YOUR ASSEMBLY IS BORKED\n");
    }
}
function writeCode($fout, $x, $y, $z)
{
    fprintf($fout, "%d %d %d\n", $x, $y, $z);
}