PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ShpDumperGetConnectionStringFromConn()

char* ShpDumperGetConnectionStringFromConn ( SHPCONNECTIONCONFIG config)

Definition at line 1179 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().

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