]> sigrok.org Git - libsigrok.git/blobdiff - session.c
MinGW: Build fix.
[libsigrok.git] / session.c
index 13b7a241a9cbf43555d72a5acf35e9c86577b7ef..58116e758ab5668bb88baa302bf4d2f229542da5 100644 (file)
--- a/session.c
+++ b/session.c
@@ -26,6 +26,8 @@
 #include <sigrok.h>
 #include <config.h>
 
+/* demo.c */
+extern GIOChannel channels[2];
 
 /* There can only be one session at a time. */
 struct session *session;
@@ -83,19 +85,19 @@ void session_device_clear(void)
        session->devices = NULL;
 }
 
-int session_device_add(struct device *device)
+int session_device_add(struct sr_device *device)
 {
        int ret;
 
        if (device->plugin && device->plugin->open) {
                ret = device->plugin->open(device->plugin_index);
-               if (ret != SIGROK_OK)
+               if (ret != SR_OK)
                        return ret;
        }
 
        session->devices = g_slist_append(session->devices, device);
 
-       return SIGROK_OK;
+       return SR_OK;
 }
 
 void session_pa_clear(void)
@@ -127,7 +129,7 @@ void session_datafeed_callback_add(datafeed_callback callback)
 
 int session_start(void)
 {
-       struct device *device;
+       struct sr_device *device;
        GSList *l;
        int ret;
 
@@ -135,7 +137,7 @@ int session_start(void)
        for (l = session->devices; l; l = l->next) {
                device = l->data;
                if ((ret = device->plugin->start_acquisition(
-                               device->plugin_index, device)) != SIGROK_OK)
+                               device->plugin_index, device)) != SR_OK)
                        break;
        }
 
@@ -196,7 +198,7 @@ void session_halt(void)
 
 void session_stop(void)
 {
-       struct device *device;
+       struct sr_device *device;
        GSList *l;
 
        g_message("stopping session");
@@ -209,7 +211,7 @@ void session_stop(void)
 
 }
 
-void session_bus(struct device *device, struct datafeed_packet *packet)
+void session_bus(struct sr_device *device, struct sr_datafeed_packet *packet)
 {
        GSList *l;
        datafeed_callback cb;
@@ -228,7 +230,7 @@ int session_save(char *filename)
 {
        GSList *l, *p, *d;
        FILE *meta;
-       struct device *device;
+       struct sr_device *device;
        struct probe *probe;
        struct datastore *ds;
        struct zip *zipfile;
@@ -244,23 +246,23 @@ int session_save(char *filename)
        /* Quietly delete it first, libzip wants replace ops otherwise. */
        unlink(newfn);
        if (!(zipfile = zip_open(newfn, ZIP_CREATE, &error)))
-               return SIGROK_ERR;
+               return SR_ERR;
        g_free(newfn);
 
        /* "version" */
        version[0] = '1';
        if (!(versrc = zip_source_buffer(zipfile, version, 1, 0)))
-               return SIGROK_ERR;
+               return SR_ERR;
        if (zip_add(zipfile, "version", versrc) == -1) {
                g_message("error saving version into zipfile: %s",
                          zip_strerror(zipfile));
-               return SIGROK_ERR;
+               return SR_ERR;
        }
 
        /* init "metadata" */
        strcpy(metafile, "sigrok-meta-XXXXXX");
        if ((tmpfile = g_mkstemp(metafile)) == -1)
-               return SIGROK_ERR;
+               return SR_ERR;
        close(tmpfile);
        meta = fopen(metafile, "wb");
        fprintf(meta, "sigrok version = %s\n", PACKAGE_VERSION);
@@ -303,28 +305,28 @@ int session_save(char *filename)
                        }
                        if (!(logicsrc = zip_source_buffer(zipfile, buf,
                                       ds->num_units * ds->ds_unitsize, TRUE)))
-                               return SIGROK_ERR;
+                               return SR_ERR;
                        snprintf(rawname, 15, "logic-%d", devcnt);
                        if (zip_add(zipfile, rawname, logicsrc) == -1)
-                               return SIGROK_ERR;
+                               return SR_ERR;
                }
                devcnt++;
        }
        fclose(meta);
 
        if (!(metasrc = zip_source_file(zipfile, metafile, 0, -1)))
-               return SIGROK_ERR;
+               return SR_ERR;
        if (zip_add(zipfile, "metadata", metasrc) == -1)
-               return SIGROK_ERR;
+               return SR_ERR;
 
        if ((ret = zip_close(zipfile)) == -1) {
                g_message("error saving zipfile: %s", zip_strerror(zipfile));
-               return SIGROK_ERR;
+               return SR_ERR;
        }
 
        unlink(metafile);
 
-       return SIGROK_OK;
+       return SR_OK;
 }
 
 void session_source_add(int fd, int events, int timeout,