1 /* libquvi 2 * Copyright (C) 2012-2013 Toni Gundogdu <legatvs@gmail.com> 3 * 4 * This file is part of libquvi <http://quvi.sourceforge.net/>. 5 * 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. 10 * 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. 15 * 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/>. 19 */ 20 21 /** @file new.c */ 22 23 #include "config.h" 24 25 #include <glib/gi18n-lib.h> 26 #include <glib.h> 27 #include <string.h> 28 #include <proxy.h> 29 30 #include "quvi.h" 31 /* -- */ 32 #include "_quvi_s.h" 33 _quvi_new()34static gpointer _quvi_new() 35 { 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); 40 } 41 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 */ 48 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 54 */ quvi_new()55quvi_t quvi_new() 56 { 57 _quvi_t q; 58 59 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); 60 61 q = _quvi_new(); 62 q->status.rc = l_init(q); 63 64 if (q->status.rc == QUVI_OK) 65 q->status.rc = m_scan_scripts(q); 66 67 if (q->status.rc == QUVI_OK) 68 q->status.rc = c_init(q); 69 70 if (q->status.rc == QUVI_OK) 71 q->status.rc = g_init(); 72 73 if (q->status.rc == QUVI_OK) 74 { 75 q->handle.proxy = px_proxy_factory_new(); 76 if (q->handle.proxy == NULL) 77 q->status.rc = QUVI_ERROR_PROXY_INIT; 78 } 79 return (q); 80 } 81 82 /* vim: set ts=2 sw=2 tw=72 expandtab: */ 83