From: Alan Cox Date: Thu, 21 May 2015 22:04:56 +0000 (+0100) Subject: libc: add a tool to make the new liberror.txt X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1725e5626b8fb222db3a4735bbe7d705ae43d566;p=FUZIX.git libc: add a tool to make the new liberror.txt --- diff --git a/Library/Makefile b/Library/Makefile index 49cbf251..f9731bff 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -2,14 +2,21 @@ CFLAGS += -I../Kernel/include -all: tools/syscall tools/binman tools/fcc +all: tools/syscall tools/binman tools/fcc tools/syscall_6502 \ + tools/syscall_6809 tools/binman tools/fcc tools/liberror clean: rm -f tools/syscall tools/binman tools/fcc rm -f tools/syscall-z88dk tools/syscall_6502 tools/syscall_6809 tools/syscall: tools/syscall.c ../Kernel/include/syscall_name.h + tools/syscall-z88dk: tools/syscall-z88dk.c ../Kernel/include/syscall_name.h + tools/syscall_6502: tools/syscall_6502.c ../Kernel/include/syscall_name.h + tools/syscall_6809: tools/syscall_6809.c ../Kernel/include/syscall_name.h + tools/binman: tools/binman.c + +tools/liberror: tools/liberror.c diff --git a/Library/tools/liberror.c b/Library/tools/liberror.c new file mode 100644 index 00000000..b0bf3640 --- /dev/null +++ b/Library/tools/liberror.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include + +#define ERRORS 38 +const char *err[38] = { + "Success", + "Operation not permitted", + "No such file or directory", + "No such process", + "Interrupted system call", + "I/O error", + "No such device or address", + "Arg list too long", + "Exec format error", + "Bad file number", + "No child processes", + "Try again", + "Out of memory", + "Permission denied", + "Bad address", + "Block device required", + "Device or resource busy", + "File exists", + "Cross-device link", + "No such device", + "Not a directory", + "Is a directory", + "Invalid argument", + "File table overflow", + "Too many open files", + "Not a typewriter", + "Text file busy", + "File too large", + "No space left on device", + "Illegal seek", + "Read-only file system", + "Too many links", + "Broken pipe", + "Math argument out of domain of efunc", + "Math result not representable", + "Lock table full", + "Directory is not empty", + "File name too long" +}; + +static uint8_t buf[16384]; + +int main(int argc, char *argv[]) +{ + int base = 2 * ERRORS + 2; + uint8_t *bp = buf + 2; + int swizzle = 0; + int i; + + if (argc > 1 && strcmp(argv[1], "-x") == 0) + swizzle = 1; + + buf[0] = ERRORS; + buf[1] = 0; + + for (i = 0; i < ERRORS; i++) { + int len = strlen(err[i]) + 1; + if (swizzle) { + *bp++ = base >> 8; + *bp++ = base & 0xFF; + } else { + *bp++ = base & 0xFF; + *bp++ = base >> 8; + } + memcpy(buf + base, err[i], len); + base += len; + } + write(1, buf, base); + return 0; +}