aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM.Gergő2020-05-27 02:56:06 +0200
committerM.Gergő2020-05-27 02:56:06 +0200
commitf95ba68da990aef8cd66ef934c7daf3d372c52de (patch)
treeb411ef28067f7981c67171bbd32599536ef7bac9
parentf7ad1d4158a1efaf620801673b364a3705b98aef (diff)
downloadlightconfini-f95ba68da990aef8cd66ef934c7daf3d372c52de.tar.gz
lightconfini-f95ba68da990aef8cd66ef934c7daf3d372c52de.zip
New function: lciniGetVersionStr()
-rw-r--r--makefile16
-rw-r--r--src/ini_read.c10
-rw-r--r--src/lightconfini.h1
-rw-r--r--src/main.c9
4 files changed, 28 insertions, 8 deletions
diff --git a/makefile b/makefile
index 5369f24..95975f7 100644
--- a/makefile
+++ b/makefile
@@ -12,10 +12,12 @@ CP = -/bin/cp
# fordíto általános flagek
PWD = $(shell pwd)
+#LASTVER = 2.0.0
LASTVER = $(shell git describe)
LASTVERT = $(shell git describe --tags --abbrev=0)
LASTMAINT = $(firstword $(subst ., ,$(LASTVERT)))
-CFLAGS = -Wall -c -D"GIT_LAST=$(LASTVER)" -D"GIT_LASTT=$(LASTVERT)" -D"GIT_MAINT=$(LASTMAINT)"
+VERSTRING = -D"GIT_LAST=\"$(LASTVER)\"" -D"GIT_LASTT=\"$(LASTVERT)\"" -D"GIT_MAINT=\"$(LASTMAINT)\""
+CFLAGS = -Wall -c $(VERSTRING)
LDFLAGS =
LDLIBS =
PREP=
@@ -25,7 +27,6 @@ BINDIR = bin
LIBDIR = libdir
OBJDIR = build
SRCDIR = src
-#LASTVER = 2.0.0
# .o fájlok
@@ -51,19 +52,20 @@ testlib: clean mkdir main
testlibd: clean mkdir main
# debug-hoz felüldefiniálva
-debug: CFLAGS = -Wall -c -O0 -g -g3 -ggdb -std=c89 -Wpedantic -Wmissing-prototypes -D"GIT_LAST=$(LASTVER)" -D"GIT_LASTT=$(LASTVERT)" -D"GIT_MAINT=$(LASTMAINT)"
+debug: CFLAGS = -Wall -c -O0 -g -g3 -ggdb -std=c89 -Wpedantic -Wmissing-prototypes $(VERSTRING)
debug: LDLIBS = -lefence
# make lib FLAGS: not link: -c, relative addresses: -fPIC
-lib: CFLAGS = -fPIC -c -Wall -D"GIT_LAST=$(LASTVER)" -D"GIT_LASTT=$(LASTVERT)" -D"GIT_MAINT=$(LASTMAINT)"
+lib: CFLAGS = -fPIC -c -Wall $(VERSTRING)
lib: LDFLAGS = -shared -Wl,-soname,liblightconfini.so.$(LASTMAINT)
lib: LDLIBS = -lc
# nem mindegy, hogy mellette van, vagy alatta egy sorral!
-#testlib: LDFLAGS = -L $(PWD)/$(LIBDIR)/
+testlib: LDFLAGS = -L $(PWD)/$(LIBDIR)/
testlib: LDLIBS = -llightconfini
#Dinamikus betöltés tesztelése
testlibd: LDFLAGS = -rdynamic
testlibd: LDLIBS = -ldl
testlibd: PREP = -D"TESTLIBD"
+#Load lib from /user/local/lib/
#testlibd: PREP = -D"TESTLIBD" -D"LIBINSTALLED"
@@ -98,13 +100,13 @@ rebuild: clean all
copylib:
$(CP) -f $(SRCDIR)/lightconfini.h /usr/local/include/
- $(CP) -f $(LIBDIR)/* /usr/local/lib/
+ $(CP) -fd $(LIBDIR)/* /usr/local/lib/
ln -sf /usr/local/lib/liblightconfini.so.$(LASTVERT) /usr/local/lib/liblightconfini.so
ldconfig
ldconf:
ln -sf $(PWD)/$(LIBDIR)/liblightconfini.so.$(LASTVERT) $(PWD)/$(LIBDIR)/liblightconfini.so
- #ldconfig -n $(PWD)/$(LIBDIR)/
+ ldconfig -n $(PWD)/$(LIBDIR)/
mkdir:
$(MKD) $(BINDIR)
diff --git a/src/ini_read.c b/src/ini_read.c
index e58bc80..b712163 100644
--- a/src/ini_read.c
+++ b/src/ini_read.c
@@ -994,3 +994,13 @@ int lciniGetFromFileStr(const char *filename, const char *section, const char *p
}
return r;
}
+
+
+char *lciniGetVersionStr(void){
+#ifdef GIT_LAST
+ char *ret = GIT_LAST;
+# else
+ char *ret = "";
+#endif
+ return ret;
+} \ No newline at end of file
diff --git a/src/lightconfini.h b/src/lightconfini.h
index 748e1cd..44929db 100644
--- a/src/lightconfini.h
+++ b/src/lightconfini.h
@@ -59,6 +59,7 @@ size_t lciniFileMaxLineLen(FILE *tfd);
lcini_shortret *lciniMKShortRet(int bufflen);
void lciniDestroyShortRet(lcini_shortret *dt);
+char *lciniGetVersionStr(void);
#endif /* LIGHTCONFINI_H_INCLUDED */
diff --git a/src/main.c b/src/main.c
index ff84fd4..c5d9690 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,6 +60,7 @@ int main(int argc, char* argv[]){
/*lcini_data *(*lciniCreateNode)( lcini_data *head, int lineLen ); */
/*lcini_shortret *(*lciniMKShortRet)(int bufflen); */
void (*lciniDestroyShortRet)(lcini_shortret *dt);
+ char *(*lciniGetVersionStr)(void);
#endif
if(argc > 1){
memset(filename, 0, 4096);
@@ -78,6 +79,8 @@ int main(int argc, char* argv[]){
if(!hl){
printf("\nDynamic Library load error - %s \nexit\n",dlerror());
exit(1);
+ } else {
+ printf("\nDynamic Library loaded: %s", linkpath);
}
lciniFileMaxLineLen = dlsym(hl, "lciniFileMaxLineLen");
if((buff1 = dlerror()) != NULL){
@@ -127,8 +130,11 @@ int main(int argc, char* argv[]){
if((buff1 = dlerror()) != NULL){
printf("\nsym err - %s\n", buff1);
}
+ lciniGetVersionStr = dlsym(hl, "lciniGetVersionStr");
+ if((buff1 = dlerror()) != NULL){
+ printf("\nsym err - %s\n", buff1);
+ }
-
#endif
@@ -233,6 +239,7 @@ int main(int argc, char* argv[]){
free(buff4);
free(buff5);
free(buff6);
+ printf("\n\nLightConfINI Version: %s \n", lciniGetVersionStr());
printf("\n -- end --\n");
#ifdef TESTLIBD
dlclose(hl);