diff --git a/src/ckdb.php b/src/ckdb.php index 9ae4b1a9..8fa2b97e 100644 --- a/src/ckdb.php +++ b/src/ckdb.php @@ -19,10 +19,12 @@ function getsock2($fun, $tmo) return _getsock($fun, "$socket_dir$socket_name/$socket_file", $tmo); } # -function msg($line, $tmo = false) +function msg($line, $tabs, $tmo = false) { global $fld_sep, $val_sep; + if ($tabs) + $line = str_replace("TAB", "\t", $line); $fun = 'stdin'; $ret = false; $socket = getsock2($fun, $tmo); @@ -40,7 +42,8 @@ function msg($line, $tmo = false) function usAge($a0) { global $socket_name_def, $socket_dir_def, $socket_file_def; - echo "usAge: php $a0 [name [dir [socket]]]\n"; + echo "usAge: php $a0 [-t] [name [dir [socket]]]\n"; + echo " -t = don't convert 'TAB' to a tab character\n"; echo " default name = $socket_name_def\n"; echo " default dir = $socket_dir_def\n"; echo " default socket = $socket_file_def\n"; @@ -48,18 +51,26 @@ function usAge($a0) exit(1); } # +$tabs = true; +# if (count($argv) > 1) { if ($argv[1] == '-?' || $argv[1] == '-h' || $argv[1] == '-help' || $argv[1] == '--help') usAge($argv[0]); - $socket_name = $argv[1]; - if (count($argv) > 2) + $a = 1; + if ($argv[$a] == '-t') + { + $tabs = false; + $a++; + } + $socket_name = $argv[$a++]; + if (count($argv) > $a) { - $socket_dir = $argv[2]; - if (count($argv) > 3) - $socket_file = $argv[3]; + $socket_dir = $argv[$a++]; + if (count($argv) > $a) + $socket_file = $argv[$a]; } } # @@ -68,7 +79,7 @@ while ($line = fgets(STDIN)) $line = trim($line); if (strlen($line) > 0) { - $rep = msg($line); + $rep = msg($line, $tabs); if ($rep === false) echo "Failed\n"; else