#include <stdlib.h>
#include <string.h>
#include <sigrok.h>
+#include <sigrok-internal.h>
/**
* Convert a numeric samplerate value to its "natural" string representation.
max_probes = g_slist_length(device->probes);
error = FALSE;
- triggerlist = g_malloc0(max_probes * sizeof(char *));
+
+ if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) {
+ sr_err("session file: %s: metafile malloc failed", __func__);
+ return NULL;
+ }
+
tokens = g_strsplit(triggerstring, ",", max_probes);
trigger_types = device->plugin->get_device_info(0, SR_DI_TRIGGER_TYPES);
if (trigger_types == NULL)
}
if (probenum < 1 || probenum > max_probes) {
- printf("Invalid probe.\n");
+ sr_err("Invalid probe.\n");
error = TRUE;
break;
}
if ((trigger = strchr(tokens[i], '='))) {
for (tc = ++trigger; *tc; tc++) {
if (strchr(trigger_types, *tc) == NULL) {
- printf("Unsupported trigger type "
+ sr_err("Unsupported trigger type "
"'%c'\n", *tc);
error = TRUE;
break;
return time_msec;
}
+
+gboolean sr_parse_boolstring(const char *boolstr)
+{
+ if (!boolstr)
+ return FALSE;
+
+ if (!g_strcasecmp(boolstr, "true") ||
+ !g_strcasecmp(boolstr, "yes") ||
+ !g_strcasecmp(boolstr, "on") ||
+ !g_strcasecmp(boolstr, "1"))
+ return TRUE;
+
+ return FALSE;
+}
+