Pass lua_State arg to l_quvi_object_opts_croak_if_error
[libquvi.git] / src / api / new.c
blob495bece392f8bd08549e270d53c85ec3cc156c5b
1 /* libquvi
2 * Copyright (C) 2012-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 /** @file new.c */
23 #include "config.h"
25 #include <glib/gi18n-lib.h>
26 #include <glib.h>
27 #include <string.h>
28 #include <proxy.h>
30 #include "quvi.h"
31 /* -- */
32 #include "_quvi_s.h"
34 static gpointer _quvi_new()
36 _quvi_t q = g_new0(struct _quvi_s, 1);
37 q->status.errmsg = g_string_new(NULL);
38 return (q);
41 /** @cond NODOC */
42 extern QuviError m_scan_scripts(_quvi_t q);
43 extern QuviError l_init(_quvi_t q);
44 extern QuviError c_init(_quvi_t q);
45 extern QuviError g_init();
46 /** @endcond */
48 /** @brief Create a new library handle
49 @return New handle, @ref quvi_free it when done using it
50 @note Use @ref quvi_ok for checking if an error occurred
51 @sa @ref getting_started
52 @ingroup lib
54 quvi_t quvi_new()
56 _quvi_t q;
58 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
60 q = _quvi_new();
61 q->status.rc = l_init(q);
63 if (q->status.rc == QUVI_OK)
64 q->status.rc = m_scan_scripts(q);
66 if (q->status.rc == QUVI_OK)
67 q->status.rc = c_init(q);
69 if (q->status.rc == QUVI_OK)
70 q->status.rc = g_init();
72 if (q->status.rc == QUVI_OK)
74 q->handle.proxy = px_proxy_factory_new();
75 if (q->handle.proxy == NULL)
76 q->status.rc = QUVI_ERROR_PROXY_INIT;
78 return (q);
81 /* vim: set ts=2 sw=2 tw=72 expandtab: */