#include #include #include #ifdef _DB_MYSQL_ #include #endif #ifdef _DB_PGSQL_ #include "libpq-fe.h" #endif #include "gld.h" #ifdef _DB_MYSQL_ static int MySQLConnect(char *host,char *user,char *passwd,char *db); static void MySQLClose(void); static long MySQLQuery(char *q); #endif #ifdef _DB_PGSQL_ static int PgSQLConnect(char *host,char *user,char *passwd,char *db); static void PgSQLClose(void); static long PgSQLQuery(char *q); #endif int SQLConnect(char *host,char *user,char *passwd,char *db) { #ifdef _DB_MYSQL_ return(MySQLConnect(host, user, passwd, db)); #endif #ifdef _DB_PGSQL_ return(PgSQLConnect(host, user, passwd, db)); #endif } void SQLClose(void) { #ifdef _DB_MYSQL_ return(MySQLClose()); #endif #ifdef _DB_PGSQL_ return(PgSQLClose()); #endif } long SQLQuery(char *q) { #ifdef _DB_MYSQL_ return(MySQLQuery(q)); #endif #ifdef _DB_PGSQL_ return(PgSQLQuery(q)); #endif } void ShowBaseInfo(void) { char query[QLEN]; int c; long now; now=time(0); snprintf(query,sizeof(query)-1,"select count(*) from greylist"); c=SQLQuery(query); printf("# of entries in the database : %d\n",c); if(c!=0) { snprintf(query,sizeof(query)-1,"select count(*) from greylist where n=1"); c=SQLQuery(query); printf("# of one hit entries in the database : %d\n",c); snprintf(query,sizeof(query)-1,"select min(first) from greylist"); c=SQLQuery(query); printf("Oldest entry in database : %ld days ago\n",(now-c)/86400); } } void Quote(char *str) { int i,l; l=strlen(str); for(i=0;i