Mercurial > hg > sidinfo
changeset 33:39d9df17c8b1
Add field separator argument to -l option.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 26 Sep 2014 00:16:42 +0300 |
parents | 93a432519b84 |
children | 50fe65830c03 |
files | sidinfo.c |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <field separator>", 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)