]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working on the unipos and unimar library .
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 19:36:02 +0000 (15:36 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 19:36:02 +0000 (15:36 -0400)
Makefile
app/Makefile
lib/Makefile
lib/subrou.h
lib/unimar.h
lib/unipos.c

index 2deec46650e0748f03ca16decd0a8ed432721cf9..8327063d85ea881ba2bfda07caea249f2565d782 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ debug                                                 \
        :
           @ for i in $(SUBDIR) ;                       \
               do                                       \
-              $(MAKE) -s -C $$i $@ ;                   \
+              $(MAKE)  -C $$i $@ ;                     \
               done
 
 clean  :  cleanrpm
index 2c3f7a023f6fddd3c09165450777047b4c67b83a..b22e21b0b60a1dd043dcf77d1c4a219e9c9a6bc1 100644 (file)
@@ -40,7 +40,7 @@ SRC=                                                          \
 CC     =  gcc 
 LD     =  gcc -g
 CFLAGS =  -I ../lib -Wall $(OPTIME)
-LIBMAIL        =  ../lib/libmail.a ../shared/libposql.so ../shared/libmasql.so
+LIBMAIL        =  ../lib/libmail.a 
 #LIBMAIL       =  ../lib/libmail.a
 LIBS   =       $(LIBMAIL)                      \
                -luuid                          \
@@ -55,6 +55,7 @@ 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 7385ad195d1efbb269750b94bf5dc4e9f2f85d3d..560abf380819a686b746a2b7e1cd6df77c241381 100644 (file)
@@ -16,28 +16,27 @@ clean       :
           - rm -fr ../shared/* *.so.* *.o *.a *.tar.gz
 
 #--------------------------------------------------------------------
-#database definition
-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
-
+#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
 #--------------------------------------------------------------------
-unipos.o:  unipos.h
-          $(CC) $(CFLAGS) -c -fPIC -o $@ unipos.c
-
-unimar.o:  unimar.h
-          $(CC) $(CFLAGS) -c -fPIC -o $@ unimar.c
-
 #--------------------------------------------------------------------
 #Equivalences
 #--------------------------------------------------------------------
@@ -46,11 +45,11 @@ OBJS=                                               \
          lvleml.o                              \
          gesspf.o gestcp.o geseml.o            \
          devlog.o devsoc.o devsql.o            \
-         unidns.o unieml.o                     \
-         unipar.o uniprc.o unisig.o unitls.o   \
+         unidns.o unieml.o unimar.o unipar.o   \
+         unipos.o uniprc.o unisig.o unitls.o   \
          subafn.o subrou.o 
 
-objs   : $(OBJS) shared
+objs   : $(OBJS)
          @ ar -cr $(LIBMAIL) $(OBJS)
 
 #--------------------------------------------------------------------
@@ -153,6 +152,9 @@ uniprc.h:                                   \
 unitls.h:                                      \
           subafn.h
 
+unipos.o:  unipos.c unipos.h
+          $(CC) $(CFLAGS) -c -o $@ unipos.c
+
 #--------------------------------------------------------------------
 
 toremake:  Makefile
@@ -163,10 +165,12 @@ toremake:  Makefile
 .PHONY:        clean
 #--------------------------------------------------------------------
 #definitions
+POSTGRESQL     =1
+MYSQL          =2
 #--------------------------------------------------------------------
 CC     = gcc
 LD     = gcc
-CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME)
+CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME) -DDATABASE=$(DB)
 LIBMAIL        = libmail.a
 PAR    = -j`/usr/bin/getconf _NPROCESSORS_ONLN`
 #--------------------------------------------------------------------
index 281dd3081ad2483b1d0b8b02775ace29e74d3a65..9eb2f2988812894b4363976476d66d97c41f9db4 100644 (file)
 
 #define ITSOK   0               //to check errno against no error
 
+//defining database #define
+#define POSTGRESQL      1
+#define MYSQL           2
+
 typedef void (*genfree_t)(void *);
 
 typedef struct timespec TIMESPEC;
index c8beb3582cb60d73d78829ac9a1c63b0f5a490da..b353cf01a7fda2b86afd59901ad0e699301e8d6f 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef        UNIMAR
 #define UNIMAR
 
+
 //reference to a SQL pointer reference
 typedef void MARPTR;
 
index 2d4c022f77670ebe5cfc4266fd8bd847c7d85b9c..7ad57fdb4c032c93e44eb7f449a83529f0859f64 100644 (file)
@@ -8,8 +8,14 @@
 #include        <libpq-fe.h>
 #include        <stdio.h>
 
+#include        "subrou.h"
 #include        "unipos.h"
 
+//checking if MYSQL database need to compiled
+#if DATABASE==POSTGRESQL
+  #define DB_POSTGRESQL
+#endif
+
 /*
 \f
 */
@@ -23,20 +29,33 @@ POSPTR *pos_opensql(const char *host,const char *sqlport,const char *dbname)
 
 {
 #define OPEP    "unipos.c:pos_opensql,"
+POSPTR *posptr;
 
-char *z;        //parameter null
-PGconn *pf;
+posptr=(POSPTR *)0;
+#ifdef  DB_POSTGRESQL
+  {
+  char *z;        //parameter null
+  PGconn *pf;
 
-z=(char *)0;
-pf=PQsetdbLogin(host,sqlport,z,z,dbname,z,z);
-// Check if the connection is successful
-if (PQstatus(pf)!=CONNECTION_OK) {
-  (void) fprintf(stderr,"%s Connection to database '%s' failed, cause '%s'\n",
-                         OPEP,dbname,PQerrorMessage(pf));
-  (void) PQfinish(pf);
-  pf=(PGconn *)0;
+  POST DATABASE;
+  z=(char *)0;
+  pf=PQsetdbLogin(host,sqlport,z,z,dbname,z,z);
+  // Check if the connection is successful
+  if (PQstatus(pf)!=CONNECTION_OK) {
+    (void) fprintf(stderr,"%s Connection to database '%s' failed, cause '%s'\n",
+                           OPEP,dbname,PQerrorMessage(pf));
+    (void) PQfinish(pf);
+    pf=(PGconn *)0;
+    }
+  posptr=(POSPTR *)pf;
   }
-return (POSPTR *)pf;
+#else
+  {
+  OTHER DATABASE;
+  (void) rou_alert(0,"%s not compiled for postgresql",OPEP);
+  } 
+#endif
+return (POSPTR *)posptr;
 #undef  OPEP
 }
 /*