From: Uwe Hermann Date: Tue, 10 Feb 2015 20:38:21 +0000 (+0100) Subject: transform: Add a "nop" transform module. X-Git-Tag: libsigrok-0.4.0~655 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=39f1752eff0cde7eaedcc5ed950d56f4f244ea32 transform: Add a "nop" transform module. This doesn't do anything, just passes input packets on unmodified. --- diff --git a/Makefile.am b/Makefile.am index 00536456..e5012f36 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,7 +70,8 @@ libsigrok_la_SOURCES += \ # Transform modules libsigrok_la_SOURCES += \ - src/transform/transform.c + src/transform/transform.c \ + src/transform/nop.c # SCPI support libsigrok_la_SOURCES += \ diff --git a/src/transform/nop.c b/src/transform/nop.c new file mode 100644 index 00000000..8de2f2d7 --- /dev/null +++ b/src/transform/nop.c @@ -0,0 +1,49 @@ +/* + * This file is part of the libsigrok project. + * + * Copyright (C) 2015 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libsigrok.h" +#include "libsigrok-internal.h" + +#define LOG_PREFIX "transform/nop" + +static int receive(const struct sr_transform *t, + struct sr_datafeed_packet *packet_in, + struct sr_datafeed_packet **packet_out) +{ + if (!t || !t->sdi || !packet_in || !packet_out) + return SR_ERR_ARG; + + /* Do nothing, just pass on packets unmodified. */ + sr_spew("Received packet of type %d, passing on unmodified.", packet_in->type); + *packet_out = packet_in; + + return SR_OK; +} + +SR_PRIV struct sr_transform_module transform_nop = { + .id = "nop", + .name = "NOP", + .desc = "Do nothing", + .options = NULL, + .init = NULL, + .receive = receive, + .cleanup = NULL, +}; diff --git a/src/transform/transform.c b/src/transform/transform.c index 0c569a6f..7477dc45 100644 --- a/src/transform/transform.c +++ b/src/transform/transform.c @@ -39,9 +39,11 @@ */ /** @cond PRIVATE */ +extern SR_PRIV struct sr_transform_module transform_nop; /* @endcond */ static const struct sr_transform_module *transform_module_list[] = { + &transform_nop, NULL, };