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 scan_new.c */
30 #include "_quvi_net_s.h"
31 #include "_quvi_scan_s.h"
33 #include "net/handle.h"
34 #include "net/fetch.h"
36 #include "misc/scan_new.h"
39 struct _exec_scan_script_s
48 typedef struct _exec_scan_script_s
*_exec_scan_script_t
;
50 static void _exec_scan_script(gpointer p
, gpointer userdata
)
52 _exec_scan_script_t ess
= (_exec_scan_script_t
) userdata
;
53 _quvi_t q
= (ess
!= NULL
) ? ess
->handle
.scan
->handle
.quvi
: NULL
;
55 if (p
== NULL
|| userdata
== NULL
)
58 if (q
->status
.rc
== QUVI_OK
)
60 q
->status
.rc
= l_exec_scan_script_parse(
62 ess
->handle
.net
->fetch
.content
->str
);
67 extern gint
c_reset(_quvi_t
);
69 /** @brief Scan URL contents for supported embedded media URLs
70 @return New handle, @ref quvi_scan_free it when done using it
72 - Calling this function restores the current @ref sess_handle to its
73 initial state (cookies cleared, custom headers cleared, default
74 user-agent string restored, ...)
75 - Use @ref quvi_ok for checking if an error occurred
79 quvi_scan_t
quvi_scan_new(quvi_t handle
, const char *url
)
81 _quvi_t q
= (_quvi_t
) handle
;
82 _quvi_scan_t qs
= NULL
;
84 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
85 g_return_val_if_fail(handle
!= NULL
, NULL
);
86 g_return_val_if_fail(url
!= NULL
, NULL
);
90 qs
= m_scan_new(q
, url
);
93 n_fetch(q
, &n
, qs
->url
.input
->str
, NULL
);
95 if (quvi_ok(q
) == QUVI_TRUE
)
97 struct _exec_scan_script_s e
;
102 g_slist_foreach(q
->scripts
.scan
, _exec_scan_script
, &e
);
110 /* vim: set ts=2 sw=2 tw=72 expandtab: */