+
+static int verify_trigger(struct sr_trigger *trigger)
+{
+ struct sr_trigger_stage *stage;
+ struct sr_trigger_match *match;
+ GSList *l, *m;
+
+ if (!trigger->stages) {
+ sr_err("No trigger stages defined.");
+ return SR_ERR;
+ }
+
+ sr_spew("Checking trigger:");
+ for (l = trigger->stages; l; l = l->next) {
+ stage = l->data;
+ if (!stage->matches) {
+ sr_err("Stage %d has no matches defined.", stage->stage);
+ return SR_ERR;
+ }
+ for (m = stage->matches; m; m = m->next) {
+ match = m->data;
+ if (!match->channel) {
+ sr_err("Stage %d match has no channel.", stage->stage);
+ return SR_ERR;
+ }
+ if (!match->match) {
+ sr_err("Stage %d match is not defined.", stage->stage);
+ return SR_ERR;
+ }
+ sr_spew("Stage %d match on channel %s, match %d", stage->stage,
+ match->channel->name, match->match);
+ }
+ }
+
+ return SR_OK;
+}