Merge pull request #114 from BarbarossaTM/feature/compatiblity-layer

Introduce compatibility layer framework
This commit is contained in:
Maximilian Wilhelm 2020-10-18 03:27:46 +02:00 committed by GitHub
commit 80a590ca33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 1 deletions

View file

@ -38,7 +38,8 @@ LIBIFUPDOWN_SRC = \
libifupdown/execute.c \ libifupdown/execute.c \
libifupdown/lifecycle.c \ libifupdown/lifecycle.c \
libifupdown/config-parser.c \ libifupdown/config-parser.c \
libifupdown/config-file.c libifupdown/config-file.c \
libifupdown/compat.c \
LIBIFUPDOWN_OBJ = ${LIBIFUPDOWN_SRC:.c=.o} LIBIFUPDOWN_OBJ = ${LIBIFUPDOWN_SRC:.c=.o}
LIBIFUPDOWN_LIB = libifupdown.a LIBIFUPDOWN_LIB = libifupdown.a

View file

@ -261,6 +261,12 @@ ifupdown_main(int argc, char *argv[])
return EXIT_FAILURE; 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)) if (!lif_state_sync(&state, &collection))
{ {
fprintf(stderr, "%s: could not sync state\n", argv0); fprintf(stderr, "%s: could not sync state\n", argv0);

27
libifupdown/compat.c Normal file
View file

@ -0,0 +1,27 @@
/*
* libifupdown/compat.c
* Purpose: compatiblity glue to other implementations
*
* Copyright (c) 2020 Maximilian Wilhelm <max@sdn.clinic>
*
* 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 <stdbool.h>
#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;
}

23
libifupdown/compat.h Normal file
View file

@ -0,0 +1,23 @@
/*
* libifupdown/compat.h
* Purpose: compatiblity glue to other implementations
*
* Copyright (c) 2020 Maximilian Wilhelm <max@sdn.clinic>
*
* 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

View file

@ -29,6 +29,7 @@
#include "libifupdown/tokenize.h" #include "libifupdown/tokenize.h"
#include "libifupdown/config-file.h" #include "libifupdown/config-file.h"
#include "libifupdown/config-parser.h" #include "libifupdown/config-parser.h"
#include "libifupdown/compat.h"
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x))