PostGIS  2.1.10dev-r@@SVN_REVISION@@
static SHPLOADERCONFIG* create_new_file_config ( const char *  filename)
static

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

References shp_loader_config::encoding, shp_loader_config::geo_col, shp_loader_config::geography, GEOGRAPHY_DEFAULT, GEOMETRY_DEFAULT, shp_loader_config::schema, shp_loader_config::shp_file, and shp_loader_config::table.

Referenced by pgui_action_open_file_dialog(), and process_single_uri().

904 {
905  SHPLOADERCONFIG *loader_file_config;
906  char *table_start, *table_end;
907  int i;
908 
909  /* Generate a new configuration by copying the global options first and then
910  adding in the specific values for this file */
911  loader_file_config = malloc(sizeof(SHPLOADERCONFIG));
912  memcpy(loader_file_config, global_loader_config, sizeof(SHPLOADERCONFIG));
913 
914  /* Note: we must copy the encoding here since it is the only pass-by-reference
915  type set in set_loader_config_defaults() and each config needs its own copy
916  of any referenced items */
917  loader_file_config->encoding = strdup(global_loader_config->encoding);
918 
919  /* Copy the filename (we'll remove the .shp extension in a sec) */
920  loader_file_config->shp_file = strdup(filename);
921 
922  /* Generate the default table name from the filename */
923  table_start = loader_file_config->shp_file + strlen(loader_file_config->shp_file);
924  while (*table_start != '/' && *table_start != '\\' && table_start > loader_file_config->shp_file)
925  table_start--;
926 
927  /* Forward one to start of actual characters */
928  table_start++;
929 
930  /* Roll back from end to first . character. */
931  table_end = loader_file_config->shp_file + strlen(loader_file_config->shp_file);
932  while (*table_end != '.' && table_end > loader_file_config->shp_file && table_end > table_start )
933  table_end--;
934 
935  /* Copy the table name */
936  loader_file_config->table = malloc(table_end - table_start + 1);
937  memcpy(loader_file_config->table, table_start, table_end - table_start);
938  loader_file_config->table[table_end - table_start] = '\0';
939 
940  /* Force the table name to lower case */
941  for (i = 0; i < table_end - table_start; i++)
942  {
943  if (isupper(loader_file_config->table[i]) != 0)
944  loader_file_config->table[i] = tolower(loader_file_config->table[i]);
945  }
946 
947  /* Set the default schema to public */
948  loader_file_config->schema = strdup("public");
949 
950  /* Set the default geo column name */
952  loader_file_config->geo_col = strdup(GEOGRAPHY_DEFAULT);
953  else
954  loader_file_config->geo_col = strdup(GEOMETRY_DEFAULT);
955 
956  return loader_file_config;
957 }
static SHPLOADERCONFIG * global_loader_config
#define GEOGRAPHY_DEFAULT
#define GEOMETRY_DEFAULT

Here is the caller graph for this function: