# HG changeset patch # User Matti Hamalainen # Date 1411679802 -10800 # Node ID 39d9df17c8b17f34e627d64fffbd01c4d0cfeb64 # Parent 93a432519b84a943b2426cede381bf1e3596f11d Add field separator argument to -l option. diff -r 93a432519b84 -r 39d9df17c8b1 sidinfo.c --- a/sidinfo.c Fri Sep 26 00:16:26 2014 +0300 +++ b/sidinfo.c Fri Sep 26 00:16:42 2014 +0300 @@ -77,6 +77,7 @@ optNoNamePrefix = FALSE, optHexadecimal = FALSE, optOneLine = FALSE; +char * optFieldSep = NULL; uint32_t optFields = PSF_ALL; int optNFiles = 0; @@ -88,7 +89,7 @@ // { 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 }, - { 6, 'l', "oneline", "Output in one line format", OPT_NONE }, + { 6, 'l', "line", "Output in one line format, -l ", OPT_ARGREQ }, { 3, 'f', "fields", "Show only specified field(s)", OPT_ARGREQ }, { 4, 'x', "hex", "Use hexadecimal values", OPT_NONE }, }; @@ -219,6 +220,7 @@ case 6: optOneLine = TRUE; + optFieldSep = optArg; break; default: @@ -416,6 +418,12 @@ } +static void siPrintFieldSeparator(FILE *outFile) +{ + fprintf(outFile, optOneLine ? optFieldSep : "\n"); +} + + static void siPrintPSIDInfoLine(FILE *outFile, BOOL *shown, const int xindex, const char *xfmt, const char *xaltfmt, ...) { const PSFOption *opt = &optPSFlags[xindex]; @@ -435,7 +443,7 @@ va_end(ap); - fprintf(outFile, optOneLine ? "|" : "\n"); + siPrintFieldSeparator(outFile); *shown = TRUE; } } @@ -467,7 +475,7 @@ { siPrintFieldPrefix(outFile, "Hash"); th_md5_print(outFile, psid->hash); - fprintf(outFile, optOneLine ? "|" : "\n"); + siPrintFieldSeparator(outFile); } if (shown)