API: quvi_get: Remove QUVI_INFO_ERROR_CODE support
[libquvi.git] / src / api / get.c
blob022d520d7cc6c25811d5a71b23fb31087146f96d
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 QuviError _get(_quvi_t q, const QuviInfo n, ...)
33 QuviError rc;
34 gpointer *vp;
35 va_list arg;
36 gdouble *dp;
37 gchar **sp;
38 glong *lp;
39 gint type;
41 va_start(arg, n);
42 type = QUVI_INFO_TYPE_MASK & (gint) n;
44 rc = QUVI_OK;
45 vp = NULL;
46 lp = NULL;
47 dp = NULL;
48 sp = NULL;
50 switch (type)
52 case QUVI_INFO_TYPE_LONG:
53 lp = va_arg(arg, glong*);
54 if (lp == NULL)
55 rc = QUVI_ERROR_INVALID_ARG;
56 break;
57 case QUVI_INFO_TYPE_VOID:
58 vp = va_arg(arg, gpointer*);
59 if (vp == NULL)
60 rc = QUVI_ERROR_INVALID_ARG;
61 break;
62 case QUVI_INFO_TYPE_DOUBLE:
63 dp = va_arg(arg, gdouble*);
64 if (dp == NULL)
65 rc = QUVI_ERROR_INVALID_ARG;
66 break;
67 case QUVI_INFO_TYPE_STRING:
68 sp = va_arg(arg, gchar**);
69 if (sp == NULL)
70 rc = QUVI_ERROR_INVALID_ARG;
71 break;
72 default:
73 rc = QUVI_ERROR_INVALID_ARG;
74 break;
76 va_end(arg);
78 if (rc != QUVI_OK)
79 return (rc);
81 switch (n)
83 case QUVI_INFO_RESPONSE_CODE:
84 *lp = q->status.resp_code;
85 break;
86 case QUVI_INFO_CURL_HANDLE:
87 *vp = q->handle.curl;
88 break;
89 default:
90 rc = QUVI_ERROR_INVALID_ARG;
91 break;
93 return (rc);
96 /** @brief Return information about the library handle
97 @sa @ref getting_started
98 @ingroup lib
100 void quvi_get(quvi_t handle, QuviInfo info, ...)
102 va_list arg;
103 gpointer p;
104 _quvi_t q;
106 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
107 g_return_if_fail(handle != NULL);
109 va_start(arg, info);
110 p = va_arg(arg, gpointer);
111 va_end(arg);
113 q = (_quvi_t) handle;
114 q->status.rc = _get(q, info, p);
117 /* vim: set ts=2 sw=2 tw=72 expandtab: */