summaryrefslogtreecommitdiffstats
path: root/database/postgresql
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2011-07-26 00:05:45 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2013-06-13 01:01:55 +0200
commit9e34f375787fb267e3c6e735590abf25efb3d63b (patch)
tree3d8a4f2fd9aa0d51a6128e2716365637b5c24172 /database/postgresql
parent452b54e3105d3f5cb4f8f35ee228ac582106e394 (diff)
downloadeurephia-9e34f375787fb267e3c6e735590abf25efb3d63b.tar.gz
eurephia-9e34f375787fb267e3c6e735590abf25efb3d63b.tar.xz
eurephia-9e34f375787fb267e3c6e735590abf25efb3d63b.zip
edb-pgsql: Renamed local PostgreSQL functions
Generic local PostgreSQL functions were prefixed with 'PG'. As this is too close to the prefix PostgreSQL uses, these functions where changed to 'ePG'. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'database/postgresql')
-rw-r--r--database/postgresql/edb-pgsql.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/database/postgresql/edb-pgsql.c b/database/postgresql/edb-pgsql.c
index 7fea328..e1330b5 100644
--- a/database/postgresql/edb-pgsql.c
+++ b/database/postgresql/edb-pgsql.c
@@ -75,7 +75,7 @@ static const eDBattempt_types_t eDBattempt_types[] = {
};
-static inline char *PGgetValue(PGresult *res, int row, int col) {
+static inline char *ePGgetValue(PGresult *res, int row, int col) {
if( (res == NULL) || (PQgetisnull(res, row, col) == 1) ) {
return NULL;
} else {
@@ -84,7 +84,7 @@ static inline char *PGgetValue(PGresult *res, int row, int col) {
}
-static void PGerrorMessage(eurephiaCTX *ctx, PGresult *dbr, int logdst, int loglvl,
+static void ePGerrorMessage(eurephiaCTX *ctx, PGresult *dbr, int logdst, int loglvl,
const char *prepsql, const char *fmt, ...)
{
char msgfmt[514];
@@ -150,7 +150,7 @@ static inline void update_blacklist_attempt(eurephiaCTX *ctx, const char *blid)
"UPDATE blacklist "
" SET last_accessed = CURRENT_TIMESTAMP WHERE blid = $1", 1, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_CRITICAL, 0, PREPSQL_BLACKLIST_ATTEMPTUPD,
+ ePGerrorMessage(ctx, dbr, LOG_CRITICAL, 0, PREPSQL_BLACKLIST_ATTEMPTUPD,
"Preparing last attempt query update failed");
return;
}
@@ -162,7 +162,7 @@ static inline void update_blacklist_attempt(eurephiaCTX *ctx, const char *blid)
qry_args, NULL, NULL, 0);
free_nullsafe(ctx, qry_args);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_CRITICAL, 0, PREPSQL_BLACKLIST_ATTEMPTUPD,
+ ePGerrorMessage(ctx, dbr, LOG_CRITICAL, 0, PREPSQL_BLACKLIST_ATTEMPTUPD,
"Failed to update blaclist.last_access timestamp for blid %s",
blid);
return;
@@ -223,7 +223,7 @@ int eDBconnect(eurephiaCTX *ctx, const int argc, const char **argv)
}
if( PQstatus(dbc->dbhandle) != CONNECTION_OK ) {
- PGerrorMessage(ctx, NULL, LOG_EMERG, 0, "DB-INIT",
+ ePGerrorMessage(ctx, NULL, LOG_EMERG, 0, "DB-INIT",
"Failed to connect to the PostgreSQL database '%s'",
dbname);
ctx->dbc = NULL;
@@ -249,12 +249,12 @@ int eDBconnect(eurephiaCTX *ctx, const int argc, const char **argv)
return 0;
}
for( i = 0; i < PQntuples(res); i++ ) {
- eAdd_value(ctx, cfg, PGgetValue(res, i, 0), PGgetValue(res, i, 1));
+ eAdd_value(ctx, cfg, ePGgetValue(res, i, 0), ePGgetValue(res, i, 1));
}
dbc->config = cfg;
PQclear(res);
} else {
- PGerrorMessage(ctx, res, LOG_EMERG, 0, "DB-INIT",
+ ePGerrorMessage(ctx, res, LOG_EMERG, 0, "DB-INIT",
"Failed to the configuration from the database");
eFree_values(ctx, dbc->dbparams);
free_nullsafe(ctx, dbc);
@@ -320,7 +320,7 @@ int eDBauth_TLS(eurephiaCTX *ctx, const char *org, const char *cname, const char
" AND lower(cert.digest)=lower($5::varchar)\0",
5, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_TLS_AUTH, "Failed to prepare SQL query");
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_TLS_AUTH, "Failed to prepare SQL query");
return 0;
}
PQclear(dbr);
@@ -337,15 +337,15 @@ int eDBauth_TLS(eurephiaCTX *ctx, const char *org, const char *cname, const char
dbr = PQexecPrepared(ctx->dbc->dbhandle, PREPSQL_TLS_AUTH, 5, qry_args, NULL, NULL, 0);
free_nullsafe(ctx, qry_args);
if( !dbr || (PQresultStatus(dbr) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_TLS_AUTH,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_TLS_AUTH,
"Could not lookup certificate information "
"[O=%s/CN=%s/emailAddress=%s - depth %s, digest=%s]",
org, cname, email, depth_str, digest);
return 0;
}
- certid = atoi_nullsafe(PGgetValue(dbr, 0, 0));
- blid = strdup_nullsafe(PGgetValue(dbr, 0, 1));
+ certid = atoi_nullsafe(ePGgetValue(dbr, 0, 0));
+ blid = strdup_nullsafe(ePGgetValue(dbr, 0, 1));
if( blid != NULL ) {
// If the certificate is blacklisted, update last access status and deny access.
@@ -394,7 +394,7 @@ int eDBauth_user(eurephiaCTX *ctx, const int certid, const char *username, const
" JOIN blacklist USING(digest)) bl2 ON(uc.certid = bl2.certid)"
" WHERE uc.certid = $1::INTEGER AND ou.username = $2::VARCHAR", 2, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERPWD_AUTH,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERPWD_AUTH,
"Failed to prepare SQL query");
uicid = 0;
goto exit;
@@ -410,7 +410,7 @@ int eDBauth_user(eurephiaCTX *ctx, const int certid, const char *username, const
dbr = PQexecPrepared(ctx->dbc->dbhandle, PREPSQL_USERPWD_AUTH, 2, qry_args, NULL, NULL, 0);
free_nullsafe(ctx, qry_args);
if( !dbr || (PQresultStatus(dbr) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0,
"Failed to lookup user account information [username=%s, certid=%s]",
username, certid_str);
uicid = 0;
@@ -426,12 +426,12 @@ int eDBauth_user(eurephiaCTX *ctx, const int certid, const char *username, const
}
// Check if the user account is valid and that the password is correct
- uid = PGgetValue(dbr, 0, 1);
- activated = PGgetValue(dbr, 0, 2);
- deactivated = PGgetValue(dbr, 0, 3);
- blid_uname = PGgetValue(dbr, 0, 4);
- blid_cert = PGgetValue(dbr, 0, 5);
- dbpwd = PGgetValue(dbr, 0, 6);
+ uid = ePGgetValue(dbr, 0, 1);
+ activated = ePGgetValue(dbr, 0, 2);
+ deactivated = ePGgetValue(dbr, 0, 3);
+ blid_uname = ePGgetValue(dbr, 0, 4);
+ blid_cert = ePGgetValue(dbr, 0, 5);
+ dbpwd = ePGgetValue(dbr, 0, 6);
if( dbpwd == NULL ) {
eurephia_log(ctx, LOG_WARNING, 0,"Authentication failed for user '%s'. DB error.",
@@ -471,14 +471,14 @@ int eDBauth_user(eurephiaCTX *ctx, const int certid, const char *username, const
} else {
PGresult *upd = NULL;
- uicid = atoi_nullsafe(PGgetValue(dbr, 0, 0));
+ uicid = atoi_nullsafe(ePGgetValue(dbr, 0, 0));
// Update last accessed status
upd = PQprepare(ctx->dbc->dbhandle, PREPSQL_USERS_LASTACC_UPD,
"UPDATE users SET last_accessed = CURRENT_TIMESTAMP"
" WHERE uid = $1::INTEGER", 1, NULL);
if( !dbr || (PQresultStatus(upd) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, upd, LOG_FATAL, 0, PREPSQL_USERS_LASTACC_UPD,
+ ePGerrorMessage(ctx, upd, LOG_FATAL, 0, PREPSQL_USERS_LASTACC_UPD,
"Failed to prepare SQL query");
} else if( dbr ) {
PQclear(upd);
@@ -489,7 +489,7 @@ int eDBauth_user(eurephiaCTX *ctx, const int certid, const char *username, const
1, qry_args, NULL, NULL, 0);
free_nullsafe(ctx, qry_args);
if( !upd || (PQresultStatus(upd) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, upd, LOG_FATAL, 0, PREPSQL_USERS_LASTACC_UPD
+ ePGerrorMessage(ctx, upd, LOG_FATAL, 0, PREPSQL_USERS_LASTACC_UPD
"Failed to update last access status for uid %s", uid);
}
if( upd ) {
@@ -533,7 +533,7 @@ int eDBget_uid(eurephiaCTX *ctx, const int certid, const char *username)
" WHERE certid = $1::INTEGER AND username = $1::VARCHAR",
2, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERS_GETUID,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERS_GETUID,
"Failed to prepare SQL query");
ret = -1;
goto exit;
@@ -547,7 +547,7 @@ int eDBget_uid(eurephiaCTX *ctx, const int certid, const char *username)
dbr = PQexecPrepared(ctx->dbc->dbhandle, PREPSQL_USERPWD_AUTH, 2, qry_args, NULL, NULL, 0);
free_nullsafe(ctx, qry_args);
if( !dbr || (PQresultStatus(dbr) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERPWD_AUTH,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_USERPWD_AUTH,
"Failed to lookup userid for user '%s'", username);
ret = -1;
goto exit;
@@ -561,7 +561,7 @@ int eDBget_uid(eurephiaCTX *ctx, const int certid, const char *username)
break;
case 1:
- ret = atoi_nullsafe(PGgetValue(dbr,0, 0));
+ ret = atoi_nullsafe(ePGgetValue(dbr,0, 0));
break;
default:
eurephia_log(ctx, LOG_CRIT, 0, "Failed to lookup userid for user '%s'",
@@ -606,7 +606,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
dbr = PQprepare(ctx->dbc->dbhandle, PREPSQL_BLACKLIST_CHECK, sql, 1, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
"Failed to prepare SQL query");
blacklisted = -1;
goto exit;
@@ -615,7 +615,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
dbr = PQexecPrepared(ctx->dbc->dbhandle, PREPSQL_BLACKLIST_CHECK, 2, qry_args, NULL, NULL, 0);
if( !dbr || (PQresultStatus(dbr) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
"Failed to lookup %s in the blacklist for '%s'",
eDBattempt_types[type].descr, val);
blacklisted = -1;
@@ -623,7 +623,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
}
if( dbr && PQntuples(dbr) > 0 ) {
- blid = PGgetValue(dbr, 0, 0);
+ blid = ePGgetValue(dbr, 0, 0);
if( blid != NULL ) {
eurephia_log(ctx, LOG_WARNING, 0, "Attempt from blacklisted %s: %s",
eDBattempt_types[type].descr, val);
@@ -632,7 +632,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
update_blacklist_attempt(ctx, blid);
PQclear(dbr);
} else {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
"Blacklist query for %s failed (%s)",
eDBattempt_types[type].descr, val);
};
@@ -651,7 +651,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
eDBattempt_types[type].colname_where);
dbr = PQprepare(ctx->dbc->dbhandle, PREPSQL_ATTEMPTS_CHECK, sql, 1, NULL);
if( !dbr || (PQresultStatus(dbr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_ATTEMPTS_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_ATTEMPTS_CHECK,
"Failed to prepare SQL query");
blacklisted = -1;
goto exit;
@@ -660,7 +660,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
dbr = PQexecPrepared(ctx->dbc->dbhandle, PREPSQL_BLACKLIST_CHECK, 1, qry_args, NULL, NULL, 0);
if( !dbr || (PQresultStatus(dbr) != PGRES_TUPLES_OK) ) {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
"Failed look up attempts counter for %s in the blacklist check on '%s'",
eDBattempt_types[type].descr, val);
blacklisted = -1;
@@ -668,8 +668,8 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
}
if( dbr && (PQntuples(dbr) > 0) ) {
- atpid = PGgetValue(dbr, 0, 0);
- atpexceed = atoi_nullsafe(PGgetValue(dbr, 0, 1));
+ atpid = ePGgetValue(dbr, 0, 0);
+ atpexceed = atoi_nullsafe(ePGgetValue(dbr, 0, 1));
// If [type] has reached attempt limit and it is not black listed, black list it
if( (atpexceed > 0) && (blid == NULL) ) {
@@ -683,7 +683,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
eDBattempt_types[type].colname);
blr = PQprepare(ctx->dbc->dbhandle, PREPSQL_BLACKLIST_REGISTER, sql, 1, NULL);
if( !blr || (PQresultStatus(blr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, blr, LOG_FATAL, 0, PREPSQL_BLACKLIST_REGISTER,
+ ePGerrorMessage(ctx, blr, LOG_FATAL, 0, PREPSQL_BLACKLIST_REGISTER,
"Failed to prepare SQL query");
} else {
PQclear(blr);
@@ -691,7 +691,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
PREPSQL_BLACKLIST_REGISTER, 1, qry_args,
NULL, NULL, 0);
if( !blr || (PQresultStatus(blr) != PGRES_COMMAND_OK) ) {
- PGerrorMessage(ctx, blr, LOG_FATAL, 0,
+ ePGerrorMessage(ctx, blr, LOG_FATAL, 0,
PREPSQL_BLACKLIST_REGISTER,
"Failed to register %s value '%s' in the "
"blacklist:",
@@ -704,7 +704,7 @@ int eDBblacklist_check(eurephiaCTX *ctx, const int type, const char *val)
atpid = NULL;
PQclear(dbr);
} else {
- PGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
+ ePGerrorMessage(ctx, dbr, LOG_FATAL, 0, PREPSQL_BLACKLIST_CHECK,
"Querying attempts counts for blacklisted %s failed (%s)",
eDBattempt_types[type].descr, val);
}