138857Sbostic /* 238857Sbostic * Copyright (c) 1989 The Regents of the University of California. 338857Sbostic * All rights reserved. 438857Sbostic * 5*42734Sbostic * %sccs.include.redist.c% 638857Sbostic */ 738857Sbostic 838857Sbostic #ifndef lint 938857Sbostic char copyright[] = 1038857Sbostic "@(#) Copyright (c) 1989 The Regents of the University of California.\n\ 1138857Sbostic All rights reserved.\n"; 1238857Sbostic #endif /* not lint */ 1338857Sbostic 1438857Sbostic #ifndef lint 15*42734Sbostic static char sccsid[] = "@(#)hexdump.c 5.5 (Berkeley) 06/01/90"; 1638857Sbostic #endif /* not lint */ 1738857Sbostic 1838857Sbostic #include <sys/types.h> 1938857Sbostic #include <stdio.h> 2038857Sbostic #include "hexdump.h" 2138857Sbostic 2238857Sbostic FS *fshead; /* head of format strings */ 2338857Sbostic int blocksize; /* data block size */ 2438857Sbostic int exitval; /* final exit value */ 2541455Sbostic int length = -1; /* max bytes to read */ 2638857Sbostic 2738857Sbostic main(argc, argv) 2838857Sbostic int argc; 2938857Sbostic char **argv; 3038857Sbostic { 3141455Sbostic extern int errno; 3238857Sbostic register FS *tfs; 3338857Sbostic char *p, *rindex(); 3438857Sbostic 3541455Sbostic if (!(p = rindex(argv[0], 'o')) || strcmp(p, "od")) 3641455Sbostic newsyntax(argc, &argv); 3741455Sbostic else 3841455Sbostic oldsyntax(argc, &argv); 3938857Sbostic 4038857Sbostic /* figure out the data block size */ 4138857Sbostic for (blocksize = 0, tfs = fshead; tfs; tfs = tfs->nextfs) { 4238857Sbostic tfs->bcnt = size(tfs); 4338857Sbostic if (blocksize < tfs->bcnt) 4438857Sbostic blocksize = tfs->bcnt; 4538857Sbostic } 4638857Sbostic /* rewrite the rules, do syntax checking */ 4738857Sbostic for (tfs = fshead; tfs; tfs = tfs->nextfs) 4838857Sbostic rewrite(tfs); 4938857Sbostic 5038857Sbostic (void)next(argv); 5138857Sbostic display(); 5238857Sbostic exit(exitval); 5338857Sbostic } 54