From 00cd830bd0f0654ed230a8fe3ac7684a205adfab Mon Sep 17 00:00:00 2001 From: gdr-ftp Date: Sat, 16 Jan 1999 18:35:57 +0000 Subject: [PATCH] Makefile: Changed to match the base builds. binprint.asm: Renamed to doline.asm. The default makefiles don't like to have name overloading like there was with binprint.c and binprint.asm doline.asm: - added a dummy segment - added the setcom directive binprint.c: - added stack checking code - prototyped functions - removed extraneous declarations - fflush stdout before writing to STDOUT_FILENO binprint.1, binprint.desc, binprint.rez: - initial checkin --- bin/binprint/Makefile | 14 +++-- bin/binprint/binprint.1 | 55 +++++++++++++++++ bin/binprint/binprint.asm | 123 ------------------------------------- bin/binprint/binprint.c | 43 +++++++------ bin/binprint/binprint.desc | 10 +++ bin/binprint/binprint.rez | 18 ++++++ bin/binprint/doline.asm | 10 ++- 7 files changed, 120 insertions(+), 153 deletions(-) create mode 100644 bin/binprint/binprint.1 delete mode 100644 bin/binprint/binprint.asm create mode 100644 bin/binprint/binprint.desc create mode 100644 bin/binprint/binprint.rez diff --git a/bin/binprint/Makefile b/bin/binprint/Makefile index 4884a1d..a5158cd 100644 --- a/bin/binprint/Makefile +++ b/bin/binprint/Makefile @@ -1,8 +1,10 @@ -binprint.a: binprint.c - compile -p binprint.c keep=binprint +# +# $Id: Makefile,v 1.2 1999/01/16 18:35:57 gdr-ftp Exp $ +# -bprasm.a: binprint.asm - compile -p binprint.asm +PROG = binprint +SRCS = binprint.c doline.asm +OPTIMIZE= -1 + +.INCLUDE : /src/gno/prog.mk -binprint: binprint.a bprasm.a - link -p binprint bprasm keep=binprint diff --git a/bin/binprint/binprint.1 b/bin/binprint/binprint.1 new file mode 100644 index 0000000..3c8ce4a --- /dev/null +++ b/bin/binprint/binprint.1 @@ -0,0 +1,55 @@ +.\" +.\" $Id: binprint.1,v 1.1 1999/01/16 18:35:57 gdr-ftp Exp $ +.\" +.TH BINPRINT 1 "15 January 1998" GNO "Commands and Applications" +.SH NAME +.BR binprint +\- print Appleworks GS formatted manual pages +.SH SYNOPSIS +.BR binprint +[ +.BI -c cols +] [ +.B -V +] +.RI [ filename "] ..." +.SH DESCRIPTION +.BR binprint +displays files in hex-dump format. +.LP +For each file, +.BR binprint +will print out the +.IR filename , +followed by one line of output for each 16 bytes of input data. +Each line consists of the file offset (in hexadecimal) of the first displayed +byte in the line, a colon, up to 16 bytes of data in hexadecimal format, +followed by the same 16 bytes shown in ASCII format: +.in 0in +.nf + +binprint.c + 0: 2F 2A 20 0D 20 20 20 20 42 49 4E 50 52 49 4E 54 /* . BINPRINT + 10: 2E 43 0D 0D 20 20 20 20 44 69 73 70 6C 61 79 73 .C.. Displays + 20: 20 66 69 6C 65 73 20 69 6E 20 68 65 78 2D 64 75 files in hex-du + +.fi +.LP +Where there is no printable ASCII equivalent of a given byte, a period is +printed in its place. +.LP +If no +.IR filename s +are given, +.BR binprint +reads from stdin. +.SH OPTIONS +.IP "\fB-c\fR \fIcols\fR" +Specify the number of columns (one byte per column) to display per line. +The default as shown in the example above is 16. +Values less than 8 are silently ignored (the default is used). +.IP \fB-V\fR +Print version number and exit. +.SH HISTORY +.BR binprint +appeared in GNO v2.0.1. diff --git a/bin/binprint/binprint.asm b/bin/binprint/binprint.asm deleted file mode 100644 index 0f48c44..0000000 --- a/bin/binprint/binprint.asm +++ /dev/null @@ -1,123 +0,0 @@ - case on - - keep bprasm - -doline start - pha - tsc - phd - tcd - phb - phk - plb - -counter equ 1 -RTLs equ 3 -dest equ 6 -source equ 10 -cols equ 14 -actual equ 16 -PREVIOUS equ 18 - - pei actual - stz counter - ldy #0 -loop anop - lda [source],y - jsr puthex - iny - dec cols - dec actual - bne loop - ldy counter -loop2 lda cols - beq done - lda #$2020 - sta [dest],y - iny - sta [dest],y - iny - iny - dec cols - bra loop2 - -done anop - pla - sta actual - tya - clc - inc a - adc actual - sta counter - ldy actual -chrloop dey - cpy #$ffff - beq endloop - lda [source],y - and #$ff - cmp #$7f - bcs noprint - cmp #$20 - bcs printable -noprint lda #'.' -printable sep #$20 - sta [source],y - rep #$20 - bra chrloop -endloop ldy actual - dey - lda [source],y - and #$00ff - ora #$0d00 - sta [source],y - - ldy counter - plb - lda 4 - sta PREVIOUS-2 - lda 3 - sta PREVIOUS-3 - pld - tsc - clc - adc #PREVIOUS-4 - tcs - tya - rtl - end - -puthex private -counter equ 1 -RTLs equ 3 -dest equ 6 -source equ 10 -cols equ 14 - phy - ldy counter - pha - lsr a - lsr a - lsr a - lsr a - and #$f - tax - lda hexdigits,x - sta [ #include #include #include #include +#include /* for stack checking routines */ -extern FILE *fdopen(int,char *); - -unsigned int doline(char *dest, char *source, - unsigned int actual, unsigned int cols); +unsigned int doline(char *dest, char *source, unsigned int actual, + unsigned int cols); +static void printGood(long off, unsigned char *buf, int real, int form); unsigned char *buffer2; -main(argc,argv) - int argc; - char **argv; +int +main(int argc, char **argv) { int duh; int a; - int c,errflg = 0,columns = 16; + int c, errflg = 0, columns = 16; size_t pos = 0; unsigned char *buffer; - extern char *optarg; - extern int optind; - extern int getopt(int,char **,char*); + __REPORT_STACK(); while ((c = getopt(argc,argv, "Vc:")) != EOF) switch (c) { case 'c' : columns = atoi(optarg); break; case 'V' : - fprintf(stdout, "binprint v1.2 for GNO/ME\n"); + fprintf(stdout, "binprint v%s for GNO/ME\n", VERSION); exit(0); - default : errflg++; + default : + errflg++; } if (errflg) { fprintf(stderr,"usage: binprint [-c] files...\n"); @@ -69,6 +69,7 @@ main(argc,argv) exit(1); } printf("\n%s\n",*argv); + fflush(stdout); /* we write to STDOUT_FILENO directly */ action: while ((a = (int)read(duh, buffer, (size_t)(columns * sizeof(unsigned char)))) != 0) { @@ -82,15 +83,13 @@ main(argc,argv) exit(0); } -printGood(off,buf,real,form) - long off; - unsigned char *buf; - int real; - int form; +static void +printGood(long off, unsigned char *buf, int real, int form) { if (!real) return; #if 0 printf("%8lX: ",off); + fflush(stdout); #endif /* The following is a hack required because of buffering by the stdio diff --git a/bin/binprint/binprint.desc b/bin/binprint/binprint.desc new file mode 100644 index 0000000..ddd865d --- /dev/null +++ b/bin/binprint/binprint.desc @@ -0,0 +1,10 @@ +Name: binprint +Version: 1.3 +Shell: GNO, ORCA +Author: Derek Taubert. +Contact: taubert@geeks.org +Where: /bin +FTP: ftp.gno.org + +binprint displays files in hex-dump format. It also provides an ASCII +subdisplay if it is so desired. diff --git a/bin/binprint/binprint.rez b/bin/binprint/binprint.rez new file mode 100644 index 0000000..deb7978 --- /dev/null +++ b/bin/binprint/binprint.rez @@ -0,0 +1,18 @@ +/* + * $Id: binprint.rez,v 1.1 1999/01/16 18:35:57 gdr-ftp Exp $ + */ + +#include "Types.Rez" +#include "builddate.rez" + +resource rVersion (0x1, purgeable3, nocrossbank) { + + { 1, 3, 0, /* version */ + release, /* development|alpha|beta|final|release */ + 0 /* non-final release number */ + }, + verUS, + "binprint", + "Displays data in hex-dump format.\n" + BUILD_DATE +}; diff --git a/bin/binprint/doline.asm b/bin/binprint/doline.asm index 0f48c44..e05c074 100644 --- a/bin/binprint/doline.asm +++ b/bin/binprint/doline.asm @@ -1,6 +1,12 @@ - case on +* +* $Id: doline.asm,v 1.2 1999/01/16 18:35:57 gdr-ftp Exp $ +* +dummy start ; ends up in .root + end - keep bprasm + setcom 60 + + case on doline start pha