blob: e22b27718acdbf5ad520e79aa9b1cae31d5942d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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);
}
|