From: Uwe Hermann Date: Thu, 19 Apr 2018 18:10:50 +0000 (+0200) Subject: output/null: Add a null module that discards all data. X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=1af7497d6733e00b050b25c6d0fbad3ea62c7136 output/null: Add a null module that discards all data. This is useful for testing purposes. --- diff --git a/Makefile.am b/Makefile.am index 5a46ed31..4929b283 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,7 +92,8 @@ libsigrok_la_SOURCES += \ src/output/hex.c \ src/output/ols.c \ src/output/srzip.c \ - src/output/vcd.c + src/output/vcd.c \ + src/output/null.c # Transform modules libsigrok_la_SOURCES += \ diff --git a/src/output/null.c b/src/output/null.c new file mode 100644 index 00000000..94faf4bf --- /dev/null +++ b/src/output/null.c @@ -0,0 +1,46 @@ +/* + * 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 +#include "libsigrok-internal.h" + +#define LOG_PREFIX "output/null" + +static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet, + GString **out) +{ + (void)o; + (void)packet; + + *out = NULL; + + return SR_OK; +} + +SR_PRIV struct sr_output_module output_null = { + .id = "null", + .name = "Null output", + .desc = "Null output (discards all data)", + .exts = NULL, + .flags = 0, + .options = NULL, + .receive = receive, +}; diff --git a/src/output/output.c b/src/output/output.c index efb205c6..c6c2d720 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -64,6 +64,7 @@ extern SR_PRIV struct sr_output_module output_csv; extern SR_PRIV struct sr_output_module output_analog; extern SR_PRIV struct sr_output_module output_srzip; extern SR_PRIV struct sr_output_module output_wav; +extern SR_PRIV struct sr_output_module output_null; /* @endcond */ static const struct sr_output_module *output_module_list[] = { @@ -78,6 +79,7 @@ static const struct sr_output_module *output_module_list[] = { &output_analog, &output_srzip, &output_wav, + &output_null, NULL, };