- return status;
-}
-
-static int init(struct sr_input *in, const char *filename)
-{
- struct sr_channel *ch;
- int num_channels, i;
- char name[SR_MAX_CHANNELNAME_LEN + 1];
- char *param;
- struct context *ctx;
-
- (void)filename;
-
- if (!(ctx = g_try_malloc0(sizeof(*ctx)))) {
- sr_err("Input format context malloc failed.");
- return SR_ERR_MALLOC;
- }
-
- num_channels = DEFAULT_NUM_CHANNELS;
- ctx->samplerate = 0;
- ctx->downsample = 1;
- ctx->skip = -1;
-
- if (in->param) {
- param = g_hash_table_lookup(in->param, "numchannels");
- if (param) {
- num_channels = strtoul(param, NULL, 10);
- if (num_channels < 1) {
- release_context(ctx);
- return SR_ERR;
- } else if (num_channels > 64) {
- sr_err("No more than 64 channels supported.");
- return SR_ERR;
- }
- }
-
- param = g_hash_table_lookup(in->param, "downsample");
- if (param) {
- ctx->downsample = strtoul(param, NULL, 10);
- if (ctx->downsample < 1)
- ctx->downsample = 1;
- }
-
- param = g_hash_table_lookup(in->param, "compress");
- if (param)
- ctx->compress = strtoul(param, NULL, 10);
-
- param = g_hash_table_lookup(in->param, "skip");
- if (param)
- ctx->skip = strtoul(param, NULL, 10) / ctx->downsample;
- }
-
- /* Maximum number of channels to parse from the VCD */
- ctx->maxchannels = num_channels;
-
- /* Create a virtual device. */
- in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL);
- in->internal = ctx;
-
- for (i = 0; i < num_channels; i++) {
- snprintf(name, SR_MAX_CHANNELNAME_LEN, "%d", i);
-
- if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name))) {
- release_context(ctx);
- return SR_ERR;
- }
-
- in->sdi->channels = g_slist_append(in->sdi->channels, ch);
- }
-
- return SR_OK;