X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Foutput%2Fsrzip.c;h=476ed57a2083cd178d3bc6800b10cbb7775858a1;hb=7237e91262251a138cf150f9fcfe7b05d0e5904b;hp=84755a3d56c42429c6dc9a97fe081f50e7b3d750;hpb=1beccaed464a4d92a070988a0331fe399f9f7a7a;p=libsigrok.git diff --git a/src/output/srzip.c b/src/output/srzip.c index 84755a3d..476ed57a 100644 --- a/src/output/srzip.c +++ b/src/output/srzip.c @@ -24,7 +24,7 @@ #include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #define LOG_PREFIX "output/srzip" @@ -39,11 +39,16 @@ static int init(struct sr_output *o, GHashTable *options) { 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; } @@ -91,7 +96,7 @@ static int zip_create(const struct sr_output *o) 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); @@ -181,7 +186,7 @@ static int zip_append(const struct sr_output *o, unsigned char *buf, 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; @@ -296,7 +301,6 @@ static int cleanup(struct sr_output *o) } static struct sr_option options[] = { - { "filename", "Filename", "File to write", NULL, NULL }, ALL_ZERO }; @@ -313,6 +317,7 @@ SR_PRIV struct sr_output_module output_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,