aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-03-14 18:17:23 +0100
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-03-14 18:17:23 +0100
commit53a32c2aeb0e1f95ecbe5693e6c297495f5bba80 (patch)
tree8bc20d0409734a3ce86f3af1b58a7e0b81694551
parentc9cb97f8acb76b317dd4d913438c1098e752e90c (diff)
downloadutils-53a32c2aeb0e1f95ecbe5693e6c297495f5bba80.tar.gz
utils-53a32c2aeb0e1f95ecbe5693e6c297495f5bba80.zip
Generify the function to get the version
-rw-r--r--src/list.c6
-rw-r--r--src/list.h3
-rw-r--r--src/version.c24
-rw-r--r--src/version.h25
-rw-r--r--test/test_list.c2
5 files changed, 52 insertions, 8 deletions
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 <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+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 <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+#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");