X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=input.c;h=a4206e0e220bde32803566e56dfc73b4b617a976;hp=4f51e11553e3bb68c1c714610b28f5b7e3fb2922;hb=3addebb2440550f9b34a39629bdb7c1ab1d05fc3;hpb=f553109693c34861f14884b917139bef19d79000 diff --git a/input.c b/input.c index 4f51e11..a4206e0 100644 --- a/input.c +++ b/input.c @@ -17,8 +17,7 @@ * along with this program. If not, see . */ -#include "sigrok-cli.h" -#include "config.h" +#include #include #include #include @@ -27,8 +26,9 @@ #include #include #include +#include "sigrok-cli.h" -#define BUFSIZE 16384 +#define BUFSIZE (16 * 1024) static void load_input_file_module(void) { @@ -74,7 +74,7 @@ static void load_input_file_module(void) g_hash_table_destroy(mod_args); if ((fd = open(opt_input_file, O_RDONLY)) == -1) g_critical("Failed to load %s: %s.", opt_input_file, - strerror(errno)); + g_strerror(errno)); } else { if (strcmp(opt_input_file, "-")) { /* @@ -96,26 +96,26 @@ static void load_input_file_module(void) } else { if ((fd = open(opt_input_file, O_RDONLY)) == -1) g_critical("Failed to load %s: %s.", opt_input_file, - strerror(errno)); + g_strerror(errno)); } if ((len = read(fd, buf->str, BUFSIZE)) < 1) g_critical("Failed to read %s: %s.", opt_input_file, - strerror(errno)); + g_strerror(errno)); buf->len = len; sr_input_scan_buffer(buf, &in); } if (!in) g_critical("Error: no input module found for this file."); } - sr_session_new(&session); + sr_session_new(sr_ctx, &session); sr_session_datafeed_callback_add(session, &datafeed_in, NULL); got_sdi = FALSE; - while(TRUE) { + while (TRUE) { g_string_truncate(buf, 0); len = read(fd, buf->str, BUFSIZE); if (len < 0) - g_critical("Read failed: %s", strerror(errno)); + g_critical("Read failed: %s", g_strerror(errno)); if (len == 0) /* End of file or stream. */ break; @@ -124,7 +124,7 @@ static void load_input_file_module(void) break; sdi = sr_input_dev_inst_get(in); - if(!got_sdi && sdi) { + if (!got_sdi && sdi) { /* First time we got a valid sdi. */ if (select_channels(sdi) != SR_OK) return; @@ -135,7 +135,6 @@ static void load_input_file_module(void) } got_sdi = TRUE; } - } sr_input_end(in); sr_input_free(in); @@ -156,7 +155,8 @@ void load_input_file(void) /* Input from stdin is never a session file. */ load_input_file_module(); } else { - if ((ret = sr_session_load(opt_input_file, &session)) == SR_OK) { + if ((ret = sr_session_load(sr_ctx, opt_input_file, + &session)) == SR_OK) { /* sigrok session file */ ret = sr_session_dev_list(session, &devices); if (ret != SR_OK || !devices || !devices->data) {