PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ ShpDumperGetConnectionStringFromConn()

char* ShpDumperGetConnectionStringFromConn ( SHPCONNECTIONCONFIG conn)

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

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