File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed
Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ MANSEC=1
3636MANDIR =/usr/share/man/man$(MANSEC )
3737DISTFILES =README vmsbackup.1 Makefile vmsbackup.c match.c NEWS build.com dclmain.c getoptmain.c vmsbackup.cld vmsbackup.h sysdep.h
3838
39- vmsbackup : vmsbackup.o match.o getoptmain.o
39+ vmsbackup : vmsbackup.o match.o getoptmain.o hexdump.o
4040
4141vmsbackup.o : vmsbackup.c
4242match.o : match.c
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <stdlib.h>
3+ #include <stdarg.h>
4+ #include <unistd.h>
5+ #include <ctype.h>
6+
7+ void
8+ hexdump (const unsigned char * ptr , int size , FILE * out )
9+ /*
10+ * hex dump 'size' bytes starting at 'ptr'
11+ */
12+ {
13+ const unsigned char * lptr = ptr ;
14+ int count = 0 ;
15+ long start = 0 ;
16+
17+ while (size -- > 0 )
18+ {
19+ if ((count % 16 ) == 0 )
20+ fprintf (out , "\t%08lx:" , start );
21+ fprintf (out , " %02x" , * ptr ++ );
22+ count ++ ;
23+ start ++ ;
24+ if (size == 0 )
25+ {
26+ while ((count % 16 ) != 0 )
27+ {
28+ fprintf (out , " " );
29+ count ++ ;
30+ }
31+ }
32+ if ((count % 16 ) == 0 )
33+ {
34+ fprintf (out , " " );
35+ while (lptr < ptr )
36+ {
37+ unsigned char c = * lptr & 0x7f ;
38+ c = ((c < 32 )|| (c == 0x7f ))?'.' :c ;
39+ fprintf (out , "%c" , c );
40+ lptr ++ ;
41+ }
42+ fprintf (out ,"\n" );
43+ }
44+ }
45+ if ((count % 16 ) != 0 )
46+ fprintf (out , "\n" );
47+
48+ fflush (out );
49+ return ;
50+ }
51+
Original file line number Diff line number Diff line change 1+ void hexdump (const unsigned char * ptr , int size , FILE * out );
You can’t perform that action at this time.
0 commit comments