#Executable generation area
#--------------------------------------------------------------------
debug : toremake
- @ $(MAKE) $(PAR) OPTIME="-g -DMODEDEBUG" objs
+ @ $(MAKE) \
+ $(PAR) \
+ DATABASE=$(DATABASE) \
+ OPTIME="-g -DMODEDEBUG" \
+ objs
@ echo "library compiled in '$@' mode, now ready"
prod : toremake
#--------------------------------------------------------------------
.PHONY: clean
#--------------------------------------------------------------------
+#database USED POSQL->Postgresql, MYSQL->mysql|mariadb
+DATABASE= MYSQL
+#--------------------------------------------------------------------
#definitions
#--------------------------------------------------------------------
CC = gcc
LD = gcc
-CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME)
+CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME) -D$(DATABASE)
LIBMAIL = libmail.a
PAR = -j`/usr/bin/getconf _NPROCESSORS_ONLN`
#--------------------------------------------------------------------
#include "subrou.h"
#include "unipos.h"
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to report database is not implemented */
+/* */
+/********************************************************/
+#ifndef POSQL
+static void notavail()
+
+{
+char *cmt="Postgresql Database access is NOT implemented (config?)";
+
+(void) rou_alert(0,"%s",cmt);
+}
+#endif
/*
\f
*/
{
#define OPEP "unipos.c:pos_opensql,"
-PGconn *pf;
-char *z; //parameter null
+POSPTR *posptr;
+
+posptr=(POSPTR *)0;
+#ifdef POSQL
+ {
+ PGconn *pf;
+ char *z; //parameter null
-z=(char *)0;
-pf=PQsetdbLogin(host,sqlport,z,z,dbname,z,z);
-// Check if the connection is successful
-if (PQstatus(pf)!=CONNECTION_OK) {
- (void) rou_alert(0,"%s Connection to database '%s' failed, cause '%s'",
- OPEP,dbname,PQerrorMessage(pf));
- (void) PQfinish(pf);
- pf=(PGconn *)0;
+ z=(char *)0;
+ pf=PQsetdbLogin(host,sqlport,z,z,dbname,z,z);
+ // Check if the connection is successful
+ if (PQstatus(pf)!=CONNECTION_OK) {
+ (void) rou_alert(0,"%s Connection to database '%s' failed, cause '%s'",
+ OPEP,dbname,PQerrorMessage(pf));
+ (void) PQfinish(pf);
+ pf=(PGconn *)0;
+ }
+ posptr=(POSPTR *)pf;
+ }
+#else
+ {
+ (void) notavail();
}
-return (POSPTR *)pf;
+#endif
+return posptr;
#undef OPEP
}
/*
{
#define OPEP "unipos.c:pos_closesql,"
-PGconn *pf;
+#ifdef POSQL
+ {
+ PGconn *pf;
-pf=(PGconn *)posptr;
-if (pf==(PGconn *)0) {
- (void) rou_alert(0,"%s Database link already closedi (Bug?)",OPEP);
- (void) PQfinish(pf);
+ pf=(PGconn *)posptr;
+ if (pf==(PGconn *)0) {
+ (void) rou_alert(0,"%s Database link already closedi (Bug?)",OPEP);
+ (void) PQfinish(pf);
+ }
+ else {
+ (void) PQfinish((PGconn *)pf);
+ pf=(PGconn *)0;
+ }
+ posptr=(POSPTR *)pf;
}
-else {
- (void) PQfinish((PGconn *)pf);
- pf=(PGconn *)0;
+#else
+ {
+ (void) notavail();
}
-return (POSPTR *)pf;
+#endif
+return posptr;
#undef OPEP
}
// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/********************************************************/
/* */
-/* base level subroutine declaration */
-/* to handle Postscript SQL request. */
+/* Base level subroutine declaration */
+/* to handle Postgresql SQL request. */
/* */
/********************************************************/
#ifndef UNIPOS