1119679Smbr/*
2310490Scy * Copyright (c) 2002-2014 Ion Badulescu
3310490Scy * Copyright (c) 1997-2014 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.
20310490Scy * 3. Neither the name of the University nor the names of its contributors
21119679Smbr *    may be used to endorse or promote products derived from this software
22119679Smbr *    without specific prior written permission.
23119679Smbr *
24119679Smbr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25119679Smbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26119679Smbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27119679Smbr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28119679Smbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29119679Smbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30119679Smbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31119679Smbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32119679Smbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33119679Smbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34119679Smbr * SUCH DAMAGE.
35119679Smbr *
36119679Smbr *
37174294Sobrien * File: am-utils/libamu/strerror.c
38119679Smbr *
39119679Smbr */
40119679Smbr
41119679Smbr#ifdef HAVE_CONFIG_H
42119679Smbr# include <config.h>
43119679Smbr#endif /* HAVE_CONFIG_H */
44119679Smbr#include <am_defs.h>
45119679Smbr#include <amu.h>
46119679Smbr
47119679Smbr
48119679Smbr/*
49119679Smbr * Convert errno to a string
50119679Smbr */
51119679Smbrchar *
52119679Smbrstrerror(int errnum)
53119679Smbr{
54119679Smbr#ifdef HAVE_EXTERN_SYS_ERRLIST
55119679Smbr  if (errnum < 0 || errnum >= (sizeof(sys_errlist) >> 2)) {
56119679Smbr    static char errstr[30];
57174294Sobrien    xsnprintf(errstr, sizeof(errstr), "Unknown error #%d", errnum);
58119679Smbr    return errstr;
59119679Smbr  }
60119679Smbr  return sys_errlist[error];
61119679Smbr#else  /* not HAVE_EXTERN_SYS_ERRLIST */
62119679Smbr  return "unknown (strerror not available)";
63119679Smbr#endif /* not HAVE_EXTERN_SYS_ERRLIST */
64119679Smbr}
65