1119679Smbr/* 2174294Sobrien * Copyright (c) 2002-2006 Ion Badulescu 3174294Sobrien * Copyright (c) 1997-2006 Erez Zadok 4119679Smbr * Copyright (c) 1990 Jan-Simon Pendry 5119679Smbr * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 6119679Smbr * Copyright (c) 1990 The Regents of the University of California. 7119679Smbr * All rights reserved. 8119679Smbr * 9119679Smbr * This code is derived from software contributed to Berkeley by 10119679Smbr * Jan-Simon Pendry at Imperial College, London. 11119679Smbr * 12119679Smbr * Redistribution and use in source and binary forms, with or without 13119679Smbr * modification, are permitted provided that the following conditions 14119679Smbr * are met: 15119679Smbr * 1. Redistributions of source code must retain the above copyright 16119679Smbr * notice, this list of conditions and the following disclaimer. 17119679Smbr * 2. Redistributions in binary form must reproduce the above copyright 18119679Smbr * notice, this list of conditions and the following disclaimer in the 19119679Smbr * documentation and/or other materials provided with the distribution. 20119679Smbr * 3. All advertising materials mentioning features or use of this software 21119679Smbr * must display the following acknowledgment: 22119679Smbr * This product includes software developed by the University of 23119679Smbr * California, Berkeley and its contributors. 24119679Smbr * 4. Neither the name of the University nor the names of its contributors 25119679Smbr * may be used to endorse or promote products derived from this software 26119679Smbr * without specific prior written permission. 27119679Smbr * 28119679Smbr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29119679Smbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30119679Smbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31119679Smbr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32119679Smbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33119679Smbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34119679Smbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35119679Smbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36119679Smbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37119679Smbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38119679Smbr * SUCH DAMAGE. 39119679Smbr * 40119679Smbr * 41174294Sobrien * File: am-utils/libamu/strerror.c 42119679Smbr * 43119679Smbr */ 44119679Smbr 45119679Smbr#ifdef HAVE_CONFIG_H 46119679Smbr# include <config.h> 47119679Smbr#endif /* HAVE_CONFIG_H */ 48119679Smbr#include <am_defs.h> 49119679Smbr#include <amu.h> 50119679Smbr 51119679Smbr 52119679Smbr/* 53119679Smbr * Convert errno to a string 54119679Smbr */ 55119679Smbrchar * 56119679Smbrstrerror(int errnum) 57119679Smbr{ 58119679Smbr#ifdef HAVE_EXTERN_SYS_ERRLIST 59119679Smbr if (errnum < 0 || errnum >= (sizeof(sys_errlist) >> 2)) { 60119679Smbr static char errstr[30]; 61174294Sobrien xsnprintf(errstr, sizeof(errstr), "Unknown error #%d", errnum); 62119679Smbr return errstr; 63119679Smbr } 64119679Smbr return sys_errlist[error]; 65119679Smbr#else /* not HAVE_EXTERN_SYS_ERRLIST */ 66119679Smbr return "unknown (strerror not available)"; 67119679Smbr#endif /* not HAVE_EXTERN_SYS_ERRLIST */ 68119679Smbr} 69