summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1996-12-01 16:58:31 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:34:16 +0200
commitf8de35da65c5d93bb733073cf40da154bc1c0748 (patch)
treed28c7644739a24402376d24cb0020ea410a9ccff /libc
parentc218c617b5be443b7968308506969ad2b726d73c (diff)
downloaddev86-f8de35da65c5d93bb733073cf40da154bc1c0748.tar.gz
Import Dev86src-0.0.9.tar.gzv0.0.9
Diffstat (limited to 'libc')
-rw-r--r--libc/Make.defs2
-rw-r--r--libc/Makefile2
-rw-r--r--libc/bcc/heap.c2
-rw-r--r--libc/bios/bios.c21
-rw-r--r--libc/include/a.out.h2
-rw-r--r--libc/include/ctype.h24
-rw-r--r--libc/misc/Makefile2
-rw-r--r--libc/misc/ctype.c2
-rw-r--r--libc/misc/getcwd.c109
-rw-r--r--libc/msdos/Makefile4
-rw-r--r--libc/msdos/msdos.c22
-rw-r--r--libc/syscall/Makefile4
-rw-r--r--libc/syscall/exec.c (renamed from libc/syscall/execve.c)88
-rw-r--r--libc/syscall/mksys38630
-rw-r--r--libc/tests/hd.c203
15 files changed, 423 insertions, 94 deletions
diff --git a/libc/Make.defs b/libc/Make.defs
index ff571d7..b4f0c28 100644
--- a/libc/Make.defs
+++ b/libc/Make.defs
@@ -21,7 +21,7 @@ endif
VERMAJOR=0
VERMINOR=0
-VERPATCH=8
+VERPATCH=9
VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH)
LIBDEFS='-D__LIBC__="$(VER)"'
diff --git a/libc/Makefile b/libc/Makefile
index d533320..0359619 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -66,7 +66,7 @@ clean:
done
dellib:
- rm -f libc*.a libdos.a
+ rm -f *.a
##############################################################################
diff --git a/libc/bcc/heap.c b/libc/bcc/heap.c
index 6a6ce2c..2cab16e 100644
--- a/libc/bcc/heap.c
+++ b/libc/bcc/heap.c
@@ -44,7 +44,7 @@ has_change:
js go_down
add ax,[brk_addr] ! Goin up!
jc Enomem
- sub bx,#512 ! Safety space 512 bytes
+ sub bx,#511 ! Safety space 512 bytes
cmp bx,ax ! Too close ?
jb Enomem
diff --git a/libc/bios/bios.c b/libc/bios/bios.c
index 18e2448..3059fd9 100644
--- a/libc/bios/bios.c
+++ b/libc/bios/bios.c
@@ -115,6 +115,27 @@ reti_ins:
/****************************************************************************/
+#ifdef L___file_3
+
+/* If the block function does track buffering this should be ok ... */
+struct {
+ int (*block_rw)(); /* Args (rwoc, &buffer, blockno) 1k blocks */
+ /* 0 = read, 1 = write */
+ /* 2 = open, buffer is fname ptr */
+ /* 3 = close, other args ignored */
+ long offset;
+
+ int flags;
+ long block_num;
+ char buffer[1024];
+} __file_3_data;
+
+#define FILE3_OPEN 1 /* File is open */
+#define FILE3_DATA 2 /* buffer has valid contents */
+#define FILE3_DIRTY 4 /* buffer has been modified */
+
+#endif
+
#ifdef L_bios_write
write(fd,buf,len)
int fd,len;
diff --git a/libc/include/a.out.h b/libc/include/a.out.h
index f6a7b94..bd58346 100644
--- a/libc/include/a.out.h
+++ b/libc/include/a.out.h
@@ -90,7 +90,7 @@ struct reloc {
#define S_BSS ((unsigned short)-4)
struct nlist { /* symbol table entry */
- char n_name[24]; /* symbol name */
+ char n_name[8]; /* symbol name */
long n_value; /* value */
unsigned char n_sclass; /* storage class */
unsigned char n_numaux; /* number of auxiliary entries (not used) */
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index 3e94272..ed22ef7 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -5,7 +5,7 @@
#ifndef __CTYPE_H
#define __CTYPE_H
-extern unsigned char _ctype[];
+extern unsigned char __ctype[];
#define __CT_d 0x01 /* numeric digit */
#define __CT_u 0x02 /* upper case */
@@ -22,17 +22,17 @@ extern unsigned char _ctype[];
#define toascii(c) ((c)&0x7F)
/* Note the '!!' is a cast to 'bool' and even BCC deletes it in an if() */
-#define isalnum(c) (!!(_ctype[(int) c]&(__CT_u|__CT_l|__CT_d)))
-#define isalpha(c) (!!(_ctype[(int) c]&(__CT_u|__CT_l)))
+#define isalnum(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l|__CT_d)))
+#define isalpha(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l)))
#define isascii(c) (!((c)&~0x7F))
-#define iscntrl(c) (!!(_ctype[(int) c]&__CT_c))
-#define isdigit(c) (!!(_ctype[(int) c]&__CT_d))
-#define isgraph(c) (!(_ctype[(int) c]&(__CT_c|__CT_s)))
-#define islower(c) (!!(_ctype[(int) c]&__CT_l))
-#define isprint(c) (!(_ctype[(int) c]&__CT_c))
-#define ispunct(c) (!!(_ctype[(int) c]&__CT_p))
-#define isspace(c) (!!(_ctype[(int) c]&__CT_s))
-#define isupper(c) (!!(_ctype[(int) c]&__CT_u))
-#define isxdigit(c) (!!(_ctype[(int) c]&__CT_x))
+#define iscntrl(c) (!!(__ctype[(int) c]&__CT_c))
+#define isdigit(c) (!!(__ctype[(int) c]&__CT_d))
+#define isgraph(c) (!(__ctype[(int) c]&(__CT_c|__CT_s)))
+#define islower(c) (!!(__ctype[(int) c]&__CT_l))
+#define isprint(c) (!(__ctype[(int) c]&__CT_c))
+#define ispunct(c) (!!(__ctype[(int) c]&__CT_p))
+#define isspace(c) (!!(__ctype[(int) c]&__CT_s))
+#define isupper(c) (!!(__ctype[(int) c]&__CT_u))
+#define isxdigit(c) (!!(__ctype[(int) c]&__CT_x))
#endif /* __CTYPE_H */
diff --git a/libc/misc/Makefile b/libc/misc/Makefile
index 3db73a7..c7ed8fa 100644
--- a/libc/misc/Makefile
+++ b/libc/misc/Makefile
@@ -15,7 +15,7 @@ GOBJ=atoi.o atol.o ltoa.o ltostr.o \
ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \
itoa.o cputype.o strtol.o crypt.o
-UOBJ=getenv.o putenv.o popen.o system.o setenv.o
+UOBJ=getenv.o putenv.o popen.o system.o setenv.o getcwd.o
ifeq ($(LIB_OS),ELKS)
diff --git a/libc/misc/ctype.c b/libc/misc/ctype.c
index 1514668..6b6cd3d 100644
--- a/libc/misc/ctype.c
+++ b/libc/misc/ctype.c
@@ -12,7 +12,7 @@
#undef toupper
#undef tolower
-unsigned char _ctype[128] =
+unsigned char __ctype[128] =
{
__CT_c, __CT_c, __CT_c, __CT_c, /* 0x00..0x03 */
__CT_c, __CT_c, __CT_c, __CT_c, /* 0x04..0x07 */
diff --git a/libc/misc/getcwd.c b/libc/misc/getcwd.c
new file mode 100644
index 0000000..351214c
--- /dev/null
+++ b/libc/misc/getcwd.c
@@ -0,0 +1,109 @@
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <string.h>
+/*
+ * These functions find the absolute path to the current working directory.
+ *
+ * They don't use malloc or large amounts of stack space.
+ */
+
+static char * recurser(); /* Routine to go up tree */
+static char * search_dir(); /* Routine to find the step back down */
+static char * path_buf;
+static int path_size;
+
+static dev_t root_dev;
+static ino_t root_ino;
+
+static struct stat st;
+
+char *
+getcwd(buf, size)
+char * buf;
+int size;
+{
+ path_buf = buf;
+ path_size = size;
+
+ if( size < 3 ) { errno = ERANGE; return 0; }
+ strcpy(path_buf, ".");
+
+ if( stat("/", &st) < 0 ) return 0;
+
+ root_dev = st.st_dev;
+ root_ino = st.st_ino;
+
+ return recurser();
+}
+
+static char *
+recurser()
+{
+ dev_t this_dev;
+ ino_t this_ino;
+ if( stat(path_buf, &st) < 0 ) return 0;
+ this_dev = st.st_dev;
+ this_ino = st.st_ino;
+ if( this_dev == root_dev && this_ino == root_ino )
+ {
+ strcpy(path_buf, "/");
+ return path_buf;
+ }
+ if( strlen(path_buf) + 4 > path_size ) { errno = ERANGE; return 0; }
+ strcat(path_buf, "/..");
+ if( recurser() == 0 ) return 0;
+
+ return search_dir(this_dev, this_ino);
+}
+
+static char *
+search_dir(this_dev, this_ino)
+dev_t this_dev;
+ino_t this_ino;
+{
+ DIR * dp;
+ struct dirent * d;
+ char * ptr;
+ int slen;
+ /* The test is for ELKS lib 0.0.9, this should be fixed in the real kernel*/
+ int slow_search = (sizeof(ino_t) != sizeof(d->d_ino));
+
+ if( stat(path_buf, &st) < 0 ) return 0;
+ if( this_dev != st.st_dev ) slow_search = 1;
+
+ slen = strlen(path_buf);
+ ptr = path_buf + slen -1;
+ if( *ptr != '/' )
+ {
+ if( slen + 2 > path_size ) { errno = ERANGE; return 0; }
+ strcpy(++ptr, "/");
+ slen++;
+ }
+ slen++;
+
+ dp = opendir(path_buf);
+ if( dp == 0 ) return 0;
+
+ while( (d=readdir(dp)) != 0 )
+ {
+ if( slow_search || this_ino == d->d_ino )
+ {
+ if( slen + strlen(d->d_name) > path_size )
+ { errno = ERANGE; return 0; }
+ strcpy(ptr+1, d->d_name);
+ if( stat(path_buf, &st) < 0 )
+ continue;
+ if( st.st_ino == this_ino && st.st_dev == this_dev )
+ {
+ closedir(dp);
+ return path_buf;
+ }
+ }
+ }
+
+ closedir(dp);
+ errno = ENOENT;
+ return 0;
+}
diff --git a/libc/msdos/Makefile b/libc/msdos/Makefile
index 59f38b9..f069699 100644
--- a/libc/msdos/Makefile
+++ b/libc/msdos/Makefile
@@ -6,8 +6,8 @@ TOP=..
include $(TOP)/Make.defs
ASRC=msdos.c
-AOBJ= dos_start.o __mkargv.o dos__fconv.o dos_read.o dos_write.o \
- dos_open.o dos_close.o dos_unlink.o dos_lseek.o \
+AOBJ= dos_start.o __mkargv.o __mkenvp.o dos__fconv.o dos_read.o \
+ dos_write.o dos_open.o dos_close.o dos_unlink.o dos_lseek.o \
dos_segalloc.o dos_segfree.o dos_setvect.o dos_getvect.o \
dos_isatty.o dos_getmod.o dos_stat.o
diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c
index 390e904..2d23374 100644
--- a/libc/msdos/msdos.c
+++ b/libc/msdos/msdos.c
@@ -210,6 +210,28 @@ char ** __argv;
}
#endif
+#ifdef L___mkenvp
+
+#ifdef __AS386_16__
+#asm
+ loc 1 ! Make sure the pointer is in the correct segment
+auto_func: ! Label for bcc -M to work.
+ .word ___mkenvp ! Pointer to the autorun function
+ .text ! So the function after is also in the correct seg.
+#endasm
+#endif
+
+char ** environ = 0;
+
+__mkenvp(__argc, __argv, __envp)
+int __argc;
+char ** __argv;
+char ** __envp;
+{
+ /* FIXME !!! */
+}
+#endif
+
#ifdef L_dos__fconv
/* This function converts filenames from unix like to DOS. */
char *
diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile
index 06728da..b487655 100644
--- a/libc/syscall/Makefile
+++ b/libc/syscall/Makefile
@@ -16,8 +16,8 @@ LSRC0=syslib0.c
LOBJ0=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \
getegid.o dup2.o dup.o getpgrp.o times.o
-ESRC=execve.c
-E2OBJ=execl.o execv.o execle.o
+ESRC=exec.c
+E2OBJ=execl.o execv.o execle.o execlp.o execvp.o
EOBJ=execve.o $(E2OBJ)
DSRC=dirent.c
diff --git a/libc/syscall/execve.c b/libc/syscall/exec.c
index 33643ca..411b744 100644
--- a/libc/syscall/execve.c
+++ b/libc/syscall/exec.c
@@ -1,5 +1,6 @@
#include <errno.h>
+#include <sys/stat.h>
extern char ** environ;
@@ -113,9 +114,91 @@ char ** envp;
}
#endif
-#ifdef L_execvve
+#ifdef L_execlp
int
-execvve(fname, interp, argv, envp)
+execlp(fname, arg0)
+char * fname, *arg0;
+{
+ return execvp(fname, &arg0);
+}
+#endif
+
+#ifdef L_execvp
+int
+execvp(fname, argv)
+char * fname, **argv;
+{
+ char *pname = fname, *path;
+ int besterr = ENOENT;
+ int flen, plen;
+ char * bp = sbrk(0);
+
+ if( *fname != '/' && (path = getenv("PATH")) != 0 )
+ {
+ flen = strlen(fname)+2;
+
+ for(;path;)
+ {
+ if( *path == ':' || *path == '\0' )
+ {
+ tryrun(fname, argv);
+ if( errno == EACCES ) besterr = EACCES;
+ if( *path ) path++; else break;
+ }
+ else
+ {
+ char * p = strchr(path, ':');
+ if(p) *p = '\0';
+ plen = strlen(path);
+ pname = sbrk(plen+flen);
+
+ strcpy(pname, path);
+ strcat(pname, "/");
+ strcat(pname, fname);
+
+ tryrun(pname, argv);
+ if( errno == EACCES ) besterr = EACCES;
+
+ brk(pname);
+ pname = fname;
+ if(p) *p++ = ':';
+ path=p;
+ }
+ }
+ }
+
+ tryrun(pname, argv);
+ brk(bp);
+ if( errno == ENOENT || errno == 0 ) errno = besterr;
+ return -1;
+}
+
+static int tryrun(pname, argv)
+char * pname;
+char ** argv;
+{
+static char *shprog[] = {"/bin/sh", "", 0};
+ struct stat st;
+
+ if( stat(pname, &st) < 0 ) return;
+ if( !S_ISREG(st.st_mode) ) return;
+
+#ifdef __AS386_16__
+ __execvve(pname, (void*)0, argv, environ);
+ if( errno == ENOEXEC )
+ {
+ shprog[1] = pname;
+ __execvve(shprog[0], shprog, argv, environ);
+ }
+#else
+ execve(pname, argv, environ);
+ /* FIXME - running /bin/sh in 386 mode */
+#endif
+}
+
+#ifdef __AS386_16__
+static int
+__execvve(fname, interp, argv, envp)
char * fname;
char ** interp;
char ** argv;
@@ -206,3 +289,4 @@ char ** envp;
return rv;
}
#endif
+#endif
diff --git a/libc/syscall/mksys386 b/libc/syscall/mksys386
index be7b2d5..5abcbf8 100644
--- a/libc/syscall/mksys386
+++ b/libc/syscall/mksys386
@@ -50,18 +50,16 @@ awk 'BEGIN{
else if( $4 == "*" ) funcname="__" $1;
else funcname=$1;
- shortname=substr(funcname,1,12);
-
if( length(obj) > 60 )
{
printf("%s\t\\\n", obj) > "syscall.mak";
obj=" ";
}
- obj=obj shortname ".o ";
+ obj=obj funcname ".o ";
printf "/* CALL %s */\n\n", $0;
- printf("#ifdef L_%s\n", shortname);
+ printf("#ifdef L_%s\n", funcname);
printf("#asm\n");
printf("export _%s\n", funcname);
printf("_%s:\n", funcname);
@@ -86,27 +84,27 @@ awk 'BEGIN{
else
{
if( $3 >= 1 ) printf("#if __FIRST_ARG_IN_AX__\n");
- if( $3 >= 5 ) printf(" push edi\n");
- if( $3 >= 4 ) printf(" push esi\n");
- if( $3 >= 5 ) printf(" mov edi,[esp+16]\n");
- if( $3 >= 4 ) printf(" mov esi,[esp+12]\n");
- if( $3 >= 3 ) printf(" mov edx,[esp+8]\n");
- if( $3 >= 2 ) printf(" mov ecx,[esp+4]\n");
if( $3 >= 1 ) printf(" mov ebx,eax\n");
- if( $3 >= 1 ) printf("#else\n");
- if( $3 >= 5 ) printf(" push edi\n");
+ if( $3 >= 2 ) printf(" mov ecx,[esp+4]\n");
+ if( $3 >= 3 ) printf(" mov edx,[esp+8]\n");
if( $3 >= 4 ) printf(" push esi\n");
- if( $3 >= 5 ) printf(" mov edi,[esp+20]\n");
if( $3 >= 4 ) printf(" mov esi,[esp+16]\n");
- if( $3 >= 3 ) printf(" mov edx,[esp+12]\n");
- if( $3 >= 2 ) printf(" mov ecx,[esp+8]\n");
+ if( $3 >= 5 ) printf(" push edi\n");
+ if( $3 >= 5 ) printf(" mov edi,[esp+24]\n");
+ if( $3 >= 1 ) printf("#else\n");
if( $3 >= 1 ) printf(" mov ebx,[esp+4]\n");
+ if( $3 >= 2 ) printf(" mov ecx,[esp+8]\n");
+ if( $3 >= 3 ) printf(" mov edx,[esp+12]\n");
+ if( $3 >= 4 ) printf(" push esi\n");
+ if( $3 >= 4 ) printf(" mov esi,[esp+20]\n");
+ if( $3 >= 5 ) printf(" push edi\n");
+ if( $3 >= 5 ) printf(" mov edi,[esp+28]\n");
if( $3 >= 1 ) printf("#endif\n");
printf(" mov eax,#%d\n", $2);
printf(" int $80\n");
- if( $3 >= 4 ) printf(" pop esi\n");
if( $3 >= 5 ) printf(" pop edi\n");
+ if( $3 >= 4 ) printf(" pop esi\n");
printf(" test eax,eax\n");
printf(" jl syscall_err\n");
diff --git a/libc/tests/hd.c b/libc/tests/hd.c
index f6af1f9..341185f 100644
--- a/libc/tests/hd.c
+++ b/libc/tests/hd.c
@@ -1,90 +1,185 @@
+
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
+
+int lastnum[16] = {-1};
+long lastaddr = -1;
+long offset = 0;
-int lastnum[16] = { -1 };
-long lastaddr = -1;
+FILE *fd;
main(argc, argv)
-int argc;
-char ** argv;
+int argc;
+char **argv;
{
- FILE * fd;
- int j, ch;
- char buf[20];
- int num[16];
- long offset = 0;
-
-#ifndef MSDOS
- if( argc == 1 )
+ int done = 0;
+ int ar;
+ int aflag = 1;
+
+ for (ar = 1; ar < argc; ar++)
+ if (aflag && argv[ar][0] == '-')
+ switch (argv[ar][1])
+ {
+ case 'r':
+ return reverse_hd(argc, argv);
+ case 'o':
+ offset = strtol(argv[ar] + 2, (void *) 0, 0);
+ break;
+ case '-':
+ aflag = 0;
+ break;
+ default:
+ Usage();
+ }
+ else
+ {
+ fd = fopen(argv[ar], "rb");
+ if (fd == 0)
+ fprintf(stderr, "Cannot open file '%s'\n", argv[ar]);
+ else
+ {
+ do_fd();
+ fclose(fd);
+ }
+ done = 1;
+ }
+
+ if (!done)
+#ifdef MSDOS
+ Usage();
+#else
{
fd = stdin;
+ do_fd();
}
- else
#endif
- {
- if( argc == 3 ) offset = strtol(argv[2], (char*)0, 16);
- else if( argc != 2 )
- {
- fprintf(stderr, "Usage: hd file [hexoffset]\n");
- exit(1);
- }
- fd = fopen(argv[1], "rb");
- if( fd == 0 )
- {
- fprintf(stderr, "Cannot open file '%s'\n", argv[1]);
- exit(1);
- }
- }
+}
+
+Usage()
+{
+ fprintf(stderr, "Usage: hd [-r]|[[-oOffset] file]\n");
+ exit(1);
+}
+
+do_fd()
+{
+ int j, ch;
+ char buf[20];
+ int num[16];
- /* if( offset ) fseek(fd, offset, 0); */
+ if (offset)
+ fseek(fd, offset, 0);
- for(ch=0; ch!=EOF; offset+=16)
+ for (ch = 0; ch != EOF; offset += 16)
{
memset(buf, '\0', 16);
- for(j=0; j<16; j++) num[j] = -1;
- for(j=0; j<16; j++)
+ for (j = 0; j < 16; j++)
+ num[j] = -1;
+ for (j = 0; j < 16; j++)
{
- ch = fgetc(fd);
- if( ch == EOF ) break;
+ ch = fgetc(fd);
+ if (ch == EOF)
+ break;
- num[j] = ch;
- if( isascii(ch) && isprint(ch) ) buf[j] = ch;
- else buf[j] = '.';
+ num[j] = ch;
+ if (isascii(ch) && isprint(ch))
+ buf[j] = ch;
+ else
+ buf[j] = '.';
}
- printline(offset, num, buf, ch==EOF);
+ printline(offset, num, buf, ch == EOF);
}
- fclose(fd);
}
printline(address, num, chr, eofflag)
-long address;
-int * num;
-char * chr;
-int eofflag;
+long address;
+int *num;
+char *chr;
+int eofflag;
{
- int j;
+ int j;
- if( lastaddr >= 0 )
+ if (lastaddr >= 0)
{
- for(j=0; j<16; j++)
- if( num[j] != lastnum[j] )
- break;
- if( j == 16 && !eofflag ) return;
- if( lastaddr+16 != address )
- printf("*\n");
+ for (j = 0; j < 16; j++)
+ if (num[j] != lastnum[j])
+ break;
+ if (j == 16 && !eofflag)
+ {
+ if (lastaddr + 16 == address)
+ {
+ printf("*\n");
+ fflush(stdout);
+ }
+ return;
+ }
}
lastaddr = address;
printf("%06lx:", address);
- for(j=0; j<16; j++)
+ for (j = 0; j < 16; j++)
{
- if( num[j] >= 0 )
- printf(" %02x", num[j]);
+ if (j == 8)
+ putchar(' ');
+ if (num[j] >= 0)
+ printf(" %02x", num[j]);
else
- printf(" ");
+ printf(" ");
lastnum[j] = num[j];
num[j] = -1;
}
printf(" %.16s\n", chr);
}
+
+
+/*
+ * This function takes output from hd and converts it back into a binary
+ * file
+ */
+
+/* -- 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+static char *datafmt = "%x: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n";
+reverse_hd()
+{
+ char str[160];
+ char * ptr;
+ int c[16], d[16], x, i, nxtaddr, addr;
+
+ for (i = 0; i < 16; i++)
+ c[i] = 0;
+ nxtaddr = 0;
+
+ for (nxtaddr = 0;;)
+ {
+ if (gets(str) == NULL)
+ break;
+
+ str[57] = 0;
+ ptr = str;
+
+ if( !isxdigit(*ptr) ) continue;
+ addr = strtol(ptr, &ptr, 16);
+ if( *ptr == ':' ) ptr++;
+
+ if (nxtaddr == 0)
+ nxtaddr = addr;
+ while (nxtaddr < addr)
+ {
+ nxtaddr += 16;
+ for (i = 0; i < 16; i++)
+ putchar(c[i]);
+ }
+ for (i = 0; i < 16 && *ptr; i++)
+ {
+ char * ptr2;
+ c[i] = strtol(ptr, &ptr2, 16);
+ if( ptr == ptr2 ) break;
+ putchar(c[i]);
+ ptr = ptr2;
+ }
+ nxtaddr += 16;
+ }
+ return 0;
+}