sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * *** CAUTION!!! KEEP DOC CONSISTENT---if you change text of a message sl@0: * *** here, change two places: sl@0: * *** 1) the leading doc section (alphabetized by macro) sl@0: * *** 2) the real text inside switch(errnum) sl@0: * FUNCTION sl@0: * <>---convert error number to string sl@0: * INDEX sl@0: * strerror sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * char *strerror(int <[errnum]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * char *strerror(<[errnum]>) sl@0: * int <[errnum]>; sl@0: * <> converts the error number <[errnum]> into a sl@0: * string. The value of <[errnum]> is usually a copy of <>. sl@0: * If <> is not a known error number, the result points to an sl@0: * empty string. sl@0: * RETURNS sl@0: * This function returns a pointer to a string. Your application must sl@0: * not modify that string. sl@0: * PORTABILITY sl@0: * ANSI C requires <>, but does not specify the strings used sl@0: * for each error number. sl@0: * Although this implementation of <> is reentrant, ANSI C sl@0: * declares that subsequent calls to <> may overwrite the sl@0: * result string; therefore portable code cannot depend on the reentrancy sl@0: * of this subroutine. sl@0: * <> requires no supporting OS subroutines. sl@0: * QUICKREF sl@0: * strerror ansi pure sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Get pointer to error message string. sl@0: Returns a pointer to a string with the error message sl@0: corresponding to the errnum error number. sl@0: The returned pointer points to a statically allocated string. sl@0: Further calls to this function will overwrite its content. sl@0: @param errnum Error number. sl@0: */ sl@0: EXPORT_C char * sl@0: strerror (int errnum) sl@0: { sl@0: char *error; sl@0: sl@0: switch (errnum) sl@0: { sl@0: case EPERM: sl@0: error = "Not owner"; sl@0: break; sl@0: case ENOENT: sl@0: error = "No such file or directory"; sl@0: break; sl@0: case ESRCH: sl@0: error = "No such process"; sl@0: break; sl@0: case EINTR: sl@0: error = "Interrupted system call"; sl@0: break; sl@0: case EIO: sl@0: error = "I/O error"; sl@0: break; sl@0: case ENXIO: sl@0: error = "No such device or address"; sl@0: break; sl@0: case E2BIG: sl@0: error = "Arg list too long"; sl@0: break; sl@0: case ENOEXEC: sl@0: error = "Exec format error"; sl@0: break; sl@0: case EBADF: sl@0: error = "Bad file number"; sl@0: break; sl@0: case ECHILD: sl@0: error = "No children"; sl@0: break; sl@0: case EAGAIN: sl@0: error = "No more processes"; sl@0: break; sl@0: case ENOMEM: sl@0: error = "Not enough space"; sl@0: break; sl@0: case EACCES: sl@0: error = "Permission denied"; sl@0: break; sl@0: case EFAULT: sl@0: error = "Bad address"; sl@0: break; sl@0: case ENOTBLK: sl@0: error = "Block device required"; sl@0: break; sl@0: case EBUSY: sl@0: error = "Device or resource busy"; sl@0: break; sl@0: case EEXIST: sl@0: error = "File exists"; sl@0: break; sl@0: case EXDEV: sl@0: error = "Cross-device link"; sl@0: break; sl@0: case ENODEV: sl@0: error = "No such device"; sl@0: break; sl@0: case ENOTDIR: sl@0: error = "Not a directory"; sl@0: break; sl@0: case EISDIR: sl@0: error = "Is a directory"; sl@0: break; sl@0: case EINVAL: sl@0: error = "Invalid argument"; sl@0: break; sl@0: case ENFILE: sl@0: error = "Too many open files in system"; sl@0: break; sl@0: case EMFILE: sl@0: error = "Too many open files"; sl@0: break; sl@0: case ENOTTY: sl@0: error = "Not a character device"; sl@0: break; sl@0: case ETXTBSY: sl@0: error = "Text file busy"; sl@0: break; sl@0: case EFBIG: sl@0: error = "File too large"; sl@0: break; sl@0: case ENOSPC: sl@0: error = "No space left on device"; sl@0: break; sl@0: case ESPIPE: sl@0: error = "Illegal seek"; sl@0: break; sl@0: case EROFS: sl@0: error = "Read-only file system"; sl@0: break; sl@0: case EMLINK: sl@0: error = "Too many links"; sl@0: break; sl@0: case EPIPE: sl@0: error = "Broken pipe"; sl@0: break; sl@0: case EDOM: sl@0: error = "Math argument"; sl@0: break; sl@0: case ERANGE: sl@0: error = "Result too large"; sl@0: break; sl@0: case ENOMSG: sl@0: error = "No message of desired type"; sl@0: break; sl@0: case EIDRM: sl@0: error = "Identifier removed"; sl@0: break; sl@0: case EDEADLK: sl@0: error = "Deadlock"; sl@0: break; sl@0: case ENOLCK: sl@0: error = "No lock"; sl@0: break; sl@0: case ENOTSOCK: error = "Not a socket"; break; sl@0: case EADDRNOTAVAIL: error = "Remote address not available"; break; sl@0: case EAFNOSUPPORT: error = "Address not supported by protocol"; break; sl@0: case EISCONN: error = "Socket already connected"; break; sl@0: case ECONNREFUSED: error = "Connection refused by remote host"; break; sl@0: case EADDRINUSE: error = "Address already in use"; break; sl@0: case ETIMEDOUT: error = "Connection timed out"; break; sl@0: case ENOSTR: sl@0: error = "Not a stream"; sl@0: break; sl@0: case ETIME: sl@0: error = "Stream ioctl timeout"; sl@0: break; sl@0: case ENOSR: sl@0: error = "No stream resources"; sl@0: break; sl@0: case ENONET: sl@0: error = "Machine is not on the network"; sl@0: break; sl@0: case ENOPKG: sl@0: error = "No package"; sl@0: break; sl@0: case EREMOTE: sl@0: error = "Resource is remote"; sl@0: break; sl@0: case ENOLINK: sl@0: error = "Virtual circuit is gone"; sl@0: break; sl@0: case EADV: sl@0: error = "Advertise error"; sl@0: break; sl@0: case ESRMNT: sl@0: error = "Srmount error"; sl@0: break; sl@0: case ECOMM: sl@0: error = "Communication error"; sl@0: break; sl@0: case EPROTO: sl@0: error = "Protocol error"; sl@0: break; sl@0: case EMULTIHOP: sl@0: error = "Multihop attempted"; sl@0: break; sl@0: case EBADMSG: sl@0: error = "Bad message"; sl@0: break; sl@0: case ELIBACC: sl@0: error = "Cannot access a needed shared library"; sl@0: break; sl@0: case ELIBBAD: sl@0: error = "Accessing a corrupted shared library"; sl@0: break; sl@0: case ELIBSCN: sl@0: error = ".lib section in a.out corrupted"; sl@0: break; sl@0: case ELIBMAX: sl@0: error = "Attempting to link in more shared libraries than system limit"; sl@0: break; sl@0: case ELIBEXEC: sl@0: error = "Cannot exec a shared library directly"; sl@0: break; sl@0: case ENOSYS: sl@0: error = "Function not implemented"; sl@0: break; sl@0: case ENMFILE: sl@0: error = "No more files"; sl@0: break; sl@0: case ENOTEMPTY: sl@0: error = "Directory not empty"; sl@0: break; sl@0: case ENAMETOOLONG: sl@0: error = "File or path name too long"; sl@0: break; sl@0: case EILSEQ: sl@0: error = "invalid wide-character encoding"; sl@0: break; sl@0: default: sl@0: error = ""; sl@0: break; sl@0: } sl@0: sl@0: return error; sl@0: }