From ee986164d354f4d7094f7e0fb4fcea31170f5661 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Fri, 3 Feb 2023 22:41:09 +0100 Subject: Add function to get libraryversion --- Makefile | 3 ++- src/string2.c | 6 ++++++ src/string2.h | 5 +++-- test/main.c | 1 + test/test1.c | 7 +++++++ test/test1.h | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b3f85e3..c6643d4 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,9 @@ SRC != find src -name '*.c' OBJ = ${SRC:.c=.o} LIBNAME = libstr +LIBVER = 0.0.0a1 -CFLAGS = -Wall -ansi --std=c89 -pedantic ${OPT} +CFLAGS = -Wall -ansi --std=c89 -pedantic ${OPT} -DLIBVER=\"${LIBVER}\" LDFLAGS = dist: diff --git a/src/string2.c b/src/string2.c index 332dbf7..6050ea2 100644 --- a/src/string2.c +++ b/src/string2.c @@ -44,3 +44,9 @@ strstarts(const char *str, const char *end) return 0; } + +char * +strlibver(void) +{ + return LIBVER; +} diff --git a/src/string2.h b/src/string2.h index 4d79dfd..e927470 100644 --- a/src/string2.h +++ b/src/string2.h @@ -5,7 +5,8 @@ #include -int strends(const char *, const char *); -int strstarts(const char *, const char *); +int strends(const char *, const char *); +int strstarts(const char *, const char *); +char *strlibver(void); #endif /* __STRING2_H__ */ diff --git a/test/main.c b/test/main.c index f6be903..25e1993 100644 --- a/test/main.c +++ b/test/main.c @@ -7,6 +7,7 @@ main(int argc, char **argv) { test1(); test2(); + test3(); return 0; } diff --git a/test/test1.c b/test/test1.c index 777aa5f..3f52c93 100644 --- a/test/test1.c +++ b/test/test1.c @@ -30,3 +30,10 @@ test2(void) printf("OK\n"); } + +void +test3() +{ + printf("executing %s... OK\n", __func__); + printf("%s\n", strlibver()); +} diff --git a/test/test1.h b/test/test1.h index 1b88561..79bab4c 100644 --- a/test/test1.h +++ b/test/test1.h @@ -5,5 +5,6 @@ void test1(void); void test2(void); +void test3(void); #endif /* __TEST1_H__ */ -- cgit v1.2.3