changeset 7:36c43f085b28

Add NoPrefix option -n.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 25 Sep 2014 02:07:21 +0300
parents be3ccb7ca790
children cfc74ec918dc
files sidinfo.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sidinfo.c	Thu Sep 25 01:58:48 2014 +0300
+++ b/sidinfo.c	Thu Sep 25 02:07:21 2014 +0300
@@ -70,6 +70,7 @@
  */
 char *	optInFilename = NULL;
 BOOL	optParsable = FALSE,
+        optNoNamePrefix = FALSE,
         optHexadecimal = FALSE;
 uint32_t optFields = PSF_ALL;
 
@@ -81,6 +82,7 @@
     { 0, '?', "help",       "Show this help", OPT_NONE },
     { 1, 'v', "verbose",    "Be more verbose", OPT_NONE },
     { 2, 'p', "parsable",   "Output in script-parsable format", OPT_NONE },
+    { 5, 'n', "noprefix",   "Output without field name prefix", OPT_NONE },
     { 3, 'f', "fields",     "Show only specified field(s)", OPT_ARGREQ },
     { 4, 'x', "hex",        "Use hexadecimal values", OPT_NONE },
 };
@@ -205,6 +207,10 @@
         optHexadecimal = TRUE;
         break;
 
+    case 5:
+        optNoNamePrefix = TRUE;
+        break;
+
     default:
         THERR("Unknown option '%s'.\n", currArg);
         return FALSE;
@@ -407,10 +413,8 @@
 
 static void siPrintLinePrefix(FILE *outFile, const BOOL parsable, const char *name)
 {
-    if (parsable)
-        fprintf(outFile, "%s=", name);
-    else
-        fprintf(outFile, "%-20s : ", name);
+    if (!optNoNamePrefix)
+        fprintf(outFile, parsable ? "%s=" : "%-20s", name);
 }