m_playlist_new: Store input URL in unescaped form
[libquvi.git] / src / api / set.c
blob442a4c439174d3ec5944149263c17dcaf37b0e72
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 set.c */
23 #include "config.h"
25 #include <glib.h>
26 #include <curl/curl.h>
28 #include "quvi.h"
29 /* -- */
30 #include "_quvi_s.h"
32 static QuviError _set(_quvi_t q, const QuviOption o, va_list arg)
34 switch (o)
36 case QUVI_OPTION_ALLOW_COOKIES:
37 q->opt.allow_cookies = (gboolean) va_arg(arg, glong) >0;
38 break;
40 case QUVI_OPTION_AUTOPROXY:
41 q->opt.autoproxy = (gboolean) va_arg(arg, glong) >0;
42 break;
44 case QUVI_OPTION_USER_AGENT:
45 /* Save for later use: c_reset will reuse this value. */
46 g_string_assign(q->opt.user_agent, va_arg(arg, gchar*));
47 /* Apply for immediate effect. */
48 curl_easy_setopt(q->handle.curl, CURLOPT_USERAGENT,
49 q->opt.user_agent->str);
50 break;
52 case QUVI_OPTION_CALLBACK_STATUS:
53 q->cb.status = va_arg(arg, quvi_callback_status);
54 break;
56 case QUVI_OPTION_CALLBACK_STATUS_USERDATA:
57 q->cb.userdata.status = va_arg(arg, void*);
58 break;
60 default:
61 return (QUVI_ERROR_INVALID_ARG);
64 return (QUVI_OK);
67 /** @brief Set library handle option
68 @sa @ref getting_started
69 @ingroup lib
71 void quvi_set(quvi_t handle, QuviOption option, ...)
73 va_list arg;
74 _quvi_t q;
76 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
77 g_return_if_fail(handle != NULL);
79 q = (_quvi_t) handle;
81 va_start(arg, option);
82 q->status.rc = _set(handle, option, arg);
83 va_end(arg);
86 /* vim: set ts=2 sw=2 tw=72 expandtab: */