X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=controller.c;h=f7ffb2567ca9cee480d8047bcc4daafd45947b8f;hb=983cb0f5b49167328864d0878148a7407becd1c0;hp=19dc2525cc43af06749a8722c3a9d176239c2b32;hpb=61132abd40fb2a69beb1873fa079f1a93a4d6534;p=libsigrokdecode.git diff --git a/controller.c b/controller.c index 19dc252..f7ffb25 100644 --- a/controller.c +++ b/controller.c @@ -24,6 +24,8 @@ #include +static GSList *callbacks = NULL; + /* TODO static GSList *pipelines = NULL; struct srd_pipeline { @@ -326,6 +328,38 @@ struct srd_decoder_instance *get_di_by_decobject(void *decobject) return NULL; } +int srd_register_callback(int output_type, void *cb) +{ + struct srd_pd_callback *pd_cb; + + if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback)))) + return SRD_ERR_MALLOC; + + pd_cb->output_type = output_type; + pd_cb->callback = cb; + callbacks = g_slist_append(callbacks, pd_cb); + + printf("got cb for %d: %p\n", output_type, cb); + return SRD_OK; +} + +void *srd_find_callback(int output_type) +{ + GSList *l; + struct srd_pd_callback *pd_cb; + void *(cb); + + cb = NULL; + for (l = callbacks; l; l = l->next) { + pd_cb = l->data; + if (pd_cb->output_type == output_type) { + cb = pd_cb->callback; + break; + } + } + + return cb; +} //int srd_pipeline_new(int plid) //{