| 1 |
/* |
| 2 |
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 3 |
* Copyright (C) 2003-2008 Benny Prijono <[email protected]> |
| 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 |
|
| 25 |
#include <e32err.h> |
| 26 |
#include <in_sock.h> |
| 27 |
|
| 28 |
|
| 29 |
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0) |
| 30 |
static const struct { |
| 31 |
pj_os_err_type code; |
| 32 |
const char *msg; |
| 33 |
} gaErrorList[] = { |
| 34 |
/* |
| 35 |
* Generic error -1 to -46 |
| 36 |
*/ |
| 37 |
PJ_BUILD_ERR( KErrNotFound, "Unable to find the specified object"), |
| 38 |
PJ_BUILD_ERR( KErrGeneral, "General (unspecified) error"), |
| 39 |
PJ_BUILD_ERR( KErrCancel, "The operation was cancelled"), |
| 40 |
PJ_BUILD_ERR( KErrNoMemory, "Not enough memory"), |
| 41 |
PJ_BUILD_ERR( KErrNotSupported, "The operation requested is not supported"), |
| 42 |
PJ_BUILD_ERR( KErrArgument, "Bad request"), |
| 43 |
PJ_BUILD_ERR( KErrTotalLossOfPrecision, "Total loss of precision"), |
| 44 |
PJ_BUILD_ERR( KErrBadHandle, "Bad object"), |
| 45 |
PJ_BUILD_ERR( KErrOverflow, "Overflow"), |
| 46 |
PJ_BUILD_ERR( KErrUnderflow, "Underflow"), |
| 47 |
PJ_BUILD_ERR( KErrAlreadyExists,"Already exists"), |
| 48 |
PJ_BUILD_ERR( KErrPathNotFound, "Unable to find the specified folder"), |
| 49 |
PJ_BUILD_ERR( KErrDied, "Closed"), |
| 50 |
PJ_BUILD_ERR( KErrInUse, "The specified object is currently in use by another program"), |
| 51 |
PJ_BUILD_ERR( KErrServerTerminated, "Server has closed"), |
| 52 |
PJ_BUILD_ERR( KErrServerBusy, "Server busy"), |
| 53 |
PJ_BUILD_ERR( KErrCompletion, "Completion error"), |
| 54 |
PJ_BUILD_ERR( KErrNotReady, "Not ready"), |
| 55 |
PJ_BUILD_ERR( KErrUnknown, "Unknown error"), |
| 56 |
PJ_BUILD_ERR( KErrCorrupt, "Corrupt"), |
| 57 |
PJ_BUILD_ERR( KErrAccessDenied, "Access denied"), |
| 58 |
PJ_BUILD_ERR( KErrLocked, "Locked"), |
| 59 |
PJ_BUILD_ERR( KErrWrite, "Failed to write"), |
| 60 |
PJ_BUILD_ERR( KErrDisMounted, "Wrong disk present"), |
| 61 |
PJ_BUILD_ERR( KErrEof, "Unexpected end of file"), |
| 62 |
PJ_BUILD_ERR( KErrDiskFull, "Disk full"), |
| 63 |
PJ_BUILD_ERR( KErrBadDriver, "Bad device driver"), |
| 64 |
PJ_BUILD_ERR( KErrBadName, "Bad name"), |
| 65 |
PJ_BUILD_ERR( KErrCommsLineFail,"Comms line failed"), |
| 66 |
PJ_BUILD_ERR( KErrCommsFrame, "Comms frame error"), |
| 67 |
PJ_BUILD_ERR( KErrCommsOverrun, "Comms overrun error"), |
| 68 |
PJ_BUILD_ERR( KErrCommsParity, "Comms parity error"), |
| 69 |
PJ_BUILD_ERR( KErrTimedOut, "Timed out"), |
| 70 |
PJ_BUILD_ERR( KErrCouldNotConnect, "Failed to connect"), |
| 71 |
PJ_BUILD_ERR( KErrCouldNotDisconnect, "Failed to disconnect"), |
| 72 |
PJ_BUILD_ERR( KErrDisconnected, "Disconnected"), |
| 73 |
PJ_BUILD_ERR( KErrBadLibraryEntryPoint, "Bad library entry point"), |
| 74 |
PJ_BUILD_ERR( KErrBadDescriptor,"Bad descriptor"), |
| 75 |
PJ_BUILD_ERR( KErrAbort, "Interrupted"), |
| 76 |
PJ_BUILD_ERR( KErrTooBig, "Too big"), |
| 77 |
PJ_BUILD_ERR( KErrDivideByZero, "Divide by zero"), |
| 78 |
PJ_BUILD_ERR( KErrBadPower, "Batteries too low"), |
| 79 |
PJ_BUILD_ERR( KErrDirFull, "Folder full"), |
| 80 |
PJ_BUILD_ERR( KErrHardwareNotAvailable, ""), |
| 81 |
PJ_BUILD_ERR( KErrSessionClosed, ""), |
| 82 |
PJ_BUILD_ERR( KErrPermissionDenied, ""), |
| 83 |
|
| 84 |
/* |
| 85 |
* Socket errors (-190 - -1000) |
| 86 |
*/ |
| 87 |
PJ_BUILD_ERR( KErrNetUnreach, "Could not connect to the network. Currently unreachable"), |
| 88 |
PJ_BUILD_ERR( KErrHostUnreach, "Could not connect to the specified server"), |
| 89 |
PJ_BUILD_ERR( KErrNoProtocolOpt,"The specified server refuses the selected protocol"), |
| 90 |
PJ_BUILD_ERR( KErrUrgentData, ""), |
| 91 |
PJ_BUILD_ERR( KErrWouldBlock, "Conflicts with KErrExtended, but cannot occur in practice"), |
| 92 |
|
| 93 |
{0, NULL} |
| 94 |
}; |
| 95 |
|
| 96 |
#endif /* PJ_HAS_ERROR_STRING */ |
| 97 |
|
| 98 |
|
| 99 |
PJ_DEF(pj_status_t) pj_get_os_error(void) |
| 100 |
{ |
| 101 |
return -1; |
| 102 |
} |
| 103 |
|
| 104 |
PJ_DEF(void) pj_set_os_error(pj_status_t code) |
| 105 |
{ |
| 106 |
PJ_UNUSED_ARG(code); |
| 107 |
} |
| 108 |
|
| 109 |
PJ_DEF(pj_status_t) pj_get_netos_error(void) |
| 110 |
{ |
| 111 |
return -1; |
| 112 |
} |
| 113 |
|
| 114 |
PJ_DEF(void) pj_set_netos_error(pj_status_t code) |
| 115 |
{ |
| 116 |
PJ_UNUSED_ARG(code); |
| 117 |
} |
| 118 |
|
| 119 |
PJ_BEGIN_DECL |
| 120 |
|
| 121 |
PJ_DECL(int) platform_strerror( pj_os_err_type os_errcode, |
| 122 |
char *buf, pj_size_t bufsize); |
| 123 |
PJ_END_DECL |
| 124 |
|
| 125 |
/* |
| 126 |
* platform_strerror() |
| 127 |
* |
| 128 |
* Platform specific error message. This file is called by pj_strerror() |
| 129 |
* in errno.c |
| 130 |
*/ |
| 131 |
PJ_DEF(int) platform_strerror( pj_os_err_type os_errcode, |
| 132 |
char *buf, pj_size_t bufsize) |
| 133 |
{ |
| 134 |
int len = 0; |
| 135 |
|
| 136 |
pj_assert(buf != NULL); |
| 137 |
|
| 138 |
if (bufsize == 0) |
| 139 |
return 0; |
| 140 |
|
| 141 |
/* |
| 142 |
* MUST NOT check stack here. |
| 143 |
* This function might be called from PJ_CHECK_STACK() itself! |
| 144 |
//PJ_CHECK_STACK(); |
| 145 |
*/ |
| 146 |
|
| 147 |
if (!len) { |
| 148 |
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING!=0) |
| 149 |
int i; |
| 150 |
for (i = 0; gaErrorList[i].msg; ++i) { |
| 151 |
if (gaErrorList[i].code == os_errcode) { |
| 152 |
len = strlen(gaErrorList[i].msg); |
| 153 |
if ((pj_size_t)len >= bufsize) { |
| 154 |
len = bufsize-1; |
| 155 |
} |
| 156 |
pj_memcpy(buf, gaErrorList[i].msg, len); |
| 157 |
buf[len] = '\0'; |
| 158 |
break; |
| 159 |
} |
| 160 |
} |
| 161 |
#endif /* PJ_HAS_ERROR_STRING */ |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
if (!len) { |
| 166 |
len = pj_ansi_snprintf( buf, bufsize-1, "Symbian native error %d", |
| 167 |
os_errcode); |
| 168 |
buf[len] = '\0'; |
| 169 |
} |
| 170 |
|
| 171 |
return len; |
| 172 |
} |
| 173 |
|