PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ create_new_file_config()

static SHPLOADERCONFIG* create_new_file_config ( const char *  filename)
static

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

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