PostGIS  2.3.7dev-r@@SVN_REVISION@@
char* ShpDumperGetConnectionStringFromConn ( SHPCONNECTIONCONFIG conn)

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

References 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().

1183 {
1184  char *connstring;
1185  int connlen;
1186 
1187  connlen = 64 +
1188  (conn->host ? strlen(conn->host) : 0) + (conn->port ? strlen(conn->port) : 0) +
1189  (conn->username ? strlen(conn->username) : 0) + (conn->password ? strlen(conn->password) : 0) +
1190  (conn->database ? strlen(conn->database) : 0);
1191 
1192  connstring = malloc(connlen);
1193  memset(connstring, 0, connlen);
1194 
1195  if (conn->host)
1196  {
1197  strcat(connstring, " host=");
1198  strcat(connstring, conn->host);
1199  }
1200 
1201  if (conn->port)
1202  {
1203  strcat(connstring, " port=");
1204  strcat(connstring, conn->port);
1205  }
1206 
1207  if (conn->username)
1208  {
1209  strcat(connstring, " user=");
1210  strcat(connstring, conn->username);
1211  }
1212 
1213  if (conn->password)
1214  {
1215  strcat(connstring, " password='");
1216  strcat(connstring, conn->password);
1217  strcat(connstring, "'");
1218  }
1219 
1220  if (conn->database)
1221  {
1222  strcat(connstring, " dbname=");
1223  strcat(connstring, conn->database);
1224  }
1225 
1226  if ( ! getenv("PGCLIENTENCODING") )
1227  {
1228  strcat(connstring, " client_encoding=UTF8");
1229  }
1230 
1231  return connstring;
1232 }
void * malloc(YYSIZE_T)

Here is the call graph for this function:

Here is the caller graph for this function: