From: František Dvořák Date: Sat, 31 Oct 2009 19:28:57 +0000 (+0000) Subject: Experiments on alternative platform. X-Git-Tag: glite-security-gss_R_2_0_1_1~25 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=c3e925e00e9be2c22db2f2988b6e370d11abed70;p=jra1mw.git Experiments on alternative platform. --- diff --git a/org.glite.lbjp-common.db/Makefile b/org.glite.lbjp-common.db/Makefile index 71ffa8f..1915902 100644 --- a/org.glite.lbjp-common.db/Makefile +++ b/org.glite.lbjp-common.db/Makefile @@ -42,7 +42,8 @@ CFLAGS:= \ -I${stagedir}/include -I${top_srcdir}/src -I. \ -I${top_srcdir}/interface \ ${COVERAGE_FLAGS} \ - -D_GNU_SOURCE + -D_GNU_SOURCE \ + -DHAVE_SYSLOG_H=1 ifdef LBS_DB_PROFILE CFLAGS:=${CFLAGS} -DLBS_DB_PROFILE diff --git a/org.glite.lbjp-common.db/examples/db_test.c b/org.glite.lbjp-common.db/examples/db_test.c index 3e541f9..e1b639f 100644 --- a/org.glite.lbjp-common.db/examples/db_test.c +++ b/org.glite.lbjp-common.db/examples/db_test.c @@ -18,6 +18,8 @@ #include #include +#include + #include "db.h" #define CS "testuser/@localhost:test" diff --git a/org.glite.lbjp-common.db/interface/db-int.h b/org.glite.lbjp-common.db/interface/db-int.h index 0d9d919..7a86c84 100644 --- a/org.glite.lbjp-common.db/interface/db-int.h +++ b/org.glite.lbjp-common.db/interface/db-int.h @@ -1,3 +1,8 @@ +#ifdef WIN32 +#define asprintf(STR, FMT...) trio_asprintf((STR), ##FMT) +#define vasprintf(STR, FMT, VARGS) trio_asprintf((STR), (FMT), (VARGS)) +#define strcasestr(H,N) strstr((H), (N)) +#endif #define dprintf(CTX, FMT...) if ((CTX)->caps & GLITE_LBU_DB_CAP_ERRORS) fprintf(stderr, ##FMT) diff --git a/org.glite.lbjp-common.db/src/db-mysql.c b/org.glite.lbjp-common.db/src/db-mysql.c index 3678dcf..60468d7 100644 --- a/org.glite.lbjp-common.db/src/db-mysql.c +++ b/org.glite.lbjp-common.db/src/db-mysql.c @@ -12,7 +12,18 @@ #include #include #include +#ifdef HAVE_SYSLOG_H #include +#endif + +#ifdef WIN32 +#include +#ifndef STDCALL +#define STDCALL __stdcall +#endif +#else +#define STDCALL +#endif #include #include @@ -96,36 +107,36 @@ typedef struct { void *lib; pthread_mutex_t lock; - void *(*mysql_init)(void *); - unsigned long (*mysql_get_client_version)(void); - int (*mysql_options)(MYSQL *mysql, enum mysql_option option, const char *arg); - unsigned int (*mysql_errno)(MYSQL *mysql); - const char *(*mysql_error)(MYSQL *mysql); - unsigned int (*mysql_stmt_errno)(MYSQL_STMT *stmt); - const char *(*mysql_stmt_error)(MYSQL_STMT *stmt); - MYSQL *(*mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag); - void (*mysql_close)(MYSQL *mysql); - int (*mysql_query)(MYSQL *mysql, const char *stmt_str); - MYSQL_RES *(*mysql_store_result)(MYSQL *mysql); - void (*mysql_free_result)(MYSQL_RES *result); - my_ulonglong (*mysql_affected_rows)(MYSQL *mysql); - my_bool (*mysql_stmt_close)(MYSQL_STMT *); - unsigned int (*mysql_num_fields)(MYSQL_RES *result); - unsigned long *(*mysql_fetch_lengths)(MYSQL_RES *result); - my_bool (*mysql_stmt_bind_result)(MYSQL_STMT *stmt, MYSQL_BIND *bind); - int (*mysql_stmt_prepare)(MYSQL_STMT *stmt, const char *stmt_str, unsigned long length); - int (*mysql_stmt_store_result)(MYSQL_STMT *stmt); - MYSQL_ROW (*mysql_fetch_row)(MYSQL_RES *result); - MYSQL_FIELD *(*mysql_fetch_field)(MYSQL_RES *result); - const char *(*mysql_get_server_info)(MYSQL *mysql); - MYSQL_STMT *(*mysql_stmt_init)(MYSQL *mysql); - my_bool (*mysql_stmt_bind_param)(MYSQL_STMT *stmt, MYSQL_BIND *bind); - int (*mysql_stmt_execute)(MYSQL_STMT *stmt); - int (*mysql_stmt_fetch)(MYSQL_STMT *stmt); - my_ulonglong (*mysql_stmt_insert_id)(MYSQL_STMT *stmt); - my_ulonglong (*mysql_stmt_affected_rows)(MYSQL_STMT *stmt); - MYSQL_RES *(*mysql_stmt_result_metadata)(MYSQL_STMT *stmt); - int (*mysql_stmt_fetch_column)(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned int column, unsigned long offset); + void * STDCALL(*mysql_init)(void *); + unsigned long STDCALL(*mysql_get_client_version)(void); + int STDCALL(*mysql_options)(MYSQL *mysql, enum mysql_option option, const char *arg); + unsigned int STDCALL(*mysql_errno)(MYSQL *mysql); + const char *STDCALL(*mysql_error)(MYSQL *mysql); + unsigned int STDCALL(*mysql_stmt_errno)(MYSQL_STMT *stmt); + const char *STDCALL(*mysql_stmt_error)(MYSQL_STMT *stmt); + MYSQL * STDCALL(*mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag); + void STDCALL(*mysql_close)(MYSQL *mysql); + int STDCALL(*mysql_query)(MYSQL *mysql, const char *stmt_str); + MYSQL_RES *STDCALL(*mysql_store_result)(MYSQL *mysql); + void STDCALL(*mysql_free_result)(MYSQL_RES *result); + my_ulonglong STDCALL(*mysql_affected_rows)(MYSQL *mysql); + my_bool STDCALL(*mysql_stmt_close)(MYSQL_STMT *); + unsigned int STDCALL(*mysql_num_fields)(MYSQL_RES *result); + unsigned long *STDCALL(*mysql_fetch_lengths)(MYSQL_RES *result); + my_bool STDCALL(*mysql_stmt_bind_result)(MYSQL_STMT *stmt, MYSQL_BIND *bind); + int STDCALL(*mysql_stmt_prepare)(MYSQL_STMT *stmt, const char *stmt_str, unsigned long length); + int STDCALL(*mysql_stmt_store_result)(MYSQL_STMT *stmt); + MYSQL_ROW STDCALL(*mysql_fetch_row)(MYSQL_RES *result); + MYSQL_FIELD *STDCALL(*mysql_fetch_field)(MYSQL_RES *result); + const char *STDCALL(*mysql_get_server_info)(MYSQL *mysql); + MYSQL_STMT *STDCALL(*mysql_stmt_init)(MYSQL *mysql); + my_bool STDCALL(*mysql_stmt_bind_param)(MYSQL_STMT *stmt, MYSQL_BIND *bind); + int STDCALL(*mysql_stmt_execute)(MYSQL_STMT *stmt); + int STDCALL(*mysql_stmt_fetch)(MYSQL_STMT *stmt); + my_ulonglong STDCALL(*mysql_stmt_insert_id)(MYSQL_STMT *stmt); + my_ulonglong STDCALL(*mysql_stmt_affected_rows)(MYSQL_STMT *stmt); + MYSQL_RES *STDCALL(*mysql_stmt_result_metadata)(MYSQL_STMT *stmt); + int STDCALL(*mysql_stmt_fetch_column)(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned int column, unsigned long offset); } mysql_module_t; @@ -249,7 +260,9 @@ int glite_lbu_InitDBContextMysql(glite_lbu_DBContext *ctx_gen) { ver_u = mysql_module.mysql_get_client_version(); if (ver_u != MYSQL_VERSION_ID) { fprintf(stderr,"Warning: MySQL library version mismatch (compiled '%d', runtime '%d')", MYSQL_VERSION_ID, ver_u); +#ifdef SYSLOG_H syslog(LOG_WARNING,"MySQL library version mismatch (compiled '%d', runtime '%d')", MYSQL_VERSION_ID, ver_u); +#endif } pthread_mutex_unlock(&mysql_module.lock); diff --git a/org.glite.lbjp-common.db/src/db-pg.c b/org.glite.lbjp-common.db/src/db-pg.c index b17e6b1..6228aa3 100644 --- a/org.glite.lbjp-common.db/src/db-pg.c +++ b/org.glite.lbjp-common.db/src/db-pg.c @@ -22,6 +22,12 @@ #include "db.h" #include "db-int.h" +#ifdef WIN32 +#define STDCALL __stdcall +#else +#define STDCALL +#endif + #define DB_CONNECT_TIMEOUT "20" #ifdef LOG @@ -58,26 +64,26 @@ typedef struct { pthread_mutex_t lock; /* functions from 8.3.8 client library version (libpq-fe.h) */ - PGconn *(*PQconnectdb)(const char *conninfo); - ConnStatusType (*PQstatus)(const PGconn *conn); - void (*PQfinish)(PGconn *conn); - char *(*PQerrorMessage)(const PGconn *conn); - int (*PQnfields)(const PGresult *res); - char *(*PQgetvalue)(const PGresult *res, int tup_num, int field_num); - int (*PQgetlength)(const PGresult *res, int tup_num, int field_num); - void (*PQclear)(PGresult *res); - PGresult *(*PQexec)(PGconn *conn, const char *query); - ExecStatusType (*PQresultStatus)(const PGresult *res); - char *(*PQresultErrorMessage)(const PGresult *res); - char *(*PQcmdTuples)(PGresult *res); - int (*PQntuples)(const PGresult *res); - char *(*PQfname)(const PGresult *res, int field_num); - unsigned char *(*PQescapeByteaConn)(PGconn *conn, + PGconn *STDCALL(*PQconnectdb)(const char *conninfo); + ConnStatusType STDCALL(*PQstatus)(const PGconn *conn); + void STDCALL(*PQfinish)(PGconn *conn); + char *STDCALL(*PQerrorMessage)(const PGconn *conn); + int STDCALL(*PQnfields)(const PGresult *res); + char *STDCALL(*PQgetvalue)(const PGresult *res, int tup_num, int field_num); + int STDCALL(*PQgetlength)(const PGresult *res, int tup_num, int field_num); + void STDCALL(*PQclear)(PGresult *res); + PGresult *STDCALL(*PQexec)(PGconn *conn, const char *query); + ExecStatusType STDCALL(*PQresultStatus)(const PGresult *res); + char *STDCALL(*PQresultErrorMessage)(const PGresult *res); + char *STDCALL(*PQcmdTuples)(PGresult *res); + int STDCALL(*PQntuples)(const PGresult *res); + char *STDCALL(*PQfname)(const PGresult *res, int field_num); + unsigned char *STDCALL(*PQescapeByteaConn)(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length); - unsigned char *(*PQunescapeBytea)(const unsigned char *strtext, + unsigned char *STDCALL(*PQunescapeBytea)(const unsigned char *strtext, size_t *retbuflen); - void (*PQfreemem)(void *ptr); + void STDCALL(*PQfreemem)(void *ptr); } psql_module_t; diff --git a/org.glite.lbjp-common.db/src/db.c b/org.glite.lbjp-common.db/src/db.c index 2b19aff..d65d5a8 100644 --- a/org.glite.lbjp-common.db/src/db.c +++ b/org.glite.lbjp-common.db/src/db.c @@ -115,7 +115,7 @@ time_t glite_lbu_StrToTime(const char *str) { struct tm tm; memset(&tm,0,sizeof(tm)); - setenv("TZ","UTC",1); tzset(); + putenv("TZ=UTC"); tzset(); sscanf(str,"%4d-%02d-%02d %02d:%02d:%02d", &tm.tm_year,&tm.tm_mon,&tm.tm_mday, &tm.tm_hour,&tm.tm_min,&tm.tm_sec); @@ -131,7 +131,7 @@ double glite_lbu_StrToTimestamp(const char *str) { double sec; memset(&tm,0,sizeof(tm)); - setenv("TZ","UTC",1); tzset(); + putenv("TZ=UTC"); tzset(); sscanf(str,"%4d-%02d-%02d %02d:%02d:%lf", &tm.tm_year,&tm.tm_mon,&tm.tm_mday, &tm.tm_hour,&tm.tm_min,&sec); diff --git a/org.glite.lbjp-common.trio/interface/trio.h b/org.glite.lbjp-common.trio/interface/trio.h index 04f133c..b5e1969 100644 --- a/org.glite.lbjp-common.trio/interface/trio.h +++ b/org.glite.lbjp-common.trio/interface/trio.h @@ -27,7 +27,7 @@ extern "C" { #endif /* make utility and C++ compiler in Windows NT fails to find this symbol */ -#if defined(WIN32) && !defined(isascii) +#if defined(WIN32) && !defined(isascii) && !defined(HAVE_IASCII) # define isascii ((unsigned)(x) < 0x80) #endif