1 /* sframe-error.c - Error messages.
3 Copyright (C) 2022 Free Software Foundation, Inc.
5 This file is part of libsframe.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "sframe-api.h"
24 /* In this file, we want to treat the first item of the SFrame error
25 macro like subsequent items. */
26 #define _SFRAME_FIRST(NAME, VALUE) _SFRAME_ITEM(NAME, VALUE)
28 /* The error message strings, each in a unique structure member precisely big
29 enough for that error, plus a str member to access them all as a string
32 static const char *const _sframe_errlist
[] = {
33 #define _SFRAME_ITEM(n, s) s,
39 sframe_errmsg (int error
)
43 if (error
>= SFRAME_ERR_BASE
&& (error
- SFRAME_ERR_BASE
) < SFRAME_ERR_NERR
)
44 str
= _sframe_errlist
[error
- SFRAME_ERR_BASE
];
46 str
= (const char *) strerror (error
);
48 return (str
? str
: "Unknown error");