2
0

maperrorcode.c 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #define INCL_DOSERRORS
  17. #include "fspr_arch_file_io.h"
  18. #include "fspr_file_io.h"
  19. #include <errno.h>
  20. #include <string.h>
  21. #include "fspr_errno.h"
  22. static int errormap[][2] = {
  23. { NO_ERROR, APR_SUCCESS },
  24. { ERROR_FILE_NOT_FOUND, APR_ENOENT },
  25. { ERROR_PATH_NOT_FOUND, APR_ENOENT },
  26. { ERROR_TOO_MANY_OPEN_FILES, APR_EMFILE },
  27. { ERROR_ACCESS_DENIED, APR_EACCES },
  28. { ERROR_SHARING_VIOLATION, APR_EACCES },
  29. { ERROR_INVALID_PARAMETER, APR_EINVAL },
  30. { ERROR_OPEN_FAILED, APR_ENOENT },
  31. { ERROR_DISK_FULL, APR_ENOSPC },
  32. { ERROR_FILENAME_EXCED_RANGE, APR_ENAMETOOLONG },
  33. { ERROR_INVALID_FUNCTION, APR_EINVAL },
  34. { ERROR_INVALID_HANDLE, APR_EBADF },
  35. { ERROR_NEGATIVE_SEEK, APR_ESPIPE },
  36. { ERROR_NO_SIGNAL_SENT, ESRCH },
  37. { ERROR_NO_DATA, APR_EAGAIN },
  38. { SOCEINTR, EINTR },
  39. { SOCEWOULDBLOCK, EWOULDBLOCK },
  40. { SOCEINPROGRESS, EINPROGRESS },
  41. { SOCEALREADY, EALREADY },
  42. { SOCENOTSOCK, ENOTSOCK },
  43. { SOCEDESTADDRREQ, EDESTADDRREQ },
  44. { SOCEMSGSIZE, EMSGSIZE },
  45. { SOCEPROTOTYPE, EPROTOTYPE },
  46. { SOCENOPROTOOPT, ENOPROTOOPT },
  47. { SOCEPROTONOSUPPORT, EPROTONOSUPPORT },
  48. { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT },
  49. { SOCEOPNOTSUPP, EOPNOTSUPP },
  50. { SOCEPFNOSUPPORT, EPFNOSUPPORT },
  51. { SOCEAFNOSUPPORT, EAFNOSUPPORT },
  52. { SOCEADDRINUSE, EADDRINUSE },
  53. { SOCEADDRNOTAVAIL, EADDRNOTAVAIL },
  54. { SOCENETDOWN, ENETDOWN },
  55. { SOCENETUNREACH, ENETUNREACH },
  56. { SOCENETRESET, ENETRESET },
  57. { SOCECONNABORTED, ECONNABORTED },
  58. { SOCECONNRESET, ECONNRESET },
  59. { SOCENOBUFS, ENOBUFS },
  60. { SOCEISCONN, EISCONN },
  61. { SOCENOTCONN, ENOTCONN },
  62. { SOCESHUTDOWN, ESHUTDOWN },
  63. { SOCETOOMANYREFS, ETOOMANYREFS },
  64. { SOCETIMEDOUT, ETIMEDOUT },
  65. { SOCECONNREFUSED, ECONNREFUSED },
  66. { SOCELOOP, ELOOP },
  67. { SOCENAMETOOLONG, ENAMETOOLONG },
  68. { SOCEHOSTDOWN, EHOSTDOWN },
  69. { SOCEHOSTUNREACH, EHOSTUNREACH },
  70. { SOCENOTEMPTY, ENOTEMPTY },
  71. { SOCEPIPE, EPIPE }
  72. };
  73. #define MAPSIZE (sizeof(errormap)/sizeof(errormap[0]))
  74. int fspr_canonical_error(fspr_status_t err)
  75. {
  76. int rv = -1, index;
  77. if (err < APR_OS_START_SYSERR)
  78. return err;
  79. err -= APR_OS_START_SYSERR;
  80. for (index=0; index<MAPSIZE && errormap[index][0] != err; index++);
  81. if (index<MAPSIZE)
  82. rv = errormap[index][1];
  83. else
  84. fprintf(stderr, "fspr_canonical_error: Unknown OS/2 error code %d\n", err );
  85. return rv;
  86. }