Pass lua_State arg to l_quvi_object_opts_croak_if_error
[libquvi.git] / src / api / subtitle_type_get.c
blob50bdbba327428c48845768645a60674c471b2383
1 /* libquvi
2 * Copyright (C) 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 subtitle_type_get.c */
23 #include "config.h"
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
30 #include "_quvi_subtitle_s.h"
32 static QuviError _get(_quvi_subtitle_type_t qst,
33 const QuviSubtitleTypeProperty n, ...)
35 QuviError rc;
36 gdouble *dp;
37 va_list arg;
38 gchar **sp;
39 glong *lp;
40 gint type;
42 va_start(arg, n);
43 type = QUVI_SUBTITLE_PROPERTY_TYPE_MASK & (gint) n;
45 rc = QUVI_OK;
46 dp = NULL;
47 sp = NULL;
48 lp = NULL;
50 switch (type)
52 case QUVI_MEDIA_PROPERTY_TYPE_STRING:
53 sp = va_arg(arg, gchar**);
54 if (sp == NULL)
55 rc = QUVI_ERROR_INVALID_ARG;
56 break;
58 case QUVI_MEDIA_PROPERTY_TYPE_LONG:
59 lp = va_arg(arg, glong*);
60 if (lp == NULL)
61 rc = QUVI_ERROR_INVALID_ARG;
62 break;
64 case QUVI_MEDIA_PROPERTY_TYPE_DOUBLE:
65 dp = va_arg(arg, gdouble*);
66 if (dp == NULL)
67 rc = QUVI_ERROR_INVALID_ARG;
68 break;
70 default:
71 rc = QUVI_ERROR_INVALID_ARG;
72 break;
74 va_end(arg);
76 if (rc != QUVI_OK)
77 return (rc);
79 switch (n)
82 * NOTE: Advances to the first item in the 'type' list if the
83 * current pointer is still set to NULL.
86 case QUVI_SUBTITLE_TYPE_PROPERTY_FORMAT:
87 *dp = qst->format;
88 break;
90 case QUVI_SUBTITLE_TYPE_PROPERTY_TYPE:
91 *dp = qst->type;
92 break;
94 default:
95 rc = QUVI_ERROR_INVALID_ARG;
96 break;
98 return (rc);
101 /** @brief Return a subtitle property
102 @sa @ref parse_subtitle
103 @ingroup subprop
105 void quvi_subtitle_type_get(quvi_subtitle_type_t handle,
106 QuviSubtitleTypeProperty n, ...)
108 _quvi_subtitle_type_t qst;
109 va_list arg;
110 gpointer p;
111 _quvi_t q;
113 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
114 g_return_if_fail(handle != NULL);
116 va_start(arg, n);
117 p = va_arg(arg, gpointer);
118 va_end(arg);
120 qst = (_quvi_subtitle_type_t) handle;
121 q = qst->handle.quvi;
123 q->status.rc = _get(qst, n, p);
126 /* vim: set ts=2 sw=2 tw=72 expandtab: */