2004-06-16 23:52:59 +02:00
|
|
|
/* the Music Player Daemon (MPD)
|
2006-07-14 21:37:45 +02:00
|
|
|
* (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
|
2004-06-16 23:52:59 +02:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
#include "inputPlugin.h"
|
|
|
|
|
|
|
|
#include "list.h"
|
2004-06-01 06:29:34 +02:00
|
|
|
#include "myfprintf.h"
|
2004-05-30 21:13:57 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2004-05-30 22:25:08 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static List * inputPlugin_list = NULL;
|
2004-05-30 21:13:57 +02:00
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
void loadInputPlugin(InputPlugin * inputPlugin) {
|
2004-05-31 03:21:17 +02:00
|
|
|
if(!inputPlugin) return;
|
|
|
|
if(!inputPlugin->name) return;
|
|
|
|
|
2004-05-31 22:59:55 +02:00
|
|
|
if(inputPlugin->initFunc && inputPlugin->initFunc() < 0) return;
|
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void unloadInputPlugin(InputPlugin * inputPlugin) {
|
2004-05-31 22:59:55 +02:00
|
|
|
if(inputPlugin->finishFunc) inputPlugin->finishFunc();
|
2004-05-30 22:25:08 +02:00
|
|
|
deleteFromList(inputPlugin_list, inputPlugin->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stringFoundInStringArray(char ** array, char * suffix) {
|
|
|
|
while(array && *array) {
|
2004-06-01 06:19:28 +02:00
|
|
|
if(strcasecmp(*array, suffix) == 0) return 1;
|
2004-05-30 22:25:08 +02:00
|
|
|
array++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-16 07:52:46 +01:00
|
|
|
InputPlugin * getInputPluginFromSuffix(char * suffix, unsigned int next) {
|
|
|
|
static ListNode * pos = NULL;
|
|
|
|
ListNode * node;
|
|
|
|
InputPlugin * plugin;
|
2004-05-30 22:25:08 +02:00
|
|
|
|
2004-05-31 03:21:17 +02:00
|
|
|
if(suffix == NULL) return NULL;
|
2006-03-16 07:52:46 +01:00
|
|
|
|
|
|
|
if (next) {
|
|
|
|
if (pos) node = pos;
|
|
|
|
else return NULL;
|
|
|
|
} else
|
|
|
|
node = inputPlugin_list->firstNode;
|
2004-05-31 03:21:17 +02:00
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
while(node != NULL) {
|
|
|
|
plugin = node->data;
|
|
|
|
if(stringFoundInStringArray(plugin->suffixes, suffix)) {
|
2006-03-16 07:52:46 +01:00
|
|
|
pos = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
return plugin;
|
|
|
|
}
|
2004-05-31 03:21:17 +02:00
|
|
|
node = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-03-16 07:52:46 +01:00
|
|
|
InputPlugin * getInputPluginFromMimeType(char * mimeType, unsigned int next) {
|
|
|
|
static ListNode * pos = NULL;
|
|
|
|
ListNode * node;
|
|
|
|
InputPlugin * plugin;
|
2004-05-30 22:25:08 +02:00
|
|
|
|
2004-06-01 03:11:44 +02:00
|
|
|
if(mimeType == NULL) return NULL;
|
2006-03-16 07:52:46 +01:00
|
|
|
|
|
|
|
node = (next && pos) ? pos : inputPlugin_list->firstNode;
|
2004-06-01 03:11:44 +02:00
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
while(node != NULL) {
|
|
|
|
plugin = node->data;
|
|
|
|
if(stringFoundInStringArray(plugin->mimeTypes, mimeType)) {
|
2006-03-16 07:52:46 +01:00
|
|
|
pos = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
return plugin;
|
|
|
|
}
|
2004-05-31 03:21:17 +02:00
|
|
|
node = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputPlugin * getInputPluginFromName(char * name) {
|
|
|
|
void * plugin = NULL;
|
|
|
|
|
|
|
|
findInList(inputPlugin_list, name, &plugin);
|
|
|
|
|
|
|
|
return (InputPlugin *)plugin;
|
|
|
|
}
|
|
|
|
|
2004-06-01 06:29:34 +02:00
|
|
|
void printAllInputPluginSuffixes(FILE * fp) {
|
|
|
|
ListNode * node = inputPlugin_list->firstNode;
|
|
|
|
InputPlugin * plugin;
|
|
|
|
char ** suffixes;
|
|
|
|
|
|
|
|
while(node) {
|
|
|
|
plugin = (InputPlugin *)node->data;
|
|
|
|
suffixes = plugin->suffixes;
|
|
|
|
while(suffixes && *suffixes) {
|
|
|
|
myfprintf(fp, "%s ", *suffixes);
|
|
|
|
suffixes++;
|
|
|
|
}
|
|
|
|
node = node->nextNode;
|
|
|
|
}
|
|
|
|
myfprintf(fp, "\n");
|
|
|
|
}
|
|
|
|
|
2004-05-31 03:21:17 +02:00
|
|
|
extern InputPlugin mp3Plugin;
|
2006-03-16 07:52:46 +01:00
|
|
|
extern InputPlugin oggvorbisPlugin;
|
2004-05-31 03:54:10 +02:00
|
|
|
extern InputPlugin flacPlugin;
|
2006-03-16 07:52:46 +01:00
|
|
|
extern InputPlugin oggflacPlugin;
|
2004-05-31 04:31:55 +02:00
|
|
|
extern InputPlugin audiofilePlugin;
|
2004-05-31 04:42:22 +02:00
|
|
|
extern InputPlugin mp4Plugin;
|
2005-02-01 04:20:16 +01:00
|
|
|
extern InputPlugin mpcPlugin;
|
2004-05-31 05:30:09 +02:00
|
|
|
extern InputPlugin aacPlugin;
|
2004-05-31 22:59:55 +02:00
|
|
|
extern InputPlugin modPlugin;
|
2004-05-31 03:21:17 +02:00
|
|
|
|
sparse: ANSI-fy function declarations
These are just warnings from sparse, but it makes the output
easier to read. I ran this through a quick perl script, but
of course verified the output by looking at the diff and making
sure the thing still compiles.
here's the quick perl script I wrote to generate this patch:
----------- 8< -----------
use Tie::File;
defined(my $pid = open my $fh, '-|') or die $!;
if (!$pid) {
open STDERR, '>&STDOUT' or die $!;
exec 'sparse', @ARGV or die $!;
}
my $na = 'warning: non-ANSI function declaration of function';
while (<$fh>) {
print STDERR $_;
if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) {
my ($f, $l, $pos, $func) = ($1, $2, $3, $4);
$l--;
tie my @x, 'Tie::File', $f or die "$!: $f";
print '-', $x[$l], "\n";
$x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/;
print '+', $x[$l], "\n";
untie @x;
}
}
git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-17 02:15:34 +02:00
|
|
|
void initInputPlugins(void) {
|
2004-11-11 03:59:16 +01:00
|
|
|
inputPlugin_list = makeList(NULL, 1);
|
2004-05-30 22:25:08 +02:00
|
|
|
|
|
|
|
/* load plugins here */
|
2004-05-31 03:21:17 +02:00
|
|
|
loadInputPlugin(&mp3Plugin);
|
2006-03-16 07:52:46 +01:00
|
|
|
loadInputPlugin(&oggvorbisPlugin);
|
|
|
|
loadInputPlugin(&oggflacPlugin);
|
2004-05-31 03:54:10 +02:00
|
|
|
loadInputPlugin(&flacPlugin);
|
2004-05-31 04:31:55 +02:00
|
|
|
loadInputPlugin(&audiofilePlugin);
|
2004-05-31 04:42:22 +02:00
|
|
|
loadInputPlugin(&mp4Plugin);
|
2005-02-01 04:20:16 +01:00
|
|
|
loadInputPlugin(&mpcPlugin);
|
2004-05-31 22:59:55 +02:00
|
|
|
loadInputPlugin(&modPlugin);
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
sparse: ANSI-fy function declarations
These are just warnings from sparse, but it makes the output
easier to read. I ran this through a quick perl script, but
of course verified the output by looking at the diff and making
sure the thing still compiles.
here's the quick perl script I wrote to generate this patch:
----------- 8< -----------
use Tie::File;
defined(my $pid = open my $fh, '-|') or die $!;
if (!$pid) {
open STDERR, '>&STDOUT' or die $!;
exec 'sparse', @ARGV or die $!;
}
my $na = 'warning: non-ANSI function declaration of function';
while (<$fh>) {
print STDERR $_;
if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) {
my ($f, $l, $pos, $func) = ($1, $2, $3, $4);
$l--;
tie my @x, 'Tie::File', $f or die "$!: $f";
print '-', $x[$l], "\n";
$x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/;
print '+', $x[$l], "\n";
untie @x;
}
}
git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-17 02:15:34 +02:00
|
|
|
void finishInputPlugins(void) {
|
2004-05-30 22:25:08 +02:00
|
|
|
freeList(inputPlugin_list);
|
|
|
|
}
|