From: Uwe Hermann Date: Thu, 19 Apr 2018 20:15:54 +0000 (+0200) Subject: input/null: Add a null module that discards all data. X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=2003be8cecbb516119b61b845ed5b0a87321f2e0 input/null: Add a null module that discards all data. This is useful for testing purposes. --- diff --git a/Makefile.am b/Makefile.am index 4929b283..707e796a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,7 +77,8 @@ libsigrok_la_SOURCES += \ src/input/raw_analog.c \ src/input/trace32_ad.c \ src/input/vcd.c \ - src/input/wav.c + src/input/wav.c \ + src/input/null.c # Output modules libsigrok_la_SOURCES += \ diff --git a/src/input/input.c b/src/input/input.c index 3db29ffe..2f2f3db8 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -66,6 +66,7 @@ extern SR_PRIV struct sr_input_module input_trace32_ad; extern SR_PRIV struct sr_input_module input_vcd; extern SR_PRIV struct sr_input_module input_wav; extern SR_PRIV struct sr_input_module input_raw_analog; +extern SR_PRIV struct sr_input_module input_null; /* @endcond */ static const struct sr_input_module *input_module_list[] = { @@ -76,6 +77,7 @@ static const struct sr_input_module *input_module_list[] = { &input_vcd, &input_wav, &input_raw_analog, + &input_null, NULL, }; diff --git a/src/input/null.c b/src/input/null.c new file mode 100644 index 00000000..031b553c --- /dev/null +++ b/src/input/null.c @@ -0,0 +1,59 @@ +/* + * This file is part of the libsigrok project. + * + * Copyright (C) 2018 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include "libsigrok-internal.h" + +#define LOG_PREFIX "input/null" + +static int init(struct sr_input *in, GHashTable *options) +{ + (void)in; + (void)options; + + return SR_OK; +} + +static int receive(struct sr_input *in, GString *buf) +{ + (void)in; + (void)buf; + + return SR_OK; +} + +static int end(struct sr_input *in) +{ + (void)in; + + return SR_OK; +} + +SR_PRIV struct sr_input_module input_null = { + .id = "null", + .name = "Null", + .desc = "Null input (discards all input)", + .exts = NULL, + .options = NULL, + .init = init, + .receive = receive, + .end = end, + .reset = NULL, +};