PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int connection_test ( void  )
static

Definition at line 467 of file shp2pgsql-gui.c.

References _, pg_connection, pgui_logf(), pgui_raise_error_dialogue(), pgui_sanitize_connection_string(), ShpDumperGetConnectionStringFromConn(), and valid_connection.

Referenced by pgui_action_connection_okay(), pgui_action_export(), pgui_action_import(), and pgui_action_open_table_dialog().

468 {
469  char *connection_string = NULL;
470  char *connection_sanitized = NULL;
471 
472  if (!(connection_string = ShpDumperGetConnectionStringFromConn(conn)))
473  {
475  valid_connection = 0;
476  return 0;
477  }
478 
479  connection_sanitized = strdup(connection_string);
480  pgui_sanitize_connection_string(connection_sanitized);
481  pgui_logf("Connecting: %s", connection_sanitized);
482  free(connection_sanitized);
483 
484  pg_connection = PQconnectdb(connection_string);
485  if (PQstatus(pg_connection) == CONNECTION_BAD)
486  {
487  pgui_logf( _("Database connection failed: %s"), PQerrorMessage(pg_connection));
488  free(connection_string);
489  PQfinish(pg_connection);
490  pg_connection = NULL;
491  valid_connection = 0;
492  return 0;
493  }
494  PQfinish(pg_connection);
495  pg_connection = NULL;
496  free(connection_string);
497 
498  valid_connection = 1;
499  return 1;
500 }
#define _(String)
Definition: shpcommon.h:23
static void pgui_logf(const char *fmt,...)
static SHPCONNECTIONCONFIG * conn
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
static void pgui_sanitize_connection_string(char *connection_string)
static int valid_connection
static void pgui_raise_error_dialogue(void)
static PGconn * pg_connection

Here is the call graph for this function:

Here is the caller graph for this function: