From 53a32c2aeb0e1f95ecbe5693e6c297495f5bba80 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Tue, 14 Mar 2023 18:17:23 +0100 Subject: Generify the function to get the version --- src/list.c | 6 ------ src/list.h | 3 ++- src/version.c | 24 ++++++++++++++++++++++++ src/version.h | 25 +++++++++++++++++++++++++ test/test_list.c | 2 +- 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 src/version.c create mode 100644 src/version.h diff --git a/src/list.c b/src/list.c index ea038f4..d2fd682 100644 --- a/src/list.c +++ b/src/list.c @@ -115,9 +115,3 @@ clist_iterator_next(iterator_t *i) return data; } - -char * -clist_version(void) -{ - return VERSION; -} diff --git a/src/list.h b/src/list.h index da0793d..824b213 100644 --- a/src/list.h +++ b/src/list.h @@ -20,6 +20,8 @@ #ifndef _LIST_H_ #define _LIST_H_ +#include "version.h" + typedef struct list_item_t { void *data; struct list_item_t *next; @@ -42,6 +44,5 @@ void clist_remove (list_t *, list_item_t *); iterator_t clist_iterator (list_t *); int clist_iterator_has_next(iterator_t); void *clist_iterator_next (iterator_t *); -char* clist_version (void); #endif diff --git a/src/version.c b/src/version.c new file mode 100644 index 0000000..9255e7c --- /dev/null +++ b/src/version.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022-2023 Alessandro Iezzi + * + * This file is part of libutils. + * + * libutils is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libutils 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libutils. If not, see . + */ + +char * +utils_version() +{ + return VERSION; +} diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..cc42a65 --- /dev/null +++ b/src/version.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2022-2023 Alessandro Iezzi + * + * This file is part of libutils. + * + * libutils is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libutils 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libutils. If not, see . + */ + +#ifndef _VERSION_H_ +#define _VERSION_H_ + +char *utils_version(); + +#endif /* _VERSION_H_ */ diff --git a/test/test_list.c b/test/test_list.c index 8bfffe1..4df9203 100644 --- a/test/test_list.c +++ b/test/test_list.c @@ -173,7 +173,7 @@ test_list6() log("Running..."); char buff[127]; - sprintf(buff, "Version: %s", clist_version()); + sprintf(buff, "Version: %s", utils_version()); log(buff); log("OK\n"); -- cgit v1.2.3