PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ create_new_file_config()

static SHPLOADERCONFIG * create_new_file_config ( const char *  filename)
static

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

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