Add misc/url.* with m_url_(un)escaped_form
[libquvi.git] / src / api / script_next.c
blobccdecd0548edfb4a1ad3660e239e2a64dad090e8
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 script_next.c */
23 #include "config.h"
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
31 /** @cond NODOC */
32 #ifdef _1
33 #define _W "libquvi: %s: %d"
34 #endif
35 /** @endcond */
37 /** @brief Traverse to the next script
38 @return QUVI_TRUE if succeeded, otherwise QUVI_FALSE
39 @ingroup script
41 QuviBoolean quvi_script_next(quvi_t handle, QuviScriptType type)
43 QuviBoolean r;
44 GSList *l;
45 _quvi_t q;
47 q = (_quvi_t) handle;
49 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
50 g_return_val_if_fail(handle != NULL, QUVI_FALSE);
52 switch (type)
54 case QUVI_SCRIPT_TYPE_SUBTITLE_EXPORT:
55 l = q->scripts.subtitle_export;
56 break;
58 case QUVI_SCRIPT_TYPE_SUBTITLE:
59 l = q->scripts.subtitle;
60 break;
62 case QUVI_SCRIPT_TYPE_PLAYLIST:
63 l = q->scripts.playlist;
64 break;
66 default:
67 #ifdef _1
68 g_warning(_W, __func__, (gint) type);
69 #endif
70 case QUVI_SCRIPT_TYPE_MEDIA:
71 l = q->scripts.media;
72 break;
74 case QUVI_SCRIPT_TYPE_SCAN:
75 l = q->scripts.scan;
76 break;
79 r = QUVI_FALSE;
81 switch (type)
83 case QUVI_SCRIPT_TYPE_SUBTITLE_EXPORT:
84 q->scripts.curr.subtitle_export =
85 (q->scripts.curr.subtitle_export != NULL)
86 ? g_slist_next(q->scripts.curr.subtitle_export)
87 : l;
88 r = (q->scripts.curr.subtitle_export != NULL)
89 ? QUVI_TRUE
90 : QUVI_FALSE;
91 break;
93 case QUVI_SCRIPT_TYPE_SUBTITLE:
94 q->scripts.curr.subtitle = (q->scripts.curr.subtitle != NULL)
95 ? g_slist_next(q->scripts.curr.subtitle)
96 : l;
97 r = (q->scripts.curr.subtitle != NULL)
98 ? QUVI_TRUE
99 : QUVI_FALSE;
100 break;
102 case QUVI_SCRIPT_TYPE_PLAYLIST:
103 q->scripts.curr.playlist = (q->scripts.curr.playlist != NULL)
104 ? g_slist_next(q->scripts.curr.playlist)
105 : l;
106 r = (q->scripts.curr.playlist != NULL)
107 ? QUVI_TRUE
108 : QUVI_FALSE;
109 break;
111 case QUVI_SCRIPT_TYPE_MEDIA:
112 default:
113 q->scripts.curr.media = (q->scripts.curr.media != NULL)
114 ? g_slist_next(q->scripts.curr.media)
115 : l;
116 r = (q->scripts.curr.media != NULL)
117 ? QUVI_TRUE
118 : QUVI_FALSE;
119 break;
121 case QUVI_SCRIPT_TYPE_SCAN:
122 q->scripts.curr.scan = (q->scripts.curr.scan != NULL)
123 ? g_slist_next(q->scripts.curr.scan)
124 : l;
125 r = (q->scripts.curr.scan != NULL)
126 ? QUVI_TRUE
127 : QUVI_FALSE;
128 break;
131 return (r);
134 #undef _W
136 /* vim: set ts=2 sw=2 tw=72 expandtab: */