PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ create_new_file_config()

static SHPLOADERCONFIG* create_new_file_config ( const char *  filename)
static

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

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

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