- 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
#--------------------------------------------------------------------
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)
#--------------------------------------------------------------------
unitls.h: \
subafn.h
+unipos.o: unipos.c unipos.h
+ $(CC) $(CFLAGS) -c -o $@ unipos.c
+
#--------------------------------------------------------------------
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`
#--------------------------------------------------------------------
#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
*/
{
#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
}
/*