src/api/: Use intended license header
[libquvi.git] / src / api / errmsg.c
blobe48d4ae26fdda8790e4030ba5c73f98f980ea738
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 /** @file errmsg.c */
22 #include "config.h"
24 #include <glib.h>
26 #include "quvi.h"
27 /* -- */
28 #include "_quvi_s.h"
30 static const gchar *msg[] =
32 "No error",
33 "Aborted by callback",
34 "'playlist scripts' not found in the path",
35 "'media scripts' not found in the path",
36 "'scan scripts' not found in the path",
37 "'utility scripts' not found in the path",
38 "Invalid argument to function",
39 "libproxy initialization failed",
40 "cURL initialization failed",
41 "Lua initialization failed"
44 static const gchar inv_code_msg[] = "Invalid error code";
46 /** @return NULL-terminated error string
47 @note Do not attempt to free the returned string
48 @sa @ref getting_started
49 @ingroup convenience
51 const char *quvi_errmsg(quvi_t handle)
53 const gchar *s;
54 QuviError c;
55 _quvi_t q;
56 gint i;
58 if (handle == NULL)
59 return (msg[QUVI_ERROR_INVALID_ARG]);
61 q = (_quvi_t) handle;
62 c = q->status.rc;
64 for (i=1; msg[i] != NULL; ++i);
66 s = msg[0];
68 if ( (gint) c<0 || c>i)
70 if (q->status.errmsg->len >0)
71 s = q->status.errmsg->str;
72 else
73 s = inv_code_msg;
75 else
76 s = msg[c];
78 return (s);
81 /* vim: set ts=2 sw=2 tw=72 expandtab: */