diff --git a/AUTHORS b/AUTHORS
index e69de29..0dd8989 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Thomas de Grivel <thoxdg@gmail.com>
+Judy Najnudel <judy.najnudel@gmail.com>
diff --git a/COPYING b/COPYING
deleted file mode 100644
index f84fe9a..0000000
--- a/COPYING
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index e69de29..0000000
--- a/ChangeLog
+++ /dev/null
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 8865734..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,368 +0,0 @@
-Installation Instructions
-*************************
-
- Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
-Foundation, Inc.
-
- Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved. This file is offered as-is,
-without warranty of any kind.
-
-Basic Installation
-==================
-
- Briefly, the shell command './configure && make && make install'
-should configure, build, and install this package. The following
-more-detailed instructions are generic; see the 'README' file for
-instructions specific to this package. Some packages provide this
-'INSTALL' file but do not implement all of the features documented
-below. The lack of an optional feature in a given package is not
-necessarily a bug. More recommendations for GNU packages can be found
-in *note Makefile Conventions: (standards)Makefile Conventions.
-
- The 'configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a 'Makefile' in each directory of the package.
-It may also create one or more '.h' files containing system-dependent
-definitions. Finally, it creates a shell script 'config.status' that
-you can run in the future to recreate the current configuration, and a
-file 'config.log' containing compiler output (useful mainly for
-debugging 'configure').
-
- It can also use an optional file (typically called 'config.cache' and
-enabled with '--cache-file=config.cache' or simply '-C') that saves the
-results of its tests to speed up reconfiguring. Caching is disabled by
-default to prevent problems with accidental use of stale cache files.
-
- If you need to do unusual things to compile the package, please try
-to figure out how 'configure' could check whether to do them, and mail
-diffs or instructions to the address given in the 'README' so they can
-be considered for the next release. If you are using the cache, and at
-some point 'config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file 'configure.ac' (or 'configure.in') is used to create
-'configure' by a program called 'autoconf'. You need 'configure.ac' if
-you want to change it or regenerate 'configure' using a newer version of
-'autoconf'.
-
- The simplest way to compile this package is:
-
- 1. 'cd' to the directory containing the package's source code and type
- './configure' to configure the package for your system.
-
- Running 'configure' might take a while. While running, it prints
- some messages telling which features it is checking for.
-
- 2. Type 'make' to compile the package.
-
- 3. Optionally, type 'make check' to run any self-tests that come with
- the package, generally using the just-built uninstalled binaries.
-
- 4. Type 'make install' to install the programs and any data files and
- documentation. When installing into a prefix owned by root, it is
- recommended that the package be configured and built as a regular
- user, and only the 'make install' phase executed with root
- privileges.
-
- 5. Optionally, type 'make installcheck' to repeat any self-tests, but
- this time using the binaries in their final installed location.
- This target does not install anything. Running this target as a
- regular user, particularly if the prior 'make install' required
- root privileges, verifies that the installation completed
- correctly.
-
- 6. You can remove the program binaries and object files from the
- source code directory by typing 'make clean'. To also remove the
- files that 'configure' created (so you can compile the package for
- a different kind of computer), type 'make distclean'. There is
- also a 'make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
- 7. Often, you can also type 'make uninstall' to remove the installed
- files again. In practice, not all packages have tested that
- uninstallation works correctly, even though it is required by the
- GNU Coding Standards.
-
- 8. Some packages, particularly those that use Automake, provide 'make
- distcheck', which can by used by developers to test that all other
- targets like 'make install' and 'make uninstall' work correctly.
- This target is generally not run by end users.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the 'configure' script does not know about. Run './configure --help'
-for details on some of the pertinent environment variables.
-
- You can give 'configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here is
-an example:
-
- ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you can use GNU 'make'. 'cd' to the
-directory where you want the object files and executables to go and run
-the 'configure' script. 'configure' automatically checks for the source
-code in the directory that 'configure' is in and in '..'. This is known
-as a "VPATH" build.
-
- With a non-GNU 'make', it is safer to compile the package for one
-architecture at a time in the source code directory. After you have
-installed the package for one architecture, use 'make distclean' before
-reconfiguring for another architecture.
-
- On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple '-arch' options to the
-compiler but only a single '-arch' option to the preprocessor. Like
-this:
-
- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
- CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
- CPP="gcc -E" CXXCPP="g++ -E"
-
- This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the 'lipo' tool if you have problems.
-
-Installation Names
-==================
-
- By default, 'make install' installs the package's commands under
-'/usr/local/bin', include files under '/usr/local/include', etc. You
-can specify an installation prefix other than '/usr/local' by giving
-'configure' the option '--prefix=PREFIX', where PREFIX must be an
-absolute file name.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like '--bindir=DIR' to specify different values for particular
-kinds of files. Run 'configure --help' for a list of the directories
-you can set and what kinds of files go in them. In general, the default
-for these options is expressed in terms of '${prefix}', so that
-specifying just '--prefix' will affect all of the other directory
-specifications that were not explicitly provided.
-
- The most portable way to affect installation locations is to pass the
-correct locations to 'configure'; however, many packages provide one or
-both of the following shortcuts of passing variable assignments to the
-'make install' command line to change installation locations without
-having to reconfigure or recompile.
-
- The first method involves providing an override variable for each
-affected directory. For example, 'make install
-prefix=/alternate/directory' will choose an alternate location for all
-directory configuration variables that were expressed in terms of
-'${prefix}'. Any directories that were specified during 'configure',
-but not in terms of '${prefix}', must each be overridden at install time
-for the entire installation to be relocated. The approach of makefile
-variable overrides for each directory variable is required by the GNU
-Coding Standards, and ideally causes no recompilation. However, some
-platforms have known limitations with the semantics of shared libraries
-that end up requiring recompilation when using this method, particularly
-noticeable in packages that use GNU Libtool.
-
- The second method involves providing the 'DESTDIR' variable. For
-example, 'make install DESTDIR=/alternate/directory' will prepend
-'/alternate/directory' before all installation names. The approach of
-'DESTDIR' overrides is not required by the GNU Coding Standards, and
-does not work on platforms that have drive letters. On the other hand,
-it does better at avoiding recompilation issues, and works well even
-when some directory options were not specified in terms of '${prefix}'
-at 'configure' time.
-
-Optional Features
-=================
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving 'configure' the
-option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
-
- Some packages pay attention to '--enable-FEATURE' options to
-'configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to '--with-PACKAGE' options, where PACKAGE
-is something like 'gnu-as' or 'x' (for the X Window System). The
-'README' should mention any '--enable-' and '--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, 'configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the 'configure' options '--x-includes=DIR' and
-'--x-libraries=DIR' to specify their locations.
-
- Some packages offer the ability to configure how verbose the
-execution of 'make' will be. For these packages, running './configure
---enable-silent-rules' sets the default to minimal output, which can be
-overridden with 'make V=1'; while running './configure
---disable-silent-rules' sets the default to verbose, which can be
-overridden with 'make V=0'.
-
-Particular systems
-==================
-
- On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
-is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
- ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
- HP-UX 'make' updates targets which have the same time stamps as their
-prerequisites, which makes it generally unusable when shipped generated
-files such as 'configure' are involved. Use GNU 'make' instead.
-
- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
-workaround. If GNU CC is not installed, it is therefore recommended to
-try
-
- ./configure CC="cc"
-
-and if that doesn't work, try
-
- ./configure CC="cc -nodtk"
-
- On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
-directory contains several dysfunctional programs; working variants of
-these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
-in your 'PATH', put it _after_ '/usr/bin'.
-
- On Haiku, software installed for all users goes in '/boot/common',
-not '/usr/local'. It is recommended to use the following options:
-
- ./configure --prefix=/boot/common
-
-Specifying the System Type
-==========================
-
- There may be some features 'configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on. Usually, assuming the package is built to be run on the
-_same_ architectures, 'configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-'--build=TYPE' option. TYPE can either be a short name for the system
-type, such as 'sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS
- KERNEL-OS
-
- See the file 'config.sub' for the possible values of each field. If
-'config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the option '--target=TYPE' to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with '--host=TYPE'.
-
-Sharing Defaults
-================
-
- If you want to set default values for 'configure' scripts to share,
-you can create a site shell script called 'config.site' that gives
-default values for variables like 'CC', 'cache_file', and 'prefix'.
-'configure' looks for 'PREFIX/share/config.site' if it exists, then
-'PREFIX/etc/config.site' if it exists. Or, you can set the
-'CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all 'configure' scripts look for a site script.
-
-Defining Variables
-==================
-
- Variables not defined in a site shell script can be set in the
-environment passed to 'configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the 'configure' command line, using 'VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-causes the specified 'gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
-Autoconf limitation. Until the limitation is lifted, you can use this
-workaround:
-
- CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-'configure' Invocation
-======================
-
- 'configure' recognizes the following options to control how it
-operates.
-
-'--help'
-'-h'
- Print a summary of all of the options to 'configure', and exit.
-
-'--help=short'
-'--help=recursive'
- Print a summary of the options unique to this package's
- 'configure', and exit. The 'short' variant lists options used only
- in the top level, while the 'recursive' variant lists options also
- present in any nested packages.
-
-'--version'
-'-V'
- Print the version of Autoconf used to generate the 'configure'
- script, and exit.
-
-'--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally 'config.cache'. FILE defaults to '/dev/null' to
- disable caching.
-
-'--config-cache'
-'-C'
- Alias for '--cache-file=config.cache'.
-
-'--quiet'
-'--silent'
-'-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to '/dev/null' (any error
- messages will still be shown).
-
-'--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- 'configure' can determine that directory automatically.
-
-'--prefix=DIR'
- Use DIR as the installation prefix. *note Installation Names:: for
- more details, including other options available for fine-tuning the
- installation locations.
-
-'--no-create'
-'-n'
- Run the configure checks, but stop before creating any output
- files.
-
-'configure' also accepts some other, not widely useful, options. Run
-'configure --help' for more details.
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index f3ecbdc..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-ACLOCAL_AMFLAGS = -I build-aux/m4
-
-SUBDIRS = librtbuf cli gtk3 lib
diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/NEWS
+++ /dev/null
diff --git a/README b/README
deleted file mode 100644
index e69de29..0000000
--- a/README
+++ /dev/null
diff --git a/README.md b/README.md
index f9801ff..c8cdf16 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,14 @@ Real time signal processing in ANSI C.
See https://rtbuf.kmx.io/
+## Installation
+
+```
+./configure
+make
+make install
+```
+
## Issues
signal/bandpass2 does not work
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 5f76331..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-set -e
-
-srcdir="$(dirname $0)"
-cd "$srcdir"
-
-which autoreconf >/dev/null || \
- (echo "configuration failed, please install autoconf first" && exit 1)
-
-autoreconf --install --force --warnings=all
diff --git a/config.subr b/config.subr
new file mode 100644
index 0000000..577dde2
--- /dev/null
+++ b/config.subr
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+c_lo_deps() {
+ echo >> ${CONFIG_MK}
+ $CC -M "$1" | sed -e 's/[.]o:/.lo:/' >> ${CONFIG_MK}
+}
+
+c2prog() {
+ echo "$@" | sed -e 's/[.]c$//' -e 's/[.]c / /g'
+}
+
+c2o() {
+ echo "$@" | sed -e 's/[.]c$/.o/' -e 's/[.]c /.o /g'
+}
+
+c2lo() {
+ echo "$@" | sed -e 's/[.]c$/.lo/' -e 's/[.]c /.lo /g'
+}
+
+c2la() {
+ echo "$@" | sed -e 's/[.]c$/.la/' -e 's/[.]c /.la /g'
+}
+
+CONFIG_MK=config.mk
+echo "# config.mk generated by configure" > ${CONFIG_MK}
+
+if test -z "$CC"; then
+ if test -n $(which cc); then
+ CC=cc
+ elif test -n $(which gcc); then
+ CC=gcc
+ fi
+fi
+echo "CC = $CC" >> ${CONFIG_MK}
+
+if test -x /usr/local/bin/libtool; then
+ LIBTOOL=/usr/local/bin/libtool
+else
+ LIBTOOL=libtool
+fi
+echo "LIBTOOL = $LIBTOOL" >> ${CONFIG_MK}
+
+if test -z "$INSTALL"; then
+ if test -x "$(which install)"; then
+ INSTALL=install
+ fi
+fi
+echo "INSTALL = $INSTALL" >> ${CONFIG_MK}
diff --git a/gtk3/rtbuf_gtk.gresource.xml b/gtk3/rtbuf_gtk.gresource.xml
deleted file mode 100644
index 41b0bcc..0000000
--- a/gtk3/rtbuf_gtk.gresource.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<gresources>
- <gresource prefix="/rtbuf/">
- <file>player_play.png</file>
- <file>player_stop.png</file>
- <file>rtbuf.png</file>
- <file preprocess="xml-stripblanks">rtbuf_input_widget.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_modular.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_output_widget.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_widget.ui</file>
- </gresource>
- <gresource prefix="/org/gtk/libgtk/icons/24x24/status/">
- <file>image-missing.png</file>
- </gresource>
-</gresources>
diff --git a/gtk3/rtbuf_gtk3.gresource.xml b/gtk3/rtbuf_gtk3.gresource.xml
new file mode 100644
index 0000000..41b0bcc
--- /dev/null
+++ b/gtk3/rtbuf_gtk3.gresource.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/rtbuf/">
+ <file>player_play.png</file>
+ <file>player_stop.png</file>
+ <file>rtbuf.png</file>
+ <file preprocess="xml-stripblanks">rtbuf_input_widget.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_modular.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_output_widget.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_widget.ui</file>
+ </gresource>
+ <gresource prefix="/org/gtk/libgtk/icons/24x24/status/">
+ <file>image-missing.png</file>
+ </gresource>
+</gresources>
diff --git a/gtk3/rtbuf_gtk3_connection.h b/gtk3/rtbuf_gtk3_connection.h
new file mode 100644
index 0000000..19efd9d
--- /dev/null
+++ b/gtk3/rtbuf_gtk3_connection.h
@@ -0,0 +1,31 @@
+#ifndef RTBUF_GTK_CONNECTION_H
+#define RTBUF_GTK_CONNECTION_H
+
+#include "rtbuf_input_widget.h"
+#include "rtbuf_output_widget.h"
+
+typedef struct rtbuf_gtk_connection s_rtbuf_gtk_connection;
+
+struct rtbuf_gtk_connection {
+ RtbufOutputWidget *output_widget;
+ RtbufInputWidget *input_widget;
+ s_rtbuf_gtk_connection *next;
+};
+
+void rtbuf_gtk_connection_init ();
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ();
+void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection);
+
+void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item);
+int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item);
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
+(s_rtbuf_gtk_connection *c,
+ RtbufOutputWidget *output_widget,
+ RtbufInputWidget *input_widget);
+
+void rtbuf_gtk_connection_remove_rtbuf (s_rtbuf_gtk_connection **head,
+ s_rtbuf *rtbuf);
+
+#endif
diff --git a/gtk3/rtbuf_gtk_connection.h b/gtk3/rtbuf_gtk_connection.h
deleted file mode 100644
index 19efd9d..0000000
--- a/gtk3/rtbuf_gtk_connection.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef RTBUF_GTK_CONNECTION_H
-#define RTBUF_GTK_CONNECTION_H
-
-#include "rtbuf_input_widget.h"
-#include "rtbuf_output_widget.h"
-
-typedef struct rtbuf_gtk_connection s_rtbuf_gtk_connection;
-
-struct rtbuf_gtk_connection {
- RtbufOutputWidget *output_widget;
- RtbufInputWidget *input_widget;
- s_rtbuf_gtk_connection *next;
-};
-
-void rtbuf_gtk_connection_init ();
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ();
-void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection);
-
-void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item);
-int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item);
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
-(s_rtbuf_gtk_connection *c,
- RtbufOutputWidget *output_widget,
- RtbufInputWidget *input_widget);
-
-void rtbuf_gtk_connection_remove_rtbuf (s_rtbuf_gtk_connection **head,
- s_rtbuf *rtbuf);
-
-#endif
diff --git a/librtbuf/Makefile.am b/librtbuf/Makefile.am
deleted file mode 100644
index 6b104f6..0000000
--- a/librtbuf/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-
-lib_LTLIBRARIES = librtbuf.la
-librtbuf_la_CFLAGS = ${LIBRTBUF_CFLAGS}
-librtbuf_la_LDFLAGS = -no-undefined
-librtbuf_la_LIBADD = ${LIBRTBUF_LIBS}
-librtbuf_la_SOURCES = \
- data.c \
- symbol.c \
- rtbuf_lib.c \
- rtbuf_type.c \
- rtbuf_proc.c \
- rtbuf_var.c \
- rtbuf.c
-
-rtbuf_includedir = $(includedir)/rtbuf
-rtbuf_include_HEADERS = \
- include/rtbuf/data.h \
- include/rtbuf/symbol.h \
- include/rtbuf/defs.h \
- include/rtbuf/lib.h \
- include/rtbuf/proc.h \
- include/rtbuf/type.h \
- include/rtbuf/var.h \
- include/rtbuf/rtbuf.h
diff --git a/librtbuf/configure b/librtbuf/configure
new file mode 100755
index 0000000..82be2b8
--- /dev/null
+++ b/librtbuf/configure
@@ -0,0 +1,42 @@
+#!/bin/sh
+set -e
+
+. ../config.subr
+
+LIB=librtbuf.la
+
+SOURCES="$(ls *.c | tr '\n' ' ')"
+echo "SOURCES = $SOURCES" >> ${CONFIG_MK}
+
+OBJECTS="$(c2lo "$SOURCES")"
+echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
+
+if test -d /usr/local/include; then
+ CPPFLAGS="-I/usr/local/include"
+fi
+CPPFLAGS="$CPPFLAGS -I./include"
+echo "CPPFLAGS = $CPPFLAGS" >> ${CONFIG_MK}
+
+if [ x"$DEBUG" = x"yes" ]; then
+ CFLAGS="-DDEBUG -O0 -ggdb"
+else
+ CFLAGS="-DNDEBUG -O3"
+fi
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c89 -pedantic"
+echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
+
+LDFLAGS=""
+echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
+
+LIBDIR=/usr/local/lib
+echo "LIBDIR = $LIBDIR" >> ${CONFIG_MK}
+
+for SRC in $SOURCES; do
+ SRC_LO="$(c2lo "$SRC")"
+ c_lo_deps $SRC
+ echo "\t${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
+done
+
+echo >> ${CONFIG_MK}
+echo "$LIB: $OBJECTS" >> ${CONFIG_MK}
+echo "\t${LIBTOOL} --tag=CC --mode=link \${CC} \${LDFLAGS} $OBJECTS -o $LIB -rpath ${LIBDIR}" >> ${CONFIG_MK}
diff --git a/librtbuf/data.c b/librtbuf/data.c
index 90373dc..7c62dd0 100644
--- a/librtbuf/data.c
+++ b/librtbuf/data.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -17,7 +17,7 @@
#include <assert.h>
#include <stdlib.h>
#include <strings.h>
-#include <rtbuf/data.h>
+#include "data.h"
s_data_type g_data_alloc_type = {
sizeof(s_data_alloc) * 8,
@@ -67,7 +67,7 @@ void * data_new_at (s_data_alloc *da, unsigned int i)
{
unsigned int octets = (da->t->bits + 7) / 8;
unsigned int offset = i * octets;
- void *m = da->mem + offset;
+ void *m = (char*) da->mem + offset;
bzero(m, octets);
if (da->init)
da->init(m);
@@ -118,7 +118,7 @@ void data_delete (s_data_alloc *da, void *data)
if (da->clean)
da->clean(data);
bzero(data, octets);
- i = (data - da->mem) / octets;
+ i = ((char*) data - (char*) da->mem) / octets;
da->free[da->free_n++] = i;
}
diff --git a/librtbuf/data.h b/librtbuf/data.h
new file mode 100644
index 0000000..e756285
--- /dev/null
+++ b/librtbuf/data.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef DATA_H
+#define DATA_H
+
+typedef enum {
+ DATA_TYPE_BITS,
+ DATA_TYPE_VECTOR,
+ DATA_TYPE_INTEGER,
+ DATA_TYPE_FLOAT,
+ DATA_TYPE_STRUCT
+} e_data_type;
+
+#define DATA_TYPE_SIGNED 1
+#define DATA_TYPE_BIG_ENDIAN 2
+
+typedef struct data_type {
+ unsigned int bits;
+ unsigned int type;
+} s_data_type;
+
+typedef struct data_type_vector {
+ s_data_type t;
+ s_data_type *element_type;
+ unsigned int nmemb;
+} s_data_type_vector;
+
+typedef struct data_type_integer {
+ s_data_type t;
+ unsigned int flags;
+} s_data_type_integer;
+
+typedef struct data_type_float {
+ s_data_type t;
+} s_data_type_float;
+
+typedef struct data_type_struct {
+ s_data_type t;
+ s_data_type *first;
+ struct data_type_struct *rest;
+} s_data_type_struct;
+
+typedef union data_type_ {
+ s_data_type t;
+ s_data_type_vector t_vector;
+ s_data_type_integer t_integer;
+ s_data_type_float t_float;
+ s_data_type_struct t_struct;
+} u_data_type;
+
+#define DATA_TYPE_MAX 1024
+
+u_data_type * data_type_new (unsigned int bits, unsigned int type);
+void data_type_delete (s_data_type *t);
+
+typedef void f_data_init (void *data);
+typedef void f_data_clean (void *data);
+
+typedef struct data_alloc {
+ s_data_type *t;
+ unsigned int max;
+ void *mem;
+ unsigned int n;
+ unsigned int *free;
+ unsigned int free_n;
+ f_data_init *init;
+ f_data_clean *clean;
+} s_data_alloc;
+
+#define DATA_ALLOC_MAX 1024
+
+void * data_new (s_data_alloc *da);
+int data_new_i (s_data_alloc *da);
+void data_delete (s_data_alloc *da, void *data);
+
+void data_alloc_init (s_data_alloc *da, s_data_type *t,
+ unsigned int max, f_data_init *init,
+ f_data_clean *clean);
+void data_alloc_clean (s_data_alloc *da);
+s_data_alloc * data_alloc_new (s_data_type *t,
+ unsigned int max, f_data_init *init,
+ f_data_clean *clean);
+void data_alloc_delete (s_data_alloc *da);
+
+int libdata_init ();
+
+#endif
diff --git a/librtbuf/defs.h b/librtbuf/defs.h
new file mode 100644
index 0000000..0830b88
--- /dev/null
+++ b/librtbuf/defs.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_DEFS_H
+#define RTBUF_DEFS_H
+
+typedef struct rtbuf s_rtbuf;
+typedef struct rtbuf_binding s_rtbuf_binding;
+typedef struct rtbuf_proc s_rtbuf_proc;
+typedef struct rtbuf_proc_in s_rtbuf_proc_in;
+typedef struct rtbuf_proc_out s_rtbuf_proc_out;
+typedef struct rtbuf_lib s_rtbuf_lib;
+typedef struct rtbuf_lib_proc s_rtbuf_lib_proc;
+typedef struct rtbuf_lib_proc_in s_rtbuf_lib_proc_in;
+typedef struct rtbuf_lib_proc_out s_rtbuf_lib_proc_out;
+typedef struct rtbuf_type s_rtbuf_type;
+typedef struct rtbuf_var s_rtbuf_var;
+typedef union rtbuf_var_data u_rtbuf_var_data;
+
+typedef enum rtbuf_var_type {
+ RTBUF_VAR_NULL = 0,
+ RTBUF_VAR_RTBUF = 1
+} e_rtbuf_var_type;
+
+typedef int f_rtbuf_proc (s_rtbuf *rtbuf);
+typedef int f_rtbuf_lib_init (s_rtbuf_lib *lib);
+
+#endif
diff --git a/librtbuf/include/rtbuf/data.h b/librtbuf/include/rtbuf/data.h
deleted file mode 100644
index 8e61f96..0000000
--- a/librtbuf/include/rtbuf/data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef DATA_H
-#define DATA_H
-
-typedef enum {
- DATA_TYPE_BITS,
- DATA_TYPE_VECTOR,
- DATA_TYPE_INTEGER,
- DATA_TYPE_FLOAT,
- DATA_TYPE_STRUCT
-} e_data_type;
-
-#define DATA_TYPE_SIGNED 1
-#define DATA_TYPE_BIG_ENDIAN 2
-
-typedef struct data_type {
- unsigned int bits;
- unsigned int type;
-} s_data_type;
-
-typedef struct data_type_vector {
- s_data_type t;
- s_data_type *element_type;
- unsigned int nmemb;
-} s_data_type_vector;
-
-typedef struct data_type_integer {
- s_data_type t;
- unsigned int flags;
-} s_data_type_integer;
-
-typedef struct data_type_float {
- s_data_type t;
-} s_data_type_float;
-
-typedef struct data_type_struct {
- s_data_type t;
- s_data_type *first;
- struct data_type_struct *rest;
-} s_data_type_struct;
-
-typedef union data_type_ {
- s_data_type t;
- s_data_type_vector t_vector;
- s_data_type_integer t_integer;
- s_data_type_float t_float;
- s_data_type_struct t_struct;
-} u_data_type;
-
-#define DATA_TYPE_MAX 1024
-
-u_data_type * data_type_new (unsigned int bits, unsigned int type);
-void data_type_delete (s_data_type *t);
-
-typedef void f_data_init (void *data);
-typedef void f_data_clean (void *data);
-
-typedef struct data_alloc {
- s_data_type *t;
- unsigned int max;
- void *mem;
- unsigned int n;
- unsigned int *free;
- unsigned int free_n;
- f_data_init *init;
- f_data_clean *clean;
-} s_data_alloc;
-
-#define DATA_ALLOC_MAX 1024
-
-void * data_new (s_data_alloc *da);
-int data_new_i (s_data_alloc *da);
-void data_delete (s_data_alloc *da, void *data);
-
-void data_alloc_init (s_data_alloc *da, s_data_type *t,
- unsigned int max, f_data_init *init,
- f_data_clean *clean);
-void data_alloc_clean (s_data_alloc *da);
-s_data_alloc * data_alloc_new (s_data_type *t,
- unsigned int max, f_data_init *init,
- f_data_clean *clean);
-void data_alloc_delete (s_data_alloc *da);
-
-int libdata_init ();
-
-#endif
diff --git a/librtbuf/include/rtbuf/defs.h b/librtbuf/include/rtbuf/defs.h
deleted file mode 100644
index 4d88bc7..0000000
--- a/librtbuf/include/rtbuf/defs.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_DEFS_H
-#define RTBUF_DEFS_H
-
-typedef struct rtbuf s_rtbuf;
-typedef struct rtbuf_binding s_rtbuf_binding;
-typedef struct rtbuf_proc s_rtbuf_proc;
-typedef struct rtbuf_proc_in s_rtbuf_proc_in;
-typedef struct rtbuf_proc_out s_rtbuf_proc_out;
-typedef struct rtbuf_lib s_rtbuf_lib;
-typedef struct rtbuf_lib_proc s_rtbuf_lib_proc;
-typedef struct rtbuf_lib_proc_in s_rtbuf_lib_proc_in;
-typedef struct rtbuf_lib_proc_out s_rtbuf_lib_proc_out;
-typedef struct rtbuf_type s_rtbuf_type;
-typedef struct rtbuf_var s_rtbuf_var;
-typedef union rtbuf_var_data u_rtbuf_var_data;
-
-typedef enum rtbuf_var_type {
- RTBUF_VAR_NULL = 0,
- RTBUF_VAR_RTBUF = 1
-} e_rtbuf_var_type;
-
-typedef int f_rtbuf_proc (s_rtbuf *rtbuf);
-typedef int f_rtbuf_lib_init (s_rtbuf_lib *lib);
-
-#endif
diff --git a/librtbuf/include/rtbuf/lib.h b/librtbuf/include/rtbuf/lib.h
deleted file mode 100644
index 5b9f4f8..0000000
--- a/librtbuf/include/rtbuf/lib.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_LIB_H
-#define RTBUF_LIB_H
-
-#include <rtbuf/defs.h>
-
-#define RTBUF_LIB_MAX 1000
-#define RTBUF_LIB_VER 0x00020001
-
-struct rtbuf_lib_proc_in {
- const char *name;
- const char *type;
- double def;
- double min;
- double max;
- double log_base;
-};
-
-struct rtbuf_lib_proc_out {
- const char *name;
- const char *type;
-};
-
-struct rtbuf_lib_proc {
- const char *name;
- f_rtbuf_proc *f;
- f_rtbuf_proc *start;
- f_rtbuf_proc *stop;
- s_rtbuf_lib_proc_in *in; /* inputs, end with NULL */
- s_rtbuf_lib_proc_out *out; /* outputs, end with NULL */
-};
-
-struct rtbuf_lib {
- const char *name;
- s_rtbuf_proc *proc;
- void *lib;
- const char *path;
-};
-
-extern char *g_rtbuf_lib_path[];
-
-extern s_data_alloc g_rtbuf_lib_alloc;
-extern s_rtbuf_lib *g_rtbuf_lib;
-
-void rtbuf_lib_delete (s_rtbuf_lib *rl);
-int rtbuf_lib_find (const char *str);
-void rtbuf_lib_init_ ();
-s_rtbuf_lib * rtbuf_lib_load (const char *path);
-s_rtbuf_lib * rtbuf_lib_new ();
-void rtbuf_lib_print (const s_rtbuf_lib *lib);
-void rtbuf_lib_print_long (unsigned int i);
-
-void rtbuf_lib_proc_var_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_in *in);
-void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_out *out);
-void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x);
-
-#endif
diff --git a/librtbuf/include/rtbuf/proc.h b/librtbuf/include/rtbuf/proc.h
deleted file mode 100644
index 32441dc..0000000
--- a/librtbuf/include/rtbuf/proc.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_PROC_H
-#define RTBUF_PROC_H
-
-#include <rtbuf/data.h>
-#include <rtbuf/defs.h>
-#include <rtbuf/symbol.h>
-
-struct rtbuf_proc_in {
- symbol name;
- const char *name_type;
- s_rtbuf_type *type;
- double def;
- double min;
- double max;
- double log_base;
- unsigned int offset;
-};
-
-struct rtbuf_proc_out {
- symbol name;
- const char *name_type;
- s_rtbuf_type *type;
- unsigned int offset;
-};
-
-#define RTBUF_PROC_IN_MAX 1024
-#define RTBUF_PROC_OUT_MAX 1024
-
-struct rtbuf_proc {
- symbol name;
- f_rtbuf_proc *f;
- f_rtbuf_proc *start;
- f_rtbuf_proc *stop;
- s_rtbuf_proc_in in[RTBUF_PROC_IN_MAX]; /* inputs */
- unsigned int in_n; /* number of inputs */
- unsigned int in_bytes; /* size of input data in bytes */
- s_rtbuf_proc_out out[RTBUF_PROC_OUT_MAX]; /* outputs */
- unsigned int out_n; /* number of outputs */
- unsigned int out_bytes; /* size of output data in bytes */
- s_rtbuf_lib *lib; /* the library this procedure comes from */
- unsigned int bytes; /* size of buffer data in bytes */
- s_data_type type;
- s_data_alloc alloc;
-};
-
-#define RTBUF_PROC_MAX 1024
-extern s_data_alloc g_rtbuf_proc_alloc;
-extern s_rtbuf_proc *g_rtbuf_proc;
-
-void rtbuf_proc_init ();
-int rtbuf_proc_p (s_rtbuf_proc *proc);
-s_rtbuf_proc * rtbuf_proc_new ();
-void rtbuf_proc_delete (s_rtbuf_proc *proc);
-s_rtbuf_proc * rtbuf_proc_find (const char *x);
-int rtbuf_proc_out_find (s_rtbuf_proc *proc,
- const char *name);
-void rtbuf_proc_print (s_rtbuf_proc *proc);
-
-#endif
diff --git a/librtbuf/include/rtbuf/queue.h b/librtbuf/include/rtbuf/queue.h
deleted file mode 100644
index f886dd3..0000000
--- a/librtbuf/include/rtbuf/queue.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef QUEUE_H
-#define QUEUE_H
-
-/* static queue */
-
-#define QUEUE_TYPE(type, size) \
- type ## _queue_ ## size
-
-#define QUEUE(type, size) \
- struct QUEUE_TYPE(type, size) { \
- unsigned int length; \
- unsigned int read_index; \
- unsigned int write_index; \
- type item[size]; \
- }
-
-#define S_QUEUE_TYPE(type, size) \
- s_ ## QUEUE_TYPE(type, size)
-
-#define QUEUE_METHOD(type, size, method) \
- QUEUE_TYPE(type, size) ## _ ## method
-
-#define DEFINE_QUEUE(type, size) \
- typedef QUEUE(type, size) S_QUEUE_TYPE(type, size); \
- static void QUEUE_METHOD(type, size, init) \
- (S_QUEUE_TYPE(type, size) *q) \
- { \
- bzero(q, sizeof(q)); \
- } \
- static void QUEUE_METHOD(type, size, free) \
- (S_QUEUE_TYPE(type, size) *q) \
- { \
- bzero(q, sizeof(q)); \
- } \
- static int QUEUE_METHOD(type, size, enqueue) \
- (S_QUEUE_TYPE(type, size) *q, type item) \
- { \
- if (q->length < size) { \
- unsigned int write_index = q->write_index; \
- q->write_index = (q->write_index + 1) % size; \
- q->item[write_index] = item; \
- q->length++; \
- return 0; \
- } \
- return -1; \
- } \
- static int QUEUE_METHOD(type, size, dequeue) \
- (S_QUEUE_TYPE(type, size) *q, type *ptr) \
- { \
- if (q->length > 0) { \
- unsigned int read_index = q->read_index; \
- q->read_index = (read_index + 1) % size; \
- *ptr = q->item[read_index]; \
- q->length--; \
- return 0; \
- } \
- return -1; \
- }
-
-#endif
diff --git a/librtbuf/include/rtbuf/rtbuf.h b/librtbuf/include/rtbuf/rtbuf.h
deleted file mode 100644
index bbabab5..0000000
--- a/librtbuf/include/rtbuf/rtbuf.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2018-2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_H
-#define RTBUF_H
-
-#include <rtbuf/data.h>
-#include <rtbuf/defs.h>
-#include <rtbuf/type.h>
-#include <rtbuf/proc.h>
-
-#define RTBUF_SORT 0x0001
-#define RTBUF_DELETE 0x0002
-#define RTBUF_NEW 0x0004
-#define RTBUF_READY 0x0008
-
-struct rtbuf_binding
-{
- int rtb;
- unsigned int out;
-};
-
-struct rtbuf
-{
- void *data;
- unsigned int flags;
- s_rtbuf_proc *proc;
- unsigned int refc;
- s_rtbuf_binding in[RTBUF_PROC_IN_MAX];
- unsigned int in_n;
- void *user_ptr;
-};
-
-#define RTBUF_MAX 10000
-#define RTBUF_INSTANCE_MAX 100
-
-extern s_data_alloc g_rtbuf_alloc;
-extern s_rtbuf *g_rtbuf;
-extern int g_rtbuf_run;
-
-typedef void (*f_rtbuf_new_cb) (s_rtbuf *rtb);
-typedef void (*f_rtbuf_delete_cb) (s_rtbuf *rtb);
-typedef void (*f_rtbuf_bind_cb) (s_rtbuf *src, unsigned int out,
- s_rtbuf *dest, unsigned int in);
-typedef void (*f_rtbuf_unbind_cb) (s_rtbuf *src, unsigned int out,
- s_rtbuf *dest, unsigned int in);
-
-extern f_rtbuf_new_cb g_rtbuf_new_cb;
-extern f_rtbuf_delete_cb g_rtbuf_delete_cb;
-extern f_rtbuf_bind_cb g_rtbuf_bind_cb;
-extern f_rtbuf_unbind_cb g_rtbuf_unbind_cb;
-
-int librtbuf_init ();
-
-int rtbuf_err (const char *msg);
-int rtbuf_new (s_rtbuf_proc *rp);
-int rtbuf_new_ptr (s_rtbuf_proc *rp, void *user_ptr);
-void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int in);
-void rtbuf_out_unbind (s_rtbuf *rtb, unsigned int out);
-void rtbuf_unbind_all (s_rtbuf *rtb);
-void rtbuf_delete (s_rtbuf *rtb);
-int rtbuf_clone (s_rtbuf *rtb);
-int rtbuf_find (symbol sym);
-int rtbuf_in_find (s_rtbuf *rtb, const char *x);
-void rtbuf_bind (unsigned int src, unsigned int out,
- s_rtbuf *dest, unsigned int in);
-int rtbuf_out_find (s_rtbuf *rtb, symbol sym);
-int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
- unsigned int size);
-void rtbuf_sort ();
-int rtbuf_start ();
-int rtbuf_run ();
-void rtbuf_stop ();
-void rtbuf_print (unsigned int i);
-void rtbuf_print_long (unsigned int i);
-void rtbuf_print_sorted ();
-
-int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value);
-
-double * rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in);
-
-double min (double a, double b);
-double max (double a, double b);
-double clamp (double inf, double x, double sup);
-
-#endif /* RTBUF_H */
diff --git a/librtbuf/include/rtbuf/symbol.h b/librtbuf/include/rtbuf/symbol.h
deleted file mode 100644
index c071589..0000000
--- a/librtbuf/include/rtbuf/symbol.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef SYMBOL_H
-#define SYMBOL_H
-
-#include <sys/types.h>
-
-typedef const char *symbol;
-
-#define STRING_MAX 65536
-extern char g_str_start[STRING_MAX];
-extern char *g_str;
-extern unsigned int g_str_n;
-extern unsigned int g_str_last;
-
-char * g_str_append (const char *str, size_t len);
-void g_str_reset (char *head);
-
-#define SYMBOL_MAX 32768
-extern symbol g_symbols[SYMBOL_MAX];
-extern unsigned int g_symbols_n;
-
-void symbols_init ();
-symbol symbol_new (symbol name);
-void symbol_delete (symbol sym);
-symbol symbol_find (symbol name);
-symbol symbol_intern (const char *name);
-
-#endif
diff --git a/librtbuf/include/rtbuf/type.h b/librtbuf/include/rtbuf/type.h
deleted file mode 100644
index 86b848d..0000000
--- a/librtbuf/include/rtbuf/type.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_TYPE_H
-#define RTBUF_TYPE_H
-
-#include <rtbuf/data.h>
-#include <rtbuf/defs.h>
-#include <rtbuf/symbol.h>
-
-struct rtbuf_type {
- symbol name;
- s_data_type t;
-};
-
-#define RTBUF_TYPE_MAX 1024
-
-void rtbuf_type_init ();
-s_rtbuf_type * rtbuf_type_new (const char *name,
- unsigned int size);
-void rtbuf_type_delete (s_rtbuf_type *rt);
-s_rtbuf_type * rtbuf_type_find (symbol name);
-s_rtbuf_type * rtbuf_type_define (const char *name,
- unsigned int size);
-s_rtbuf_type * rtbuf_type (const char *name);
-s_rtbuf_type * rtbuf_type_array (const char *element_type,
- unsigned int size);
-
-#define RTBUF_TYPE_CHAR_ARRAY(size) ("char[" #size "]")
-#define RTBUF_TYPE_SHORT_ARRAY(size) ("short[" #size "]")
-#define RTBUF_TYPE_DOUBLE_ARRAY(size) ("double[" #size "]")
-
-#endif
diff --git a/librtbuf/include/rtbuf/var.h b/librtbuf/include/rtbuf/var.h
deleted file mode 100644
index 0d37215..0000000
--- a/librtbuf/include/rtbuf/var.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef RTBUF_VAR_H
-#define RTBUF_VAR_H
-
-#include <rtbuf/defs.h>
-
-#define RTBUF_VAR_MAX 1000
-
-struct rtbuf_var {
- e_rtbuf_var_type type;
- const char *name;
- unsigned index;
-};
-
-void rtbuf_var_init (void);
-s_rtbuf_var * rtbuf_var_find (const char *name);
-s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i);
-void rtbuf_var_print (const s_rtbuf_var *v);
-
-#endif
diff --git a/librtbuf/lib.h b/librtbuf/lib.h
new file mode 100644
index 0000000..2d32ea8
--- /dev/null
+++ b/librtbuf/lib.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_LIB_H
+#define RTBUF_LIB_H
+
+#include "defs.h"
+
+#define RTBUF_LIB_MAX 1000
+#define RTBUF_LIB_VER 0x00020001
+
+struct rtbuf_lib_proc_in {
+ const char *name;
+ const char *type;
+ double def;
+ double min;
+ double max;
+ double log_base;
+};
+
+struct rtbuf_lib_proc_out {
+ const char *name;
+ const char *type;
+};
+
+struct rtbuf_lib_proc {
+ const char *name;
+ f_rtbuf_proc *f;
+ f_rtbuf_proc *start;
+ f_rtbuf_proc *stop;
+ s_rtbuf_lib_proc_in *in; /* inputs, end with NULL */
+ s_rtbuf_lib_proc_out *out; /* outputs, end with NULL */
+};
+
+struct rtbuf_lib {
+ const char *name;
+ s_rtbuf_proc *proc;
+ void *lib;
+ const char *path;
+};
+
+extern char *g_rtbuf_lib_path[];
+
+extern s_data_alloc g_rtbuf_lib_alloc;
+extern s_rtbuf_lib *g_rtbuf_lib;
+
+void rtbuf_lib_delete (s_rtbuf_lib *rl);
+int rtbuf_lib_find (const char *str);
+void rtbuf_lib_init_ ();
+s_rtbuf_lib * rtbuf_lib_load (const char *path);
+s_rtbuf_lib * rtbuf_lib_new ();
+void rtbuf_lib_print (const s_rtbuf_lib *lib);
+void rtbuf_lib_print_long (unsigned int i);
+
+void rtbuf_lib_proc_var_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_in *in);
+void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_out *out);
+void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x);
+
+#endif
diff --git a/librtbuf/proc.h b/librtbuf/proc.h
new file mode 100644
index 0000000..1650b90
--- /dev/null
+++ b/librtbuf/proc.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_PROC_H
+#define RTBUF_PROC_H
+
+#include "data.h"
+#include "defs.h"
+#include "symbol.h"
+
+struct rtbuf_proc_in {
+ symbol name;
+ const char *name_type;
+ s_rtbuf_type *type;
+ double def;
+ double min;
+ double max;
+ double log_base;
+ unsigned int offset;
+};
+
+struct rtbuf_proc_out {
+ symbol name;
+ const char *name_type;
+ s_rtbuf_type *type;
+ unsigned int offset;
+};
+
+#define RTBUF_PROC_IN_MAX 1024
+#define RTBUF_PROC_OUT_MAX 1024
+
+struct rtbuf_proc {
+ symbol name;
+ f_rtbuf_proc *f;
+ f_rtbuf_proc *start;
+ f_rtbuf_proc *stop;
+ s_rtbuf_proc_in in[RTBUF_PROC_IN_MAX]; /* inputs */
+ unsigned int in_n; /* number of inputs */
+ unsigned int in_bytes; /* size of input data in bytes */
+ s_rtbuf_proc_out out[RTBUF_PROC_OUT_MAX]; /* outputs */
+ unsigned int out_n; /* number of outputs */
+ unsigned int out_bytes; /* size of output data in bytes */
+ s_rtbuf_lib *lib; /* the library this procedure comes from */
+ unsigned int bytes; /* size of buffer data in bytes */
+ s_data_type type;
+ s_data_alloc alloc;
+};
+
+#define RTBUF_PROC_MAX 1024
+extern s_data_alloc g_rtbuf_proc_alloc;
+extern s_rtbuf_proc *g_rtbuf_proc;
+
+void rtbuf_proc_init ();
+int rtbuf_proc_p (s_rtbuf_proc *proc);
+s_rtbuf_proc * rtbuf_proc_new ();
+void rtbuf_proc_delete (s_rtbuf_proc *proc);
+s_rtbuf_proc * rtbuf_proc_find (const char *x);
+int rtbuf_proc_out_find (s_rtbuf_proc *proc,
+ const char *name);
+void rtbuf_proc_print (s_rtbuf_proc *proc);
+
+#endif
diff --git a/librtbuf/queue.h b/librtbuf/queue.h
new file mode 100644
index 0000000..fd28803
--- /dev/null
+++ b/librtbuf/queue.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef QUEUE_H
+#define QUEUE_H
+
+/* static queue */
+
+#define QUEUE_TYPE(type, size) \
+ type ## _queue_ ## size
+
+#define QUEUE(type, size) \
+ struct QUEUE_TYPE(type, size) { \
+ unsigned int length; \
+ unsigned int read_index; \
+ unsigned int write_index; \
+ type item[size]; \
+ }
+
+#define S_QUEUE_TYPE(type, size) \
+ s_ ## QUEUE_TYPE(type, size)
+
+#define QUEUE_METHOD(type, size, method) \
+ QUEUE_TYPE(type, size) ## _ ## method
+
+#define DEFINE_QUEUE(type, size) \
+ typedef QUEUE(type, size) S_QUEUE_TYPE(type, size); \
+ static void QUEUE_METHOD(type, size, init) \
+ (S_QUEUE_TYPE(type, size) *q) \
+ { \
+ bzero(q, sizeof(q)); \
+ } \
+ static void QUEUE_METHOD(type, size, free) \
+ (S_QUEUE_TYPE(type, size) *q) \
+ { \
+ bzero(q, sizeof(q)); \
+ } \
+ static int QUEUE_METHOD(type, size, enqueue) \
+ (S_QUEUE_TYPE(type, size) *q, type item) \
+ { \
+ if (q->length < size) { \
+ unsigned int write_index = q->write_index; \
+ q->write_index = (q->write_index + 1) % size; \
+ q->item[write_index] = item; \
+ q->length++; \
+ return 0; \
+ } \
+ return -1; \
+ } \
+ static int QUEUE_METHOD(type, size, dequeue) \
+ (S_QUEUE_TYPE(type, size) *q, type *ptr) \
+ { \
+ if (q->length > 0) { \
+ unsigned int read_index = q->read_index; \
+ q->read_index = (read_index + 1) % size; \
+ *ptr = q->item[read_index]; \
+ q->length--; \
+ return 0; \
+ } \
+ return -1; \
+ }
+
+#endif
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
index 9354139..e9fb1b4 100644
--- a/librtbuf/rtbuf.c
+++ b/librtbuf/rtbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -19,11 +19,11 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <rtbuf/data.h>
-#include <rtbuf/rtbuf.h>
-#include <rtbuf/lib.h>
-#include <rtbuf/var.h>
-#include <rtbuf/symbol.h>
+#include "data.h"
+#include "rtbuf.h"
+#include "lib.h"
+#include "var.h"
+#include "symbol.h"
s_data_type g_rtbuf_type = {
sizeof(s_rtbuf) * 8,
@@ -262,7 +262,7 @@ int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
if (out_i >= 0) {
s_rtbuf_proc_out *out = &rtb->proc->out[out_i];
if (out->type->t.bits == size * 8) {
- void *data = rtb->data + out->offset;
+ void *data = (char*) rtb->data + out->offset;
memcpy(data, value, size);
return size;
}
@@ -536,7 +536,7 @@ int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value)
o = &rtb->proc->out[out];
assert(o->type);
if (o->type->t.bits >= sizeof(int) * 8) {
- int *i = (int*)(rtb->data + o->offset);
+ int *i = (int*)((char*) rtb->data + o->offset);
return *i;
}
return default_value;
@@ -637,6 +637,6 @@ double * rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in)
assert(in < rtb->proc->in_n);
offset = rtb->proc->in[in].offset;
assert(offset < rtb->proc->bytes);
- p = rtb->data + offset;
+ p = (char*) rtb->data + offset;
return (double*) p;
}
diff --git a/librtbuf/rtbuf.h b/librtbuf/rtbuf.h
new file mode 100644
index 0000000..e7e6c66
--- /dev/null
+++ b/librtbuf/rtbuf.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_H
+#define RTBUF_H
+
+#include "data.h"
+#include "defs.h"
+#include "type.h"
+#include "proc.h"
+
+#define RTBUF_SORT 0x0001
+#define RTBUF_DELETE 0x0002
+#define RTBUF_NEW 0x0004
+#define RTBUF_READY 0x0008
+
+struct rtbuf_binding
+{
+ int rtb;
+ unsigned int out;
+};
+
+struct rtbuf
+{
+ void *data;
+ unsigned int flags;
+ s_rtbuf_proc *proc;
+ unsigned int refc;
+ s_rtbuf_binding in[RTBUF_PROC_IN_MAX];
+ unsigned int in_n;
+ void *user_ptr;
+};
+
+#define RTBUF_MAX 10000
+#define RTBUF_INSTANCE_MAX 100
+
+extern s_data_alloc g_rtbuf_alloc;
+extern s_rtbuf *g_rtbuf;
+extern int g_rtbuf_run;
+
+typedef void (*f_rtbuf_new_cb) (s_rtbuf *rtb);
+typedef void (*f_rtbuf_delete_cb) (s_rtbuf *rtb);
+typedef void (*f_rtbuf_bind_cb) (s_rtbuf *src, unsigned int out,
+ s_rtbuf *dest, unsigned int in);
+typedef void (*f_rtbuf_unbind_cb) (s_rtbuf *src, unsigned int out,
+ s_rtbuf *dest, unsigned int in);
+
+extern f_rtbuf_new_cb g_rtbuf_new_cb;
+extern f_rtbuf_delete_cb g_rtbuf_delete_cb;
+extern f_rtbuf_bind_cb g_rtbuf_bind_cb;
+extern f_rtbuf_unbind_cb g_rtbuf_unbind_cb;
+
+int librtbuf_init ();
+
+int rtbuf_err (const char *msg);
+int rtbuf_new (s_rtbuf_proc *rp);
+int rtbuf_new_ptr (s_rtbuf_proc *rp, void *user_ptr);
+void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int in);
+void rtbuf_out_unbind (s_rtbuf *rtb, unsigned int out);
+void rtbuf_unbind_all (s_rtbuf *rtb);
+void rtbuf_delete (s_rtbuf *rtb);
+int rtbuf_clone (s_rtbuf *rtb);
+int rtbuf_find (symbol sym);
+int rtbuf_in_find (s_rtbuf *rtb, const char *x);
+void rtbuf_bind (unsigned int src, unsigned int out,
+ s_rtbuf *dest, unsigned int in);
+int rtbuf_out_find (s_rtbuf *rtb, symbol sym);
+int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
+ unsigned int size);
+void rtbuf_sort ();
+int rtbuf_start ();
+int rtbuf_run ();
+void rtbuf_stop ();
+void rtbuf_print (unsigned int i);
+void rtbuf_print_long (unsigned int i);
+void rtbuf_print_sorted ();
+
+int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value);
+
+double * rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in);
+
+double min (double a, double b);
+double max (double a, double b);
+double clamp (double inf, double x, double sup);
+
+#endif /* RTBUF_H */
diff --git a/librtbuf/rtbuf_fun.c b/librtbuf/rtbuf_fun.c
deleted file mode 100644
index ea103e1..0000000
--- a/librtbuf/rtbuf_fun.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include "data.h"
-#include "rtbuf.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_proc_type = {
- sizeof(s_rtbuf_proc) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_proc_alloc;
-s_rtbuf_proc *g_rtbuf_proc;
-
-void rtbuf_proc_init ()
-{
- data_alloc_init(&g_rtbuf_proc_alloc, &g_rtbuf_proc_type,
- RTBUF_PROC_MAX, 0, 0);
-}
-
-int rtbuf_proc_p (s_rtbuf_proc *proc)
-{
- return proc && proc->name;
-}
-
-s_rtbuf_proc * rtbuf_proc_new ()
-{
- s_rtbuf_proc *rf = data_new(&g_rtbuf_proc_alloc);
- return rf;
-}
-
-void rtbuf_proc_delete (s_rtbuf_proc *proc)
-{
- assert(proc);
- data_delete(&g_rtbuf_proc_alloc, proc);
-}
-
-s_rtbuf_proc * rtbuf_proc_find (const char *x)
-{
- const char *sym = symbol_find(x);
- if (sym) {
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
- while (i < g_rtbuf_proc_alloc.n && n > 0) {
- if (rtbuf_proc_p(&g_rtbuf_proc[i])) {
- if (sym == g_rtbuf_proc[i].name)
- return &g_rtbuf_proc[i];
- n--;
- }
- i++;
- }
- }
- return 0;
-}
-
-int rtbuf_proc_out_find (s_rtbuf_proc *proc, const char *x)
-{
- symbol sym;
- if (x && '0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < proc->out_n)
- return i;
- }
- if ((sym = symbol_find(x))) {
- unsigned int i = 0;
- while (i < proc->out_n) {
- if (sym == proc->out[i].name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-void rtbuf_proc_print (s_rtbuf_proc *proc)
-{
- unsigned int i = 0;
- printf("#<proc %i %s (", proc->lib_proc, proc->name);
- while (i < proc->var_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->var[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->var[i].type->name, stdout);
- i++;
- }
- printf(") -> (");
- i = 0;
- while (i < proc->out_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->out[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->out[i].type->name, stdout);
- i++;
- }
- fputs(")>", stdout);
-}
diff --git a/librtbuf/rtbuf_lib.c b/librtbuf/rtbuf_lib.c
index ab21c4f..6d74b20 100644
--- a/librtbuf/rtbuf_lib.c
+++ b/librtbuf/rtbuf_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com>
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -21,10 +21,9 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
-
-#include <rtbuf/rtbuf.h>
-#include <rtbuf/lib.h>
-#include <rtbuf/symbol.h>
+#include "rtbuf.h"
+#include "lib.h"
+#include "symbol.h"
s_data_type g_rtbuf_lib_type = {
sizeof(s_rtbuf_lib) * 8,
@@ -281,7 +280,7 @@ void rtbuf_lib_print (const s_rtbuf_lib *lib)
(i = lib - g_rtbuf_lib) < RTBUF_LIB_MAX)
printf("#<lib %i %s>\n", i, lib->name);
else
- printf("#<lib %p %s>\n", lib, lib->name);
+ printf("#<lib %p %s>\n", (void*) lib, lib->name);
}
void rtbuf_lib_print_long (unsigned int i)
diff --git a/librtbuf/rtbuf_proc.c b/librtbuf/rtbuf_proc.c
index f3d98dd..eb3d8eb 100644
--- a/librtbuf/rtbuf_proc.c
+++ b/librtbuf/rtbuf_proc.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com>
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,9 +18,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
-#include <rtbuf/data.h>
-#include <rtbuf/rtbuf.h>
-#include <rtbuf/symbol.h>
+#include "data.h"
+#include "rtbuf.h"
+#include "symbol.h"
s_data_type g_rtbuf_proc_type = {
sizeof(s_rtbuf_proc) * 8,
diff --git a/librtbuf/rtbuf_type.c b/librtbuf/rtbuf_type.c
index 8bfb46c..5e24911 100644
--- a/librtbuf/rtbuf_type.c
+++ b/librtbuf/rtbuf_type.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -19,8 +19,8 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <rtbuf/type.h>
-#include <rtbuf/symbol.h>
+#include "type.h"
+#include "symbol.h"
extern int snprintf (char *, size_t, const char *, ...);
diff --git a/librtbuf/rtbuf_var.c b/librtbuf/rtbuf_var.c
index 5be53f3..1eaeb45 100644
--- a/librtbuf/rtbuf_var.c
+++ b/librtbuf/rtbuf_var.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com>
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,9 +16,9 @@
#include <assert.h>
#include <stdio.h>
-#include <rtbuf/data.h>
-#include <rtbuf/var.h>
-#include <rtbuf/rtbuf.h>
+#include "data.h"
+#include "var.h"
+#include "rtbuf.h"
s_data_type g_rtbuf_var_type = {
sizeof(s_rtbuf_var) * 8,
diff --git a/librtbuf/symbol.c b/librtbuf/symbol.c
index 6cf3001..17fae96 100644
--- a/librtbuf/symbol.c
+++ b/librtbuf/symbol.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <strings.h>
-#include <rtbuf/symbol.h>
+#include "symbol.h"
char g_str_start[STRING_MAX];
char *g_str = g_str_start;
diff --git a/librtbuf/symbol.h b/librtbuf/symbol.h
new file mode 100644
index 0000000..0a09cd4
--- /dev/null
+++ b/librtbuf/symbol.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+#include <sys/types.h>
+
+typedef const char *symbol;
+
+#define STRING_MAX 65536
+extern char g_str_start[STRING_MAX];
+extern char *g_str;
+extern unsigned int g_str_n;
+extern unsigned int g_str_last;
+
+char * g_str_append (const char *str, size_t len);
+void g_str_reset (char *head);
+
+#define SYMBOL_MAX 32768
+extern symbol g_symbols[SYMBOL_MAX];
+extern unsigned int g_symbols_n;
+
+void symbols_init ();
+symbol symbol_new (symbol name);
+void symbol_delete (symbol sym);
+symbol symbol_find (symbol name);
+symbol symbol_intern (const char *name);
+
+#endif
diff --git a/librtbuf/type.h b/librtbuf/type.h
new file mode 100644
index 0000000..3c3713b
--- /dev/null
+++ b/librtbuf/type.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_TYPE_H
+#define RTBUF_TYPE_H
+
+#include "data.h"
+#include "defs.h"
+#include "symbol.h"
+
+struct rtbuf_type {
+ symbol name;
+ s_data_type t;
+};
+
+#define RTBUF_TYPE_MAX 1024
+
+void rtbuf_type_init ();
+s_rtbuf_type * rtbuf_type_new (const char *name,
+ unsigned int size);
+void rtbuf_type_delete (s_rtbuf_type *rt);
+s_rtbuf_type * rtbuf_type_find (symbol name);
+s_rtbuf_type * rtbuf_type_define (const char *name,
+ unsigned int size);
+s_rtbuf_type * rtbuf_type (const char *name);
+s_rtbuf_type * rtbuf_type_array (const char *element_type,
+ unsigned int size);
+
+#define RTBUF_TYPE_CHAR_ARRAY(size) ("char[" #size "]")
+#define RTBUF_TYPE_SHORT_ARRAY(size) ("short[" #size "]")
+#define RTBUF_TYPE_DOUBLE_ARRAY(size) ("double[" #size "]")
+
+#endif
diff --git a/librtbuf/var.h b/librtbuf/var.h
new file mode 100644
index 0000000..5e7ce75
--- /dev/null
+++ b/librtbuf/var.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018-2021 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_VAR_H
+#define RTBUF_VAR_H
+
+#include "defs.h"
+
+#define RTBUF_VAR_MAX 1000
+
+struct rtbuf_var {
+ e_rtbuf_var_type type;
+ const char *name;
+ unsigned index;
+};
+
+void rtbuf_var_init (void);
+s_rtbuf_var * rtbuf_var_find (const char *name);
+s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i);
+void rtbuf_var_print (const s_rtbuf_var *v);
+
+#endif