aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/numconvert.c
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2021-10-11 19:05:27 -0800
committerDavid M. Syzdek <david@syzdek.net>2021-10-11 19:05:27 -0800
commit65f5bbfcafb63aebf63df2ff32f2be9275aaa0b2 (patch)
tree929e038ff70191be8f9eac47096fa0ab05034db8 /src/numconvert.c
parentbf4e7c9c0d77bbf45b654082db552b196f8fd7a1 (diff)
downloaddmstools-65f5bbfcafb63aebf63df2ff32f2be9275aaa0b2.tar.gz
dmstools-65f5bbfcafb63aebf63df2ff32f2be9275aaa0b2.tar.bz2
dmstools-65f5bbfcafb63aebf63df2ff32f2be9275aaa0b2.tar.xz
dmstools-65f5bbfcafb63aebf63df2ff32f2be9275aaa0b2.zip
numconvert: adding ability to suppress column names
Diffstat (limited to '')
-rw-r--r--src/numconvert.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/numconvert.c b/src/numconvert.c
index e7b3a8c..17db6f1 100644
--- a/src/numconvert.c
+++ b/src/numconvert.c
@@ -100,6 +100,7 @@
100#define MY_OPT_LIMIT 0x0080 ///< print hex and binary with least amount of digits 100#define MY_OPT_LIMIT 0x0080 ///< print hex and binary with least amount of digits
101#define MY_OPT_ASCII 0x0100 101#define MY_OPT_ASCII 0x0100
102#define MY_OPT_HEADER 0x0200 102#define MY_OPT_HEADER 0x0200
103#define MY_OPT_QUIET 0x0400
103 104
104#define MY_TOGGLE(value, bit) ( (value&bit) ? (value&(~bit)) : (value|bit)) 105#define MY_TOGGLE(value, bit) ( (value&bit) ? (value&(~bit)) : (value|bit))
105 106
@@ -147,7 +148,7 @@ int main(int argc, char * argv[])
147 const char * order; 148 const char * order;
148 149
149 // getopt options 150 // getopt options
150 static char short_opt[] = "AaBbDdf:hlOoRrsVXx"; 151 static char short_opt[] = "AaBbDdf:hlOoqRrsVXx";
151 static struct option long_opt[] = 152 static struct option long_opt[] =
152 { 153 {
153 {"help", no_argument, 0, 'h'}, 154 {"help", no_argument, 0, 'h'},
@@ -216,6 +217,10 @@ int main(int argc, char * argv[])
216 base = 8; 217 base = 8;
217 break; 218 break;
218 219
220 case 'q':
221 opt |= MY_OPT_QUIET;
222 break;
223
219 case 'R': 224 case 'R':
220 opt |= MY_OPT_LEBYTE; 225 opt |= MY_OPT_LEBYTE;
221 break; 226 break;
@@ -267,7 +272,8 @@ int main(int argc, char * argv[])
267 }; 272 };
268 273
269 if ( ((argc - optind) > 1) || (bases > 1) ) 274 if ( ((argc - optind) > 1) || (bases > 1) )
270 my_print(opt|MY_OPT_HEADER, 0, order); 275 if (!(opt & MY_OPT_QUIET))
276 my_print(opt|MY_OPT_HEADER, 0, order);
271 277
272 for(x = optind; x < argc; x++) 278 for(x = optind; x < argc; x++)
273 { 279 {
@@ -472,6 +478,7 @@ void my_usage()
472 printf(" -l print output assuming 64 bit numbers instead of 32 bit numbers\n"); 478 printf(" -l print output assuming 64 bit numbers instead of 32 bit numbers\n");
473 printf(" -O enable octal output\n"); 479 printf(" -O enable octal output\n");
474 printf(" -o assume octal notation for input\n"); 480 printf(" -o assume octal notation for input\n");
481 printf(" -q suppress column names\n");
475 printf(" -R display binary in little endian byte order\n"); 482 printf(" -R display binary in little endian byte order\n");
476 printf(" -r display binary in little endian bit nad byte order\n"); 483 printf(" -r display binary in little endian bit nad byte order\n");
477 printf(" -s display binary value in 8 bit blocks\n"); 484 printf(" -s display binary value in 8 bit blocks\n");