chiark / gitweb /
codec/{base32,hex}.h: Include `codec.h'.
[mLib] / codec / codec.c
CommitLineData
236f657b
MW
1/* -*-c-*-
2 *
3 * Binary codec utilities
4 *
5 * (c) 2009 Straylight/Edgeware
6 */
7
8/*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of the mLib utilities library.
11 *
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
28/*----- Header files ------------------------------------------------------*/
29
30#include "codec.h"
31#include "macros.h"
32
33/*----- Static variables --------------------------------------------------*/
34
35static const char *errtab[] = {
36#define ERR(name, text) text,
37 CODEC_ERRORS(ERR)
38};
39
40/*----- Main code ---------------------------------------------------------*/
41
42/* --- @codec_strerror@ --- *
43 *
44 * Arguments: @int err@ = error code from codec
45 *
46 * Returns: Pointer to error text.
47 *
48 * Use: Converts error codes to human-readable strings.
49 */
50
51const char *codec_strerror(int err)
52{
53 if (err < 0 || err >= N(errtab))
54 return ("Error code out of range");
55 return (errtab[err]);
56}
57
58/*----- That's all, folks -------------------------------------------------*/