PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ create_new_file_config()

static SHPLOADERCONFIG* create_new_file_config ( const char *  filename)
static

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

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

References shp_loader_config::encoding, shp_loader_config::geo_col, shp_loader_config::geography, GEOGRAPHY_DEFAULT, GEOMETRY_DEFAULT, global_loader_config, malloc(), 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().

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