=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/hexdump/hexsyntax.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- src/usr.bin/hexdump/hexsyntax.c 2001/11/02 19:41:06 1.5 +++ src/usr.bin/hexdump/hexsyntax.c 2001/12/30 08:17:32 1.6 @@ -1,8 +1,9 @@ -/* $OpenBSD: hexsyntax.c,v 1.5 2001/11/02 19:41:06 mickey Exp $ */ +/* $OpenBSD: hexsyntax.c,v 1.6 2001/12/30 08:17:32 pvalchev Exp $ */ +/* $NetBSD: hexsyntax.c,v 1.8 1998/04/08 23:48:57 jeremy Exp $ */ /*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,15 +36,17 @@ #ifndef lint /*static char sccsid[] = "from: @(#)hexsyntax.c 5.2 (Berkeley) 5/8/90";*/ -static char rcsid[] = "$OpenBSD: hexsyntax.c,v 1.5 2001/11/02 19:41:06 mickey Exp $"; +static char rcsid[] = "$OpenBSD: hexsyntax.c,v 1.6 2001/12/30 08:17:32 pvalchev Exp $"; #endif /* not lint */ #include + +#include #include #include -#include +#include #include -#include + #include "hexdump.h" off_t skip; /* bytes to skip */ @@ -53,15 +56,11 @@ int argc; char ***argvp; { - extern enum _vflag vflag; - extern FS *fshead; - extern char *optarg; - extern int length, optind; int ch; char *p, **argv; argv = *argvp; - while ((ch = getopt(argc, argv, "bcde:f:n:os:vx")) != -1) + while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != -1) switch (ch) { case 'b': add("\"%07.7_Ax\n\""); @@ -71,6 +70,11 @@ add("\"%07.7_Ax\n\""); add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\""); break; + case 'C': + add("\"%08.8_Ax\n\""); + add("\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); + add("\" |\" 16/1 \"%_p\" \"|\\n\""); + break; case 'd': add("\"%07.7_Ax\n\""); add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\""); @@ -83,7 +87,7 @@ break; case 'n': if ((length = atoi(optarg)) < 0) - errx(1, "bad length value"); + errx(1, "%s: bad length value", optarg); break; case 'o': add("\"%07.7_Ax\n\""); @@ -91,7 +95,7 @@ break; case 's': if ((skip = strtol(optarg, &p, 0)) < 0) - errx(1, "bad skip value"); + errx(1, "%s: bad skip value", optarg); switch(*p) { case 'b': skip *= 512; @@ -113,7 +117,6 @@ break; case '?': usage(); - exit(1); } if (!fshead) { @@ -128,7 +131,7 @@ usage() { extern char *__progname; - fprintf(stderr, "usage: %s [-bcdovx] [-e fmt] [-f fmt_file] " - "[-n length] [-s skip] [file ...]", __progname); + fprintf(stderr, "usage: %s [-bcCdovx] [-e fmt] [-f fmt_file] " + "[-n length] [-s skip] [file ...]\n", __progname); exit(1); }