input: Added preferred file extension field
This fixes parts of bug #541.
This commit is contained in:
parent
dc7125bb7c
commit
c7bc82ffa1
|
@ -1385,6 +1385,15 @@ string InputFormat::description()
|
||||||
return valid_string(sr_input_description_get(_structure));
|
return valid_string(sr_input_description_get(_structure));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> InputFormat::extensions()
|
||||||
|
{
|
||||||
|
vector<string> exts;
|
||||||
|
for (const char *const *e = sr_input_extensions_get(_structure);
|
||||||
|
e && *e; e++)
|
||||||
|
exts.push_back(*e);
|
||||||
|
return exts;
|
||||||
|
}
|
||||||
|
|
||||||
map<string, shared_ptr<Option>> InputFormat::options()
|
map<string, shared_ptr<Option>> InputFormat::options()
|
||||||
{
|
{
|
||||||
const struct sr_option **options = sr_input_options_get(_structure);
|
const struct sr_option **options = sr_input_options_get(_structure);
|
||||||
|
|
|
@ -865,6 +865,9 @@ public:
|
||||||
string name();
|
string name();
|
||||||
/** Description of this input format. */
|
/** Description of this input format. */
|
||||||
string description();
|
string description();
|
||||||
|
/** A list of preferred file name extensions for this file format.
|
||||||
|
* @note This list is a recommendation only. */
|
||||||
|
vector<string> extensions();
|
||||||
/** Options supported by this input format. */
|
/** Options supported by this input format. */
|
||||||
map<string, shared_ptr<Option> > options();
|
map<string, shared_ptr<Option> > options();
|
||||||
/** Create an input using this input format.
|
/** Create an input using this input format.
|
||||||
|
|
|
@ -150,6 +150,8 @@ SR_API const struct sr_input_module **sr_input_list(void);
|
||||||
SR_API const char *sr_input_id_get(const struct sr_input_module *in);
|
SR_API const char *sr_input_id_get(const struct sr_input_module *in);
|
||||||
SR_API const char *sr_input_name_get(const struct sr_input_module *in);
|
SR_API const char *sr_input_name_get(const struct sr_input_module *in);
|
||||||
SR_API const char *sr_input_description_get(const struct sr_input_module *in);
|
SR_API const char *sr_input_description_get(const struct sr_input_module *in);
|
||||||
|
SR_API const char *const *sr_input_extensions_get(
|
||||||
|
const struct sr_input_module *o);
|
||||||
SR_API const struct sr_input_module *sr_input_find(char *id);
|
SR_API const struct sr_input_module *sr_input_find(char *id);
|
||||||
SR_API const struct sr_option **sr_input_options_get(const struct sr_input_module *in);
|
SR_API const struct sr_option **sr_input_options_get(const struct sr_input_module *in);
|
||||||
SR_API void sr_input_options_free(const struct sr_option **options);
|
SR_API void sr_input_options_free(const struct sr_option **options);
|
||||||
|
|
|
@ -165,6 +165,7 @@ SR_PRIV struct sr_input_module input_binary = {
|
||||||
.id = "binary",
|
.id = "binary",
|
||||||
.name = "Binary",
|
.name = "Binary",
|
||||||
.desc = "Raw binary",
|
.desc = "Raw binary",
|
||||||
|
.exts = NULL,
|
||||||
.options = get_options,
|
.options = get_options,
|
||||||
.init = init,
|
.init = init,
|
||||||
.receive = receive,
|
.receive = receive,
|
||||||
|
|
|
@ -177,6 +177,7 @@ SR_PRIV struct sr_input_module input_chronovu_la8 = {
|
||||||
.id = "chronovu-la8",
|
.id = "chronovu-la8",
|
||||||
.name = "Chronovu-LA8",
|
.name = "Chronovu-LA8",
|
||||||
.desc = "ChronoVu LA8",
|
.desc = "ChronoVu LA8",
|
||||||
|
.exts = (const char*[]){"kdt", NULL},
|
||||||
.metadata = { SR_INPUT_META_FILESIZE | SR_INPUT_META_REQUIRED },
|
.metadata = { SR_INPUT_META_FILESIZE | SR_INPUT_META_REQUIRED },
|
||||||
.options = get_options,
|
.options = get_options,
|
||||||
.format_match = format_match,
|
.format_match = format_match,
|
||||||
|
|
|
@ -819,6 +819,7 @@ SR_PRIV struct sr_input_module input_csv = {
|
||||||
.id = "csv",
|
.id = "csv",
|
||||||
.name = "CSV",
|
.name = "CSV",
|
||||||
.desc = "Comma-separated values",
|
.desc = "Comma-separated values",
|
||||||
|
.exts = (const char*[]){"csv", NULL},
|
||||||
.metadata = { SR_INPUT_META_MIMETYPE },
|
.metadata = { SR_INPUT_META_MIMETYPE },
|
||||||
.options = get_options,
|
.options = get_options,
|
||||||
.format_match = format_match,
|
.format_match = format_match,
|
||||||
|
|
|
@ -129,6 +129,25 @@ SR_API const char *sr_input_description_get(const struct sr_input_module *o)
|
||||||
return o->desc;
|
return o->desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the specified input module's file extensions typical for the file
|
||||||
|
* format, as a NULL terminated array, or returns a NULL pointer if there is
|
||||||
|
* no preferred extension.
|
||||||
|
* @note these are a suggestions only.
|
||||||
|
*
|
||||||
|
* @since 0.4.0
|
||||||
|
*/
|
||||||
|
SR_API const char *const *sr_input_extensions_get(
|
||||||
|
const struct sr_input_module *o)
|
||||||
|
{
|
||||||
|
if (!o) {
|
||||||
|
sr_err("Invalid input module NULL!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return o->exts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the input module with the specified ID, or NULL if no module
|
* Return the input module with the specified ID, or NULL if no module
|
||||||
* with that id is found.
|
* with that id is found.
|
||||||
|
|
|
@ -569,6 +569,7 @@ SR_PRIV struct sr_input_module input_vcd = {
|
||||||
.id = "vcd",
|
.id = "vcd",
|
||||||
.name = "VCD",
|
.name = "VCD",
|
||||||
.desc = "Value Change Dump",
|
.desc = "Value Change Dump",
|
||||||
|
.exts = (const char*[]){"vcd", NULL},
|
||||||
.metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED },
|
.metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED },
|
||||||
.options = get_options,
|
.options = get_options,
|
||||||
.format_match = format_match,
|
.format_match = format_match,
|
||||||
|
|
|
@ -365,6 +365,7 @@ SR_PRIV struct sr_input_module input_wav = {
|
||||||
.id = "wav",
|
.id = "wav",
|
||||||
.name = "WAV",
|
.name = "WAV",
|
||||||
.desc = "WAV file",
|
.desc = "WAV file",
|
||||||
|
.exts = (const char*[]){"wav", NULL},
|
||||||
.metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED },
|
.metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED },
|
||||||
.format_match = format_match,
|
.format_match = format_match,
|
||||||
.init = init,
|
.init = init,
|
||||||
|
|
|
@ -238,6 +238,13 @@ struct sr_input_module {
|
||||||
*/
|
*/
|
||||||
const char *desc;
|
const char *desc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A NULL terminated array of strings containing a list of file name
|
||||||
|
* extensions typical for the input file format, or NULL if there is
|
||||||
|
* no typical extension for this file format.
|
||||||
|
*/
|
||||||
|
const char *const *exts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zero-terminated list of metadata items the module needs to be able
|
* Zero-terminated list of metadata items the module needs to be able
|
||||||
* to identify an input stream. Can be all-zero, if the module cannot
|
* to identify an input stream. Can be all-zero, if the module cannot
|
||||||
|
|
Loading…
Reference in New Issue