* @param filename The name of the session file to load.
* @param session The session to load the file into.
*
* @param filename The name of the session file to load.
* @param session The session to load the file into.
*
-SR_API int sr_session_load(const char *filename, struct sr_session **session)
+SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
+ struct sr_session **session)
char **sections, **keys, *metafile, *val;
char channelname[SR_MAX_CHANNELNAME_LEN + 1];
char **sections, **keys, *metafile, *val;
char channelname[SR_MAX_CHANNELNAME_LEN + 1];
keys = g_key_file_get_keys(kf, sections[i], NULL, NULL);
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
keys = g_key_file_get_keys(kf, sections[i], NULL, NULL);
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
sdi->driver = &session_driver;
sdi->status = SR_ST_ACTIVE;
if (!session_driver_initialized) {
/* first device, init the driver */
session_driver_initialized = 1;
sdi->driver = &session_driver;
sdi->status = SR_ST_ACTIVE;
if (!session_driver_initialized) {
/* first device, init the driver */
session_driver_initialized = 1;
g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_channels; p++) {
snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
g_variant_new_uint64(total_channels), sdi, NULL);
for (p = 0; p < total_channels; p++) {
snprintf(channelname, SR_MAX_CHANNELNAME_LEN, "%" PRIu64, p);
- if (!(ch = sr_channel_new(p, SR_CHANNEL_LOGIC, TRUE,
- channelname)))
- return SR_ERR;
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, p, SR_CHANNEL_LOGIC, FALSE,
+ channelname);
- enabled_channels++;
- tmp_u64 = strtoul(keys[j]+5, NULL, 10);
+ tmp_u64 = strtoul(keys[j]+5, NULL, 10) - 1;
+ ch = g_slist_nth_data(sdi->channels, tmp_u64);
- sr_dev_channel_name_set(sdi, tmp_u64 - 1, val);
+ sr_dev_channel_name_set(ch, val);
+ sr_dev_channel_enable(ch, TRUE);
close(tmpfile);
meta = g_fopen(metafile, "wb");
fprintf(meta, "[global]\n");
close(tmpfile);
meta = g_fopen(metafile, "wb");
fprintf(meta, "[global]\n");