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NF/lAȽ nM 4 &#:MӫZIJ[_CT;GW-h UNF/lA.CX3XaY/U2xda݇RriN mfHmC Ʒ'Tm*v:wy|T'Hc (ٳڤC~)@xd=/tߏ,u(gh_W)M.6/N(,mδ8\ i+֏>;|hQ( w&(B'Uc*r!~"_;mB.C"i jDO_ ڻe 땞C% ^نIXFP #֎XkIYp(8:E4~ö1_?8΅:h+x;Sxݮh#jC!pPU^.D9yBa"[g3<6%{vt*^[ </(ҕEp̖Sp`S쟤Lo+8 G-a*n !/+09YKQau ݠA2T4%c0YAO8batǰe\#2K]z{ǁJIN7jӶ_$ 1컃?B %?6s5k$8a|TևÝ50ڶSr4YF&dsxDİ1>/+(0ldoh'Rߛ뜙7L_'I,!By$혲6qCƥg eʵbh]$kC)8?r;X y9mpͩ%{oXhLE@nCƥg eʵ* G ӈv"s=X|eq <3ct*d-p"L@/%mZ^X}%&G*x::Q釛Egb\RUw 诸BWEu~hw/}l@A\de`7ggRŰ]܆3úS}pt($version, $args, $short_options, $long_options = null, $skip_unknown = false) { // in case you pass directly readPHPArgv() as the first arg if (PEAR::isError($args)) { return $args; } if (empty($args)) { return array(array(), array()); } $non_opts = $opts = array(); settype($args, 'array'); if ($long_options) { sort($long_options); } /* * Preserve backwards compatibility with callers that relied on * erroneous POSIX fix. */ if ($version < 2) { if (isset($args[0][0]) && $args[0][0] != '-') { array_shift($args); } } for ($i = 0; $i < count($args); $i++) { $arg = $args[$i]; /* The special element '--' means explicit end of options. Treat the rest of the arguments as non-options and end the loop. */ if ($arg == '--') { $non_opts = array_merge($non_opts, array_slice($args, $i + 1)); break; } if ($arg[0] != '-' || (strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) { $non_opts = array_merge($non_opts, array_slice($args, $i)); break; } elseif (strlen($arg) > 1 && $arg[1] == '-') { $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $i, $args, $skip_unknown); if (PEAR::isError($error)) { return $error; } } elseif ($arg == '-') { // - is stdin $non_opts = array_merge($non_opts, array_slice($args, $i)); break; } else { $error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $i, $args, $skip_unknown); if (PEAR::isError($error)) { return $error; } } } return array($opts, $non_opts); } /** * Parse short option * * @param string $arg Argument * @param string[] $short_options Available short options * @param string[][] &$opts * @param int &$argIdx * @param string[] $args * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option * * @return void */ protected static function _parseShortOption($arg, $short_options, &$opts, &$argIdx, $args, $skip_unknown) { for ($i = 0; $i < strlen($arg); $i++) { $opt = $arg[$i]; $opt_arg = null; /* Try to find the short option in the specifier string. */ if (($spec = strstr($short_options, $opt)) === false || $arg[$i] == ':') { if ($skip_unknown === true) { break; } $msg = "Console_Getopt: unrecognized option -- $opt"; return PEAR::raiseError($msg); } if (strlen($spec) > 1 && $spec[1] == ':') { if (strlen($spec) > 2 && $spec[2] == ':') { if ($i + 1 < strlen($arg)) { /* Option takes an optional argument. Use the remainder of the arg string if there is anything left. */ $opts[] = array($opt, substr($arg, $i + 1)); break; } } else { /* Option requires an argument. Use the remainder of the arg string if there is anything left. */ if ($i + 1 < strlen($arg)) { $opts[] = array($opt, substr($arg, $i + 1)); break; } else if (isset($args[++$argIdx])) { $opt_arg = $args[$argIdx]; /* Else use the next argument. */; if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) { $msg = "option requires an argument --$opt"; return PEAR::raiseError("Console_Getopt: " . $msg); } } else { $msg = "option requires an argument --$opt"; return PEAR::raiseError("Console_Getopt: " . $msg); } } } $opts[] = array($opt, $opt_arg); } } /** * Checks if an argument is a short option * * @param string $arg Argument to check * * @return bool */ protected static function _isShortOpt($arg) { return strlen($arg) == 2 && $arg[0] == '-' && preg_match('/[a-zA-Z]/', $arg[1]); } /** * Checks if an argument is a long option * * @param string $arg Argument to check * * @return bool */ protected static function _isLongOpt($arg) { return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' && preg_match('/[a-zA-Z]+$/', substr($arg, 2)); } /** * Parse long option * * @param string $arg Argument * @param string[] $long_options Available long options * @param string[][] &$opts * @param int &$argIdx * @param string[] $args * * @return void|PEAR_Error */ protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx, $args, $skip_unknown) { @list($opt, $opt_arg) = explode('=', $arg, 2); $opt_len = strlen($opt); for ($i = 0; $i < count($long_options); $i++) { $long_opt = $long_options[$i]; $opt_start = substr($long_opt, 0, $opt_len); $long_opt_name = str_replace('=', '', $long_opt); /* Option doesn't match. Go on to the next one. */ if ($long_opt_name != $opt) { continue; } $opt_rest = substr($long_opt, $opt_len); /* Check that the options uniquely matches one of the allowed options. */ if ($i + 1 < count($long_options)) { $next_option_rest = substr($long_options[$i + 1], $opt_len); } else { $next_option_rest = ''; } if ($opt_rest != '' && $opt[0] != '=' && $i + 1 < count($long_options) && $opt == substr($long_options[$i+1], 0, $opt_len) && $next_option_rest != '' && $next_option_rest[0] != '=') { $msg = "Console_Getopt: option --$opt is ambiguous"; return PEAR::raiseError($msg); } if (substr($long_opt, -1) == '=') { if (substr($long_opt, -2) != '==') { /* Long option requires an argument. Take the next argument if one wasn't specified. */; if (!strlen($opt_arg)) { if (!isset($args[++$argIdx])) { $msg = "Console_Getopt: option requires an argument --$opt"; return PEAR::raiseError($msg); } $opt_arg = $args[$argIdx]; } if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) { $msg = "Console_Getopt: option requires an argument --$opt"; return PEAR::raiseError($msg); } } } else if ($opt_arg) { $msg = "Console_Getopt: option --$opt doesn't allow an argument"; return PEAR::raiseError($msg); } $opts[] = array('--' . $opt, $opt_arg); return; } if ($skip_unknown === true) { return; } return PEAR::raiseError("Console_Getopt: unrecognized option --$opt"); } /** * Safely read the $argv PHP array across different PHP configurations. * Will take care on register_globals and register_argc_argv ini directives * * @return mixed the $argv PHP array or PEAR error if not registered */ public static function readPHPArgv() { global $argv; if (!is_array($argv)) { if (!@is_array($_SERVER['argv'])) { if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) { $msg = "Could not read cmd args (register_argc_argv=Off?)"; return PEAR::raiseError("Console_Getopt: " . $msg); } return $GLOBALS['HTTP_SERVER_VARS']['argv']; } return $_SERVER['argv']; } return $argv; } }