mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-05-31 15:41:31 +00:00
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
This commit is contained in:
parent
fc1083b2b0
commit
00cd830bd0
|
@ -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
|
PROG = binprint
|
||||||
compile -p binprint.asm
|
SRCS = binprint.c doline.asm
|
||||||
|
OPTIMIZE= -1
|
||||||
|
|
||||||
|
.INCLUDE : /src/gno/prog.mk
|
||||||
|
|
||||||
binprint: binprint.a bprasm.a
|
|
||||||
link -p binprint bprasm keep=binprint
|
|
||||||
|
|
55
bin/binprint/binprint.1
Normal file
55
bin/binprint/binprint.1
Normal file
|
@ -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.
|
|
@ -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 [<dest],y
|
|
||||||
iny
|
|
||||||
pla
|
|
||||||
and #$f
|
|
||||||
tax
|
|
||||||
lda hexdigits,x
|
|
||||||
and #$00ff
|
|
||||||
ora #$2000
|
|
||||||
sta [<dest],y
|
|
||||||
iny
|
|
||||||
iny
|
|
||||||
sty counter
|
|
||||||
ply
|
|
||||||
rts
|
|
||||||
end
|
|
||||||
|
|
||||||
hexdigits privdata
|
|
||||||
dc c'0123456789ABCDEF'
|
|
||||||
end
|
|
|
@ -3,50 +3,50 @@
|
||||||
|
|
||||||
Displays files in hex-dump format (with ascii subdisplay if desired)
|
Displays files in hex-dump format (with ascii subdisplay if desired)
|
||||||
|
|
||||||
v1.2 Optimized and fixed input from terminal bug (pv)
|
v1.3 Incorporated sources into GNO base build. Reformatted sources,
|
||||||
v1.1 Added stacksize directive (jb)
|
prototyped functions, added calls to fflush(3). (Devin Reade)
|
||||||
|
v1.2 Optimized and fixed input from terminal bug (Phil Vandry)
|
||||||
|
v1.1 Added stacksize directive (Jawaid Bazyar)
|
||||||
v1.0 Original version by Derek Taubert
|
v1.0 Original version by Derek Taubert
|
||||||
|
|
||||||
|
$Id: binprint.c,v 1.3 1999/01/16 18:35:57 gdr-ftp Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma optimize -1
|
#define VERSION "1.3"
|
||||||
#pragma stacksize 1024
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <gno/gno.h> /* 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,
|
static void printGood(long off, unsigned char *buf, int real, int form);
|
||||||
unsigned int actual, unsigned int cols);
|
|
||||||
|
|
||||||
unsigned char *buffer2;
|
unsigned char *buffer2;
|
||||||
|
|
||||||
main(argc,argv)
|
int
|
||||||
int argc;
|
main(int argc, char **argv)
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int duh;
|
int duh;
|
||||||
int a;
|
int a;
|
||||||
int c,errflg = 0,columns = 16;
|
int c, errflg = 0, columns = 16;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
extern char *optarg;
|
|
||||||
extern int optind;
|
|
||||||
extern int getopt(int,char **,char*);
|
|
||||||
|
|
||||||
|
__REPORT_STACK();
|
||||||
while ((c = getopt(argc,argv, "Vc:")) != EOF)
|
while ((c = getopt(argc,argv, "Vc:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c' :
|
case 'c' :
|
||||||
columns = atoi(optarg);
|
columns = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'V' :
|
case 'V' :
|
||||||
fprintf(stdout, "binprint v1.2 for GNO/ME\n");
|
fprintf(stdout, "binprint v%s for GNO/ME\n", VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
default : errflg++;
|
default :
|
||||||
|
errflg++;
|
||||||
}
|
}
|
||||||
if (errflg) {
|
if (errflg) {
|
||||||
fprintf(stderr,"usage: binprint [-c<columns>] files...\n");
|
fprintf(stderr,"usage: binprint [-c<columns>] files...\n");
|
||||||
|
@ -69,6 +69,7 @@ main(argc,argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("\n%s\n",*argv);
|
printf("\n%s\n",*argv);
|
||||||
|
fflush(stdout); /* we write to STDOUT_FILENO directly */
|
||||||
action:
|
action:
|
||||||
while ((a = (int)read(duh, buffer,
|
while ((a = (int)read(duh, buffer,
|
||||||
(size_t)(columns * sizeof(unsigned char)))) != 0) {
|
(size_t)(columns * sizeof(unsigned char)))) != 0) {
|
||||||
|
@ -82,15 +83,13 @@ main(argc,argv)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
printGood(off,buf,real,form)
|
static void
|
||||||
long off;
|
printGood(long off, unsigned char *buf, int real, int form)
|
||||||
unsigned char *buf;
|
|
||||||
int real;
|
|
||||||
int form;
|
|
||||||
{
|
{
|
||||||
if (!real) return;
|
if (!real) return;
|
||||||
#if 0
|
#if 0
|
||||||
printf("%8lX: ",off);
|
printf("%8lX: ",off);
|
||||||
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The following is a hack required because of buffering by the stdio
|
/* The following is a hack required because of buffering by the stdio
|
||||||
|
|
10
bin/binprint/binprint.desc
Normal file
10
bin/binprint/binprint.desc
Normal file
|
@ -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.
|
18
bin/binprint/binprint.rez
Normal file
18
bin/binprint/binprint.rez
Normal file
|
@ -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
|
||||||
|
};
|
|
@ -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
|
doline start
|
||||||
pha
|
pha
|
||||||
|
|
Loading…
Reference in New Issue
Block a user