home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / library / __ioerr_to_errno.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  84 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  __ioerr_to_errno.c,v 1.1.1.1 1994/04/04 04:30:09 amiga Exp
  20.  *
  21.  *  __ioerr_to_errno.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:09  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.1  1992/05/14  19:55:40  mwild
  26.  *  Initial revision
  27.  *
  28.  */
  29.  
  30. #define _KERNEL
  31. #include "ixemul.h"
  32. #include "kprintf.h"
  33.  
  34. #include <errno.h>
  35.  
  36. int __ioerr_to_errno(int ioerr)
  37. {
  38.   int err;
  39.  
  40.   switch (ioerr)
  41.     {
  42.       case ERROR_NO_FREE_STORE:        err = ENOMEM; break;
  43.       case ERROR_TASK_TABLE_FULL:    err = EAGAIN; break;
  44.       case ERROR_LINE_TOO_LONG:        err = E2BIG;  break;
  45.       case ERROR_FILE_NOT_OBJECT:    
  46.       case ERROR_INVALID_RESIDENT_LIBRARY: err = ENOEXEC; break;
  47.       case ERROR_NO_DEFAULT_DIR:    err = ENOTDIR; break;
  48.       case ERROR_OBJECT_IN_USE:
  49.       case ERROR_OBJECT_EXISTS:        err = EEXIST;  break;
  50.       case ERROR_DIR_NOT_FOUND:
  51.       case ERROR_OBJECT_NOT_FOUND:
  52.       case ERROR_BAD_STREAM_NAME:    err = ENOENT;  break;
  53.       case ERROR_OBJECT_TOO_LARGE:    err = ENOMEM;  break;
  54.       case ERROR_ACTION_NOT_KNOWN:    err = ENODEV;  break;
  55.       case ERROR_INVALID_COMPONENT_NAME:err = EIO;     break;
  56.       case ERROR_INVALID_LOCK:        err = ENODEV;  break;
  57.       case ERROR_OBJECT_WRONG_TYPE:    err = EINVAL;  break;
  58.       case ERROR_DISK_NOT_VALIDATED:    err = EIO;     break;
  59.       case ERROR_DISK_WRITE_PROTECTED:    err = EROFS;   break;
  60.       case ERROR_RENAME_ACROSS_DEVICES:    err = EXDEV;   break;
  61.       case ERROR_DIRECTORY_NOT_EMPTY:   err = ENOTEMPTY; break;
  62.       case ERROR_TOO_MANY_LEVELS:    err = ELOOP;   break;
  63.       case ERROR_DEVICE_NOT_MOUNTED:    err = ENXIO;   break;
  64.       case ERROR_SEEK_ERROR:        err = ESPIPE;  break;
  65.       case ERROR_COMMENT_TOO_BIG:    err = ENAMETOOLONG; break;
  66.       case ERROR_DISK_FULL:        err = ENOSPC;  break;
  67.       case ERROR_DELETE_PROTECTED:
  68.       case ERROR_WRITE_PROTECTED:
  69.       case ERROR_READ_PROTECTED:    err = EACCES;  break;
  70.       case ERROR_NOT_A_DOS_DISK:
  71.       case ERROR_NO_DISK:        err = ENXIO;   break;
  72.       case ERROR_NO_MORE_ENTRIES:    err = ENOENT;  break;
  73.       /* catch-all for illegal accesses to NIL: */
  74.       case 4242:            err = EPERM;   break;
  75.       /* catch-all for illegal accesses to /dev/[pt]tyXX */
  76.       case 5252:            err = EPERM;   break;
  77.       /* catch-all for illegal accesses to / */
  78.       case 6262:            err = EPERM;   break;
  79.       default:                err = EIO;     break;
  80.     }
  81.   KPRINTF (("ioerr = %ld, err = %ld\n", ioerr, err));
  82.   return err;
  83. }
  84.