diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-07-22 23:35:31 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:47 +0200 |
commit | 673f690a37f6673a3262e933709c79de8a66f48c (patch) | |
tree | 3acd007863bf23ce8549f9edb5e51d23a3bc6078 /tests | |
parent | 352e3b3230dfc6746be6d53325ffe1e33efc5289 (diff) | |
download | dev86-673f690a37f6673a3262e933709c79de8a66f48c.tar.gz |
Import Dev86src-0.16.4.tar.gzv0.16.4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 4 | ||||
-rwxr-xr-x | tests/a.out | bin | 0 -> 8783 bytes | |||
-rw-r--r-- | tests/ft.c | 6 | ||||
-rw-r--r-- | tests/hd.c | 40 | ||||
-rw-r--r-- | tests/size.c | 83 |
5 files changed, 41 insertions, 92 deletions
diff --git a/tests/Makefile b/tests/Makefile index f2dc16b..015f65e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,10 +6,10 @@ BCC=bcc CC=$(BCC) CFLAGS=-O -SRC=env.c ft.c hd.c size.c sync.c compr.c ucomp.c ouch.c lines.c \ +SRC=env.c ft.c hd.c sync.c compr.c ucomp.c ouch.c lines.c \ wc.c line2.c rand.c grab.c OBJ= -EXE=env ft hd size sync compr ucomp ouch lines wc line2 rand grab +EXE=env ft hd sync compr ucomp ouch lines wc line2 rand grab LINK_FILES=cat chgrp chmod chown cp install ln mkdir mkfifo mknod mv rm diff --git a/tests/a.out b/tests/a.out Binary files differnew file mode 100755 index 0000000..14156c6 --- /dev/null +++ b/tests/a.out @@ -42,7 +42,7 @@ #define PR(x) () #endif -void main PR((int argc, char ** argv)); +int main PR((int argc, char ** argv)); int select_command PR((char * argv)); void do_prep PR((void)); void do_post PR((void)); @@ -156,7 +156,7 @@ struct stat access_stat; int done_something = 0; -void +int main(argc, argv) int argc; char ** argv; { @@ -261,7 +261,7 @@ int argc; char ** argv; else Usage(); } - exit(0); + return 0; } int select_command(argv) @@ -1,7 +1,27 @@ +/* + * This is a Xenix style hex dump command. + * + * The 'reverse hex dump' option is an addition that allows a simple + * method of editing binary files. + * + * The overkill Linux 'hexdump' command can be configured to generate + * the same format as this command by this shell macro: + * + * hd() { hexdump -e '"%06.6_ax:" 8/1 " %02x" " " 8/1 " %02x" " " ' \ + * -e '16/1 "%_p" "\n"' \ + * "$@" + * } + * + */ #include <stdio.h> #include <ctype.h> #include <errno.h> +#ifndef MSDOS +#ifndef __BCC__ +#include <locale.h> +#endif +#endif int lastnum[16] = {-1}; long lastaddr = -1; @@ -9,7 +29,7 @@ long offset = 0; FILE *fd; -FILE * ofd = stdout; +FILE * ofd; char * outfile = 0; int reverse = 0; @@ -21,6 +41,14 @@ char **argv; int ar; int aflag = 1; +#ifndef MSDOS +#ifndef __BCC__ + setlocale(LC_CTYPE, ""); +#endif +#endif + + ofd = stdout; + for (ar = 1; ar < argc; ar++) if (aflag && argv[ar][0] == '-') switch (argv[ar][1]) @@ -119,7 +147,7 @@ do_fd() break; num[j] = ch; - if (isascii(ch) && isprint(ch)) + if (isprint(ch)) buf[j] = ch; else buf[j] = '.'; @@ -195,8 +223,12 @@ do_rev_fd() ptr = str; if( *ptr == '*' ) zap_last = 0; - if( !isxdigit(*ptr) ) continue; - addr = strtol(ptr, &ptr, 16); + if( *ptr != ':' ) { + if( !isxdigit(*ptr) ) continue; + addr = strtol(ptr, &ptr, 16); + } + else + addr = nxtaddr; if( *ptr == ':' ) ptr++; if (nxtaddr == 0) diff --git a/tests/size.c b/tests/size.c deleted file mode 100644 index 6b08f46..0000000 --- a/tests/size.c +++ /dev/null @@ -1,83 +0,0 @@ -#include <fcntl.h> -#include <a.out.h> - -int verbose = 0; - -void size(filename) - char *filename; -{ - int f; - struct exec ex; - long total; - int cc; - - if ((f = open(filename, O_RDONLY)) < 0 ) - { - perror(filename); - return; - } - cc = read(f, &ex, sizeof(ex)); - - if (cc == sizeof(ex) && !BADMAG(ex)) - { - total = ex.a_text + ex.a_data + ex.a_bss; - if( verbose ) - { - printf("Text segment of %s = %5ld (0x%lx)\n", - filename, ex.a_text, ex.a_text); - printf("Init data of %s = %5ld (0x%lx)\n", - filename, ex.a_data, ex.a_data); - printf("Uninit data of %s = %5ld (0x%lx)\n", - filename, ex.a_bss, ex.a_bss); - printf("Data segment of %s = %5ld (0x%lx)\n", - filename, ex.a_total, ex.a_total); - printf("Minimum size of %s = %5ld (0x%lx)\n", - filename, total, total); - - total = ex.a_total; - if( ex.a_flags & A_SEP ) - total += ex.a_text; - printf("Maximum size of %s = %5ld (0x%lx)\n", - filename, total, total); - } - else - printf("%-ld\t%-ld\t%-ld\t%-ld\t%-lx\t%s\n", - ex.a_text, ex.a_data, ex.a_bss, total, total, - filename); - } - else if( cc > 16 && memcmp(&ex, "\243\206\001\000*", 5) == 0 ) - { /* *.o file */ - total = ((unsigned char*)&ex)[9] + - ((unsigned char*)&ex)[10] * 256; - if( verbose ) - printf("Size of object %s = %5ld (0x%lx)\n", - filename, total, total); - else - printf("\t\t\t%-ld\t%-lx\t%s\n", - total, total, filename); - } - else - printf("%s: Not an a.out file\n", filename); - close(f); -} - -int main(argc, argv) - int argc; - char **argv; -{ - if (argc > 1 && strcmp(argv[1], "-v") == 0 ) - { - verbose++; - argc--, argv++; - } - if (argc < 2) - { - printf("Usage: %s [-v] file\n", argv[0]); - exit(1); - } - if(!verbose) - printf("text\tdata\tbss\tdec\thex\tfilename\n"); - for (--argc, ++argv; argc > 0; --argc, ++argv) - size(*argv); - exit(0); -} |