+ trigger = sr_trigger_new(NULL);
+ error = FALSE;
+ tokens = g_strsplit(s, ",", -1);
+ for (i = 0; tokens[i]; i++) {
+ if (!(sep = strchr(tokens[i], '='))) {
+ g_critical("Invalid trigger '%s'.", tokens[i]);
+ error = TRUE;
+ break;
+ }
+ *sep++ = 0;
+ ch = NULL;
+ for (l = sdi->channels; l; l = l->next) {
+ ch = l->data;
+ if (ch->enabled && !strcmp(ch->name, tokens[i]))
+ break;
+ ch = NULL;
+ }
+ if (!ch) {
+ g_critical("Invalid channel '%s'.", tokens[i]);
+ error = TRUE;
+ break;
+ }
+ for (t = 0; sep[t]; t++) {
+ if (!(match = parse_trigger_match(sep[t]))) {
+ g_critical("Invalid trigger match '%c'.", sep[t]);
+ error = TRUE;
+ break;
+ }
+ found_match = FALSE;
+ for (j = 0; j < num_matches; j++) {
+ if (matches[j] == match) {
+ found_match = TRUE;
+ break;
+ }
+ }
+ if (!found_match) {
+ g_critical("Trigger match '%c' not supported by device.", sep[t]);
+ error = TRUE;
+ break;
+ }
+ /* Make sure this ends up in the right stage, creating
+ * them as needed. */
+ while (!(stage = g_slist_nth_data(trigger->stages, t)))
+ sr_trigger_stage_add(trigger);
+ if (sr_trigger_match_add(stage, ch, match, 0) != SR_OK) {
+ error = TRUE;
+ break;
+ }
+ }
+ }