os_error_symbian.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program 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
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <pj/errno.h>
  20. #include <pj/assert.h>
  21. #include <pj/compat/stdarg.h>
  22. #include <pj/unicode.h>
  23. #include <pj/string.h>
  24. #include <e32err.h>
  25. #include <in_sock.h>
  26. #if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0)
  27. static const struct {
  28. pj_os_err_type code;
  29. const char *msg;
  30. } gaErrorList[] = {
  31. /*
  32. * Generic error -1 to -46
  33. */
  34. PJ_BUILD_ERR( KErrNotFound, "Unable to find the specified object"),
  35. PJ_BUILD_ERR( KErrGeneral, "General (unspecified) error"),
  36. PJ_BUILD_ERR( KErrCancel, "The operation was cancelled"),
  37. PJ_BUILD_ERR( KErrNoMemory, "Not enough memory"),
  38. PJ_BUILD_ERR( KErrNotSupported, "The operation requested is not supported"),
  39. PJ_BUILD_ERR( KErrArgument, "Bad request"),
  40. PJ_BUILD_ERR( KErrTotalLossOfPrecision, "Total loss of precision"),
  41. PJ_BUILD_ERR( KErrBadHandle, "Bad object"),
  42. PJ_BUILD_ERR( KErrOverflow, "Overflow"),
  43. PJ_BUILD_ERR( KErrUnderflow, "Underflow"),
  44. PJ_BUILD_ERR( KErrAlreadyExists,"Already exists"),
  45. PJ_BUILD_ERR( KErrPathNotFound, "Unable to find the specified folder"),
  46. PJ_BUILD_ERR( KErrDied, "Closed"),
  47. PJ_BUILD_ERR( KErrInUse, "The specified object is currently in use by another program"),
  48. PJ_BUILD_ERR( KErrServerTerminated, "Server has closed"),
  49. PJ_BUILD_ERR( KErrServerBusy, "Server busy"),
  50. PJ_BUILD_ERR( KErrCompletion, "Completion error"),
  51. PJ_BUILD_ERR( KErrNotReady, "Not ready"),
  52. PJ_BUILD_ERR( KErrUnknown, "Unknown error"),
  53. PJ_BUILD_ERR( KErrCorrupt, "Corrupt"),
  54. PJ_BUILD_ERR( KErrAccessDenied, "Access denied"),
  55. PJ_BUILD_ERR( KErrLocked, "Locked"),
  56. PJ_BUILD_ERR( KErrWrite, "Failed to write"),
  57. PJ_BUILD_ERR( KErrDisMounted, "Wrong disk present"),
  58. PJ_BUILD_ERR( KErrEof, "Unexpected end of file"),
  59. PJ_BUILD_ERR( KErrDiskFull, "Disk full"),
  60. PJ_BUILD_ERR( KErrBadDriver, "Bad device driver"),
  61. PJ_BUILD_ERR( KErrBadName, "Bad name"),
  62. PJ_BUILD_ERR( KErrCommsLineFail,"Comms line failed"),
  63. PJ_BUILD_ERR( KErrCommsFrame, "Comms frame error"),
  64. PJ_BUILD_ERR( KErrCommsOverrun, "Comms overrun error"),
  65. PJ_BUILD_ERR( KErrCommsParity, "Comms parity error"),
  66. PJ_BUILD_ERR( KErrTimedOut, "Timed out"),
  67. PJ_BUILD_ERR( KErrCouldNotConnect, "Failed to connect"),
  68. PJ_BUILD_ERR( KErrCouldNotDisconnect, "Failed to disconnect"),
  69. PJ_BUILD_ERR( KErrDisconnected, "Disconnected"),
  70. PJ_BUILD_ERR( KErrBadLibraryEntryPoint, "Bad library entry point"),
  71. PJ_BUILD_ERR( KErrBadDescriptor,"Bad descriptor"),
  72. PJ_BUILD_ERR( KErrAbort, "Interrupted"),
  73. PJ_BUILD_ERR( KErrTooBig, "Too big"),
  74. PJ_BUILD_ERR( KErrDivideByZero, "Divide by zero"),
  75. PJ_BUILD_ERR( KErrBadPower, "Batteries too low"),
  76. PJ_BUILD_ERR( KErrDirFull, "Folder full"),
  77. PJ_BUILD_ERR( KErrHardwareNotAvailable, ""),
  78. PJ_BUILD_ERR( KErrSessionClosed, ""),
  79. PJ_BUILD_ERR( KErrPermissionDenied, ""),
  80. /*
  81. * Socket errors (-190 - -1000)
  82. */
  83. PJ_BUILD_ERR( KErrNetUnreach, "Could not connect to the network. Currently unreachable"),
  84. PJ_BUILD_ERR( KErrHostUnreach, "Could not connect to the specified server"),
  85. PJ_BUILD_ERR( KErrNoProtocolOpt,"The specified server refuses the selected protocol"),
  86. PJ_BUILD_ERR( KErrUrgentData, ""),
  87. PJ_BUILD_ERR( KErrWouldBlock, "Conflicts with KErrExtended, but cannot occur in practice"),
  88. {0, NULL}
  89. };
  90. #endif /* PJ_HAS_ERROR_STRING */
  91. PJ_DEF(pj_status_t) pj_get_os_error(void)
  92. {
  93. return -1;
  94. }
  95. PJ_DEF(void) pj_set_os_error(pj_status_t code)
  96. {
  97. PJ_UNUSED_ARG(code);
  98. }
  99. PJ_DEF(pj_status_t) pj_get_netos_error(void)
  100. {
  101. return -1;
  102. }
  103. PJ_DEF(void) pj_set_netos_error(pj_status_t code)
  104. {
  105. PJ_UNUSED_ARG(code);
  106. }
  107. PJ_BEGIN_DECL
  108. PJ_DECL(int) platform_strerror( pj_os_err_type os_errcode,
  109. char *buf, pj_size_t bufsize);
  110. PJ_END_DECL
  111. /*
  112. * platform_strerror()
  113. *
  114. * Platform specific error message. This file is called by pj_strerror()
  115. * in errno.c
  116. */
  117. PJ_DEF(int) platform_strerror( pj_os_err_type os_errcode,
  118. char *buf, pj_size_t bufsize)
  119. {
  120. int len = 0;
  121. pj_assert(buf != NULL);
  122. pj_assert(bufsize >= 0);
  123. /*
  124. * MUST NOT check stack here.
  125. * This function might be called from PJ_CHECK_STACK() itself!
  126. //PJ_CHECK_STACK();
  127. */
  128. if (!len) {
  129. #if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0)
  130. int i;
  131. for (i = 0; gaErrorList[i].msg; ++i) {
  132. if (gaErrorList[i].code == os_errcode) {
  133. len = strlen(gaErrorList[i].msg);
  134. if ((pj_size_t)len >= bufsize) {
  135. len = bufsize-1;
  136. }
  137. pj_memcpy(buf, gaErrorList[i].msg, len);
  138. buf[len] = '\0';
  139. break;
  140. }
  141. }
  142. #endif /* PJ_HAS_ERROR_STRING */
  143. }
  144. if (!len) {
  145. len = pj_ansi_snprintf( buf, bufsize-1, "Symbian native error %d",
  146. os_errcode);
  147. buf[len] = '\0';
  148. }
  149. return len;
  150. }