Pass lua_State arg to l_quvi_object_opts_croak_if_error
[libquvi.git] / src / api / get.c
blobb4032c4f8dcbf61b40177a7ebbc854189b9f1a88
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 get.c */
23 #include "config.h"
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
31 static void _get(_quvi_t q, QuviInfo info, ...)
33 gpointer *vp;
34 va_list arg;
35 glong *lp;
36 gint type;
37 #ifdef _CURRENTLY_UNUSED
38 gdouble *dp;
39 gchar **sp;
40 #endif
42 va_start(arg, info);
43 type = QUVI_INFO_TYPE_MASK & (gint) info;
45 vp = NULL;
46 lp = NULL;
47 #ifdef _CURRENTLY_UNUSED
48 dp = NULL;
49 sp = NULL;
50 #endif
52 switch (type)
54 case QUVI_INFO_TYPE_LONG:
55 lp = va_arg(arg, glong*);
56 break;
57 case QUVI_INFO_TYPE_VOID:
58 vp = va_arg(arg, gpointer*);
59 break;
60 #ifdef _CURRENTLY_UNUSED
61 case QUVI_INFO_TYPE_DOUBLE:
62 dp = va_arg(arg, gdouble*);
63 break;
64 case QUVI_INFO_TYPE_STRING:
65 sp = va_arg(arg, gchar**);
66 break;
67 #endif
68 default:
69 break;
71 va_end(arg);
73 switch (info)
75 case QUVI_INFO_RESPONSE_CODE:
76 default:
77 if (lp != NULL)
78 *lp = q->status.resp_code;
79 break;
80 case QUVI_INFO_ERROR_CODE:
81 if (lp != NULL)
82 *lp = q->status.rc;
83 break;
84 case QUVI_INFO_CURL_HANDLE:
85 if (vp != NULL)
86 *vp = q->handle.curl;
87 break;
91 /** @brief Return information about the library handle
92 @sa @ref getting_started
93 @ingroup lib
95 void quvi_get(quvi_t handle, QuviInfo info, ...)
97 va_list arg;
98 gpointer p;
100 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
101 g_return_if_fail(handle != NULL);
103 va_start(arg, info);
104 p = va_arg(arg, gpointer);
105 va_end(arg);
107 _get((_quvi_t) handle, info, p);
110 /* vim: set ts=2 sw=2 tw=72 expandtab: */