]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adding unisql components
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 00:12:08 +0000 (20:12 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 17 Jun 2025 00:12:08 +0000 (20:12 -0400)
lib/Makefile
lib/unisql.c [new file with mode: 0644]
lib/unisql.h [new file with mode: 0644]

index 598d98084888f4467717a0bbd817cfe00eca83fa..6742bc281644919730d6934f00cb454c7e8ed4c9 100644 (file)
@@ -17,16 +17,24 @@ clean       :
 
 #--------------------------------------------------------------------
 #database definition
-shared :  libposql
+shared :  libposql libmysql
           mv -f libposql.so.1.0 ../shared
           ln -nsf libposql.so.1.0 ../shared/libposql.so.1
+          mv -f libmysql.so.1.0 ../shared
+          ln -nsf libmysql.so.1.0 ../shared/libmysql.so.1
 
 libposql:  unipos.o
           $(CC) -shared -Wl,-soname,$@.so.1 -o $@.so.1.0 unipos.o
 
+libmysql:  unisql.o
+          $(CC) -shared -Wl,-soname,$@.so.1 -o $@.so.1.0 unisql.o
+
 unipos.o:  unipos.h
           $(CC) $(CFLAGS) -c -fPIC -o $@ unipos.c
 
+unisql.o:  unisql.h
+          $(CC) $(CFLAGS) -c -fPIC -o $@ unisql.c
+
 #--------------------------------------------------------------------
 #Equivalences
 #--------------------------------------------------------------------
@@ -152,7 +160,7 @@ toremake:  Makefile
 .PHONY:        clean
 #--------------------------------------------------------------------
 #database USED POSQL->Postgresql, MYSQL->mysql|mariadb
-DATABASE= MYSQL
+DATABASE= POSQL
 #--------------------------------------------------------------------
 #definitions
 #--------------------------------------------------------------------
diff --git a/lib/unisql.c b/lib/unisql.c
new file mode 100644 (file)
index 0000000..28615f5
--- /dev/null
@@ -0,0 +1,84 @@
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/*                                                     */
+/*     Low level subroutine implementation             */
+/*     to handle POSTGRES SQL request                  */
+/*                                                     */
+/********************************************************/
+#include        "subrou.h"
+#include        "unisql.h"
+
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to report database is not implemented */
+/*                                                      */
+/********************************************************/
+#ifndef MYSQL
+static void notavail()
+
+{
+char *cmt="Postgresql Database access is NOT implemented (config?)";
+
+(void) fprintf(stderr,"%s\n",cmt);
+}
+#endif
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to establish a link with the          */
+/*      postgresq SQL server.                           */
+/*                                                      */
+/********************************************************/
+PUBLIC SQLPTR *sql_opensql(const char *host,const char *sqlport,const char *dbname)
+
+{
+#define OPEP    "unisql.c:sql_opensql,"
+
+SQLPTR *sqlptr;
+
+sqlptr=(SQLPTR *)0;
+#ifdef  MYSQL
+  {
+  (void) fprintf(stderr,"%s\n","To be implemented");
+  }
+#else
+  {
+  (void) notavail();
+  }
+#endif
+return sqlptr;
+#undef  OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to close the link with the designated */
+/*      postgresql SQL server.                          */
+/*                                                      */
+/********************************************************/
+PUBLIC SQLPTR *sql_closesql(SQLPTR *sqlptr)
+
+{
+#define OPEP    "sqlpos.c:sql_closesql,"
+
+#ifdef  MYSQL
+  {
+  (void) fprintf(stderr,"%s\n","To be implemented");
+  }
+#else
+  {
+  (void) notavail();
+  }
+#endif
+return sqlptr;
+#undef  OPEP
+}
+
+
diff --git a/lib/unisql.h b/lib/unisql.h
new file mode 100644 (file)
index 0000000..0a88104
--- /dev/null
@@ -0,0 +1,20 @@
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/*                                                     */
+/*     Base level subroutine declaration               */
+/*     to handle MYSQL/MARIADB SQL request.            */
+/*                                                     */
+/********************************************************/
+#ifndef        UNISQL
+#define UNISQL
+
+//reference to a SQL pointer reference
+typedef void SQLPTR;
+
+//Opening a postscript database
+extern SQLPTR *sql_opensql(const char *host,const char *sqlport,const char *dbname);
+
+//closing a postscript database
+extern SQLPTR *sql_closesql(SQLPTR *sqlptr);
+
+#endif