summaryrefslogtreecommitdiff
path: root/src/inputPlugin.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-30 19:13:57 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-30 19:13:57 +0000
commit8e137ddf8184f6eb8e5655b9323e47b2a8f2eef9 (patch)
tree323f69cab6f7fefa24497a69b3afa1cd05590cd7 /src/inputPlugin.c
parentcfc78c7213c7eab60248fd625b63791fc2909d6f (diff)
start to implement inputPlugin interface
git-svn-id: https://svn.musicpd.org/mpd/trunk@1242 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugin.c')
-rw-r--r--src/inputPlugin.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/inputPlugin.c b/src/inputPlugin.c
new file mode 100644
index 000000000..e22b27718
--- /dev/null
+++ b/src/inputPlugin.c
@@ -0,0 +1,67 @@
+#include "input_plugin.h"
+
+#include <stdlib.h>
+
+InputPlugin * newInputPlugin() {
+ InputPlugin * ret = malloc(sizeof(InputPlugin));
+
+ memset(ret->name,0,INPUT_PLUGIN_NAME_LENGTH);
+
+ ret->suffixes = NULL;
+ ret->mimeTypes = NULL;
+ ret->streamTypes = 0;
+
+ ret->streamDecodeFunc = NULL;
+ ret->fileDeocdeFunc = NULL;
+ ret->tagDupFunc = NULL;
+
+ return ret;
+}
+
+static void freeStringArray(char ** ptr) {
+ if(ptr) {
+ char ** tmp = ptr;
+
+ while(*tmp) {
+ if(*tmp) free(*tmp);
+ tmp++;
+ }
+
+ free (ptr);
+ }
+}
+
+void freeInputPlugin(InputPlugin * inPlugin) {
+ char * temp;
+
+ freeStringArray(inPlugin->suffixes);
+ freeStringArray(inPlugin->mimeTypes);
+
+ free(inPlugin);
+}
+
+static char ** AddStringToArray(char ** array, char * string) {
+ int arraySize = 1;
+
+ if(array) {
+ char ** tmp = array;
+ while(*array) {
+ arraySize++;
+ array++;
+ }
+ }
+
+ array = realloc(array, arraySize*sizeof(char *));
+
+ array[arraySize-1] = strdup(string);
+
+ return array;
+}
+
+void addSuffixToInputPlugin(InputPlugin * inPlugin, char * suffix) {
+ inPlugin->suffixes = AddStringToArray(inPlugin->suffixes, suffix);
+}
+
+void addMimeTypeToInputPlugin(InputPlugin * inPlugin, char * mimeType) {
+ inPlugin->mimeTypes = AddStringToArray(inPlugin->mimeTypes, mimeType);
+}