mirror of https://gerrit.osmocom.org/gapk
format: Add function to get format by name
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
ef7ada56ce
commit
24b761218f
|
@ -62,5 +62,6 @@ struct format_desc {
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct format_desc *fmt_get_from_type(enum format_type type);
|
const struct format_desc *fmt_get_from_type(enum format_type type);
|
||||||
|
const struct format_desc *fmt_get_from_name(const char *name);
|
||||||
|
|
||||||
#endif /* __GAPK_FORMATS_H__ */
|
#endif /* __GAPK_FORMATS_H__ */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h> /* for NULL */
|
#include <stdio.h> /* for NULL */
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <gapk/formats.h>
|
#include <gapk/formats.h>
|
||||||
|
|
||||||
|
@ -49,3 +50,17 @@ fmt_get_from_type(enum format_type type)
|
||||||
return NULL;
|
return NULL;
|
||||||
return supported_formats[type];
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue