version 1.5, 2001/11/02 19:41:06 |
version 1.6, 2001/12/30 08:17:32 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
|
/* $NetBSD: hexsyntax.c,v 1.8 1998/04/08 23:48:57 jeremy Exp $ */ |
|
|
/*- |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* Copyright (c) 1990, 1993 |
* All rights reserved. |
* The Regents of the University of California. All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
|
|
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
#include <err.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <limits.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <err.h> |
|
#include "hexdump.h" |
#include "hexdump.h" |
|
|
off_t skip; /* bytes to skip */ |
off_t skip; /* bytes to skip */ |
|
|
int argc; |
int argc; |
char ***argvp; |
char ***argvp; |
{ |
{ |
extern enum _vflag vflag; |
|
extern FS *fshead; |
|
extern char *optarg; |
|
extern int length, optind; |
|
int ch; |
int ch; |
char *p, **argv; |
char *p, **argv; |
|
|
argv = *argvp; |
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) { |
switch (ch) { |
case 'b': |
case 'b': |
add("\"%07.7_Ax\n\""); |
add("\"%07.7_Ax\n\""); |
|
|
add("\"%07.7_Ax\n\""); |
add("\"%07.7_Ax\n\""); |
add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\""); |
add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\""); |
break; |
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': |
case 'd': |
add("\"%07.7_Ax\n\""); |
add("\"%07.7_Ax\n\""); |
add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\""); |
add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\""); |
|
|
break; |
break; |
case 'n': |
case 'n': |
if ((length = atoi(optarg)) < 0) |
if ((length = atoi(optarg)) < 0) |
errx(1, "bad length value"); |
errx(1, "%s: bad length value", optarg); |
break; |
break; |
case 'o': |
case 'o': |
add("\"%07.7_Ax\n\""); |
add("\"%07.7_Ax\n\""); |
|
|
break; |
break; |
case 's': |
case 's': |
if ((skip = strtol(optarg, &p, 0)) < 0) |
if ((skip = strtol(optarg, &p, 0)) < 0) |
errx(1, "bad skip value"); |
errx(1, "%s: bad skip value", optarg); |
switch(*p) { |
switch(*p) { |
case 'b': |
case 'b': |
skip *= 512; |
skip *= 512; |
|
|
break; |
break; |
case '?': |
case '?': |
usage(); |
usage(); |
exit(1); |
|
} |
} |
|
|
if (!fshead) { |
if (!fshead) { |
|
|
usage() |
usage() |
{ |
{ |
extern char *__progname; |
extern char *__progname; |
fprintf(stderr, "usage: %s [-bcdovx] [-e fmt] [-f fmt_file] " |
fprintf(stderr, "usage: %s [-bcCdovx] [-e fmt] [-f fmt_file] " |
"[-n length] [-s skip] [file ...]", __progname); |
"[-n length] [-s skip] [file ...]\n", __progname); |
exit(1); |
exit(1); |
} |
} |