aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-10-29 22:45:22 +0200
committerSylvain Munaut <tnt@246tNt.com>2010-11-11 20:26:41 +0100
commit24b761218f2db05f8e758640e3f7817410c43212 (patch)
treeb1c4242d57b15cdf3268976a6f6458c366bb8bf8 /src
parentef7ada56cecbdc3504162f2a89be64546a0af345 (diff)
format: Add function to get format by name
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r--src/formats.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/formats.c b/src/formats.c
index 9e8da5e..8f51c2d 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -18,6 +18,7 @@
*/
#include <stdio.h> /* for NULL */
+#include <string.h>
#include <gapk/formats.h>
@@ -49,3 +50,17 @@ fmt_get_from_type(enum format_type type)
return NULL;
return supported_formats[type];
}
+
+const struct format_desc *
+fmt_get_from_name(const char *name)
+{
+ int i;
+ for (i=FMT_INVALID+1; i<_FMT_MAX; i++) {
+ const struct format_desc *fmt = supported_formats[i];
+ if (!fmt)
+ continue;
+ if (!strcmp(fmt->name, name))
+ return fmt;
+ }
+ return NULL;
+}