Use word "library" in the source file headers
[libquvi.git] / src / lua / quvi / crypto / err.c
blob9105da47b05c7f9fafbcca99eba89681c39e1126
1 /* libquvi
2 * Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <lauxlib.h>
24 #include <gcrypt.h>
25 #include <glib.h>
26 #include <quvi.h>
28 #include "_quvi_s.h"
29 /* -- */
30 #include "gcrypt/crypto.h"
31 #include "lua/quvi/crypto/opts.h"
32 #include "lua/quvi/crypto/err.h"
33 #include "lua/quvi/opts.h"
34 #include "lua/def.h"
36 void
37 l_quvi_object_crypto_invalid_hexstr(lua_State *l, _quvi_t q,
38 const gboolean croak_if_error)
40 g_string_assign(q->status.errmsg, "invalid hex string value");
41 q->status.rc = QUVI_ERROR_CALLBACK;
43 if (croak_if_error ==TRUE)
44 luaL_error(l, "%s", q->status.errmsg->str);
47 QuviError
48 l_quvi_object_crypto_chk_if_failed(lua_State *l, const crypto_t c,
49 const gboolean croak_if_error, _quvi_t q)
51 if (crypto_ok(c) == TRUE)
52 return (QUVI_OK);
54 g_string_assign(q->status.errmsg, c->errmsg);
56 if (croak_if_error ==TRUE)
57 luaL_error(l, "%s", c->errmsg);
59 return (QUVI_ERROR_CALLBACK);
62 /* vim: set ts=2 sw=2 tw=72 expandtab: */