X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fsession_file.c;h=dc4012d95ec6c3828c55f918dccc3e3d734d76c5;hb=f5c697bfe6d80c95051eaa1f52e1fefb54effa97;hp=fd0dbd07309f98f315726c3b0930020c9c8f9e93;hpb=7c69b528e4e216be213ff2a1bacaced6df3fe38f;p=libsigrok.git diff --git a/src/session_file.c b/src/session_file.c index fd0dbd07..dc4012d9 100644 --- a/src/session_file.c +++ b/src/session_file.c @@ -43,12 +43,14 @@ * @{ */ +/** @cond PRIVATE */ extern SR_PRIV struct sr_dev_driver session_driver; +/** @endcond */ static int session_driver_initialized = 0; #if !HAVE_ZIP_DISCARD -/* Replacement for zip_discard() if it isn't available. - */ +/* Replacement for zip_discard() if it isn't available. */ +/** @private */ SR_PRIV void sr_zip_discard(struct zip *archive) { if (zip_unchange_all(archive) < 0 || zip_close(archive) < 0) @@ -56,10 +58,15 @@ SR_PRIV void sr_zip_discard(struct zip *archive) } #endif -/** Read metadata entries from a session archive. +/** + * Read metadata entries from a session archive. + * * @param[in] archive An open ZIP archive. * @param[in] entry Stat buffer filled in for the metadata archive member. + * * @return A new key/value store containing the session metadata. + * + * @private */ SR_PRIV GKeyFile *sr_sessionfile_read_metadata(struct zip *archive, const struct zip_stat *entry) @@ -163,13 +170,14 @@ SR_PRIV int sr_sessionfile_check(const char *filename) return SR_OK; } +/** @private */ SR_PRIV struct sr_dev_inst *sr_session_prepare_sdi(const char *filename, struct sr_session **session) { struct sr_dev_inst *sdi = NULL; sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->driver = &session_driver; - sdi->status = SR_ST_ACTIVE; + sdi->status = SR_ST_INACTIVE; if (!session_driver_initialized) { /* first device, init the driver */ session_driver_initialized = 1; @@ -212,6 +220,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename, int unitsize; char **sections, **keys, *val; char channelname[SR_MAX_CHANNELNAME_LEN + 1]; + gboolean file_has_logic; if ((ret = sr_sessionfile_check(filename)) != SR_OK) return ret; @@ -233,8 +242,11 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename, return ret; } + total_channels = 0; + error = NULL; ret = SR_OK; + file_has_logic = FALSE; sections = g_key_file_get_groups(kf, NULL); for (i = 0; sections[i] && ret == SR_OK; i++) { if (!strcmp(sections[i], "global")) @@ -261,6 +273,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename, sr_config_set(sdi, NULL, SR_CONF_CAPTUREFILE, g_variant_new_string(val)); g_free(val); + file_has_logic = TRUE; } g_clear_error(&error); @@ -277,7 +290,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename, g_free(val); sr_config_set(sdi, NULL, SR_CONF_SAMPLERATE, g_variant_new_uint64(tmp_u64)); - } else if (!strcmp(keys[j], "unitsize")) { + } else if (!strcmp(keys[j], "unitsize") && file_has_logic) { unitsize = g_key_file_get_integer(kf, sections[i], keys[j], &error); if (!sdi || unitsize <= 0 || error) {