summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usbg_schemes_libconfig.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/usbg_schemes_libconfig.c b/src/usbg_schemes_libconfig.c
index bb856dc..0f6a99a 100644
--- a/src/usbg_schemes_libconfig.c
+++ b/src/usbg_schemes_libconfig.c
@@ -1136,6 +1136,61 @@ out:
}
+static int usbg_import_f_midi_attrs(config_setting_t *root, usbg_function *f)
+{
+ config_setting_t *node;
+ int ret = USBG_ERROR_NO_MEM;
+ int tmp;
+ usbg_function_attrs attrs;
+ usbg_f_midi_attrs *midi_attrs = &attrs.attrs.midi;
+
+ attrs.header.attrs_type = USBG_F_ATTRS_MIDI;
+
+#define ADD_F_MIDI_INT_ATTR(attr, defval, minval) \
+ do { \
+ node = config_setting_get_member(root, #attr); \
+ if (node) { \
+ if (!usbg_config_is_int(node)) { \
+ ret = USBG_ERROR_INVALID_TYPE; \
+ goto out; \
+ } \
+ tmp = config_setting_get_int(node); \
+ if (tmp < minval) { \
+ ret = USBG_ERROR_INVALID_VALUE; \
+ goto out; \
+ } \
+ midi_attrs->attr = tmp; \
+ } else { \
+ midi_attrs->attr = defval; \
+ } \
+ } while (0)
+
+ ADD_F_MIDI_INT_ATTR(index, -1, INT_MIN);
+ ADD_F_MIDI_INT_ATTR(in_ports, 1, 0);
+ ADD_F_MIDI_INT_ATTR(out_ports, 1, 0);
+ ADD_F_MIDI_INT_ATTR(buflen, 256, 0);
+ ADD_F_MIDI_INT_ATTR(qlen, 32, 0);
+
+#undef ADD_F_MIDI_INT_ATTR
+
+ node = config_setting_get_member(root, "id");
+ if (node) {
+ if (!usbg_config_is_string(node)) {
+ ret = USBG_ERROR_INVALID_TYPE;
+ goto out;
+ }
+
+ midi_attrs->id = config_setting_get_string(node);
+ } else {
+ midi_attrs->id = "";
+ }
+
+
+ ret = usbg_set_function_attrs(f, &attrs);
+out:
+ return ret;
+}
+
static int usbg_import_function_attrs(config_setting_t *root, usbg_function *f)
{
int ret = USBG_SUCCESS;
@@ -1169,6 +1224,10 @@ static int usbg_import_function_attrs(config_setting_t *root, usbg_function *f)
ret = usbg_import_f_ms_attrs(root, f);
break;
+ case USBG_F_ATTRS_MIDI:
+ ret = usbg_import_f_midi_attrs(root, f);
+ break;
+
default:
ERROR("Unsupported function type\n");
ret = USBG_ERROR_NOT_SUPPORTED;