@ 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
#--------------------------------------------------------------------
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)
#--------------------------------------------------------------------
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) -DDATABASE=$(DB)
+CFLAGS = -Wall -D_GNU_SOURCE $(OPTIME)
LIBMAIL = libmail.a
PAR = -j`/usr/bin/getconf _NPROCESSORS_ONLN`
#--------------------------------------------------------------------
/********************************************************/
#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
}
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
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
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
{
#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
}