902{
904 char *table_start, *table_end;
905 int i;
906
907
908
911
912
913
914
916 if ( loader_file_config->
encoding == NULL )
917 {
918 free(loader_file_config);
919 pgui_seterr(
"Unable to allocate memory for encoding");
920 return 0;
921 }
922
923
924 loader_file_config->
shp_file = strdup(filename);
925 if ( loader_file_config->
shp_file == NULL )
926 {
928 free(loader_file_config);
929 pgui_seterr(
"Unable to allocate memory for filename");
930 return 0;
931 }
932
933
934 table_start = loader_file_config->
shp_file + strlen(loader_file_config->
shp_file);
935 while (*table_start !=
'/' && *table_start !=
'\\' && table_start > loader_file_config->
shp_file)
936 table_start--;
937
938
939 table_start++;
940
941
942 table_end = loader_file_config->
shp_file + strlen(loader_file_config->
shp_file);
943 while (*table_end !=
'.' && table_end > loader_file_config->
shp_file && table_end > table_start )
944 table_end--;
945
946
947 loader_file_config->
table =
malloc(table_end - table_start + 1);
948 memcpy(loader_file_config->
table, table_start, table_end - table_start);
949 loader_file_config->
table[table_end - table_start] =
'\0';
950
951
952 for (i = 0; i < table_end - table_start; i++)
953 {
954 if (isupper(loader_file_config->
table[i]) != 0)
955 loader_file_config->
table[i] = tolower(loader_file_config->
table[i]);
956 }
957
958
959 loader_file_config->
schema = strdup(
"public");
960
961
964 else
966
967 return loader_file_config;
968}
#define GEOGRAPHY_DEFAULT
static void static void static void static void pgui_seterr(const char *fmt,...) __attribute__((format(printf
static SHPLOADERCONFIG * global_loader_config