+ g_strfreev(tokens);
+}
+
+static int init(struct sr_input *in, GHashTable *options)
+{
+ struct context *inc;
+
+ inc = in->priv = g_malloc0(sizeof(struct context));
+
+ inc->maxchannels = g_variant_get_int32(g_hash_table_lookup(options, "numchannels"));
+ inc->downsample = g_variant_get_int32(g_hash_table_lookup(options, "downsample"));
+ if (inc->downsample < 1)
+ inc->downsample = 1;
+
+ inc->compress = g_variant_get_int32(g_hash_table_lookup(options, "compress"));
+ inc->skip = g_variant_get_int32(g_hash_table_lookup(options, "skip"));
+ inc->skip /= inc->downsample;
+
+ in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
+ in->priv = inc;
+
+ inc->buffer = g_malloc(CHUNKSIZE);
+
+ return SR_OK;
+}
+
+static gboolean have_header(GString *buf)
+{
+ unsigned int pos;
+ char *p;
+
+ if (!(p = g_strstr_len(buf->str, buf->len, "$enddefinitions")))
+ return FALSE;
+ pos = p - buf->str + 15;
+ while (pos < buf->len - 4 && g_ascii_isspace(buf->str[pos]))
+ pos++;
+ if (!strncmp(buf->str + pos, "$end", 4))
+ return TRUE;