comparison src/audacious/custom_uri.c @ 3340:a0c93cb34598 trunk

Add functions for custom uri support of input plugins
author Christian Birchinger <joker@netswarm.net>
date Sun, 12 Aug 2007 20:18:04 +0200
parents
children
comparison
equal deleted inserted replaced
3339:c23513d0ee17 3340:a0c93cb34598
1 /*
2 * Audacious
3 * Copyright (c) 2007 William Pitcock
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; under version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
16 *
17 * The Audacious team does not consider modular code linking to
18 * Audacious or using our public API to be a derived work.
19 */
20
21 #include "custom_uri.h"
22
23 mowgli_dictionary_t *uri_type_dict = NULL;
24
25 void uri_set_plugin(const gchar *uri, InputPlugin *ip)
26 {
27 g_return_if_fail(uri != NULL);
28 g_return_if_fail(ip != NULL);
29
30 if (uri_type_dict == NULL)
31 uri_type_dict = mowgli_dictionary_create(strcasecmp);
32 else if (mowgli_dictionary_find(uri_type_dict, uri))
33 mowgli_dictionary_delete(uri_type_dict, uri);
34 mowgli_dictionary_add(uri_type_dict, uri, ip);
35 }
36
37 InputPlugin *uri_get_plugin(const gchar *filename)
38 {
39 gchar *uri, *pos;
40 InputPlugin *ip;
41
42 if (filename == NULL)
43 return NULL;
44
45 if (uri_type_dict == NULL)
46 return NULL;
47
48 pos = strstr(filename, "://");
49 if (pos)
50 uri = g_strndup(filename, pos - filename + 3);
51 else
52 return NULL;
53
54 ip = mowgli_dictionary_retrieve(uri_type_dict, uri);
55
56 g_free(uri);
57
58 return ip;
59 }