* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <zip.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#define LOG_PREFIX "output/srzip"
{
struct out_context *outc;
+ (void)options;
+
+ if (strlen(o->filename) == 0) {
+ sr_info("srzip output module requires a file name, cannot save.");
+ return SR_ERR_ARG;
+ }
+
outc = g_malloc0(sizeof(struct out_context));
+ outc->filename = g_strdup(o->filename);
o->priv = outc;
- outc->filename = g_strdup(g_variant_get_string(g_hash_table_lookup(options, "filename"), NULL));
- if (strlen(outc->filename) == 0)
- return SR_ERR_ARG;
return SR_OK;
}
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);
fprintf(meta, "[device 1]\ncapturefile = logic-1\n");
fprintf(meta, "total probes = %d\n", g_slist_length(o->sdi->channels));
s = sr_samplerate_string(outc->samplerate);
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;
}
static struct sr_option options[] = {
- { "filename", "Filename", "File to write", NULL, NULL },
ALL_ZERO
};
.id = "srzip",
.name = "srzip",
.desc = "srzip session file",
+ .exts = (const char*[]){"sr", NULL},
+ .flags = SR_OUTPUT_INTERNAL_IO_HANDLING,
.options = get_options,
.init = init,
.receive = receive,
.cleanup = cleanup,
};
-