Pass lua_State arg to l_quvi_object_opts_croak_if_error
[libquvi.git] / src / api / set.c
blobbebb9094f1d267ef719d2fa64e105155d7a612df
1 /* libquvi
2 * Copyright (C) 2012 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>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
31 static QuviError _set(_quvi_t q, QuviOption o, va_list arg)
33 switch (o)
35 case QUVI_OPTION_AUTOPROXY:
36 q->opt.autoproxy = (gboolean) va_arg(arg, glong) >0;
37 break;
39 /* Callback */
41 case QUVI_OPTION_CALLBACK_STATUS:
42 q->cb.status = va_arg(arg, quvi_callback_status);
43 break;
45 /* Default */
47 default:
48 return (QUVI_ERROR_INVALID_ARG);
51 return (QUVI_OK);
54 /** @brief Set library handle option
55 @sa @ref getting_started
56 @ingroup lib
58 void quvi_set(quvi_t handle, QuviOption option, ...)
60 va_list arg;
61 _quvi_t q;
63 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
64 g_return_if_fail(handle != NULL);
66 q = (_quvi_t) handle;
68 va_start(arg, option);
69 q->status.rc = _set(handle, option, arg);
70 va_end(arg);
73 /* vim: set ts=2 sw=2 tw=72 expandtab: */