Reviewed-by: Steven Dake <[email protected]> On 05/11/2011 08:35 AM, Jan Friesse wrote: > --- > man/corosync-objctl.8 | 5 ++++- > tools/corosync-objctl.c | 37 +++++++++++++++++++++++++++++++++---- > 2 files changed, 37 insertions(+), 5 deletions(-) > > diff --git a/man/corosync-objctl.8 b/man/corosync-objctl.8 > index b83e172..2b3a7b6 100644 > --- a/man/corosync-objctl.8 > +++ b/man/corosync-objctl.8 > @@ -35,7 +35,7 @@ > .SH NAME > corosync-objctl \- Configure objects in the Object Database > .SH SYNOPSIS > -.B "corosync-objctl [\-c|\-w|\-d|\-a|\-t\-h] <OBJECT-SPEC>..." > +.B "corosync-objctl [\-b] [\-c|\-w|\-d|\-a|\-t\-h] <OBJECT-SPEC>..." > .SH DESCRIPTION > .B corosync-objctl > is used to configure objects within the object database at runtime. > @@ -74,6 +74,9 @@ they are printed out. this is kind of like a "tail -f" for > the object database. > .TP > .B -h > Print basic usage. > +.TP > +.B -b > +Display binary values in BASH backslash escape sequences format. > .SH EXAMPLES > .TP > Print the objOne object (shouldn't exist yet). > diff --git a/tools/corosync-objctl.c b/tools/corosync-objctl.c > index 3052ff0..d043865 100644 > --- a/tools/corosync-objctl.c > +++ b/tools/corosync-objctl.c > @@ -103,8 +103,29 @@ static confdb_callbacks_t callbacks = { > }; > > static int debug = 0; > +static int show_binary = 0; > static int action; > > +static void print_binary_key (char *value, size_t value_len) > +{ > + size_t i; > + char c; > + > + for (i = 0; i < value_len; i++) { > + c = value[i]; > + if (c >= ' ' && c < 0x7f && c != '\\') { > + fputc (c, stdout); > + } else { > + if (c == '\\') { > + printf ("\\\\"); > + } else { > + printf ("\\x%02X", c); > + } > + } > + } > + printf ("\n"); > +} > + > static void print_key (char *key_name, void *value, size_t value_len, > confdb_value_types_t type) > { > switch (type) { > @@ -145,7 +166,12 @@ static void print_key (char *key_name, void *value, > size_t value_len, confdb_val > break; > default: > case CONFDB_VALUETYPE_ANY: > - printf ("%s=**binary**(%d)\n", key_name, type); > + if (!show_binary) { > + printf ("%s=**binary**(%d)\n", key_name, type); > + } else { > + printf ("%s=", key_name); > + print_binary_key ((char *)value, value_len); > + } > break; > } > } > @@ -312,13 +338,13 @@ static int print_all(void) > static int print_help(void) > { > printf("\n"); > - printf ("usage: corosync-objctl object%ckey ... > Print an object\n", SEPERATOR); > + printf ("usage: corosync-objctl [-b] object%ckey ... > Print an object\n", SEPERATOR); > printf (" corosync-objctl -c object%cchild_obj ... > Create Object\n", SEPERATOR); > printf (" corosync-objctl -d object%cchild_obj ... > Delete object\n", SEPERATOR); > printf (" corosync-objctl -w object%cchild_obj.key=value ... > Create a key\n", SEPERATOR); > printf (" corosync-objctl -n object%cchild_obj.key=value ... > Create a new object with the key\n", SEPERATOR); > printf (" corosync-objctl -t object%cchild_obj ... > Track changes\n", SEPERATOR); > - printf (" corosync-objctl -a > Print all objects\n"); > + printf (" corosync-objctl [-b] -a > Print all objects\n"); > printf (" corosync-objctl -p <filename> Load in config from the > specified file.\n"); > printf("\n"); > return 0; > @@ -802,7 +828,7 @@ int main (int argc, char *argv[]) { > action = ACTION_READ; > > for (;;){ > - c = getopt (argc,argv,"hawncvdtp:"); > + c = getopt (argc,argv,"habwncvdtp:"); > if (c==-1) { > break; > } > @@ -816,6 +842,9 @@ int main (int argc, char *argv[]) { > case 'a': > action = ACTION_PRINT_ALL; > break; > + case 'b': > + show_binary++; > + break; > case 'p': > return read_in_config_file (optarg); > break;
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
