aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-02-04 01:48:29 +0100
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-02-04 01:48:29 +0100
commit2d51bed54445c15086edb413156d2388ce597c24 (patch)
treeeeaabccfbe4a01752f47f45404ba50572e0ef38e
parent8ca441830f36111943860a98a21c736d4087bb2e (diff)
downloadlog-2d51bed54445c15086edb413156d2388ce597c24.tar.gz
log-2d51bed54445c15086edb413156d2388ce597c24.zip
Add function to get library version
-rw-r--r--Makefile3
-rw-r--r--src/log.c6
-rw-r--r--src/log.h1
-rw-r--r--test/main.c2
4 files changed, 11 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 1e10800..b831cbb 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,9 @@ SRC != find src -name "*.c"
OBJ = ${SRC:.c=.o}
LIBNAME = liblog
+LIBVER = 0
-CFLAGS = -Wall -ansi --std=c89 -pedantic ${OPT} ${LIBINC}
+CFLAGS = -Wall -ansi --std=c89 -pedantic ${OPT} ${LIBINC} -DLIBVER=\"${LIBVER}\"
LDFLAGS = ${LIBS}
dist: static shared
diff --git a/src/log.c b/src/log.c
index 85f94c9..a7605da 100644
--- a/src/log.c
+++ b/src/log.c
@@ -15,6 +15,12 @@
#define BUFF_SIZE 256
#define HALF_SIZE (BUFF_SIZE / 2 - 1)
+char *
+loglibver(void)
+{
+ return LIBVER;
+}
+
/* Checks if the terminal supports colors */
static int
check_term_colors()
diff --git a/src/log.h b/src/log.h
index 7fdfa92..84c9c72 100644
--- a/src/log.h
+++ b/src/log.h
@@ -20,5 +20,6 @@ int log_is_error(Log *);
int log_is_info(Log *);
int log_is_warn(Log *);
+char *loglibver(void);
#endif /* __LOG_H__ */
diff --git a/test/main.c b/test/main.c
index d8be980..475d23d 100644
--- a/test/main.c
+++ b/test/main.c
@@ -11,5 +11,7 @@ main(int argc, char **argv)
log_warn(log, "warning log");
log_error(log, "error log");
+ printf("Version: %s\n", loglibver());
+
return 0;
}