errno.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * errno.c
  3. *
  4. * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <errno.h>
  20. #include <monolithium.h>
  21. int errno = 0;
  22. int __crt_translate_error(uint32_t status_code)
  23. {
  24. switch (status_code)
  25. {
  26. case ERR_NOTFOUND:
  27. return ENOENT;
  28. case ERR_FORBIDDEN:
  29. return EACCES;
  30. case ERR_INVALID:
  31. return EINVAL;
  32. case ERR_EXISTS:
  33. return EEXIST;
  34. case ERR_NOMEMORY:
  35. return ENOMEM;
  36. case ERR_HARDWARE:
  37. return EIO;
  38. case ERR_BUSY:
  39. return EAGAIN;
  40. case ERR_WRITEPROT:
  41. return EROFS;
  42. case ERR_NOSYSCALL:
  43. return ENOSYS;
  44. case ERR_TIMEOUT:
  45. return ETIMEDOUT;
  46. case ERR_BADPTR:
  47. return EFAULT;
  48. case ERR_CANCELED:
  49. return ECANCELED;
  50. case ERR_ISDIR:
  51. return EISDIR;
  52. case ERR_ISNOTDIR:
  53. return ENOTDIR;
  54. case ERR_DISKFULL:
  55. return ENOSPC;
  56. case ERR_BEYOND:
  57. return ENXIO;
  58. case ERR_SMALLBUF:
  59. return ETOOSMALL;
  60. default:
  61. return 0;
  62. }
  63. }