PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ShpDumperGetConnectionStringFromConn()

char* ShpDumperGetConnectionStringFromConn ( SHPCONNECTIONCONFIG conn)

Definition at line 1198 of file pgsql2shp-core.c.

1199 {
1200  char *connstring;
1201  int connlen;
1202 
1203  connlen = 64 +
1204  (conn->host ? strlen(conn->host) : 0) + (conn->port ? strlen(conn->port) : 0) +
1205  (conn->username ? strlen(conn->username) : 0) + (conn->password ? strlen(conn->password) : 0) +
1206  (conn->database ? strlen(conn->database) : 0);
1207 
1208  connstring = malloc(connlen);
1209  memset(connstring, 0, connlen);
1210 
1211  if (conn->host)
1212  {
1213  strcat(connstring, " host=");
1214  strcat(connstring, conn->host);
1215  }
1216 
1217  if (conn->port)
1218  {
1219  strcat(connstring, " port=");
1220  strcat(connstring, conn->port);
1221  }
1222 
1223  if (conn->username)
1224  {
1225  strcat(connstring, " user=");
1226  strcat(connstring, conn->username);
1227  }
1228 
1229  if (conn->password)
1230  {
1231  strcat(connstring, " password='");
1232  strcat(connstring, conn->password);
1233  strcat(connstring, "'");
1234  }
1235 
1236  if (conn->database)
1237  {
1238  strcat(connstring, " dbname=");
1239  strcat(connstring, conn->database);
1240  }
1241 
1242  if ( ! getenv("PGCLIENTENCODING") )
1243  {
1244  strcat(connstring, " client_encoding=UTF8");
1245  }
1246 
1247  return connstring;
1248 }
void * malloc(YYSIZE_T)
static SHPCONNECTIONCONFIG * conn

References conn, shp_connection_state::database, shp_connection_state::host, malloc(), shp_connection_state::password, shp_connection_state::port, and shp_connection_state::username.

Referenced by connection_test(), pgui_action_import(), ShpDumperConnectDatabase(), and update_table_chooser_from_database().

Here is the call graph for this function:
Here is the caller graph for this function: