コード例 #1
0
ファイル: chatd.php プロジェクト: EmmanuelYupit/educursos
        $DAEMON->fatal('Garbage in command line');
    }
} else {
    // Parse command line
    $switches = preg_split('/(-{1,2}[a-zA-Z]+) */', $commandline, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    // Taking advantage of the fact that $switches is indexed with incrementing numeric keys
    // We will be using that to pass additional information to those switches who need it
    $numswitches = count($switches);
    // Fancy way to give a "hyphen" boolean flag to each "switch"
    $switches = array_map(create_function('$x', 'return array("str" => $x, "hyphen" => (substr($x, 0, 1) == "-"));'), $switches);
    for ($i = 0; $i < $numswitches; ++$i) {
        $switch = $switches[$i]['str'];
        $params = $i == $numswitches - 1 ? NULL : ($switches[$i + 1]['hyphen'] ? NULL : trim($switches[$i + 1]['str']));
        if (substr($switch, 0, 2) == '--') {
            // Double-hyphen switch
            $DAEMON->cli_switch(strtolower(substr($switch, 2)), $params);
        } else {
            if (substr($switch, 0, 1) == '-') {
                // Single-hyphen switch(es), may be more than one run together
                $switch = substr($switch, 1);
                // Get rid of the -
                $len = strlen($switch);
                for ($j = 0; $j < $len; ++$j) {
                    $DAEMON->cli_switch(strtolower(substr($switch, $j, 1)), $params);
                }
            }
        }
    }
}
if (!$DAEMON->query_start()) {
    // For some reason we didn't start, so print out some info
コード例 #2
0
ファイル: chatd.php プロジェクト: gabrielrosset/moodle
        $daemon->fatal('Garbage in command line');
    }
} else {
    // Parse command line.
    $switches = preg_split('/(-{1,2}[a-zA-Z]+) */', $commandline, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    // Taking advantage of the fact that $switches is indexed with incrementing numeric keys.
    // We will be using that to pass additional information to those switches who need it.
    $numswitches = count($switches);
    // Fancy way to give a "hyphen" boolean flag to each "switch".
    $switches = array_map(create_function('$x', 'return array("str" => $x, "hyphen" => (substr($x, 0, 1) == "-"));'), $switches);
    for ($i = 0; $i < $numswitches; ++$i) {
        $switch = $switches[$i]['str'];
        $params = $i == $numswitches - 1 ? null : ($switches[$i + 1]['hyphen'] ? null : trim($switches[$i + 1]['str']));
        if (substr($switch, 0, 2) == '--') {
            // Double-hyphen switch.
            $daemon->cli_switch(strtolower(substr($switch, 2)), $params);
        } else {
            if (substr($switch, 0, 1) == '-') {
                // Single-hyphen switch(es), may be more than one run together.
                $switch = substr($switch, 1);
                // Get rid of the "-".
                $len = strlen($switch);
                for ($j = 0; $j < $len; ++$j) {
                    $daemon->cli_switch(strtolower(substr($switch, $j, 1)), $params);
                }
            }
        }
    }
}
if (!$daemon->query_start()) {
    // For some reason we didn't start, so print out some info.