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
20 /** @file scan_new.c */
29 #include "_quvi_net_s.h"
30 #include "_quvi_scan_s.h"
32 #include "net/handle.h"
33 #include "net/fetch.h"
35 #include "misc/scan_new.h"
38 struct _exec_scan_script_s
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
)
57 if (q
->status
.rc
== QUVI_OK
)
59 q
->status
.rc
= l_exec_scan_script_parse(
61 ess
->handle
.net
->fetch
.content
->str
);
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
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
);
84 n_fetch(q
, &n
, qs
->url
.input
->str
);
86 if (quvi_ok(q
) == QUVI_TRUE
)
88 struct _exec_scan_script_s e
;
93 g_slist_foreach(q
->scripts
.scan
, _exec_scan_script
, &e
);
101 /* vim: set ts=2 sw=2 tw=72 expandtab: */