Add misc/url.* with m_url_(un)escaped_form
[libquvi.git] / src / api / new.c
blob54864b293d2f56e8a35290ee04d7ed1ffb0042f7
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->opt.user_agent = g_string_new(NULL);
38 q->status.errmsg = g_string_new(NULL);
39 return (q);
42 /** @cond NODOC */
43 extern QuviError m_scan_scripts(_quvi_t q);
44 extern QuviError l_init(_quvi_t q);
45 extern QuviError c_init(_quvi_t q);
46 extern QuviError g_init();
47 /** @endcond */
49 /** @brief Create a new library handle
50 @return New handle, @ref quvi_free it when done using it
51 @note Use @ref quvi_ok for checking if an error occurred
52 @sa @ref getting_started
53 @ingroup lib
55 quvi_t quvi_new()
57 _quvi_t q;
59 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
61 q = _quvi_new();
62 q->status.rc = l_init(q);
64 if (q->status.rc == QUVI_OK)
65 q->status.rc = m_scan_scripts(q);
67 if (q->status.rc == QUVI_OK)
68 q->status.rc = c_init(q);
70 if (q->status.rc == QUVI_OK)
71 q->status.rc = g_init();
73 if (q->status.rc == QUVI_OK)
75 q->handle.proxy = px_proxy_factory_new();
76 if (q->handle.proxy == NULL)
77 q->status.rc = QUVI_ERROR_PROXY_INIT;
79 return (q);
82 /* vim: set ts=2 sw=2 tw=72 expandtab: */