Functions such as nbdkit_error and nbdkit_debug which are not plugin specific. Also the NBDKIT_THREAD_MODEL macros which will be shared with filters. --- include/Makefile.am | 4 ++- include/nbdkit-common.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ include/nbdkit-plugin.h | 26 ++---------------- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index 7d54215..bc8adff 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -30,4 +30,6 @@ # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -include_HEADERS = nbdkit-plugin.h +include_HEADERS = \ + nbdkit-common.h \ + nbdkit-plugin.h diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h new file mode 100644 index 0000000..f8517d5 --- /dev/null +++ b/include/nbdkit-common.h @@ -0,0 +1,70 @@ +/* nbdkit + * Copyright (C) 2013-2018 Red Hat Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Red Hat nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef NBDKIT_COMMON_H +#define NBDKIT_COMMON_H + +#include <stdarg.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTIONS 0 +#define NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS 1 +#define NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS 2 +#define NBDKIT_THREAD_MODEL_PARALLEL 3 + +extern void nbdkit_error (const char *msg, ...) + __attribute__((format (printf, 1, 2))); +extern void nbdkit_verror (const char *msg, va_list args); +extern void nbdkit_debug (const char *msg, ...) + __attribute__((format (printf, 1, 2))); +extern void nbdkit_vdebug (const char *msg, va_list args); + +extern char *nbdkit_absolute_path (const char *path); +extern int64_t nbdkit_parse_size (const char *str); +extern int nbdkit_read_password (const char *value, char **password); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +#define NBDKIT_CXX_LANG_C extern "C" +#else +#define NBDKIT_CXX_LANG_C /* nothing */ +#endif + +#endif /* NBDKIT_COMMON_H */ diff --git a/include/nbdkit-plugin.h b/include/nbdkit-plugin.h index 2ec3b15..1981061 100644 --- a/include/nbdkit-plugin.h +++ b/include/nbdkit-plugin.h @@ -1,5 +1,5 @@ /* nbdkit - * Copyright (C) 2013-2017 Red Hat Inc. + * Copyright (C) 2013-2018 Red Hat Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,18 +36,12 @@ #ifndef NBDKIT_PLUGIN_H #define NBDKIT_PLUGIN_H -#include <stdarg.h> -#include <stdint.h> +#include <nbdkit-common.h> #ifdef __cplusplus extern "C" { #endif -#define NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTIONS 0 -#define NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS 1 -#define NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS 2 -#define NBDKIT_THREAD_MODEL_PARALLEL 3 - #define NBDKIT_API_VERSION 1 struct nbdkit_plugin { @@ -100,22 +94,6 @@ struct nbdkit_plugin { }; extern void nbdkit_set_error (int err); -extern void nbdkit_error (const char *msg, ...) - __attribute__((format (printf, 1, 2))); -extern void nbdkit_verror (const char *msg, va_list args); -extern void nbdkit_debug (const char *msg, ...) - __attribute__((format (printf, 1, 2))); -extern void nbdkit_vdebug (const char *msg, va_list args); - -extern char *nbdkit_absolute_path (const char *path); -extern int64_t nbdkit_parse_size (const char *str); -extern int nbdkit_read_password (const char *value, char **password); - -#ifdef __cplusplus -#define NBDKIT_CXX_LANG_C extern "C" -#else -#define NBDKIT_CXX_LANG_C /* nothing */ -#endif #define NBDKIT_REGISTER_PLUGIN(plugin) \ NBDKIT_CXX_LANG_C \ -- 2.15.1