| 1572 | } |
| 1573 | |
| 1574 | static int sr_load_virtual_device_session(struct sr_dev_inst *sdi) |
| 1575 | { |
| 1576 | GKeyFile *kf; |
| 1577 | unzFile archive = NULL; |
| 1578 | char szFilePath[15]; |
| 1579 | unz_file_info64 fileInfo; |
| 1580 | |
| 1581 | struct sr_channel *probe; |
| 1582 | int devcnt, i, j; |
| 1583 | uint16_t probenum; |
| 1584 | uint64_t tmp_u64, total_probes, enabled_probes; |
| 1585 | uint16_t p; |
| 1586 | int64_t tmp_64; |
| 1587 | char **sections, **keys, *metafile, *val; |
| 1588 | char probename[SR_MAX_PROBENAME_LEN + 1]; |
| 1589 | int mode = LOGIC; |
| 1590 | int channel_type = SR_CHANNEL_LOGIC; |
| 1591 | double tmp_double; |
| 1592 | int version = 1; |
| 1593 | |
| 1594 | assert(sdi); |
| 1595 | assert(sdi->path); |
| 1596 | |
| 1597 | if (sdi->dev_type != DEV_TYPE_FILELOG) |
| 1598 | { |
| 1599 | sr_err("%s: Is not a virtual device instance.", __func__); |
| 1600 | return SR_ERR_ARG; |
| 1601 | } |
| 1602 | |
| 1603 | // Clear all channels. |
| 1604 | sr_dev_probes_free(sdi); |
| 1605 | |
| 1606 | archive = unzOpen64(sdi->path); |
| 1607 | if (NULL == archive) |
| 1608 | { |
| 1609 | sr_err("%s: Load zip file error.", __func__); |
| 1610 | return SR_ERR; |
| 1611 | } |
| 1612 | if (unzLocateFile(archive, "header", 0) != UNZ_OK) |
| 1613 | { |
| 1614 | unzClose(archive); |
| 1615 | sr_err("%s: unzLocateFile error.", __func__); |
| 1616 | return SR_ERR; |
| 1617 | } |
| 1618 | if (unzGetCurrentFileInfo64(archive, &fileInfo, szFilePath, |
| 1619 | sizeof(szFilePath), NULL, 0, NULL, 0) != UNZ_OK) |
| 1620 | { |
| 1621 | unzClose(archive); |
| 1622 | sr_err("%s: unzGetCurrentFileInfo64 error.", __func__); |
| 1623 | return SR_ERR; |
| 1624 | } |
| 1625 | if (unzOpenCurrentFile(archive) != UNZ_OK) |
| 1626 | { |
| 1627 | sr_err("%s: Cant't open zip inner file.", __func__); |
| 1628 | unzClose(archive); |
| 1629 | return SR_ERR; |
| 1630 | } |
| 1631 |
no test coverage detected