quvi_new: Add call to bindtextdomain
[libquvi.git] / src / api / scan_new.c
blobabda1f3b427307aca4a73ded6e75d07c8d7add93
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 scan_new.c */
22 #include "config.h"
24 #include <glib.h>
26 #include "quvi.h"
27 /* -- */
28 #include "_quvi_s.h"
29 #include "_quvi_net_s.h"
30 #include "_quvi_scan_s.h"
31 /* -- */
32 #include "net/handle.h"
33 #include "net/fetch.h"
34 #include "lua/exec.h"
35 #include "misc/scan_new.h"
37 /** @cond NODOC */
38 struct _exec_scan_script_s
40 struct
42 _quvi_scan_t scan;
43 _quvi_net_t net;
44 } handle;
47 typedef struct _exec_scan_script_s *_exec_scan_script_t;
49 static void _exec_scan_script(gpointer p, gpointer userdata)
51 _exec_scan_script_t ess = (_exec_scan_script_t) userdata;
52 _quvi_t q = (ess != NULL) ? ess->handle.scan->handle.quvi : NULL;
54 if (p == NULL || userdata == NULL)
55 return;
57 if (q->status.rc == QUVI_OK)
59 q->status.rc = l_exec_scan_script_parse(
60 ess->handle.scan, p,
61 ess->handle.net->fetch.content->str);
64 /** @endcond */
66 /** @brief Scan URL contents for supported embedded media URLs
67 @return New handle, @ref quvi_scan_free it when done using it
68 @note Use @ref quvi_ok for checking if an error occurred
69 @sa @ref scan_media
70 @ingroup scan
72 quvi_scan_t quvi_scan_new(quvi_t handle, const char *url)
74 _quvi_t q = (_quvi_t) handle;
75 _quvi_scan_t qs = NULL;
77 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
78 g_return_val_if_fail(handle != NULL, NULL);
79 g_return_val_if_fail(url != NULL, NULL);
81 qs = m_scan_new(q, url);
83 _quvi_net_t n = NULL;
84 n_fetch(q, &n, qs->url.input->str);
86 if (quvi_ok(q) == QUVI_TRUE)
88 struct _exec_scan_script_s e;
90 e.handle.scan = qs;
91 e.handle.net = n;
93 g_slist_foreach(q->scripts.scan, _exec_scan_script, &e);
95 n_free(n);
96 n = NULL;
98 return (qs);
101 /* vim: set ts=2 sw=2 tw=72 expandtab: */