Guest User

Untitled

a guest
Jun 2nd, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. /*--------------------------------------------------------------------------------------------------
  2. *
  3. *------------------------------------------------------------------------------------------------*/
  4. static int authorize_user(PGconn *conn, apr_pool_t *pool, char *username, char *password, char *proc_name){
  5. PGresult *res;
  6. char *sql;
  7. char *result;
  8.  
  9.  
  10. if(username == NULL || password == NULL || proc_name == NULL) return 0;
  11.  
  12.  
  13.  
  14. sql = apr_psprintf(pool,"SELECT * FROM %s('%s','%s','%s');",AUTHORIZE_WEB_METHOD,
  15. username,
  16. password,
  17. proc_name);
  18.  
  19. res = PQexec(conn,sql);
  20.  
  21. if(!res){
  22. return 0;
  23. }
  24.  
  25. if(PQresultStatus(res) == PGRES_FATAL_ERROR){
  26. PQclear(res);
  27. return 0;
  28. }
  29.  
  30. if(PQntuples(res) == 0){
  31. PQclear(res);
  32. return 0;
  33. };
  34.  
  35. result = PQgetvalue(res,0,0);
  36.  
  37. if(strcmp(result,"t") == 0){
  38. PQclear(res);
  39. return 1;
  40. } else {
  41. PQclear(res);
  42. return 0;
  43. }
  44. }
Add Comment
Please, Sign In to add comment