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