1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)hexsyntax.c 5.3 (Berkeley) 07/14/92"; 10 #endif /* not lint */ 11 12 #include <sys/types.h> 13 14 #include <stdio.h> 15 #include <stdlib.h> 16 #include <string.h> 17 #include "hexdump.h" 18 19 off_t skip; /* bytes to skip */ 20 21 void 22 newsyntax(argc, argvp) 23 int argc; 24 char ***argvp; 25 { 26 extern enum _vflag vflag; 27 extern FS *fshead; 28 extern int length; 29 int ch; 30 char *p, **argv; 31 32 argv = *argvp; 33 while ((ch = getopt(argc, argv, "bcde:f:n:os:vx")) != EOF) 34 switch (ch) { 35 case 'b': 36 add("\"%07.7_Ax\n\""); 37 add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\""); 38 break; 39 case 'c': 40 add("\"%07.7_Ax\n\""); 41 add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\""); 42 break; 43 case 'd': 44 add("\"%07.7_Ax\n\""); 45 add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\""); 46 break; 47 case 'e': 48 add(optarg); 49 break; 50 case 'f': 51 addfile(optarg); 52 break; 53 case 'n': 54 if ((length = atoi(optarg)) < 0) 55 err("%s: bad length value", optarg); 56 break; 57 case 'o': 58 add("\"%07.7_Ax\n\""); 59 add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\""); 60 break; 61 case 's': 62 if ((skip = strtol(optarg, &p, 0)) < 0) 63 err("%s: bad skip value", optarg); 64 switch(*p) { 65 case 'b': 66 skip *= 512; 67 break; 68 case 'k': 69 skip *= 1024; 70 break; 71 case 'm': 72 skip *= 1048576; 73 break; 74 } 75 break; 76 case 'v': 77 vflag = ALL; 78 break; 79 case 'x': 80 add("\"%07.7_Ax\n\""); 81 add("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\""); 82 break; 83 case '?': 84 usage(); 85 } 86 87 if (!fshead) { 88 add("\"%07.7_Ax\n\""); 89 add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\""); 90 } 91 92 *argvp += optind; 93 } 94 95 void 96 usage() 97 { 98 (void)fprintf(stderr, 99 "hexdump: [-bcdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n"); 100 exit(1); 101 } 102