From d96f579d7f01afc2a6743287792c7b87bb33542a Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Sun, 18 Oct 2020 03:19:28 +0200 Subject: [PATCH] Introduce an compatibility layer which is empty for now. Signed-off-by: Maximilian Wilhelm --- Makefile | 3 ++- cmd/ifupdown.c | 6 ++++++ libifupdown/compat.c | 27 +++++++++++++++++++++++++++ libifupdown/compat.h | 23 +++++++++++++++++++++++ libifupdown/libifupdown.h | 1 + 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 libifupdown/compat.c create mode 100644 libifupdown/compat.h diff --git a/Makefile b/Makefile index a87ef80..a362e75 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,8 @@ LIBIFUPDOWN_SRC = \ libifupdown/execute.c \ libifupdown/lifecycle.c \ libifupdown/config-parser.c \ - libifupdown/config-file.c + libifupdown/config-file.c \ + libifupdown/compat.c \ LIBIFUPDOWN_OBJ = ${LIBIFUPDOWN_SRC:.c=.o} LIBIFUPDOWN_LIB = libifupdown.a diff --git a/cmd/ifupdown.c b/cmd/ifupdown.c index 1edc2d0..da133c2 100644 --- a/cmd/ifupdown.c +++ b/cmd/ifupdown.c @@ -261,6 +261,12 @@ ifupdown_main(int argc, char *argv[]) return EXIT_FAILURE; } + if(!lif_compat_apply(&collection)) + { + fprintf(stderr, "%s: failed to apply compatibility glue\n", argv0); + return EXIT_FAILURE; + } + if (!lif_state_sync(&state, &collection)) { fprintf(stderr, "%s: could not sync state\n", argv0); diff --git a/libifupdown/compat.c b/libifupdown/compat.c new file mode 100644 index 0000000..10a16d7 --- /dev/null +++ b/libifupdown/compat.c @@ -0,0 +1,27 @@ +/* + * libifupdown/compat.c + * Purpose: compatiblity glue to other implementations + * + * Copyright (c) 2020 Maximilian Wilhelm + * + * Permission to use, copy, modify, and/or 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. + * + * This software is provided 'as is' and without any warranty, express or + * implied. In no event shall the authors be liable for any damages arising + * from the use of this software. + */ + +#include +#include "libifupdown/dict.h" + +extern bool +lif_compat_apply(struct lif_dict *collection) +{ + (void) collection; + + /* Mangle interfaces according to some config options here */ + + return true; +} diff --git a/libifupdown/compat.h b/libifupdown/compat.h new file mode 100644 index 0000000..ebb668b --- /dev/null +++ b/libifupdown/compat.h @@ -0,0 +1,23 @@ +/* + * libifupdown/compat.h + * Purpose: compatiblity glue to other implementations + * + * Copyright (c) 2020 Maximilian Wilhelm + * + * Permission to use, copy, modify, and/or 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. + * + * This software is provided 'as is' and without any warranty, express or + * implied. In no event shall the authors be liable for any damages arising + * from the use of this software. + */ + +#ifndef LIBIFUPDOWN__COMPAT_H +#define LIBIFUPDOWN__COMPAT_H + +#include "libifupdown/config-file.h" + +extern bool lif_compat_apply (struct lif_dict *collection); + +#endif diff --git a/libifupdown/libifupdown.h b/libifupdown/libifupdown.h index 6459c6a..823adb0 100644 --- a/libifupdown/libifupdown.h +++ b/libifupdown/libifupdown.h @@ -29,6 +29,7 @@ #include "libifupdown/tokenize.h" #include "libifupdown/config-file.h" #include "libifupdown/config-parser.h" +#include "libifupdown/compat.h" #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))