From: Jean-Marc Pigeon (Delson) Date: Tue, 17 Jun 2025 20:51:57 +0000 (-0400) Subject: Added a way to have "not yet implemented SQL library" X-Git-Tag: tag-0.9~130 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=3b77d30cebdf4752afd0e4d1ed954fc91a57767e;p=jmp%2Fmailleur Added a way to have "not yet implemented SQL library" --- diff --git a/Makefile b/Makefile index 8327063..2deec46 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ debug \ : @ for i in $(SUBDIR) ; \ do \ - $(MAKE) -C $$i $@ ; \ + $(MAKE) -s -C $$i $@ ; \ done clean : cleanrpm diff --git a/app/Makefile b/app/Makefile index b22e21b..e0a81d9 100644 --- a/app/Makefile +++ b/app/Makefile @@ -40,8 +40,12 @@ SRC= \ CC = gcc LD = gcc -g CFLAGS = -I ../lib -Wall $(OPTIME) -LIBMAIL = ../lib/libmail.a -#LIBMAIL = ../lib/libmail.a +#LIBMAIL= ../lib/libmail.a +LIBMAIL = \ + ../shared/libposql.so \ + ../shared/libmasql.so \ + ../lib/libmail.a + LIBS = $(LIBMAIL) \ -luuid \ -lpq \ @@ -55,7 +59,6 @@ chkspf : toremake chkspf.o @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) receiver: toremake receiver.o - @ echo JMPDBG DB=$(DB) @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS) feeder : toremake feeder.o diff --git a/lib/Makefile b/lib/Makefile index 560abf3..eb4a383 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -13,30 +13,89 @@ prod : toremake @ echo "library compiled in '$@' mode, now ready" clean : - - rm -fr ../shared/* *.so.* *.o *.a *.tar.gz + - rm -fr ../shared/* ../nodb/* *.so.* *.o *.a *.tar.gz #-------------------------------------------------------------------- -#database definition USING SHARED (test a way to do it) -#shared : libposql libmasql -# mv -f libposql.so.1.0 ../shared -# ln -nsf libposql.so.1.0 ../shared/libposql.so.1 -# ln -nsf libposql.so.1.0 ../shared/libposql.so -# mv -f libmasql.so.1.0 ../shared -# ln -nsf libmasql.so.1.0 ../shared/libmasql.so.1 -# ln -nsf libmasql.so.1.0 ../shared/libmasql.so -# -#libposql: unipos.o -# $(CC) -shared -Wl,-soname,$@.so.1 -o $@.so.1.0 unipos.o -# -#libmasql: unimar.o -# $(CC) -shared -Wl,-soname,$@.so.1 -o $@.so.1.0 unimar.o - -#unipos.o: unipos.h -# $(CC) $(CFLAGS) -c -fPIC -o $@ unipos.c -# -#unimar.o: unimar.h -# $(CC) $(CFLAGS) -c -fPIC -o $@ unimar.c +#DATABASE definitions +POSTGRESQL =1 +MYSQL =2 #-------------------------------------------------------------------- +#database definition USING SHARED (test a way to do it) +shared : libposql libmasql libponql libmanql + @ mv -f libposql.so.1.0 ../shared + @ mv -f libmasql.so.1.0 ../shared + @ ln -nsf libposql.so.1.0 ../shared/libposql.so.1 + @ ln -nsf libposql.so.1.0 ../shared/libposql.so + @ ln -nsf libmasql.so.1.0 ../shared/libmasql.so.1 + @ ln -nsf libmasql.so.1.0 ../shared/libmasql.so + @ mv -f libponql.so.1.0 ../nodb + @ mv -f libmanql.so.1.0 ../nodb + @ ln -nsf libponql.so.1.0 ../nodb/libponql.so.1 + @ ln -nsf libponql.so.1.0 ../nodb/libponql.so + @ ln -nsf libmanql.so.1.0 ../nodb/libmanql.so.1 + @ ln -nsf libmanql.so.1.0 ../nodb/libmanql.so + @ echo "shared and nodb library ready" + +libposql: unipos.o + @ $(CC) \ + -shared \ + -Wl,-soname,$@.so.1 \ + -o $@.so.1.0 \ + $< + +libponql: no-unipos.o + @ $(CC) \ + -shared \ + -Wl,-soname,$@.so.1 \ + -o $@.so.1.0 \ + $< + +libmasql: unimar.o + @ $(CC) \ + -shared \ + -Wl,-soname,$@.so.1 \ + -o $@.so.1.0 \ + $< + +libmanql: no-unimar.o + @ $(CC) \ + -shared \ + -Wl,-soname,$@.so.1 \ + -o $@.so.1.0 \ + $< + +unipos.o: unipos.h + @ $(CC) \ + $(CFLAGS) \ + -c -fPIC \ + -o $@ \ + -DDATABASE=POSTGRESQL \ + unipos.c + +no-unipos.o: + @ $(CC) \ + $(CFLAGS) \ + -c -fPIC \ + -o $@ \ + -DDATABASE=0 \ + unipos.c + +unimar.o: unimar.h + @ $(CC) \ + $(CFLAGS) \ + -c -fPIC \ + -o $@ \ + -DDATABASE=MYSQL \ + unimar.c + +no-unimar.o: + @ $(CC) \ + $(CFLAGS) \ + -c -fPIC \ + -o $@ \ + -DDATABASE=0 \ + unimar.c + #-------------------------------------------------------------------- #Equivalences #-------------------------------------------------------------------- @@ -45,11 +104,11 @@ OBJS= \ lvleml.o \ gesspf.o gestcp.o geseml.o \ devlog.o devsoc.o devsql.o \ - unidns.o unieml.o unimar.o unipar.o \ - unipos.o uniprc.o unisig.o unitls.o \ + unidns.o unieml.o unipar.o \ + uniprc.o unisig.o unitls.o \ subafn.o subrou.o -objs : $(OBJS) +objs : $(OBJS) shared @ ar -cr $(LIBMAIL) $(OBJS) #-------------------------------------------------------------------- @@ -152,9 +211,6 @@ uniprc.h: \ unitls.h: \ subafn.h -unipos.o: unipos.c unipos.h - $(CC) $(CFLAGS) -c -o $@ unipos.c - #-------------------------------------------------------------------- toremake: Makefile @@ -164,13 +220,9 @@ toremake: Makefile #-------------------------------------------------------------------- .PHONY: clean #-------------------------------------------------------------------- -#definitions -POSTGRESQL =1 -MYSQL =2 -#-------------------------------------------------------------------- CC = gcc LD = gcc -CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME) -DDATABASE=$(DB) +CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME) LIBMAIL = libmail.a PAR = -j`/usr/bin/getconf _NPROCESSORS_ONLN` #-------------------------------------------------------------------- diff --git a/lib/unimar.c b/lib/unimar.c index 67e4124..102949d 100644 --- a/lib/unimar.c +++ b/lib/unimar.c @@ -7,8 +7,15 @@ /********************************************************/ #include + +#include "subrou.h" #include "unimar.h" +//checking if MYSQL database need to compiled +#if DATABASE==MYSQL + #define DB_MYSQL +#endif + /* */ @@ -21,12 +28,16 @@ MARPTR *mar_opensql(const char *host,const char *sqlport,const char *dbname) { -#define OPEP "unisql.c:sql_opensql," +#define OPEP "unimar.c:mar_opensql," MARPTR *marptr; marptr=(MARPTR *)0; -(void) fprintf(stderr,"%s\n","To be implemented"); +#ifdef DB_MYSQL + (void) fprintf(stderr,"%s not yet implemented\n",OPEP); +#else + (void) fprintf(stderr,"%s not compiled to be used with mysql\n",OPEP); +#endif return marptr; #undef OPEP } @@ -42,9 +53,13 @@ return marptr; MARPTR *mar_closesql(MARPTR *marptr) { -#define OPEP "sqlpos.c:sql_closesql," +#define OPEP "sqlmar.c:mar_closesql," -(void) fprintf(stderr,"%s\n","To be implemented"); +#ifdef DB_MYSQL + (void) fprintf(stderr,"%s not yet implemented\n",OPEP); +#else + (void) fprintf(stderr,"%s not compiled to be used with mysql\n",OPEP); +#endif return marptr; #undef OPEP diff --git a/lib/unipos.c b/lib/unipos.c index 7ad57fd..89fb4cc 100644 --- a/lib/unipos.c +++ b/lib/unipos.c @@ -37,7 +37,6 @@ posptr=(POSPTR *)0; char *z; //parameter null PGconn *pf; - POST DATABASE; z=(char *)0; pf=PQsetdbLogin(host,sqlport,z,z,dbname,z,z); // Check if the connection is successful @@ -50,10 +49,7 @@ posptr=(POSPTR *)0; posptr=(POSPTR *)pf; } #else - { - OTHER DATABASE; - (void) rou_alert(0,"%s not compiled for postgresql",OPEP); - } + (void) fprintf(stderr,"%s not compiled to be used with postgresql\n",OPEP); #endif return (POSPTR *)posptr; #undef OPEP @@ -72,18 +68,26 @@ POSPTR *pos_closesql(POSPTR *posptr) { #define OPEP "unipos.c:pos_closesql," -PGconn *pf; +#ifdef DB_POSTGRESQL + { + PGconn *pf; -pf=(PGconn *)posptr; -if (pf==(PGconn *)0) { - (void) fprintf(stderr,"%s Database link already closedi (Bug?)\n",OPEP); - (void) PQfinish(pf); - } -else { - (void) PQfinish((PGconn *)pf); - pf=(PGconn *)0; + pf=(PGconn *)posptr; + if (pf==(PGconn *)0) { + (void) fprintf(stderr,"%s Database link already closedi (Bug?)\n",OPEP); + (void) PQfinish(pf); + } + else { + (void) PQfinish((PGconn *)pf); + pf=(PGconn *)0; + } + posptr=(POSPTR *)pf; } -return (POSPTR *)pf; +#else + (void) fprintf(stderr,"%s not compiled to be used with postgresql\n",OPEP); +#endif +return posptr; + #undef OPEP }