From a1822cb42ce0609d1d6a0af3a180f1eaee858a66 Mon Sep 17 00:00:00 2001 From: hjp Date: Fri, 14 Feb 2003 11:59:43 +0000 Subject: [PATCH] Added list of #defines from HP-UX. --- errno/GNUmakefile | 12 +++-- errno/errno.c | 21 ++++++-- errno/errno.list | 112 ++++++++++++++++++++++++++++++++++++++++++ errno/errno_list.h | 9 ++++ errno/make_errno_list | 11 +++++ 5 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 errno/errno.list create mode 100644 errno/errno_list.h create mode 100755 errno/make_errno_list diff --git a/errno/GNUmakefile b/errno/GNUmakefile index 63e78f0..21f4a2d 100644 --- a/errno/GNUmakefile +++ b/errno/GNUmakefile @@ -1,6 +1,9 @@ -# $Id: GNUmakefile,v 1.2 1998-05-31 01:20:06 hjp Exp $ +# $Id: GNUmakefile,v 1.3 2003-02-14 11:59:43 hjp Exp $ # $Log: GNUmakefile,v $ -# Revision 1.2 1998-05-31 01:20:06 hjp +# Revision 1.3 2003-02-14 11:59:43 hjp +# Added list of #defines from HP-UX. +# +# Revision 1.2 1998/05/31 01:20:06 hjp # GNUmakerules split into GNUmakerules and GNUmakevars. # @@ -9,7 +12,10 @@ include GNUmakerules all: errno -errno: +errno: errno.o errno_list.o +errno_list.c: errno.list make_errno_list + ./make_errno_list + clean: rm errno install: $(BINDIR)/errno diff --git a/errno/errno.c b/errno/errno.c index 8ee3b97..5f64340 100644 --- a/errno/errno.c +++ b/errno/errno.c @@ -2,6 +2,8 @@ #include #include +#include "errno_list.h" + char *cmnd; static void usage(void) { @@ -16,15 +18,26 @@ int main(int argc, char **argv) { cmnd = argv[0]; if (argc <= 1) { - int e; - for (e = 0;; e++) { - printf("%d\t%s\n", e, strerror(e)); + int i; + for (i = 0; i < wke_nr; i++) { + int e = wke[i].number; + char *d = wke[i].define; + printf("%d\t%s\t%s\n", e, d, strerror(e)); } } else { for (i = 1; i < argc; i++) { int e = strtoul(argv[i], NULL, 0); + char *d = "(unknown)"; + int j; - printf("%d\t%s\n", e, strerror(e)); + for (j = 0; j < wke_nr; j++) { + if (wke[j].number == e) { + d = wke[j].define; + break; + } + } + + printf("%d\t%s\t%s\n", e, d, strerror(e)); } } return 0; diff --git a/errno/errno.list b/errno/errno.list new file mode 100644 index 0000000..d828e0e --- /dev/null +++ b/errno/errno.list @@ -0,0 +1,112 @@ +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EADV +EAFNOSUPPORT +EAGAIN +EALREADY +EBADF +EBADMSG +EBADVER +EBUSY +ECANCELED +ECHILD +ECHRNG +ECOMM +ECONFIG +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDOTDOT +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +EL2HLT +EL2NSYNC +EL3HLT +EL3RST +ELNRNG +ELOOP +EMFILE +EMLINK +EMSGSIZE +EMULTIHOP +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENOCSI +ENODATA +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOLINK +ENOLOAD +ENOMATCH +ENOMEM +ENOMSG +ENONET +ENOPKG +ENOPROTOOPT +ENOREG +ENOSPC +ENOSR +ENOSTR +ENOSYM +ENOSYS +ENOTBLK +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTSUP +ENOTTY +ENOUNLD +ENOUNREG +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EREFUSED +ERELOC +EREMOTE +EREMOTERELEASE +EROFS +ESHUTDOWN +ESOCKTNOSUPPORT +ESPIPE +ESRCH +ESRMNT +ESTALE +ETIME +ETIMEDOUT +ETOOMANYREFS +ETXTBSY +EUNATCH +EUSERS +EWOULDBLOCK +EXDEV diff --git a/errno/errno_list.h b/errno/errno_list.h new file mode 100644 index 0000000..527bf28 --- /dev/null +++ b/errno/errno_list.h @@ -0,0 +1,9 @@ +#include + +typedef struct { + int number; + char *define; +} errno_T; + +extern errno_T wke[]; +extern const size_t wke_nr; diff --git a/errno/make_errno_list b/errno/make_errno_list new file mode 100755 index 0000000..18d1ecf --- /dev/null +++ b/errno/make_errno_list @@ -0,0 +1,11 @@ +echo '#include ' > errno_list.c +echo '#include "errno_list.h"' >> errno_list.c +echo 'errno_T wke[] = {' >> errno_list.c +for e in `cat errno.list` +do + echo " #if defined($e)" >> errno_list.c + echo " { $e, \"$e\" }," >> errno_list.c + echo " #endif" >> errno_list.c +done +echo '};' >> errno_list.c +echo 'const size_t wke_nr = sizeof(wke)/sizeof(wke[0]);' >> errno_list.c