]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Added a way to have "not yet implemented SQL library"
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 20:51:57 +0000 (16:51 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 20:51:57 +0000 (16:51 -0400)
Makefile
app/Makefile
lib/Makefile
lib/unimar.c
lib/unipos.c

index 8327063d85ea881ba2bfda07caea249f2565d782..2deec46650e0748f03ca16decd0a8ed432721cf9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ debug                                                 \
        :
           @ for i in $(SUBDIR) ;                       \
               do                                       \
-              $(MAKE)  -C $$i $@ ;                     \
+              $(MAKE) -s -C $$i $@ ;                   \
               done
 
 clean  :  cleanrpm
index b22e21b0b60a1dd043dcf77d1c4a219e9c9a6bc1..e0a81d9cd49cf59ab062ecc5faf3ea378981458e 100644 (file)
@@ -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
index 560abf380819a686b746a2b7e1cd6df77c241381..eb4a38350a4d3ef664cf60037080ba892d6b9dc3 100644 (file)
@@ -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`
 #--------------------------------------------------------------------
index 67e4124a78a6308783e279ee63a618ba76cc9454..102949d6ca768101999ef79c694e8cd7b757e15f 100644 (file)
@@ -7,8 +7,15 @@
 /********************************************************/
 #include        <stdio.h>
 
+
+#include        "subrou.h"
 #include        "unimar.h"
 
+//checking if MYSQL database need to compiled
+#if DATABASE==MYSQL
+  #define DB_MYSQL
+#endif
+
 /*
 \f
 */
 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
index 7ad57fdb4c032c93e44eb7f449a83529f0859f64..89fb4cccf330f94d03e1a32a9f9a28d07863c8dd 100644 (file)
@@ -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
 }