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 + +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); +} diff --git a/src/input_plugin.h b/src/inputPlugin.h similarity index 100% rename from src/input_plugin.h rename to src/inputPlugin.h