* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <glib.h>
#include <glib/gstdio.h>
-#include "config.h" /* Needed for PACKAGE_VERSION and others. */
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
/** @cond PRIVATE */
extern SR_PRIV struct sr_dev_driver session_driver;
static int session_driver_initialized = 0;
-
/** @private */
SR_PRIV int sr_sessionfile_check(const char *filename)
{
return SR_ERR_ARG;
if (stat(filename, &st) == -1) {
- sr_err("Couldn't stat %s: %s", filename, strerror(errno));
+ sr_err("Couldn't stat %s: %s", filename, g_strerror(errno));
return SR_ERR;
}
/**
* Load the session from the specified filename.
*
+ * @param ctx The context in which to load the session.
* @param filename The name of the session file to load.
* @param session The session to load the file into.
*
* @retval SR_ERR_DATA Malformed session file
* @retval SR_ERR This is not a session file
*/
-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)
{
GKeyFile *kf;
GPtrArray *capturefiles;
return SR_ERR;
}
- if ((ret = sr_session_new(session)) != SR_OK)
+ if ((ret = sr_session_new(ctx, session)) != SR_OK)
return ret;
ret = SR_OK;
if (!session_driver_initialized) {
/* first device, init the driver */
session_driver_initialized = 1;
- sdi->driver->init(NULL);
+ sdi->driver->init(sdi->driver, NULL);
}
sr_dev_open(sdi);
sr_session_dev_add(*session, sdi);
close(tmpfile);
meta = g_fopen(metafile, "wb");
fprintf(meta, "[global]\n");
- fprintf(meta, "sigrok version = %s\n", PACKAGE_VERSION);
+ fprintf(meta, "sigrok version = %s\n", SR_PACKAGE_VERSION_STRING);
/* metadata */
fprintf(meta, "[device 1]\n");
if ((tmpfile = g_mkstemp(tmpname)) == -1)
return SR_ERR;
if (write(tmpfile, metafile, len) < 0) {
- sr_dbg("Failed to create new metadata: %s", strerror(errno));
+ sr_dbg("Failed to create new metadata: %s", g_strerror(errno));
g_free(metafile);
unlink(tmpname);
return SR_ERR;