| 322 | } |
| 323 | |
| 324 | static int init(struct sr_input *in, const char *filename) |
| 325 | { |
| 326 | struct sr_channel *probe; |
| 327 | uint16_t num_probes, i; |
| 328 | char name[SR_MAX_PROBENAME_LEN + 1]; |
| 329 | char *param; |
| 330 | struct context *ctx; |
| 331 | |
| 332 | (void)filename; |
| 333 | |
| 334 | if (!(ctx = malloc(sizeof(struct context)))) { |
| 335 | sr_err("Input format context malloc failed."); |
| 336 | return SR_ERR_MALLOC; |
| 337 | } |
| 338 | memset(ctx, 0, sizeof(struct context)); |
| 339 | |
| 340 | num_probes = DEFAULT_NUM_PROBES; |
| 341 | ctx->samplerate = 0; |
| 342 | ctx->downsample = 1; |
| 343 | ctx->skip = -1; |
| 344 | |
| 345 | if (in->param) { |
| 346 | param = g_hash_table_lookup(in->param, "numprobes"); |
| 347 | if (param) { |
| 348 | num_probes = strtoul(param, NULL, 10); |
| 349 | if (num_probes < 1) |
| 350 | { |
| 351 | release_context(ctx); |
| 352 | return SR_ERR; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | param = g_hash_table_lookup(in->param, "downsample"); |
| 357 | if (param) { |
| 358 | ctx->downsample = strtoul(param, NULL, 10); |
| 359 | if (ctx->downsample < 1) |
| 360 | { |
| 361 | ctx->downsample = 1; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | param = g_hash_table_lookup(in->param, "compress"); |
| 366 | if (param) { |
| 367 | ctx->compress = strtoul(param, NULL, 10); |
| 368 | } |
| 369 | |
| 370 | param = g_hash_table_lookup(in->param, "skip"); |
| 371 | if (param) { |
| 372 | ctx->skip = strtoul(param, NULL, 10) / ctx->downsample; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /* Maximum number of probes to parse from the VCD */ |
| 377 | ctx->maxprobes = num_probes; |
| 378 | |
| 379 | /* Create a virtual device. */ |
| 380 | in->sdi = sr_dev_inst_new(LOGIC, SR_ST_ACTIVE, NULL, NULL, NULL); |
| 381 | in->internal = ctx; |
nothing calls this directly
no test coverage detected