/* to handle POSTGRES SQL request */
/* */
/********************************************************/
+#include <pwd.h>
#include <stdio.h>
-
+#include <stdlib.h>
+#include <unistd.h>
+#include <mysql/mysql.h>
+#include <sys/types.h>
#include "subrou.h"
#include "unimar.h"
marptr=(MARPTR *)0;
#ifdef DB_MYSQL
- (void) fprintf(stderr,"%s not yet implemented\n",OPEP);
+ {
+ struct passwd *pw;
+ MYSQL *mysql;
+ int port;
+
+ if ((pw=getpwuid(geteuid()))==(struct passwd *)0) {
+ (void) rou_core_dump("%s is unable to find name for uid '%s'",
+ OPEP,geteuid());
+ //never ever REACHED
+ }
+ mysql=mysql_init((MYSQL *)0);
+ port=0;
+ if (sqlport!=(char *)0)
+ port=atoi(sqlport);
+ if (mysql_real_connect(mysql,host,pw->pw_name,(char *)0,dbname,port,
+ (char *)0,CLIENT_FOUND_ROWS)==(MYSQL *)0) {
+ (void) rou_alert(0,"%s Connection to database '%s' failed, cause '%s'",
+ OPEP,dbname,mysql_error(mysql));
+ (void) free(mysql);
+ mysql=(MYSQL *)0;
+ }
+ marptr=(MARPTR *)mysql;
+ }
#else
(void) fprintf(stderr,"%s not compiled to be used with mysql\n",OPEP);
#endif
#define OPEP "sqlmar.c:mar_closesql,"
#ifdef DB_MYSQL
- (void) fprintf(stderr,"%s not yet implemented\n",OPEP);
+ (void) mysql_close(MYSQL *marptr);
#else
(void) fprintf(stderr,"%s not compiled to be used with mysql\n",OPEP);
#endif
+marptr=(MARPTR *)0;
return marptr;
#undef OPEP