diff --git a/html/lib/sysVcom.php b/html/lib/sysVcom.php
index 125e603..7949ea0 100644
--- a/html/lib/sysVcom.php
+++ b/html/lib/sysVcom.php
@@ -80,6 +80,10 @@
return unserialize( IPC( serialize( $params ) ) );
}
+function rpc_with_array( $params ){
+ return unserialize( IPC( serialize( $params ) ) );
+}
+
/**
* Returns the next message waiting on the queue if there is one. The value of $caller_id must be checked
* to ascertain the validity of the return value.
diff --git a/html/shd/common.php b/html/shd/common.php
index 7056bea..a120610 100644
--- a/html/shd/common.php
+++ b/html/shd/common.php
@@ -21,28 +21,58 @@
/**
* Format a 2D array into a 1D array of strings suitable for output in a
* readable style.
+ *
+ * $fxd_widths
+ * An array of widths to set which overrides the calculated width values
+ *
*/
-function format_array_2d( $arr ){
+function format_array_2d( $arr, $fxd_widths=array() ){
- //get the maximum field widths for all rows
- $arr_col_mxw = array();
- foreach($arr as $row){
+ $arr_col_mxw = null;
+ $tot_field_cnt = count($arr[0]);
+
+ if(count($fxd_widths)>=$tot_field_cnt ){
+ $arr_col_mxw = $fxd_widths;
+
+ }else{
+ $st_col = count($fxd_widths);
+ $arr_col_mxw = array();
$i=0;
- foreach($row as $field){
- if( strlen($field)>$arr_col_mxw[$i]){
- $arr_col_mxw[$i] = strlen($field);
+
+ for($i=0; $i<$tot_field_cnt; $i++){
+ if($i<$st_col){
+ array_push( $arr_col_mxw, $fxd_widths[$i]);
+ }else{
+ array_push( $arr_col_mxw, 0 );
}
- $i++;
}
+
+ //get the remaining field maximum widths for all rows
+ foreach($arr as $row){
+ for($i=$st_col; $i$arr_col_mxw[$i]){
+ $arr_col_mxw[$i] = strlen($field);
+ }
+ }
+ }
+
}
+ //print_r($arr_col_mxw);
+
$arr_rtn = array();
foreach($arr as $row){
$str_row = '|';
- $i=0;
+ $i=-1;
foreach($row as $field){
- $str_row .= str_pad($field, $arr_col_mxw[$i]) ." | ";
$i++;
+ if($arr_col_mxw[$i]==0) continue;
+ if( strlen($field) > $arr_col_mxw[$i]){
+ $str_row .= substr($field, 0, $arr_col_mxw[$i] ) ."| ";
+ }else{
+ $str_row .= str_pad($field, $arr_col_mxw[$i]) ."| ";
+ }
}
array_push($arr_rtn, $str_row);
}
diff --git a/html/svc/main-svc.php b/html/svc/main-svc.php
index 7c48561..ad66b61 100644
--- a/html/svc/main-svc.php
+++ b/html/svc/main-svc.php
@@ -4,8 +4,15 @@
rpc_setGlobals( 'procName', __DIR__.'/BU-commander' );
rpc_setGlobals( 'max_chan', 8182 );
+/**
+ * Expecting either an array or a single string.
+ */
function run_main_command( $cmd ){
- return rpc( $cmd );
+ if(is_array($cmd)){
+ return rpc_with_array( $cmd );
+ }else{
+ return rpc_with_array( array($cmd) );
+ }
}
?>
diff --git a/html/svc/main.php b/html/svc/main.php
index b39bd39..6412741 100644
--- a/html/svc/main.php
+++ b/html/svc/main.php
@@ -63,7 +63,9 @@
exit(0);
}
- $rtn = run_main_command( $argv[1] );
+ $arg_copy = $argv;
+ array_shift($arg_copy);
+ $rtn = run_main_command( $arg_copy );
print_r( $rtn );
exit(0);
@@ -513,7 +515,8 @@
return array('ok:reload');
case 'f:cache-show':
- foreach( format_cache() as $line){
+ array_shift($obj);
+ foreach( format_cache($obj) as $line){
log_print( "$line\n" );
}
return array('ok:cache-show');
diff --git a/html/svc/table-cache.php b/html/svc/table-cache.php
index 8ad655c..677a1d1 100644
--- a/html/svc/table-cache.php
+++ b/html/svc/table-cache.php
@@ -10,8 +10,12 @@
/**
* Output the cache in a readable format. Rather than being a 2D array, it
* is a 1D array, each entry corresponding to a single row.
+ *
+ * $width_limits
+ * This array contains the size limits of each field in field order. The array may be smaller than the
+ * total number of fields in which case the remaining fields will expand as necessary.
*/
-function format_cache(){
+function format_cache( $width_limits=array() ){
global $g_bu_table;
global $g_bu_colIdxs;
@@ -28,7 +32,7 @@
$arr_all = $g_bu_table;
array_unshift( $arr_all, $arr_header);
- return format_array_2d( $arr_all );
+ return format_array_2d( $arr_all, $width_limits );
}
/**