diff options
author | Bert Vermeulen <bert@biot.com> | 2012-01-07 02:50:14 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2012-01-07 02:54:43 +0100 |
commit | 159699490ea4bf2495e99dcd5fb18b240d7499df (patch) | |
tree | 9e6f497a2b078e25918fd478d9b0cc41b86bb8da /controller.c | |
parent | 721501bf4267db27bd6b848c8a0d4b5016b1f1c0 (diff) | |
download | libsigrokdecode-159699490ea4bf2495e99dcd5fb18b240d7499df.tar.gz libsigrokdecode-159699490ea4bf2495e99dcd5fb18b240d7499df.zip |
convert data coming in from a PD to C structs
This is in preparation for passing annotation data back to the calling
frontend, and python data up to the next protocol in the stack.
Diffstat (limited to 'controller.c')
-rw-r--r-- | controller.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/controller.c b/controller.c index de9b00a..19dc252 100644 --- a/controller.c +++ b/controller.c @@ -292,33 +292,24 @@ int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf, int pd_output_new(struct srd_decoder_instance *di, int output_type, - char *protocol_id, char *description) + char *protocol_id) { - GSList *l; struct srd_pd_output *pdo; - int pdo_id; - - fprintf(stdout, "%s: output type %d, protocol_id %s, description %s\n", - __func__, output_type, protocol_id, description); - - pdo_id = -1; - for (l = di->pd_output; l; l = l->next) { - pdo = l->data; - if (pdo->pdo_id > pdo_id) - pdo_id = pdo->pdo_id; - } - pdo_id++; if (!(pdo = g_try_malloc(sizeof(struct srd_pd_output)))) return -1; - pdo->pdo_id = pdo_id; + /* pdo_id is just a simple index, nothing is deleted from this list anway */ + pdo->pdo_id = g_slist_length(di->pd_output); pdo->output_type = output_type; + pdo->decoder = di->decoder; pdo->protocol_id = g_strdup(protocol_id); - pdo->description = g_strdup(description); di->pd_output = g_slist_append(di->pd_output, pdo); - return pdo_id; + fprintf(stdout, "%s: output type %d, protocol_id %s, id %d\n", + __func__, output_type, protocol_id, pdo->pdo_id); + + return pdo->pdo_id; } struct srd_decoder_instance *get_di_by_decobject(void *decobject) |