Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--------------------------------------------------------------------------------------------------
- *
- *------------------------------------------------------------------------------------------------*/
- static int authorize_user(PGconn *conn, apr_pool_t *pool, char *username, char *password, char *proc_name){
- PGresult *res;
- char *sql;
- char *result;
- if(username == NULL || password == NULL || proc_name == NULL) return 0;
- sql = apr_psprintf(pool,"SELECT * FROM %s('%s','%s','%s');",AUTHORIZE_WEB_METHOD,
- username,
- password,
- proc_name);
- res = PQexec(conn,sql);
- if(!res){
- return 0;
- }
- if(PQresultStatus(res) == PGRES_FATAL_ERROR){
- PQclear(res);
- return 0;
- }
- if(PQntuples(res) == 0){
- PQclear(res);
- return 0;
- };
- result = PQgetvalue(res,0,0);
- if(strcmp(result,"t") == 0){
- PQclear(res);
- return 1;
- } else {
- PQclear(res);
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment