diff options
Diffstat (limited to 'libc-0.0.4/error')
-rw-r--r-- | libc-0.0.4/error/Config | 2 | ||||
-rw-r--r-- | libc-0.0.4/error/Makefile | 17 | ||||
-rw-r--r-- | libc-0.0.4/error/README | 10 | ||||
-rw-r--r-- | libc-0.0.4/error/__assert.c | 28 | ||||
-rw-r--r-- | libc-0.0.4/error/error.c | 57 | ||||
-rw-r--r-- | libc-0.0.4/error/liberror.txt | 121 | ||||
-rw-r--r-- | libc-0.0.4/error/perror.c | 19 | ||||
-rw-r--r-- | libc-0.0.4/error/sys_errlist.c | 75 | ||||
-rw-r--r-- | libc-0.0.4/error/sys_siglist.c | 38 |
9 files changed, 367 insertions, 0 deletions
diff --git a/libc-0.0.4/error/Config b/libc-0.0.4/error/Config new file mode 100644 index 0000000..1f384b7 --- /dev/null +++ b/libc-0.0.4/error/Config @@ -0,0 +1,2 @@ + +error: Unix error functions diff --git a/libc-0.0.4/error/Makefile b/libc-0.0.4/error/Makefile new file mode 100644 index 0000000..885f2b8 --- /dev/null +++ b/libc-0.0.4/error/Makefile @@ -0,0 +1,17 @@ +# Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk> +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +TOP=.. +include $(TOP)/Make.defs + +OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o + +all: $(OBJ) + +$(LIBC): $(OBJ) + ar r ../$(LIBC) $(OBJ) + @touch libc.a + +clean: + rm -f $(OBJ) libc.a diff --git a/libc-0.0.4/error/README b/libc-0.0.4/error/README new file mode 100644 index 0000000..02c123f --- /dev/null +++ b/libc-0.0.4/error/README @@ -0,0 +1,10 @@ +Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk> +This file is part of the Linux-8086 C library and is distributed +under the GNU Library General Public License. + +These routines assume the existance of a file /usr/lib/liberror.txt, +this file contains the actual error messages. One useful feature, +the language of the error messages can be easily changed. + + +-Robert diff --git a/libc-0.0.4/error/__assert.c b/libc-0.0.4/error/__assert.c new file mode 100644 index 0000000..bcf04e8 --- /dev/null +++ b/libc-0.0.4/error/__assert.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1996 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include <unistd.h> + +static void errput(str) +const char * str; +{ + write(2, str, strlen(str)); +} + +void +__assert(assertion, filename, linenumber) +const char * assertion; +const char * filename; +int linenumber; +{ + errput("Failed assertion '"); + errput(assertion); + errput("' in file "); + errput(filename); + errput(" at line "); + errput(itoa(linenumber)); + errput(".\n"); + abort(); +} diff --git a/libc-0.0.4/error/error.c b/libc-0.0.4/error/error.c new file mode 100644 index 0000000..3695719 --- /dev/null +++ b/libc-0.0.4/error/error.c @@ -0,0 +1,57 @@ +/* Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ +#include <string.h> + +char **__sys_errlist =0; +int __sys_nerr = 0; + +char * +strerror(err) +int err; +{ + int fd; + static char retbuf[80]; + char inbuf[256]; + int cc; + int bufoff = 0; + + if( __sys_nerr ) + { + if( err < 0 || err >= __sys_nerr ) goto unknown; + return __sys_errlist[err]; + } + + if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */ + fd = open("/usr/lib/liberror.txt", 0); + if( fd < 0 ) goto unknown; + + while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) + { + int i; + for(i=0; i<cc; i++) + { + if( inbuf[i] == '\n' ) + { + retbuf[bufoff] = '\0'; + if( err == atoi(retbuf) ) + { + char * p = strchr(retbuf, ' '); + if( p == 0 ) goto unknown; + while(*p == ' ') p++; + close(fd); + return p; + } + bufoff = 0; + } + else if( bufoff < sizeof(retbuf)-1 ) + retbuf[bufoff++] = inbuf[i]; + } + } +unknown:; + if( fd >= 0 ) close(fd); + strcpy(retbuf, "Unknown error "); + strcpy(retbuf+14, itoa(err)); + return retbuf; +} diff --git a/libc-0.0.4/error/liberror.txt b/libc-0.0.4/error/liberror.txt new file mode 100644 index 0000000..2b510bd --- /dev/null +++ b/libc-0.0.4/error/liberror.txt @@ -0,0 +1,121 @@ +1 Operation not permitted +2 No such file or directory +3 No such process +4 Interrupted system call +5 I/O error +6 No such device or address +7 Arg list too long +8 Exec format error +9 Bad file number +10 No child processes +11 Try again +12 Out of memory +13 Permission denied +14 Bad address +15 Block device required +16 Device or resource busy +17 File exists +18 Cross-device link +19 No such device +20 Not a directory +21 Is a directory +22 Invalid argument +23 File table overflow +24 Too many open files +25 Not a typewriter +26 Text file busy +27 File too large +28 No space left on device +29 Illegal seek +30 Read-only file system +31 Too many links +32 Broken pipe +33 Math argument out of domain of func +34 Math result not representable +35 Resource deadlock would occur +36 File name too long +37 No record locks available +38 Function not implemented +39 Directory not empty +40 Too many symbolic links encountered +41 Operation would block +42 No message of desired type +43 Identifier removed +44 Channel number out of range +45 Level 2 not synchronized +46 Level 3 halted +47 Level 3 reset +48 Link number out of range +49 Protocol driver not attached +50 No CSI structure available +51 Level 2 halted +52 Invalid exchange +53 Invalid request descriptor +54 Exchange full +55 No anode +56 Invalid request code +57 Invalid slot +58 File locking deadlock error +59 Bad font file format +60 Device not a stream +61 No data available +62 Timer expired +63 Out of streams resources +64 Machine is not on the network +65 Package not installed +66 Object is remote +67 Link has been severed +68 Advertise error +69 Srmount error +70 Communication error on send +71 Protocol error +72 Multihop attempted +73 RFS specific error +74 Not a data message +75 Value too large for defined data type +76 Name not unique on network +77 File descriptor in bad state +78 Remote address changed +79 Can not access a needed shared library +80 Accessing a corrupted shared library +81 .lib section in a.out corrupted +82 Attempting to link in too many shared libraries +83 Cannot exec a shared library directly +84 Illegal byte sequence +85 Interrupted system call should be restarted +86 Streams pipe error +87 Too many users +88 Socket operation on non-socket +89 Destination address required +90 Message too long +91 Protocol wrong type for socket +92 Protocol not available +93 Protocol not supported +94 Socket type not supported +95 Operation not supported on transport endpoint +96 Protocol family not supported +97 Address family not supported by protocol +98 Address already in use +99 Cannot assign requested address +100 Network is down +101 Network is unreachable +102 Network dropped connection because of reset +103 Software caused connection abort +104 Connection reset by peer +105 No buffer space available +106 Transport endpoint is already connected +107 Transport endpoint is not connected +108 Cannot send after transport endpoint shutdown +109 Too many references: cannot splice +110 Connection timed out +111 Connection refused +112 Host is down +113 No route to host +114 Operation already in progress +115 Operation now in progress +116 Stale NFS file handle +117 Structure needs cleaning +118 Not a XENIX named type file +119 No XENIX semaphores available +120 Is a named type file +121 Remote I/O error diff --git a/libc-0.0.4/error/perror.c b/libc-0.0.4/error/perror.c new file mode 100644 index 0000000..f9b0965 --- /dev/null +++ b/libc-0.0.4/error/perror.c @@ -0,0 +1,19 @@ + +#include <errno.h> + +void +perror(str) +__const char * str; +{ + register char * ptr; + if(str) + { + write(2, str, strlen(str)); + write(2, ": ", 2); + } + else write(2, "perror: ", 8); + + ptr = strerror(errno); + write(2, ptr, strlen(ptr)); + write(2, "\n", 1); +} diff --git a/libc-0.0.4/error/sys_errlist.c b/libc-0.0.4/error/sys_errlist.c new file mode 100644 index 0000000..1d9e65b --- /dev/null +++ b/libc-0.0.4/error/sys_errlist.c @@ -0,0 +1,75 @@ +/* Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +/* This is a flash way of auto-initing the error array from an external file + * I wouldn't be surprised tho if it's a lot better just to hard code the + * error messages into the array. + * + * Of course the best of all is to use strerror(). + */ + +#ifdef __AS386_16__ +#define NR_ERRORS 128 + +extern char **__sys_errlist; +extern int __sys_nerr; + +char *sys_errlist[NR_ERRORS]; +int sys_nerr = NR_ERRORS; + +#asm + loc 1 ! Make sure the pointer is in the correct segment +auto_func: ! Label for bcc -M to work. + .word _init_vars ! Pointer to the autorun function + .word no_op ! Space filler cause segs are padded to 4 bytes. + .text ! So the function after is also in the correct seg. +#endasm + +static void init_vars() +{ + char inbuf[256]; + char errbuf[80]; + int i, cc, fd, err, len, bufoff=0; + char * ptr; + + fd = open("/usr/lib/liberror.txt", 0); + if( fd < 0 ) return; + + for(i=0; i<NR_ERRORS; i++) sys_errlist[i] = "Unknown error"; + + while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) + { + for(i=0; i<cc; i++) + { + if( inbuf[i] == '\n' ) + { + errbuf[bufoff] = '\0'; + err = atoi(errbuf); + ptr = strchr(errbuf, ' '); + if( ptr && err > 0 && err < NR_ERRORS ) + { + while(*ptr == ' ') ptr++; + len = strlen(ptr)+1; + sys_errlist[err] = (void*)sbrk(len); + if( (int)sys_errlist[err] == -1 ) + { + sys_errlist[err] == ""; + break; + } + memcpy(sys_errlist[err], ptr, len); + } + bufoff = 0; + } + else if( bufoff < sizeof(errbuf)-1 ) + errbuf[bufoff++] = inbuf[i]; + } + } + close(fd); + + __sys_errlist = sys_errlist; + __sys_nerr = sys_nerr = NR_ERRORS; +} + +#endif /* __AS386_16__ */ diff --git a/libc-0.0.4/error/sys_siglist.c b/libc-0.0.4/error/sys_siglist.c new file mode 100644 index 0000000..8f502f6 --- /dev/null +++ b/libc-0.0.4/error/sys_siglist.c @@ -0,0 +1,38 @@ + +#include <signal.h> + +__const char * __const sys_siglist[NSIG] = +{ + "Unknown signal", + "Hangup", + "Interrupt", + "Quit", + "Illegal instruction", + "Trace/breakpoint trap", + "IOT trap/Abort", + "Bus error", + "Floating point exception", + "Killed", + "User defined signal 1", + "Segmentation fault", + "User defined signal 2", + "Broken pipe", + "Alarm clock", + "Terminated", + "Stack fault", + "Child exited", + "Continued", + "Stopped (signal)", + "Stopped", + "Stopped (tty input)", + "Stopped (tty output)", + "Possible I/O", + "CPU time limit exceeded", + "File size limit exceeded", + "Virtual time alarm", + "Profile signal", + "Window size changed", + "File lock lost", + "Power failure", + "Unused signal" +}; |