Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 5543845dedfc10c2 To 9bca3f7859551e1e
2018-01-14
| ||
17:16 | fixing for building on MinGW check-in: ef518a87ff user: sandro tags: trunk | |
2018-01-06
| ||
11:45 | supporting spatialite_dem (contributed by Mark Johnson) check-in: 5543845ded user: sandro tags: trunk | |
2017-09-25
| ||
16:18 | supporting extended version infos: -v or --version argument check-in: 3366873e1a user: sandro tags: trunk | |
2014-12-16
| ||
12:48 | updating to automake 1.14.1 check-in: 574499a88a user: sandro tags: trunk | |
2014-11-28
| ||
18:31 | fixing several typos reported by LinuxMinded check-in: 9bca3f7859 user: sandro tags: trunk | |
2014-11-22
| ||
21:18 | switching to 4.2.1 release candidate 1 check-in: f2d2cf93c6 user: sandro tags: trunk | |
Changes to Makefile-static-MinGW.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 .. 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 .. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 .. 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 .. 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ... 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 ... 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 ... 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 ... 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 ... 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 ... 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 ... 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 ... 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 ... 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
all: ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe \ ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe \ ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe \ ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe \ ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe \ ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe \ ./static_bin/spatialite_osm_overpass.exe ./static_bin/shp_sanitize.exe \ ./static_bin/spatialite_xml_collapse.exe \ ./static_bin/spatialite_xml_validator.exe \ ./static_bin/spatialite_xml_load.exe \ ./static_bin/spatialite_xml_print.exe ./static_bin/spatialite.exe: shell.o $(GG) shell.o -o ./static_bin/spatialite.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe: spatialite_tool.o $(GG) spatialite_tool.o -o \ ./static_bin/spatialite_tool.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite_tool.exe ./static_bin/spatialite_convert.exe: spatialite_convert.o $(GG) spatialite_convert.o -o \ ./static_bin/spatialite_convert.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe: spatialite_dxf.o $(GG) spatialite_dxf.o -o \ ./static_bin/spatialite_dxf.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_dxf.exe ./static_bin/spatialite_network.exe: spatialite_network.o $(GG) spatialite_network.o -o ./static_bin/spatialite_network.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe: shp_doctor.o $(GG) shp_doctor.o -o ./static_bin/shp_doctor.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ /usr/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_doctor.exe ./static_bin/shp_sanitize.exe: shp_sanitize.o $(GG) shp_sanitize.o -o ./static_bin/shp_sanitize.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ /usr/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_sanitize.exe ./static_bin/exif_loader.exe: exif_loader.o $(GG) exif_loader.o -o ./static_bin/exif_loader.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe: spatialite_osm_net.o $(GG) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libreadosm.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_net.exe ./static_bin/spatialite_osm_map.exe: spatialite_osm_map.o $(GG) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libiconv.a \ /usr/local/lib/libfreexl.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe: spatialite_gml.o $(GG) spatialite_gml.o -o ./static_bin/spatialite_gml.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_gml.exe ./static_bin/spatialite_osm_raw.exe: spatialite_osm_raw.o $(GG) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libreadosm.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe: spatialite_osm_filter.o $(GG) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_filter.exe ./static_bin/spatialite_osm_overpass.exe: spatialite_osm_overpass.o $(GG) spatialite_osm_overpass.o -o ./static_bin/spatialite_osm_overpass.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_overpass.exe ./static_bin/spatialite_xml_collapse.exe: spatialite_xml_collapse.o $(GG) spatialite_xml_collapse.o -o ./static_bin/spatialite_xml_collapse.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lws2_32 -static-libgcc strip --strip-all ./static_bin/spatialite_xml_validator.exe ./static_bin/spatialite_xml_load.exe: spatialite_xml_load.o $(GG) spatialite_xml_load.o -o ./static_bin/spatialite_xml_load.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libexpat.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_load.exe ./static_bin/spatialite_xml_print.exe: spatialite_xml_print.o $(GG) spatialite_xml_print.o -o ./static_bin/spatialite_xml_print.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/librttopo.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ $(CC) $(CFLAGS) spatialite_tool.c -c spatialite_network.o: $(CC) $(CFLAGS) spatialite_network.c -c shp_doctor.o: $(CC) $(CFLAGS) shp_doctor.c -c shp_sanitize.o: $(CC) $(CFLAGS) shp_sanitize.c -c exif_loader.o: $(CC) $(CFLAGS) exif_loader.c -c spatialite_osm_net.o: $(CC) $(CFLAGS) spatialite_osm_net.c -c |
| | | | | | | < < < < < < < < < < < < < < < < | | | | | | | | | | < < < |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 .. 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 .. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 .. 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 .. 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ... 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 ... 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 ... 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 ... 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 ... 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 ... 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 ... 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 ... 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 ... 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 ... 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 ... 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
all: ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe \ ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe \ ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe \ ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe \ ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe \ ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe \ ./static_bin/spatialite_osm_overpass.exe \ ./static_bin/spatialite_xml_collapse.exe \ ./static_bin/spatialite_xml_validator.exe \ ./static_bin/spatialite_xml_load.exe \ ./static_bin/spatialite_xml_print.exe ./static_bin/spatialite.exe: shell.o $(GG) shell.o -o ./static_bin/spatialite.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe: spatialite_tool.o $(GG) spatialite_tool.o -o \ ./static_bin/spatialite_tool.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite_tool.exe ./static_bin/spatialite_convert.exe: spatialite_convert.o $(GG) spatialite_convert.o -o \ ./static_bin/spatialite_convert.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ strip --strip-all ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe: spatialite_dxf.o $(GG) spatialite_dxf.o -o \ ./static_bin/spatialite_dxf.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_dxf.exe ./static_bin/spatialite_network.exe: spatialite_network.o $(GG) spatialite_network.o -o ./static_bin/spatialite_network.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe: shp_doctor.o $(GG) shp_doctor.o -o ./static_bin/shp_doctor.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ /usr/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_doctor.exe ./static_bin/exif_loader.exe: exif_loader.o $(GG) exif_loader.o -o ./static_bin/exif_loader.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe: spatialite_osm_net.o $(GG) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libreadosm.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_net.exe ./static_bin/spatialite_osm_map.exe: spatialite_osm_map.o $(GG) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libiconv.a \ /usr/local/lib/libfreexl.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe: spatialite_gml.o $(GG) spatialite_gml.o -o ./static_bin/spatialite_gml.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_gml.exe ./static_bin/spatialite_osm_raw.exe: spatialite_osm_raw.o $(GG) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libreadosm.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe: spatialite_osm_filter.o $(GG) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_filter.exe ./static_bin/spatialite_osm_overpass.exe: spatialite_osm_overpass.o $(GG) spatialite_osm_overpass.o -o ./static_bin/spatialite_osm_overpass.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_overpass.exe ./static_bin/spatialite_xml_collapse.exe: spatialite_xml_collapse.o $(GG) spatialite_xml_collapse.o -o ./static_bin/spatialite_xml_collapse.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ -lm -lws2_32 -static-libgcc strip --strip-all ./static_bin/spatialite_xml_validator.exe ./static_bin/spatialite_xml_load.exe: spatialite_xml_load.o $(GG) spatialite_xml_load.o -o ./static_bin/spatialite_xml_load.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libexpat.a \ ................................................................................ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_load.exe ./static_bin/spatialite_xml_print.exe: spatialite_xml_print.o $(GG) spatialite_xml_print.o -o ./static_bin/spatialite_xml_print.exe \ /usr/local/lib/libspatialite.a \ /usr/local/lib/libsqlite3.a \ /usr/local/lib/liblwgeom.a \ /usr/local/lib/libxml2.a \ /usr/local/lib/liblzma.a \ /usr/local/lib/libproj.a \ /usr/local/lib/libgeos_c.a \ /usr/local/lib/libgeos.a \ /usr/local/lib/libfreexl.a \ /usr/local/lib/libz.a \ ................................................................................ $(CC) $(CFLAGS) spatialite_tool.c -c spatialite_network.o: $(CC) $(CFLAGS) spatialite_network.c -c shp_doctor.o: $(CC) $(CFLAGS) shp_doctor.c -c exif_loader.o: $(CC) $(CFLAGS) exif_loader.c -c spatialite_osm_net.o: $(CC) $(CFLAGS) spatialite_osm_net.c -c |
Deleted Makefile-static-mingw32.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# SandroFurieri (c) 2009 # Makefile Spatialite statically linked CLI-tools [Win MSYS/MinGW] CFLAGS = -Wall -Wextra -Wunused -pedantic -I/mingw32/local/include GG = g++ -static CC = gcc -static all: ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe \ ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe \ ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe \ ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe \ ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe \ ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe \ ./static_bin/spatialite_osm_overpass.exe ./static_bin/shp_sanitize.exe \ ./static_bin/spatialite_xml_collapse.exe \ ./static_bin/spatialite_xml_validator.exe \ ./static_bin/spatialite_xml_load.exe \ ./static_bin/spatialite_xml2utf8.exe \ ./static_bin/spatialite_xml_print.exe ./static_bin/spatialite.exe: shell.o $(GG) shell.o -o ./static_bin/spatialite.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe: spatialite_tool.o $(GG) spatialite_tool.o -o \ ./static_bin/spatialite_tool.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_tool.exe ./static_bin/spatialite_convert.exe: spatialite_convert.o $(GG) spatialite_convert.o -o \ ./static_bin/spatialite_convert.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe: spatialite_dxf.o $(GG) spatialite_dxf.o -o \ ./static_bin/spatialite_dxf.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_dxf.exe ./static_bin/spatialite_network.exe: spatialite_network.o $(GG) spatialite_network.o -o ./static_bin/spatialite_network.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe: shp_doctor.o $(GG) shp_doctor.o -o ./static_bin/shp_doctor.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_doctor.exe ./static_bin/shp_sanitize.exe: shp_sanitize.o $(GG) shp_sanitize.o -o ./static_bin/shp_sanitize.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_sanitize.exe ./static_bin/exif_loader.exe: exif_loader.o $(GG) exif_loader.o -o ./static_bin/exif_loader.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe: spatialite_osm_net.o $(GG) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libreadosm.a \ /mingw32/local/lib/libiconv.a \ /mingw32/local/lib/libexpat.a \ /mingw32/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_net.exe ./static_bin/spatialite_osm_map.exe: spatialite_osm_map.o $(GG) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libiconv.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libreadosm.a \ /mingw32/local/lib/libexpat.a \ /mingw32/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe: spatialite_gml.o $(GG) spatialite_gml.o -o ./static_bin/spatialite_gml.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ /mingw32/local/lib/libexpat.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_gml.exe ./static_bin/spatialite_osm_raw.exe: spatialite_osm_raw.o $(GG) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libreadosm.a \ /mingw32/local/lib/libiconv.a \ /mingw32/local/lib/libexpat.a \ /mingw32/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe: spatialite_osm_filter.o $(GG) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_filter.exe ./static_bin/spatialite_osm_overpass.exe: spatialite_osm_overpass.o $(GG) spatialite_osm_overpass.o -o ./static_bin/spatialite_osm_overpass.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_overpass.exe ./static_bin/spatialite_xml_collapse.exe: spatialite_xml_collapse.o $(GG) spatialite_xml_collapse.o -o ./static_bin/spatialite_xml_collapse.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_collapse.exe ./static_bin/spatialite_xml_validator.exe: spatialite_xml_validator.o $(CC) spatialite_xml_validator.o -o ./static_bin/spatialite_xml_validator.exe \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lws2_32 -static-libgcc strip --strip-all ./static_bin/spatialite_xml_validator.exe ./static_bin/spatialite_xml_load.exe: spatialite_xml_load.o $(GG) spatialite_xml_load.o -o ./static_bin/spatialite_xml_load.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libexpat.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_load.exe ./static_bin/spatialite_xml2utf8.exe: spatialite_xml2utf8.o $(CC) spatialite_xml2utf8.o -o ./static_bin/spatialite_xml2utf8.exe \ /mingw32/local/lib/libiconv.a \ -static-libgcc strip --strip-all ./static_bin/spatialite_xml2utf8.exe ./static_bin/spatialite_xml_print.exe: spatialite_xml_print.o $(GG) spatialite_xml_print.o -o ./static_bin/spatialite_xml_print.exe \ /mingw32/local/lib/libspatialite.a \ /mingw32/local/lib/libsqlite3.a \ /mingw32/local/lib/librttopo.a \ /mingw32/local/lib/libxml2.a \ /mingw32/local/lib/liblzma.a \ /mingw32/local/lib/libproj.a \ /mingw32/local/lib/libgeos_c.a \ /mingw32/local/lib/libgeos.a \ /mingw32/local/lib/libfreexl.a \ /mingw32/local/lib/libz.a \ /mingw32/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_print.exe shell.o: $(CC) $(CFLAGS) shell.c -c spatialite_tool.o: $(CC) $(CFLAGS) spatialite_tool.c -c spatialite_network.o: $(CC) $(CFLAGS) spatialite_network.c -c shp_doctor.o: $(CC) $(CFLAGS) shp_doctor.c -c shp_sanitize.o: $(CC) $(CFLAGS) shp_sanitize.c -c exif_loader.o: $(CC) $(CFLAGS) exif_loader.c -c spatialite_osm_net.o: $(CC) $(CFLAGS) spatialite_osm_net.c -c spatialite_osm_map.o: $(CC) $(CFLAGS) spatialite_osm_map.c -c spatialite_gml.o: $(CC) $(CFLAGS) spatialite_gml.c -c spatialite_osm_raw.o: $(CC) $(CFLAGS) spatialite_osm_raw.c -c spatialite_osm_filter.o: $(CC) $(CFLAGS) spatialite_osm_filter.c -c spatialite_osm_overpass.o: $(CC) $(CFLAGS) spatialite_osm_overpass.c -c spatialite_xml_collapse.o: $(CC) $(CFLAGS) spatialite_xml_collapse.c -c spatialite_xml_validator.o: $(CC) $(CFLAGS) spatialite_xml_validator.c -c spatialite_xml_load.o: $(CC) $(CFLAGS) spatialite_xml_load.c -c spatialite_xml2utf8.o: $(CC) $(CFLAGS) spatialite_xml2utf8.c -c spatialite_xml_print.o: $(CC) $(CFLAGS) spatialite_xml_print.c -c |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted Makefile-static-mingw64.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# SandroFurieri (c) 2009 # Makefile Spatialite statically linked CLI-tools [Win MSYS/MinGW] CFLAGS = -Wall -Wextra -Wunused -pedantic -I/mingw64/local/include GG = g++ -static CC = gcc -static all: ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe \ ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe \ ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe \ ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe \ ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe \ ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe \ ./static_bin/spatialite_osm_overpass.exe ./static_bin/shp_sanitize.exe \ ./static_bin/spatialite_xml_collapse.exe \ ./static_bin/spatialite_xml_validator.exe \ ./static_bin/spatialite_xml_load.exe \ ./static_bin/spatialite_xml2utf8.exe \ ./static_bin/spatialite_xml_print.exe ./static_bin/spatialite.exe: shell.o $(GG) shell.o -o ./static_bin/spatialite.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite.exe ./static_bin/spatialite_tool.exe: spatialite_tool.o $(GG) spatialite_tool.o -o \ ./static_bin/spatialite_tool.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_tool.exe ./static_bin/spatialite_convert.exe: spatialite_convert.o $(GG) spatialite_convert.o -o \ ./static_bin/spatialite_convert.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_convert.exe ./static_bin/spatialite_dxf.exe: spatialite_dxf.o $(GG) spatialite_dxf.o -o \ ./static_bin/spatialite_dxf.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_dxf.exe ./static_bin/spatialite_network.exe: spatialite_network.o $(GG) spatialite_network.o -o ./static_bin/spatialite_network.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_network.exe ./static_bin/shp_doctor.exe: shp_doctor.o $(GG) shp_doctor.o -o ./static_bin/shp_doctor.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_doctor.exe ./static_bin/shp_sanitize.exe: shp_sanitize.o $(GG) shp_sanitize.o -o ./static_bin/shp_sanitize.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/shp_sanitize.exe ./static_bin/exif_loader.exe: exif_loader.o $(GG) exif_loader.o -o ./static_bin/exif_loader.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/exif_loader.exe ./static_bin/spatialite_osm_net.exe: spatialite_osm_net.o $(GG) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libreadosm.a \ /mingw64/local/lib/libiconv.a \ /mingw64/local/lib/libexpat.a \ /mingw64/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_net.exe ./static_bin/spatialite_osm_map.exe: spatialite_osm_map.o $(GG) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libiconv.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libreadosm.a \ /mingw64/local/lib/libexpat.a \ /mingw64/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_map.exe ./static_bin/spatialite_gml.exe: spatialite_gml.o $(GG) spatialite_gml.o -o ./static_bin/spatialite_gml.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ /mingw64/local/lib/libexpat.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_gml.exe ./static_bin/spatialite_osm_raw.exe: spatialite_osm_raw.o $(GG) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libreadosm.a \ /mingw64/local/lib/libiconv.a \ /mingw64/local/lib/libexpat.a \ /mingw64/local/lib/libz.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_raw.exe ./static_bin/spatialite_osm_filter.exe: spatialite_osm_filter.o $(GG) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_filter.exe ./static_bin/spatialite_osm_overpass.exe: spatialite_osm_overpass.o $(GG) spatialite_osm_overpass.o -o ./static_bin/spatialite_osm_overpass.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_osm_overpass.exe ./static_bin/spatialite_xml_collapse.exe: spatialite_xml_collapse.o $(GG) spatialite_xml_collapse.o -o ./static_bin/spatialite_xml_collapse.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_collapse.exe ./static_bin/spatialite_xml_validator.exe: spatialite_xml_validator.o $(CC) spatialite_xml_validator.o -o ./static_bin/spatialite_xml_validator.exe \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lws2_32 -static-libgcc strip --strip-all ./static_bin/spatialite_xml_validator.exe ./static_bin/spatialite_xml_load.exe: spatialite_xml_load.o $(GG) spatialite_xml_load.o -o ./static_bin/spatialite_xml_load.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libexpat.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_load.exe ./static_bin/spatialite_xml2utf8.exe: spatialite_xml2utf8.o $(CC) spatialite_xml2utf8.o -o ./static_bin/spatialite_xml2utf8.exe \ /mingw64/local/lib/libiconv.a \ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_load.exe ./static_bin/spatialite_xml_print.exe: spatialite_xml_print.o $(GG) spatialite_xml_print.o -o ./static_bin/spatialite_xml_print.exe \ /mingw64/local/lib/libspatialite.a \ /mingw64/local/lib/libsqlite3.a \ /mingw64/local/lib/librttopo.a \ /mingw64/local/lib/libxml2.a \ /mingw64/local/lib/liblzma.a \ /mingw64/local/lib/libproj.a \ /mingw64/local/lib/libgeos_c.a \ /mingw64/local/lib/libgeos.a \ /mingw64/local/lib/libfreexl.a \ /mingw64/local/lib/libz.a \ /mingw64/local/lib/libiconv.a \ -lm -lmsimg32 -lws2_32 -static-libstdc++ -static-libgcc strip --strip-all ./static_bin/spatialite_xml_print.exe shell.o: $(CC) $(CFLAGS) shell.c -c spatialite_tool.o: $(CC) $(CFLAGS) spatialite_tool.c -c spatialite_network.o: $(CC) $(CFLAGS) spatialite_network.c -c shp_doctor.o: $(CC) $(CFLAGS) shp_doctor.c -c shp_sanitize.o: $(CC) $(CFLAGS) shp_sanitize.c -c exif_loader.o: $(CC) $(CFLAGS) exif_loader.c -c spatialite_osm_net.o: $(CC) $(CFLAGS) spatialite_osm_net.c -c spatialite_osm_map.o: $(CC) $(CFLAGS) spatialite_osm_map.c -c spatialite_gml.o: $(CC) $(CFLAGS) spatialite_gml.c -c spatialite_osm_raw.o: $(CC) $(CFLAGS) spatialite_osm_raw.c -c spatialite_osm_filter.o: $(CC) $(CFLAGS) spatialite_osm_filter.c -c spatialite_osm_overpass.o: $(CC) $(CFLAGS) spatialite_osm_overpass.c -c spatialite_xml_collapse.o: $(CC) $(CFLAGS) spatialite_xml_collapse.c -c spatialite_xml_validator.o: $(CC) $(CFLAGS) spatialite_xml_validator.c -c spatialite_xml_load.o: $(CC) $(CFLAGS) spatialite_xml_load.c -c spatialite_xml2utf8.o: $(CC) $(CFLAGS) spatialite_xml2utf8.c -c spatialite_xml_print.o: $(CC) $(CFLAGS) spatialite_xml_print.c -c |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to Makefile.am.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
ACLOCAL_AMFLAGS = -I m4 if NO_READOSM bin_PROGRAMS = spatialite \ spatialite_tool \ spatialite_network \ shp_doctor shp_sanitize \ exif_loader \ spatialite_osm_filter \ spatialite_gml \ spatialite_convert \ spatialite_dxf \ spatialite_xml_validator \ spatialite_xml_load \ spatialite_xml2utf8 \ spatialite_xml_collapse \ spatialite_xml_print \ spatialite_osm_overpass \ spatialite_dem else bin_PROGRAMS = spatialite \ spatialite_tool \ spatialite_network \ shp_doctor shp_sanitize \ exif_loader \ spatialite_osm_net \ spatialite_osm_map \ spatialite_osm_raw \ spatialite_osm_filter \ spatialite_gml \ spatialite_convert \ spatialite_dxf \ spatialite_xml_validator \ spatialite_xml_load \ spatialite_xml2utf8 \ spatialite_xml_collapse \ spatialite_xml_print \ spatialite_osm_overpass \ spatialite_dem endif AM_CPPFLAGS = @CFLAGS@ @CPPFLAGS@ @LIBXML2_CFLAGS@ AM_CPPFLAGS += -I$(top_srcdir) spatialite_SOURCES = shell.c spatialite_tool_SOURCES = spatialite_tool.c spatialite_network_SOURCES = spatialite_network.c shp_doctor_SOURCES = shp_doctor.c shp_sanitize_SOURCES = shp_sanitize.c exif_loader_SOURCES = exif_loader.c spatialite_xml_validator_SOURCES = spatialite_xml_validator.c spatialite_xml_load_SOURCES = spatialite_xml_load.c spatialite_xml2utf8_SOURCES = spatialite_xml2utf8.c spatialite_xml_collapse_SOURCES = spatialite_xml_collapse.c spatialite_xml_print_SOURCES = spatialite_xml_print.c if NO_READOSM else spatialite_osm_net_SOURCES = spatialite_osm_net.c spatialite_osm_map_SOURCES = spatialite_osm_map.c spatialite_osm_raw_SOURCES = spatialite_osm_raw.c endif spatialite_osm_filter_SOURCES = spatialite_osm_filter.c spatialite_gml_SOURCES = spatialite_gml.c spatialite_osm_overpass_SOURCES = spatialite_osm_overpass.c spatialite_dem_SOURCES = spatialite_dem.c spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_osm_overpass_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBXML2_LIBS@ spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ -lexpat spatialite_dem_LDADD = @LIBSPATIALITE_LIBS@ spatialite_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ @READLINE_LIBS@ spatialite_xml_validator_LDADD = @LIBXML2_LIBS@ spatialite_xml_load_LDADD = @LIBSPATIALITE_LIBS@ \ -lexpat spatialite_xml_collapse_LDADD = @LIBSPATIALITE_LIBS@ ................................................................................ spatialite_xml_print_LADD = @LIBSPATIALIATE_LIBS@ LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ EXTRA_DIST = makefile.vc nmake.opt \ config-msvc.h \ Makefile-static-MinGW \ Makefile-static-mingw32 \ Makefile-static-mingw64 \ Makefile-static-Linux \ Makefile-static-MacOsX AUTOMAKE_OPTIONS = dist-zip foreign |
|
<
|
<
|
<
|
<
|
<
<
<
<
<
<
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
..
78
79
80
81
82
83
84
85
86
87
88
89
|
ACLOCAL_AMFLAGS = -I m4
if NO_READOSM
bin_PROGRAMS = spatialite \
spatialite_tool \
spatialite_network \
shp_doctor \
exif_loader \
spatialite_osm_filter \
spatialite_gml \
spatialite_convert \
spatialite_dxf \
spatialite_xml_validator \
spatialite_xml_load \
spatialite_xml_collapse \
spatialite_xml_print \
spatialite_osm_overpass
else
bin_PROGRAMS = spatialite \
spatialite_tool \
spatialite_network \
shp_doctor \
exif_loader \
spatialite_osm_net \
spatialite_osm_map \
spatialite_osm_raw \
spatialite_osm_filter \
spatialite_gml \
spatialite_convert \
spatialite_dxf \
spatialite_xml_validator \
spatialite_xml_load \
spatialite_xml_collapse \
spatialite_xml_print \
spatialite_osm_overpass
endif
AM_CPPFLAGS = @CFLAGS@ @LIBXML2_CFLAGS@
AM_CPPFLAGS += -I$(top_srcdir)
spatialite_SOURCES = shell.c
spatialite_tool_SOURCES = spatialite_tool.c
spatialite_network_SOURCES = spatialite_network.c
shp_doctor_SOURCES = shp_doctor.c
exif_loader_SOURCES = exif_loader.c
spatialite_xml_validator_SOURCES = spatialite_xml_validator.c
spatialite_xml_load_SOURCES = spatialite_xml_load.c
spatialite_xml_collapse_SOURCES = spatialite_xml_collapse.c
spatialite_xml_print_SOURCES = spatialite_xml_print.c
if NO_READOSM
else
spatialite_osm_net_SOURCES = spatialite_osm_net.c
spatialite_osm_map_SOURCES = spatialite_osm_map.c
spatialite_osm_raw_SOURCES = spatialite_osm_raw.c
endif
spatialite_osm_filter_SOURCES = spatialite_osm_filter.c
spatialite_gml_SOURCES = spatialite_gml.c
spatialite_osm_overpass_SOURCES = spatialite_osm_overpass.c
spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
spatialite_osm_overpass_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ @LIBXML2_LIBS@
spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ \
-lexpat
spatialite_LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@ \
@READLINE_LIBS@
spatialite_xml_validator_LDADD = @LIBXML2_LIBS@
spatialite_xml_load_LDADD = @LIBSPATIALITE_LIBS@ \
-lexpat
spatialite_xml_collapse_LDADD = @LIBSPATIALITE_LIBS@
................................................................................
spatialite_xml_print_LADD = @LIBSPATIALIATE_LIBS@
LDADD = @LIBSPATIALITE_LIBS@ \
@LIBFREEXL_LIBS@
EXTRA_DIST = makefile.vc nmake.opt \
config-msvc.h \
Makefile-static-MinGW \
Makefile-static-Linux \
Makefile-static-MacOsX
AUTOMAKE_OPTIONS = dist-zip
|
Changes to Makefile.in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 .. 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 ... 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 ... 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 ... 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 ... 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 ... 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 ... 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 ... 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 ... 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 ... 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 ... 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 ... 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 ... 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 ... 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 ... 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 .... 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ ................................................................................ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @NO_READOSM_FALSE@bin_PROGRAMS = spatialite$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_tool$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_network$(EXEEXT) \ @NO_READOSM_FALSE@ shp_doctor$(EXEEXT) shp_sanitize$(EXEEXT) \ @NO_READOSM_FALSE@ exif_loader$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_net$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_map$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_raw$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_filter$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_gml$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_convert$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_dxf$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_validator$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_load$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml2utf8$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_collapse$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_print$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_overpass$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_dem$(EXEEXT) @NO_READOSM_TRUE@bin_PROGRAMS = spatialite$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_tool$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_network$(EXEEXT) \ @NO_READOSM_TRUE@ shp_doctor$(EXEEXT) shp_sanitize$(EXEEXT) \ @NO_READOSM_TRUE@ exif_loader$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_osm_filter$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_gml$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_convert$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_dxf$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_validator$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_load$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml2utf8$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_collapse$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_print$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_osm_overpass$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_dem$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" ................................................................................ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_shp_doctor_OBJECTS = shp_doctor.$(OBJEXT) shp_doctor_OBJECTS = $(am_shp_doctor_OBJECTS) shp_doctor_LDADD = $(LDADD) shp_doctor_DEPENDENCIES = am_shp_sanitize_OBJECTS = shp_sanitize.$(OBJEXT) shp_sanitize_OBJECTS = $(am_shp_sanitize_OBJECTS) shp_sanitize_LDADD = $(LDADD) shp_sanitize_DEPENDENCIES = am_spatialite_OBJECTS = shell.$(OBJEXT) spatialite_OBJECTS = $(am_spatialite_OBJECTS) spatialite_DEPENDENCIES = spatialite_convert_SOURCES = spatialite_convert.c spatialite_convert_OBJECTS = spatialite_convert.$(OBJEXT) spatialite_convert_LDADD = $(LDADD) spatialite_convert_DEPENDENCIES = am_spatialite_dem_OBJECTS = spatialite_dem.$(OBJEXT) spatialite_dem_OBJECTS = $(am_spatialite_dem_OBJECTS) spatialite_dem_DEPENDENCIES = spatialite_dxf_SOURCES = spatialite_dxf.c spatialite_dxf_OBJECTS = spatialite_dxf.$(OBJEXT) spatialite_dxf_LDADD = $(LDADD) spatialite_dxf_DEPENDENCIES = am_spatialite_gml_OBJECTS = spatialite_gml.$(OBJEXT) spatialite_gml_OBJECTS = $(am_spatialite_gml_OBJECTS) spatialite_gml_DEPENDENCIES = ................................................................................ @NO_READOSM_FALSE@ spatialite_osm_raw.$(OBJEXT) spatialite_osm_raw_OBJECTS = $(am_spatialite_osm_raw_OBJECTS) spatialite_osm_raw_DEPENDENCIES = am_spatialite_tool_OBJECTS = spatialite_tool.$(OBJEXT) spatialite_tool_OBJECTS = $(am_spatialite_tool_OBJECTS) spatialite_tool_LDADD = $(LDADD) spatialite_tool_DEPENDENCIES = am_spatialite_xml2utf8_OBJECTS = spatialite_xml2utf8.$(OBJEXT) spatialite_xml2utf8_OBJECTS = $(am_spatialite_xml2utf8_OBJECTS) spatialite_xml2utf8_LDADD = $(LDADD) spatialite_xml2utf8_DEPENDENCIES = am_spatialite_xml_collapse_OBJECTS = \ spatialite_xml_collapse.$(OBJEXT) spatialite_xml_collapse_OBJECTS = \ $(am_spatialite_xml_collapse_OBJECTS) spatialite_xml_collapse_DEPENDENCIES = am_spatialite_xml_load_OBJECTS = spatialite_xml_load.$(OBJEXT) spatialite_xml_load_OBJECTS = $(am_spatialite_xml_load_OBJECTS) ................................................................................ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(exif_loader_SOURCES) $(shp_doctor_SOURCES) \ $(shp_sanitize_SOURCES) $(spatialite_SOURCES) \ spatialite_convert.c $(spatialite_dem_SOURCES) \ spatialite_dxf.c $(spatialite_gml_SOURCES) \ $(spatialite_network_SOURCES) $(spatialite_osm_filter_SOURCES) \ $(spatialite_osm_map_SOURCES) $(spatialite_osm_net_SOURCES) \ $(spatialite_osm_overpass_SOURCES) \ $(spatialite_osm_raw_SOURCES) $(spatialite_tool_SOURCES) \ $(spatialite_xml2utf8_SOURCES) \ $(spatialite_xml_collapse_SOURCES) \ $(spatialite_xml_load_SOURCES) $(spatialite_xml_print_SOURCES) \ $(spatialite_xml_validator_SOURCES) DIST_SOURCES = $(exif_loader_SOURCES) $(shp_doctor_SOURCES) \ $(shp_sanitize_SOURCES) $(spatialite_SOURCES) \ spatialite_convert.c $(spatialite_dem_SOURCES) \ spatialite_dxf.c $(spatialite_gml_SOURCES) \ $(spatialite_network_SOURCES) $(spatialite_osm_filter_SOURCES) \ $(am__spatialite_osm_map_SOURCES_DIST) \ $(am__spatialite_osm_net_SOURCES_DIST) \ $(spatialite_osm_overpass_SOURCES) \ $(am__spatialite_osm_raw_SOURCES_DIST) \ $(spatialite_tool_SOURCES) $(spatialite_xml2utf8_SOURCES) \ $(spatialite_xml_collapse_SOURCES) \ $(spatialite_xml_load_SOURCES) $(spatialite_xml_print_SOURCES) \ $(spatialite_xml_validator_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac ................................................................................ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \ COPYING ChangeLog INSTALL NEWS README compile config.guess \ config.sub depcomp install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ ................................................................................ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ RTTOPO_CFLAGS = @RTTOPO_CFLAGS@ RTTOPO_LIBS = @RTTOPO_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ ................................................................................ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = @CFLAGS@ @CPPFLAGS@ @LIBXML2_CFLAGS@ -I$(top_srcdir) spatialite_SOURCES = shell.c spatialite_tool_SOURCES = spatialite_tool.c spatialite_network_SOURCES = spatialite_network.c shp_doctor_SOURCES = shp_doctor.c shp_sanitize_SOURCES = shp_sanitize.c exif_loader_SOURCES = exif_loader.c spatialite_xml_validator_SOURCES = spatialite_xml_validator.c spatialite_xml_load_SOURCES = spatialite_xml_load.c spatialite_xml2utf8_SOURCES = spatialite_xml2utf8.c spatialite_xml_collapse_SOURCES = spatialite_xml_collapse.c spatialite_xml_print_SOURCES = spatialite_xml_print.c @NO_READOSM_FALSE@spatialite_osm_net_SOURCES = spatialite_osm_net.c @NO_READOSM_FALSE@spatialite_osm_map_SOURCES = spatialite_osm_map.c @NO_READOSM_FALSE@spatialite_osm_raw_SOURCES = spatialite_osm_raw.c spatialite_osm_filter_SOURCES = spatialite_osm_filter.c spatialite_gml_SOURCES = spatialite_gml.c spatialite_osm_overpass_SOURCES = spatialite_osm_overpass.c spatialite_dem_SOURCES = spatialite_dem.c spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_osm_overpass_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBXML2_LIBS@ spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \ ................................................................................ spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ -lexpat spatialite_dem_LDADD = @LIBSPATIALITE_LIBS@ spatialite_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ @READLINE_LIBS@ spatialite_xml_validator_LDADD = @LIBXML2_LIBS@ spatialite_xml_load_LDADD = @LIBSPATIALITE_LIBS@ \ -lexpat ................................................................................ spatialite_xml_print_LADD = @LIBSPATIALIATE_LIBS@ LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ EXTRA_DIST = makefile.vc nmake.opt \ config-msvc.h \ Makefile-static-MinGW \ Makefile-static-mingw32 \ Makefile-static-mingw64 \ Makefile-static-Linux \ Makefile-static-MacOsX AUTOMAKE_OPTIONS = dist-zip foreign all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ ................................................................................ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 ................................................................................ @rm -f exif_loader$(EXEEXT) $(AM_V_CCLD)$(LINK) $(exif_loader_OBJECTS) $(exif_loader_LDADD) $(LIBS) shp_doctor$(EXEEXT): $(shp_doctor_OBJECTS) $(shp_doctor_DEPENDENCIES) $(EXTRA_shp_doctor_DEPENDENCIES) @rm -f shp_doctor$(EXEEXT) $(AM_V_CCLD)$(LINK) $(shp_doctor_OBJECTS) $(shp_doctor_LDADD) $(LIBS) shp_sanitize$(EXEEXT): $(shp_sanitize_OBJECTS) $(shp_sanitize_DEPENDENCIES) $(EXTRA_shp_sanitize_DEPENDENCIES) @rm -f shp_sanitize$(EXEEXT) $(AM_V_CCLD)$(LINK) $(shp_sanitize_OBJECTS) $(shp_sanitize_LDADD) $(LIBS) spatialite$(EXEEXT): $(spatialite_OBJECTS) $(spatialite_DEPENDENCIES) $(EXTRA_spatialite_DEPENDENCIES) @rm -f spatialite$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_OBJECTS) $(spatialite_LDADD) $(LIBS) spatialite_convert$(EXEEXT): $(spatialite_convert_OBJECTS) $(spatialite_convert_DEPENDENCIES) $(EXTRA_spatialite_convert_DEPENDENCIES) @rm -f spatialite_convert$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_convert_OBJECTS) $(spatialite_convert_LDADD) $(LIBS) spatialite_dem$(EXEEXT): $(spatialite_dem_OBJECTS) $(spatialite_dem_DEPENDENCIES) $(EXTRA_spatialite_dem_DEPENDENCIES) @rm -f spatialite_dem$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_dem_OBJECTS) $(spatialite_dem_LDADD) $(LIBS) spatialite_dxf$(EXEEXT): $(spatialite_dxf_OBJECTS) $(spatialite_dxf_DEPENDENCIES) $(EXTRA_spatialite_dxf_DEPENDENCIES) @rm -f spatialite_dxf$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_dxf_OBJECTS) $(spatialite_dxf_LDADD) $(LIBS) spatialite_gml$(EXEEXT): $(spatialite_gml_OBJECTS) $(spatialite_gml_DEPENDENCIES) $(EXTRA_spatialite_gml_DEPENDENCIES) @rm -f spatialite_gml$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_gml_OBJECTS) $(spatialite_gml_LDADD) $(LIBS) ................................................................................ @rm -f spatialite_osm_raw$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_osm_raw_OBJECTS) $(spatialite_osm_raw_LDADD) $(LIBS) spatialite_tool$(EXEEXT): $(spatialite_tool_OBJECTS) $(spatialite_tool_DEPENDENCIES) $(EXTRA_spatialite_tool_DEPENDENCIES) @rm -f spatialite_tool$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_tool_OBJECTS) $(spatialite_tool_LDADD) $(LIBS) spatialite_xml2utf8$(EXEEXT): $(spatialite_xml2utf8_OBJECTS) $(spatialite_xml2utf8_DEPENDENCIES) $(EXTRA_spatialite_xml2utf8_DEPENDENCIES) @rm -f spatialite_xml2utf8$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_xml2utf8_OBJECTS) $(spatialite_xml2utf8_LDADD) $(LIBS) spatialite_xml_collapse$(EXEEXT): $(spatialite_xml_collapse_OBJECTS) $(spatialite_xml_collapse_DEPENDENCIES) $(EXTRA_spatialite_xml_collapse_DEPENDENCIES) @rm -f spatialite_xml_collapse$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_xml_collapse_OBJECTS) $(spatialite_xml_collapse_LDADD) $(LIBS) spatialite_xml_load$(EXEEXT): $(spatialite_xml_load_OBJECTS) $(spatialite_xml_load_DEPENDENCIES) $(EXTRA_spatialite_xml_load_DEPENDENCIES) @rm -f spatialite_xml_load$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_xml_load_OBJECTS) $(spatialite_xml_load_LDADD) $(LIBS) ................................................................................ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exif_loader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shp_doctor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shp_sanitize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_convert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_dem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_dxf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_gml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_network.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_filter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_net.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_overpass.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_raw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_tool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml2utf8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_collapse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_load.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_print.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_validator.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< ................................................................................ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir ................................................................................ $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: ................................................................................ # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ ................................................................................ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: |
| | | < < < < < < < < < < | < < | < | < < | < > > > > > < < < < < < < < < < < < < | < | | | < | < | | < | < < < < < | < < < < < < | | | | | > | | < < < < < < < < < < < < < < < | | | < < < | < < < | | | | | < < < |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 .. 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 ... 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 ... 182 183 184 185 186 187 188 189 190 191 192 193 194 195 ... 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 281 282 283 284 285 286 287 288 289 290 291 292 293 294 ... 376 377 378 379 380 381 382 383 384 385 386 387 388 389 ... 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 ... 467 468 469 470 471 472 473 474 475 476 477 478 479 480 ... 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 ... 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 ... 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 ... 643 644 645 646 647 648 649 650 651 652 653 654 655 656 ... 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 ... 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 ... 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 ... 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 .... 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# Makefile.in generated by automake 1.13.4 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ ................................................................................ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @NO_READOSM_FALSE@bin_PROGRAMS = spatialite$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_tool$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_network$(EXEEXT) \ @NO_READOSM_FALSE@ shp_doctor$(EXEEXT) exif_loader$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_net$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_map$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_raw$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_filter$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_gml$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_convert$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_dxf$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_validator$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_load$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_collapse$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_xml_print$(EXEEXT) \ @NO_READOSM_FALSE@ spatialite_osm_overpass$(EXEEXT) @NO_READOSM_TRUE@bin_PROGRAMS = spatialite$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_tool$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_network$(EXEEXT) \ @NO_READOSM_TRUE@ shp_doctor$(EXEEXT) exif_loader$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_osm_filter$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_gml$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_convert$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_dxf$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_validator$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_load$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_collapse$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_xml_print$(EXEEXT) \ @NO_READOSM_TRUE@ spatialite_osm_overpass$(EXEEXT) subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in depcomp COPYING config.guess config.sub \ install-sh missing ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" ................................................................................ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_shp_doctor_OBJECTS = shp_doctor.$(OBJEXT) shp_doctor_OBJECTS = $(am_shp_doctor_OBJECTS) shp_doctor_LDADD = $(LDADD) shp_doctor_DEPENDENCIES = am_spatialite_OBJECTS = shell.$(OBJEXT) spatialite_OBJECTS = $(am_spatialite_OBJECTS) spatialite_DEPENDENCIES = spatialite_convert_SOURCES = spatialite_convert.c spatialite_convert_OBJECTS = spatialite_convert.$(OBJEXT) spatialite_convert_LDADD = $(LDADD) spatialite_convert_DEPENDENCIES = spatialite_dxf_SOURCES = spatialite_dxf.c spatialite_dxf_OBJECTS = spatialite_dxf.$(OBJEXT) spatialite_dxf_LDADD = $(LDADD) spatialite_dxf_DEPENDENCIES = am_spatialite_gml_OBJECTS = spatialite_gml.$(OBJEXT) spatialite_gml_OBJECTS = $(am_spatialite_gml_OBJECTS) spatialite_gml_DEPENDENCIES = ................................................................................ @NO_READOSM_FALSE@ spatialite_osm_raw.$(OBJEXT) spatialite_osm_raw_OBJECTS = $(am_spatialite_osm_raw_OBJECTS) spatialite_osm_raw_DEPENDENCIES = am_spatialite_tool_OBJECTS = spatialite_tool.$(OBJEXT) spatialite_tool_OBJECTS = $(am_spatialite_tool_OBJECTS) spatialite_tool_LDADD = $(LDADD) spatialite_tool_DEPENDENCIES = am_spatialite_xml_collapse_OBJECTS = \ spatialite_xml_collapse.$(OBJEXT) spatialite_xml_collapse_OBJECTS = \ $(am_spatialite_xml_collapse_OBJECTS) spatialite_xml_collapse_DEPENDENCIES = am_spatialite_xml_load_OBJECTS = spatialite_xml_load.$(OBJEXT) spatialite_xml_load_OBJECTS = $(am_spatialite_xml_load_OBJECTS) ................................................................................ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(exif_loader_SOURCES) $(shp_doctor_SOURCES) \ $(spatialite_SOURCES) spatialite_convert.c spatialite_dxf.c \ $(spatialite_gml_SOURCES) $(spatialite_network_SOURCES) \ $(spatialite_osm_filter_SOURCES) $(spatialite_osm_map_SOURCES) \ $(spatialite_osm_net_SOURCES) \ $(spatialite_osm_overpass_SOURCES) \ $(spatialite_osm_raw_SOURCES) $(spatialite_tool_SOURCES) \ $(spatialite_xml_collapse_SOURCES) \ $(spatialite_xml_load_SOURCES) $(spatialite_xml_print_SOURCES) \ $(spatialite_xml_validator_SOURCES) DIST_SOURCES = $(exif_loader_SOURCES) $(shp_doctor_SOURCES) \ $(spatialite_SOURCES) spatialite_convert.c spatialite_dxf.c \ $(spatialite_gml_SOURCES) $(spatialite_network_SOURCES) \ $(spatialite_osm_filter_SOURCES) \ $(am__spatialite_osm_map_SOURCES_DIST) \ $(am__spatialite_osm_net_SOURCES_DIST) \ $(spatialite_osm_overpass_SOURCES) \ $(am__spatialite_osm_raw_SOURCES_DIST) \ $(spatialite_tool_SOURCES) $(spatialite_xml_collapse_SOURCES) \ $(spatialite_xml_load_SOURCES) $(spatialite_xml_print_SOURCES) \ $(spatialite_xml_validator_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac ................................................................................ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ ................................................................................ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ ................................................................................ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = @CFLAGS@ @LIBXML2_CFLAGS@ -I$(top_srcdir) spatialite_SOURCES = shell.c spatialite_tool_SOURCES = spatialite_tool.c spatialite_network_SOURCES = spatialite_network.c shp_doctor_SOURCES = shp_doctor.c exif_loader_SOURCES = exif_loader.c spatialite_xml_validator_SOURCES = spatialite_xml_validator.c spatialite_xml_load_SOURCES = spatialite_xml_load.c spatialite_xml_collapse_SOURCES = spatialite_xml_collapse.c spatialite_xml_print_SOURCES = spatialite_xml_print.c @NO_READOSM_FALSE@spatialite_osm_net_SOURCES = spatialite_osm_net.c @NO_READOSM_FALSE@spatialite_osm_map_SOURCES = spatialite_osm_map.c @NO_READOSM_FALSE@spatialite_osm_raw_SOURCES = spatialite_osm_raw.c spatialite_osm_filter_SOURCES = spatialite_osm_filter.c spatialite_gml_SOURCES = spatialite_gml.c spatialite_osm_overpass_SOURCES = spatialite_osm_overpass.c spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_osm_overpass_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBXML2_LIBS@ spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \ ................................................................................ spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ -lexpat spatialite_LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ \ @READLINE_LIBS@ spatialite_xml_validator_LDADD = @LIBXML2_LIBS@ spatialite_xml_load_LDADD = @LIBSPATIALITE_LIBS@ \ -lexpat ................................................................................ spatialite_xml_print_LADD = @LIBSPATIALIATE_LIBS@ LDADD = @LIBSPATIALITE_LIBS@ \ @LIBFREEXL_LIBS@ EXTRA_DIST = makefile.vc nmake.opt \ config-msvc.h \ Makefile-static-MinGW \ Makefile-static-Linux \ Makefile-static-MacOsX AUTOMAKE_OPTIONS = dist-zip all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ ................................................................................ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 ................................................................................ @rm -f exif_loader$(EXEEXT) $(AM_V_CCLD)$(LINK) $(exif_loader_OBJECTS) $(exif_loader_LDADD) $(LIBS) shp_doctor$(EXEEXT): $(shp_doctor_OBJECTS) $(shp_doctor_DEPENDENCIES) $(EXTRA_shp_doctor_DEPENDENCIES) @rm -f shp_doctor$(EXEEXT) $(AM_V_CCLD)$(LINK) $(shp_doctor_OBJECTS) $(shp_doctor_LDADD) $(LIBS) spatialite$(EXEEXT): $(spatialite_OBJECTS) $(spatialite_DEPENDENCIES) $(EXTRA_spatialite_DEPENDENCIES) @rm -f spatialite$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_OBJECTS) $(spatialite_LDADD) $(LIBS) spatialite_convert$(EXEEXT): $(spatialite_convert_OBJECTS) $(spatialite_convert_DEPENDENCIES) $(EXTRA_spatialite_convert_DEPENDENCIES) @rm -f spatialite_convert$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_convert_OBJECTS) $(spatialite_convert_LDADD) $(LIBS) spatialite_dxf$(EXEEXT): $(spatialite_dxf_OBJECTS) $(spatialite_dxf_DEPENDENCIES) $(EXTRA_spatialite_dxf_DEPENDENCIES) @rm -f spatialite_dxf$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_dxf_OBJECTS) $(spatialite_dxf_LDADD) $(LIBS) spatialite_gml$(EXEEXT): $(spatialite_gml_OBJECTS) $(spatialite_gml_DEPENDENCIES) $(EXTRA_spatialite_gml_DEPENDENCIES) @rm -f spatialite_gml$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_gml_OBJECTS) $(spatialite_gml_LDADD) $(LIBS) ................................................................................ @rm -f spatialite_osm_raw$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_osm_raw_OBJECTS) $(spatialite_osm_raw_LDADD) $(LIBS) spatialite_tool$(EXEEXT): $(spatialite_tool_OBJECTS) $(spatialite_tool_DEPENDENCIES) $(EXTRA_spatialite_tool_DEPENDENCIES) @rm -f spatialite_tool$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_tool_OBJECTS) $(spatialite_tool_LDADD) $(LIBS) spatialite_xml_collapse$(EXEEXT): $(spatialite_xml_collapse_OBJECTS) $(spatialite_xml_collapse_DEPENDENCIES) $(EXTRA_spatialite_xml_collapse_DEPENDENCIES) @rm -f spatialite_xml_collapse$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_xml_collapse_OBJECTS) $(spatialite_xml_collapse_LDADD) $(LIBS) spatialite_xml_load$(EXEEXT): $(spatialite_xml_load_OBJECTS) $(spatialite_xml_load_DEPENDENCIES) $(EXTRA_spatialite_xml_load_DEPENDENCIES) @rm -f spatialite_xml_load$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spatialite_xml_load_OBJECTS) $(spatialite_xml_load_LDADD) $(LIBS) ................................................................................ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exif_loader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shp_doctor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_convert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_dxf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_gml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_network.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_filter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_net.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_overpass.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_osm_raw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_tool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_collapse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_load.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_print.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spatialite_xml_validator.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< ................................................................................ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir ................................................................................ $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: ................................................................................ # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ ................................................................................ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: |
Changes to aclocal.m4.
1 2 3 4 5 6 7 8 9 10 .. 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 .. 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 ... 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 ... 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 ... 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 ... 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 ... 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 ... 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 ... 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 ... 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 ... 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 ... 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 ... 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 .... 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 .... 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 .... 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 .... 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 .... 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 .... 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 .... 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 .... 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 |
# generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without ................................................................................ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- dnl serial 11 (pkg-config-0.29.1) dnl dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>. dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.1]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) ................................................................................ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) ................................................................................ ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR # Copyright (C) 2002-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.15], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies ................................................................................ m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.15])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to ................................................................................ # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- ................................................................................ fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be ................................................................................ _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS ................................................................................ [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. ................................................................................ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, ................................................................................ AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: <http://www.gnu.org/software/coreutils/>. If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate ................................................................................ break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. ................................................................................ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- ................................................................................ MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- ................................................................................ AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ ................................................................................ fi ]) # -*- Autoconf -*- # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. AC_DEFUN([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], ................................................................................ AC_DEFUN([AM_C_PROTOTYPES], [AC_FATAL([automatic de-ANSI-fication support has been removed])]) AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- ................................................................................ # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- ................................................................................ # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- ................................................................................ AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- ................................................................................ dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- ................................................................................ # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- |
| | | | < > | < < > | | | | < > | | | | < > | | | < < > | | | | < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < | | < < < > | | < > | | | | > | | < < | | | < | | | < < < > > | | | > > > | < < < < < < < < < < < < < < < < < < < < < < | | < < | | | | | | | | < < | | | | | | | | | < < | | | | | | | | > | | | | | | < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | |
1 2 3 4 5 6 7 8 9 10 .. 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 .. 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 ... 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ... 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 ... 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 ... 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 ... 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 ... 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 ... 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 ... 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 ... 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 ... 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 ... 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 ... 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 ... 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 ... 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 ... 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 .... 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 .... 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 .... 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 .... 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 |
# generated automatically by aclocal 1.13.4 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without ................................................................................ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant <scott@netsplit.com>. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) ................................................................................ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) ................................................................................ ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # PKG_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable pkgconfigdir as the location where a module # should install pkg-config .pc files. By default the directory is # $libdir/pkgconfig, but the default can be changed by passing # DIRECTORY. The user can override through the --with-pkgconfigdir # parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_INSTALLDIR # PKG_NOARCH_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable noarch_pkgconfigdir as the location where a # module should install arch-independent pkg-config .pc files. By # default the directory is $datadir/pkgconfig, but the default can be # changed by passing DIRECTORY. The user can override through the # --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_NOARCH_INSTALLDIR # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------- # Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.13' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.13.4], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies ................................................................................ m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.13.4])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to ................................................................................ # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- ................................................................................ fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be ................................................................................ _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS ................................................................................ [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. ................................................................................ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, ................................................................................ AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate ................................................................................ break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. ................................................................................ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- ................................................................................ MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- ................................................................................ AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ ................................................................................ fi ]) # -*- Autoconf -*- # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. AC_DEFUN([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], ................................................................................ AC_DEFUN([AM_C_PROTOTYPES], [AC_FATAL([automatic de-ANSI-fication support has been removed])]) AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- ................................................................................ # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- ................................................................................ # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- ................................................................................ AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- ................................................................................ dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- ................................................................................ # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- |
Deleted compile.
1 |
/usr/share/automake-1.15/compile
|
< |
Changes to config.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 .. 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ... 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 ... 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 ... 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Should be defined in order to enable LIBXML2 support. */ #define ENABLE_LIBXML2 1 /* Should be defined in order to enable RTTOPO support. */ #define ENABLE_RTTOPO 1 /* depending on SQLite library version. */ #define HAVE_DECL_SQLITE_CONFIG_URI 1 /* depending on SQLite library version. */ #define HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT 1 /* depending on SQLite library version. */ ................................................................................ /* Define to 1 if you have the `expat' library (-lexpat). */ #define HAVE_LIBEXPAT 1 /* Define to 1 if you have the `proj' library (-lproj). */ #define HAVE_LIBPROJ 1 /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ #define HAVE_LIBSQLITE3 1 /* Define to 1 if you have the `localtime_r' function. */ #define HAVE_LOCALTIME_R 1 /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ /* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ ................................................................................ /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `readline' function. */ #define HAVE_READLINE 1 /* Define to 1 if you have the <sqlite3ext.h> header file. */ #define HAVE_SQLITE3EXT_H 1 /* Define to 1 if you have the <sqlite3.h> header file. */ #define HAVE_SQLITE3_H 1 /* Define to 1 if you have the `sqrt' function. */ /* #undef HAVE_SQRT */ /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ /* #undef HAVE_STAT_EMPTY_STRING_BUG */ ................................................................................ /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "a.furieri@lqt.it" /* Define to the full name of this package. */ #define PACKAGE_NAME "spatialite-tools" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "spatialite-tools 4.5.0-devel" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "spatialite-tools" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "4.5.0-devel" /* must be defined when using libspatialite-amalgamation */ /* #undef SPATIALITE_AMALGAMATION */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 ................................................................................ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #define TIME_WITH_SYS_TIME 1 /* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ /* Version number of package */ #define VERSION "4.5.0-devel" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to `long int' if <sys/types.h> does not define. */ /* #undef off_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ /* #undef size_t */ /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ /* #undef volatile */ |
< < < < < < < < < < < < | | | |
1 2 3 4 5 6 7 8 9 10 11 12 13 .. 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ... 106 107 108 109 110 111 112 113 114 115 116 117 118 119 ... 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 ... 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Should be defined in order to enable LIBXML2 support. */ #define ENABLE_LIBXML2 1 /* depending on SQLite library version. */ #define HAVE_DECL_SQLITE_CONFIG_URI 1 /* depending on SQLite library version. */ #define HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT 1 /* depending on SQLite library version. */ ................................................................................ /* Define to 1 if you have the `expat' library (-lexpat). */ #define HAVE_LIBEXPAT 1 /* Define to 1 if you have the `proj' library (-lproj). */ #define HAVE_LIBPROJ 1 /* Define to 1 if you have the `localtime_r' function. */ #define HAVE_LOCALTIME_R 1 /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ /* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ ................................................................................ /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `readline' function. */ #define HAVE_READLINE 1 /* Define to 1 if you have the `sqrt' function. */ /* #undef HAVE_SQRT */ /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ /* #undef HAVE_STAT_EMPTY_STRING_BUG */ ................................................................................ /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "a.furieri@lqt.it" /* Define to the full name of this package. */ #define PACKAGE_NAME "spatialite-tools" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "spatialite-tools 4.2.1-rc1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "spatialite-tools" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "4.2.1-rc1" /* must be defined when using libspatialite-amalgamation */ /* #undef SPATIALITE_AMALGAMATION */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 ................................................................................ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #define TIME_WITH_SYS_TIME 1 /* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ /* Version number of package */ #define VERSION "4.2.1-rc1" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to `long int' if <sys/types.h> does not define. */ /* #undef off_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ /* #undef size_t */ /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ /* #undef volatile */ |
Changes to config.h.in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .. 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ... 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/* config.h.in. Generated from configure.ac by autoheader. */ /* Should be defined in order to enable LIBXML2 support. */ #undef ENABLE_LIBXML2 /* Should be defined in order to enable RTTOPO support. */ #undef ENABLE_RTTOPO /* depending on SQLite library version. */ #undef HAVE_DECL_SQLITE_CONFIG_URI /* depending on SQLite library version. */ #undef HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT /* depending on SQLite library version. */ ................................................................................ /* Define to 1 if you have the `expat' library (-lexpat). */ #undef HAVE_LIBEXPAT /* Define to 1 if you have the `proj' library (-lproj). */ #undef HAVE_LIBPROJ /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ #undef HAVE_LIBSQLITE3 /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_LSTAT_EMPTY_STRING_BUG ................................................................................ /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `readline' function. */ #undef HAVE_READLINE /* Define to 1 if you have the <sqlite3ext.h> header file. */ #undef HAVE_SQLITE3EXT_H /* Define to 1 if you have the <sqlite3.h> header file. */ #undef HAVE_SQLITE3_H /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG |
< < < < < < < < < < < < |
1 2 3 4 5 6 7 8 9 10 11 12 .. 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ... 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
/* config.h.in. Generated from configure.ac by autoheader. */ /* Should be defined in order to enable LIBXML2 support. */ #undef ENABLE_LIBXML2 /* depending on SQLite library version. */ #undef HAVE_DECL_SQLITE_CONFIG_URI /* depending on SQLite library version. */ #undef HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT /* depending on SQLite library version. */ ................................................................................ /* Define to 1 if you have the `expat' library (-lexpat). */ #undef HAVE_LIBEXPAT /* Define to 1 if you have the `proj' library (-lproj). */ #undef HAVE_LIBPROJ /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if `lstat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_LSTAT_EMPTY_STRING_BUG ................................................................................ /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `readline' function. */ #undef HAVE_READLINE /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG |
Changes to configure.
1 2 3 4 5 6 7 8 9 10 ... 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 ... 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 ... 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 ... 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 .... 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 .... 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 .... 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 .... 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 .... 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 .... 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 .... 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 .... 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 .... 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 .... 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 .... 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 .... 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 .... 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 .... 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 .... 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 .... 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 ..... 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 ..... 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 ..... 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 ..... 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 ..... 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 |
#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for spatialite-tools 4.5.0-devel. # # Report bugs to <a.furieri@lqt.it>. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # ................................................................................ subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='spatialite-tools' PACKAGE_TARNAME='spatialite-tools' PACKAGE_VERSION='4.5.0-devel' PACKAGE_STRING='spatialite-tools 4.5.0-devel' PACKAGE_BUGREPORT='a.furieri@lqt.it' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H ................................................................................ #ifdef HAVE_UNISTD_H # include <unistd.h> #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS RTTOPO_LIBS RTTOPO_CFLAGS LIBXML2_LIBS LIBXML2_CFLAGS NO_READOSM_FALSE NO_READOSM_TRUE LIBREADOSM_CFLAGS LIBREADOSM_LIBS LIBFREEXL_LIBS ................................................................................ with_sysroot enable_libtool_lock enable_readline with_geosconfig enable_freexl enable_readosm enable_libxml2 enable_rttopo ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS ................................................................................ LIBSPATIALITE_CFLAGS LIBSPATIALITE_LIBS LIBFREEXL_CFLAGS LIBFREEXL_LIBS LIBREADOSM_CFLAGS LIBREADOSM_LIBS LIBXML2_CFLAGS LIBXML2_LIBS RTTOPO_CFLAGS RTTOPO_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= ................................................................................ # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures spatialite-tools 4.5.0-devel to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. ................................................................................ --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of spatialite-tools 4.5.0-devel:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ................................................................................ --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-readline use readline in shell tool (yes, no) [default=yes] --enable-freexl enables FreeXL inclusion [default=yes] --enable-readosm enables ReadOSM inclusion [default=yes] --enable-libxml2 enables libxml2 inclusion [default=yes] --enable-rttopo enables librttopo inclusion [default=yes] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] ................................................................................ C compiler flags for LIBREADOSM, overriding pkg-config LIBREADOSM_LIBS linker flags for LIBREADOSM, overriding pkg-config LIBXML2_CFLAGS C compiler flags for LIBXML2, overriding pkg-config LIBXML2_LIBS linker flags for LIBXML2, overriding pkg-config RTTOPO_CFLAGS C compiler flags for RTTOPO, overriding pkg-config RTTOPO_LIBS linker flags for RTTOPO, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to <a.furieri@lqt.it>. _ACEOF ac_status=$? ................................................................................ cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF spatialite-tools configure 4.5.0-devel generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit ................................................................................ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by spatialite-tools $as_me 4.5.0-devel, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { ................................................................................ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.15' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break ................................................................................ test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; ................................................................................ am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi ................................................................................ CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='spatialite-tools' VERSION='4.5.0-devel' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF ................................................................................ # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' ................................................................................ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: <http://www.gnu.org/software/coreutils/>. If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else ................................................................................ MAINT=$MAINTAINER_MODE_TRUE ac_config_headers="$ac_config_headers config.h" # supporting SPATIALITE_AMALGAMATION ................................................................................ fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 ................................................................................ #define HAVE_UNISTD_H 1 _ACEOF else as_fn_error $? "cannot find unistd.h, bailing out" "$LINENO" 5 fi done for ac_header in sqlite3.h do : ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" if test "x$ac_cv_header_sqlite3_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLITE3_H 1 _ACEOF else as_fn_error $? "cannot find sqlite3.h, bailing out" "$LINENO" 5 fi done for ac_header in sqlite3ext.h do : ac_fn_c_check_header_mongrel "$LINENO" "sqlite3ext.h" "ac_cv_header_sqlite3ext_h" "$ac_includes_default" if test "x$ac_cv_header_sqlite3ext_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLITE3EXT_H 1 _ACEOF else as_fn_error $? "cannot find sqlite3ext.h, bailing out" "$LINENO" 5 fi done # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ................................................................................ fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 ................................................................................ cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Checks for installed libraries { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_prepare_v2 in -lsqlite3" >&5 $as_echo_n "checking for sqlite3_prepare_v2 in -lsqlite3... " >&6; } if ${ac_cv_lib_sqlite3_sqlite3_prepare_v2+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 -lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sqlite3_prepare_v2 (); int main () { return sqlite3_prepare_v2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sqlite3_sqlite3_prepare_v2=yes else ac_cv_lib_sqlite3_sqlite3_prepare_v2=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_prepare_v2" >&5 $as_echo "$ac_cv_lib_sqlite3_sqlite3_prepare_v2" >&6; } if test "x$ac_cv_lib_sqlite3_sqlite3_prepare_v2" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSQLITE3 1 _ACEOF LIBS="-lsqlite3 $LIBS" else as_fn_error $? "'libsqlite3' is required but it doesn't seem to be installed on this system." "$LINENO" 5 fi ac_config_files="$ac_config_files Makefile" #----------------------------------------------------------------------- # --enable-readline # ................................................................................ else LIBREADOSM_CFLAGS=$pkg_cv_LIBREADOSM_CFLAGS LIBREADOSM_LIBS=$pkg_cv_LIBREADOSM_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readosm_version" >&5 $as_echo_n "checking for library containing readosm_version... " >&6; } if ${ac_cv_search_readosm_version+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char readosm_version (); int main () { return readosm_version (); ; return 0; } _ACEOF for ac_lib in '' readosm; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_readosm_version=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_readosm_version+:} false; then : break fi done if ${ac_cv_search_readosm_version+:} false; then : else ac_cv_search_readosm_version=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_readosm_version" >&5 $as_echo "$ac_cv_search_readosm_version" >&6; } ac_res=$ac_cv_search_readosm_version if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else as_fn_error $? "'libreadosm' (>= v.1.1.0) is required but an older version was found." "$LINENO" 5 fi else $as_echo "#define OMIT_READOSM 1" >>confdefs.h NOREADOSM="true" fi ................................................................................ $as_echo "yes" >&6; } fi $as_echo "#define ENABLE_LIBXML2 1" >>confdefs.h fi #----------------------------------------------------------------------- # --enable-rttopo # # Check whether --enable-rttopo was given. if test "${enable_rttopo+set}" = set; then : enableval=$enable_rttopo; else enable_rttopo=yes fi if test x"$enable_rttopo" != "xno"; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for RTTOPO" >&5 $as_echo_n "checking for RTTOPO... " >&6; } if test -n "$RTTOPO_CFLAGS"; then pkg_cv_RTTOPO_CFLAGS="$RTTOPO_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rttopo\""; } >&5 ($PKG_CONFIG --exists --print-errors "rttopo") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RTTOPO_CFLAGS=`$PKG_CONFIG --cflags "rttopo" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$RTTOPO_LIBS"; then pkg_cv_RTTOPO_LIBS="$RTTOPO_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rttopo\""; } >&5 ($PKG_CONFIG --exists --print-errors "rttopo") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RTTOPO_LIBS=`$PKG_CONFIG --libs "rttopo" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then RTTOPO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rttopo" 2>&1` else RTTOPO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rttopo" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$RTTOPO_PKG_ERRORS" >&5 as_fn_error $? "'librttopo' is required but it doesn't seem to be installed on this system." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "'librttopo' is required but it doesn't seem to be installed on this system." "$LINENO" 5 else RTTOPO_CFLAGS=$pkg_cv_RTTOPO_CFLAGS RTTOPO_LIBS=$pkg_cv_RTTOPO_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi $as_echo "#define ENABLE_RTTOPO 1" >>confdefs.h fi # checks for SQLite version-depending constants ac_fn_c_check_decl "$LINENO" "SQLITE_CONFIG_URI" "ac_cv_have_decl_SQLITE_CONFIG_URI" "#include <sqlite3.h> " if test "x$ac_cv_have_decl_SQLITE_CONFIG_URI" = xyes; then : $as_echo "#define HAVE_DECL_SQLITE_CONFIG_URI 1" >>confdefs.h ................................................................................ test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by spatialite-tools $as_me 4.5.0-devel, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ ................................................................................ Report bugs to <a.furieri@lqt.it>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ spatialite-tools config.status 4.5.0-devel configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." |
| | | < < < | < < | | < < < < | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | |
1 2 3 4 5 6 7 8 9 10 ... 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 ... 630 631 632 633 634 635 636 637 638 639 640 641 642 643 ... 789 790 791 792 793 794 795 796 797 798 799 800 801 802 ... 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 .... 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 .... 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 .... 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 .... 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 .... 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 .... 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 .... 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 .... 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 .... 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 .... 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 .... 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 .... 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 .... 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 .... 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 .... 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 .... 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 ..... 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 ..... 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 ..... 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 ..... 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 ..... 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 |
#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for spatialite-tools 4.2.1-rc1. # # Report bugs to <a.furieri@lqt.it>. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # ................................................................................ subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='spatialite-tools' PACKAGE_TARNAME='spatialite-tools' PACKAGE_VERSION='4.2.1-rc1' PACKAGE_STRING='spatialite-tools 4.2.1-rc1' PACKAGE_BUGREPORT='a.furieri@lqt.it' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h> #ifdef HAVE_SYS_TYPES_H ................................................................................ #ifdef HAVE_UNISTD_H # include <unistd.h> #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBXML2_LIBS LIBXML2_CFLAGS NO_READOSM_FALSE NO_READOSM_TRUE LIBREADOSM_CFLAGS LIBREADOSM_LIBS LIBFREEXL_LIBS ................................................................................ with_sysroot enable_libtool_lock enable_readline with_geosconfig enable_freexl enable_readosm enable_libxml2 ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS ................................................................................ LIBSPATIALITE_CFLAGS LIBSPATIALITE_LIBS LIBFREEXL_CFLAGS LIBFREEXL_LIBS LIBREADOSM_CFLAGS LIBREADOSM_LIBS LIBXML2_CFLAGS LIBXML2_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= ................................................................................ # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures spatialite-tools 4.2.1-rc1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. ................................................................................ --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of spatialite-tools 4.2.1-rc1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ................................................................................ --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-readline use readline in shell tool (yes, no) [default=yes] --enable-freexl enables FreeXL inclusion [default=yes] --enable-readosm enables ReadOSM inclusion [default=yes] --enable-libxml2 enables libxml2 inclusion [default=yes] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] ................................................................................ C compiler flags for LIBREADOSM, overriding pkg-config LIBREADOSM_LIBS linker flags for LIBREADOSM, overriding pkg-config LIBXML2_CFLAGS C compiler flags for LIBXML2, overriding pkg-config LIBXML2_LIBS linker flags for LIBXML2, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to <a.furieri@lqt.it>. _ACEOF ac_status=$? ................................................................................ cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF spatialite-tools configure 4.2.1-rc1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit ................................................................................ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by spatialite-tools $as_me 4.2.1-rc1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { ................................................................................ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.13' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break ................................................................................ test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; ................................................................................ am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi ................................................................................ CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='spatialite-tools' VERSION='4.2.1-rc1' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF ................................................................................ # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' ................................................................................ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else ................................................................................ MAINT=$MAINTAINER_MODE_TRUE ac_config_headers="$ac_config_headers config.h" # supporting SPATIALITE_AMALGAMATION ................................................................................ fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 ................................................................................ #define HAVE_UNISTD_H 1 _ACEOF else as_fn_error $? "cannot find unistd.h, bailing out" "$LINENO" 5 fi done # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ................................................................................ fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 ................................................................................ cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files Makefile" #----------------------------------------------------------------------- # --enable-readline # ................................................................................ else LIBREADOSM_CFLAGS=$pkg_cv_LIBREADOSM_CFLAGS LIBREADOSM_LIBS=$pkg_cv_LIBREADOSM_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi else $as_echo "#define OMIT_READOSM 1" >>confdefs.h NOREADOSM="true" fi ................................................................................ $as_echo "yes" >&6; } fi $as_echo "#define ENABLE_LIBXML2 1" >>confdefs.h fi # checks for SQLite version-depending constants ac_fn_c_check_decl "$LINENO" "SQLITE_CONFIG_URI" "ac_cv_have_decl_SQLITE_CONFIG_URI" "#include <sqlite3.h> " if test "x$ac_cv_have_decl_SQLITE_CONFIG_URI" = xyes; then : $as_echo "#define HAVE_DECL_SQLITE_CONFIG_URI 1" >>confdefs.h ................................................................................ test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by spatialite-tools $as_me 4.2.1-rc1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ ................................................................................ Report bugs to <a.furieri@lqt.it>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ spatialite-tools config.status 4.2.1-rc1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." |
Changes to configure.ac.
1 2 3 4 5 6 7 8 9 10 11 12 .. 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 .. 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 .. 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 ... 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) AC_INIT(spatialite-tools, 4.5.0-devel, a.furieri@lqt.it) AC_LANG(C) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) ................................................................................ [must be defined when using libspatialite-amalgamation]) AH_TEMPLATE([OMIT_FREEXL], [Should be defined in order to disable FREEXL support.]) AH_TEMPLATE([OMIT_READOSM], [Should be defined in order to disable ReadOSM support.]) AH_TEMPLATE([ENABLE_LIBXML2], [Should be defined in order to enable LIBXML2 support.]) AH_TEMPLATE([ENABLE_RTTOPO], [Should be defined in order to enable RTTOPO support.]) AH_TEMPLATE([HAVE_DECL_SQLITE_CONFIG_URI], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE], ................................................................................ AC_CHECK_HEADERS(float.h,, [AC_MSG_ERROR([cannot find float.h, bailing out])]) AC_CHECK_HEADERS(fcntl.h,, [AC_MSG_ERROR([cannot find fcntl.h, bailing out])]) AC_CHECK_HEADERS(inttypes.h,, [AC_MSG_ERROR([cannot find inttypes.h, bailing out])]) AC_CHECK_HEADERS(stddef.h,, [AC_MSG_ERROR([cannot find stddef.h, bailing out])]) AC_CHECK_HEADERS(stdint.h,, [AC_MSG_ERROR([cannot find stdint.h, bailing out])]) AC_CHECK_HEADERS(sys/time.h,, [AC_MSG_ERROR([cannot find sys/time.h, bailing out])]) AC_CHECK_HEADERS(unistd.h,, [AC_MSG_ERROR([cannot find unistd.h, bailing out])]) AC_CHECK_HEADERS(sqlite3.h,, [AC_MSG_ERROR([cannot find sqlite3.h, bailing out])]) AC_CHECK_HEADERS(sqlite3ext.h,, [AC_MSG_ERROR([cannot find sqlite3ext.h, bailing out])]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S ................................................................................ # Checks for library functions. AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_FUNC_MEMCMP AC_FUNC_STAT AC_FUNC_STRFTIME AC_CHECK_FUNCS([memset sqrt strcasecmp strerror strncasecmp strstr fdatasync ftruncate getcwd gettimeofday localtime_r memmove strerror]) # Checks for installed libraries AC_CHECK_LIB(sqlite3,sqlite3_prepare_v2,,AC_MSG_ERROR(['libsqlite3' is required but it doesn't seem to be installed on this system.]),-lm) AC_CONFIG_FILES([Makefile]) #----------------------------------------------------------------------- # --enable-readline # AC_ARG_ENABLE(readline, [AS_HELP_STRING( ................................................................................ # --enable-readosm # AC_ARG_ENABLE(readosm, [AS_HELP_STRING( [--enable-readosm], [enables ReadOSM inclusion [default=yes]])], [], [enable_readosm=yes]) if test x"$enable_readosm" != "xno"; then AC_SUBST(LIBREADOSM_LIBS)PKG_CHECK_MODULES([LIBREADOSM], [readosm], , AC_MSG_ERROR(['libreadosm' is required but it doesn't seem to be installed on this system.])) AC_SEARCH_LIBS(readosm_version,readosm,,AC_MSG_ERROR(['libreadosm' (>= v.1.1.0) is required but an older version was found.])) AC_SUBST(LIBREADOSM_CFLAGS) AC_SUBST(LIBREADOSM_LIBS) else AC_DEFINE(OMIT_READOSM) NOREADOSM="true" fi ................................................................................ if test x"$enable_libxml2" != "xno"; then PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], , AC_MSG_ERROR(['libxml2' is required but it doesn't seem to be installed on this system.])) AC_SUBST(LIBXML2_CFLAGS) AC_SUBST(LIBXML2_LIBS) AC_DEFINE(ENABLE_LIBXML2) fi #----------------------------------------------------------------------- # --enable-rttopo # AC_ARG_ENABLE(rttopo, [AS_HELP_STRING( [--enable-rttopo], [enables librttopo inclusion [default=yes]])], [], [enable_rttopo=yes]) if test x"$enable_rttopo" != "xno"; then PKG_CHECK_MODULES([RTTOPO], [rttopo], , AC_MSG_ERROR(['librttopo' is required but it doesn't seem to be installed on this system.])) AC_SUBST(RTTOPO_CFLAGS) AC_SUBST(RTTOPO_LIBS) AC_DEFINE(ENABLE_RTTOPO) fi # checks for SQLite version-depending constants AC_CHECK_DECL([SQLITE_CONFIG_URI], [AC_DEFINE(HAVE_DECL_SQLITE_CONFIG_URI)],[],[[#include <sqlite3.h>]]) AC_CHECK_DECL([SQLITE_DBSTATUS_LOOKASIDE_USED], [AC_DEFINE(HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED)],[],[[#include <sqlite3.h>]]) AC_CHECK_DECL([SQLITE_DBSTATUS_LOOKASIDE_HIT], [AC_DEFINE(HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT)],[],[[#include <sqlite3.h>]]) |
| < < < < < < < < < < < < < < < < < < < < < |
1 2 3 4 5 6 7 8 9 10 11 12 .. 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .. 63 64 65 66 67 68 69 70 71 72 73 74 75 76 .. 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ... 186 187 188 189 190 191 192 193 194 195 196 197 198 199 ... 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) AC_INIT(spatialite-tools, 4.2.1-rc1, a.furieri@lqt.it) AC_LANG(C) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE AM_CONFIG_HEADER(config.h) ................................................................................ [must be defined when using libspatialite-amalgamation]) AH_TEMPLATE([OMIT_FREEXL], [Should be defined in order to disable FREEXL support.]) AH_TEMPLATE([OMIT_READOSM], [Should be defined in order to disable ReadOSM support.]) AH_TEMPLATE([ENABLE_LIBXML2], [Should be defined in order to enable LIBXML2 support.]) AH_TEMPLATE([HAVE_DECL_SQLITE_CONFIG_URI], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT], [depending on SQLite library version.]) AH_TEMPLATE([HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE], ................................................................................ AC_CHECK_HEADERS(float.h,, [AC_MSG_ERROR([cannot find float.h, bailing out])]) AC_CHECK_HEADERS(fcntl.h,, [AC_MSG_ERROR([cannot find fcntl.h, bailing out])]) AC_CHECK_HEADERS(inttypes.h,, [AC_MSG_ERROR([cannot find inttypes.h, bailing out])]) AC_CHECK_HEADERS(stddef.h,, [AC_MSG_ERROR([cannot find stddef.h, bailing out])]) AC_CHECK_HEADERS(stdint.h,, [AC_MSG_ERROR([cannot find stdint.h, bailing out])]) AC_CHECK_HEADERS(sys/time.h,, [AC_MSG_ERROR([cannot find sys/time.h, bailing out])]) AC_CHECK_HEADERS(unistd.h,, [AC_MSG_ERROR([cannot find unistd.h, bailing out])]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S ................................................................................ # Checks for library functions. AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_FUNC_MEMCMP AC_FUNC_STAT AC_FUNC_STRFTIME AC_CHECK_FUNCS([memset sqrt strcasecmp strerror strncasecmp strstr fdatasync ftruncate getcwd gettimeofday localtime_r memmove strerror]) AC_CONFIG_FILES([Makefile]) #----------------------------------------------------------------------- # --enable-readline # AC_ARG_ENABLE(readline, [AS_HELP_STRING( ................................................................................ # --enable-readosm # AC_ARG_ENABLE(readosm, [AS_HELP_STRING( [--enable-readosm], [enables ReadOSM inclusion [default=yes]])], [], [enable_readosm=yes]) if test x"$enable_readosm" != "xno"; then AC_SUBST(LIBREADOSM_LIBS)PKG_CHECK_MODULES([LIBREADOSM], [readosm], , AC_MSG_ERROR(['libreadosm' is required but it doesn't seem to be installed on this system.])) AC_SUBST(LIBREADOSM_CFLAGS) AC_SUBST(LIBREADOSM_LIBS) else AC_DEFINE(OMIT_READOSM) NOREADOSM="true" fi ................................................................................ if test x"$enable_libxml2" != "xno"; then PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], , AC_MSG_ERROR(['libxml2' is required but it doesn't seem to be installed on this system.])) AC_SUBST(LIBXML2_CFLAGS) AC_SUBST(LIBXML2_LIBS) AC_DEFINE(ENABLE_LIBXML2) fi # checks for SQLite version-depending constants AC_CHECK_DECL([SQLITE_CONFIG_URI], [AC_DEFINE(HAVE_DECL_SQLITE_CONFIG_URI)],[],[[#include <sqlite3.h>]]) AC_CHECK_DECL([SQLITE_DBSTATUS_LOOKASIDE_USED], [AC_DEFINE(HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED)],[],[[#include <sqlite3.h>]]) AC_CHECK_DECL([SQLITE_DBSTATUS_LOOKASIDE_HIT], [AC_DEFINE(HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT)],[],[[#include <sqlite3.h>]]) |
Changes to exif_loader.c.
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 .... 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 .... 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceeding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "exif_loader .: %s\n", VERSION); fprintf (stderr, "target CPU ..: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ..: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: exif_loader ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite db path\n"); fprintf (stderr, "-D or --dir dir_path the DIR path containing EXIF files\n"); fprintf (stderr, "-f or --file-path file_name a single EXIF file\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "--any-exif *default*\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { ................................................................................ fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); if (cnt) fprintf (stderr, "\n\n*** %d EXIF photo%s successfully inserted into the DB\n", cnt, (cnt > 1) ? "s where" : " was"); spatialite_shutdown (); return 0; } |
| | < < < < < < < < < < < < < < < < < < < < | |
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 .... 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 .... 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceeding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: exif_loader ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite db path\n"); fprintf (stderr, "-D or --dir dir_path the DIR path containing EXIF files\n"); fprintf (stderr, "-f or --file-path file_name a single EXIF file\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "--any-exif *default*\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { ................................................................................ fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); if (cnt) fprintf (stderr, "\n\n*** %d EXIF photo%s successfully inserted into the DB\n", cnt, (cnt > 1) ? "s where" : " was"); spatialite_shutdown(); return 0; } |
Changes to makefile.vc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 .. 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 .. 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# NMAKE Makefile to build SpatiaLite-tools on Windows # !INCLUDE nmake.opt SPATIALITE_EXE = spatialite.exe EXIF_LOADER_EXE = exif_loader.exe SHP_DOCTOR_EXE = shp_doctor.exe SHP_SANITIZE_EXE = shp_sanitize.exe SPATIALITE_NETWORK_EXE = spatialite_network.exe SPATIALITE_TOOL_EXE = spatialite_tool.exe SPATIALITE_OSM_NET_EXE = spatialite_osm_net.exe SPATIALITE_OSM_MAP_EXE = spatialite_osm_map.exe SPATIALITE_OSM_RAW_EXE = spatialite_osm_raw.exe SPATIALITE_OSM_FILTER_EXE = spatialite_osm_filter.exe SPATIALITE_GML_EXE = spatialite_gml.exe ................................................................................ default: all all: $(SPATIALITE_EXE) $(SHP_DOCTOR_EXE) $(SPATIALITE_TOOL_EXE) \ $(SPATIALITE_NETWORK_EXE) $(EXIF_LOADER_EXE) \ $(SPATIALITE_OSM_NET_EXE) $(SPATIALITE_OSM_MAP_EXE) \ $(SPATIALITE_GML_EXE) $(SPATIALITE_OSM_RAW_EXE) \ $(SPATIALITE_OSM_FILTER_EXE) $(SHP_SANITIZE_EXE) $(SPATIALITE_EXE): shell.obj cl shell.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib C:\OSGeo4W\lib\geos_c.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib \ /Fe$(SPATIALITE_EXE) if exist $(SPATIALITE_EXE).manifest mt -manifest \ ................................................................................ $(SHP_DOCTOR_EXE): shp_doctor.obj cl shp_doctor.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib C:\OSGeo4W\lib\geos_c.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib if exist $(SHP_DOCTOR_EXE).manifest mt -manifest \ $(SHP_DOCTOR_EXE).manifest -outputresource:$(SHP_DOCTOR_EXE);1 $(SHP_SANITIZE_EXE): shp_sanitize.obj cl shp_sanitize.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib C:\OSGeo4W\lib\geos_c.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib if exist $(SHP_SANITIZE_EXE).manifest mt -manifest \ $(SHP_SANITIZE_EXE).manifest -outputresource:$(SHP_SANITIZE_EXE);1 $(SPATIALITE_NETWORK_EXE): spatialite_network.obj cl spatialite_network.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib if exist $(SPATIALITE_NETWORK_EXE).manifest mt -manifest \ $(SPATIALITE_TOOL_EXE).manifest \ -outputresource:$(SPATIALITE_TOOL_EXE);1 |
< | < < < < < < < |
3 4 5 6 7 8 9 10 11 12 13 14 15 16 .. 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 .. 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# NMAKE Makefile to build SpatiaLite-tools on Windows # !INCLUDE nmake.opt SPATIALITE_EXE = spatialite.exe EXIF_LOADER_EXE = exif_loader.exe SHP_DOCTOR_EXE = shp_doctor.exe SPATIALITE_NETWORK_EXE = spatialite_network.exe SPATIALITE_TOOL_EXE = spatialite_tool.exe SPATIALITE_OSM_NET_EXE = spatialite_osm_net.exe SPATIALITE_OSM_MAP_EXE = spatialite_osm_map.exe SPATIALITE_OSM_RAW_EXE = spatialite_osm_raw.exe SPATIALITE_OSM_FILTER_EXE = spatialite_osm_filter.exe SPATIALITE_GML_EXE = spatialite_gml.exe ................................................................................ default: all all: $(SPATIALITE_EXE) $(SHP_DOCTOR_EXE) $(SPATIALITE_TOOL_EXE) \ $(SPATIALITE_NETWORK_EXE) $(EXIF_LOADER_EXE) \ $(SPATIALITE_OSM_NET_EXE) $(SPATIALITE_OSM_MAP_EXE) \ $(SPATIALITE_GML_EXE) $(SPATIALITE_OSM_RAW_EXE) \ $(SPATIALITE_OSM_FILTER_EXE) $(SPATIALITE_EXE): shell.obj cl shell.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib C:\OSGeo4W\lib\geos_c.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib \ /Fe$(SPATIALITE_EXE) if exist $(SPATIALITE_EXE).manifest mt -manifest \ ................................................................................ $(SHP_DOCTOR_EXE): shp_doctor.obj cl shp_doctor.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib C:\OSGeo4W\lib\geos_c.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib if exist $(SHP_DOCTOR_EXE).manifest mt -manifest \ $(SHP_DOCTOR_EXE).manifest -outputresource:$(SHP_DOCTOR_EXE);1 $(SPATIALITE_NETWORK_EXE): spatialite_network.obj cl spatialite_network.obj C:\OSGeo4W\lib\proj_i.lib \ C:\OSGeo4W\lib\iconv.lib \ C:\OSGeo4W\lib\spatialite_i.lib C:\OSGeo4W\lib\sqlite3_i.lib if exist $(SPATIALITE_NETWORK_EXE).manifest mt -manifest \ $(SPATIALITE_TOOL_EXE).manifest \ -outputresource:$(SPATIALITE_TOOL_EXE);1 |
Changes to shell.c.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 ... 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 ... 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 ... 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 ... 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 ... 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 .... 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 .... 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 .... 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 .... 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 .... 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 .... 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 .... 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 .... 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 .... 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 .... 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 |
#include <stdarg.h> #ifdef _WIN32 #define strcasecmp _stricmp #endif /* not WIN32 */ #if !defined(_WIN32) && !defined(WIN32) #include <signal.h> #if !defined(__RTP__) && !defined(_WRS_KERNEL) #include <pwd.h> #endif #include <unistd.h> #include <sys/types.h> #endif #ifdef HAVE_EDITLINE #include <editline/editline.h> #endif #if defined(HAVE_READLINE) && HAVE_READLINE==1 #include <readline/readline.h> #include <readline/history.h> #endif #if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1) #define readline(p) local_getline(p,stdin,0) #define add_history(X) #define read_history(X) #define write_history(X) #define stifle_history(X) #endif #if defined(_WIN32) || defined(WIN32) #include <io.h> #define isatty(h) _isatty(h) #define access(f,m) _access((f),(m)) #undef popen #define popen(a,b) _popen((a),(b)) #undef pclose #define pclose(x) _pclose(x) #else /* Make sure isatty() has a prototype. */ extern int isatty (int); #endif #if defined(_WIN32_WCE) /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty() * thus we always assume that we have a console. That can be * overridden with the -batch command line option. */ ................................................................................ /* Saved resource information for the beginning of an operation */ static struct rusage sBegin; /* ** Begin timing an operation */ static void beginTimer (void) { if (enableTimer) { getrusage (RUSAGE_SELF, &sBegin); } } /* Return the difference of two time_structs in seconds */ static double timeDiff (struct timeval *pStart, struct timeval *pEnd) { return (pEnd->tv_usec - pStart->tv_usec) * 0.000001 + (double) (pEnd->tv_sec - pStart->tv_sec); } /* ** Print the timing results. */ static void endTimer (void) { if (enableTimer) { struct rusage sEnd; getrusage (RUSAGE_SELF, &sEnd); printf ("CPU Time: user %f sys %f\n", timeDiff (&sBegin.ru_utime, &sEnd.ru_utime), timeDiff (&sBegin.ru_stime, &sEnd.ru_stime)); } } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER 1 #elif (defined(_WIN32) || defined(WIN32)) ................................................................................ #include <windows.h> /* Saved resource information for the beginning of an operation */ static HANDLE hProcess; static FILETIME ftKernelBegin; static FILETIME ftUserBegin; typedef BOOL (WINAPI * GETPROCTIMES) (HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME); static GETPROCTIMES getProcessTimesAddr = NULL; /* ** Check to see if we have timer support. Return 1 if necessary ** support found (or found previously). */ static int hasTimer (void) { if (getProcessTimesAddr) { return 1; } else { /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions. ** See if the version we are running on has it, and if it does, save off ** a pointer to it and the current process handle. */ hProcess = GetCurrentProcess (); if (hProcess) { HINSTANCE hinstLib = LoadLibrary (TEXT ("Kernel32.dll")); if (NULL != hinstLib) { getProcessTimesAddr = (GETPROCTIMES) GetProcAddress (hinstLib, "GetProcessTimes"); if (NULL != getProcessTimesAddr) { return 1; } FreeLibrary (hinstLib); } } } return 0; } /* ** Begin timing an operation */ static void beginTimer (void) { if (enableTimer && getProcessTimesAddr) { FILETIME ftCreation, ftExit; getProcessTimesAddr (hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin); } } /* Return the difference of two FILETIME structs in seconds */ static double timeDiff (FILETIME * pStart, FILETIME * pEnd) { sqlite_int64 i64Start = *((sqlite_int64 *) pStart); sqlite_int64 i64End = *((sqlite_int64 *) pEnd); return (double) ((i64End - i64Start) / 10000000.0); } /* ** Print the timing results. */ static void endTimer (void) { if (enableTimer && getProcessTimesAddr) { FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd; getProcessTimesAddr (hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd); printf ("CPU Time: user %f sys %f\n", timeDiff (&ftUserBegin, &ftUserEnd), timeDiff (&ftKernelBegin, &ftKernelEnd)); } } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER hasTimer() #else #define BEGIN_TIMER #define END_TIMER #define HAS_TIMER 0 #endif /* sandro: 3 September 2012 ** If the following flag is set, then SQL Log is enabled */ ................................................................................ */ static char *Argv0; /* ** Prompt strings. Initialized in main. Settable with ** .prompt main continue */ static char mainPrompt[20]; /* First line prompt. default: "spatialite> " */ static char continuePrompt[20]; /* Continuation prompt. default: " ...> " */ /* ** Write I/O traces to the following stream. */ #ifdef SQLITE_ENABLE_IOTRACE static FILE *iotrace = 0; #endif ................................................................................ /* ** This routine works like printf in that its first argument is a ** format string and subsequent arguments are values to be substituted ** in place of % fields. The result of formatting this string ** is written to iotrace. */ #ifdef SQLITE_ENABLE_IOTRACE static void iotracePrintf (const char *zFormat, ...) { va_list ap; char *z; if (iotrace == 0) return; va_start (ap, zFormat); z = sqlite3_vmprintf (zFormat, ap); va_end (ap); fprintf (iotrace, "%s", z); sqlite3_free (z); } #endif /* Sandro Furieri 2013-04-29 WFS progress handler callback */ static void wfs_page_done (int features, void *ptr) { if (ptr != NULL) ptr = NULL; /* silencing stupid compiler warnings */ if (isatty (1)) { printf ("WFS Features loaded since now: %d\r", features); fflush (stdout); } } /* Sandro Furieri 2008-11-20 implementing AUTO FDO */ ................................................................................ utf8buf[maxlen - utf8len] = '\0'; memcpy (buf, utf8buf, (maxlen - utf8len) + 1); free (utf8buf); } /* sandro 2013-11-17 */ static void split_drop_name (const char *str, char **prefix, char **table) { int len1; int len2; const char *pt = NULL; const char *p = str; *prefix = NULL; *table = NULL; while (*p != '\0') { if (*p == '.') { pt = p; break; } p++; } if (pt == NULL) return; len1 = pt - str; len2 = strlen (pt + 1); if (len1 > 0 && len2 > 0) { *prefix = malloc (len1 + 1); memcpy (*prefix, str, len1); *(*prefix + len1) = '\0'; *table = malloc (len2 + 1); strcpy (*table, pt + 1); } } /* end sandro 2013-11-17 */ static void convert_input_to_utf8 (char *buf, int maxlen) { /* converting from required charset to UTF8 */ char *utf8buf = 0; ................................................................................ /* end Sandro Furieri 11 July 2008 */ /* ** Determines if a string is a number of not. */ static int isNumber (const char *z, int *realnum) { if (*z == '-' || *z == '+') z++; if (!IsDigit (*z)) { return 0; } z++; if (realnum) *realnum = 0; while (IsDigit (*z)) { z++; } if (*z == '.') { z++; if (!IsDigit (*z)) return 0; while (IsDigit (*z)) { z++; } if (realnum) *realnum = 1; } if (*z == 'e' || *z == 'E') { z++; if (*z == '+' || *z == '-') z++; if (!IsDigit (*z)) return 0; while (IsDigit (*z)) { z++; } if (realnum) *realnum = 1; } return *z == 0; } /* ** A global char* and an SQL function to access its current value ** from within an SQL statement. This program used to use the ** sqlite_exec_printf() API to substitue a string into an SQL statement. ** The correct way to do this with sqlite3 is to use the bind API, but ** since the shell is built around the callback paradigm it would be a lot ** of work. Instead just use this hack, which is quite harmless. */ static const char *zShellStatic = 0; static void shellstaticFunc (sqlite3_context * context, int argc, sqlite3_value ** argv) { assert (0 == argc); assert (zShellStatic); UNUSED_PARAMETER (argc); UNUSED_PARAMETER (argv); sqlite3_result_text (context, zShellStatic, -1, SQLITE_STATIC); } /* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer ** to the text. NULL is returned at end of file, or if malloc() ** fails. ** ** The interface is like "readline" but no command-line editing ** is done. */ static char * local_getline (char *zPrompt, FILE * in, int csvFlag) { char *zLine; int nLine; int n; int inQuote = 0; if (zPrompt && *zPrompt) { printf ("%s", zPrompt); fflush (stdout); } nLine = 100; zLine = malloc (nLine); if (zLine == 0) return 0; n = 0; while (1) { if (n + 100 > nLine) { nLine = nLine * 2 + 100; zLine = realloc (zLine, nLine); if (zLine == 0) return 0; } if (fgets (&zLine[n], nLine - n, in) == 0) { if (n == 0) { free (zLine); return 0; } zLine[n] = 0; break; } while (zLine[n]) { if (zLine[n] == '"') inQuote = !inQuote; n++; } if (n > 0 && zLine[n - 1] == '\n' && (!inQuote || !csvFlag)) { n--; if (n > 0 && zLine[n - 1] == '\r') n--; zLine[n] = 0; break; } } zLine = realloc (zLine, n + 1); return zLine; } /* ** Retrieve a single line of input text. ** ** zPrior is a string of prior text retrieved. If not the empty ** string, then issue a continuation prompt. */ static char * one_input_line (const char *zPrior, FILE * in) { char *zPrompt; char *zResult; if (in != 0) { return local_getline (0, in, 0); } if (zPrior && zPrior[0]) { zPrompt = continuePrompt; } else { zPrompt = mainPrompt; } zResult = readline (zPrompt); #if defined(HAVE_READLINE) && HAVE_READLINE==1 if (zResult && *zResult) add_history (zResult); #endif return zResult; } struct previous_mode_data { int valid; /* Is there legit data in here? */ int mode; int showHeader; int colWidth[100]; }; /* ** An pointer to an instance of this structure is passed from ** the main program to the callback. This is used to communicate ** state and mode information. */ struct callback_data { sqlite3 *db; /* The database */ int echoOn; /* True to echo input commands */ int statsOn; /* True to display memory stats before each finalize */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ FILE *traceOut; /* Output for sqlite3_trace() */ int nErr; /* Number of errors seen */ int mode; /* An output mode setting */ int writableSchema; /* True if PRAGMA writable_schema=ON */ int showHeader; /* True to show column names in List or Column mode */ char *zDestTable; /* Name of destination table when MODE_Insert */ char separator[20]; /* Separator character for MODE_List */ int colWidth[100]; /* Requested width of each column when in column mode */ int actualWidth[100]; /* Actual width of each column */ char nullvalue[20]; /* The text to print when a NULL comes back from ** the database */ struct previous_mode_data explainPrev; /* Holds the mode information just before ** .explain ON */ char outfile[FILENAME_MAX]; /* Filename for *out */ const char *zDbFilename; /* name of the database file */ const char *zVfs; /* Name of VFS to use */ sqlite3_stmt *pStmt; /* Current statement if any. */ FILE *pLog; /* Write log output here */ }; /* ** These are the allowed modes. */ #define MODE_Line 0 /* One column per line. Blank line between records */ #define MODE_Column 1 /* One record per line in neat columns */ #define MODE_List 2 /* One record per line with a separator */ #define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */ #define MODE_Html 4 /* Generate an XHTML table */ #define MODE_Insert 5 /* Generate SQL "insert" statements */ #define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */ #define MODE_Csv 7 /* Quote strings, numbers are plain */ #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ static const char *modeDescr[] = { "line", "column", "list", "semi", "html", "insert", "tcl", "csv", "explain", }; /* ** Number of elements in an array */ #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) /* ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ static int strlen30 (const char *z) { const char *z2 = z; while (*z2) { z2++; } return 0x3fffffff & (int) (z2 - z); } /* ** A callback for the sqlite3_log() interface. */ static void shellLog (void *pArg, int iErrCode, const char *zMsg) { struct callback_data *p = (struct callback_data *) pArg; if (p->pLog == 0) return; fprintf (p->pLog, "(%d) %s\n", iErrCode, zMsg); fflush (p->pLog); } /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ static void output_hex_blob (FILE * out, const void *pBlob, int nBlob) { int i; char *zBlob = (char *) pBlob; fprintf (out, "X'"); for (i = 0; i < nBlob; i++) { fprintf (out, "%02x", zBlob[i] & 0xff); } fprintf (out, "'"); } /* ** Output the given string as a quoted string using SQL quoting conventions. */ static void output_quoted_string (FILE * out, const char *z) { int i; int nSingle = 0; for (i = 0; z[i]; i++) { if (z[i] == '\'') nSingle++; } if (nSingle == 0) { fprintf (out, "'%s'", z); } else { fprintf (out, "'"); while (*z) { for (i = 0; z[i] && z[i] != '\''; i++) { } if (i == 0) { fprintf (out, "''"); z++; } else if (z[i] == '\'') { fprintf (out, "%.*s''", i, z); z += i + 1; } else { fprintf (out, "%s", z); break; } } fprintf (out, "'"); } } /* ** Output the given string as a quoted according to C or TCL quoting rules. */ static void output_c_string (FILE * out, const char *z) { unsigned int c; fputc ('"', out); while ((c = *(z++)) != 0) { if (c == '\\') { fputc (c, out); fputc (c, out); } else if (c == '\t') { fputc ('\\', out); fputc ('t', out); } else if (c == '\n') { fputc ('\\', out); fputc ('n', out); } else if (c == '\r') { fputc ('\\', out); fputc ('r', out); } else if (!isprint (c)) { fprintf (out, "\\%03o", c & 0xff); } else { fputc (c, out); } } fputc ('"', out); } /* ** Output the given string with characters that are special to ** HTML escaped. */ static void output_html_string (FILE * out, const char *z) { int i; while (*z) { for (i = 0; z[i] && z[i] != '<' && z[i] != '&' && z[i] != '>' && z[i] != '\"' && z[i] != '\''; i++) { } if (i > 0) { fprintf (out, "%.*s", i, z); } if (z[i] == '<') { fprintf (out, "<"); } else if (z[i] == '&') { fprintf (out, "&"); } else if (z[i] == '>') { fprintf (out, ">"); } else if (z[i] == '\"') { fprintf (out, """); } else if (z[i] == '\'') { fprintf (out, "'"); } else { break; } z += i + 1; } } /* ** If a field contains any character identified by a 1 in the following ** array, then the string must be quoted for CSV. */ static const char needCsvQuote[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; /* ** Output a single term of CSV. Actually, p->separator is used for ** the separator, which may or may not be a comma. p->nullvalue is ** the null value. Strings are quoted if necessary. */ static void output_csv (struct callback_data *p, const char *z, int bSep) { FILE *out = p->out; if (z == 0) { fprintf (out, "%s", p->nullvalue); } else { int i; int nSep = strlen30 (p->separator); for (i = 0; z[i]; i++) { if (needCsvQuote[((unsigned char *) z)[i]] || (z[i] == p->separator[0] && (nSep == 1 || memcmp (z, p->separator, nSep) == 0))) { i = 0; break; } } if (i == 0) { putc ('"', out); for (i = 0; z[i]; i++) { if (z[i] == '"') putc ('"', out); putc (z[i], out); } putc ('"', out); } else { fprintf (out, "%s", z); } } if (bSep) { fprintf (p->out, "%s", p->separator); } } #ifdef SIGINT /* ** This routine runs when the user presses Ctrl-C */ static void interrupt_handler (int NotUsed) { UNUSED_PARAMETER (NotUsed); seenInterrupt = 1; if (db) sqlite3_interrupt (db); } #endif /* ** This is the callback routine that the shell ** invokes for each row of a query result. */ static int shell_callback (void *pArg, int nArg, char **azArg, char **azCol, int *aiType) { int i; /* Sandro Furieri 11 July 2008 - supporting full UNICODE */ char *buf = NULL; int len; /* end Sandro Furieri 11 July 2008 */ struct callback_data *p = (struct callback_data *) pArg; switch (p->mode) { case MODE_Line: { int w = 5; if (azArg == 0) break; for (i = 0; i < nArg; i++) { int len = strlen30 (azCol[i] ? azCol[i] : ""); if (len > w) w = len; } if (p->cnt++ > 0) fprintf (p->out, "\n"); for (i = 0; i < nArg; i++) { /* Sandro Furieri 11 July 2008 fprintf(p->out,"%*s = %s\n", w, azCol[i], azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) fprintf (p->out, "%*s = %s\n", w, azCol[i], p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); fprintf (p->out, "%*s = %s\n", w, azCol[i], azArg[i] ? buf : p->nullvalue); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ } break; } case MODE_Explain: case MODE_Column: { if (p->cnt++ == 0) { for (i = 0; i < nArg; i++) { int w, n; if (i < ArraySize (p->colWidth)) { w = p->colWidth[i]; } else { w = 0; } if (w <= 0) { w = strlen30 (azCol[i] ? azCol[i] : ""); if (w < 10) w = 10; n = strlen30 (azArg && azArg[i] ? azArg[i] : p->nullvalue); if (w < n) w = n; } if (i < ArraySize (p->actualWidth)) { p->actualWidth[i] = w; } if (p->showHeader) { fprintf (p->out, "%-*.*s%s", w, w, azCol[i], i == nArg - 1 ? "\n" : " "); } } if (p->showHeader) { for (i = 0; i < nArg; i++) { int w; if (i < ArraySize (p->actualWidth)) { w = p->actualWidth[i]; } else { w = 10; } fprintf (p->out, "%-*.*s%s", w, w, "-----------------------------------" "----------------------------------------------------------", i == nArg - 1 ? "\n" : " "); } } } if (azArg == 0) break; for (i = 0; i < nArg; i++) { int w; if (i < ArraySize (p->actualWidth)) { w = p->actualWidth[i]; } else { w = 10; } if (p->mode == MODE_Explain && azArg[i] && strlen30 (azArg[i]) > w) { w = strlen30 (azArg[i]); } /* Sandro Furieri 11 July 2008 fprintf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " "); */ if (azArg[i] == 0) fprintf (p->out, "%-*.*s%s", w, w, p->nullvalue, i == nArg - 1 ? "\n" : " "); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); fprintf (p->out, "%-*.*s%s", w, w, azArg[i] ? buf : p->nullvalue, i == nArg - 1 ? "\n" : " "); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf (p->out, "%-*.*s%s", w, w, azArg[i] ? azArg[i] : p->nullvalue, i == nArg - 1 ? "\n" : " "); } break; } case MODE_Semi: case MODE_List: { if (p->cnt++ == 0 && p->showHeader) { for (i = 0; i < nArg; i++) { fprintf (p->out, "%s%s", azCol[i], i == nArg - 1 ? "\n" : p->separator); } } if (azArg == 0) break; for (i = 0; i < nArg; i++) { /* Sandro Furieri 11 July 2008 char *z = azArg[i]; if( z==0 ) z = p->nullvalue; */ char *z; if (azArg[i] == 0) z = p->nullvalue; else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); z = buf; strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); } /* end Sandro Furieri 11 July 2008 */ fprintf (p->out, "%s", z); if (buf) free (buf); buf = NULL; if (i < nArg - 1) { fprintf (p->out, "%s", p->separator); } else if (p->mode == MODE_Semi) { fprintf (p->out, ";\n"); } else { fprintf (p->out, "\n"); } } break; } case MODE_Html: { if (p->cnt++ == 0 && p->showHeader) { fprintf (p->out, "<TR>"); for (i = 0; i < nArg; i++) { fprintf (p->out, "<TH>"); output_html_string (p->out, azCol[i]); fprintf (p->out, "</TH>\n"); } fprintf (p->out, "</TR>\n"); } if (azArg == 0) break; fprintf (p->out, "<TR>"); for (i = 0; i < nArg; i++) { fprintf (p->out, "<TD>"); /* Sandro Furieri 11 July 2008 output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) output_html_string (p->out, p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_html_string (p->out, azArg[i] ? buf : p->nullvalue); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf (p->out, "</TD>\n"); } fprintf (p->out, "</TR>\n"); break; } case MODE_Tcl: { if (p->cnt++ == 0 && p->showHeader) { for (i = 0; i < nArg; i++) { output_c_string (p->out, azCol[i] ? azCol[i] : ""); fprintf (p->out, "%s", p->separator); } fprintf (p->out, "\n"); } if (azArg == 0) break; for (i = 0; i < nArg; i++) { /* Sandro Furieri 11 July 2008 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) output_c_string (p->out, p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_c_string (p->out, azArg[i] ? buf : p->nullvalue); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf (p->out, "%s", p->separator); } fprintf (p->out, "\n"); break; } case MODE_Csv: { if (p->cnt++ == 0 && p->showHeader) { for (i = 0; i < nArg; i++) { output_csv (p, azCol[i] ? azCol[i] : "", i < nArg - 1); } fprintf (p->out, "\n"); } if (azArg == 0) break; for (i = 0; i < nArg; i++) { /* Sandro Furieri 11 July 2008 output_csv(p, azArg[i], i<nArg-1); */ if (azArg[i] == 0) output_csv (p, azArg[i], i < nArg - 1); else { ................................................................................ len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_csv (p, buf, i < nArg - 1); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ } fprintf (p->out, "\n"); break; } case MODE_Insert: { p->cnt++; if (azArg == 0) break; fprintf (p->out, "INSERT INTO %s VALUES(", p->zDestTable); for (i = 0; i < nArg; i++) { char *zSep = i > 0 ? "," : ""; if ((azArg[i] == 0) || (aiType && aiType[i] == SQLITE_NULL)) { fprintf (p->out, "%sNULL", zSep); } else if (aiType && aiType[i] == SQLITE_TEXT) { if (zSep[0]) fprintf (p->out, "%s", zSep); /* Sandro Furieri 11 July 2008 output_quoted_string(p->out, azArg[i]); */ if (azArg[i] == 0) output_quoted_string (p->out, azArg[i]); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_quoted_string (p->out, buf); free (buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ } else if (aiType && (aiType[i] == SQLITE_INTEGER || aiType[i] == SQLITE_FLOAT)) { fprintf (p->out, "%s%s", zSep, azArg[i]); } else if (aiType && aiType[i] == SQLITE_BLOB && p->pStmt) { const void *pBlob = sqlite3_column_blob (p->pStmt, i); int nBlob = sqlite3_column_bytes (p->pStmt, i); if (zSep[0]) fprintf (p->out, "%s", zSep); output_hex_blob (p->out, pBlob, nBlob); } else if (isNumber (azArg[i], 0)) { fprintf (p->out, "%s%s", zSep, azArg[i]); } else { if (zSep[0]) fprintf (p->out, "%s", zSep); output_quoted_string (p->out, azArg[i]); } } fprintf (p->out, ");\n"); break; } } return 0; } /* ** This is the callback routine that the SQLite library ** invokes for each row of a query result. */ static int callback (void *pArg, int nArg, char **azArg, char **azCol) { /* since we don't have type info, call the shell_callback with a NULL value */ return shell_callback (pArg, nArg, azArg, azCol, NULL); } /* ** Set the destination table field of the callback_data structure to ** the name of the table given. Escape any quote characters in the ** table name. */ static void set_table_name (struct callback_data *p, const char *zName) { int i, n; int needQuote; char *z; if (p->zDestTable) { free (p->zDestTable); p->zDestTable = 0; } if (zName == 0) return; needQuote = !isalpha ((unsigned char) *zName) && *zName != '_'; for (i = n = 0; zName[i]; i++, n++) { if (!isalnum ((unsigned char) zName[i]) && zName[i] != '_') { needQuote = 1; if (zName[i] == '\'') n++; } } if (needQuote) n += 2; z = p->zDestTable = malloc (n + 1); if (z == 0) { fprintf (stderr, "Error: out of memory\n"); exit (1); } n = 0; if (needQuote) z[n++] = '\''; for (i = 0; zName[i]; i++) { z[n++] = zName[i]; if (zName[i] == '\'') z[n++] = '\''; } if (needQuote) z[n++] = '\''; z[n] = 0; } /* zIn is either a pointer to a NULL-terminated string in memory obtained ** from malloc(), or a NULL pointer. The string pointed to by zAppend is ** added to zIn, and the result returned in memory obtained from malloc(). ** zIn, if it was not NULL, is freed. ** ** If the third argument, quote, is not '\0', then it is used as a ** quote character for zAppend. */ static char * appendText (char *zIn, char const *zAppend, char quote) { int len; int i; int nAppend = strlen30 (zAppend); int nIn = (zIn ? strlen30 (zIn) : 0); len = nAppend + nIn + 1; if (quote) { len += 2; for (i = 0; i < nAppend; i++) { if (zAppend[i] == quote) len++; } } zIn = (char *) realloc (zIn, len); if (!zIn) { return 0; } if (quote) { char *zCsr = &zIn[nIn]; *zCsr++ = quote; for (i = 0; i < nAppend; i++) { *zCsr++ = zAppend[i]; if (zAppend[i] == quote) *zCsr++ = quote; } *zCsr++ = quote; *zCsr++ = '\0'; assert ((zCsr - zIn) == len); } else { memcpy (&zIn[nIn], zAppend, nAppend); zIn[len - 1] = '\0'; } return zIn; } /* ** Execute a query statement that will generate SQL output. Print ** the result columns, comma-separated, on a line and then add a ** semicolon terminator to the end of that line. ** ** If the number of columns is 1 and that column contains text "--" ** then write the semicolon on a separate line. That way, if a ** "--" comment occurs at the end of the statement, the comment ** won't consume the semicolon terminator. */ static int run_table_dump_query (struct callback_data *p, /* Query context */ const char *zSelect, /* SELECT statement to extract content */ const char *zFirstRow /* Print before first row, if not NULL */ ) { sqlite3_stmt *pSelect; int rc; int nResult; int i; const char *z; rc = sqlite3_prepare (p->db, zSelect, -1, &pSelect, 0); if (rc != SQLITE_OK || !pSelect) { fprintf (p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg (p->db)); p->nErr++; return rc; } rc = sqlite3_step (pSelect); nResult = sqlite3_column_count (pSelect); while (rc == SQLITE_ROW) { if (zFirstRow) { fprintf (p->out, "%s", zFirstRow); zFirstRow = 0; } z = (const char *) sqlite3_column_text (pSelect, 0); fprintf (p->out, "%s", z); for (i = 1; i < nResult; i++) { fprintf (p->out, ",%s", sqlite3_column_text (pSelect, i)); } if (z == 0) z = ""; while (z[0] && (z[0] != '-' || z[1] != '-')) z++; if (z[0]) { fprintf (p->out, "\n;\n"); } else { fprintf (p->out, ";\n"); } rc = sqlite3_step (pSelect); } rc = sqlite3_finalize (pSelect); if (rc != SQLITE_OK) { fprintf (p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg (p->db)); p->nErr++; } return rc; } /* ** Allocate space and save off current error string. */ static char * save_err_msg (sqlite3 * db /* Database to query */ ) { int nErrMsg = 1 + strlen30 (sqlite3_errmsg (db)); char *zErrMsg = sqlite3_malloc (nErrMsg); if (zErrMsg) { memcpy (zErrMsg, sqlite3_errmsg (db), nErrMsg); } return zErrMsg; } /* ** Display memory stats. */ static int display_stats (sqlite3 * db, /* Database to query */ struct callback_data *pArg, /* Pointer to struct callback_data */ int bReset /* True to reset the stats */ ) { int iCur; int iHiwtr; if (pArg && pArg->out) { iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr); /* ** Not currently used by the CLI. ** iHiwtr = iCur = -1; ** sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset); ** fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr); */ iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); /* ** Not currently used by the CLI. ** iHiwtr = iCur = -1; ** sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset); ** fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr); */ iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Largest Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr); #ifdef YYTRACKMAXSTACKDEPTH iHiwtr = iCur = -1; sqlite3_status (SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr); #endif } /* Sandro Furieri 1 November 2012 - depending on SQLite version */ if (pArg && pArg->out && db) { iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED sqlite3_db_status (db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); #else fprintf (pArg->out, "Lookaside Slots Used: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT sqlite3_db_status (db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); #else fprintf (pArg->out, "Successful lookaside attempts: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE sqlite3_db_status (db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); #else fprintf (pArg->out, "Lookaside failures due to size: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL sqlite3_db_status (db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); #else fprintf (pArg->out, "Lookaside failures due to OOM: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_USED sqlite3_db_status (db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Pager Heap Usage: %d bytes\n", iCur); #else fprintf (pArg->out, "Pager Heap Usage: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT sqlite3_db_status (db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1); fprintf (pArg->out, "Page cache hits: %d\n", iCur); #else fprintf (pArg->out, "Page cache hits: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_MISS sqlite3_db_status (db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1); fprintf (pArg->out, "Page cache misses: %d\n", iCur); #else fprintf (pArg->out, "Page cache misses: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_WRITE sqlite3_db_status (db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1); fprintf (pArg->out, "Page cache writes: %d\n", iCur); #else fprintf (pArg->out, "Page cache writes: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_SCHEMA_USED sqlite3_db_status (db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Schema Heap Usage: %d bytes\n", iCur); #else fprintf (pArg->out, "Schema Heap Usage: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_STMT_USED sqlite3_db_status (db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset); fprintf (pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur); #else fprintf (pArg->out, "Statement Heap/Lookaside Usage: n.a.\n"); #endif } if (pArg && pArg->out && db && pArg->pStmt) { #ifdef HAVE_DECL_SQLITE_STMTSTATUS_FULLSCAN_STEP iCur = sqlite3_stmt_status (pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset); fprintf (pArg->out, "Fullscan Steps: %d\n", iCur); #else fprintf (pArg->out, "Fullscan Steps: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_STMTSTATUS_SORT iCur = sqlite3_stmt_status (pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset); fprintf (pArg->out, "Sort Operations: %d\n", iCur); #else fprintf (pArg->out, "Sort Operations: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_STMTSTATUS_AUTOINDEX iCur = sqlite3_stmt_status (pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset); fprintf (pArg->out, "Autoindex Inserts: %d\n", iCur); #else fprintf (pArg->out, "Autoindex Inserts: n.a.\n"); #endif } /* end sandro 1 November 2012 */ return 0; } /* ** Execute a statement or set of statements. Print ** any result rows/columns depending on the current mode ** set via the supplied callback. ** ** This is very similar to SQLite's built-in sqlite3_exec() ** function except it takes a slightly different callback ** and callback data argument. */ static int shell_exec (sqlite3 * db, /* An open database */ const char *zSql, /* SQL to be evaluated */ int (*xCallback) (void *, int, char **, char **, int *), /* Callback function */ /* (not the same as sqlite3_exec) */ struct callback_data *pArg, /* Pointer to struct callback_data */ char **pzErrMsg /* Error msg written here */ ) { sqlite3_stmt *pStmt = NULL; /* Statement to execute. */ int rc = SQLITE_OK; /* Return Code */ int rc2; const char *zLeftover; /* Tail of unprocessed SQL */ if (pzErrMsg) { *pzErrMsg = NULL; } while (zSql[0] && (SQLITE_OK == rc)) { rc = sqlite3_prepare_v2 (db, zSql, -1, &pStmt, &zLeftover); if (SQLITE_OK != rc) { if (pzErrMsg) { *pzErrMsg = save_err_msg (db); } } else { if (!pStmt) { /* this happens for a comment or white-space */ zSql = zLeftover; while (IsSpace (zSql[0])) zSql++; continue; } /* save off the prepared statment handle and reset row count */ if (pArg) { pArg->pStmt = pStmt; pArg->cnt = 0; } /* echo the sql statement if echo on */ if (pArg && pArg->echoOn) { const char *zStmtSql = sqlite3_sql (pStmt); fprintf (pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); } /* Output TESTCTRL_EXPLAIN text of requested */ if (pArg && pArg->mode == MODE_Explain) { /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_TESTCTRL_EXPLAIN_STMT const char *zExplain = 0; sqlite3_test_control (SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain); if (zExplain && zExplain[0]) { fprintf (pArg->out, "%s", zExplain); } #else fprintf (pArg->out, "TESTCTRL_EXPLAIN: unsupported"); #endif /* end sandro 1 November 2012 */ } /* perform the first step. this will tell us if we ** have a result set or not and how wide it is. */ rc = sqlite3_step (pStmt); /* if we have a result set... */ if (SQLITE_ROW == rc) { /* if we have a callback... */ if (xCallback) { /* allocate space for col name ptr, value ptr, and type */ int nCol = sqlite3_column_count (pStmt); void *pData = sqlite3_malloc (3 * nCol * sizeof (const char *) + 1); if (!pData) { rc = SQLITE_NOMEM; } else { char **azCols = (char **) pData; /* Names of result columns */ char **azVals = &azCols[nCol]; /* Results */ int *aiTypes = (int *) &azVals[nCol]; /* Result types */ int i; assert (sizeof (int) <= sizeof (char *)); /* save off ptrs to column names */ for (i = 0; i < nCol; i++) { azCols[i] = (char *) sqlite3_column_name (pStmt, i); } do { /* extract the data and data types */ for (i = 0; i < nCol; i++) { azVals[i] = (char *) sqlite3_column_text (pStmt, i); aiTypes[i] = sqlite3_column_type (pStmt, i); if (!azVals[i] && (aiTypes[i] != SQLITE_NULL)) { rc = SQLITE_NOMEM; break; /* from for */ } } /* end for */ /* if data and types extracted successfully... */ if (SQLITE_ROW == rc) { /* call the supplied callback with the result row data */ if (xCallback (pArg, nCol, azVals, azCols, aiTypes)) { rc = SQLITE_ABORT; } else { rc = sqlite3_step (pStmt); } } } while (SQLITE_ROW == rc); sqlite3_free (pData); } } else { do { rc = sqlite3_step (pStmt); } while (rc == SQLITE_ROW); } } /* print usage stats if stats on */ if (pArg && pArg->statsOn) { display_stats (db, pArg, 0); } /* Finalize the statement just executed. If this fails, save a ** copy of the error message. Otherwise, set zSql to point to the ** next statement to execute. */ rc2 = sqlite3_finalize (pStmt); if (rc != SQLITE_NOMEM) rc = rc2; if (rc == SQLITE_OK) { zSql = zLeftover; while (IsSpace (zSql[0])) zSql++; } else if (pzErrMsg) { *pzErrMsg = save_err_msg (db); } /* clear saved stmt handle */ if (pArg) { pArg->pStmt = NULL; } } } /* end while */ return rc; } /* ** This is a different callback routine used for dumping the database. ** Each row received by this callback consists of a table name, ** the table type ("index" or "table") and SQL to create the table. ** This routine should print text sufficient to recreate the table. */ static int dump_callback (void *pArg, int nArg, char **azArg, char **azCol) { int rc; const char *zTable; const char *zType; const char *zSql; const char *zPrepStmt = 0; struct callback_data *p = (struct callback_data *) pArg; UNUSED_PARAMETER (azCol); if (nArg != 3) return 1; zTable = azArg[0]; zType = azArg[1]; zSql = azArg[2]; if (strcmp (zTable, "sqlite_sequence") == 0) { zPrepStmt = "DELETE FROM sqlite_sequence;\n"; } else if (strcmp (zTable, "sqlite_stat1") == 0) { fprintf (p->out, "ANALYZE sqlite_master;\n"); } else if (strncmp (zTable, "sqlite_", 7) == 0) { return 0; } else if (strncmp (zSql, "CREATE VIRTUAL TABLE", 20) == 0) { char *zIns; if (!p->writableSchema) { fprintf (p->out, "PRAGMA writable_schema=ON;\n"); p->writableSchema = 1; } zIns = sqlite3_mprintf ("INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)" "VALUES('table','%q','%q',0,'%q');", zTable, zTable, zSql); fprintf (p->out, "%s\n", zIns); sqlite3_free (zIns); return 0; } else { fprintf (p->out, "%s;\n", zSql); } if (strcmp (zType, "table") == 0) { sqlite3_stmt *pTableInfo = 0; char *zSelect = 0; char *zTableInfo = 0; char *zTmp = 0; int nRow = 0; zTableInfo = appendText (zTableInfo, "PRAGMA table_info(", 0); zTableInfo = appendText (zTableInfo, zTable, '"'); zTableInfo = appendText (zTableInfo, ");", 0); rc = sqlite3_prepare (p->db, zTableInfo, -1, &pTableInfo, 0); free (zTableInfo); if (rc != SQLITE_OK || !pTableInfo) { return 1; } zSelect = appendText (zSelect, "SELECT 'INSERT INTO ' || ", 0); /* Always quote the table name, even if it appears to be pure ascii, ** in case it is a keyword. Ex: INSERT INTO "table" ... */ zTmp = appendText (zTmp, zTable, '"'); if (zTmp) { zSelect = appendText (zSelect, zTmp, '\''); free (zTmp); } zSelect = appendText (zSelect, " || ' VALUES(' || ", 0); rc = sqlite3_step (pTableInfo); while (rc == SQLITE_ROW) { const char *zText = (const char *) sqlite3_column_text (pTableInfo, 1); zSelect = appendText (zSelect, "quote(", 0); zSelect = appendText (zSelect, zText, '"'); rc = sqlite3_step (pTableInfo); if (rc == SQLITE_ROW) { zSelect = appendText (zSelect, "), ", 0); } else { zSelect = appendText (zSelect, ") ", 0); } nRow++; } rc = sqlite3_finalize (pTableInfo); if (rc != SQLITE_OK || nRow == 0) { free (zSelect); return 1; } zSelect = appendText (zSelect, "|| ')' FROM ", 0); zSelect = appendText (zSelect, zTable, '"'); rc = run_table_dump_query (p, zSelect, zPrepStmt); if (rc == SQLITE_CORRUPT) { zSelect = appendText (zSelect, " ORDER BY rowid DESC", 0); run_table_dump_query (p, zSelect, 0); } free (zSelect); } return 0; } static void spatialite_autocreate (sqlite3 * db) { /* attempting to perform self-initialization for a newly created DB */ int ret; ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } spatial_ref_sys_init (db, 1); } /* ** Run zQuery. Use dump_callback() as the callback routine so that ** the contents of the query are output as SQL statements. ** ** If we get a SQLITE_CORRUPT error, rerun the query after appending ** "ORDER BY rowid DESC" to the end. */ static int run_schema_dump_query (struct callback_data *p, const char *zQuery) { int rc; char *zErr = 0; rc = sqlite3_exec (p->db, zQuery, dump_callback, p, &zErr); if (rc == SQLITE_CORRUPT) { char *zQ2; int len = strlen30 (zQuery); fprintf (p->out, "/****** CORRUPTION ERROR *******/\n"); if (zErr) { fprintf (p->out, "/****** %s ******/\n", zErr); sqlite3_free (zErr); zErr = 0; } zQ2 = malloc (len + 100); if (zQ2 == 0) return rc; sqlite3_snprintf (len + 100, zQ2, "%s ORDER BY rowid DESC", zQuery); rc = sqlite3_exec (p->db, zQ2, dump_callback, p, &zErr); if (rc) { fprintf (p->out, "/****** ERROR: %s ******/\n", zErr); } else { rc = SQLITE_CORRUPT; } sqlite3_free (zErr); free (zQ2); } return rc; } /* ** Text of a help message */ static char zHelp[] = ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail ON|OFF Stop after hitting an error. Default OFF\n" ".databases List names and files of attached databases\n" ".dump ?TABLE? ... Dump the database in an SQL text format\n" " If TABLE specified, only dump tables matching\n" " LIKE pattern TABLE.\n" ".echo ON|OFF Turn command echo on or off\n" ".exit Exit this program\n" ".explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.\n" " With no args, it turns EXPLAIN on.\n" ".header(s) ON|OFF Turn display of headers on or off\n" ".help Show this message\n" ".import FILE TABLE Import data from FILE into TABLE\n" ".indices ?TABLE? Show names of all indices\n" " If TABLE specified, only show indices for tables\n" " matching LIKE pattern TABLE.\n" #ifdef SQLITE_ENABLE_IOTRACE ".iotrace FILE Enable I/O diagnostic logging to FILE\n" #endif #ifndef SQLITE_OMIT_LOAD_EXTENSION ".load FILE ?ENTRY? Load an extension library\n" #endif ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" " csv Comma-separated values\n" " column Left-aligned columns. (See .width)\n" " html HTML <table> code\n" " insert SQL insert statements for TABLE\n" " line One value per line\n" " list Values delimited by .separator string\n" " tabs Tab-separated values\n" " tcl TCL list elements\n" ".nullvalue STRING Print STRING in place of NULL values\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" ".schema ?TABLE? Show the CREATE statements\n" " If TABLE specified, only show tables matching\n" " LIKE pattern TABLE.\n" ".separator STRING Change separator used by output mode and .import\n" ".shell CMD ARGS... Run CMD ARGS... in a system shell\n" ".show Show the current values for various settings\n" ".stats ON|OFF Turn stats on or off\n" ".system CMD ARGS... Run CMD ARGS... in a system shell\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" ".timeout MS Try opening locked tables for MS milliseconds\n" ".trace FILE|off Output each SQL statement as it is run\n" ".vfsname ?AUX? Print the name of the VFS stack\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"; static char zTimerHelp[] = ".timer ON|OFF Turn the CPU timer measurement on or off\n" /* Sandro Furieri 2008-06-20 */ "\n====================== SpatiaLite ========================================\n\n" ".charset Report the current locale charset setting\n\n" ".charset <charset-name>\n" " Set the charset encoding according to the command shell\n" " e.g.: when working on Windows Command Prompt, if you notice\n" " 'strange' chars, a very good idea may be to type\n" ................................................................................ ".remdupl <table> Removes any duplicated row from a TABLE\n\n" ".elemgeo <args> derives a new table from the original one, so to ensure that\n" " only elementary Geometries (one for each row) will be present\n" " arg_list: in_tbl geom out_tbl out_pk out_old_id\n\n" ".loadshp <args> Loads a SHAPEFILE into a SpatiaLite table\n" " arg_list: shp_path table_name charset [SRID] [column_name]\n" " [pk_column] [geom_type] [2d | 3d] [compressed]\n" " [with_spatial_index] [text_dates] [colname_case]\n" " geom_type={ AUTO | LINESTRING[ Z | M | ZM ]\n" " | MULTILINESTRING[ Z | M | ZM ]\n" " | POLYGON[ Z | M | ZM ]\n" " | MULTIPOLYGON[ Z | M | ZM ] }\n\n" ".dumpshp <args> Dumps a SpatiaLite table into a SHAPEFILE\n" " arg_list: table_name column_name shp_path charset [geom_type]\n" " [colname_case]\n" " geom_type={ POINT | LINESTRING | POLYGON | MULTIPOINT }\n\n" ".loaddbf <args> Loads a DBF into a SpatiaLite table\n" " arg_list: dbf_path table_name charset [pk_column]\n" " [text_dates] [colname_case]\n\n" ".dumpdbf <args> Dumps a SpatiaLite table into a DBF\n" " arg_list: table_name dbf_path charset [colname_case]\n\n" #ifndef OMIT_FREEXL /* FreeXL is enabled */ ".loadxl <args> Loads a XL spreadsheet (.xls) into a SpatiaLite table\n" " arg_list: xl_path table_name \n" " [worksheet_index [first_line_titles{0/1}]]\n\n" #endif /* end FreeXL support */ ".dumpkml <args> Dumps a SpatiaLite table as a KML file\n" " arg_list: table_name geom_column kml_path\n" ................................................................................ " [swap] [page_size] [with_spatial_index]\n\n" ".loaddxf <args> Loads data from some DXF source into SpatiaLite tables\n" " arg_list: DXF_path [srid] [append] [dims] [mode]\n" " [rings] [table_prefix] [layer_name]\n" " append={Y|N} dims={AUTO|2D|3D} mode={DISTINCT|MIXED}\n" " rings={NONE|LINKED|UNLINKED}\n\n" /* end Sandro Furieri 2008-06-20 */ ; /* Forward reference */ static int process_input (struct callback_data *p, FILE * in, char *in_charset); /* ** Make sure the database is open. If it is not, then open it. If ** the database fails to open, print an error message and exit. */ static void open_db (struct callback_data *p) { if (p->db == 0) { sqlite3_initialize (); sqlite3_open (p->zDbFilename, &p->db); db = p->db; if (db && sqlite3_errcode (db) == SQLITE_OK) { sqlite3_create_function (db, "shellstatic", 0, SQLITE_UTF8, 0, shellstaticFunc, 0, 0); } if (db == 0 || SQLITE_OK != sqlite3_errcode (db)) { fprintf (stderr, "Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg (db)); exit (1); } spatialite_init_ex (p->db, splite_cache, (splite_silent == 0) ? 1 : 0); #ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension (p->db, 1); #endif /* Sandro Furieri 2009-11-08 */ sqlite3_exec (p->db, "PRAGMA foreign_keys = 1", NULL, 0, NULL); /* end Sandro Furieri 2008-11-08 */ /* Sandro Furieri 2010-08-07 */ spatialite_autocreate (p->db); /* end Sandro Furieri 2010-08-07 */ } } /* ** Do C-language style dequoting. ** ** \t -> tab ** \n -> newline ** \r -> carriage return ** \NNN -> ascii character NNN in octal ** \\ -> backslash */ static void resolve_backslashes (char *z) { int i, j; char c; for (i = j = 0; (c = z[i]) != 0; i++, j++) { if (c == '\\') { c = z[++i]; if (c == 'n') { c = '\n'; } else if (c == 't') { c = '\t'; } else if (c == 'r') { c = '\r'; } else if (c >= '0' && c <= '7') { c -= '0'; if (z[i + 1] >= '0' && z[i + 1] <= '7') { i++; c = (c << 3) + z[i] - '0'; if (z[i + 1] >= '0' && z[i + 1] <= '7') { i++; c = (c << 3) + z[i] - '0'; } } } } z[j] = c; } z[j] = 0; } /* ** Interpret zArg as a boolean value. Return either 0 or 1. */ static int booleanValue (char *zArg) { int val = atoi (zArg); int j; for (j = 0; zArg[j]; j++) { zArg[j] = ToLower (zArg[j]); } if (strcmp (zArg, "on") == 0) { val = 1; } else if (strcmp (zArg, "yes") == 0) { val = 1; } return val; } /* ** Close an output file, assuming it is not stderr or stdout */ static void output_file_close (FILE * f) { if (f && f != stdout && f != stderr) fclose (f); } /* ** Try to open an output file. The names "stdout" and "stderr" are ** recognized and do the right thing. NULL is returned if the output ** filename is "off". */ static FILE * output_file_open (const char *zFile) { FILE *f; if (strcmp (zFile, "stdout") == 0) { f = stdout; } else if (strcmp (zFile, "stderr") == 0) { f = stderr; } else if (strcmp (zFile, "off") == 0) { f = 0; } else { f = fopen (zFile, "wb"); if (f == 0) { fprintf (stderr, "Error: cannot open \"%s\"\n", zFile); } } return f; } /* ** A routine for handling output from sqlite3_trace(). */ static void sql_trace_callback (void *pArg, const char *z) { FILE *f = (FILE *) pArg; if (f) fprintf (f, "%s\n", z); } /* ** A no-op routine that runs with the ".breakpoint" doc-command. This is ** a useful spot to set a debugger breakpoint. */ static void test_breakpoint (void) { static int nCall = 0; nCall++; } /* ** If an input line begins with "." then invoke this routine to ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command (char *zLine, struct callback_data *p) { int i = 1; int nArg = 0; int n, c; int rc = 0; char *azArg[50]; /* Parse the input line into tokens. */ while (zLine[i] && nArg < ArraySize (azArg)) { while (IsSpace (zLine[i])) { i++; } if (zLine[i] == 0) break; if (zLine[i] == '\'' || zLine[i] == '"') { int delim = zLine[i++]; azArg[nArg++] = &zLine[i]; while (zLine[i] && zLine[i] != delim) { i++; } if (zLine[i] == delim) { zLine[i++] = 0; } if (delim == '"') resolve_backslashes (azArg[nArg - 1]); } else { azArg[nArg++] = &zLine[i]; while (zLine[i] && !IsSpace (zLine[i])) { i++; } if (zLine[i]) zLine[i++] = 0; resolve_backslashes (azArg[nArg - 1]); } } /* Process the input line. */ if (nArg == 0) return 0; /* no tokens, no error */ n = strlen30 (azArg[0]); c = azArg[0][0]; #ifndef SQLITE_OMIT_LOAD_EXTENSION if (c == 'l' && strncmp (azArg[0], "load", n) == 0 && nArg >= 2) { const char *zFile, *zProc; char *zErrMsg = 0; zFile = azArg[1]; zProc = nArg >= 3 ? azArg[2] : 0; open_db (p); rc = sqlite3_load_extension (p->db, zFile, zProc, &zErrMsg); if (rc != SQLITE_OK) { fprintf (stderr, "Error: %s\n", zErrMsg); sqlite3_free (zErrMsg); rc = 1; } } else #endif /* Sandro Furieri 2008-06-20 */ if (c == 'c' && n > 1 && strncmp (azArg[0], "charset", n) == 0 && nArg == 1) { /* reporting the charset */ if (*spatialite_charset == '\0') { printf ("the shell's default LOCALE CHARSET is currently in use\n"); fflush (stdout); ................................................................................ else if (c == 'c' && n > 1 && strncmp (azArg[0], "charset", n) == 0 && nArg == 2) { /* setting the charset */ create_utf8_converter (azArg[1]); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpshp", n) == 0 && (nArg == 5 || nArg == 6 || nArg == 7)) { /* dumping a spatial table to SHAPEFILE */ char *table = azArg[1]; char *column = azArg[2]; char *shp_path = azArg[3]; char *outCS = azArg[4]; char *type = NULL; int rows; int colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; if (nArg >= 6) type = azArg[5]; if (nArg >= 7) { const char *pColnameCase = azArg[6]; if (strcasecmp (pColnameCase, "UPPER") == 0 || strcasecmp (pColnameCase, "UPPERCASE") == 0) colname_case = GAIA_DBF_COLNAME_UPPERCASE; else if (strcasecmp (pColnameCase, "LOWER") == 0 || strcasecmp (pColnameCase, "LOWERCASE") == 0) colname_case = GAIA_DBF_COLNAME_LOWERCASE; else colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; } open_db (p); dump_shapefile_ex (p->db, table, column, shp_path, outCS, type, 1, &rows, colname_case, NULL); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpdbf", n) == 0 && (nArg == 4 || nArg == 5)) { /* dumping a spatial table to DBF */ char *table = azArg[1]; char *dbf_path = azArg[2]; char *outCS = azArg[3]; int rows; int colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; if (nArg >= 5) { const char *pColnameCase = azArg[4]; if (strcasecmp (pColnameCase, "UPPER") == 0 || strcasecmp (pColnameCase, "UPPERCASE") == 0) colname_case = GAIA_DBF_COLNAME_UPPERCASE; else if (strcasecmp (pColnameCase, "LOWER") == 0 || strcasecmp (pColnameCase, "LOWERCASE") == 0) colname_case = GAIA_DBF_COLNAME_LOWERCASE; else colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; } open_db (p); dump_dbf_ex2 (p->db, table, dbf_path, outCS, &rows, colname_case, NULL); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpkml", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7)) { /* dumping a spatial table as KML file */ char *table = azArg[1]; char *geom = azArg[2]; ................................................................................ if (nArg == 6) precision = atoi (azArg[5]); open_db (p); dump_geojson (p->db, table, geom, gml_path, precision, format); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadshp", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7 || nArg == 8 || nArg == 9 || nArg == 10 || nArg == 11 || nArg == 12 || nArg == 13)) { char *shp_path = azArg[1]; char *table = azArg[2]; char *inCS = azArg[3]; int srid = -1; int coerce2d = 0; int compressed = 0; int with_spatial_index = 0; int text_dates = 0; int colname_case = GAIA_DBF_COLNAME_LOWERCASE; char *column = NULL; char *gtype = NULL; char *pk = NULL; int rows; if (nArg >= 5) srid = atoi (azArg[4]); if (nArg >= 6) column = azArg[5]; if (nArg >= 7) pk = azArg[6]; ................................................................................ gtype = azArg[7]; if (nArg >= 9) { if (strcasecmp (azArg[8], "2d") == 0) coerce2d = 1; } if (nArg >= 10) { if (strcasecmp (azArg[9], "compressed") == 0) compressed = 1; if (strcasecmp (azArg[9], "yes") == 0) compressed = 1; if (strcasecmp (azArg[9], "true") == 0) compressed = 1; if (strcasecmp (azArg[9], "1") == 0) compressed = 1; } if (nArg >= 11) { if (strcasecmp (azArg[10], "with_spatial_index") == 0) with_spatial_index = 1; if (strcasecmp (azArg[10], "yes") == 0) with_spatial_index = 1; if (strcasecmp (azArg[10], "true") == 0) with_spatial_index = 1; if (strcasecmp (azArg[10], "1") == 0) with_spatial_index = 1; } if (nArg >= 12) { if (strcasecmp (azArg[11], "text_dates") == 0) text_dates = 1; if (strcasecmp (azArg[11], "yes") == 0) text_dates = 1; if (strcasecmp (azArg[11], "true") == 0) text_dates = 1; if (strcasecmp (azArg[11], "1") == 0) text_dates = 1; } if (nArg >= 13) { const char *pColnameCase = azArg[12]; if (strcasecmp (pColnameCase, "UPPER") == 0 || strcasecmp (pColnameCase, "UPPERCASE") == 0) colname_case = GAIA_DBF_COLNAME_UPPERCASE; else if (strcasecmp (pColnameCase, "SAME") == 0 || strcasecmp (pColnameCase, "SAMECASE") == 0) colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; else colname_case = GAIA_DBF_COLNAME_LOWERCASE; } open_db (p); load_shapefile_ex3 (p->db, shp_path, table, inCS, srid, column, gtype, pk, coerce2d, compressed, 1, with_spatial_index, text_dates, &rows, colname_case, NULL); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loaddbf", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7)) { char *dbf_path = azArg[1]; char *table = azArg[2]; char *inCS = azArg[3]; char *pk = NULL; int text_dates = 0; int colname_case = GAIA_DBF_COLNAME_LOWERCASE; int rows; if (nArg >= 5) pk = azArg[4]; if (nArg >= 6) { if (strcasecmp (azArg[5], "text_dates") == 0) text_dates = 1; if (strcasecmp (azArg[5], "yes") == 0) text_dates = 1; if (strcasecmp (azArg[5], "true") == 0) text_dates = 1; if (strcasecmp (azArg[5], "1") == 0) text_dates = 1; } if (nArg >= 7) { const char *pColnameCase = azArg[6]; if (strcasecmp (pColnameCase, "UPPER") == 0 || strcasecmp (pColnameCase, "UPPERCASE") == 0) colname_case = GAIA_DBF_COLNAME_UPPERCASE; else if (strcasecmp (pColnameCase, "SAME") == 0 || strcasecmp (pColnameCase, "SAMECASE") == 0) colname_case = GAIA_DBF_COLNAME_CASE_IGNORE; else colname_case = GAIA_DBF_COLNAME_LOWERCASE; } open_db (p); load_dbf_ex3 (p->db, dbf_path, table, pk, inCS, 1, text_dates, &rows, colname_case, NULL); } #ifndef OMIT_FREEXL /* FREEXL is enabled */ else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadxl", n) == 0 && (nArg == 3 || nArg == 4 || nArg == 5)) { unsigned int rows; char *xl_path = azArg[1]; ................................................................................ open_db (p); load_XL (p->db, xl_path, table, worksheet, firstLine, &rows, NULL); } #endif /* end FREEXL support */ else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadwfs", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7 || nArg == 8)) { char *path_or_url = azArg[1]; char *layer_name = azArg[2]; char *table = azArg[3]; int swap_axes = 0; int with_spatial_index = 0; int page_size = -1; char *pk = NULL; char *err_msg = NULL; int rows; if (nArg >= 5) pk = azArg[4]; if (nArg >= 6) { if (strcasecmp (azArg[5], "swap") == 0 || strcasecmp (azArg[5], "swap_axis") == 0 || strcasecmp (azArg[5], "swap_axes") == 0) swap_axes = 1; } if (nArg >= 7) page_size = atoi (azArg[6]); if (nArg == 8) with_spatial_index = 1; open_db (p); if (load_from_wfs_paged (p->db, path_or_url, NULL, layer_name, swap_axes, table, pk, with_spatial_index, page_size, &rows, &err_msg, wfs_page_done, NULL) == 0) { fprintf (stderr, "Unable to load data from WFS:\n"); fprintf (stderr, "%s\n\n", err_msg); } else fprintf (stderr, "inserted %d rows from WFS into table \"%s\"\n\n", rows, table); if (err_msg) free (err_msg); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loaddxf", n) == 0 && (nArg == 2 || (nArg >= 3 && nArg <= 9))) { char *dxf_path = azArg[1]; int srid = -1; int append = 0; int special_rings = GAIA_DXF_RING_NONE; int mode = GAIA_DXF_IMPORT_BY_LAYER; int force_dims = GAIA_DXF_AUTO_2D_3D; char *prefix = NULL; char *layer_name = NULL; gaiaDxfParserPtr dxf = NULL; if (nArg >= 3) srid = atoi (azArg[2]); if (nArg >= 4) { if (strcasecmp (azArg[3], "y") == 0 || strcasecmp (azArg[3], "yes") == 0) append = 1; } if (nArg >= 5) { if (strcasecmp (azArg[4], "2D") == 0) force_dims = GAIA_DXF_FORCE_2D; if (strcasecmp (azArg[4], "3D") == 0) force_dims = GAIA_DXF_FORCE_3D; } if (nArg >= 6) { if (strcasecmp (azArg[5], "mixed") == 0) mode = GAIA_DXF_IMPORT_MIXED; } if (nArg >= 7) { if (strcasecmp (azArg[6], "linked") == 0) special_rings = GAIA_DXF_RING_LINKED; if (strcasecmp (azArg[6], "unlinked") == 0) special_rings = GAIA_DXF_RING_UNLINKED; } if (nArg >= 8) { if (strlen (azArg[7]) > 0) prefix = azArg[7]; } if (nArg == 9) { if (strlen (azArg[8]) > 0) layer_name = azArg[8]; } open_db (p); /* creating a DXF parser */ dxf = gaiaCreateDxfParser (srid, force_dims, prefix, layer_name, special_rings); if (dxf == NULL) goto stop_dxf; /* attempting to parse the DXF input file */ if (gaiaParseDxfFile_r (splite_cache, dxf, dxf_path)) { /* loading into the DB */ if (!gaiaLoadFromDxfParser (p->db, dxf, mode, append)) fprintf (stderr, "DB error while loading: %s\n", dxf_path); } else fprintf (stderr, "Unable to parse: %s\n", dxf_path); fprintf (stderr, "\n*** DXF file successfully loaded\n"); stop_dxf: /* destroying the DXF parser */ gaiaDestroyDxfParser (dxf); } else if (c == 'r' && strncmp (azArg[0], "read", n) == 0) { FILE *alt; char *arg2 = NULL; if (nArg == 2) ; else if (nArg == 3) arg2 = azArg[2]; else { fprintf (stderr, "invalid arguments: .read script_path charset\n"); return rc; } alt = fopen (azArg[1], "rb"); if (alt == 0) { fprintf (stderr, "can't open \"%s\"\n", azArg[1]); } else { process_input (p, alt, arg2); fclose (alt); } } else if (c == 'c' && strncmp (azArg[0], "chkdupl", n) == 0 && nArg == 2) { int rows; char *table = azArg[1]; ................................................................................ else if (c == 'c' && strncmp (azArg[0], "checkgeom", n) == 0 && nArg == 4) { char *table = azArg[1]; char *geometry = azArg[2]; char *report = azArg[3]; char *err_msg = NULL; open_db (p); if (!check_geometry_column (p->db, table, geometry, report, NULL, NULL, &err_msg)) { fprintf (stderr, "check_geometry_column error:\n"); fprintf (stderr, "%s\n\n", err_msg); } if (err_msg) free (err_msg); } else if (c == 'c' && strncmp (azArg[0], "checkgeom", n) == 0 && nArg == 2) { char *output_dir = azArg[1]; char *err_msg = NULL; open_db (p); if (!check_all_geometry_columns (p->db, output_dir, NULL, &err_msg)) { fprintf (stderr, "check_all_geometry_columns error:\n"); fprintf (stderr, "%s\n\n", err_msg); } if (err_msg) free (err_msg); } else if (c == 's' && strncmp (azArg[0], "sanegeom", n) == 0 && nArg == 5) { char *table = azArg[1]; char *geometry = azArg[2]; char *tmp_table = azArg[3]; char *report = azArg[4]; char *err_msg = NULL; open_db (p); if (!sanitize_geometry_column (p->db, table, geometry, tmp_table, report, NULL, NULL, NULL, NULL, &err_msg)) { fprintf (stderr, "sanitize_geometry_column error:\n"); fprintf (stderr, "%s\n\n", err_msg); } if (err_msg) free (err_msg); } else if (c == 's' && strncmp (azArg[0], "sanegeom", n) == 0 && nArg == 3) { char *tmp_prefix = azArg[1]; char *output_dir = azArg[2]; char *err_msg = NULL; open_db (p); if (!sanitize_all_geometry_columns (p->db, tmp_prefix, output_dir, NULL, &err_msg)) { fprintf (stderr, "sanitize_all_geometry_columns error:\n"); fprintf (stderr, "%s\n\n", err_msg); } if (err_msg) free (err_msg); } else if (c == 'e' && strncmp (azArg[0], "elemgeo", n) == 0 && nArg == 6) { char *inTable = azArg[1]; char *geom = azArg[2]; char *outTable = azArg[3]; char *pKey = azArg[4]; ................................................................................ } else if (c == 's' && strncmp (azArg[0], "sqllog", n) == 0 && nArg > 1) { sql_log_enabled = booleanValue (azArg[1]); } else if (c == 'd' && strncmp (azArg[0], "dropgeo", n) == 0 && nArg > 1) { char *prefix; char *table; int ret; int cnt0 = sqlite3_total_changes (p->db); split_drop_name (azArg[1], &prefix, &table); if (prefix != NULL && table != NULL) ret = gaiaDropTableEx (p->db, prefix, table); else ret = gaiaDropTable (p->db, azArg[1]); if (ret) { int cnt1 = sqlite3_total_changes (p->db); if (cnt1 > cnt0) fprintf (stderr, "SpatialTable %s successfully removed\n", azArg[1]); else fprintf (stderr, "SpatialTable %s seems not to exist\n", azArg[1]); } else fprintf (stderr, "ERROR: unable to remove SpatialTable %s\n", azArg[1]); if (prefix != NULL) free (prefix); if (table != NULL) free (table); } else /* end sandro 2008-06-20 */ if (c == 'b' && n >= 3 && strncmp (azArg[0], "backup", n) == 0 && nArg > 1 && nArg < 4) { const char *zDestFile; const char *zDb; sqlite3 *pDest; sqlite3_backup *pBackup; if (nArg == 2) { zDestFile = azArg[1]; zDb = "main"; } else { zDestFile = azArg[2]; zDb = azArg[1]; } rc = sqlite3_open (zDestFile, &pDest); if (rc != SQLITE_OK) { fprintf (stderr, "Error: cannot open \"%s\"\n", zDestFile); sqlite3_close (pDest); return 1; } open_db (p); pBackup = sqlite3_backup_init (pDest, "main", p->db, zDb); if (pBackup == 0) { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (pDest)); sqlite3_close (pDest); return 1; } while ((rc = sqlite3_backup_step (pBackup, 100)) == SQLITE_OK) { } sqlite3_backup_finish (pBackup); if (rc == SQLITE_DONE) { rc = 0; } else { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (pDest)); rc = 1; } sqlite3_close (pDest); } else if (c == 'b' && n >= 3 && strncmp (azArg[0], "bail", n) == 0 && nArg > 1 && nArg < 3) { bail_on_error = booleanValue (azArg[1]); } else /* The undocumented ".breakpoint" command causes a call to the no-op ** routine named test_breakpoint(). */ if (c == 'b' && n >= 3 && strncmp (azArg[0], "breakpoint", n) == 0) { test_breakpoint (); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "databases", n) == 0 && nArg == 1) { struct callback_data data; char *zErrMsg = 0; open_db (p); memcpy (&data, p, sizeof (data)); data.showHeader = 1; data.mode = MODE_Column; data.colWidth[0] = 3; data.colWidth[1] = 15; data.colWidth[2] = 58; data.cnt = 0; sqlite3_exec (p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if (zErrMsg) { fprintf (stderr, "Error: %s\n", zErrMsg); sqlite3_free (zErrMsg); rc = 1; } } else if (c == 'd' && strncmp (azArg[0], "dump", n) == 0 && nArg < 3) { open_db (p); /* When playing back a "dump", the content might appear in an order ** which causes immediate foreign key constraints to be violated. ** So disable foreign-key constraint enforcement to prevent problems. */ fprintf (p->out, "PRAGMA foreign_keys=OFF;\n"); fprintf (p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; sqlite3_exec (p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; if (nArg == 1) { run_schema_dump_query (p, "SELECT name, type, sql FROM sqlite_master " "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'"); run_schema_dump_query (p, "SELECT name, type, sql FROM sqlite_master " "WHERE name=='sqlite_sequence'"); run_table_dump_query (p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0); } else { int i; for (i = 1; i < nArg; i++) { zShellStatic = azArg[i]; run_schema_dump_query (p, "SELECT name, type, sql FROM sqlite_master " "WHERE tbl_name LIKE shellstatic() AND type=='table'" " AND sql NOT NULL"); run_table_dump_query (p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL" " AND type IN ('index','trigger','view')" " AND tbl_name LIKE shellstatic()", 0); zShellStatic = 0; } } if (p->writableSchema) { fprintf (p->out, "PRAGMA writable_schema=OFF;\n"); p->writableSchema = 0; } sqlite3_exec (p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); sqlite3_exec (p->db, "RELEASE dump;", 0, 0, 0); fprintf (p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); } else if (c == 'e' && strncmp (azArg[0], "echo", n) == 0 && nArg > 1 && nArg < 3) { p->echoOn = booleanValue (azArg[1]); } else if (c == 'e' && strncmp (azArg[0], "exit", n) == 0 && nArg == 1) { rc = 2; } else if (c == 'e' && strncmp (azArg[0], "explain", n) == 0 && nArg < 3) { int val = nArg >= 2 ? booleanValue (azArg[1]) : 1; if (val == 1) { if (!p->explainPrev.valid) { p->explainPrev.valid = 1; p->explainPrev.mode = p->mode; p->explainPrev.showHeader = p->showHeader; memcpy (p->explainPrev.colWidth, p->colWidth, sizeof (p->colWidth)); } /* We could put this code under the !p->explainValid ** condition so that it does not execute if we are already in ** explain mode. However, always executing it allows us an easy ** was to reset to explain mode in case the user previously ** did an .explain followed by a .width, .mode or .header ** command. */ p->mode = MODE_Explain; p->showHeader = 1; memset (p->colWidth, 0, ArraySize (p->colWidth)); p->colWidth[0] = 4; /* addr */ p->colWidth[1] = 13; /* opcode */ p->colWidth[2] = 4; /* P1 */ p->colWidth[3] = 4; /* P2 */ p->colWidth[4] = 4; /* P3 */ p->colWidth[5] = 13; /* P4 */ p->colWidth[6] = 2; /* P5 */ p->colWidth[7] = 13; /* Comment */ } else if (p->explainPrev.valid) { p->explainPrev.valid = 0; p->mode = p->explainPrev.mode; p->showHeader = p->explainPrev.showHeader; memcpy (p->colWidth, p->explainPrev.colWidth, sizeof (p->colWidth)); } } else if (c == 'h' && (strncmp (azArg[0], "header", n) == 0 || strncmp (azArg[0], "headers", n) == 0) && nArg > 1 && nArg < 3) { p->showHeader = booleanValue (azArg[1]); } else if (c == 'h' && strncmp (azArg[0], "help", n) == 0) { fprintf (stderr, "%s", zHelp); if (HAS_TIMER) { fprintf (stderr, "%s", zTimerHelp); } } else if (c == 'i' && strncmp (azArg[0], "import", n) == 0 && nArg == 3) { char *zTable = azArg[2]; /* Insert data into this table */ char *zFile = azArg[1]; /* The file from which to extract data */ sqlite3_stmt *pStmt = NULL; /* A statement */ int nCol; /* Number of columns in the table */ int nByte; /* Number of bytes in an SQL string */ int i, j; /* Loop counters */ int nSep; /* Number of bytes in p->separator[] */ char *zSql; /* An SQL statement */ char *zLine; /* A single line of input from the file */ char **azCol; /* zLine[] broken up into columns */ char *zCommit; /* How to commit changes */ FILE *in; /* The input file */ int lineno = 0; /* Line number of input file */ open_db (p); nSep = strlen30 (p->separator); if (nSep == 0) { fprintf (stderr, "Error: non-null separator required for import\n"); return 1; } zSql = sqlite3_mprintf ("SELECT * FROM %s", zTable); if (zSql == 0) { fprintf (stderr, "Error: out of memory\n"); return 1; } nByte = strlen30 (zSql); rc = sqlite3_prepare (p->db, zSql, -1, &pStmt, 0); sqlite3_free (zSql); if (rc) { if (pStmt) sqlite3_finalize (pStmt); fprintf (stderr, "Error: %s\n", sqlite3_errmsg (db)); return 1; } nCol = sqlite3_column_count (pStmt); sqlite3_finalize (pStmt); pStmt = 0; if (nCol == 0) return 0; /* no columns, no error */ zSql = malloc (nByte + 20 + nCol * 2); if (zSql == 0) { fprintf (stderr, "Error: out of memory\n"); return 1; } sqlite3_snprintf (nByte + 20, zSql, "INSERT INTO %s VALUES(?", zTable); j = strlen30 (zSql); for (i = 1; i < nCol; i++) { zSql[j++] = ','; zSql[j++] = '?'; } zSql[j++] = ')'; zSql[j] = 0; rc = sqlite3_prepare (p->db, zSql, -1, &pStmt, 0); free (zSql); if (rc) { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (db)); if (pStmt) sqlite3_finalize (pStmt); return 1; } in = fopen (zFile, "rb"); if (in == 0) { fprintf (stderr, "Error: cannot open \"%s\"\n", zFile); sqlite3_finalize (pStmt); return 1; } azCol = malloc (sizeof (azCol[0]) * (nCol + 1)); if (azCol == 0) { fprintf (stderr, "Error: out of memory\n"); fclose (in); sqlite3_finalize (pStmt); return 1; } sqlite3_exec (p->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while ((zLine = local_getline (0, in, 1)) != 0) { char *z, c; int inQuote = 0; lineno++; azCol[0] = zLine; for (i = 0, z = zLine; (c = *z) != 0; z++) { if (c == '"') inQuote = !inQuote; if (c == '\n') lineno++; if (!inQuote && c == p->separator[0] && strncmp (z, p->separator, nSep) == 0) { *z = 0; i++; if (i < nCol) { azCol[i] = &z[nSep]; z += nSep - 1; } } } /* end for */ *z = 0; if (i + 1 != nCol) { fprintf (stderr, "Error: %s line %d: expected %d columns of data but found %d\n", zFile, lineno, nCol, i + 1); zCommit = "ROLLBACK"; free (zLine); rc = 1; break; /* from while */ } for (i = 0; i < nCol; i++) { if (azCol[i][0] == '"') { int k; for (z = azCol[i], j = 1, k = 0; z[j]; j++) { if (z[j] == '"') { j++; if (z[j] == 0) break; } z[k++] = z[j]; } z[k] = 0; } sqlite3_bind_text (pStmt, i + 1, azCol[i], -1, SQLITE_STATIC); } sqlite3_step (pStmt); rc = sqlite3_reset (pStmt); free (zLine); if (rc != SQLITE_OK) { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (db)); zCommit = "ROLLBACK"; rc = 1; break; /* from while */ } } /* end while */ free (azCol); fclose (in); sqlite3_finalize (pStmt); sqlite3_exec (p->db, zCommit, 0, 0, 0); } else if (c == 'i' && strncmp (azArg[0], "indices", n) == 0 && nArg < 3) { struct callback_data data; char *zErrMsg = 0; open_db (p); memcpy (&data, p, sizeof (data)); data.showHeader = 0; data.mode = MODE_List; if (nArg == 1) { rc = sqlite3_exec (p->db, "SELECT name FROM sqlite_master " "WHERE type='index' AND name NOT LIKE 'sqlite_%' " "UNION ALL " "SELECT name FROM sqlite_temp_master " "WHERE type='index' " "ORDER BY 1", callback, &data, &zErrMsg); } else { zShellStatic = azArg[1]; rc = sqlite3_exec (p->db, "SELECT name FROM sqlite_master " "WHERE type='index' AND tbl_name LIKE shellstatic() " "UNION ALL " "SELECT name FROM sqlite_temp_master " "WHERE type='index' AND tbl_name LIKE shellstatic() " "ORDER BY 1", callback, &data, &zErrMsg); zShellStatic = 0; } if (zErrMsg) { fprintf (stderr, "Error: %s\n", zErrMsg); sqlite3_free (zErrMsg); rc = 1; } else if (rc != SQLITE_OK) { fprintf (stderr, "Error: querying sqlite_master and sqlite_temp_master\n"); rc = 1; } } else #ifdef SQLITE_ENABLE_IOTRACE if (c == 'i' && strncmp (azArg[0], "iotrace", n) == 0) { extern void (*sqlite3IoTrace) (const char *, ...); if (iotrace && iotrace != stdout) fclose (iotrace); iotrace = 0; if (nArg < 2) { sqlite3IoTrace = 0; } else if (strcmp (azArg[1], "-") == 0) { sqlite3IoTrace = iotracePrintf; iotrace = stdout; } else { iotrace = fopen (azArg[1], "w"); if (iotrace == 0) { fprintf (stderr, "Error: cannot open \"%s\"\n", azArg[1]); sqlite3IoTrace = 0; rc = 1; } else { sqlite3IoTrace = iotracePrintf; } } } else #endif if (c == 'l' && strncmp (azArg[0], "log", n) == 0 && nArg >= 2) { const char *zFile = azArg[1]; output_file_close (p->pLog); p->pLog = output_file_open (zFile); } else if (c == 'm' && strncmp (azArg[0], "mode", n) == 0 && nArg == 2) { int n2 = strlen30 (azArg[1]); if ((n2 == 4 && strncmp (azArg[1], "line", n2) == 0) || (n2 == 5 && strncmp (azArg[1], "lines", n2) == 0)) { p->mode = MODE_Line; } else if ((n2 == 6 && strncmp (azArg[1], "column", n2) == 0) || (n2 == 7 && strncmp (azArg[1], "columns", n2) == 0)) { p->mode = MODE_Column; } else if (n2 == 4 && strncmp (azArg[1], "list", n2) == 0) { p->mode = MODE_List; } else if (n2 == 4 && strncmp (azArg[1], "html", n2) == 0) { p->mode = MODE_Html; } else if (n2 == 3 && strncmp (azArg[1], "tcl", n2) == 0) { p->mode = MODE_Tcl; } else if (n2 == 3 && strncmp (azArg[1], "csv", n2) == 0) { p->mode = MODE_Csv; sqlite3_snprintf (sizeof (p->separator), p->separator, ","); } else if (n2 == 4 && strncmp (azArg[1], "tabs", n2) == 0) { p->mode = MODE_List; sqlite3_snprintf (sizeof (p->separator), p->separator, "\t"); } else if (n2 == 6 && strncmp (azArg[1], "insert", n2) == 0) { p->mode = MODE_Insert; set_table_name (p, "table"); } else { fprintf (stderr, "Error: mode should be one of: " "column csv html insert line list tabs tcl\n"); rc = 1; } } else if (c == 'm' && strncmp (azArg[0], "mode", n) == 0 && nArg == 3) { int n2 = strlen30 (azArg[1]); if (n2 == 6 && strncmp (azArg[1], "insert", n2) == 0) { p->mode = MODE_Insert; set_table_name (p, azArg[2]); } else { fprintf (stderr, "Error: invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[2]); rc = 1; } } else if (c == 'n' && strncmp (azArg[0], "nullvalue", n) == 0 && nArg == 2) { sqlite3_snprintf (sizeof (p->nullvalue), p->nullvalue, "%.*s", (int) ArraySize (p->nullvalue) - 1, azArg[1]); } else if (c == 'o' && strncmp (azArg[0], "output", n) == 0 && nArg == 2) { if (p->outfile[0] == '|') { pclose (p->out); } else { output_file_close (p->out); } p->outfile[0] = 0; if (azArg[1][0] == '|') { p->out = popen (&azArg[1][1], "w"); if (p->out == 0) { fprintf (stderr, "Error: cannot open pipe \"%s\"\n", &azArg[1][1]); p->out = stdout; rc = 1; } else { sqlite3_snprintf (sizeof (p->outfile), p->outfile, "%s", azArg[1]); } } else { p->out = output_file_open (azArg[1]); if (p->out == 0) { if (strcmp (azArg[1], "off") != 0) { fprintf (stderr, "Error: cannot write to \"%s\"\n", azArg[1]); } p->out = stdout; rc = 1; } else { sqlite3_snprintf (sizeof (p->outfile), p->outfile, "%s", azArg[1]); } } } else if (c == 'p' && strncmp (azArg[0], "prompt", n) == 0 && (nArg == 2 || nArg == 3)) { if (nArg >= 2) { strncpy (mainPrompt, azArg[1], (int) ArraySize (mainPrompt) - 1); } if (nArg >= 3) { strncpy (continuePrompt, azArg[2], (int) ArraySize (continuePrompt) - 1); } } else if (c == 'q' && strncmp (azArg[0], "quit", n) == 0 && nArg == 1) { rc = 2; } else if (c == 'r' && n >= 3 && strncmp (azArg[0], "read", n) == 0 && nArg > 0) { FILE *alt = fopen (azArg[1], "rb"); if (alt == 0) { fprintf (stderr, "Error: cannot open \"%s\"\n", azArg[1]); rc = 1; } else { rc = process_input (p, alt, 0); fclose (alt); } } else if (c == 'r' && n >= 3 && strncmp (azArg[0], "restore", n) == 0 && nArg > 1 && nArg < 4) { const char *zSrcFile; const char *zDb; sqlite3 *pSrc; sqlite3_backup *pBackup; int nTimeout = 0; if (nArg == 2) { zSrcFile = azArg[1]; zDb = "main"; } else { zSrcFile = azArg[2]; zDb = azArg[1]; } rc = sqlite3_open (zSrcFile, &pSrc); if (rc != SQLITE_OK) { fprintf (stderr, "Error: cannot open \"%s\"\n", zSrcFile); sqlite3_close (pSrc); return 1; } open_db (p); pBackup = sqlite3_backup_init (p->db, zDb, pSrc, "main"); if (pBackup == 0) { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (p->db)); sqlite3_close (pSrc); return 1; } while ((rc = sqlite3_backup_step (pBackup, 100)) == SQLITE_OK || rc == SQLITE_BUSY) { if (rc == SQLITE_BUSY) { if (nTimeout++ >= 3) break; sqlite3_sleep (100); } } sqlite3_backup_finish (pBackup); if (rc == SQLITE_DONE) { rc = 0; } else if (rc == SQLITE_BUSY || rc == SQLITE_LOCKED) { fprintf (stderr, "Error: source database is busy\n"); rc = 1; } else { fprintf (stderr, "Error: %s\n", sqlite3_errmsg (p->db)); rc = 1; } sqlite3_close (pSrc); } else if (c == 's' && strncmp (azArg[0], "schema", n) == 0 && nArg < 3) { struct callback_data data; char *zErrMsg = 0; open_db (p); memcpy (&data, p, sizeof (data)); data.showHeader = 0; data.mode = MODE_Semi; if (nArg > 1) { int i; for (i = 0; azArg[1][i]; i++) azArg[1][i] = ToLower (azArg[1][i]); if (strcmp (azArg[1], "sqlite_master") == 0) { char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TABLE sqlite_master (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" " sql text\n" ")"; new_argv[1] = 0; new_colv[0] = "sql"; new_colv[1] = 0; callback (&data, 1, new_argv, new_colv); rc = SQLITE_OK; } else if (strcmp (azArg[1], "sqlite_temp_master") == 0) { char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TEMP TABLE sqlite_temp_master (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" " sql text\n" ")"; new_argv[1] = 0; new_colv[0] = "sql"; new_colv[1] = 0; callback (&data, 1, new_argv, new_colv); rc = SQLITE_OK; } else { zShellStatic = azArg[1]; rc = sqlite3_exec (p->db, "SELECT sql FROM " " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" " FROM sqlite_master UNION ALL" " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " "WHERE lower(tbl_name) LIKE shellstatic()" " AND type!='meta' AND sql NOTNULL " "ORDER BY substr(type,2,1), " " CASE type WHEN 'view' THEN rowid ELSE name END", callback, &data, &zErrMsg); zShellStatic = 0; } } else { rc = sqlite3_exec (p->db, "SELECT sql FROM " " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" " FROM sqlite_master UNION ALL" " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'" "ORDER BY substr(type,2,1)," " CASE type WHEN 'view' THEN rowid ELSE name END", callback, &data, &zErrMsg); } if (zErrMsg) { fprintf (stderr, "Error: %s\n", zErrMsg); sqlite3_free (zErrMsg); rc = 1; } else if (rc != SQLITE_OK) { fprintf (stderr, "Error: querying schema information\n"); rc = 1; } else { rc = 0; } } else if (c == 's' && strncmp (azArg[0], "separator", n) == 0 && nArg == 2) { sqlite3_snprintf (sizeof (p->separator), p->separator, "%.*s", (int) sizeof (p->separator) - 1, azArg[1]); } else if (c == 's' && (strncmp (azArg[0], "shell", n) == 0 || strncmp (azArg[0], "system", n) == 0)) { char *zCmd; int i; if (nArg < 2) { fprintf (stderr, "Usage: .system COMMAND\n"); rc = 1; } else { zCmd = sqlite3_mprintf (strchr (azArg[1], ' ') == 0 ? "%s" : "\"%s\"", azArg[1]); for (i = 2; i < nArg; i++) { zCmd = sqlite3_mprintf (strchr (azArg[i], ' ') == 0 ? "%z %s" : "%z \"%s\"", zCmd, azArg[i]); } (void) system (zCmd); sqlite3_free (zCmd); } } else if (c == 's' && strncmp (azArg[0], "show", n) == 0 && nArg == 1) { int i; fprintf (p->out, "%9.9s: %s\n", "echo", p->echoOn ? "on" : "off"); fprintf (p->out, "%9.9s: %s\n", "explain", p->explainPrev.valid ? "on" : "off"); fprintf (p->out, "%9.9s: %s\n", "headers", p->showHeader ? "on" : "off"); fprintf (p->out, "%9.9s: %s\n", "mode", modeDescr[p->mode]); fprintf (p->out, "%9.9s: ", "nullvalue"); output_c_string (p->out, p->nullvalue); fprintf (p->out, "\n"); fprintf (p->out, "%9.9s: %s\n", "output", strlen30 (p->outfile) ? p->outfile : "stdout"); fprintf (p->out, "%9.9s: ", "separator"); output_c_string (p->out, p->separator); fprintf (p->out, "\n"); fprintf (p->out, "%9.9s: %s\n", "stats", p->statsOn ? "on" : "off"); fprintf (p->out, "%9.9s: ", "width"); for (i = 0; i < (int) ArraySize (p->colWidth) && p->colWidth[i] != 0; i++) { fprintf (p->out, "%d ", p->colWidth[i]); } fprintf (p->out, "\n"); } else if (c == 's' && strncmp (azArg[0], "stats", n) == 0 && nArg > 1 && nArg < 3) { p->statsOn = booleanValue (azArg[1]); } else if (c == 't' && n > 1 && strncmp (azArg[0], "tables", n) == 0 && nArg < 3) { sqlite3_stmt *pStmt; char **azResult; int nRow, nAlloc; char *zSql = 0; int ii; open_db (p); rc = sqlite3_prepare_v2 (p->db, "PRAGMA database_list", -1, &pStmt, 0); if (rc) return rc; zSql = sqlite3_mprintf ("SELECT name FROM sqlite_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1"); while (sqlite3_step (pStmt) == SQLITE_ROW) { const char *zDbName = (const char *) sqlite3_column_text (pStmt, 1); if (zDbName == 0 || strcmp (zDbName, "main") == 0) continue; if (strcmp (zDbName, "temp") == 0) { zSql = sqlite3_mprintf ("%z UNION ALL " "SELECT 'temp.' || name FROM sqlite_temp_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1", zSql); } else { zSql = sqlite3_mprintf ("%z UNION ALL " "SELECT '%q.' || name FROM \"%w\".sqlite_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1", zSql, zDbName, zDbName); } } sqlite3_finalize (pStmt); zSql = sqlite3_mprintf ("%z ORDER BY 1", zSql); rc = sqlite3_prepare_v2 (p->db, zSql, -1, &pStmt, 0); sqlite3_free (zSql); if (rc) return rc; nRow = nAlloc = 0; azResult = 0; if (nArg > 1) { sqlite3_bind_text (pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT); } else { sqlite3_bind_text (pStmt, 1, "%", -1, SQLITE_STATIC); } while (sqlite3_step (pStmt) == SQLITE_ROW) { if (nRow >= nAlloc) { char **azNew; int n = nAlloc * 2 + 10; azNew = sqlite3_realloc (azResult, sizeof (azResult[0]) * n); if (azNew == 0) { fprintf (stderr, "Error: out of memory\n"); break; } nAlloc = n; azResult = azNew; } azResult[nRow] = sqlite3_mprintf ("%s", sqlite3_column_text (pStmt, 0)); if (azResult[nRow]) nRow++; } sqlite3_finalize (pStmt); if (nRow > 0) { int len, maxlen = 0; int i, j; int nPrintCol, nPrintRow; for (i = 0; i < nRow; i++) { len = strlen30 (azResult[i]); if (len > maxlen) maxlen = len; } nPrintCol = 80 / (maxlen + 2); if (nPrintCol < 1) nPrintCol = 1; nPrintRow = (nRow + nPrintCol - 1) / nPrintCol; for (i = 0; i < nPrintRow; i++) { for (j = i; j < nRow; j += nPrintRow) { char *zSp = j < nPrintRow ? "" : " "; printf ("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : ""); } printf ("\n"); } } for (ii = 0; ii < nRow; ii++) sqlite3_free (azResult[ii]); sqlite3_free (azResult); } else if (c == 't' && n >= 8 && strncmp (azArg[0], "testctrl", n) == 0 && nArg >= 2) { static const struct { const char *zCtrlName; /* Name of a test-control option */ int ctrlCode; /* Integer code for that option */ } aCtrl[] = { { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE}, { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE}, { "prng_reset", SQLITE_TESTCTRL_PRNG_RESET}, { "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST}, { "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL}, { "benign_malloc_hooks", SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS}, { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE}, { "assert", SQLITE_TESTCTRL_ASSERT}, { "always", SQLITE_TESTCTRL_ALWAYS}, { "reserve", SQLITE_TESTCTRL_RESERVE}, { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS}, { "iskeyword", SQLITE_TESTCTRL_ISKEYWORD}, { "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC},}; int testctrl = -1; int rc = 0; int i, n; open_db (p); /* convert testctrl text option to value. allow any unique prefix ** of the option name, or a numerical value. */ n = strlen30 (azArg[1]); for (i = 0; i < (int) (sizeof (aCtrl) / sizeof (aCtrl[0])); i++) { if (strncmp (azArg[1], aCtrl[i].zCtrlName, n) == 0) { if (testctrl < 0) { testctrl = aCtrl[i].ctrlCode; } else { fprintf (stderr, "ambiguous option name: \"%s\"\n", azArg[1]); testctrl = -1; break; } } } if (testctrl < 0) testctrl = atoi (azArg[1]); if ((testctrl < SQLITE_TESTCTRL_FIRST) || (testctrl > SQLITE_TESTCTRL_LAST)) { fprintf (stderr, "Error: invalid testctrl option: %s\n", azArg[1]); } else { switch (testctrl) { /* sqlite3_test_control(int, db, int) */ case SQLITE_TESTCTRL_OPTIMIZATIONS: case SQLITE_TESTCTRL_RESERVE: if (nArg == 3) { int opt = (int) strtol (azArg[2], 0, 0); rc = sqlite3_test_control (testctrl, p->db, opt); printf ("%d (0x%08x)\n", rc, rc); } else { fprintf (stderr, "Error: testctrl %s takes a single int option\n", azArg[1]); } break; /* sqlite3_test_control(int) */ case SQLITE_TESTCTRL_PRNG_SAVE: case SQLITE_TESTCTRL_PRNG_RESTORE: case SQLITE_TESTCTRL_PRNG_RESET: if (nArg == 2) { rc = sqlite3_test_control (testctrl); printf ("%d (0x%08x)\n", rc, rc); } else { fprintf (stderr, "Error: testctrl %s takes no options\n", azArg[1]); } break; /* sqlite3_test_control(int, uint) */ case SQLITE_TESTCTRL_PENDING_BYTE: if (nArg == 3) { unsigned int opt = (unsigned int) atoi (azArg[2]); rc = sqlite3_test_control (testctrl, opt); printf ("%d (0x%08x)\n", rc, rc); } else { fprintf (stderr, "Error: testctrl %s takes a single unsigned" " int option\n", azArg[1]); } break; /* sqlite3_test_control(int, int) */ case SQLITE_TESTCTRL_ASSERT: case SQLITE_TESTCTRL_ALWAYS: if (nArg == 3) { int opt = atoi (azArg[2]); rc = sqlite3_test_control (testctrl, opt); printf ("%d (0x%08x)\n", rc, rc); } else { fprintf (stderr, "Error: testctrl %s takes a single int option\n", azArg[1]); } break; /* sqlite3_test_control(int, char *) */ #ifdef SQLITE_N_KEYWORD case SQLITE_TESTCTRL_ISKEYWORD: if (nArg == 3) { const char *opt = azArg[2]; rc = sqlite3_test_control (testctrl, opt); printf ("%d (0x%08x)\n", rc, rc); } else { fprintf (stderr, "Error: testctrl %s takes a single char * option\n", azArg[1]); } break; #endif case SQLITE_TESTCTRL_BITVEC_TEST: case SQLITE_TESTCTRL_FAULT_INSTALL: case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: case SQLITE_TESTCTRL_SCRATCHMALLOC: default: fprintf (stderr, "Error: CLI support for testctrl %s not implemented\n", azArg[1]); break; } } } else if (c == 't' && n > 4 && strncmp (azArg[0], "timeout", n) == 0 && nArg == 2) { open_db (p); sqlite3_busy_timeout (p->db, atoi (azArg[1])); } else if (HAS_TIMER && c == 't' && n >= 5 && strncmp (azArg[0], "timer", n) == 0 && nArg == 2) { enableTimer = booleanValue (azArg[1]); } else if (c == 't' && strncmp (azArg[0], "trace", n) == 0 && nArg > 1) { open_db (p); output_file_close (p->traceOut); p->traceOut = output_file_open (azArg[1]); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if (p->traceOut == 0) { sqlite3_trace (p->db, 0, 0); } else { sqlite3_trace (p->db, sql_trace_callback, p->traceOut); } #endif } else if (c == 'v' && strncmp (azArg[0], "version", n) == 0) { printf ("SQLite %s %s\n" /*extra-version-info */ , sqlite3_libversion (), sqlite3_sourceid ()); } else if (c == 'v' && strncmp (azArg[0], "vfsname", n) == 0) { const char *zDbName = nArg == 2 ? azArg[1] : "main"; char *zVfsName = 0; if (p->db) { /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_FCNTL_VFSNAME sqlite3_file_control (p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName); if (zVfsName) { printf ("%s\n", zVfsName); sqlite3_free (zVfsName); } #else printf ("FCNTL_VFSNAME: unsupported\n"); #endif /* end sandro 1 November 2012 */ } } else if (c == 'w' && strncmp (azArg[0], "width", n) == 0 && nArg > 1) { int j; assert (nArg <= ArraySize (azArg)); for (j = 1; j < nArg && j < ArraySize (p->colWidth); j++) { p->colWidth[j - 1] = atoi (azArg[j]); } } else { fprintf (stderr, "Error: unknown command or invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[0]); rc = 1; } return rc; } /* ** Return TRUE if a semicolon occurs anywhere in the first N characters ** of string z[]. */ static int _contains_semicolon (const char *z, int N) { int i; for (i = 0; i < N; i++) { if (z[i] == ';') return 1; } return 0; } /* ** Test to see if a line consists entirely of whitespace. */ static int _all_whitespace (const char *z) { for (; *z; z++) { if (IsSpace (z[0])) continue; if (*z == '/' && z[1] == '*') { z += 2; while (*z && (*z != '*' || z[1] != '/')) { z++; } if (*z == 0) return 0; z++; continue; } if (*z == '-' && z[1] == '-') { z += 2; while (*z && *z != '\n') { z++; } if (*z == 0) return 1; continue; } return 0; } return 1; } /* ** Return TRUE if the line typed in is an SQL command terminator other ** than a semi-colon. The SQL Server style "go" command is understood ** as is the Oracle "/". */ static int _is_command_terminator (const char *zLine) { while (IsSpace (zLine[0])) { zLine++; }; if (zLine[0] == '/' && _all_whitespace (&zLine[1])) { return 1; /* Oracle */ } if (ToLower (zLine[0]) == 'g' && ToLower (zLine[1]) == 'o' && _all_whitespace (&zLine[2])) { return 1; /* SQL Server */ } return 0; } /* ** Return true if zSql is a complete SQL statement. Return false if it ** ends in the middle of a string literal or C-style comment. */ static int _is_complete (char *zSql, int nSql) { int rc; if (zSql == 0) return 1; zSql[nSql] = ';'; zSql[nSql + 1] = 0; rc = sqlite3_complete (zSql); zSql[nSql] = 0; return rc; } /* ** Read input from *in and process it. If *in==0 then input ** is interactive - the user is typing it it. Otherwise, input ** is coming from a file or device. A prompt is issued and history ** is saved only if input is interactive. An interrupt signal will ** cause this routine to exit immediately, unless input is interactive. ** ** Return the number of errors. */ static int process_input (struct callback_data *p, FILE * in, char *in_charset) { char *zLine = 0; char *zSql = 0; /* Sandro Furieri - 11 July 2008 - supporting UNICODE */ int utf8len; char *utf8Sql = 0; /* End Sandro Furieri - 11 July 2008 */ /* Sandro Furieri - 3 September 2012 - supporting SqlLog */ sqlite3_int64 sqllog_pk; /* End Sandro Furieri - 3 September 2012 - supporting SqlLog */ int nSql = 0; int nSqlPrior = 0; char *zErrMsg; int rc; int errCnt = 0; int lineno = 0; int startline = 0; /* Sandro Furieri - 11 July 2008 - supporting UNICODE */ if (in_charset) create_input_utf8_converter (in_charset); /* End Sandro Furieri - 11 July 2008 */ while (errCnt == 0 || !bail_on_error || (in == 0 && stdin_is_interactive)) { fflush (stderr); fflush (p->out); free (zLine); zLine = one_input_line (zSql, in); if (zLine == 0) { /* End of input */ if (stdin_is_interactive) printf ("\n"); break; } if (seenInterrupt) { if (in != 0) break; seenInterrupt = 0; } lineno++; if ((zSql == 0 || zSql[0] == 0) && _all_whitespace (zLine)) continue; if (zLine && zLine[0] == '.' && nSql == 0) { if (p->echoOn) printf ("%s\n", zLine); rc = do_meta_command (zLine, p); if (rc == 2) { /* exit requested */ break; } else if (rc) { errCnt++; } continue; } if (_is_command_terminator (zLine) && _is_complete (zSql, nSql)) { memcpy (zLine, ";", 2); } nSqlPrior = nSql; if (zSql == 0) { int i; for (i = 0; zLine[i] && IsSpace (zLine[i]); i++) { } if (zLine[i] != 0) { nSql = strlen30 (zLine); zSql = malloc (nSql + 3); if (zSql == 0) { fprintf (stderr, "Error: out of memory\n"); exit (1); } memcpy (zSql, zLine, nSql + 1); startline = lineno; } } else { int len = strlen30 (zLine); zSql = realloc (zSql, nSql + len + 4); if (zSql == 0) { fprintf (stderr, "Error: out of memory\n"); exit (1); } zSql[nSql++] = '\n'; memcpy (&zSql[nSql], zLine, len + 1); nSql += len; } if (zSql && _contains_semicolon (&zSql[nSqlPrior], nSql - nSqlPrior) && sqlite3_complete (zSql)) { p->cnt = 0; open_db (p); /* Sandro Furieri - 11 July 2008 BEGIN_TIMER; rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg); END_TIMER; */ utf8len = strlen (zSql) * 4; utf8Sql = malloc (utf8len); if (utf8Sql == 0) { fprintf (stderr, "%s: out of memory!\n", Argv0); exit (1); } strncpy (utf8Sql, zSql, utf8len - 1); utf8Sql[utf8len - 1] = '\0'; if (!in_charset) { /* assuming input is locale_charset encoded */ convert_to_utf8 (utf8Sql, utf8len); } else { /* input has an explicit charset */ convert_input_to_utf8 (utf8Sql, utf8len); } if (sql_log_enabled) gaiaInsertIntoSqlLog (p->db, "spatialite CLI", utf8Sql, &sqllog_pk); BEGIN_TIMER; rc = sqlite3_exec (p->db, utf8Sql, callback, p, &zErrMsg); END_TIMER; if (sql_log_enabled) gaiaUpdateSqlLog (p->db, sqllog_pk, (rc == SQLITE_OK) ? 1 : 0, zErrMsg); free (utf8Sql); /* End Sandro Furieri - 11 July 2008 */ if (rc || zErrMsg) { char zPrefix[100]; if (in != 0 || !stdin_is_interactive) { sqlite3_snprintf (sizeof (zPrefix), zPrefix, "Error: near line %d:", startline); } else { sqlite3_snprintf (sizeof (zPrefix), zPrefix, "Error:"); } if (zErrMsg != 0) { fprintf (stderr, "%s %s\n", zPrefix, zErrMsg); sqlite3_free (zErrMsg); zErrMsg = 0; } else { fprintf (stderr, "%s %s\n", zPrefix, sqlite3_errmsg (p->db)); } errCnt++; } free (zSql); zSql = 0; nSql = 0; } } if (zSql) { if (!_all_whitespace (zSql)) { fprintf (stderr, "Error: incomplete SQL: %s\n", zSql); } free (zSql); } free (zLine); /* Sandro Furieri - 11 July 2008 */ if (in_charset_to_utf8) { /* destroying input converter, if exists */ iconv_close (in_charset_to_utf8); in_charset_to_utf8 = NULL; } /* End Sandro Furieri - 11 July 2008 */ return errCnt; } /* ** Return a pathname which is the user's home directory. A ** 0 return indicates an error of some kind. */ static char * find_home_dir (void) { static char *home_dir = NULL; if (home_dir) return home_dir; #if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL) { struct passwd *pwent; uid_t uid = getuid (); if ((pwent = getpwuid (uid)) != NULL) { home_dir = pwent->pw_dir; } } #endif #if defined(_WIN32_WCE) /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv() */ home_dir = "/"; #else #if defined(_WIN32) || defined(WIN32) if (!home_dir) { home_dir = getenv ("USERPROFILE"); } #endif if (!home_dir) { home_dir = getenv ("HOME"); } #if defined(_WIN32) || defined(WIN32) if (!home_dir) { char *zDrive, *zPath; int n; zDrive = getenv ("HOMEDRIVE"); zPath = getenv ("HOMEPATH"); if (zDrive && zPath) { n = strlen30 (zDrive) + strlen30 (zPath) + 1; home_dir = malloc (n); if (home_dir == 0) return 0; sqlite3_snprintf (n, home_dir, "%s%s", zDrive, zPath); return home_dir; } home_dir = "c:\\"; } #endif #endif /* !_WIN32_WCE */ if (home_dir) { int n = strlen30 (home_dir) + 1; char *z = malloc (n); if (z) memcpy (z, home_dir, n); home_dir = z; } return home_dir; } /* ** Read input from the file given by sqliterc_override. Or if that ** parameter is NULL, take input from ~/.sqliterc ** ** Returns the number of errors. */ static int process_sqliterc (struct callback_data *p, /* Configuration data */ const char *sqliterc_override /* Name of config file. NULL to use default */ ) { char *home_dir = NULL; const char *sqliterc = sqliterc_override; char *zBuf = 0; FILE *in = NULL; int rc = 0; if (sqliterc == NULL) { home_dir = find_home_dir (); if (home_dir == 0) { #if !defined(__RTP__) && !defined(_WRS_KERNEL) fprintf (stderr, "%s: Error: cannot locate your home directory\n", Argv0); #endif return 1; } sqlite3_initialize (); zBuf = sqlite3_mprintf ("%s/.sqliterc", home_dir); sqliterc = zBuf; } in = fopen (sqliterc, "rb"); if (in) { if (stdin_is_interactive) { fprintf (stderr, "-- Loading resources from %s\n", sqliterc); } rc = process_input (p, in, 0); fclose (in); } sqlite3_free (zBuf); return rc; } /* ** Show available command line options */ static const char zOptions[] = " -bail stop after hitting an error\n" " -batch force batch I/O\n" " -column set output mode to 'column'\n" " -cmd command run \"command\" before reading stdin\n" " -csv set output mode to 'csv'\n" " -echo print commands before execution\n" " -init filename read/process named file\n" " -[no]header turn headers on or off\n" " -help show this message\n" " -html set output mode to HTML\n" " -interactive force interactive I/O\n" " -line set output mode to 'line'\n" " -list set output mode to 'list'\n" " -silent suppress the welcome message\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -nullvalue 'text' set text string for NULL values\n" " -separator 'x' set output field separator (|)\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif ; static void usage (int showDetail) { fprintf (stderr, "Usage: %s [OPTIONS] FILENAME [SQL]\n" "FILENAME is the name of an SQLite database. A new database is created\n" "if the file does not previously exist.\n", Argv0); if (showDetail) { fprintf (stderr, "OPTIONS include:\n%s", zOptions); } else { fprintf (stderr, "Use the -help option for additional information\n"); } exit (1); } /* ** Initialize the state information in data */ static void main_init (struct callback_data *data) { memset (data, 0, sizeof (*data)); data->mode = MODE_List; memcpy (data->separator, "|", 2); data->showHeader = 0; /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_CONFIG_URI sqlite3_config (SQLITE_CONFIG_URI, 1); #endif /* end sandro 1 November 2012 */ sqlite3_config (SQLITE_CONFIG_LOG, shellLog, data); sqlite3_snprintf (sizeof (mainPrompt), mainPrompt, "spatialite> "); sqlite3_snprintf (sizeof (continuePrompt), continuePrompt, " ...> "); sqlite3_config (SQLITE_CONFIG_SINGLETHREAD); } int main (int argc, char **argv) { char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; char *zFirstCmd = 0; int i; int rc = 0; /* initializing the SpatiaLite's internal cache */ splite_cache = spatialite_alloc_connection (); /* * sandro: 2015-06-26 * * disabling version check as suggested by Fedora and Debian maintainers * if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } */ Argv0 = argv[0]; main_init (&data); /* Sandro Furieri 30 May 2008 =========================== registering the SpatiaLite extension 2013-08-30: supporting "silent mode" */ for (i = 1; i < argc && argv[i][0] == '-'; i++) { char *z = argv[i]; if (z[1] == '-') { z++; } if (strcmp (z, "-silent") == 0) { splite_silent = 1; } } stdin_is_interactive = isatty (0); /* Make sure we have a valid signal handler early, before anything ** else is done. */ #ifdef SIGINT signal (SIGINT, interrupt_handler); #endif /* Do an initial pass through the command-line argument to locate ** the name of the database file, the name of the initialization file, ** the size of the alternative malloc heap, ** and the first command to execute. */ for (i = 1; i < argc - 1; i++) { char *z; if (argv[i][0] != '-') break; z = argv[i]; if (z[1] == '-') z++; if (strcmp (z, "-separator") == 0 || strcmp (z, "-nullvalue") == 0 || strcmp (z, "-cmd") == 0) { i++; } else if (strcmp (z, "-init") == 0) { i++; zInitFile = argv[i]; /* Need to check for batch mode here to so we can avoid printing ** informational messages (like from process_sqliterc) before ** we do the actual processing of arguments later in a second pass. */ } else if (strcmp (z, "-batch") == 0) { stdin_is_interactive = 0; } else if (strcmp (z, "-heap") == 0) { #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) int j, c; const char *zSize; sqlite3_int64 szHeap; zSize = argv[++i]; szHeap = atoi (zSize); for (j = 0; (c = zSize[j]) != 0; j++) { if (c == 'M') { szHeap *= 1000000; break; } if (c == 'K') { szHeap *= 1000; break; } if (c == 'G') { szHeap *= 1000000000; break; } } if (szHeap > 0x7fff0000) szHeap = 0x7fff0000; sqlite3_config (SQLITE_CONFIG_HEAP, malloc ((int) szHeap), (int) szHeap, 64); #endif #ifdef SQLITE_ENABLE_VFSTRACE } else if (strcmp (z, "-vfstrace") == 0) { extern int vfstrace_register (const char *zTraceName, const char *zOldVfsName, int (*xOut) (const char *, void *), void *pOutArg, int makeDefault); vfstrace_register ("trace", 0, (int (*)(const char *, void *)) fputs, stderr, 1); #endif #ifdef SQLITE_ENABLE_MULTIPLEX } else if (strcmp (z, "-multiplex") == 0) { extern int sqlite3_multiple_initialize (const char *, int); sqlite3_multiplex_initialize (0, 1); #endif } else if (strcmp (z, "-vfs") == 0) { sqlite3_vfs *pVfs = sqlite3_vfs_find (argv[++i]); if (pVfs) { sqlite3_vfs_register (pVfs, 1); } else { fprintf (stderr, "no such VFS: \"%s\"\n", argv[i]); exit (1); } } } if (i < argc) { data.zDbFilename = argv[i++]; } else { #ifndef SQLITE_OMIT_MEMORYDB data.zDbFilename = ":memory:"; #else data.zDbFilename = 0; #endif } if (i < argc) { zFirstCmd = argv[i++]; } if (i < argc) { fprintf (stderr, "%s: Error: too many options: \"%s\"\n", Argv0, argv[i]); fprintf (stderr, "Use -help for a list of options.\n"); return 1; } data.out = stdout; #ifdef SQLITE_OMIT_MEMORYDB if (data.zDbFilename == 0) { fprintf (stderr, "%s: Error: no database filename specified\n", Argv0); return 1; } #endif /* Go ahead and open the database file if it already exists. If the ** file does not exist, delay opening it. This prevents empty database ** files from being created if a user mistypes the database name argument ** to the sqlite command-line tool. */ if (access (data.zDbFilename, 0) == 0) { open_db (&data); } /* Process the initialization file if there is one. If no -init option ** is given on the command line, look for a file named ~/.sqliterc and ** try to process it. */ rc = process_sqliterc (&data, zInitFile); if (rc > 0) { return rc; } /* Make a second pass through the command-line argument and set ** options. This second pass is delayed until after the initialization ** file is processed so that the command-line arguments will override ** settings in the initialization file. */ for (i = 1; i < argc && argv[i][0] == '-'; i++) { char *z = argv[i]; if (z[1] == '-') { z++; } if (strcmp (z, "-init") == 0) { i++; } else if (strcmp (z, "-html") == 0) { data.mode = MODE_Html; } else if (strcmp (z, "-list") == 0) { data.mode = MODE_List; } else if (strcmp (z, "-line") == 0) { data.mode = MODE_Line; } else if (strcmp (z, "-column") == 0) { data.mode = MODE_Column; } else if (strcmp (z, "-csv") == 0) { data.mode = MODE_Csv; memcpy (data.separator, ",", 2); } else if (strcmp (z, "-separator") == 0) { i++; if (i >= argc) { fprintf (stderr, "%s: Error: missing argument for option: %s\n", Argv0, z); fprintf (stderr, "Use -help for a list of options.\n"); return 1; } sqlite3_snprintf (sizeof (data.separator), data.separator, "%.*s", (int) sizeof (data.separator) - 1, argv[i]); } else if (strcmp (z, "-nullvalue") == 0) { i++; if (i >= argc) { fprintf (stderr, "%s: Error: missing argument for option: %s\n", Argv0, z); fprintf (stderr, "Use -help for a list of options.\n"); return 1; } sqlite3_snprintf (sizeof (data.nullvalue), data.nullvalue, "%.*s", (int) sizeof (data.nullvalue) - 1, argv[i]); } else if (strcmp (z, "-header") == 0) { data.showHeader = 1; } else if (strcmp (z, "-noheader") == 0) { data.showHeader = 0; } else if (strcmp (z, "-echo") == 0) { data.echoOn = 1; } else if (strcmp (z, "-stats") == 0) { data.statsOn = 1; } else if (strcmp (z, "-bail") == 0) { bail_on_error = 1; } else if (strcmp (z, "-silent") == 0) { /* sandro 2013-08-30 */ splite_silent = 1; /* end sandro */ } else if (strcmp (z, "-version") == 0) { printf ("%s %s\n", sqlite3_libversion (), sqlite3_sourceid ()); return 0; } else if (strcmp (z, "-interactive") == 0) { stdin_is_interactive = 1; } else if (strcmp (z, "-batch") == 0) { stdin_is_interactive = 0; } else if (strcmp (z, "-heap") == 0) { i++; } else if (strcmp (z, "-vfs") == 0) { i++; #ifdef SQLITE_ENABLE_VFSTRACE } else if (strcmp (z, "-vfstrace") == 0) { i++; #endif #ifdef SQLITE_ENABLE_MULTIPLEX } else if (strcmp (z, "-multiplex") == 0) { i++; #endif } else if (strcmp (z, "-help") == 0) { usage (1); } else if (strcmp (z, "-cmd") == 0) { if (i == argc - 1) break; i++; z = argv[i]; if (z[0] == '.') { rc = do_meta_command (z, &data); if (rc && bail_on_error) return rc; } else { open_db (&data); rc = shell_exec (data.db, z, shell_callback, &data, &zErrMsg); if (zErrMsg != 0) { fprintf (stderr, "Error: %s\n", zErrMsg); if (bail_on_error) return rc != 0 ? rc : 1; } else if (rc != 0) { fprintf (stderr, "Error: unable to process SQL \"%s\"\n", z); if (bail_on_error) return rc; } } } else { fprintf (stderr, "%s: Error: unknown option: %s\n", Argv0, z); fprintf (stderr, "Use -help for a list of options.\n"); return 1; } } if (zFirstCmd) { /* Run just the command that follows the database name */ if (zFirstCmd[0] == '.') { rc = do_meta_command (zFirstCmd, &data); } else { open_db (&data); rc = shell_exec (data.db, zFirstCmd, shell_callback, &data, &zErrMsg); if (zErrMsg != 0) { fprintf (stderr, "Error: %s\n", zErrMsg); return rc != 0 ? rc : 1; } else if (rc != 0) { fprintf (stderr, "Error: unable to process SQL \"%s\"\n", zFirstCmd); return rc; } } } else { /* Run commands received from standard input */ if (stdin_is_interactive) { char *zHome; char *zHistory = 0; int nHistory; /* Sandro Furieri 2008-11-20 printf( "SQLite version %s %.19s\n" "Enter \".help\" for instructions\n" "Enter SQL statements terminated with a \";\"\n", sqlite3_libversion(), sqlite3_sourceid() ); */ open_db (&data); if (isatty (1)) printf ("SQLite version ......: %s\n", sqlite3_libversion ()); auto_fdo_start (data.db); if (isatty (1)) printf ("Enter \".help\" for instructions\n"); /* end Sandro Furieri 2008-11-20 */ printf ("SQLite version %s %.19s\n" /*extra-version-info */ "Enter \".help\" for instructions\n" "Enter SQL statements terminated with a \";\"\n", sqlite3_libversion (), sqlite3_sourceid ()); zHome = find_home_dir (); if (zHome) { nHistory = strlen30 (zHome) + 20; if ((zHistory = malloc (nHistory)) != 0) { sqlite3_snprintf (nHistory, zHistory, "%s/.sqlite_history", zHome); } } #if defined(HAVE_READLINE) && HAVE_READLINE==1 if (zHistory) read_history (zHistory); #endif rc = process_input (&data, 0, 0); if (zHistory) { stifle_history (100); write_history (zHistory); free (zHistory); } } else { rc = process_input (&data, stdin, 0); } } set_table_name (&data, 0); if (data.db) { /* Sandro Furieri 2008-11-20 */ auto_fdo_stop (data.db); /* end Sandro Furieri 2008-11-20 */ /* Sandro Furieri 2015-09-14 */ spatialite_finalize_topologies (splite_cache); /* end Sandro Furieri 2015-09-14 */ if (sqlite3_close (data.db) != SQLITE_OK) { fprintf (stderr, "error closing database: %s\n", sqlite3_errmsg (data.db)); } } /* Sandro Furieri 30 May 2008 =========================== memory cleanup for SpatiaLite extension */ spatialite_cleanup_ex (splite_cache); spatialite_shutdown (); return rc; } |
| | | | | | | | | | | | | | | | | < < | < | | < | < | | | < < | < | | | | | | | < | < < | < | < | < | | | | | | < | | < < | < | < | | | | | | | | < < | < | | < | | < < | | | | < < | < | | < | | | | | | | < | < | | < | | | | | | < | < < | | | | | | | | | | | | | | | | | | | | | | < < | < < < > | < | | | < | < < > > | < < < < < | < < < < < > | | < < > | < < < > | < < < < < > | | | | | < > | > > | | | | < | < | | | | | < | | | | | < | | | < < < > | | < | | | < < < > | | | | | | | < < | | | | < | < < > | | | | | | < | < | | < < > | | | < | < | < | | | | < | | < | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | < | < < | < | < | < | < | | | < | < | | | < < < < > | < | < | | | < < | | | < < < > | < | | < | < < < < > | | < < < < > > | < | < < > | | | | | < < < > | | | < < < > | | < | < | | < | < | | < | < | | < < < > | < | < | | | | < < < > | | < < > | | < < > > > > > > | < < < < < < < < < < > > > | < < < < < < < > > > | < < < > | < | < | | | | | | | | | | | | | | | | | | | | < | < | < < > | < | < | | | < | | | < | | | | < < > | | < < < > | | | < | < | | | | < | | < | < | | < | < | < | | | < | < | < | | < | < | | < < > | < | | | | | | | | | | | | | | | | | | | | | < | < | < | | < | < | < | | < < > | < | < | < < | | | < | | | < < < > | | | < | < | | < | < | < | | < | | < > | | | < | | < | | < | < | < | | | | < | | | | | | | | | | | | | | | | | | | < > | < | | | | | < | < | < < | | | < | | < | | | | | | | | | | | | | | | | | < < > | < < < > | < | < | | | | | | < | < < > | < < > | | | | | < | < > | < < > | | | | | | | | | | | | | | | | | | | | | < | < | < | | | | | < | | < | | | | | | | | | | | | | | | | | | | | | < | < | < | < | | | < | | < | | | | | | | < | < | | | < | | < < < > | < < < > | | | | | | | | | | | | | | < < < < < > | < | < | | < < > | < | < | < | < < < > | | | < > | | | | < | < | | < | < | | | | < | | | < | < > | < | < | < < > | | | < | < < > | | | | < | | < | < | | < | | < | < | | | | | | < | | < | < | | | | < | | | < | | | < | < | | | | < < > | < | | | | | | | | | < | | | | | | | < | < | | | | | | < | < | | | < > | | < | | < | < < > | < | < | < | | | | | | < | < | | | | | | < < > | | < | | | | | | | | < | | | | < | | < | < | | < | < | | < < | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | < > > | | | | < | | | | < | | | | | < | | | < < > | < | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | < | < | | | < | < < < > | | | | < | | | < < > | | | | | < | | < | < | | < < < < > > | < < > | < | < | < | < | < < < > | < < > | | < < > | | | | | | | | | | < < | | | < | | < < > | < < < > | | | | | < < < < | < | < < > | < | < | < | < | < | < | < < > | | | | < | < | < | < | < | | < | < | | | | | | | | < < < < < < > | | < | | | < < < | < | | < | < | < | | < < < < | | | | | | < | | | < < > | | | | | | | < | | | | < | | < | < | < < < < < < < < < < < < | | | < < < < < < < < < < < < < < | < | < < | | < < < < < < | | < < | < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < | | < > | | | < | | | < < | < < < < < < < < < < < < < < < < < < < | < | | | | | | | | | | | | | | | | < | | < | | | | | < | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | < < < < | < | | | | | | | | | | | | | < | < | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < > | < | < | < < | | < | < < < < < > | | | | | < | < < < < < > | | | | | | < | < < < < < > | < | | < > | < | | | < | < | < | | | | | | < | < | | | | | | | | | | | | | | < < < > | | | < < > | | < | | | < < | | | | < < > | < < | | < | | < | < | | | | < < < > > | | < < > | | < < | < | | < < > | | | | | | < | < | | < < > | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | < | | | | < | | | < | | < | | < < | < < < > | | < | | | < | < | < | | | | | | | | | < | < | | | | | | | | | | | | | < < | < | | | | < < > | | | | | | | < | | | < | | | < | | | | | < | | < | | | | | | | < | | < | | | | | | | | < | | | | | | < | | < < | < | | | | | | | < < > | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | < | | | | | < | < | < | | | < | < | | | | | | | | | < | < | | | | | | | | < < < < < < < | | | < | < < < < < < > | | | < | | | | | | | | | | < < > | | < | < < > | < < > > > | < < < > | | | | | | < < < > | < < < > | | | | | | < < < | < < < < | < < < < | < | < < | | < < < < > | > | | | | < < < > > < < < > | | < < < > | | < | < | < | | | | | < < > | < | < | | | < < > | | < < > | < | | | | | < | < | | | | | | | | < | | | | | | | < < > | | | | | | | | < | < < < < < < > > | < < < > | < < < > | < < < > | < < < > | < < < > | | < < < > | | < < | | | | | | < < < < < > > | | < < | | | | | | < < < < < > > | < < < > | < < < > | < < < > | < < < > | < < < > | < < < > | | < | < | < < < > | < < < > | < < < > | < < < > | < < < > | < < < > | < < < < > | | | < < > | | < < | < | | | < < | | < < | < < | < | < | | < | < | | | | | | < | | | < | < | < | | | < < | | < | < | < | | | < | < | | | < | | | | | | | | | | > | | | | > | | < | | < < | | | < | | | < | | | | < | < | | | | < < < < < | | | | |
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 ... 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 ... 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 ... 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 ... 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 ... 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 ... 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 .... 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 .... 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 .... 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 .... 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 .... 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 .... 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 .... 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 .... 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 .... 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 .... 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 |
#include <stdarg.h> #ifdef _WIN32 #define strcasecmp _stricmp #endif /* not WIN32 */ #if !defined(_WIN32) && !defined(WIN32) # include <signal.h> # if !defined(__RTP__) && !defined(_WRS_KERNEL) # include <pwd.h> # endif # include <unistd.h> # include <sys/types.h> #endif #ifdef HAVE_EDITLINE # include <editline/editline.h> #endif #if defined(HAVE_READLINE) && HAVE_READLINE==1 # include <readline/readline.h> # include <readline/history.h> #endif #if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1) # define readline(p) local_getline(p,stdin,0) # define add_history(X) # define read_history(X) # define write_history(X) # define stifle_history(X) #endif #if defined(_WIN32) || defined(WIN32) # include <io.h> #define isatty(h) _isatty(h) #define access(f,m) _access((f),(m)) #undef popen #define popen(a,b) _popen((a),(b)) #undef pclose #define pclose(x) _pclose(x) #else /* Make sure isatty() has a prototype. */ extern int isatty(int); #endif #if defined(_WIN32_WCE) /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty() * thus we always assume that we have a console. That can be * overridden with the -batch command line option. */ ................................................................................ /* Saved resource information for the beginning of an operation */ static struct rusage sBegin; /* ** Begin timing an operation */ static void beginTimer(void){ if( enableTimer ){ getrusage(RUSAGE_SELF, &sBegin); } } /* Return the difference of two time_structs in seconds */ static double timeDiff(struct timeval *pStart, struct timeval *pEnd){ return (pEnd->tv_usec - pStart->tv_usec)*0.000001 + (double)(pEnd->tv_sec - pStart->tv_sec); } /* ** Print the timing results. */ static void endTimer(void){ if( enableTimer ){ struct rusage sEnd; getrusage(RUSAGE_SELF, &sEnd); printf("CPU Time: user %f sys %f\n", timeDiff(&sBegin.ru_utime, &sEnd.ru_utime), timeDiff(&sBegin.ru_stime, &sEnd.ru_stime)); } } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER 1 #elif (defined(_WIN32) || defined(WIN32)) ................................................................................ #include <windows.h> /* Saved resource information for the beginning of an operation */ static HANDLE hProcess; static FILETIME ftKernelBegin; static FILETIME ftUserBegin; typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME); static GETPROCTIMES getProcessTimesAddr = NULL; /* ** Check to see if we have timer support. Return 1 if necessary ** support found (or found previously). */ static int hasTimer(void){ if( getProcessTimesAddr ){ return 1; } else { /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions. ** See if the version we are running on has it, and if it does, save off ** a pointer to it and the current process handle. */ hProcess = GetCurrentProcess(); if( hProcess ){ HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll")); if( NULL != hinstLib ){ getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes"); if( NULL != getProcessTimesAddr ){ return 1; } FreeLibrary(hinstLib); } } } return 0; } /* ** Begin timing an operation */ static void beginTimer(void){ if( enableTimer && getProcessTimesAddr ){ FILETIME ftCreation, ftExit; getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin); } } /* Return the difference of two FILETIME structs in seconds */ static double timeDiff(FILETIME *pStart, FILETIME *pEnd){ sqlite_int64 i64Start = *((sqlite_int64 *) pStart); sqlite_int64 i64End = *((sqlite_int64 *) pEnd); return (double) ((i64End - i64Start) / 10000000.0); } /* ** Print the timing results. */ static void endTimer(void){ if( enableTimer && getProcessTimesAddr){ FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd; getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd); printf("CPU Time: user %f sys %f\n", timeDiff(&ftUserBegin, &ftUserEnd), timeDiff(&ftKernelBegin, &ftKernelEnd)); } } #define BEGIN_TIMER beginTimer() #define END_TIMER endTimer() #define HAS_TIMER hasTimer() #else #define BEGIN_TIMER #define END_TIMER #define HAS_TIMER 0 #endif /* sandro: 3 September 2012 ** If the following flag is set, then SQL Log is enabled */ ................................................................................ */ static char *Argv0; /* ** Prompt strings. Initialized in main. Settable with ** .prompt main continue */ static char mainPrompt[20]; /* First line prompt. default: "spatialite> "*/ static char continuePrompt[20]; /* Continuation prompt. default: " ...> " */ /* ** Write I/O traces to the following stream. */ #ifdef SQLITE_ENABLE_IOTRACE static FILE *iotrace = 0; #endif ................................................................................ /* ** This routine works like printf in that its first argument is a ** format string and subsequent arguments are values to be substituted ** in place of % fields. The result of formatting this string ** is written to iotrace. */ #ifdef SQLITE_ENABLE_IOTRACE static void iotracePrintf(const char *zFormat, ...){ va_list ap; char *z; if( iotrace==0 ) return; va_start(ap, zFormat); z = sqlite3_vmprintf(zFormat, ap); va_end(ap); fprintf(iotrace, "%s", z); sqlite3_free(z); } #endif /* Sandro Furieri 2013-04-29 WFS progress handler callback */ static void wfs_page_done(int features, void *ptr) { if (isatty (1)) { printf("WFS Features loaded since now: %d\r", features); fflush(stdout); } } /* Sandro Furieri 2008-11-20 implementing AUTO FDO */ ................................................................................ utf8buf[maxlen - utf8len] = '\0'; memcpy (buf, utf8buf, (maxlen - utf8len) + 1); free (utf8buf); } /* sandro 2013-11-17 */ static void split_drop_name(const char *str, char **prefix, char **table) { int len1; int len2; const char *pt = NULL; const char *p = str; *prefix = NULL; *table = NULL; while (*p != '\0') { if (*p == '.') { pt = p; break; } p++; } if (pt == NULL) return; len1 = pt - str; len2 = strlen(pt + 1); if (len1 > 0 && len2 > 0) { *prefix = malloc(len1 + 1); memcpy(*prefix, str, len1); *(*prefix + len1) = '\0'; *table = malloc(len2 + 1); strcpy(*table, pt + 1); } } /* end sandro 2013-11-17 */ static void convert_input_to_utf8 (char *buf, int maxlen) { /* converting from required charset to UTF8 */ char *utf8buf = 0; ................................................................................ /* end Sandro Furieri 11 July 2008 */ /* ** Determines if a string is a number of not. */ static int isNumber(const char *z, int *realnum){ if( *z=='-' || *z=='+' ) z++; if( !IsDigit(*z) ){ return 0; } z++; if( realnum ) *realnum = 0; while( IsDigit(*z) ){ z++; } if( *z=='.' ){ z++; if( !IsDigit(*z) ) return 0; while( IsDigit(*z) ){ z++; } if( realnum ) *realnum = 1; } if( *z=='e' || *z=='E' ){ z++; if( *z=='+' || *z=='-' ) z++; if( !IsDigit(*z) ) return 0; while( IsDigit(*z) ){ z++; } if( realnum ) *realnum = 1; } return *z==0; } /* ** A global char* and an SQL function to access its current value ** from within an SQL statement. This program used to use the ** sqlite_exec_printf() API to substitue a string into an SQL statement. ** The correct way to do this with sqlite3 is to use the bind API, but ** since the shell is built around the callback paradigm it would be a lot ** of work. Instead just use this hack, which is quite harmless. */ static const char *zShellStatic = 0; static void shellstaticFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ assert( 0==argc ); assert( zShellStatic ); UNUSED_PARAMETER(argc); UNUSED_PARAMETER(argv); sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC); } /* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer ** to the text. NULL is returned at end of file, or if malloc() ** fails. ** ** The interface is like "readline" but no command-line editing ** is done. */ static char *local_getline(char *zPrompt, FILE *in, int csvFlag){ char *zLine; int nLine; int n; int inQuote = 0; if( zPrompt && *zPrompt ){ printf("%s",zPrompt); fflush(stdout); } nLine = 100; zLine = malloc( nLine ); if( zLine==0 ) return 0; n = 0; while( 1 ){ if( n+100>nLine ){ nLine = nLine*2 + 100; zLine = realloc(zLine, nLine); if( zLine==0 ) return 0; } if( fgets(&zLine[n], nLine - n, in)==0 ){ if( n==0 ){ free(zLine); return 0; } zLine[n] = 0; break; } while( zLine[n] ){ if( zLine[n]=='"' ) inQuote = !inQuote; n++; } if( n>0 && zLine[n-1]=='\n' && (!inQuote || !csvFlag) ){ n--; if( n>0 && zLine[n-1]=='\r' ) n--; zLine[n] = 0; break; } } zLine = realloc( zLine, n+1 ); return zLine; } /* ** Retrieve a single line of input text. ** ** zPrior is a string of prior text retrieved. If not the empty ** string, then issue a continuation prompt. */ static char *one_input_line(const char *zPrior, FILE *in){ char *zPrompt; char *zResult; if( in!=0 ){ return local_getline(0, in, 0); } if( zPrior && zPrior[0] ){ zPrompt = continuePrompt; }else{ zPrompt = mainPrompt; } zResult = readline(zPrompt); #if defined(HAVE_READLINE) && HAVE_READLINE==1 if( zResult && *zResult ) add_history(zResult); #endif return zResult; } struct previous_mode_data { int valid; /* Is there legit data in here? */ int mode; int showHeader; int colWidth[100]; }; /* ** An pointer to an instance of this structure is passed from ** the main program to the callback. This is used to communicate ** state and mode information. */ struct callback_data { sqlite3 *db; /* The database */ int echoOn; /* True to echo input commands */ int statsOn; /* True to display memory stats before each finalize */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ FILE *traceOut; /* Output for sqlite3_trace() */ int nErr; /* Number of errors seen */ int mode; /* An output mode setting */ int writableSchema; /* True if PRAGMA writable_schema=ON */ int showHeader; /* True to show column names in List or Column mode */ char *zDestTable; /* Name of destination table when MODE_Insert */ char separator[20]; /* Separator character for MODE_List */ int colWidth[100]; /* Requested width of each column when in column mode*/ int actualWidth[100]; /* Actual width of each column */ char nullvalue[20]; /* The text to print when a NULL comes back from ** the database */ struct previous_mode_data explainPrev; /* Holds the mode information just before ** .explain ON */ char outfile[FILENAME_MAX]; /* Filename for *out */ const char *zDbFilename; /* name of the database file */ const char *zVfs; /* Name of VFS to use */ sqlite3_stmt *pStmt; /* Current statement if any. */ FILE *pLog; /* Write log output here */ }; /* ** These are the allowed modes. */ #define MODE_Line 0 /* One column per line. Blank line between records */ #define MODE_Column 1 /* One record per line in neat columns */ #define MODE_List 2 /* One record per line with a separator */ #define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */ #define MODE_Html 4 /* Generate an XHTML table */ #define MODE_Insert 5 /* Generate SQL "insert" statements */ #define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */ #define MODE_Csv 7 /* Quote strings, numbers are plain */ #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ static const char *modeDescr[] = { "line", "column", "list", "semi", "html", "insert", "tcl", "csv", "explain", }; /* ** Number of elements in an array */ #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) /* ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ static int strlen30(const char *z){ const char *z2 = z; while( *z2 ){ z2++; } return 0x3fffffff & (int)(z2 - z); } /* ** A callback for the sqlite3_log() interface. */ static void shellLog(void *pArg, int iErrCode, const char *zMsg){ struct callback_data *p = (struct callback_data*)pArg; if( p->pLog==0 ) return; fprintf(p->pLog, "(%d) %s\n", iErrCode, zMsg); fflush(p->pLog); } /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ int i; char *zBlob = (char *)pBlob; fprintf(out,"X'"); for(i=0; i<nBlob; i++){ fprintf(out,"%02x",zBlob[i]&0xff); } fprintf(out,"'"); } /* ** Output the given string as a quoted string using SQL quoting conventions. */ static void output_quoted_string(FILE *out, const char *z){ int i; int nSingle = 0; for(i=0; z[i]; i++){ if( z[i]=='\'' ) nSingle++; } if( nSingle==0 ){ fprintf(out,"'%s'",z); }else{ fprintf(out,"'"); while( *z ){ for(i=0; z[i] && z[i]!='\''; i++){} if( i==0 ){ fprintf(out,"''"); z++; }else if( z[i]=='\'' ){ fprintf(out,"%.*s''",i,z); z += i+1; }else{ fprintf(out,"%s",z); break; } } fprintf(out,"'"); } } /* ** Output the given string as a quoted according to C or TCL quoting rules. */ static void output_c_string(FILE *out, const char *z){ unsigned int c; fputc('"', out); while( (c = *(z++))!=0 ){ if( c=='\\' ){ fputc(c, out); fputc(c, out); }else if( c=='\t' ){ fputc('\\', out); fputc('t', out); }else if( c=='\n' ){ fputc('\\', out); fputc('n', out); }else if( c=='\r' ){ fputc('\\', out); fputc('r', out); }else if( !isprint(c) ){ fprintf(out, "\\%03o", c&0xff); }else{ fputc(c, out); } } fputc('"', out); } /* ** Output the given string with characters that are special to ** HTML escaped. */ static void output_html_string(FILE *out, const char *z){ int i; while( *z ){ for(i=0; z[i] && z[i]!='<' && z[i]!='&' && z[i]!='>' && z[i]!='\"' && z[i]!='\''; i++){} if( i>0 ){ fprintf(out,"%.*s",i,z); } if( z[i]=='<' ){ fprintf(out,"<"); }else if( z[i]=='&' ){ fprintf(out,"&"); }else if( z[i]=='>' ){ fprintf(out,">"); }else if( z[i]=='\"' ){ fprintf(out,"""); }else if( z[i]=='\'' ){ fprintf(out,"'"); }else{ break; } z += i + 1; } } /* ** If a field contains any character identified by a 1 in the following ** array, then the string must be quoted for CSV. */ static const char needCsvQuote[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; /* ** Output a single term of CSV. Actually, p->separator is used for ** the separator, which may or may not be a comma. p->nullvalue is ** the null value. Strings are quoted if necessary. */ static void output_csv(struct callback_data *p, const char *z, int bSep){ FILE *out = p->out; if( z==0 ){ fprintf(out,"%s",p->nullvalue); }else{ int i; int nSep = strlen30(p->separator); for(i=0; z[i]; i++){ if( needCsvQuote[((unsigned char*)z)[i]] || (z[i]==p->separator[0] && (nSep==1 || memcmp(z, p->separator, nSep)==0)) ){ i = 0; break; } } if( i==0 ){ putc('"', out); for(i=0; z[i]; i++){ if( z[i]=='"' ) putc('"', out); putc(z[i], out); } putc('"', out); }else{ fprintf(out, "%s", z); } } if( bSep ){ fprintf(p->out, "%s", p->separator); } } #ifdef SIGINT /* ** This routine runs when the user presses Ctrl-C */ static void interrupt_handler(int NotUsed){ UNUSED_PARAMETER(NotUsed); seenInterrupt = 1; if( db ) sqlite3_interrupt(db); } #endif /* ** This is the callback routine that the shell ** invokes for each row of a query result. */ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){ int i; /* Sandro Furieri 11 July 2008 - supporting full UNICODE */ char *buf = NULL; int len; /* end Sandro Furieri 11 July 2008 */ struct callback_data *p = (struct callback_data*)pArg; switch( p->mode ){ case MODE_Line: { int w = 5; if( azArg==0 ) break; for(i=0; i<nArg; i++){ int len = strlen30(azCol[i] ? azCol[i] : ""); if( len>w ) w = len; } if( p->cnt++>0 ) fprintf(p->out,"\n"); for(i=0; i<nArg; i++){ /* Sandro Furieri 11 July 2008 fprintf(p->out,"%*s = %s\n", w, azCol[i], azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) fprintf (p->out, "%*s = %s\n", w, azCol[i], p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); fprintf (p->out, "%*s = %s\n", w, azCol[i], azArg[i] ? buf : p->nullvalue); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ } break; } case MODE_Explain: case MODE_Column: { if( p->cnt++==0 ){ for(i=0; i<nArg; i++){ int w, n; if( i<ArraySize(p->colWidth) ){ w = p->colWidth[i]; }else{ w = 0; } if( w<=0 ){ w = strlen30(azCol[i] ? azCol[i] : ""); if( w<10 ) w = 10; n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue); if( w<n ) w = n; } if( i<ArraySize(p->actualWidth) ){ p->actualWidth[i] = w; } if( p->showHeader ){ fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " "); } } if( p->showHeader ){ for(i=0; i<nArg; i++){ int w; if( i<ArraySize(p->actualWidth) ){ w = p->actualWidth[i]; }else{ w = 10; } fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------" "----------------------------------------------------------", i==nArg-1 ? "\n": " "); } } } if( azArg==0 ) break; for(i=0; i<nArg; i++){ int w; if( i<ArraySize(p->actualWidth) ){ w = p->actualWidth[i]; }else{ w = 10; } if( p->mode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){ w = strlen30(azArg[i]); } /* Sandro Furieri 11 July 2008 fprintf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " "); */ if (azArg[i] == 0) fprintf (p->out, "%-*.*s%s", w, w, p->nullvalue, i == nArg - 1 ? "\n" : " "); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); fprintf (p->out, "%-*.*s%s", w, w, azArg[i] ? buf : p->nullvalue, i == nArg - 1 ? "\n" : " "); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " "); } break; } case MODE_Semi: case MODE_List: { if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ fprintf(p->out,"%s%s",azCol[i], i==nArg-1 ? "\n" : p->separator); } } if( azArg==0 ) break; for(i=0; i<nArg; i++){ /* Sandro Furieri 11 July 2008 char *z = azArg[i]; if( z==0 ) z = p->nullvalue; */ char *z; if (azArg[i] == 0) z = p->nullvalue; else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); z = buf; strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); } /* end Sandro Furieri 11 July 2008 */ fprintf(p->out, "%s", z); if (buf) free(buf); buf = NULL; if( i<nArg-1 ){ fprintf(p->out, "%s", p->separator); }else if( p->mode==MODE_Semi ){ fprintf(p->out, ";\n"); }else{ fprintf(p->out, "\n"); } } break; } case MODE_Html: { if( p->cnt++==0 && p->showHeader ){ fprintf(p->out,"<TR>"); for(i=0; i<nArg; i++){ fprintf(p->out,"<TH>"); output_html_string(p->out, azCol[i]); fprintf(p->out,"</TH>\n"); } fprintf(p->out,"</TR>\n"); } if( azArg==0 ) break; fprintf(p->out,"<TR>"); for(i=0; i<nArg; i++){ fprintf(p->out,"<TD>"); /* Sandro Furieri 11 July 2008 output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) output_html_string (p->out, p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_html_string (p->out, azArg[i] ? buf : p->nullvalue); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf(p->out,"</TD>\n"); } fprintf(p->out,"</TR>\n"); break; } case MODE_Tcl: { if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_c_string(p->out,azCol[i] ? azCol[i] : ""); fprintf(p->out, "%s", p->separator); } fprintf(p->out,"\n"); } if( azArg==0 ) break; for(i=0; i<nArg; i++){ /* Sandro Furieri 11 July 2008 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); */ if (azArg[i] == 0) output_c_string (p->out, p->nullvalue); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_c_string (p->out, azArg[i] ? buf : p->nullvalue); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ fprintf(p->out, "%s", p->separator); } fprintf(p->out,"\n"); break; } case MODE_Csv: { if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } fprintf(p->out,"\n"); } if( azArg==0 ) break; for(i=0; i<nArg; i++){ /* Sandro Furieri 11 July 2008 output_csv(p, azArg[i], i<nArg-1); */ if (azArg[i] == 0) output_csv (p, azArg[i], i < nArg - 1); else { ................................................................................ len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_csv (p, buf, i < nArg - 1); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ } fprintf(p->out,"\n"); break; } case MODE_Insert: { p->cnt++; if( azArg==0 ) break; fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); for(i=0; i<nArg; i++){ char *zSep = i>0 ? ",": ""; if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ fprintf(p->out,"%sNULL",zSep); }else if( aiType && aiType[i]==SQLITE_TEXT ){ if( zSep[0] ) fprintf(p->out,"%s",zSep); /* Sandro Furieri 11 July 2008 output_quoted_string(p->out, azArg[i]); */ if (azArg[i] == 0) output_quoted_string (p->out, azArg[i]); else { len = strlen (azArg[i]) + 1; if (buf) free (buf); buf = malloc (len * 4); strcpy (buf, azArg[i]); convert_from_utf8 (buf, len * 4); output_quoted_string (p->out, buf); free(buf); buf = NULL; } /* end Sandro Furieri 11 July 2008 */ }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){ fprintf(p->out,"%s%s",zSep, azArg[i]); }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ const void *pBlob = sqlite3_column_blob(p->pStmt, i); int nBlob = sqlite3_column_bytes(p->pStmt, i); if( zSep[0] ) fprintf(p->out,"%s",zSep); output_hex_blob(p->out, pBlob, nBlob); }else if( isNumber(azArg[i], 0) ){ fprintf(p->out,"%s%s",zSep, azArg[i]); }else{ if( zSep[0] ) fprintf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); } } fprintf(p->out,");\n"); break; } } return 0; } /* ** This is the callback routine that the SQLite library ** invokes for each row of a query result. */ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ /* since we don't have type info, call the shell_callback with a NULL value */ return shell_callback(pArg, nArg, azArg, azCol, NULL); } /* ** Set the destination table field of the callback_data structure to ** the name of the table given. Escape any quote characters in the ** table name. */ static void set_table_name(struct callback_data *p, const char *zName){ int i, n; int needQuote; char *z; if( p->zDestTable ){ free(p->zDestTable); p->zDestTable = 0; } if( zName==0 ) return; needQuote = !isalpha((unsigned char)*zName) && *zName!='_'; for(i=n=0; zName[i]; i++, n++){ if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ){ needQuote = 1; if( zName[i]=='\'' ) n++; } } if( needQuote ) n += 2; z = p->zDestTable = malloc( n+1 ); if( z==0 ){ fprintf(stderr,"Error: out of memory\n"); exit(1); } n = 0; if( needQuote ) z[n++] = '\''; for(i=0; zName[i]; i++){ z[n++] = zName[i]; if( zName[i]=='\'' ) z[n++] = '\''; } if( needQuote ) z[n++] = '\''; z[n] = 0; } /* zIn is either a pointer to a NULL-terminated string in memory obtained ** from malloc(), or a NULL pointer. The string pointed to by zAppend is ** added to zIn, and the result returned in memory obtained from malloc(). ** zIn, if it was not NULL, is freed. ** ** If the third argument, quote, is not '\0', then it is used as a ** quote character for zAppend. */ static char *appendText(char *zIn, char const *zAppend, char quote){ int len; int i; int nAppend = strlen30(zAppend); int nIn = (zIn?strlen30(zIn):0); len = nAppend+nIn+1; if( quote ){ len += 2; for(i=0; i<nAppend; i++){ if( zAppend[i]==quote ) len++; } } zIn = (char *)realloc(zIn, len); if( !zIn ){ return 0; } if( quote ){ char *zCsr = &zIn[nIn]; *zCsr++ = quote; for(i=0; i<nAppend; i++){ *zCsr++ = zAppend[i]; if( zAppend[i]==quote ) *zCsr++ = quote; } *zCsr++ = quote; *zCsr++ = '\0'; assert( (zCsr-zIn)==len ); }else{ memcpy(&zIn[nIn], zAppend, nAppend); zIn[len-1] = '\0'; } return zIn; } /* ** Execute a query statement that will generate SQL output. Print ** the result columns, comma-separated, on a line and then add a ** semicolon terminator to the end of that line. ** ** If the number of columns is 1 and that column contains text "--" ** then write the semicolon on a separate line. That way, if a ** "--" comment occurs at the end of the statement, the comment ** won't consume the semicolon terminator. */ static int run_table_dump_query( struct callback_data *p, /* Query context */ const char *zSelect, /* SELECT statement to extract content */ const char *zFirstRow /* Print before first row, if not NULL */ ){ sqlite3_stmt *pSelect; int rc; int nResult; int i; const char *z; rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0); if( rc!=SQLITE_OK || !pSelect ){ fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); p->nErr++; return rc; } rc = sqlite3_step(pSelect); nResult = sqlite3_column_count(pSelect); while( rc==SQLITE_ROW ){ if( zFirstRow ){ fprintf(p->out, "%s", zFirstRow); zFirstRow = 0; } z = (const char*)sqlite3_column_text(pSelect, 0); fprintf(p->out, "%s", z); for(i=1; i<nResult; i++){ fprintf(p->out, ",%s", sqlite3_column_text(pSelect, i)); } if( z==0 ) z = ""; while( z[0] && (z[0]!='-' || z[1]!='-') ) z++; if( z[0] ){ fprintf(p->out, "\n;\n"); }else{ fprintf(p->out, ";\n"); } rc = sqlite3_step(pSelect); } rc = sqlite3_finalize(pSelect); if( rc!=SQLITE_OK ){ fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); p->nErr++; } return rc; } /* ** Allocate space and save off current error string. */ static char *save_err_msg( sqlite3 *db /* Database to query */ ){ int nErrMsg = 1+strlen30(sqlite3_errmsg(db)); char *zErrMsg = sqlite3_malloc(nErrMsg); if( zErrMsg ){ memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg); } return zErrMsg; } /* ** Display memory stats. */ static int display_stats( sqlite3 *db, /* Database to query */ struct callback_data *pArg, /* Pointer to struct callback_data */ int bReset /* True to reset the stats */ ){ int iCur; int iHiwtr; if( pArg && pArg->out ){ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr); /* ** Not currently used by the CLI. ** iHiwtr = iCur = -1; ** sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset); ** fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr); */ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); /* ** Not currently used by the CLI. ** iHiwtr = iCur = -1; ** sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset); ** fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr); */ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr); #ifdef YYTRACKMAXSTACKDEPTH iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr); #endif } /* Sandro Furieri 1 November 2012 - depending on SQLite version */ if( pArg && pArg->out && db ){ iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_USED sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); #else fprintf(pArg->out, "Lookaside Slots Used: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_HIT sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); #else fprintf(pArg->out, "Successful lookaside attempts: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); #else fprintf(pArg->out, "Lookaside failures due to size: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); #else fprintf(pArg->out, "Lookaside failures due to OOM: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_USED sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); #else fprintf(pArg->out, "Pager Heap Usage: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_HIT sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1); fprintf(pArg->out, "Page cache hits: %d\n", iCur); #else fprintf(pArg->out, "Page cache hits: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_MISS sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1); fprintf(pArg->out, "Page cache misses: %d\n", iCur); #else fprintf(pArg->out, "Page cache misses: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_CACHE_WRITE sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1); fprintf(pArg->out, "Page cache writes: %d\n", iCur); #else fprintf(pArg->out, "Page cache writes: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_SCHEMA_USED sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur); #else fprintf(pArg->out, "Schema Heap Usage: n.a.\n"); #endif iHiwtr = iCur = -1; #ifdef HAVE_DECL_SQLITE_DBSTATUS_STMT_USED sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur); #else fprintf(pArg->out, "Statement Heap/Lookaside Usage: n.a.\n"); #endif } if( pArg && pArg->out && db && pArg->pStmt ){ #ifdef HAVE_DECL_SQLITE_STMTSTATUS_FULLSCAN_STEP iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset); fprintf(pArg->out, "Fullscan Steps: %d\n", iCur); #else fprintf(pArg->out, "Fullscan Steps: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_STMTSTATUS_SORT iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset); fprintf(pArg->out, "Sort Operations: %d\n", iCur); #else fprintf(pArg->out, "Sort Operations: n.a.\n"); #endif #ifdef HAVE_DECL_SQLITE_STMTSTATUS_AUTOINDEX iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset); fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur); #else fprintf(pArg->out, "Autoindex Inserts: n.a.\n"); #endif } /* end sandro 1 November 2012 */ return 0; } /* ** Execute a statement or set of statements. Print ** any result rows/columns depending on the current mode ** set via the supplied callback. ** ** This is very similar to SQLite's built-in sqlite3_exec() ** function except it takes a slightly different callback ** and callback data argument. */ static int shell_exec( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ int (*xCallback)(void*,int,char**,char**,int*), /* Callback function */ /* (not the same as sqlite3_exec) */ struct callback_data *pArg, /* Pointer to struct callback_data */ char **pzErrMsg /* Error msg written here */ ){ sqlite3_stmt *pStmt = NULL; /* Statement to execute. */ int rc = SQLITE_OK; /* Return Code */ int rc2; const char *zLeftover; /* Tail of unprocessed SQL */ if( pzErrMsg ){ *pzErrMsg = NULL; } while( zSql[0] && (SQLITE_OK == rc) ){ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); if( SQLITE_OK != rc ){ if( pzErrMsg ){ *pzErrMsg = save_err_msg(db); } }else{ if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; while( IsSpace(zSql[0]) ) zSql++; continue; } /* save off the prepared statment handle and reset row count */ if( pArg ){ pArg->pStmt = pStmt; pArg->cnt = 0; } /* echo the sql statement if echo on */ if( pArg && pArg->echoOn ){ const char *zStmtSql = sqlite3_sql(pStmt); fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); } /* Output TESTCTRL_EXPLAIN text of requested */ if( pArg && pArg->mode==MODE_Explain ){ /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_TESTCTRL_EXPLAIN_STMT const char *zExplain = 0; sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain); if( zExplain && zExplain[0] ){ fprintf(pArg->out, "%s", zExplain); } #else fprintf(pArg->out, "TESTCTRL_EXPLAIN: unsupported"); #endif /* end sandro 1 November 2012 */ } /* perform the first step. this will tell us if we ** have a result set or not and how wide it is. */ rc = sqlite3_step(pStmt); /* if we have a result set... */ if( SQLITE_ROW == rc ){ /* if we have a callback... */ if( xCallback ){ /* allocate space for col name ptr, value ptr, and type */ int nCol = sqlite3_column_count(pStmt); void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1); if( !pData ){ rc = SQLITE_NOMEM; }else{ char **azCols = (char **)pData; /* Names of result columns */ char **azVals = &azCols[nCol]; /* Results */ int *aiTypes = (int *)&azVals[nCol]; /* Result types */ int i; assert(sizeof(int) <= sizeof(char *)); /* save off ptrs to column names */ for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite3_column_name(pStmt, i); } do{ /* extract the data and data types */ for(i=0; i<nCol; i++){ azVals[i] = (char *)sqlite3_column_text(pStmt, i); aiTypes[i] = sqlite3_column_type(pStmt, i); if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){ rc = SQLITE_NOMEM; break; /* from for */ } } /* end for */ /* if data and types extracted successfully... */ if( SQLITE_ROW == rc ){ /* call the supplied callback with the result row data */ if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){ rc = SQLITE_ABORT; }else{ rc = sqlite3_step(pStmt); } } } while( SQLITE_ROW == rc ); sqlite3_free(pData); } }else{ do{ rc = sqlite3_step(pStmt); } while( rc == SQLITE_ROW ); } } /* print usage stats if stats on */ if( pArg && pArg->statsOn ){ display_stats(db, pArg, 0); } /* Finalize the statement just executed. If this fails, save a ** copy of the error message. Otherwise, set zSql to point to the ** next statement to execute. */ rc2 = sqlite3_finalize(pStmt); if( rc!=SQLITE_NOMEM ) rc = rc2; if( rc==SQLITE_OK ){ zSql = zLeftover; while( IsSpace(zSql[0]) ) zSql++; }else if( pzErrMsg ){ *pzErrMsg = save_err_msg(db); } /* clear saved stmt handle */ if( pArg ){ pArg->pStmt = NULL; } } } /* end while */ return rc; } /* ** This is a different callback routine used for dumping the database. ** Each row received by this callback consists of a table name, ** the table type ("index" or "table") and SQL to create the table. ** This routine should print text sufficient to recreate the table. */ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ int rc; const char *zTable; const char *zType; const char *zSql; const char *zPrepStmt = 0; struct callback_data *p = (struct callback_data *)pArg; UNUSED_PARAMETER(azCol); if( nArg!=3 ) return 1; zTable = azArg[0]; zType = azArg[1]; zSql = azArg[2]; if( strcmp(zTable, "sqlite_sequence")==0 ){ zPrepStmt = "DELETE FROM sqlite_sequence;\n"; }else if( strcmp(zTable, "sqlite_stat1")==0 ){ fprintf(p->out, "ANALYZE sqlite_master;\n"); }else if( strncmp(zTable, "sqlite_", 7)==0 ){ return 0; }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){ char *zIns; if( !p->writableSchema ){ fprintf(p->out, "PRAGMA writable_schema=ON;\n"); p->writableSchema = 1; } zIns = sqlite3_mprintf( "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)" "VALUES('table','%q','%q',0,'%q');", zTable, zTable, zSql); fprintf(p->out, "%s\n", zIns); sqlite3_free(zIns); return 0; }else{ fprintf(p->out, "%s;\n", zSql); } if( strcmp(zType, "table")==0 ){ sqlite3_stmt *pTableInfo = 0; char *zSelect = 0; char *zTableInfo = 0; char *zTmp = 0; int nRow = 0; zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0); zTableInfo = appendText(zTableInfo, zTable, '"'); zTableInfo = appendText(zTableInfo, ");", 0); rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0); free(zTableInfo); if( rc!=SQLITE_OK || !pTableInfo ){ return 1; } zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0); /* Always quote the table name, even if it appears to be pure ascii, ** in case it is a keyword. Ex: INSERT INTO "table" ... */ zTmp = appendText(zTmp, zTable, '"'); if( zTmp ){ zSelect = appendText(zSelect, zTmp, '\''); free(zTmp); } zSelect = appendText(zSelect, " || ' VALUES(' || ", 0); rc = sqlite3_step(pTableInfo); while( rc==SQLITE_ROW ){ const char *zText = (const char *)sqlite3_column_text(pTableInfo, 1); zSelect = appendText(zSelect, "quote(", 0); zSelect = appendText(zSelect, zText, '"'); rc = sqlite3_step(pTableInfo); if( rc==SQLITE_ROW ){ zSelect = appendText(zSelect, "), ", 0); }else{ zSelect = appendText(zSelect, ") ", 0); } nRow++; } rc = sqlite3_finalize(pTableInfo); if( rc!=SQLITE_OK || nRow==0 ){ free(zSelect); return 1; } zSelect = appendText(zSelect, "|| ')' FROM ", 0); zSelect = appendText(zSelect, zTable, '"'); rc = run_table_dump_query(p, zSelect, zPrepStmt); if( rc==SQLITE_CORRUPT ){ zSelect = appendText(zSelect, " ORDER BY rowid DESC", 0); run_table_dump_query(p, zSelect, 0); } free(zSelect); } return 0; } static void spatialite_autocreate (sqlite3 * db) { /* attempting to perform self-initialization for a newly created DB */ int ret; ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } spatial_ref_sys_init (db, 1); } /* ** Run zQuery. Use dump_callback() as the callback routine so that ** the contents of the query are output as SQL statements. ** ** If we get a SQLITE_CORRUPT error, rerun the query after appending ** "ORDER BY rowid DESC" to the end. */ static int run_schema_dump_query( struct callback_data *p, const char *zQuery ){ int rc; char *zErr = 0; rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr); if( rc==SQLITE_CORRUPT ){ char *zQ2; int len = strlen30(zQuery); fprintf(p->out, "/****** CORRUPTION ERROR *******/\n"); if( zErr ){ fprintf(p->out, "/****** %s ******/\n", zErr); sqlite3_free(zErr); zErr = 0; } zQ2 = malloc( len+100 ); if( zQ2==0 ) return rc; sqlite3_snprintf(len+100, zQ2, "%s ORDER BY rowid DESC", zQuery); rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr); if( rc ){ fprintf(p->out, "/****** ERROR: %s ******/\n", zErr); }else{ rc = SQLITE_CORRUPT; } sqlite3_free(zErr); free(zQ2); } return rc; } /* ** Text of a help message */ static char zHelp[] = ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail ON|OFF Stop after hitting an error. Default OFF\n" ".databases List names and files of attached databases\n" ".dump ?TABLE? ... Dump the database in an SQL text format\n" " If TABLE specified, only dump tables matching\n" " LIKE pattern TABLE.\n" ".echo ON|OFF Turn command echo on or off\n" ".exit Exit this program\n" ".explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.\n" " With no args, it turns EXPLAIN on.\n" ".header(s) ON|OFF Turn display of headers on or off\n" ".help Show this message\n" ".import FILE TABLE Import data from FILE into TABLE\n" ".indices ?TABLE? Show names of all indices\n" " If TABLE specified, only show indices for tables\n" " matching LIKE pattern TABLE.\n" #ifdef SQLITE_ENABLE_IOTRACE ".iotrace FILE Enable I/O diagnostic logging to FILE\n" #endif #ifndef SQLITE_OMIT_LOAD_EXTENSION ".load FILE ?ENTRY? Load an extension library\n" #endif ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" " csv Comma-separated values\n" " column Left-aligned columns. (See .width)\n" " html HTML <table> code\n" " insert SQL insert statements for TABLE\n" " line One value per line\n" " list Values delimited by .separator string\n" " tabs Tab-separated values\n" " tcl TCL list elements\n" ".nullvalue STRING Print STRING in place of NULL values\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" ".schema ?TABLE? Show the CREATE statements\n" " If TABLE specified, only show tables matching\n" " LIKE pattern TABLE.\n" ".separator STRING Change separator used by output mode and .import\n" ".shell CMD ARGS... Run CMD ARGS... in a system shell\n" ".show Show the current values for various settings\n" ".stats ON|OFF Turn stats on or off\n" ".system CMD ARGS... Run CMD ARGS... in a system shell\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" ".timeout MS Try opening locked tables for MS milliseconds\n" ".trace FILE|off Output each SQL statement as it is run\n" ".vfsname ?AUX? Print the name of the VFS stack\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n" ; static char zTimerHelp[] = ".timer ON|OFF Turn the CPU timer measurement on or off\n" /* Sandro Furieri 2008-06-20 */ "\n====================== SpatiaLite ========================================\n\n" ".charset Report the current locale charset setting\n\n" ".charset <charset-name>\n" " Set the charset encoding according to the command shell\n" " e.g.: when working on Windows Command Prompt, if you notice\n" " 'strange' chars, a very good idea may be to type\n" ................................................................................ ".remdupl <table> Removes any duplicated row from a TABLE\n\n" ".elemgeo <args> derives a new table from the original one, so to ensure that\n" " only elementary Geometries (one for each row) will be present\n" " arg_list: in_tbl geom out_tbl out_pk out_old_id\n\n" ".loadshp <args> Loads a SHAPEFILE into a SpatiaLite table\n" " arg_list: shp_path table_name charset [SRID] [column_name]\n" " [pk_column] [geom_type] [2d | 3d] [compressed]\n" " [with_spatial_index] [text_dates]\n" " geom_type={ AUTO | LINESTRING[ Z | M | ZM ]\n" " | MULTILINESTRING[ Z | M | ZM ]\n" " | POLYGON[ Z | M | ZM ]\n" " | MULTIPOLYGON[ Z | M | ZM ] }\n\n" ".dumpshp <args> Dumps a SpatiaLite table into a SHAPEFILE\n" " arg_list: table_name column_name shp_path charset [geom_type]\n" " geom_type={ POINT | LINESTRING | POLYGON | MULTIPOINT }\n\n" ".loaddbf <args> Loads a DBF into a SpatiaLite table\n" " arg_list: dbf_path table_name charset [pk_column] [text_dates]\n\n" ".dumpdbf <args> Dumps a SpatiaLite table into a DBF\n" " arg_list: table_name dbf_path charset\n\n" #ifndef OMIT_FREEXL /* FreeXL is enabled */ ".loadxl <args> Loads a XL spreadsheet (.xls) into a SpatiaLite table\n" " arg_list: xl_path table_name \n" " [worksheet_index [first_line_titles{0/1}]]\n\n" #endif /* end FreeXL support */ ".dumpkml <args> Dumps a SpatiaLite table as a KML file\n" " arg_list: table_name geom_column kml_path\n" ................................................................................ " [swap] [page_size] [with_spatial_index]\n\n" ".loaddxf <args> Loads data from some DXF source into SpatiaLite tables\n" " arg_list: DXF_path [srid] [append] [dims] [mode]\n" " [rings] [table_prefix] [layer_name]\n" " append={Y|N} dims={AUTO|2D|3D} mode={DISTINCT|MIXED}\n" " rings={NONE|LINKED|UNLINKED}\n\n" /* end Sandro Furieri 2008-06-20 */ ; /* Forward reference */ static int process_input(struct callback_data *p, FILE *in, char *in_charset); /* ** Make sure the database is open. If it is not, then open it. If ** the database fails to open, print an error message and exit. */ static void open_db(struct callback_data *p){ if( p->db==0 ){ sqlite3_initialize(); sqlite3_open(p->zDbFilename, &p->db); db = p->db; if( db && sqlite3_errcode(db)==SQLITE_OK ){ sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0, shellstaticFunc, 0, 0); } if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){ fprintf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg(db)); exit(1); } spatialite_init_ex (p->db, splite_cache, (splite_silent == 0) ? 1 : 0); #ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension(p->db, 1); #endif /* Sandro Furieri 2009-11-08 */ sqlite3_exec (p->db, "PRAGMA foreign_keys = 1", NULL, 0, NULL); /* end Sandro Furieri 2008-11-08 */ /* Sandro Furieri 2010-08-07 */ spatialite_autocreate (p->db); /* end Sandro Furieri 2010-08-07 */ } } /* ** Do C-language style dequoting. ** ** \t -> tab ** \n -> newline ** \r -> carriage return ** \NNN -> ascii character NNN in octal ** \\ -> backslash */ static void resolve_backslashes(char *z){ int i, j; char c; for(i=j=0; (c = z[i])!=0; i++, j++){ if( c=='\\' ){ c = z[++i]; if( c=='n' ){ c = '\n'; }else if( c=='t' ){ c = '\t'; }else if( c=='r' ){ c = '\r'; }else if( c>='0' && c<='7' ){ c -= '0'; if( z[i+1]>='0' && z[i+1]<='7' ){ i++; c = (c<<3) + z[i] - '0'; if( z[i+1]>='0' && z[i+1]<='7' ){ i++; c = (c<<3) + z[i] - '0'; } } } } z[j] = c; } z[j] = 0; } /* ** Interpret zArg as a boolean value. Return either 0 or 1. */ static int booleanValue(char *zArg){ int val = atoi(zArg); int j; for(j=0; zArg[j]; j++){ zArg[j] = ToLower(zArg[j]); } if( strcmp(zArg,"on")==0 ){ val = 1; }else if( strcmp(zArg,"yes")==0 ){ val = 1; } return val; } /* ** Close an output file, assuming it is not stderr or stdout */ static void output_file_close(FILE *f){ if( f && f!=stdout && f!=stderr ) fclose(f); } /* ** Try to open an output file. The names "stdout" and "stderr" are ** recognized and do the right thing. NULL is returned if the output ** filename is "off". */ static FILE *output_file_open(const char *zFile){ FILE *f; if( strcmp(zFile,"stdout")==0 ){ f = stdout; }else if( strcmp(zFile, "stderr")==0 ){ f = stderr; }else if( strcmp(zFile, "off")==0 ){ f = 0; }else{ f = fopen(zFile, "wb"); if( f==0 ){ fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); } } return f; } /* ** A routine for handling output from sqlite3_trace(). */ static void sql_trace_callback(void *pArg, const char *z){ FILE *f = (FILE*)pArg; if( f ) fprintf(f, "%s\n", z); } /* ** A no-op routine that runs with the ".breakpoint" doc-command. This is ** a useful spot to set a debugger breakpoint. */ static void test_breakpoint(void){ static int nCall = 0; nCall++; } /* ** If an input line begins with "." then invoke this routine to ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command(char *zLine, struct callback_data *p){ int i = 1; int nArg = 0; int n, c; int rc = 0; char *azArg[50]; /* Parse the input line into tokens. */ while( zLine[i] && nArg<ArraySize(azArg) ){ while( IsSpace(zLine[i]) ){ i++; } if( zLine[i]==0 ) break; if( zLine[i]=='\'' || zLine[i]=='"' ){ int delim = zLine[i++]; azArg[nArg++] = &zLine[i]; while( zLine[i] && zLine[i]!=delim ){ i++; } if( zLine[i]==delim ){ zLine[i++] = 0; } if( delim=='"' ) resolve_backslashes(azArg[nArg-1]); }else{ azArg[nArg++] = &zLine[i]; while( zLine[i] && !IsSpace(zLine[i]) ){ i++; } if( zLine[i] ) zLine[i++] = 0; resolve_backslashes(azArg[nArg-1]); } } /* Process the input line. */ if( nArg==0 ) return 0; /* no tokens, no error */ n = strlen30(azArg[0]); c = azArg[0][0]; #ifndef SQLITE_OMIT_LOAD_EXTENSION if( c=='l' && strncmp(azArg[0], "load", n)==0 && nArg>=2 ){ const char *zFile, *zProc; char *zErrMsg = 0; zFile = azArg[1]; zProc = nArg>=3 ? azArg[2] : 0; open_db(p); rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg); if( rc!=SQLITE_OK ){ fprintf(stderr, "Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } }else #endif /* Sandro Furieri 2008-06-20 */ if (c == 'c' && n > 1 && strncmp (azArg[0], "charset", n) == 0 && nArg == 1) { /* reporting the charset */ if (*spatialite_charset == '\0') { printf ("the shell's default LOCALE CHARSET is currently in use\n"); fflush (stdout); ................................................................................ else if (c == 'c' && n > 1 && strncmp (azArg[0], "charset", n) == 0 && nArg == 2) { /* setting the charset */ create_utf8_converter (azArg[1]); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpshp", n) == 0 && (nArg == 5 || nArg == 6)) { /* dumping a spatial table to SHAPEFILE */ char *table = azArg[1]; char *column = azArg[2]; char *shp_path = azArg[3]; char *outCS = azArg[4]; char *type = NULL; int rows; if (nArg == 6) type = azArg[5]; open_db (p); dump_shapefile (p->db, table, column, shp_path, outCS, type, 1, &rows, NULL); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpdbf", n) == 0 && (nArg == 4)) { /* dumping a spatial table to DBF */ char *table = azArg[1]; char *dbf_path = azArg[2]; char *outCS = azArg[3]; open_db (p); dump_dbf (p->db, table, dbf_path, outCS, NULL); } else if (c == 'd' && n > 1 && strncmp (azArg[0], "dumpkml", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7)) { /* dumping a spatial table as KML file */ char *table = azArg[1]; char *geom = azArg[2]; ................................................................................ if (nArg == 6) precision = atoi (azArg[5]); open_db (p); dump_geojson (p->db, table, geom, gml_path, precision, format); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadshp", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7 || nArg == 8 || nArg == 9 || nArg == 10 || nArg == 11 || nArg == 12)) { char *shp_path = azArg[1]; char *table = azArg[2]; char *inCS = azArg[3]; int srid = -1; int coerce2d = 0; int compressed = 0; int with_spatial_index = 0; int text_dates = 0; char *column = NULL; char *gtype = NULL; char *pk = NULL; int rows; if (nArg >= 5) srid = atoi (azArg[4]); if (nArg >= 6) column = azArg[5]; if (nArg >= 7) pk = azArg[6]; ................................................................................ gtype = azArg[7]; if (nArg >= 9) { if (strcasecmp (azArg[8], "2d") == 0) coerce2d = 1; } if (nArg >= 10) { if (strcasecmp (azArg[9], "compressed") == 0) compressed = 1; } if (nArg == 11) with_spatial_index = 1; if (nArg == 12) text_dates = atoi(azArg[11]); open_db (p); load_shapefile_ex2 (p->db, shp_path, table, inCS, srid, column, gtype, pk, coerce2d, compressed, 1, with_spatial_index, text_dates, &rows, NULL); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loaddbf", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6)) { char *dbf_path = azArg[1]; char *table = azArg[2]; char *inCS = azArg[3]; char *pk = NULL; int text_dates = 0; int rows; if (nArg == 5) pk = azArg[4]; if (nArg == 6) text_dates = atoi(azArg[5]); open_db (p); load_dbf_ex2 (p->db, dbf_path, table, pk, inCS, 1, text_dates, &rows, NULL); } #ifndef OMIT_FREEXL /* FREEXL is enabled */ else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadxl", n) == 0 && (nArg == 3 || nArg == 4 || nArg == 5)) { unsigned int rows; char *xl_path = azArg[1]; ................................................................................ open_db (p); load_XL (p->db, xl_path, table, worksheet, firstLine, &rows, NULL); } #endif /* end FREEXL support */ else if (c == 'l' && n > 1 && strncmp (azArg[0], "loadwfs", n) == 0 && (nArg == 4 || nArg == 5 || nArg == 6 || nArg == 7 || nArg == 8)) { char *path_or_url = azArg[1]; char *layer_name = azArg[2]; char *table = azArg[3]; int swap_axes = 0; int with_spatial_index = 0; int page_size = -1; char *pk = NULL; char *err_msg = NULL; int rows; if (nArg >= 5) pk = azArg[4]; if (nArg >= 6) { if (strcasecmp(azArg[5], "swap") == 0 || strcasecmp(azArg[5], "swap_axis") == 0 || strcasecmp(azArg[5], "swap_axes") == 0) swap_axes = 1; } if (nArg >= 7) page_size = atoi(azArg[6]); if (nArg == 8) with_spatial_index = 1; open_db (p); if (load_from_wfs_paged (p->db, path_or_url, NULL, layer_name, swap_axes, table, pk, with_spatial_index, page_size, &rows, &err_msg, wfs_page_done, NULL) == 0) { fprintf(stderr, "Unable to load data from WFS:\n"); fprintf(stderr, "%s\n\n", err_msg); } else fprintf(stderr, "inserted %d rows from WFS into table \"%s\"\n\n", rows, table); if (err_msg) free(err_msg); } else if (c == 'l' && n > 1 && strncmp (azArg[0], "loaddxf", n) == 0 && (nArg == 2 || (nArg >= 3 && nArg <= 9))) { char *dxf_path = azArg[1]; int srid = -1; int append = 0; int special_rings = GAIA_DXF_RING_NONE; int mode = GAIA_DXF_IMPORT_BY_LAYER; int force_dims = GAIA_DXF_AUTO_2D_3D; char *prefix = NULL; char *layer_name = NULL; gaiaDxfParserPtr dxf = NULL; if (nArg >= 3) srid = atoi(azArg[2]); if (nArg >= 4) { if (strcasecmp(azArg[3], "y") == 0 || strcasecmp(azArg[3], "yes") == 0) append = 1; } if (nArg >= 5) { if (strcasecmp(azArg[4], "2D") == 0) force_dims = GAIA_DXF_FORCE_2D; if (strcasecmp(azArg[4], "3D") == 0) force_dims = GAIA_DXF_FORCE_3D; } if (nArg >= 6) { if (strcasecmp(azArg[5], "mixed") == 0) mode = GAIA_DXF_IMPORT_MIXED; } if (nArg >= 7) { if (strcasecmp(azArg[6], "linked") == 0) special_rings = GAIA_DXF_RING_LINKED; if (strcasecmp(azArg[6], "unlinked") == 0) special_rings = GAIA_DXF_RING_UNLINKED; } if (nArg >= 8) { if (strlen(azArg[7]) > 0) prefix = azArg[7]; } if (nArg == 9) { if (strlen(azArg[8]) > 0) layer_name = azArg[8]; } open_db (p); /* creating a DXF parser */ dxf = gaiaCreateDxfParser (srid, force_dims, prefix, layer_name, special_rings); if (dxf == NULL) goto stop_dxf; /* attempting to parse the DXF input file */ if (gaiaParseDxfFile_r (splite_cache, dxf, dxf_path)) { /* loading into the DB */ if (!gaiaLoadFromDxfParser (p->db, dxf, mode, append)) fprintf (stderr, "DB error while loading: %s\n", dxf_path); } else fprintf (stderr, "Unable to parse: %s\n", dxf_path); fprintf(stderr, "\n*** DXF file successfully loaded\n"); stop_dxf: /* destroying the DXF parser */ gaiaDestroyDxfParser (dxf); } else if (c == 'r' && strncmp (azArg[0], "read", n) == 0) { FILE *alt; if (nArg != 3) { fprintf (stderr, "invalid arguments: .read script_path charset\n"); return rc; } alt = fopen (azArg[1], "rb"); if (alt == 0) { fprintf (stderr, "can't open \"%s\"\n", azArg[1]); } else { process_input (p, alt, azArg[2]); fclose (alt); } } else if (c == 'c' && strncmp (azArg[0], "chkdupl", n) == 0 && nArg == 2) { int rows; char *table = azArg[1]; ................................................................................ else if (c == 'c' && strncmp (azArg[0], "checkgeom", n) == 0 && nArg == 4) { char *table = azArg[1]; char *geometry = azArg[2]; char *report = azArg[3]; char *err_msg = NULL; open_db (p); if (!check_geometry_column (p->db, table, geometry, report, NULL, NULL, &err_msg)) { fprintf(stderr, "check_geometry_column error:\n"); fprintf(stderr, "%s\n\n", err_msg); } if (err_msg) free(err_msg); } else if (c == 'c' && strncmp (azArg[0], "checkgeom", n) == 0 && nArg == 2) { char *output_dir = azArg[1]; char *err_msg = NULL; open_db (p); if (!check_all_geometry_columns (p->db, output_dir, NULL, &err_msg)) { fprintf(stderr, "check_all_geometry_columns error:\n"); fprintf(stderr, "%s\n\n", err_msg); } if (err_msg) free(err_msg); } else if (c == 's' && strncmp (azArg[0], "sanegeom", n) == 0 && nArg == 5) { char *table = azArg[1]; char *geometry = azArg[2]; char *tmp_table = azArg[3]; char *report = azArg[4]; char *err_msg = NULL; open_db (p); if (!sanitize_geometry_column (p->db, table, geometry, tmp_table, report, NULL, NULL, NULL, NULL, &err_msg)) { fprintf(stderr, "sanitize_geometry_column error:\n"); fprintf(stderr, "%s\n\n", err_msg); } if (err_msg) free(err_msg); } else if (c == 's' && strncmp (azArg[0], "sanegeom", n) == 0 && nArg == 3) { char *tmp_prefix = azArg[1]; char *output_dir = azArg[2]; char *err_msg = NULL; open_db (p); if (!sanitize_all_geometry_columns (p->db, tmp_prefix, output_dir, NULL, &err_msg)) { fprintf(stderr, "sanitize_all_geometry_columns error:\n"); fprintf(stderr, "%s\n\n", err_msg); } if (err_msg) free(err_msg); } else if (c == 'e' && strncmp (azArg[0], "elemgeo", n) == 0 && nArg == 6) { char *inTable = azArg[1]; char *geom = azArg[2]; char *outTable = azArg[3]; char *pKey = azArg[4]; ................................................................................ } else if (c == 's' && strncmp (azArg[0], "sqllog", n) == 0 && nArg > 1) { sql_log_enabled = booleanValue (azArg[1]); } else if (c == 'd' && strncmp (azArg[0], "dropgeo", n) == 0 && nArg > 1) { char *prefix; char *table; int ret; int cnt0 = sqlite3_total_changes(p->db); split_drop_name(azArg[1], &prefix, &table); if (prefix != NULL && table != NULL) ret = gaiaDropTableEx (p->db, prefix, table); else ret = gaiaDropTable (p->db, azArg[1]); if (ret) { int cnt1 = sqlite3_total_changes(p->db); if (cnt1 > cnt0) fprintf(stderr, "SpatialTable %s successfully removed\n", azArg[1]); else fprintf(stderr, "SpatialTable %s seems not to exist\n", azArg[1]); } else fprintf(stderr, "ERROR: unable to remove SpatialTable %s\n", azArg[1]); if (prefix != NULL) free(prefix); if (table != NULL) free(table); } else /* end sandro 2008-06-20 */ if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 && nArg>1 && nArg<4){ const char *zDestFile; const char *zDb; sqlite3 *pDest; sqlite3_backup *pBackup; if( nArg==2 ){ zDestFile = azArg[1]; zDb = "main"; }else{ zDestFile = azArg[2]; zDb = azArg[1]; } rc = sqlite3_open(zDestFile, &pDest); if( rc!=SQLITE_OK ){ fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile); sqlite3_close(pDest); return 1; } open_db(p); pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); sqlite3_close(pDest); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){} sqlite3_backup_finish(pBackup); if( rc==SQLITE_DONE ){ rc = 0; }else{ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); rc = 1; } sqlite3_close(pDest); }else if( c=='b' && n>=3 && strncmp(azArg[0], "bail", n)==0 && nArg>1 && nArg<3 ){ bail_on_error = booleanValue(azArg[1]); }else /* The undocumented ".breakpoint" command causes a call to the no-op ** routine named test_breakpoint(). */ if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ test_breakpoint(); }else if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){ struct callback_data data; char *zErrMsg = 0; open_db(p); memcpy(&data, p, sizeof(data)); data.showHeader = 1; data.mode = MODE_Column; data.colWidth[0] = 3; data.colWidth[1] = 15; data.colWidth[2] = 58; data.cnt = 0; sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } }else if( c=='d' && strncmp(azArg[0], "dump", n)==0 && nArg<3 ){ open_db(p); /* When playing back a "dump", the content might appear in an order ** which causes immediate foreign key constraints to be violated. ** So disable foreign-key constraint enforcement to prevent problems. */ fprintf(p->out, "PRAGMA foreign_keys=OFF;\n"); fprintf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; if( nArg==1 ){ run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'" ); run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " "WHERE name=='sqlite_sequence'" ); run_table_dump_query(p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0 ); }else{ int i; for(i=1; i<nArg; i++){ zShellStatic = azArg[i]; run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " "WHERE tbl_name LIKE shellstatic() AND type=='table'" " AND sql NOT NULL"); run_table_dump_query(p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL" " AND type IN ('index','trigger','view')" " AND tbl_name LIKE shellstatic()", 0 ); zShellStatic = 0; } } if( p->writableSchema ){ fprintf(p->out, "PRAGMA writable_schema=OFF;\n"); p->writableSchema = 0; } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0); fprintf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); }else if( c=='e' && strncmp(azArg[0], "echo", n)==0 && nArg>1 && nArg<3 ){ p->echoOn = booleanValue(azArg[1]); }else if( c=='e' && strncmp(azArg[0], "exit", n)==0 && nArg==1 ){ rc = 2; }else if( c=='e' && strncmp(azArg[0], "explain", n)==0 && nArg<3 ){ int val = nArg>=2 ? booleanValue(azArg[1]) : 1; if(val == 1) { if(!p->explainPrev.valid) { p->explainPrev.valid = 1; p->explainPrev.mode = p->mode; p->explainPrev.showHeader = p->showHeader; memcpy(p->explainPrev.colWidth,p->colWidth,sizeof(p->colWidth)); } /* We could put this code under the !p->explainValid ** condition so that it does not execute if we are already in ** explain mode. However, always executing it allows us an easy ** was to reset to explain mode in case the user previously ** did an .explain followed by a .width, .mode or .header ** command. */ p->mode = MODE_Explain; p->showHeader = 1; memset(p->colWidth,0,ArraySize(p->colWidth)); p->colWidth[0] = 4; /* addr */ p->colWidth[1] = 13; /* opcode */ p->colWidth[2] = 4; /* P1 */ p->colWidth[3] = 4; /* P2 */ p->colWidth[4] = 4; /* P3 */ p->colWidth[5] = 13; /* P4 */ p->colWidth[6] = 2; /* P5 */ p->colWidth[7] = 13; /* Comment */ }else if (p->explainPrev.valid) { p->explainPrev.valid = 0; p->mode = p->explainPrev.mode; p->showHeader = p->explainPrev.showHeader; memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth)); } }else if( c=='h' && (strncmp(azArg[0], "header", n)==0 || strncmp(azArg[0], "headers", n)==0) && nArg>1 && nArg<3 ){ p->showHeader = booleanValue(azArg[1]); }else if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ fprintf(stderr,"%s",zHelp); if( HAS_TIMER ){ fprintf(stderr,"%s",zTimerHelp); } }else if( c=='i' && strncmp(azArg[0], "import", n)==0 && nArg==3 ){ char *zTable = azArg[2]; /* Insert data into this table */ char *zFile = azArg[1]; /* The file from which to extract data */ sqlite3_stmt *pStmt = NULL; /* A statement */ int nCol; /* Number of columns in the table */ int nByte; /* Number of bytes in an SQL string */ int i, j; /* Loop counters */ int nSep; /* Number of bytes in p->separator[] */ char *zSql; /* An SQL statement */ char *zLine; /* A single line of input from the file */ char **azCol; /* zLine[] broken up into columns */ char *zCommit; /* How to commit changes */ FILE *in; /* The input file */ int lineno = 0; /* Line number of input file */ open_db(p); nSep = strlen30(p->separator); if( nSep==0 ){ fprintf(stderr, "Error: non-null separator required for import\n"); return 1; } zSql = sqlite3_mprintf("SELECT * FROM %s", zTable); if( zSql==0 ){ fprintf(stderr, "Error: out of memory\n"); return 1; } nByte = strlen30(zSql); rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ if (pStmt) sqlite3_finalize(pStmt); fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); return 1; } nCol = sqlite3_column_count(pStmt); sqlite3_finalize(pStmt); pStmt = 0; if( nCol==0 ) return 0; /* no columns, no error */ zSql = malloc( nByte + 20 + nCol*2 ); if( zSql==0 ){ fprintf(stderr, "Error: out of memory\n"); return 1; } sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zTable); j = strlen30(zSql); for(i=1; i<nCol; i++){ zSql[j++] = ','; zSql[j++] = '?'; } zSql[j++] = ')'; zSql[j] = 0; rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); free(zSql); if( rc ){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); if (pStmt) sqlite3_finalize(pStmt); return 1; } in = fopen(zFile, "rb"); if( in==0 ){ fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); sqlite3_finalize(pStmt); return 1; } azCol = malloc( sizeof(azCol[0])*(nCol+1) ); if( azCol==0 ){ fprintf(stderr, "Error: out of memory\n"); fclose(in); sqlite3_finalize(pStmt); return 1; } sqlite3_exec(p->db, "BEGIN", 0, 0, 0); zCommit = "COMMIT"; while( (zLine = local_getline(0, in, 1))!=0 ){ char *z, c; int inQuote = 0; lineno++; azCol[0] = zLine; for(i=0, z=zLine; (c = *z)!=0; z++){ if( c=='"' ) inQuote = !inQuote; if( c=='\n' ) lineno++; if( !inQuote && c==p->separator[0] && strncmp(z,p->separator,nSep)==0 ){ *z = 0; i++; if( i<nCol ){ azCol[i] = &z[nSep]; z += nSep-1; } } } /* end for */ *z = 0; if( i+1!=nCol ){ fprintf(stderr, "Error: %s line %d: expected %d columns of data but found %d\n", zFile, lineno, nCol, i+1); zCommit = "ROLLBACK"; free(zLine); rc = 1; break; /* from while */ } for(i=0; i<nCol; i++){ if( azCol[i][0]=='"' ){ int k; for(z=azCol[i], j=1, k=0; z[j]; j++){ if( z[j]=='"' ){ j++; if( z[j]==0 ) break; } z[k++] = z[j]; } z[k] = 0; } sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC); } sqlite3_step(pStmt); rc = sqlite3_reset(pStmt); free(zLine); if( rc!=SQLITE_OK ){ fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); zCommit = "ROLLBACK"; rc = 1; break; /* from while */ } } /* end while */ free(azCol); fclose(in); sqlite3_finalize(pStmt); sqlite3_exec(p->db, zCommit, 0, 0, 0); }else if( c=='i' && strncmp(azArg[0], "indices", n)==0 && nArg<3 ){ struct callback_data data; char *zErrMsg = 0; open_db(p); memcpy(&data, p, sizeof(data)); data.showHeader = 0; data.mode = MODE_List; if( nArg==1 ){ rc = sqlite3_exec(p->db, "SELECT name FROM sqlite_master " "WHERE type='index' AND name NOT LIKE 'sqlite_%' " "UNION ALL " "SELECT name FROM sqlite_temp_master " "WHERE type='index' " "ORDER BY 1", callback, &data, &zErrMsg ); }else{ zShellStatic = azArg[1]; rc = sqlite3_exec(p->db, "SELECT name FROM sqlite_master " "WHERE type='index' AND tbl_name LIKE shellstatic() " "UNION ALL " "SELECT name FROM sqlite_temp_master " "WHERE type='index' AND tbl_name LIKE shellstatic() " "ORDER BY 1", callback, &data, &zErrMsg ); zShellStatic = 0; } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n"); rc = 1; } }else #ifdef SQLITE_ENABLE_IOTRACE if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){ extern void (*sqlite3IoTrace)(const char*, ...); if( iotrace && iotrace!=stdout ) fclose(iotrace); iotrace = 0; if( nArg<2 ){ sqlite3IoTrace = 0; }else if( strcmp(azArg[1], "-")==0 ){ sqlite3IoTrace = iotracePrintf; iotrace = stdout; }else{ iotrace = fopen(azArg[1], "w"); if( iotrace==0 ){ fprintf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); sqlite3IoTrace = 0; rc = 1; }else{ sqlite3IoTrace = iotracePrintf; } } }else #endif if( c=='l' && strncmp(azArg[0], "log", n)==0 && nArg>=2 ){ const char *zFile = azArg[1]; output_file_close(p->pLog); p->pLog = output_file_open(zFile); }else if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg==2 ){ int n2 = strlen30(azArg[1]); if( (n2==4 && strncmp(azArg[1],"line",n2)==0) || (n2==5 && strncmp(azArg[1],"lines",n2)==0) ){ p->mode = MODE_Line; }else if( (n2==6 && strncmp(azArg[1],"column",n2)==0) || (n2==7 && strncmp(azArg[1],"columns",n2)==0) ){ p->mode = MODE_Column; }else if( n2==4 && strncmp(azArg[1],"list",n2)==0 ){ p->mode = MODE_List; }else if( n2==4 && strncmp(azArg[1],"html",n2)==0 ){ p->mode = MODE_Html; }else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){ p->mode = MODE_Tcl; }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){ p->mode = MODE_Csv; sqlite3_snprintf(sizeof(p->separator), p->separator, ","); }else if( n2==4 && strncmp(azArg[1],"tabs",n2)==0 ){ p->mode = MODE_List; sqlite3_snprintf(sizeof(p->separator), p->separator, "\t"); }else if( n2==6 && strncmp(azArg[1],"insert",n2)==0 ){ p->mode = MODE_Insert; set_table_name(p, "table"); }else { fprintf(stderr,"Error: mode should be one of: " "column csv html insert line list tabs tcl\n"); rc = 1; } }else if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg==3 ){ int n2 = strlen30(azArg[1]); if( n2==6 && strncmp(azArg[1],"insert",n2)==0 ){ p->mode = MODE_Insert; set_table_name(p, azArg[2]); }else { fprintf(stderr, "Error: invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[2]); rc = 1; } }else if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 && nArg==2 ) { sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue, "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]); }else if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){ if( p->outfile[0]=='|' ){ pclose(p->out); }else{ output_file_close(p->out); } p->outfile[0] = 0; if( azArg[1][0]=='|' ){ p->out = popen(&azArg[1][1], "w"); if( p->out==0 ){ fprintf(stderr,"Error: cannot open pipe \"%s\"\n", &azArg[1][1]); p->out = stdout; rc = 1; }else{ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]); } }else{ p->out = output_file_open(azArg[1]); if( p->out==0 ){ if( strcmp(azArg[1],"off")!=0 ){ fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]); } p->out = stdout; rc = 1; } else { sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]); } } }else if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){ if( nArg >= 2) { strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1); } if( nArg >= 3) { strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1); } }else if( c=='q' && strncmp(azArg[0], "quit", n)==0 && nArg==1 ){ rc = 2; }else if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 && nArg==2 ){ FILE *alt = fopen(azArg[1], "rb"); if( alt==0 ){ fprintf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); rc = 1; }else{ rc = process_input(p, alt, 0); fclose(alt); } }else if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 && nArg>1 && nArg<4){ const char *zSrcFile; const char *zDb; sqlite3 *pSrc; sqlite3_backup *pBackup; int nTimeout = 0; if( nArg==2 ){ zSrcFile = azArg[1]; zDb = "main"; }else{ zSrcFile = azArg[2]; zDb = azArg[1]; } rc = sqlite3_open(zSrcFile, &pSrc); if( rc!=SQLITE_OK ){ fprintf(stderr, "Error: cannot open \"%s\"\n", zSrcFile); sqlite3_close(pSrc); return 1; } open_db(p); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_close(pSrc); return 1; } while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK || rc==SQLITE_BUSY ){ if( rc==SQLITE_BUSY ){ if( nTimeout++ >= 3 ) break; sqlite3_sleep(100); } } sqlite3_backup_finish(pBackup); if( rc==SQLITE_DONE ){ rc = 0; }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){ fprintf(stderr, "Error: source database is busy\n"); rc = 1; }else{ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; } sqlite3_close(pSrc); }else if( c=='s' && strncmp(azArg[0], "schema", n)==0 && nArg<3 ){ struct callback_data data; char *zErrMsg = 0; open_db(p); memcpy(&data, p, sizeof(data)); data.showHeader = 0; data.mode = MODE_Semi; if( nArg>1 ){ int i; for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]); if( strcmp(azArg[1],"sqlite_master")==0 ){ char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TABLE sqlite_master (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" " sql text\n" ")"; new_argv[1] = 0; new_colv[0] = "sql"; new_colv[1] = 0; callback(&data, 1, new_argv, new_colv); rc = SQLITE_OK; }else if( strcmp(azArg[1],"sqlite_temp_master")==0 ){ char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TEMP TABLE sqlite_temp_master (\n" " type text,\n" " name text,\n" " tbl_name text,\n" " rootpage integer,\n" " sql text\n" ")"; new_argv[1] = 0; new_colv[0] = "sql"; new_colv[1] = 0; callback(&data, 1, new_argv, new_colv); rc = SQLITE_OK; }else{ zShellStatic = azArg[1]; rc = sqlite3_exec(p->db, "SELECT sql FROM " " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" " FROM sqlite_master UNION ALL" " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " "WHERE lower(tbl_name) LIKE shellstatic()" " AND type!='meta' AND sql NOTNULL " "ORDER BY substr(type,2,1), " " CASE type WHEN 'view' THEN rowid ELSE name END", callback, &data, &zErrMsg); zShellStatic = 0; } }else{ rc = sqlite3_exec(p->db, "SELECT sql FROM " " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" " FROM sqlite_master UNION ALL" " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'" "ORDER BY substr(type,2,1)," " CASE type WHEN 'view' THEN rowid ELSE name END", callback, &data, &zErrMsg ); } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ fprintf(stderr,"Error: querying schema information\n"); rc = 1; }else{ rc = 0; } }else if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){ sqlite3_snprintf(sizeof(p->separator), p->separator, "%.*s", (int)sizeof(p->separator)-1, azArg[1]); }else if( c=='s' && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0) ){ char *zCmd; int i; if( nArg<2 ){ fprintf(stderr, "Usage: .system COMMAND\n"); rc = 1; } else { zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]); for(i=2; i<nArg; i++){ zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"", zCmd, azArg[i]); } (void)system(zCmd); sqlite3_free(zCmd); } }else if( c=='s' && strncmp(azArg[0], "show", n)==0 && nArg==1 ){ int i; fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off"); fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" :"off"); fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off"); fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]); fprintf(p->out,"%9.9s: ", "nullvalue"); output_c_string(p->out, p->nullvalue); fprintf(p->out, "\n"); fprintf(p->out,"%9.9s: %s\n","output", strlen30(p->outfile) ? p->outfile : "stdout"); fprintf(p->out,"%9.9s: ", "separator"); output_c_string(p->out, p->separator); fprintf(p->out, "\n"); fprintf(p->out,"%9.9s: %s\n","stats", p->statsOn ? "on" : "off"); fprintf(p->out,"%9.9s: ","width"); for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) { fprintf(p->out,"%d ",p->colWidth[i]); } fprintf(p->out,"\n"); }else if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){ p->statsOn = booleanValue(azArg[1]); }else if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){ sqlite3_stmt *pStmt; char **azResult; int nRow, nAlloc; char *zSql = 0; int ii; open_db(p); rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0); if( rc ) return rc; zSql = sqlite3_mprintf( "SELECT name FROM sqlite_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1"); while( sqlite3_step(pStmt)==SQLITE_ROW ){ const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1); if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue; if( strcmp(zDbName,"temp")==0 ){ zSql = sqlite3_mprintf( "%z UNION ALL " "SELECT 'temp.' || name FROM sqlite_temp_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1", zSql); }else{ zSql = sqlite3_mprintf( "%z UNION ALL " "SELECT '%q.' || name FROM \"%w\".sqlite_master" " WHERE type IN ('table','view')" " AND name NOT LIKE 'sqlite_%%'" " AND name LIKE ?1", zSql, zDbName, zDbName); } } sqlite3_finalize(pStmt); zSql = sqlite3_mprintf("%z ORDER BY 1", zSql); rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ) return rc; nRow = nAlloc = 0; azResult = 0; if( nArg>1 ){ sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT); }else{ sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC); } while( sqlite3_step(pStmt)==SQLITE_ROW ){ if( nRow>=nAlloc ){ char **azNew; int n = nAlloc*2 + 10; azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n); if( azNew==0 ){ fprintf(stderr, "Error: out of memory\n"); break; } nAlloc = n; azResult = azNew; } azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0)); if( azResult[nRow] ) nRow++; } sqlite3_finalize(pStmt); if( nRow>0 ){ int len, maxlen = 0; int i, j; int nPrintCol, nPrintRow; for(i=0; i<nRow; i++){ len = strlen30(azResult[i]); if( len>maxlen ) maxlen = len; } nPrintCol = 80/(maxlen+2); if( nPrintCol<1 ) nPrintCol = 1; nPrintRow = (nRow + nPrintCol - 1)/nPrintCol; for(i=0; i<nPrintRow; i++){ for(j=i; j<nRow; j+=nPrintRow){ char *zSp = j<nPrintRow ? "" : " "; printf("%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : ""); } printf("\n"); } } for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]); sqlite3_free(azResult); }else if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){ static const struct { const char *zCtrlName; /* Name of a test-control option */ int ctrlCode; /* Integer code for that option */ } aCtrl[] = { { "prng_save", SQLITE_TESTCTRL_PRNG_SAVE }, { "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE }, { "prng_reset", SQLITE_TESTCTRL_PRNG_RESET }, { "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST }, { "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL }, { "benign_malloc_hooks", SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS }, { "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE }, { "assert", SQLITE_TESTCTRL_ASSERT }, { "always", SQLITE_TESTCTRL_ALWAYS }, { "reserve", SQLITE_TESTCTRL_RESERVE }, { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS }, { "iskeyword", SQLITE_TESTCTRL_ISKEYWORD }, { "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC }, }; int testctrl = -1; int rc = 0; int i, n; open_db(p); /* convert testctrl text option to value. allow any unique prefix ** of the option name, or a numerical value. */ n = strlen30(azArg[1]); for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){ if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){ if( testctrl<0 ){ testctrl = aCtrl[i].ctrlCode; }else{ fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); testctrl = -1; break; } } } if( testctrl<0 ) testctrl = atoi(azArg[1]); if( (testctrl<SQLITE_TESTCTRL_FIRST) || (testctrl>SQLITE_TESTCTRL_LAST) ){ fprintf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]); }else{ switch(testctrl){ /* sqlite3_test_control(int, db, int) */ case SQLITE_TESTCTRL_OPTIMIZATIONS: case SQLITE_TESTCTRL_RESERVE: if( nArg==3 ){ int opt = (int)strtol(azArg[2], 0, 0); rc = sqlite3_test_control(testctrl, p->db, opt); printf("%d (0x%08x)\n", rc, rc); } else { fprintf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; /* sqlite3_test_control(int) */ case SQLITE_TESTCTRL_PRNG_SAVE: case SQLITE_TESTCTRL_PRNG_RESTORE: case SQLITE_TESTCTRL_PRNG_RESET: if( nArg==2 ){ rc = sqlite3_test_control(testctrl); printf("%d (0x%08x)\n", rc, rc); } else { fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]); } break; /* sqlite3_test_control(int, uint) */ case SQLITE_TESTCTRL_PENDING_BYTE: if( nArg==3 ){ unsigned int opt = (unsigned int)atoi(azArg[2]); rc = sqlite3_test_control(testctrl, opt); printf("%d (0x%08x)\n", rc, rc); } else { fprintf(stderr,"Error: testctrl %s takes a single unsigned" " int option\n", azArg[1]); } break; /* sqlite3_test_control(int, int) */ case SQLITE_TESTCTRL_ASSERT: case SQLITE_TESTCTRL_ALWAYS: if( nArg==3 ){ int opt = atoi(azArg[2]); rc = sqlite3_test_control(testctrl, opt); printf("%d (0x%08x)\n", rc, rc); } else { fprintf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; /* sqlite3_test_control(int, char *) */ #ifdef SQLITE_N_KEYWORD case SQLITE_TESTCTRL_ISKEYWORD: if( nArg==3 ){ const char *opt = azArg[2]; rc = sqlite3_test_control(testctrl, opt); printf("%d (0x%08x)\n", rc, rc); } else { fprintf(stderr,"Error: testctrl %s takes a single char * option\n", azArg[1]); } break; #endif case SQLITE_TESTCTRL_BITVEC_TEST: case SQLITE_TESTCTRL_FAULT_INSTALL: case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: case SQLITE_TESTCTRL_SCRATCHMALLOC: default: fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", azArg[1]); break; } } }else if( c=='t' && n>4 && strncmp(azArg[0], "timeout", n)==0 && nArg==2 ){ open_db(p); sqlite3_busy_timeout(p->db, atoi(azArg[1])); }else if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0 && nArg==2 ){ enableTimer = booleanValue(azArg[1]); }else if( c=='t' && strncmp(azArg[0], "trace", n)==0 && nArg>1 ){ open_db(p); output_file_close(p->traceOut); p->traceOut = output_file_open(azArg[1]); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ sqlite3_trace(p->db, 0, 0); }else{ sqlite3_trace(p->db, sql_trace_callback, p->traceOut); } #endif }else if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ printf("SQLite %s %s\n" /*extra-version-info*/, sqlite3_libversion(), sqlite3_sourceid()); }else if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){ const char *zDbName = nArg==2 ? azArg[1] : "main"; char *zVfsName = 0; if( p->db ){ /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_FCNTL_VFSNAME sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName); if( zVfsName ){ printf("%s\n", zVfsName); sqlite3_free(zVfsName); } #else printf("FCNTL_VFSNAME: unsupported\n"); #endif /* end sandro 1 November 2012 */ } }else if( c=='w' && strncmp(azArg[0], "width", n)==0 && nArg>1 ){ int j; assert( nArg<=ArraySize(azArg) ); for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){ p->colWidth[j-1] = atoi(azArg[j]); } }else { fprintf(stderr, "Error: unknown command or invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[0]); rc = 1; } return rc; } /* ** Return TRUE if a semicolon occurs anywhere in the first N characters ** of string z[]. */ static int _contains_semicolon(const char *z, int N){ int i; for(i=0; i<N; i++){ if( z[i]==';' ) return 1; } return 0; } /* ** Test to see if a line consists entirely of whitespace. */ static int _all_whitespace(const char *z){ for(; *z; z++){ if( IsSpace(z[0]) ) continue; if( *z=='/' && z[1]=='*' ){ z += 2; while( *z && (*z!='*' || z[1]!='/') ){ z++; } if( *z==0 ) return 0; z++; continue; } if( *z=='-' && z[1]=='-' ){ z += 2; while( *z && *z!='\n' ){ z++; } if( *z==0 ) return 1; continue; } return 0; } return 1; } /* ** Return TRUE if the line typed in is an SQL command terminator other ** than a semi-colon. The SQL Server style "go" command is understood ** as is the Oracle "/". */ static int _is_command_terminator(const char *zLine){ while( IsSpace(zLine[0]) ){ zLine++; }; if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){ return 1; /* Oracle */ } if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o' && _all_whitespace(&zLine[2]) ){ return 1; /* SQL Server */ } return 0; } /* ** Return true if zSql is a complete SQL statement. Return false if it ** ends in the middle of a string literal or C-style comment. */ static int _is_complete(char *zSql, int nSql){ int rc; if( zSql==0 ) return 1; zSql[nSql] = ';'; zSql[nSql+1] = 0; rc = sqlite3_complete(zSql); zSql[nSql] = 0; return rc; } /* ** Read input from *in and process it. If *in==0 then input ** is interactive - the user is typing it it. Otherwise, input ** is coming from a file or device. A prompt is issued and history ** is saved only if input is interactive. An interrupt signal will ** cause this routine to exit immediately, unless input is interactive. ** ** Return the number of errors. */ static int process_input(struct callback_data *p, FILE *in, char *in_charset){ char *zLine = 0; char *zSql = 0; /* Sandro Furieri - 11 July 2008 - supporting UNICODE */ int utf8len; char *utf8Sql = 0; /* End Sandro Furieri - 11 July 2008 */ /* Sandro Furieri - 3 September 2012 - supporting SqlLog */ sqlite3_int64 sqllog_pk; /* End Sandro Furieri - 3 September 2012 - supporting SqlLog */ int nSql = 0; int nSqlPrior = 0; char *zErrMsg; int rc; int errCnt = 0; int lineno = 0; int startline = 0; /* Sandro Furieri - 11 July 2008 - supporting UNICODE */ if (in_charset) create_input_utf8_converter (in_charset); /* End Sandro Furieri - 11 July 2008 */ while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){ fflush(p->out); free(zLine); zLine = one_input_line(zSql, in); if( zLine==0 ){ /* End of input */ if( stdin_is_interactive ) printf("\n"); break; } if( seenInterrupt ){ if( in!=0 ) break; seenInterrupt = 0; } lineno++; if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue; if( zLine && zLine[0]=='.' && nSql==0 ){ if( p->echoOn ) printf("%s\n", zLine); rc = do_meta_command(zLine, p); if( rc==2 ){ /* exit requested */ break; }else if( rc ){ errCnt++; } continue; } if( _is_command_terminator(zLine) && _is_complete(zSql, nSql) ){ memcpy(zLine,";",2); } nSqlPrior = nSql; if( zSql==0 ){ int i; for(i=0; zLine[i] && IsSpace(zLine[i]); i++){} if( zLine[i]!=0 ){ nSql = strlen30(zLine); zSql = malloc( nSql+3 ); if( zSql==0 ){ fprintf(stderr, "Error: out of memory\n"); exit(1); } memcpy(zSql, zLine, nSql+1); startline = lineno; } }else{ int len = strlen30(zLine); zSql = realloc( zSql, nSql + len + 4 ); if( zSql==0 ){ fprintf(stderr,"Error: out of memory\n"); exit(1); } zSql[nSql++] = '\n'; memcpy(&zSql[nSql], zLine, len+1); nSql += len; } if( zSql && _contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior) && sqlite3_complete(zSql) ){ p->cnt = 0; open_db(p); /* Sandro Furieri - 11 July 2008 BEGIN_TIMER; rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg); END_TIMER; */ utf8len = strlen (zSql) * 4; utf8Sql = malloc (utf8len); if (utf8Sql == 0) { fprintf (stderr, "%s: out of memory!\n", Argv0); exit (1); } strncpy (utf8Sql, zSql, utf8len - 1); utf8Sql[utf8len - 1] = '\0'; if (!in_charset) { /* assuming input is locale_charset encoded */ convert_to_utf8 (utf8Sql, utf8len); } else { /* input has an explicit charset */ convert_input_to_utf8 (utf8Sql, utf8len); } if (sql_log_enabled) gaiaInsertIntoSqlLog(p->db, "spatialite CLI", utf8Sql, &sqllog_pk); BEGIN_TIMER; rc = sqlite3_exec (p->db, utf8Sql, callback, p, &zErrMsg); END_TIMER; if (sql_log_enabled) gaiaUpdateSqlLog(p->db, sqllog_pk, (rc == SQLITE_OK) ? 1 : 0, zErrMsg); free (utf8Sql); /* End Sandro Furieri - 11 July 2008 */ if( rc || zErrMsg ){ char zPrefix[100]; if( in!=0 || !stdin_is_interactive ){ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error: near line %d:", startline); }else{ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:"); } if( zErrMsg!=0 ){ fprintf(stderr, "%s %s\n", zPrefix, zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; } free(zSql); zSql = 0; nSql = 0; } } if( zSql ){ if( !_all_whitespace(zSql) ){ fprintf(stderr, "Error: incomplete SQL: %s\n", zSql); } free(zSql); } free(zLine); /* Sandro Furieri - 11 July 2008 */ if (in_charset_to_utf8) { /* destroying input converter, if exists */ iconv_close (in_charset_to_utf8); in_charset_to_utf8 = NULL; } /* End Sandro Furieri - 11 July 2008 */ return errCnt; } /* ** Return a pathname which is the user's home directory. A ** 0 return indicates an error of some kind. */ static char *find_home_dir(void){ static char *home_dir = NULL; if( home_dir ) return home_dir; #if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL) { struct passwd *pwent; uid_t uid = getuid(); if( (pwent=getpwuid(uid)) != NULL) { home_dir = pwent->pw_dir; } } #endif #if defined(_WIN32_WCE) /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv() */ home_dir = "/"; #else #if defined(_WIN32) || defined(WIN32) if (!home_dir) { home_dir = getenv("USERPROFILE"); } #endif if (!home_dir) { home_dir = getenv("HOME"); } #if defined(_WIN32) || defined(WIN32) if (!home_dir) { char *zDrive, *zPath; int n; zDrive = getenv("HOMEDRIVE"); zPath = getenv("HOMEPATH"); if( zDrive && zPath ){ n = strlen30(zDrive) + strlen30(zPath) + 1; home_dir = malloc( n ); if( home_dir==0 ) return 0; sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath); return home_dir; } home_dir = "c:\\"; } #endif #endif /* !_WIN32_WCE */ if( home_dir ){ int n = strlen30(home_dir) + 1; char *z = malloc( n ); if( z ) memcpy(z, home_dir, n); home_dir = z; } return home_dir; } /* ** Read input from the file given by sqliterc_override. Or if that ** parameter is NULL, take input from ~/.sqliterc ** ** Returns the number of errors. */ static int process_sqliterc( struct callback_data *p, /* Configuration data */ const char *sqliterc_override /* Name of config file. NULL to use default */ ){ char *home_dir = NULL; const char *sqliterc = sqliterc_override; char *zBuf = 0; FILE *in = NULL; int rc = 0; if (sqliterc == NULL) { home_dir = find_home_dir(); if( home_dir==0 ){ #if !defined(__RTP__) && !defined(_WRS_KERNEL) fprintf(stderr,"%s: Error: cannot locate your home directory\n", Argv0); #endif return 1; } sqlite3_initialize(); zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir); sqliterc = zBuf; } in = fopen(sqliterc,"rb"); if( in ){ if( stdin_is_interactive ){ fprintf(stderr,"-- Loading resources from %s\n",sqliterc); } rc = process_input(p,in, 0); fclose(in); } sqlite3_free(zBuf); return rc; } /* ** Show available command line options */ static const char zOptions[] = " -bail stop after hitting an error\n" " -batch force batch I/O\n" " -column set output mode to 'column'\n" " -cmd command run \"command\" before reading stdin\n" " -csv set output mode to 'csv'\n" " -echo print commands before execution\n" " -init filename read/process named file\n" " -[no]header turn headers on or off\n" " -help show this message\n" " -html set output mode to HTML\n" " -interactive force interactive I/O\n" " -line set output mode to 'line'\n" " -list set output mode to 'list'\n" " -silent suppress the welcome message\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -nullvalue 'text' set text string for NULL values\n" " -separator 'x' set output field separator (|)\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif ; static void usage(int showDetail){ fprintf(stderr, "Usage: %s [OPTIONS] FILENAME [SQL]\n" "FILENAME is the name of an SQLite database. A new database is created\n" "if the file does not previously exist.\n", Argv0); if( showDetail ){ fprintf(stderr, "OPTIONS include:\n%s", zOptions); }else{ fprintf(stderr, "Use the -help option for additional information\n"); } exit(1); } /* ** Initialize the state information in data */ static void main_init(struct callback_data *data) { memset(data, 0, sizeof(*data)); data->mode = MODE_List; memcpy(data->separator,"|", 2); data->showHeader = 0; /* Sandro Furieri 1 November 2012 - depending on SQLite version */ #ifdef HAVE_DECL_SQLITE_CONFIG_URI sqlite3_config(SQLITE_CONFIG_URI, 1); #endif /* end sandro 1 November 2012 */ sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"spatialite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); } int main(int argc, char **argv){ char *zErrMsg = 0; struct callback_data data; const char *zInitFile = 0; char *zFirstCmd = 0; int i; int rc = 0; /* initializing the SpatiaLite's internal cache */ splite_cache = spatialite_alloc_connection (); if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } Argv0 = argv[0]; main_init(&data); /* Sandro Furieri 30 May 2008 =========================== registering the SpatiaLite extension 2013-08-30: supporting "silent mode" */ for(i=1; i<argc && argv[i][0]=='-'; i++){ char *z = argv[i]; if( z[1]=='-' ){ z++; } if( strcmp(z,"-silent")==0 ){ splite_silent = 1;} } stdin_is_interactive = isatty(0); /* Make sure we have a valid signal handler early, before anything ** else is done. */ #ifdef SIGINT signal(SIGINT, interrupt_handler); #endif /* Do an initial pass through the command-line argument to locate ** the name of the database file, the name of the initialization file, ** the size of the alternative malloc heap, ** and the first command to execute. */ for(i=1; i<argc-1; i++){ char *z; if( argv[i][0]!='-' ) break; z = argv[i]; if( z[1]=='-' ) z++; if( strcmp(z,"-separator")==0 || strcmp(z,"-nullvalue")==0 || strcmp(z,"-cmd")==0 ){ i++; }else if( strcmp(z,"-init")==0 ){ i++; zInitFile = argv[i]; /* Need to check for batch mode here to so we can avoid printing ** informational messages (like from process_sqliterc) before ** we do the actual processing of arguments later in a second pass. */ }else if( strcmp(z,"-batch")==0 ){ stdin_is_interactive = 0; }else if( strcmp(z,"-heap")==0 ){ #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) int j, c; const char *zSize; sqlite3_int64 szHeap; zSize = argv[++i]; szHeap = atoi(zSize); for(j=0; (c = zSize[j])!=0; j++){ if( c=='M' ){ szHeap *= 1000000; break; } if( c=='K' ){ szHeap *= 1000; break; } if( c=='G' ){ szHeap *= 1000000000; break; } } if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); #endif #ifdef SQLITE_ENABLE_VFSTRACE }else if( strcmp(z,"-vfstrace")==0 ){ extern int vfstrace_register( const char *zTraceName, const char *zOldVfsName, int (*xOut)(const char*,void*), void *pOutArg, int makeDefault ); vfstrace_register("trace",0,(int(*)(const char*,void*))fputs,stderr,1); #endif #ifdef SQLITE_ENABLE_MULTIPLEX }else if( strcmp(z,"-multiplex")==0 ){ extern int sqlite3_multiple_initialize(const char*,int); sqlite3_multiplex_initialize(0, 1); #endif }else if( strcmp(z,"-vfs")==0 ){ sqlite3_vfs *pVfs = sqlite3_vfs_find(argv[++i]); if( pVfs ){ sqlite3_vfs_register(pVfs, 1); }else{ fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]); exit(1); } } } if( i<argc ){ data.zDbFilename = argv[i++]; }else{ #ifndef SQLITE_OMIT_MEMORYDB data.zDbFilename = ":memory:"; #else data.zDbFilename = 0; #endif } if( i<argc ){ zFirstCmd = argv[i++]; } if( i<argc ){ fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]); fprintf(stderr,"Use -help for a list of options.\n"); return 1; } data.out = stdout; #ifdef SQLITE_OMIT_MEMORYDB if( data.zDbFilename==0 ){ fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); return 1; } #endif /* Go ahead and open the database file if it already exists. If the ** file does not exist, delay opening it. This prevents empty database ** files from being created if a user mistypes the database name argument ** to the sqlite command-line tool. */ if( access(data.zDbFilename, 0)==0 ){ open_db(&data); } /* Process the initialization file if there is one. If no -init option ** is given on the command line, look for a file named ~/.sqliterc and ** try to process it. */ rc = process_sqliterc(&data,zInitFile); if( rc>0 ){ return rc; } /* Make a second pass through the command-line argument and set ** options. This second pass is delayed until after the initialization ** file is processed so that the command-line arguments will override ** settings in the initialization file. */ for(i=1; i<argc && argv[i][0]=='-'; i++){ char *z = argv[i]; if( z[1]=='-' ){ z++; } if( strcmp(z,"-init")==0 ){ i++; }else if( strcmp(z,"-html")==0 ){ data.mode = MODE_Html; }else if( strcmp(z,"-list")==0 ){ data.mode = MODE_List; }else if( strcmp(z,"-line")==0 ){ data.mode = MODE_Line; }else if( strcmp(z,"-column")==0 ){ data.mode = MODE_Column; }else if( strcmp(z,"-csv")==0 ){ data.mode = MODE_Csv; memcpy(data.separator,",",2); }else if( strcmp(z,"-separator")==0 ){ i++; if(i>=argc){ fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z); fprintf(stderr,"Use -help for a list of options.\n"); return 1; } sqlite3_snprintf(sizeof(data.separator), data.separator, "%.*s",(int)sizeof(data.separator)-1,argv[i]); }else if( strcmp(z,"-nullvalue")==0 ){ i++; if(i>=argc){ fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z); fprintf(stderr,"Use -help for a list of options.\n"); return 1; } sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue, "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]); }else if( strcmp(z,"-header")==0 ){ data.showHeader = 1; }else if( strcmp(z,"-noheader")==0 ){ data.showHeader = 0; }else if( strcmp(z,"-echo")==0 ){ data.echoOn = 1; }else if( strcmp(z,"-stats")==0 ){ data.statsOn = 1; }else if( strcmp(z,"-bail")==0 ){ bail_on_error = 1; }else if( strcmp(z,"-silent")==0 ){ /* sandro 2013-08-30 */ splite_silent = 1; /* end sandro */ }else if( strcmp(z,"-version")==0 ){ printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid()); return 0; }else if( strcmp(z,"-interactive")==0 ){ stdin_is_interactive = 1; }else if( strcmp(z,"-batch")==0 ){ stdin_is_interactive = 0; }else if( strcmp(z,"-heap")==0 ){ i++; }else if( strcmp(z,"-vfs")==0 ){ i++; #ifdef SQLITE_ENABLE_VFSTRACE }else if( strcmp(z,"-vfstrace")==0 ){ i++; #endif #ifdef SQLITE_ENABLE_MULTIPLEX }else if( strcmp(z,"-multiplex")==0 ){ i++; #endif }else if( strcmp(z,"-help")==0 ){ usage(1); }else if( strcmp(z,"-cmd")==0 ){ if( i==argc-1 ) break; i++; z = argv[i]; if( z[0]=='.' ){ rc = do_meta_command(z, &data); if( rc && bail_on_error ) return rc; }else{ open_db(&data); rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ fprintf(stderr,"Error: %s\n", zErrMsg); if( bail_on_error ) return rc!=0 ? rc : 1; }else if( rc!=0 ){ fprintf(stderr,"Error: unable to process SQL \"%s\"\n", z); if( bail_on_error ) return rc; } } }else{ fprintf(stderr,"%s: Error: unknown option: %s\n", Argv0, z); fprintf(stderr,"Use -help for a list of options.\n"); return 1; } } if( zFirstCmd ){ /* Run just the command that follows the database name */ if( zFirstCmd[0]=='.' ){ rc = do_meta_command(zFirstCmd, &data); }else{ open_db(&data); rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ fprintf(stderr,"Error: %s\n", zErrMsg); return rc!=0 ? rc : 1; }else if( rc!=0 ){ fprintf(stderr,"Error: unable to process SQL \"%s\"\n", zFirstCmd); return rc; } } }else{ /* Run commands received from standard input */ if( stdin_is_interactive ){ char *zHome; char *zHistory = 0; int nHistory; /* Sandro Furieri 2008-11-20 printf( "SQLite version %s %.19s\n" "Enter \".help\" for instructions\n" "Enter SQL statements terminated with a \";\"\n", sqlite3_libversion(), sqlite3_sourceid() ); */ open_db(&data); if (isatty (1)) printf ("SQLite version ......: %s\n", sqlite3_libversion ()); auto_fdo_start (data.db); if (isatty (1)) printf ("Enter \".help\" for instructions\n"); /* end Sandro Furieri 2008-11-20 */ printf( "SQLite version %s %.19s\n" /*extra-version-info*/ "Enter \".help\" for instructions\n" "Enter SQL statements terminated with a \";\"\n", sqlite3_libversion(), sqlite3_sourceid() ); zHome = find_home_dir(); if( zHome ){ nHistory = strlen30(zHome) + 20; if( (zHistory = malloc(nHistory))!=0 ){ sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome); } } #if defined(HAVE_READLINE) && HAVE_READLINE==1 if( zHistory ) read_history(zHistory); #endif rc = process_input(&data, 0, 0); if( zHistory ){ stifle_history(100); write_history(zHistory); free(zHistory); } }else{ rc = process_input(&data, stdin, 0); } } set_table_name(&data, 0); if (data.db) { /* Sandro Furieri 2008-11-20 */ auto_fdo_stop (data.db); /* end Sandro Furieri 2008-11-20 */ if (sqlite3_close (data.db) != SQLITE_OK) { fprintf (stderr, "error closing database: %s\n", sqlite3_errmsg (data.db)); } } /* Sandro Furieri 30 May 2008 =========================== memory cleanup for SpatiaLite extension */ spatialite_cleanup_ex (splite_cache); spatialite_shutdown (); return rc; } |
Changes to shp_doctor.c.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 .... 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 .... 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 |
#ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite/gaiageo.h> #include <spatialite.h> #define ARG_NONE 0 #define ARG_IN_PATH 1 #if defined(_WIN32) && !defined(__MINGW32__) #define strcasecmp _stricmp #endif /* not WIN32 */ ................................................................................ if (fl_dbf) fclose (fl_dbf); if (buf_dbf) free (buf_dbf); return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "shp_doctor ..: %s\n", VERSION); fprintf (stderr, "target CPU ..: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ..: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: shp_doctor ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-i or --in-path pathname the SHP path [no suffix]\n"); fprintf (stderr, " or\n"); fprintf (stderr, " the full DBF path [-dbf]\n"); fprintf (stderr, "\nyou can specify the following options as well\n"); fprintf (stderr, "--analyze *default*\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "--in-path") == 0) { next_arg = ARG_IN_PATH; continue; } if (strcmp (argv[i], "-i") == 0) { |
< < < < < < < < < < < < < < < < < < < < < |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 .... 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 .... 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 |
#ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite/gaiageo.h> #define ARG_NONE 0 #define ARG_IN_PATH 1 #if defined(_WIN32) && !defined(__MINGW32__) #define strcasecmp _stricmp #endif /* not WIN32 */ ................................................................................ if (fl_dbf) fclose (fl_dbf); if (buf_dbf) free (buf_dbf); return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: shp_doctor ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-i or --in-path pathname the SHP path [no suffix]\n"); fprintf (stderr, " or\n"); fprintf (stderr, " the full DBF path [-dbf]\n"); fprintf (stderr, "\nyou can specify the following options as well\n"); fprintf (stderr, "--analyze *default*\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--in-path") == 0) { next_arg = ARG_IN_PATH; continue; } if (strcmp (argv[i], "-i") == 0) { |
Deleted shp_sanitize.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 |
/* / shp_sanitize / / an analysis / sanitizing tool for broken SHAPEFILES / / version 1.0, 2016 April 25 / / Author: Sandro Furieri a.furieri@lqt.it / / Copyright (C) 2016 Alessandro Furieri / / This program is free software: you can redistribute it and/or modify / it under the terms of the GNU General Public License as published by / the Free Software Foundation, either version 3 of the License, or / (at your option) any later version. / / This program is distributed in the hope that it will be useful, / but WITHOUT ANY WARRANTY; without even the implied warranty of / MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / GNU General Public License for more details. / / You should have received a copy of the GNU General Public License / along with this program. If not, see <http://www.gnu.org/licenses/>. / */ #ifndef _WIN32 #include <unistd.h> #endif #if defined(_WIN32) && !defined(__MINGW32__) /* MSVC strictly requires this include [off_t] */ #include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include <float.h> #include <errno.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/types.h> #if defined(_WIN32) && !defined(__MINGW32__) #include <io.h> #include <direct.h> #else #include <dirent.h> #endif #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite/gaiageo.h> #include <spatialite.h> #define ARG_NONE 0 #define ARG_IN_DIR 1 #define ARG_OUT_DIR 2 #define SUFFIX_DISCARD 0 #define SUFFIX_SHP 1 #define SUFFIX_SHX 2 #define SUFFIX_DBF 3 #define SHAPEFILE_NO_DATA 1e-38 #if defined(_WIN32) && !defined(__MINGW32__) #define strcasecmp _stricmp #endif /* not WIN32 */ struct shp_entry { /* an item of the SHP list */ char *base_name; char *file_name; int has_shp; int has_shx; int has_dbf; struct shp_entry *next; }; struct shp_list { /* the SHP list */ struct shp_entry *first; struct shp_entry *last; }; static struct shp_list * alloc_shp_list (void) { /* allocating an empty SHP list */ struct shp_list *list = malloc (sizeof (struct shp_list)); list->first = NULL; list->last = NULL; return list; } static void free_shp_list (struct shp_list *list) { /* memory cleanup: freeing an SHP list */ struct shp_entry *pi; struct shp_entry *pin; if (list == NULL) return; pi = list->first; while (pi != NULL) { pin = pi->next; if (pi->base_name != NULL) sqlite3_free (pi->base_name); if (pi->file_name != NULL) sqlite3_free (pi->file_name); free (pi); pi = pin; } free (list); } static void do_add_shapefile (struct shp_list *list, char *base_name, char *file_name, int suffix) { /* adding a possible SHP to the list */ struct shp_entry *pi; if (list == NULL) return; pi = list->first; while (pi != NULL) { /* searching if already defined */ if (strcmp (pi->base_name, base_name) == 0) { switch (suffix) { case SUFFIX_SHP: pi->has_shp = 1; break; case SUFFIX_SHX: pi->has_shx = 1; break; case SUFFIX_DBF: pi->has_dbf = 1; break; }; sqlite3_free (base_name); sqlite3_free (file_name); return; } pi = pi->next; } /* adding a new SHP entry */ pi = malloc (sizeof (struct shp_entry)); pi->base_name = base_name; pi->file_name = file_name; pi->has_shp = 0; pi->has_shx = 0; pi->has_dbf = 0; pi->next = NULL; switch (suffix) { case SUFFIX_SHP: pi->has_shp = 1; break; case SUFFIX_SHX: pi->has_shx = 1; break; case SUFFIX_DBF: pi->has_dbf = 1; break; }; if (list->first == NULL) list->first = pi; if (list->last != NULL) list->last->next = pi; list->last = pi; } static int test_valid_shp (struct shp_entry *p) { /* testing for a valid SHP candidate */ if (p == NULL) return 0; if (p->has_shp && p->has_shx && p->has_dbf) return 1; return 0; } static gaiaShapefilePtr allocShapefile () { /* allocates and initializes the Shapefile object */ gaiaShapefilePtr shp = malloc (sizeof (gaiaShapefile)); shp->endian_arch = 1; shp->Path = NULL; shp->Shape = -1; shp->EffectiveType = GAIA_UNKNOWN; shp->EffectiveDims = GAIA_XY; shp->flShp = NULL; shp->flShx = NULL; shp->flDbf = NULL; shp->Dbf = NULL; shp->ShpBfsz = 0; shp->BufShp = NULL; shp->BufDbf = NULL; shp->DbfHdsz = 0; shp->DbfReclen = 0; shp->DbfSize = 0; shp->DbfRecno = 0; shp->ShpSize = 0; shp->ShxSize = 0; shp->MinX = DBL_MAX; shp->MinY = DBL_MAX; shp->MaxX = -DBL_MAX; shp->MaxY = -DBL_MAX; shp->Valid = 0; shp->IconvObj = NULL; shp->LastError = NULL; return shp; } static void freeShapefile (gaiaShapefilePtr shp) { /* frees all memory allocations related to the Shapefile object */ if (shp->Path) free (shp->Path); if (shp->flShp) fclose (shp->flShp); if (shp->flShx) fclose (shp->flShx); if (shp->flDbf) fclose (shp->flDbf); if (shp->Dbf) gaiaFreeDbfList (shp->Dbf); if (shp->BufShp) free (shp->BufShp); if (shp->BufDbf) free (shp->BufDbf); if (shp->LastError) free (shp->LastError); free (shp); } static void openShpRead (gaiaShapefilePtr shp, const char *path, double *MinX, double *MinY, double *MaxX, double *MaxY, int *mismatching) { /* trying to open the shapefile and initial checkings */ FILE *fl_shx = NULL; FILE *fl_shp = NULL; FILE *fl_dbf = NULL; char xpath[1024]; int rd; unsigned char buf_shx[256]; unsigned char *buf_shp = NULL; int buf_size = 1024; int shape; unsigned char bf[1024]; int dbf_size; int dbf_reclen = 0; int off_dbf; int ind; char field_name[2048]; char *sys_err; char errMsg[1024]; double minx; double miny; double maxx; double maxy; int len; int endian_arch = gaiaEndianArch (); gaiaDbfListPtr dbf_list = NULL; if (shp->flShp != NULL || shp->flShx != NULL || shp->flDbf != NULL) { sprintf (errMsg, "attempting to reopen an already opened Shapefile\n"); goto unsupported_conversion; } sprintf (xpath, "%s.shx", path); fl_shx = fopen (xpath, "rb"); if (!fl_shx) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for reading: %s", xpath, sys_err); goto no_file; } sprintf (xpath, "%s.shp", path); fl_shp = fopen (xpath, "rb"); if (!fl_shp) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for reading: %s", xpath, sys_err); goto no_file; } sprintf (xpath, "%s.dbf", path); fl_dbf = fopen (xpath, "rb"); if (!fl_dbf) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for reading: %s", xpath, sys_err); goto no_file; } /* reading SHX file header */ rd = fread (buf_shx, sizeof (unsigned char), 100, fl_shx); if (rd != 100) goto error; if (gaiaImport32 (buf_shx + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994) /* checks the SHX magic number */ goto error; *MinX = gaiaImport64 (buf_shx + 36, GAIA_LITTLE_ENDIAN, endian_arch); *MinY = gaiaImport64 (buf_shx + 44, GAIA_LITTLE_ENDIAN, endian_arch); *MaxX = gaiaImport64 (buf_shx + 52, GAIA_LITTLE_ENDIAN, endian_arch); *MaxY = gaiaImport64 (buf_shx + 60, GAIA_LITTLE_ENDIAN, endian_arch); /* reading SHP file header */ buf_shp = malloc (sizeof (unsigned char) * buf_size); rd = fread (buf_shp, sizeof (unsigned char), 100, fl_shp); if (rd != 100) goto error; if (gaiaImport32 (buf_shp + 0, GAIA_BIG_ENDIAN, endian_arch) != 9994) /* checks the SHP magic number */ goto error; minx = gaiaImport64 (buf_shp + 36, GAIA_LITTLE_ENDIAN, endian_arch); miny = gaiaImport64 (buf_shp + 44, GAIA_LITTLE_ENDIAN, endian_arch); maxx = gaiaImport64 (buf_shp + 52, GAIA_LITTLE_ENDIAN, endian_arch); maxy = gaiaImport64 (buf_shp + 60, GAIA_LITTLE_ENDIAN, endian_arch); *mismatching = 0; if (*MinX != minx || *MinY != miny || *MaxX != maxx || *MaxY != maxy) { fprintf (stderr, "\t\tHEADERS: found mismatching BBOX between .shx and .shp\n"); *mismatching = 1; } shape = gaiaImport32 (buf_shp + 32, GAIA_LITTLE_ENDIAN, endian_arch); if (shape == GAIA_SHP_POINT || shape == GAIA_SHP_POINTZ || shape == GAIA_SHP_POINTM || shape == GAIA_SHP_POLYLINE || shape == GAIA_SHP_POLYLINEZ || shape == GAIA_SHP_POLYLINEM || shape == GAIA_SHP_POLYGON || shape == GAIA_SHP_POLYGONZ || shape == GAIA_SHP_POLYGONM || shape == GAIA_SHP_MULTIPOINT || shape == GAIA_SHP_MULTIPOINTZ || shape == GAIA_SHP_MULTIPOINTM) ; else goto unsupported; /* reading DBF file header */ rd = fread (bf, sizeof (unsigned char), 32, fl_dbf); if (rd != 32) goto error; switch (*bf) { /* checks the DBF magic number */ case 0x03: case 0x83: break; case 0x02: case 0xF8: sprintf (errMsg, "'%s'\ninvalid magic number %02x [FoxBASE format]", path, *bf); goto dbf_bad_magic; case 0xF5: sprintf (errMsg, "'%s'\ninvalid magic number %02x [FoxPro 2.x (or earlier) format]", path, *bf); goto dbf_bad_magic; case 0x30: case 0x31: case 0x32: sprintf (errMsg, "'%s'\ninvalid magic number %02x [Visual FoxPro format]", path, *bf); goto dbf_bad_magic; case 0x43: case 0x63: case 0xBB: case 0xCB: sprintf (errMsg, "'%s'\ninvalid magic number %02x [dBASE IV format]", path, *bf); goto dbf_bad_magic; default: sprintf (errMsg, "'%s'\ninvalid magic number %02x [unknown format]", path, *bf); goto dbf_bad_magic; }; dbf_size = gaiaImport16 (bf + 8, GAIA_LITTLE_ENDIAN, endian_arch); dbf_reclen = gaiaImport16 (bf + 10, GAIA_LITTLE_ENDIAN, endian_arch); dbf_size--; off_dbf = 0; dbf_list = gaiaAllocDbfList (); for (ind = 32; ind < dbf_size; ind += 32) { /* fetches DBF fields definitions */ rd = fread (bf, sizeof (unsigned char), 32, fl_dbf); if (rd != 32) goto error; if (*(bf + 11) == 'M') { /* skipping any MEMO field */ memcpy (field_name, bf, 11); field_name[11] = '\0'; off_dbf += *(bf + 16); fprintf (stderr, "WARNING: column \"%s\" is of the MEMO type and will be ignored\n", field_name); continue; } memcpy (field_name, bf, 11); field_name[11] = '\0'; gaiaAddDbfField (dbf_list, field_name, *(bf + 11), off_dbf, *(bf + 16), *(bf + 17)); off_dbf += *(bf + 16); } if (!gaiaIsValidDbfList (dbf_list)) { /* invalid DBF */ goto illegal_dbf; } len = strlen (path); shp->Path = malloc (len + 1); strcpy (shp->Path, path); shp->ReadOnly = 1; shp->Shape = shape; switch (shape) { /* setting up a prudential geometry type */ case GAIA_SHP_POINT: case GAIA_SHP_POINTZ: case GAIA_SHP_POINTM: shp->EffectiveType = GAIA_POINT; break; case GAIA_SHP_POLYLINE: case GAIA_SHP_POLYLINEZ: case GAIA_SHP_POLYLINEM: shp->EffectiveType = GAIA_MULTILINESTRING; break; case GAIA_SHP_POLYGON: case GAIA_SHP_POLYGONZ: case GAIA_SHP_POLYGONM: shp->EffectiveType = GAIA_MULTIPOLYGON; break; case GAIA_SHP_MULTIPOINT: case GAIA_SHP_MULTIPOINTZ: case GAIA_SHP_MULTIPOINTM: shp->EffectiveType = GAIA_MULTIPOINT; break; } switch (shape) { /* setting up a prudential dimension model */ case GAIA_SHP_POINTZ: case GAIA_SHP_POLYLINEZ: case GAIA_SHP_POLYGONZ: case GAIA_SHP_MULTIPOINTZ: shp->EffectiveDims = GAIA_XY_Z_M; break; case GAIA_SHP_POINTM: case GAIA_SHP_POLYLINEM: case GAIA_SHP_POLYGONM: case GAIA_SHP_MULTIPOINTM: shp->EffectiveDims = GAIA_XY_M; break; default: shp->EffectiveDims = GAIA_XY; break; } shp->flShp = fl_shp; shp->flShx = fl_shx; shp->flDbf = fl_dbf; shp->Dbf = dbf_list; /* saving the SHP buffer */ shp->BufShp = buf_shp; shp->ShpBfsz = buf_size; /* allocating DBF buffer */ shp->BufDbf = malloc (sizeof (unsigned char) * dbf_reclen); shp->DbfHdsz = dbf_size + 1; shp->DbfReclen = dbf_reclen; shp->Valid = 1; shp->endian_arch = endian_arch; return; unsupported_conversion: /* illegal charset */ if (shp->LastError) free (shp->LastError); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); return; no_file: /* one of shapefile's files can't be accessed */ if (shp->LastError) free (shp->LastError); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); if (fl_shx) fclose (fl_shx); if (fl_shp) fclose (fl_shp); if (fl_dbf) fclose (fl_dbf); return; dbf_bad_magic: /* the DBF has an invalid magin number */ if (shp->LastError) free (shp->LastError); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); gaiaFreeDbfList (dbf_list); if (buf_shp) free (buf_shp); fclose (fl_shx); fclose (fl_shp); fclose (fl_dbf); return; error: /* the shapefile is invalid or corrupted */ if (shp->LastError) free (shp->LastError); sprintf (errMsg, "'%s' is corrupted / has invalid format", path); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); gaiaFreeDbfList (dbf_list); if (buf_shp) free (buf_shp); fclose (fl_shx); fclose (fl_shp); fclose (fl_dbf); return; unsupported: /* the shapefile has an unrecognized shape type */ if (shp->LastError) free (shp->LastError); sprintf (errMsg, "'%s' shape=%d is not supported", path, shape); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); gaiaFreeDbfList (dbf_list); if (buf_shp) free (buf_shp); fclose (fl_shx); fclose (fl_shp); if (fl_dbf) fclose (fl_dbf); return; illegal_dbf: /* the DBF-file contains unsupported data types */ if (shp->LastError) free (shp->LastError); sprintf (errMsg, "'%s.dbf' contains unsupported data types", path); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); gaiaFreeDbfList (dbf_list); if (buf_shp) free (buf_shp); fclose (fl_shx); fclose (fl_shp); if (fl_dbf) fclose (fl_dbf); return; } static int readShpEntity (gaiaShapefilePtr shp, int current_row, int *shplen, double *minx, double *miny, double *maxx, double *maxy) { /* trying to read an entity from shapefile */ unsigned char buf[512]; int len; int rd; int skpos; int offset; int off_shp; int sz; char errMsg[1024]; int shape; int endian_arch = gaiaEndianArch (); /* positioning and reading the SHX file */ offset = 100 + (current_row * 8); /* 100 bytes for the header + current row displacement; each SHX row = 8 bytes */ skpos = fseek (shp->flShx, offset, SEEK_SET); if (skpos != 0) goto eof; rd = fread (buf, sizeof (unsigned char), 8, shp->flShx); if (rd != 8) goto eof; off_shp = gaiaImport32 (buf, GAIA_BIG_ENDIAN, shp->endian_arch); /* positioning and reading the DBF file */ offset = shp->DbfHdsz + (current_row * shp->DbfReclen); skpos = fseek (shp->flDbf, offset, SEEK_SET); if (skpos != 0) goto error; rd = fread (shp->BufDbf, sizeof (unsigned char), shp->DbfReclen, shp->flDbf); if (rd != shp->DbfReclen) goto error; if (*(shp->BufDbf) == '*') goto dbf_deleted; /* positioning and reading corresponding SHP entity - geometry */ offset = off_shp * 2; skpos = fseek (shp->flShp, offset, SEEK_SET); if (skpos != 0) goto error; rd = fread (buf, sizeof (unsigned char), 8, shp->flShp); if (rd != 8) goto error; sz = gaiaImport32 (buf + 4, GAIA_BIG_ENDIAN, shp->endian_arch); if ((sz * 2) > shp->ShpBfsz) { /* current buffer is too small; we need to allocate a bigger buffer */ free (shp->BufShp); shp->ShpBfsz = sz * 2; shp->BufShp = malloc (sizeof (unsigned char) * shp->ShpBfsz); } /* reading the raw Geometry */ rd = fread (shp->BufShp, sizeof (unsigned char), sz * 2, shp->flShp); if (rd != sz * 2) goto error; *shplen = rd; /* retrieving the feature's BBOX */ shape = gaiaImport32 (shp->BufShp + 0, GAIA_LITTLE_ENDIAN, endian_arch); *minx = DBL_MAX; *miny = DBL_MAX; *maxx = DBL_MAX; *maxy = DBL_MAX; if (shape == GAIA_SHP_POINT || shape == GAIA_SHP_POINTZ || shape == GAIA_SHP_POINTM) { *minx = gaiaImport64 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN, endian_arch); *maxx = *minx; *miny = gaiaImport64 (shp->BufShp + 12, GAIA_LITTLE_ENDIAN, endian_arch); *maxy = *miny; } if (shape == GAIA_SHP_POLYLINE || shape == GAIA_SHP_POLYLINEZ || shape == GAIA_SHP_POLYLINEM || shape == GAIA_SHP_POLYGON || shape == GAIA_SHP_POLYGONZ || shape == GAIA_SHP_POLYGONM || shape == GAIA_SHP_MULTIPOINT || shape == GAIA_SHP_MULTIPOINTZ || shape == GAIA_SHP_MULTIPOINTM) { *minx = gaiaImport64 (shp->BufShp + 4, GAIA_LITTLE_ENDIAN, endian_arch); *miny = gaiaImport64 (shp->BufShp + 12, GAIA_LITTLE_ENDIAN, endian_arch); *maxx = gaiaImport64 (shp->BufShp + 20, GAIA_LITTLE_ENDIAN, endian_arch); *maxy = gaiaImport64 (shp->BufShp + 28, GAIA_LITTLE_ENDIAN, endian_arch); } return 1; eof: if (shp->LastError) free (shp->LastError); shp->LastError = NULL; return 0; error: if (shp->LastError) free (shp->LastError); sprintf (errMsg, "'%s' is corrupted / has invalid format", shp->Path); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); return 0; dbf_deleted: if (shp->LastError) free (shp->LastError); shp->LastError = NULL; return -1; } struct shp_ring_item { /* a RING item [to be reassembled into a (Multi)Polygon] */ gaiaRingPtr Ring; int IsExterior; gaiaRingPtr Mother; struct shp_ring_item *Next; }; struct shp_ring_collection { /* a collection of RING items */ struct shp_ring_item *First; struct shp_ring_item *Last; }; static void shp_free_rings (struct shp_ring_collection *ringsColl) { /* memory cleanup: rings collection */ struct shp_ring_item *p; struct shp_ring_item *pN; p = ringsColl->First; while (p) { pN = p->Next; if (p->Ring) gaiaFreeRing (p->Ring); free (p); p = pN; } } static void shp_add_ring (struct shp_ring_collection *ringsColl, gaiaRingPtr ring) { /* inserting a ring into the rings collection */ struct shp_ring_item *p = malloc (sizeof (struct shp_ring_item)); p->Ring = ring; gaiaMbrRing (ring); gaiaClockwise (ring); /* accordingly to SHP rules interior/exterior depends on direction */ p->IsExterior = ring->Clockwise; p->Mother = NULL; p->Next = NULL; /* updating the linked list */ if (ringsColl->First == NULL) ringsColl->First = p; if (ringsColl->Last != NULL) ringsColl->Last->Next = p; ringsColl->Last = p; } static int shp_check_rings (gaiaRingPtr exterior, gaiaRingPtr candidate) { /* / speditively checks if the candidate could be an interior Ring / contained into the exterior Ring */ double z; double m; double x0; double y0; double x1; double y1; int mid; int ret0; int ret1; if (candidate->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (candidate->Coords, 0, &x0, &y0, &z); } else if (candidate->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (candidate->Coords, 0, &x0, &y0, &m); } else if (candidate->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (candidate->Coords, 0, &x0, &y0, &z, &m); } else { gaiaGetPoint (candidate->Coords, 0, &x0, &y0); } mid = candidate->Points / 2; if (candidate->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (candidate->Coords, mid, &x1, &y1, &z); } else if (candidate->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (candidate->Coords, mid, &x1, &y1, &m); } else if (candidate->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (candidate->Coords, mid, &x1, &y1, &z, &m); } else { gaiaGetPoint (candidate->Coords, mid, &x1, &y1); } /* testing if the first point falls on the exterior ring surface */ ret0 = gaiaIsPointOnRingSurface (exterior, x0, y0); /* testing if the second point falls on the exterior ring surface */ ret1 = gaiaIsPointOnRingSurface (exterior, x1, y1); if (ret0 || ret1) return 1; return 0; } static int shp_mbr_contains (gaiaRingPtr r1, gaiaRingPtr r2) { /* checks if the first Ring contains the second one - MBR based */ int ok_1 = 0; int ok_2 = 0; int ok_3 = 0; int ok_4 = 0; if (r2->MinX >= r1->MinX && r2->MinX <= r1->MaxX) ok_1 = 1; if (r2->MaxX >= r1->MinX && r2->MaxX <= r1->MaxX) ok_2 = 1; if (r2->MinY >= r1->MinY && r2->MinY <= r1->MaxY) ok_3 = 1; if (r2->MaxY >= r1->MinY && r2->MaxY <= r1->MaxY) ok_4 = 1; if (ok_1 && ok_2 && ok_3 && ok_4) return 1; return 0; } static void shp_arrange_rings (struct shp_ring_collection *ringsColl) { /* / arranging Rings so to associate any interior ring / to the containing exterior ring */ struct shp_ring_item *pInt; struct shp_ring_item *pExt; pExt = ringsColl->First; while (pExt != NULL) { /* looping on Exterior Rings */ if (pExt->IsExterior) { pInt = ringsColl->First; while (pInt != NULL) { /* looping on Interior Rings */ if (pInt->IsExterior == 0 && pInt->Mother == NULL && shp_mbr_contains (pExt->Ring, pInt->Ring)) { /* ok, matches */ if (shp_check_rings (pExt->Ring, pInt->Ring)) pInt->Mother = pExt->Ring; } pInt = pInt->Next; } } pExt = pExt->Next; } pExt = ringsColl->First; while (pExt != NULL) { if (pExt->IsExterior == 0 && pExt->Mother == NULL) { /* orphan ring: promoting to Exterior */ pExt->IsExterior = 1; } pExt = pExt->Next; } } static void shp_build_area (struct shp_ring_collection *ringsColl, gaiaGeomCollPtr geom) { /* building the final (Multi)Polygon Geometry */ gaiaPolygonPtr polyg; struct shp_ring_item *pExt; struct shp_ring_item *pInt; pExt = ringsColl->First; while (pExt != NULL) { if (pExt->IsExterior) { /* creating a new Polygon */ polyg = gaiaInsertPolygonInGeomColl (geom, pExt->Ring); pInt = ringsColl->First; while (pInt != NULL) { if (pExt->Ring == pInt->Mother) { /* adding an interior ring to current POLYGON */ gaiaAddRingToPolyg (polyg, pInt->Ring); /* releasing Ring ownership */ pInt->Ring = NULL; } pInt = pInt->Next; } /* releasing Ring ownership */ pExt->Ring = NULL; } pExt = pExt->Next; } } static gaiaGeomCollPtr do_parse_geometry (const unsigned char *bufshp, int buflen, int eff_dims, int eff_type, int *nullshape) { /* attempting to parse a Geometry from the SHP */ gaiaGeomCollPtr geom = NULL; int shape; double x; double y; double z; double m; int points; int n; int n1; int base; int baseZ; int baseM; int start; int end; int iv; int ind; int max_size; int min_size; int hasM; int sz; gaiaLinestringPtr line = NULL; gaiaRingPtr ring = NULL; int endian_arch = gaiaEndianArch (); struct shp_ring_collection ringsColl; /* initializing the RING collection */ ringsColl.First = NULL; ringsColl.Last = NULL; shape = gaiaImport32 (bufshp + 0, GAIA_LITTLE_ENDIAN, endian_arch); if (shape == GAIA_SHP_NULL) { *nullshape = 1; return NULL; } *nullshape = 0; if (shape == GAIA_SHP_POINT) { /* shape point */ x = gaiaImport64 (bufshp + 4, GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 12, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) { geom = gaiaAllocGeomCollXYZ (); gaiaAddPointToGeomCollXYZ (geom, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { geom = gaiaAllocGeomCollXYM (); gaiaAddPointToGeomCollXYM (geom, x, y, 0.0); } else if (eff_dims == GAIA_XY_Z_M) { geom = gaiaAllocGeomCollXYZM (); gaiaAddPointToGeomCollXYZM (geom, x, y, 0.0, 0.0); } else { geom = gaiaAllocGeomColl (); gaiaAddPointToGeomColl (geom, x, y); } geom->DeclaredType = GAIA_POINT; } if (shape == GAIA_SHP_POINTZ) { /* shape point Z */ x = gaiaImport64 (bufshp + 4, GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 12, GAIA_LITTLE_ENDIAN, endian_arch); z = gaiaImport64 (bufshp + 20, GAIA_LITTLE_ENDIAN, endian_arch); if (buflen == 28) m = 0.0; else m = gaiaImport64 (bufshp + 28, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) { geom = gaiaAllocGeomCollXYZ (); gaiaAddPointToGeomCollXYZ (geom, x, y, z); } else if (eff_dims == GAIA_XY_M) { geom = gaiaAllocGeomCollXYM (); gaiaAddPointToGeomCollXYM (geom, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { geom = gaiaAllocGeomCollXYZM (); gaiaAddPointToGeomCollXYZM (geom, x, y, z, m); } else { geom = gaiaAllocGeomColl (); gaiaAddPointToGeomColl (geom, x, y); } geom->DeclaredType = GAIA_POINT; } if (shape == GAIA_SHP_POINTM) { /* shape point M */ x = gaiaImport64 (bufshp + 4, GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 12, GAIA_LITTLE_ENDIAN, endian_arch); m = gaiaImport64 (bufshp + 20, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) { geom = gaiaAllocGeomCollXYZ (); gaiaAddPointToGeomCollXYZ (geom, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { geom = gaiaAllocGeomCollXYM (); gaiaAddPointToGeomCollXYM (geom, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { geom = gaiaAllocGeomCollXYZM (); gaiaAddPointToGeomCollXYZM (geom, x, y, 0.0, m); } else { geom = gaiaAllocGeomColl (); gaiaAddPointToGeomColl (geom, x, y); } geom->DeclaredType = GAIA_POINT; } if (shape == GAIA_SHP_POLYLINE) { /* shape polyline */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); base = 44 + (n * 4); start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) line = gaiaAllocLinestringXYZ (points); else if (eff_dims == GAIA_XY_M) line = gaiaAllocLinestringXYM (points); else if (eff_dims == GAIA_XY_Z_M) line = gaiaAllocLinestringXYZM (points); else line = gaiaAllocLinestring (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (line->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (line->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (line->Coords, points, x, y, 0.0, 0.0); } else { gaiaSetPoint (line->Coords, points, x, y); } start++; points++; } if (!geom) { if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_LINESTRING) geom->DeclaredType = GAIA_LINESTRING; else geom->DeclaredType = GAIA_MULTILINESTRING; } gaiaInsertLinestringInGeomColl (geom, line); } } if (shape == GAIA_SHP_POLYLINEZ) { /* shape polyline Z */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 38 + (2 * n) + (n1 * 16); /* size [in 16 bits words !!!] ZM */ min_size = 30 + (2 * n) + (n1 * 12); /* size [in 16 bits words !!!] Z-only */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; base = 44 + (n * 4); baseZ = base + (n1 * 16) + 16; baseM = baseZ + (n1 * 8) + 16; start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) line = gaiaAllocLinestringXYZ (points); else if (eff_dims == GAIA_XY_M) line = gaiaAllocLinestringXYM (points); else if (eff_dims == GAIA_XY_Z_M) line = gaiaAllocLinestringXYZM (points); else line = gaiaAllocLinestring (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); z = gaiaImport64 (bufshp + baseZ + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); else m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (line->Coords, points, x, y, z); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (line->Coords, points, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (line->Coords, points, x, y, z, m); } else { gaiaSetPoint (line->Coords, points, x, y); } start++; points++; } if (!geom) { if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_LINESTRING) geom->DeclaredType = GAIA_LINESTRING; else geom->DeclaredType = GAIA_MULTILINESTRING; } gaiaInsertLinestringInGeomColl (geom, line); } } if (shape == GAIA_SHP_POLYLINEM) { /* shape polyline M */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 30 + (2 * n) + (n1 * 12); /* size [in 16 bits words !!!] M */ min_size = 22 + (2 * n) + (n1 * 8); /* size [in 16 bits words !!!] no-M */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; base = 44 + (n * 4); baseM = base + (n1 * 16) + 16; start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) line = gaiaAllocLinestringXYZ (points); else if (eff_dims == GAIA_XY_M) line = gaiaAllocLinestringXYM (points); else if (eff_dims == GAIA_XY_Z_M) line = gaiaAllocLinestringXYZM (points); else line = gaiaAllocLinestring (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); else m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (line->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (line->Coords, points, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (line->Coords, points, x, y, 0.0, m); } else { gaiaSetPoint (line->Coords, points, x, y); } start++; points++; } if (!geom) { if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_LINESTRING) geom->DeclaredType = GAIA_LINESTRING; else geom->DeclaredType = GAIA_MULTILINESTRING; } gaiaInsertLinestringInGeomColl (geom, line); } } if (shape == GAIA_SHP_POLYGON) { /* shape polygon */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); base = 44 + (n * 4); start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) ring = gaiaAllocRingXYZ (points); else if (eff_dims == GAIA_XY_M) ring = gaiaAllocRingXYM (points); else if (eff_dims == GAIA_XY_Z_M) ring = gaiaAllocRingXYZM (points); else ring = gaiaAllocRing (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (ring->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (ring->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (ring->Coords, points, x, y, 0.0, 0.0); } else { gaiaSetPoint (ring->Coords, points, x, y); } start++; points++; } shp_add_ring (&ringsColl, ring); } shp_arrange_rings (&ringsColl); /* allocating the final geometry */ if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_POLYGON) geom->DeclaredType = GAIA_POLYGON; else geom->DeclaredType = GAIA_MULTIPOLYGON; shp_build_area (&ringsColl, geom); } if (shape == GAIA_SHP_POLYGONZ) { /* shape polygon Z */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 38 + (2 * n) + (n1 * 16); /* size [in 16 bits words !!!] ZM */ min_size = 30 + (2 * n) + (n1 * 12); /* size [in 16 bits words !!!] Z-only */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; base = 44 + (n * 4); baseZ = base + (n1 * 16) + 16; baseM = baseZ + (n1 * 8) + 16; start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) ring = gaiaAllocRingXYZ (points); else if (eff_dims == GAIA_XY_M) ring = gaiaAllocRingXYM (points); else if (eff_dims == GAIA_XY_Z_M) ring = gaiaAllocRingXYZM (points); else ring = gaiaAllocRing (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); z = gaiaImport64 (bufshp + baseZ + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); else m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (ring->Coords, points, x, y, z); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (ring->Coords, points, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (ring->Coords, points, x, y, z, m); } else { gaiaSetPoint (ring->Coords, points, x, y); } start++; points++; } shp_add_ring (&ringsColl, ring); } shp_arrange_rings (&ringsColl); /* allocating the final geometry */ if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_POLYGON) geom->DeclaredType = GAIA_POLYGON; else geom->DeclaredType = GAIA_MULTIPOLYGON; shp_build_area (&ringsColl, geom); } if (shape == GAIA_SHP_POLYGONM) { /* shape polygon M */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); n1 = gaiaImport32 (bufshp + 40, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 30 + (2 * n) + (n1 * 12); /* size [in 16 bits words !!!] M */ min_size = 22 + (2 * n) + (n1 * 8); /* size [in 16 bits words !!!] no-M */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; base = 44 + (n * 4); baseM = base + (n1 * 16) + 16; start = 0; for (ind = 0; ind < n; ind++) { if (ind < (n - 1)) end = gaiaImport32 (bufshp + 44 + ((ind + 1) * 4), GAIA_LITTLE_ENDIAN, endian_arch); else end = n1; points = end - start; if (eff_dims == GAIA_XY_Z) ring = gaiaAllocRingXYZ (points); else if (eff_dims == GAIA_XY_M) ring = gaiaAllocRingXYM (points); else if (eff_dims == GAIA_XY_Z_M) ring = gaiaAllocRingXYZM (points); else ring = gaiaAllocRing (points); points = 0; for (iv = start; iv < end; iv++) { x = gaiaImport64 (bufshp + base + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + base + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) { gaiaSetPointXYZ (ring->Coords, points, x, y, 0.0); } else if (eff_dims == GAIA_XY_M) { gaiaSetPointXYM (ring->Coords, points, x, y, m); } else if (eff_dims == GAIA_XY_Z_M) { gaiaSetPointXYZM (ring->Coords, points, x, y, 0.0, m); } else { gaiaSetPoint (ring->Coords, points, x, y); } start++; points++; } shp_add_ring (&ringsColl, ring); } shp_arrange_rings (&ringsColl); /* allocating the final geometry */ if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); if (eff_type == GAIA_POLYGON) geom->DeclaredType = GAIA_POLYGON; else geom->DeclaredType = GAIA_MULTIPOLYGON; shp_build_area (&ringsColl, geom); } if (shape == GAIA_SHP_MULTIPOINT) { /* shape multipoint */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); geom->DeclaredType = GAIA_MULTIPOINT; for (iv = 0; iv < n; iv++) { x = gaiaImport64 (bufshp + 40 + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 40 + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (eff_dims == GAIA_XY_Z) gaiaAddPointToGeomCollXYZ (geom, x, y, 0.0); else if (eff_dims == GAIA_XY_M) gaiaAddPointToGeomCollXYM (geom, x, y, 0.0); else if (eff_dims == GAIA_XY_Z_M) gaiaAddPointToGeomCollXYZM (geom, x, y, 0.0, 0.0); else gaiaAddPointToGeomColl (geom, x, y); } } if (shape == GAIA_SHP_MULTIPOINTZ) { /* shape multipoint Z */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 36 + (n * 16); /* size [in 16 bits words !!!] ZM */ min_size = 28 + (n * 12); /* size [in 16 bits words !!!] Z-only */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; baseZ = 40 + (n * 16) + 16; baseM = baseZ + (n * 8) + 16; if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); geom->DeclaredType = GAIA_MULTIPOINT; for (iv = 0; iv < n; iv++) { x = gaiaImport64 (bufshp + 40 + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 40 + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); z = gaiaImport64 (bufshp + baseZ + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); else m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) gaiaAddPointToGeomCollXYZ (geom, x, y, z); else if (eff_dims == GAIA_XY_M) gaiaAddPointToGeomCollXYM (geom, x, y, m); else if (eff_dims == GAIA_XY_Z_M) gaiaAddPointToGeomCollXYZM (geom, x, y, z, m); else gaiaAddPointToGeomColl (geom, x, y); } } if (shape == GAIA_SHP_MULTIPOINTM) { /* shape multipoint M */ n = gaiaImport32 (bufshp + 36, GAIA_LITTLE_ENDIAN, endian_arch); hasM = 0; max_size = 28 + (n * 12); /* size [in 16 bits words !!!] M */ min_size = 20 + (n * 8); /* size [in 16 bits words !!!] no-M */ sz = buflen / 2; if (sz < min_size) goto error; if (sz == max_size) hasM = 1; baseM = 40 + (n * 16) + 16; if (eff_dims == GAIA_XY_Z) geom = gaiaAllocGeomCollXYZ (); else if (eff_dims == GAIA_XY_M) geom = gaiaAllocGeomCollXYM (); else if (eff_dims == GAIA_XY_Z_M) geom = gaiaAllocGeomCollXYZM (); else geom = gaiaAllocGeomColl (); geom->DeclaredType = GAIA_MULTIPOINT; for (iv = 0; iv < n; iv++) { x = gaiaImport64 (bufshp + 40 + (iv * 16), GAIA_LITTLE_ENDIAN, endian_arch); y = gaiaImport64 (bufshp + 40 + (iv * 16) + 8, GAIA_LITTLE_ENDIAN, endian_arch); if (hasM) m = gaiaImport64 (bufshp + baseM + (iv * 8), GAIA_LITTLE_ENDIAN, endian_arch); else m = 0.0; if (m < SHAPEFILE_NO_DATA) m = 0.0; if (eff_dims == GAIA_XY_Z) gaiaAddPointToGeomCollXYZ (geom, x, y, 0.0); else if (eff_dims == GAIA_XY_M) gaiaAddPointToGeomCollXYM (geom, x, y, m); else if (eff_dims == GAIA_XY_Z_M) gaiaAddPointToGeomCollXYZM (geom, x, y, 0.0, m); else gaiaAddPointToGeomColl (geom, x, y); } } if (geom != NULL) gaiaMbrGeometry (geom); shp_free_rings (&ringsColl); return geom; error: fprintf (stderr, "\tcorrupted shapefile / invalid format"); shp_free_rings (&ringsColl); return NULL; } static int do_read_shp (const void *cache, const char *shp_path, int validate, int esri, int *invalid) { /* reading some Shapefile and testing for validity */ int current_row; gaiaShapefilePtr shp = NULL; int ret; double minx; double miny; double maxx; double maxy; double MinX = DBL_MAX; double MinY = DBL_MAX; double MaxX = 0.0 - DBL_MAX; double MaxY = 0.0 - DBL_MAX; double hMinX; double hMinY; double hMaxX; double hMaxY; int mismatching; *invalid = 0; shp = allocShapefile (); openShpRead (shp, shp_path, &hMinX, &hMinY, &hMaxX, &hMaxY, &mismatching); if (!(shp->Valid)) { char extra[512]; *extra = '\0'; if (shp->LastError) sprintf (extra, "\n\tcause: %s\n", shp->LastError); fprintf (stderr, "\terror: cannot open shapefile '%s'%s", shp_path, extra); freeShapefile (shp); return 0; } if (mismatching) *invalid += 1; current_row = 0; while (1) { /* reading rows from shapefile */ int shplen; ret = readShpEntity (shp, current_row, &shplen, &minx, &miny, &maxx, &maxy); if (ret < 0) { /* found a DBF deleted record */ fprintf (stderr, "\t\trow #%d: logical deletion found\n", current_row); current_row++; *invalid += 1; continue; } if (!ret) { if (!(shp->LastError)) /* normal SHP EOF */ break; fprintf (stderr, "\tERROR: %s\n", shp->LastError); goto stop; } if (validate) { int nullshape; gaiaGeomCollPtr geom = do_parse_geometry (shp->BufShp, shplen, shp->EffectiveDims, shp->EffectiveType, &nullshape); if (nullshape) ; else { if (geom == NULL) { fprintf (stderr, "\t\trow #%d: unable to get a Geometry\n", current_row); *invalid += 1; } else { if (geom->MinX != minx || geom->MinY != miny || geom->MaxX != maxx || geom->MaxY != maxy) { fprintf (stderr, "\t\trow #%d: mismatching BBOX\n", current_row); *invalid += 1; } if (esri) { /* checking invalid geometries in ESRI mode */ gaiaGeomCollPtr detail; detail = gaiaIsValidDetailEx_r (cache, geom, 1); if (detail == NULL) { /* extra checks */ int extra = 0; if (gaiaIsToxic_r (cache, geom)) extra = 1; if (gaiaIsNotClosedGeomColl_r (cache, geom)) extra = 1; if (extra) { char *reason = gaiaIsValidReason_r (cache, geom); if (reason == NULL) fprintf (stderr, "\t\trow #%d: invalid Geometry (unknown reason)\n", current_row); else { fprintf (stderr, "\t\trow #%d: %s\n", current_row, reason); free (reason); } *invalid += 1; } } else { char *reason = gaiaIsValidReason_r (cache, geom); if (reason == NULL) fprintf (stderr, "\t\trow #%d: invalid Geometry (unknown reason)\n", current_row); else { fprintf (stderr, "\t\trow #%d: %s\n", current_row, reason); free (reason); } *invalid += 1; gaiaFreeGeomColl (detail); } } else { /* checking invalid geometries in ISO/OGC mode */ if (gaiaIsValid_r (cache, geom) != 1) { char *reason = gaiaIsValidReason_r (cache, geom); if (reason == NULL) fprintf (stderr, "\t\trow #%d: invalid Geometry (unknown reason)\n", current_row); else { fprintf (stderr, "\t\trow #%d: %s\n", current_row, reason); free (reason); } *invalid += 1; } } gaiaFreeGeomColl (geom); } } } if (minx != DBL_MAX && miny != DBL_MAX && maxx != DBL_MAX && maxy != DBL_MAX) { if (minx < MinX) MinX = minx; if (miny < MinY) MinY = miny; if (maxx > MaxX) MaxX = maxx; if (maxy > MaxY) MaxY = maxy; } current_row++; } freeShapefile (shp); if (MinX != hMinX || MinY != hMinY || MaxX != hMaxX || MaxY != hMaxY) { fprintf (stderr, "\t\tHEADERS: found invalid BBOX\n"); *invalid += 1; } return 1; stop: freeShapefile (shp); fprintf (stderr, "\tMalformed shapefile: quitting\n"); return 0; } static void do_clen_files (const char *out_path, const char *name) { /* removing an invalid Shapefile (not properly repaired) */ char path[1024]; sprintf (path, "%s/%s.shx", out_path, name); #ifdef _WIN32 _unlink (path); #else unlink (path); #endif sprintf (path, "%s/%s.shp", out_path, name); #ifdef _WIN32 _unlink (path); #else unlink (path); #endif sprintf (path, "%s/%s.dbf", out_path, name); #ifdef _WIN32 _unlink (path); #else unlink (path); #endif } static void openShpWrite (gaiaShapefilePtr shp, const char *path, int shape, gaiaDbfListPtr dbf_list) { /* trying to create the shapefile */ FILE *fl_shx = NULL; FILE *fl_shp = NULL; FILE *fl_dbf = NULL; char xpath[1024]; unsigned char *buf_shp = NULL; int buf_size = 1024; unsigned char *dbf_buf = NULL; gaiaDbfFieldPtr fld; char *sys_err; char errMsg[1024]; short dbf_reclen = 0; int shp_size = 0; int shx_size = 0; unsigned short dbf_size = 0; int len; int endian_arch = gaiaEndianArch (); char buf[2048]; if (shp->flShp != NULL || shp->flShx != NULL || shp->flDbf != NULL) { sprintf (errMsg, "attempting to reopen an already opened Shapefile\n"); goto unsupported_conversion; } buf_shp = malloc (buf_size); /* trying to open shapefile files */ sprintf (xpath, "%s.shx", path); fl_shx = fopen (xpath, "wb"); if (!fl_shx) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for writing: %s", xpath, sys_err); goto no_file; } sprintf (xpath, "%s.shp", path); fl_shp = fopen (xpath, "wb"); if (!fl_shp) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for writing: %s", xpath, sys_err); goto no_file; } sprintf (xpath, "%s.dbf", path); fl_dbf = fopen (xpath, "wb"); if (!fl_dbf) { sys_err = strerror (errno); sprintf (errMsg, "unable to open '%s' for writing: %s", xpath, sys_err); goto no_file; } /* allocating DBF buffer */ dbf_reclen = 1; /* an extra byte is needed because in DBF rows first byte is a marker for deletion */ fld = dbf_list->First; while (fld) { /* computing the DBF record length */ dbf_reclen += fld->Length; fld = fld->Next; } dbf_buf = malloc (dbf_reclen); /* writing an empty SHP file header */ memset (buf_shp, 0, 100); fwrite (buf_shp, 1, 100, fl_shp); shp_size = 50; /* note: shapefile [SHP and SHX] counts sizes in WORDS of 16 bits, not in bytes of 8 bits !!!! */ /* writing an empty SHX file header */ memset (buf_shp, 0, 100); fwrite (buf_shp, 1, 100, fl_shx); shx_size = 50; /* writing the DBF file header */ memset (buf_shp, '\0', 32); fwrite (buf_shp, 1, 32, fl_dbf); dbf_size = 32; /* note: DBF counts sizes in bytes */ fld = dbf_list->First; while (fld) { /* exporting DBF Fields specifications */ memset (buf_shp, 0, 32); strcpy (buf, fld->Name); memcpy (buf_shp, buf, strlen (buf)); *(buf_shp + 11) = fld->Type; *(buf_shp + 16) = fld->Length; *(buf_shp + 17) = fld->Decimals; fwrite (buf_shp, 1, 32, fl_dbf); dbf_size += 32; fld = fld->Next; } fwrite ("\r", 1, 1, fl_dbf); /* this one is a special DBF delimiter that closes file header */ dbf_size++; /* setting up the SHP struct */ len = strlen (path); shp->Path = malloc (len + 1); strcpy (shp->Path, path); shp->ReadOnly = 0; shp->Shape = shape; shp->flShp = fl_shp; shp->flShx = fl_shx; shp->flDbf = fl_dbf; shp->Dbf = dbf_list; shp->BufShp = buf_shp; shp->ShpBfsz = buf_size; shp->BufDbf = dbf_buf; shp->DbfHdsz = dbf_size + 1; shp->DbfReclen = dbf_reclen; shp->DbfSize = dbf_size; shp->DbfRecno = 0; shp->ShpSize = shp_size; shp->ShxSize = shx_size; shp->MinX = DBL_MAX; shp->MinY = DBL_MAX; shp->MaxX = -DBL_MAX; shp->MaxY = -DBL_MAX; shp->Valid = 1; shp->endian_arch = endian_arch; return; unsupported_conversion: /* illegal charset */ if (shp->LastError) free (shp->LastError); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); return; no_file: /* one of shapefile's files can't be created/opened */ if (shp->LastError) free (shp->LastError); len = strlen (errMsg); shp->LastError = malloc (len + 1); strcpy (shp->LastError, errMsg); if (buf_shp) free (buf_shp); if (fl_shx) fclose (fl_shx); if (fl_shp) fclose (fl_shp); if (fl_dbf) fclose (fl_dbf); return; } static int writeShpEntity (gaiaShapefilePtr shp, const unsigned char *bufshp, int shplen, const unsigned char *bufdbf, int dbflen) { /* trying to write an entity into shapefile */ unsigned char buf[64]; int endian_arch = shp->endian_arch; int shape; double minx; double maxx; double miny; double maxy; /* inserting entity in SHX file */ gaiaExport32 (buf, shp->ShpSize, GAIA_BIG_ENDIAN, endian_arch); /* exports current SHP file position */ gaiaExport32 (buf + 4, shplen / 2, GAIA_BIG_ENDIAN, endian_arch); /* exports entitiy size [in 16 bits words !!!] */ fwrite (buf, 1, 8, shp->flShx); (shp->ShxSize) += 4; /* updating current SHX file position [in 16 bits words !!!] */ /* inserting entity in SHP file */ gaiaExport32 (buf, shp->DbfRecno + 1, GAIA_BIG_ENDIAN, endian_arch); /* exports entity ID */ gaiaExport32 (buf + 4, shplen / 2, GAIA_BIG_ENDIAN, endian_arch); /* exports entity size [in 16 bits words !!!] */ fwrite (buf, 1, 8, shp->flShp); (shp->ShpSize) += 4; fwrite (bufshp, 1, shplen, shp->flShp); (shp->ShpSize) += shplen / 2; /* updating current SHP file position [in 16 bits words !!!] */ /* inserting entity in DBF file */ fwrite (bufdbf, 1, dbflen, shp->flDbf); (shp->DbfRecno)++; /* updating the full extent BBOX */ shape = gaiaImport32 (bufshp + 0, GAIA_LITTLE_ENDIAN, endian_arch); if (shape == GAIA_SHP_POINT || shape == GAIA_SHP_POINTZ || shape == GAIA_SHP_POINTM) { minx = gaiaImport64 (bufshp + 4, GAIA_LITTLE_ENDIAN, endian_arch); maxx = minx; miny = gaiaImport64 (bufshp + 12, GAIA_LITTLE_ENDIAN, endian_arch); maxy = miny; if (minx < shp->MinX) shp->MinX = minx; if (maxx > shp->MaxX) shp->MaxX = maxx; if (miny < shp->MinY) shp->MinY = miny; if (maxy > shp->MaxY) shp->MaxY = maxy; } if (shape == GAIA_SHP_POLYLINE || shape == GAIA_SHP_POLYLINEZ || shape == GAIA_SHP_POLYLINEM || shape == GAIA_SHP_POLYGON || shape == GAIA_SHP_POLYGONZ || shape == GAIA_SHP_POLYGONM || shape == GAIA_SHP_MULTIPOINT || shape == GAIA_SHP_MULTIPOINTZ || shape == GAIA_SHP_MULTIPOINTM) { minx = gaiaImport64 (bufshp + 4, GAIA_LITTLE_ENDIAN, endian_arch); miny = gaiaImport64 (bufshp + 12, GAIA_LITTLE_ENDIAN, endian_arch); maxx = gaiaImport64 (bufshp + 20, GAIA_LITTLE_ENDIAN, endian_arch); maxy = gaiaImport64 (bufshp + 28, GAIA_LITTLE_ENDIAN, endian_arch); if (minx < shp->MinX) shp->MinX = minx; if (maxx > shp->MaxX) shp->MaxX = maxx; if (miny < shp->MinY) shp->MinY = miny; if (maxy > shp->MaxY) shp->MaxY = maxy; } return 1; } static int check_geometry (gaiaGeomCollPtr geom, int shape) { /* cheching the geometry type and dims */ int pts = 0; int lns = 0; int pgs = 0; gaiaPointPtr pt; gaiaLinestringPtr ln; gaiaPolygonPtr pg; pt = geom->FirstPoint; while (pt != NULL) { pts++; pt = pt->Next; } ln = geom->FirstLinestring; while (ln != NULL) { lns++; ln = ln->Next; } pg = geom->FirstPolygon; while (pg != NULL) { pgs++; pg = pg->Next; } if (pts == 1 && lns == 0 && pgs == 0) { if (shape == GAIA_SHP_POINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POINTM && geom->DimensionModel == GAIA_XY_M) return 1; if (shape == GAIA_SHP_MULTIPOINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_MULTIPOINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_MULTIPOINTM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts > 1 && lns == 0 && pgs == 0) { if (shape == GAIA_SHP_MULTIPOINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_MULTIPOINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_MULTIPOINTM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts == 0 && lns > 0 && pgs == 0) { if (shape == GAIA_SHP_POLYLINE && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POLYLINEZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POLYLINEM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts == 0 && lns == 0 && pgs > 0) { if (shape == GAIA_SHP_POLYGON && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POLYGONZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POLYGONM && geom->DimensionModel == GAIA_XY_M) return 1; } return 0; } static int check_geometry_verbose (gaiaGeomCollPtr geom, int shape, char **expected, char **actual) { /* cheching the geometry type and dims - verbose */ int pts = 0; int lns = 0; int pgs = 0; gaiaPointPtr pt; gaiaLinestringPtr ln; gaiaPolygonPtr pg; const char *str; int len; *expected = NULL; *actual = NULL; pt = geom->FirstPoint; while (pt != NULL) { pts++; pt = pt->Next; } ln = geom->FirstLinestring; while (ln != NULL) { lns++; ln = ln->Next; } pg = geom->FirstPolygon; while (pg != NULL) { pgs++; pg = pg->Next; } if (pts == 1 && lns == 0 && pgs == 0) { if (shape == GAIA_SHP_POINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POINTM && geom->DimensionModel == GAIA_XY_M) return 1; if (shape == GAIA_SHP_MULTIPOINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_MULTIPOINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_MULTIPOINTM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts > 1 && lns == 0 && pgs == 0) { if (shape == GAIA_SHP_MULTIPOINT && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_MULTIPOINTZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_MULTIPOINTM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts == 0 && lns > 0 && pgs == 0) { if (shape == GAIA_SHP_POLYLINE && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POLYLINEZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POLYLINEM && geom->DimensionModel == GAIA_XY_M) return 1; } if (pts == 0 && lns == 0 && pgs > 0) { if (shape == GAIA_SHP_POLYGON && geom->DimensionModel == GAIA_XY) return 1; if (shape == GAIA_SHP_POLYGONZ && (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M)) return 1; if (shape == GAIA_SHP_POLYGONM && geom->DimensionModel == GAIA_XY_M) return 1; } switch (shape) { case GAIA_SHP_POINT: str = "POINT"; break; case GAIA_SHP_POINTZ: str = "POINT-M"; break; case GAIA_SHP_POINTM: str = "POINT-Z"; break; case GAIA_SHP_POLYLINE: str = "POLYLINE"; break; case GAIA_SHP_POLYLINEZ: str = "POLYLINE-Z"; break; case GAIA_SHP_POLYLINEM: str = "POLYLINE-M"; break; case GAIA_SHP_POLYGON: str = "POLYGON"; break; case GAIA_SHP_POLYGONZ: str = "POLYGON-Z"; break; case GAIA_SHP_POLYGONM: str = "POLYGON-M"; break; case GAIA_SHP_MULTIPOINT: str = "MULTIPOINT"; break; case GAIA_SHP_MULTIPOINTZ: str = "MULTIPOINT-Z"; break; case GAIA_SHP_MULTIPOINTM: str = "MULTIPOINT-M"; break; default: str = "UNKNOWN"; break; }; len = strlen (str); *expected = malloc (len + 1); strcpy (*expected, str); str = "UNKNOWN"; if (pts == 1 && lns == 0 && pgs == 0) { if (geom->DimensionModel == GAIA_XY) str = "POINT"; if (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M) str = "POINT-Z"; if (geom->DimensionModel == GAIA_XY_M) str = "POINT-M"; } if (pts > 1 && lns == 0 && pgs == 0) { if (geom->DimensionModel == GAIA_XY) str = "MULTIPOINT"; if (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M) str = "MULTIPOINT-Z"; if (geom->DimensionModel == GAIA_XY_M) str = "MULTIPOINT-M"; } if (pts == 0 && lns > 0 && pgs == 0) { if (geom->DimensionModel == GAIA_XY) str = "POLYLINE"; if (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M) str = "POLYLINE-Z"; if (geom->DimensionModel == GAIA_XY_M) str = "POLYLINE-M"; } if (pts == 0 && lns == 0 && pgs > 0) { if (geom->DimensionModel == GAIA_XY) str = "POLYGON"; if (geom->DimensionModel == GAIA_XY_Z || geom->DimensionModel == GAIA_XY_Z_M) str = "POLYGON-Z"; return 1; if (geom->DimensionModel == GAIA_XY_M) str = "POLYGON-M"; return 1; } len = strlen (str); *actual = malloc (len + 1); strcpy (*actual, str); return 0; } static void gaiaSaneClockwise (gaiaPolygonPtr polyg) { /* / when exporting POLYGONs to SHAPEFILE, we must guarantee that: / - all EXTERIOR RING must be clockwise / - all INTERIOR RING must be anti-clockwise / / this function checks for the above conditions, / and if needed inverts the rings */ int ib; int iv; int iv2; double x; double y; double z; double m; gaiaRingPtr new_ring; gaiaRingPtr ring = polyg->Exterior; gaiaClockwise (ring); if (!(ring->Clockwise)) { /* exterior ring needs inversion */ if (ring->DimensionModel == GAIA_XY_Z) new_ring = gaiaAllocRingXYZ (ring->Points); else if (ring->DimensionModel == GAIA_XY_M) new_ring = gaiaAllocRingXYM (ring->Points); else if (ring->DimensionModel == GAIA_XY_Z_M) new_ring = gaiaAllocRingXYZM (ring->Points); else new_ring = gaiaAllocRing (ring->Points); iv2 = 0; for (iv = ring->Points - 1; iv >= 0; iv--) { if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); gaiaSetPointXYZ (new_ring->Coords, iv2, x, y, z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); gaiaSetPointXYM (new_ring->Coords, iv2, x, y, m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); gaiaSetPointXYZM (new_ring->Coords, iv2, x, y, z, m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); gaiaSetPoint (new_ring->Coords, iv2, x, y); } iv2++; } polyg->Exterior = new_ring; gaiaFreeRing (ring); } for (ib = 0; ib < polyg->NumInteriors; ib++) { ring = polyg->Interiors + ib; gaiaClockwise (ring); if (ring->Clockwise) { /* interior ring needs inversion */ if (ring->DimensionModel == GAIA_XY_Z) new_ring = gaiaAllocRingXYZ (ring->Points); else if (ring->DimensionModel == GAIA_XY_M) new_ring = gaiaAllocRingXYM (ring->Points); else if (ring->DimensionModel == GAIA_XY_Z_M) new_ring = gaiaAllocRingXYZM (ring->Points); else new_ring = gaiaAllocRing (ring->Points); iv2 = 0; for (iv = ring->Points - 1; iv >= 0; iv--) { if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); gaiaSetPointXYZ (new_ring->Coords, iv2, x, y, z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); gaiaSetPointXYM (new_ring->Coords, iv2, x, y, m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); gaiaSetPointXYZM (new_ring->Coords, iv2, x, y, z, m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); gaiaSetPoint (new_ring->Coords, iv2, x, y); } iv2++; } for (iv = 0; iv < ring->Points; iv++) { if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (new_ring->Coords, iv, &x, &y, &z); gaiaSetPointXYZ (ring->Coords, iv, x, y, z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (new_ring->Coords, iv, &x, &y, &m); gaiaSetPointXYM (ring->Coords, iv, x, y, m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (new_ring->Coords, iv, &x, &y, &z, &m); gaiaSetPointXYZM (ring->Coords, iv, x, y, z, m); } else { gaiaGetPoint (new_ring->Coords, iv, &x, &y); gaiaSetPoint (ring->Coords, iv, x, y); } } gaiaFreeRing (new_ring); } } } static int do_export_geometry (gaiaGeomCollPtr geom, unsigned char **bufshp, int *buflen, int xshape, int rowno, int eff_dims) { /* attempting to encode a Geometry */ unsigned char *buf; int iv; int tot_ln; int tot_v; int tot_pts; int this_size; int ix; double x; double y; double z; double m; int hasM; double minZ; double maxZ; double minM; double maxM; int endian_arch = gaiaEndianArch (); if (geom == NULL) { /* exporting a NULL Shape */ *buflen = 4; buf = malloc (4); gaiaExport32 (buf + 0, GAIA_SHP_NULL, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = NULL */ *bufshp = buf; return 1; } if (!check_geometry (geom, xshape)) { /* mismatching Geometry type */ fprintf (stderr, "\tinput row #%d: mismatching Geometry type\n", rowno); return 0; } gaiaMbrGeometry (geom); if (xshape == GAIA_SHP_POINT) { /* this one is expected to be a POINT */ gaiaPointPtr pt = geom->FirstPoint; *buflen = 20; buf = malloc (20); gaiaExport32 (buf + 0, GAIA_SHP_POINT, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POINT */ gaiaExport64 (buf + 4, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); /* exports X coordinate */ gaiaExport64 (buf + 12, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); /* exports Y coordinate */ *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POINTZ) { /* this one is expected to be a POINT Z */ gaiaPointPtr pt = geom->FirstPoint; *buflen = 36; buf = malloc (36); gaiaExport32 (buf + 0, GAIA_SHP_POINTZ, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POINT Z */ gaiaExport64 (buf + 4, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); /* exports X coordinate */ gaiaExport64 (buf + 12, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); /* exports Y coordinate */ gaiaExport64 (buf + 20, pt->Z, GAIA_LITTLE_ENDIAN, endian_arch); /* exports Z coordinate */ gaiaExport64 (buf + 28, pt->M, GAIA_LITTLE_ENDIAN, endian_arch); /* exports M coordinate */ *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POINTM) { /* this one is expected to be a POINT M */ gaiaPointPtr pt = geom->FirstPoint; *buflen = 28; buf = malloc (28); gaiaExport32 (buf + 0, GAIA_SHP_POINTM, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POINT M */ gaiaExport64 (buf + 4, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); /* exports X coordinate */ gaiaExport64 (buf + 12, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); /* exports Y coordinate */ gaiaExport64 (buf + 20, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); /* exports M coordinate */ *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYLINE) { /* this one is expected to be a LINESTRING / MULTILINESTRING */ gaiaLinestringPtr line; tot_ln = 0; tot_v = 0; line = geom->FirstLinestring; while (line) { /* computes # lines and total # points */ tot_v += line->Points; tot_ln++; line = line->Next; } this_size = 22 + (2 * tot_ln) + (tot_v * 8); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYLINE, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYLINE */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # lines in this polyline */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ line = geom->FirstLinestring; while (line) { /* exports start point index for each line */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += line->Points; ix += 4; line = line->Next; } line = geom->FirstLinestring; while (line) { /* exports points for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports a POINT [x,y] */ if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYLINEZ) { /* this one is expected to be a LINESTRING / MULTILINESTRING Z */ gaiaLinestringPtr line; gaiaZRangeGeometry (geom, &minZ, &maxZ); gaiaMRangeGeometry (geom, &minM, &maxM); tot_ln = 0; tot_v = 0; line = geom->FirstLinestring; while (line) { /* computes # lines and total # points */ tot_v += line->Points; tot_ln++; line = line->Next; } hasM = 0; if (eff_dims == GAIA_XY_M || eff_dims == GAIA_XY_Z_M) hasM = 1; if (hasM) this_size = 38 + (2 * tot_ln) + (tot_v * 16); /* size [in 16 bits words !!!] ZM */ else this_size = 30 + (2 * tot_ln) + (tot_v * 12); /* size [in 16 bits words !!!] Z-only */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYLINEZ, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYLINE Z */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # lines in this polyline */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ line = geom->FirstLinestring; while (line) { /* exports start point index for each line */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += line->Points; ix += 4; line = line->Next; } line = geom->FirstLinestring; while (line) { /* exports points for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports a POINT [x,y] */ if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } /* exporting the Z-range [min/max] */ gaiaExport64 (buf + ix, minZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; line = geom->FirstLinestring; while (line) { /* exports Z-values for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports Z-value */ z = 0.0; if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, z, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } if (hasM) { /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; line = geom->FirstLinestring; while (line) { /* exports M-values for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports M-value */ m = 0.0; if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYLINEM) { /* this one is expected to be a LINESTRING / MULTILINESTRING M */ gaiaLinestringPtr line; gaiaMRangeGeometry (geom, &minM, &maxM); tot_ln = 0; tot_v = 0; line = geom->FirstLinestring; while (line) { /* computes # lines and total # points */ tot_v += line->Points; tot_ln++; line = line->Next; } this_size = 30 + (2 * tot_ln) + (tot_v * 12); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYLINEM, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYLINE M */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # lines in this polyline */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ line = geom->FirstLinestring; while (line) { /* exports start point index for each line */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += line->Points; ix += 4; line = line->Next; } line = geom->FirstLinestring; while (line) { /* exports points for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports a POINT [x,y] */ if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; line = geom->FirstLinestring; while (line) { /* exports M-values for each line */ for (iv = 0; iv < line->Points; iv++) { /* exports M-value */ m = 0.0; if (line->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (line->Coords, iv, &x, &y, &z); } else if (line->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (line->Coords, iv, &x, &y, &m); } else if (line->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (line->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (line->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } line = line->Next; } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYGON) { /* this one is expected to be a POLYGON or a MULTIPOLYGON */ gaiaPolygonPtr polyg; gaiaRingPtr ring; int ib; tot_ln = 0; tot_v = 0; polyg = geom->FirstPolygon; while (polyg) { /* computes # rings and total # points */ gaiaSaneClockwise (polyg); /* we must assure that exterior ring is clockwise, and interior rings are anti-clockwise */ ring = polyg->Exterior; /* this one is the exterior ring */ tot_v += ring->Points; tot_ln++; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; tot_v += ring->Points; tot_ln++; } polyg = polyg->Next; } this_size = 22 + (2 * tot_ln) + (tot_v * 8); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYGON, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYGON */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # rings in this polygon */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ polyg = geom->FirstPolygon; while (polyg) { /* exports start point index for each line */ ring = polyg->Exterior; /* this one is the exterior ring */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; } polyg = polyg->Next; } polyg = geom->FirstPolygon; while (polyg) { /* exports points for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - exterior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - interior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYGONZ) { /* this one is expected to be a POLYGON or a MULTIPOLYGON Z */ gaiaPolygonPtr polyg; gaiaRingPtr ring; int ib; gaiaZRangeGeometry (geom, &minZ, &maxZ); gaiaMRangeGeometry (geom, &minM, &maxM); tot_ln = 0; tot_v = 0; polyg = geom->FirstPolygon; while (polyg) { /* computes # rings and total # points */ gaiaSaneClockwise (polyg); /* we must assure that exterior ring is clockwise, and interior rings are anti-clockwise */ ring = polyg->Exterior; /* this one is the exterior ring */ tot_v += ring->Points; tot_ln++; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; tot_v += ring->Points; tot_ln++; } polyg = polyg->Next; } hasM = 0; if (eff_dims == GAIA_XY_M || eff_dims == GAIA_XY_Z_M) hasM = 1; if (hasM) this_size = 38 + (2 * tot_ln) + (tot_v * 16); /* size [in 16 bits words !!!] ZM */ else this_size = 30 + (2 * tot_ln) + (tot_v * 12); /* size [in 16 bits words !!!] Z-only */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYGONZ, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYGON Z */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # rings in this polygon */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ polyg = geom->FirstPolygon; while (polyg) { /* exports start point index for each line */ ring = polyg->Exterior; /* this one is the exterior ring */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; } polyg = polyg->Next; } polyg = geom->FirstPolygon; while (polyg) { /* exports points for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - exterior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - interior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } /* exporting the Z-range [min/max] */ gaiaExport64 (buf + ix, minZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; polyg = geom->FirstPolygon; while (polyg) { /* exports Z-values for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports Z-values - exterior ring */ z = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, z, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports Z-values - interior ring */ z = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, z, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } if (hasM) { /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; polyg = geom->FirstPolygon; while (polyg) { /* exports M-values for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports M-values - exterior ring */ m = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports M-values - interior ring */ m = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_POLYGONM) { /* this one is expected to be a POLYGON or a MULTIPOLYGON M */ gaiaPolygonPtr polyg; gaiaRingPtr ring; int ib; gaiaMRangeGeometry (geom, &minM, &maxM); tot_ln = 0; tot_v = 0; polyg = geom->FirstPolygon; while (polyg) { /* computes # rings and total # points */ gaiaSaneClockwise (polyg); /* we must assure that exterior ring is clockwise, and interior rings are anti-clockwise */ ring = polyg->Exterior; /* this one is the exterior ring */ tot_v += ring->Points; tot_ln++; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; tot_v += ring->Points; tot_ln++; } polyg = polyg->Next; } this_size = 30 + (2 * tot_ln) + (tot_v * 12); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_POLYGONM, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = POLYGON M */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_ln, GAIA_LITTLE_ENDIAN, endian_arch); /* exports # rings in this polygon */ gaiaExport32 (buf + 40, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ tot_v = 0; /* resets points counter */ ix = 44; /* sets current buffer offset */ polyg = geom->FirstPolygon; while (polyg) { /* exports start point index for each line */ ring = polyg->Exterior; /* this one is the exterior ring */ gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; gaiaExport32 (buf + ix, tot_v, GAIA_LITTLE_ENDIAN, endian_arch); tot_v += ring->Points; ix += 4; } polyg = polyg->Next; } polyg = geom->FirstPolygon; while (polyg) { /* exports points for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - exterior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports a POINT [x,y] - interior ring */ if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, x, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; polyg = geom->FirstPolygon; while (polyg) { /* exports M-values for each ring */ ring = polyg->Exterior; /* this one is the exterior ring */ for (iv = 0; iv < ring->Points; iv++) { /* exports M-values - exterior ring */ m = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } for (ib = 0; ib < polyg->NumInteriors; ib++) { /* that ones are the interior rings */ ring = polyg->Interiors + ib; for (iv = 0; iv < ring->Points; iv++) { /* exports M-values - interior ring */ m = 0.0; if (ring->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ (ring->Coords, iv, &x, &y, &z); } else if (ring->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM (ring->Coords, iv, &x, &y, &m); } else if (ring->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM (ring->Coords, iv, &x, &y, &z, &m); } else { gaiaGetPoint (ring->Coords, iv, &x, &y); } gaiaExport64 (buf + ix, m, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; } } polyg = polyg->Next; } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_MULTIPOINT) { /* this one is expected to be a MULTIPOINT */ gaiaPointPtr pt; tot_pts = 0; pt = geom->FirstPoint; while (pt) { /* computes # points */ tot_pts++; pt = pt->Next; } this_size = 20 + (tot_pts * 8); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_MULTIPOINT, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = MULTIPOINT */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_pts, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ ix = 40; /* sets current buffer offset */ pt = geom->FirstPoint; while (pt) { /* exports each point */ gaiaExport64 (buf + ix, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_MULTIPOINTZ) { /* this one is expected to be a MULTIPOINT Z */ gaiaPointPtr pt; gaiaZRangeGeometry (geom, &minZ, &maxZ); gaiaMRangeGeometry (geom, &minM, &maxM); tot_pts = 0; pt = geom->FirstPoint; while (pt) { /* computes # points */ tot_pts++; pt = pt->Next; } hasM = 0; if (eff_dims == GAIA_XY_M || eff_dims == GAIA_XY_Z_M) hasM = 1; if (hasM) this_size = 36 + (tot_pts * 16); /* size [in 16 bits words !!!] ZM */ else this_size = 28 + (tot_pts * 12); /* size [in 16 bits words !!!] Z-only */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_MULTIPOINTZ, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = MULTIPOINT Z */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_pts, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ ix = 40; /* sets current buffer offset */ pt = geom->FirstPoint; while (pt) { /* exports each point */ gaiaExport64 (buf + ix, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } /* exporting the Z-range [min/max] */ gaiaExport64 (buf + ix, minZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxZ, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = geom->FirstPoint; while (pt) { /* exports Z-values */ gaiaExport64 (buf + ix, pt->Z, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } if (hasM) { /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = geom->FirstPoint; while (pt) { /* exports M-values */ gaiaExport64 (buf + ix, pt->M, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } } *bufshp = buf; return 1; } if (xshape == GAIA_SHP_MULTIPOINTM) { /* this one is expected to be a MULTIPOINT M */ gaiaPointPtr pt; gaiaMRangeGeometry (geom, &minM, &maxM); tot_pts = 0; pt = geom->FirstPoint; while (pt) { /* computes # points */ tot_pts++; pt = pt->Next; } this_size = 28 + (tot_pts * 12); /* size [in 16 bits words !!!] for this SHP entity */ *buflen = this_size * 2; buf = malloc (this_size * 2); gaiaExport32 (buf + 0, GAIA_SHP_MULTIPOINTM, GAIA_LITTLE_ENDIAN, endian_arch); /* exports geometry type = MULTIPOINT M */ gaiaExport64 (buf + 4, geom->MinX, GAIA_LITTLE_ENDIAN, endian_arch); /* exports the MBR for this geometry */ gaiaExport64 (buf + 12, geom->MinY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 20, geom->MaxX, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport64 (buf + 28, geom->MaxY, GAIA_LITTLE_ENDIAN, endian_arch); gaiaExport32 (buf + 36, tot_pts, GAIA_LITTLE_ENDIAN, endian_arch); /* exports total # points */ ix = 40; /* sets current buffer offset */ pt = geom->FirstPoint; while (pt) { /* exports each point */ gaiaExport64 (buf + ix, pt->X, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, pt->Y, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } /* exporting the M-range [min/max] */ gaiaExport64 (buf + ix, minM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; gaiaExport64 (buf + ix, maxM, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = geom->FirstPoint; while (pt) { /* exports M-values */ gaiaExport64 (buf + ix, pt->M, GAIA_LITTLE_ENDIAN, endian_arch); ix += 8; pt = pt->Next; } *bufshp = buf; return 1; } fprintf (stderr, "\tinput row #%d: unable to export a consistent Geometry\n", rowno); return 0; } static int do_repair_shapefile (const void *cache, const char *shp_path, const char *out_path, int validate, int esri, int force, int *repair_failed) { /* repairing some Shapefile */ int current_row; gaiaShapefilePtr shp_in = NULL; gaiaShapefilePtr shp_out = NULL; int ret; gaiaDbfListPtr dbf_list = NULL; gaiaDbfFieldPtr in_fld; double minx; double miny; double maxx; double maxy; double hMinX; double hMinY; double hMaxX; double hMaxY; int mismatching; *repair_failed = 0; /* opening the INPUT SHP */ shp_in = allocShapefile (); openShpRead (shp_in, shp_path, &hMinX, &hMinY, &hMaxX, &hMaxY, &mismatching); if (!(shp_in->Valid)) { char extra[512]; *extra = '\0'; if (shp_in->LastError) sprintf (extra, "\n\t\tcause: %s\n", shp_in->LastError); fprintf (stderr, "\t\terror: cannot open shapefile '%s'%s", shp_path, extra); freeShapefile (shp_in); return 0; } /* preparing the DBF fields list - OUTPUT */ dbf_list = gaiaAllocDbfList (); in_fld = shp_in->Dbf->First; while (in_fld) { /* adding a DBF field - OUTPUT */ gaiaAddDbfField (dbf_list, in_fld->Name, in_fld->Type, in_fld->Offset, in_fld->Length, in_fld->Decimals); in_fld = in_fld->Next; } /* creating the OUTPUT SHP */ shp_out = allocShapefile (); openShpWrite (shp_out, out_path, shp_in->Shape, dbf_list); if (!(shp_out->Valid)) { char extra[512]; *extra = '\0'; if (shp_out->LastError) sprintf (extra, "\n\t\tcause: %s\n", shp_out->LastError); fprintf (stderr, "\t\terror: cannot open shapefile '%s'%s", out_path, extra); freeShapefile (shp_in); freeShapefile (shp_out); gaiaFreeDbfList (dbf_list); return 0; } current_row = 0; while (1) { /* reading rows from shapefile */ int shplen; ret = readShpEntity (shp_in, current_row, &shplen, &minx, &miny, &maxx, &maxy); if (ret < 0) { /* found a DBF deleted record */ current_row++; continue; } if (!ret) { if (!(shp_in->LastError)) /* normal SHP EOF */ break; fprintf (stderr, "\t\tERROR: %s\n", shp_in->LastError); goto stop; } if (validate || force) { /* attempting to rearrange geometries */ unsigned char *bufshp; int buflen; int nullshape; gaiaGeomCollPtr geom = do_parse_geometry (shp_in->BufShp, shplen, shp_in->EffectiveDims, shp_in->EffectiveType, &nullshape); if (nullshape) goto default_null; if (geom == NULL) { fprintf (stderr, "\t\tinput row #%d: unexpected NULL geometry\n", current_row); *repair_failed = 1; goto default_null; } if (validate) { /* testing for invalid Geometries */ int is_invalid = 0; if (esri) { /* checking invalid geometries in ESRI mode */ gaiaGeomCollPtr detail; detail = gaiaIsValidDetailEx_r (cache, geom, 1); if (detail == NULL) { /* extra checks */ int extra = 0; if (gaiaIsToxic_r (cache, geom)) extra = 1; if (gaiaIsNotClosedGeomColl_r (cache, geom)) extra = 1; if (extra) is_invalid = 1; } else { is_invalid = 1; gaiaFreeGeomColl (detail); } } else { /* checking invalid geometries in ISO/OGC mode */ if (gaiaIsValid_r (cache, geom) != 1) is_invalid = 1; } #ifdef ENABLE_RTTOPO /* only if RTTOPO is enabled */ if (is_invalid) { /* attempting to repair an invalid Geometry */ char *expected; char *actual; gaiaGeomCollPtr discarded; gaiaGeomCollPtr result = gaiaMakeValid (cache, geom); if (result == NULL) { fprintf (stderr, "\t\tinput row #%d: unexpected MakeValid failure\n", current_row); gaiaFreeGeomColl (geom); *repair_failed = 1; goto default_null; } discarded = gaiaMakeValidDiscarded (cache, geom); if (discarded != NULL) { fprintf (stderr, "\t\tinput row #%d: MakeValid reports discarded elements\n", current_row); gaiaFreeGeomColl (result); gaiaFreeGeomColl (discarded); gaiaFreeGeomColl (geom); *repair_failed = 1; goto default_null; } if (!check_geometry_verbose (result, shp_in->Shape, &expected, &actual)) { fprintf (stderr, "\t\tinput row #%d: MakeValid returned an invalid SHAPE (expected %s, got %s)\n", current_row, expected, actual); free (expected); free (actual); gaiaFreeGeomColl (result); gaiaFreeGeomColl (geom); *repair_failed = 1; goto default_null; } gaiaFreeGeomColl (geom); geom = result; } #endif /* end RTTOPO conditional */ if (!do_export_geometry (geom, &bufshp, &buflen, shp_in->Shape, current_row, shp_out->EffectiveDims)) { gaiaFreeGeomColl (geom); goto stop; } gaiaFreeGeomColl (geom); } else { if (!do_export_geometry (geom, &bufshp, &buflen, shp_in->Shape, current_row, shp_out->EffectiveDims)) { gaiaFreeGeomColl (geom); goto stop; } gaiaFreeGeomColl (geom); } goto ok_geom; default_null: /* exporting a NULL shape */ do_export_geometry (NULL, &bufshp, &buflen, shp_in->Shape, current_row, shp_out->EffectiveDims); ok_geom: ret = writeShpEntity (shp_out, bufshp, buflen, shp_in->BufDbf, shp_in->DbfReclen); free (bufshp); if (!ret) goto stop; } else { /* passing geometries exactly as they were */ if (!writeShpEntity (shp_out, shp_in->BufShp, shplen, shp_in->BufDbf, shp_in->DbfReclen)) goto stop; } current_row++; } gaiaFlushShpHeaders (shp_out); freeShapefile (shp_in); freeShapefile (shp_out); return 1; stop: freeShapefile (shp_in); freeShapefile (shp_out); fprintf (stderr, "\t\tMalformed shapefile, impossible to repair: quitting\n"); return 0; } static int do_test_shapefile (const void *cache, const char *shp_path, int validate, int esri, int *invalid) { /* testing a Shapefile for validity */ int n_invalid; fprintf (stderr, "\nVerifying %s.shp\n", shp_path); *invalid = 0; if (!do_read_shp (cache, shp_path, validate, esri, &n_invalid)) return 0; if (n_invalid) { fprintf (stderr, "\tfound %d invalidit%s: cleaning required.\n", n_invalid, (n_invalid > 1) ? "ies" : "y"); *invalid = 1; } else fprintf (stderr, "\tfound to be already valid.\n"); return 1; } static int check_extension (const char *file_name) { /* checks the file extension */ const char *mark = NULL; int len = strlen (file_name); const char *p = file_name + len - 1; while (p >= file_name) { if (*p == '.') mark = p; p--; } if (mark == NULL) return SUFFIX_DISCARD; if (strcasecmp (mark, ".shp") == 0) return SUFFIX_SHP; if (strcasecmp (mark, ".shx") == 0) return SUFFIX_SHX; if (strcasecmp (mark, ".dbf") == 0) return SUFFIX_DBF; return SUFFIX_DISCARD; } static int do_scan_dir (const void *cache, const char *in_dir, const char *out_dir, int *n_shp, int *r_shp, int *x_shp, int validate, int esri, int force) { /* scanning a directory and searching for Shapefiles to be checked */ struct shp_entry *p_shp; struct shp_list *list = alloc_shp_list (); #if defined(_WIN32) && !defined(__MINGW32__) /* Visual Studio .NET */ struct _finddata_t c_file; intptr_t hFile; char *path; char *name; int len; int ret; if (_chdir (in_dir) < 0) goto error; if ((hFile = _findfirst ("*.shp", &c_file)) == -1L) ; else { while (1) { if ((c_file.attrib & _A_RDONLY) == _A_RDONLY || (c_file.attrib & _A_NORMAL) == _A_NORMAL) { name = sqlite3_mprintf ("%s", c_file.name); len = strlen (name); name[len - 4] = '\0'; path = sqlite3_mprintf ("%s/%s", in_dir, name); do_add_shapefile (list, path, name, SUFFIX_SHP); } if (_findnext (hFile, &c_file) != 0) break; } _findclose (hFile); if ((hFile = _findfirst ("*.shx", &c_file)) == -1L) ; else { while (1) { if ((c_file.attrib & _A_RDONLY) == _A_RDONLY || (c_file.attrib & _A_NORMAL) == _A_NORMAL) { name = sqlite3_mprintf ("%s", c_file.name); len = strlen (name); name[len - 4] = '\0'; path = sqlite3_mprintf ("%s/%s", in_dir, name); do_add_shapefile (list, path, name, SUFFIX_SHX); } if (_findnext (hFile, &c_file) != 0) break; } _findclose (hFile); if ((hFile = _findfirst ("*.dbf", &c_file)) == -1L) ; else { while (1) { if ((c_file.attrib & _A_RDONLY) == _A_RDONLY || (c_file.attrib & _A_NORMAL) == _A_NORMAL) { name = sqlite3_mprintf ("%s", c_file.name); len = strlen (name); name[len - 4] = '\0'; path = sqlite3_mprintf ("%s/%s", in_dir, name); do_add_shapefile (list, path, name, SUFFIX_DBF); } if (_findnext (hFile, &c_file) != 0) break; } _findclose (hFile); } } } #else /* not Visual Studio .NET */ char *path; char *name; struct dirent *entry; int len; int suffix; DIR *dir = opendir (in_dir); if (!dir) goto error; while (1) { /* extracting the SHP candidates */ entry = readdir (dir); if (!entry) break; suffix = check_extension (entry->d_name); if (suffix == SUFFIX_DISCARD) continue; path = sqlite3_mprintf ("%s/%s", in_dir, entry->d_name); len = strlen (path); path[len - 4] = '\0'; name = sqlite3_mprintf ("%s", entry->d_name); len = strlen (name); name[len - 4] = '\0'; do_add_shapefile (list, path, name, suffix); } closedir (dir); #endif p_shp = list->first; while (p_shp != NULL) { if (test_valid_shp (p_shp)) { int invalid; if (!do_test_shapefile (cache, p_shp->base_name, validate, esri, &invalid)) goto error; *n_shp += 1; if (invalid) *x_shp += 1; if ((invalid || force) && out_dir != NULL) { /* attempting to repair */ int repair_failed; int ret; char *out_path = sqlite3_mprintf ("%s/%s", out_dir, p_shp->file_name); fprintf (stderr, "\tAttempting to repair: %s.shp\n", out_path); ret = do_repair_shapefile (cache, p_shp->base_name, out_path, validate, esri, force, &repair_failed); sqlite3_free (out_path); if (!ret) goto error; if (repair_failed) { do_clen_files (out_dir, p_shp->base_name); fprintf (stderr, "\tFAILURE: automatic repair is impossible, manual repair required.\n"); } else { *r_shp += 1; fprintf (stderr, "\tOK, successfully repaired.\n"); } } } p_shp = p_shp->next; } free_shp_list (list); return 1; error: free_shp_list (list); fprintf (stderr, "Unable to access \"%s\"\n", in_dir); return 0; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "shp_sanitize : %s\n", VERSION); fprintf (stderr, "target CPU ..: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ..: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: shp_sanitize ARGLIST\n"); fprintf (stderr, "=================================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-idir or --in-dir dir-path directory expected to contain\n" " all SHP to be checked\n"); fprintf (stderr, "-odir or --out-dir dir-path <optional> directory where to\n" " store all repaired SHPs\n\n"); fprintf (stderr, "======================= optional args ===========================\n" "-geom or --invalid-geoms checks for invalid Geometries\n" "-esri or --esri-flag tolerates ESRI-like inner holes\n" "-force or --force-repair unconditionally repair\n\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ int i; int error = 0; int next_arg = ARG_NONE; char *in_dir = NULL; char *out_dir = NULL; int validate = 0; int esri = 0; int force = 0; int n_shp = 0; int r_shp = 0; int x_shp = 0; const void *cache; for (i = 1; i < argc; i++) { /* parsing the invocation arguments */ if (next_arg != ARG_NONE) { switch (next_arg) { case ARG_IN_DIR: in_dir = argv[i]; break; case ARG_OUT_DIR: out_dir = argv[i]; break; }; next_arg = ARG_NONE; continue; } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "-idir") == 0 || strcasecmp (argv[i], "--in-dir") == 0) { next_arg = ARG_IN_DIR; continue; } if (strcasecmp (argv[i], "-odir") == 0 || strcasecmp (argv[i], "--out-dir") == 0) { next_arg = ARG_OUT_DIR; continue; } if (strcasecmp (argv[i], "-geom") == 0 || strcasecmp (argv[i], "--invalid-geoms") == 0) { validate = 1; continue; } if (strcasecmp (argv[i], "-esri") == 0 || strcasecmp (argv[i], "--esri-flag") == 0) { esri = 1; continue; } if (strcasecmp (argv[i], "-force") == 0 || strcasecmp (argv[i], "--force-repair") == 0) { force = 1; continue; } fprintf (stderr, "unknown argument: %s\n", argv[i]); error = 1; } if (error) { do_help (); return -1; } /* checking the arguments */ if (!in_dir) { fprintf (stderr, "did you forget setting the --in-dir argument ?\n"); error = 1; } if (error) { do_help (); return -1; } #ifndef ENABLE_RTTOPO /* only if RTTOPO is disabled */ if (validate) { validate = 0; fprintf (stderr, "the --validate-geoms option will be ignored because\n" "this copy of \"shp_sanitize\" was built by disabling RTTOPO support.\n\n"); } #endif /* end RTTOPO conditional */ if (out_dir != NULL) { #ifdef _WIN32 if (_mkdir (out_dir) != 0) #else if (mkdir (out_dir, 0777) != 0) #endif { fprintf (stderr, "ERROR: unable to create the output directory\n%s\n%s\n\n", out_dir, strerror (errno)); return -1; } } cache = spatialite_alloc_connection (); spatialite_set_silent_mode (cache); fprintf (stderr, "\nInput dir: %s\n", in_dir); if (out_dir != NULL) { fprintf (stderr, "Output dir: %s\n", out_dir); if (force) fprintf (stderr, "Unconditionally repairing all Shapefiles\n"); } else fprintf (stderr, "Only a diagnostic report will be reported\n"); if (validate) { fprintf (stderr, "Checking for invalid geometries (%s mode)\n", esri ? "ESRI" : "ISO/OGC"); } if (!do_scan_dir (cache, in_dir, out_dir, &n_shp, &r_shp, &x_shp, validate, esri, force)) { fprintf (stderr, "\n... quitting ... some unexpected error occurred\n"); spatialite_cleanup_ex (cache); return -1; } fprintf (stderr, "\n===========================================\n"); fprintf (stderr, "%d Shapefil%s ha%s been inspected.\n", n_shp, (n_shp > 1) ? "es" : "e", (n_shp > 1) ? "ve" : "s"); fprintf (stderr, "%d malformed Shapefil%s ha%s been identified.\n", x_shp, (x_shp > 1) ? "es" : "e", (x_shp > 1) ? "ve" : "s"); fprintf (stderr, "%d Shapefil%s ha%s been repaired.\n\n", r_shp, (r_shp > 1) ? "es" : "e", (r_shp > 1) ? "ve" : "s"); spatialite_cleanup_ex (cache); return 0; } |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to spatialite_convert.c.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 .... 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 .... 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif ................................................................................ return; } spatialite_init_ex (db_handle, cache, 0); *handle = db_handle; return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_convert: %s\n", VERSION); fprintf (stderr, "target CPU .......: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ....: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .......: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_convert ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "-tv or --target-version num target Version (2, 3, 4)\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ sqlite3 *handle; ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--target-version") == 0 || strcmp (argv[i], "-tv") == 0) { next_arg = ARG_VERSION; continue; } fprintf (stderr, "unknown argument: %s\n", argv[i]); error = 1; } |
< < < < < < < < < < < < < < < < < < | < < < < < < | | |
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 .... 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 .... 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include "config.h" #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif ................................................................................ return; } spatialite_init_ex (db_handle, cache, 0); *handle = db_handle; return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_convert ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "-v or --version num target Version (2, 3, 4)\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ sqlite3 *handle; ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { next_arg = ARG_VERSION; continue; } fprintf (stderr, "unknown argument: %s\n", argv[i]); error = 1; } |
Deleted spatialite_dem.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 |
/* / spatialite_dem / / a tool for setting Z coordinates from XYZ files / / version 1.0, 2017-09-14 / / Author: Mark Johnson, Berlin Germany mj10777@googlemail.com / / Copyright (C) 2017 Alessandro Furieri / / This program is free software: you can redistribute it and/or modify / it under the terms of the GNU General Public License as published by / the Free Software Foundation, either version 3 of the License, or / (at your option) any later version. / / This program is distributed in the hope that it will be useful, / but WITHOUT ANY WARRANTY; without even the implied warranty of / MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / GNU General Public License for more details. / / You should have received a copy of the GNU General Public License / along with this program. If not, see <http://www.gnu.source_geom/licenses/>. / */ // -- -- ---------------------------------- -- // astyle spatialite_dem.c // valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all --log-file=valgrind.spatialite_dem.utm_fetchz.txt ./spatialite_dem -fetchz_xy 24747.115253 20725.147344 // -- -- ---------------------------------- -- #if defined(_WIN32) && !defined(__MINGW32__) /* MSVC strictly requires this include [off_t] */ #include <sys/types.h> #endif #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #include <time.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #include <io.h> #include <direct.h> #else #include "config.h" #include <dirent.h> #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite/gaiaaux.h> #include <spatialite/gaiageo.h> #include <spatialite.h> #ifdef _WIN32 #define strcasecmp _stricmp #endif /* not WIN32 */ // -- -- ---------------------------------- -- #define ARG_NONE 0 #define ARG_DB_PATH 1 #define ARG_TABLE 2 #define ARG_COL 3 #define ARG_DEM_PATH 4 #define ARG_TABLE_DEM 5 #define ARG_COL_DEM 6 #define ARG_RESOLUTION_DEM 7 #define ARG_COPY_M 8 #define ARG_COMMAND_TYPE 9 #define ARG_FETCHZ_X 10 #define ARG_FETCHZ_Y 11 #define ARG_FETCHZ_XY 12 #define ARG_DEFAULT_SRID 13 // -- -- ---------------------------------- -- #define CMD_DEM_SNIFF 100 #define CMD_DEM_FETCHZ 101 #define CMD_DEM_CREATE 102 #define CMD_DEM_IMPORT_XYZ 103 #define CMD_DEM_UPDATEZ 104 // -- -- ---------------------------------- -- #define CONF_TYPE_DEM 1 #define CONF_TYPE_SOURCE 2 // -- -- ---------------------------------- -- // Definitions used for dem-conf // -- -- ---------------------------------- -- #define MAXBUF 1024 #define DELIM "=" #ifdef _WIN32 #define LENGTHNL 2 #else #define LENGTHNL 1 #endif /* not WIN32 */ // -- -- ---------------------------------- -- // Output of time elapse // min = (int)(time_diff.tv_sec/60); // secs = (int)(time_diff.tv_sec-(min*60)); // msecs = (int)(time_diff.tv_usec/1000); // printf("%d mins %02d.%03d secs",min,sec,msecs); // -- -- ---------------------------------- -- int timeval_subtract (struct timeval *time_diff, struct timeval *time_end, struct timeval *time_start, char **time_message) { int diff=0; int days=0; int hours=0; int mins=0; int secs=0; int msecs=0; // Perform the carry for the later subtraction by updating time_start. if (time_end->tv_usec < time_start->tv_usec) { int nsec = (time_start->tv_usec - time_end->tv_usec) / 1000000 + 1; time_start->tv_usec -= 1000000 * nsec; time_start->tv_sec += nsec; } if (time_end->tv_usec - time_start->tv_usec > 1000000) { int nsec = (time_end->tv_usec - time_start->tv_usec) / 1000000; time_start->tv_usec += 1000000 * nsec; time_start->tv_sec -= nsec; } // Compute the time remaining to wait. tv_usec is certainly positive. time_diff->tv_sec = time_end->tv_sec - time_start->tv_sec; time_diff->tv_usec = time_end->tv_usec - time_start->tv_usec; // -- -- ---------------------------------- -- diff = (int)time_diff->tv_sec; if (diff > 86400 ) {// sec per day days = diff / 86400; diff = diff-(days*86400); } if (diff > 3660 ) {// sec per hour hours = diff / 3660; diff = diff -(hours*3660); } if (diff > 60 ) { mins = diff / 60; } secs = diff - (mins * 60); msecs = (int)(time_diff->tv_usec/1000); // -- -- ---------------------------------- -- if (*time_message) { sqlite3_free(*time_message); *time_message = NULL; } if ( days > 0) { *time_message = sqlite3_mprintf(">> time needed: %2 days %02d hours %02d mins %02d secs %02d milli-secs", days, hours, mins, secs,msecs); } else if ( hours > 0) { *time_message = sqlite3_mprintf(">> time needed: %02d hours %02d mins %02d secs %02d milli-secs", hours, mins, secs,msecs); } else if ( mins > 0) { *time_message = sqlite3_mprintf(">> time needed: %02d mins %02d secs %02d milli-secs", mins, secs,msecs); } else if (secs > 0 ) { *time_message = sqlite3_mprintf(">> time needed: %02d secs %02d milli-secs", secs,msecs); } else { *time_message = sqlite3_mprintf(">> time needed: %02d milli-secs",msecs); } // -- -- ---------------------------------- -- // Return 1 if time_diff is negative. return time_end->tv_sec < time_start->tv_sec; // -- -- ---------------------------------- -- } // -- -- ---------------------------------- -- // dem-conf structure // -- -- ---------------------------------- -- struct config_dem { char dem_path[MAXBUF]; char dem_table[MAXBUF]; char dem_geometry[MAXBUF]; double dem_extent_minx; double dem_extent_miny; double dem_extent_maxx; double dem_extent_maxy; double dem_resolution; int dem_srid; unsigned int dem_rows_count; int default_srid; // Not to be used for conf_file [internal use only] char *schema; double fetchz_x; double fetchz_y; double dem_z; double dem_m; int has_z; int has_m; int has_spatial_index; int is_spatial_table; int config_type; // dem=0 ; source=1; unsigned int id_rowid; // For debugging unsigned int count_points; // For debugging unsigned int count_points_nr; // For debugging }; // -- -- ---------------------------------- -- // Reading dem-conf // Environment var 'SPATIALITE_DEM' // - with path to dem-conf // -> must be created by // (or using same syntax as) write_demconfig // -- -- ---------------------------------- -- // if not found, the tool will look for a // - 'spatialite_dem.conf' file in the active directory // if not found, default values will be used // -- -- ---------------------------------- -- // - any line not starting // -> with a '#' [comment] // -> not containing a '=' will be ignored // - any other line will look for specific // keywords before the '=' // -> unknown keywords will be ignored // -- -- ---------------------------------- -- struct config_dem get_demconfig(char *conf_filename, int verbose) { struct config_dem config_struct; // -- -- ---------------------------------- -- // Setting default values // -- -- ---------------------------------- -- strcpy(config_struct.dem_path,""); strcpy(config_struct.dem_table,""); strcpy(config_struct.dem_geometry,""); config_struct.dem_extent_minx=0.0; config_struct.dem_extent_miny=0.0; config_struct.dem_extent_maxx=0.0; config_struct.dem_extent_maxy=0.0; config_struct.dem_resolution=0.0; config_struct.dem_srid=-2; // invalid config_struct.default_srid=-2; // invalid config_struct.dem_rows_count=0; // -- -- ---------------------------------- -- // Not to be used for conf_file [internal use only] // -- -- ---------------------------------- -- config_struct.fetchz_x=0.0; config_struct.fetchz_y=0.0; config_struct.dem_z=0.0; config_struct.dem_m=0.0; config_struct.has_z=0; config_struct.has_m=0; config_struct.has_spatial_index=0; config_struct.is_spatial_table=0; config_struct.schema=NULL; config_struct.config_type=-1; config_struct.id_rowid=0; // For debugging config_struct.count_points=0; // For debugging config_struct.count_points_nr=0; // For debugging // -- -- ---------------------------------- -- if ((conf_filename) && (strlen(conf_filename) > 0) ) { FILE *conf_file = fopen(conf_filename, "r"); if (conf_file != NULL) { char line[MAXBUF]; while(fgets(line, sizeof(line), conf_file) != NULL) { char *conf_parm=NULL; char *conf_value=NULL; conf_parm=(char *)line; conf_value = strstr((char *)line,DELIM); // Skip any comments (#) lines that may also contain a '=' if ( (conf_parm[0] != '#') && (conf_value) ) { conf_parm[(int)(conf_value-conf_parm)]=0; conf_value = conf_value + strlen(DELIM); conf_value[strcspn(conf_value, "\r\n")] = 0; // printf("parm[%s] value[%s]\n",conf_parm,conf_value); if (strcmp(conf_parm,"dem_path") == 0) { strcpy(config_struct.dem_path,conf_value); // printf("%s[%s]\n",conf_parm,config_struct.dem_path); } else if (strcmp(conf_parm,"dem_table") == 0) { strcpy(config_struct.dem_table,conf_value); // printf("%s[%s]\n",conf_parm,config_struct.dem_table); } else if (strcmp(conf_parm,"dem_geometry") == 0) { strcpy(config_struct.dem_geometry,conf_value); // printf("%s[%s]\n",conf_parm,config_struct.dem_geometry); } else if (strcmp(conf_parm,"dem_extent_minx") == 0) { config_struct.dem_extent_minx=atof(conf_value); //printf("%s[%2.7f]\n",conf_parm,config_struct.dem_extent_minx); } else if (strcmp(conf_parm,"dem_extent_miny") == 0) { config_struct.dem_extent_miny=atof(conf_value); //printf("%s[%2.7f]\n",conf_parm,config_struct.dem_extent_miny); } else if (strcmp(conf_parm,"dem_extent_maxx") == 0) { config_struct.dem_extent_maxx=atof(conf_value); //printf("%s[%2.7f]\n",conf_parm,config_struct.dem_extent_maxx); } else if (strcmp(conf_parm,"dem_extent_maxy") == 0) { config_struct.dem_extent_maxy=atof(conf_value); //printf("%s[%2.7f]\n",conf_parm,config_struct.dem_extent_maxy); } else if (strcmp(conf_parm,"dem_resolution") == 0) { config_struct.dem_resolution=atof(conf_value); //printf("%s[%2.7f]\n",conf_parm,config_struct.dem_resolution); } else if (strcmp(conf_parm,"dem_srid") == 0) { config_struct.dem_rows_count=atol(conf_value); // printf("%s[%d]\n",conf_parm,config_struct.dem_rows_count); } else if (strcmp(conf_parm,"dem_srid") == 0) { config_struct.dem_srid=atoi(conf_value); // printf("%s[%d]\n",conf_parm,config_struct.dem_srid); } else if (strcmp(conf_parm,"default_srid") == 0) { config_struct.default_srid=atoi(conf_value); // printf("%s[%d]\n",conf_parm,config_struct.default_srid); } } } // End while fclose(conf_file); } // End if file else { if (strcmp(conf_filename,"spatialite_dem.conf") != 0) { if (verbose) { fprintf(stderr, "-E-> spatialite_dem: not found: conf_filename[%s]\n",conf_filename); } } } } return config_struct; } // -- -- ---------------------------------- -- // writing dem-conf // - any line not starting // -> with a '#' [comment] // -> not containing a '=' will be ignored // - any other line will look for specific // keywords before the '=' // -> unknown keywords will be ignored // -- -- ---------------------------------- -- // Saving dem-conf '-save_conf' // - will save to files set in 'SPATIALITE_DEM' // - if empty to the default 'spatialite_dem.conf' // -- -- ---------------------------------- -- int write_demconfig(char *conf_filename, struct config_dem config_struct) { int rc=0; FILE *conf_file = fopen(conf_filename, "w"); if (conf_file != NULL) { fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# For use with spatialite_dem\n"); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# export SPATIALITE_DEM=%s\n",conf_filename); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# Full path to Spatialite-Database containing a Dem-POINTZ (or POINTZM) Geometry\n"); fprintf(conf_file, "dem_path=%s\n", config_struct.dem_path); fprintf(conf_file, "# Table-Name containing a Dem-POINTZ (or POINTZM) Geometry\n"); fprintf(conf_file, "dem_table=%s\n", config_struct.dem_table); fprintf(conf_file, "# Geometry-Column containing a Dem-POINTZ (or POINTZM) Geometry\n"); fprintf(conf_file, "dem_geometry=%s\n", config_struct.dem_geometry); fprintf(conf_file, "# Srid of the Dem-Geometry\n"); fprintf(conf_file, "dem_srid=%d\n", config_struct.dem_srid); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# Area around given point to Query Dem-Geometry in units of Dem-Srid\n"); fprintf(conf_file, "# -> Rule: a Dem with 1m resolution: min=0.50\n"); fprintf(conf_file, "dem_resolution=%2.7f\n", config_struct.dem_resolution); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# Default Srid to use for queries against Dem-Geometry [-fetchz_xy, -updatez]\n"); fprintf(conf_file, "default_srid=%d\n", config_struct.default_srid); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fprintf(conf_file, "# Count of rows in Dem-Geometry\n"); fprintf(conf_file, "dem_rows_count=%u\n", config_struct.dem_rows_count); fprintf(conf_file, "# Min X of Dem-Geometry\n"); fprintf(conf_file, "dem_extent_minx=%2.7f\n", config_struct.dem_extent_minx); fprintf(conf_file, "# Max X of Dem-Geometry\n"); fprintf(conf_file, "dem_extent_maxx=%2.7f\n", config_struct.dem_extent_maxx); fprintf(conf_file, "# Min Y of Dem-Geometry\n"); fprintf(conf_file, "dem_extent_miny=%2.7f\n", config_struct.dem_extent_miny); fprintf(conf_file, "# Max Y of Dem-Geometry\n"); fprintf(conf_file, "dem_extent_maxy=%2.7f\n", config_struct.dem_extent_maxy); fprintf(conf_file, "# Width of Dem-Area in Srid-Units\n"); fprintf(conf_file, "dem_extent_width=%2.7f\n", (config_struct.dem_extent_maxx-config_struct.dem_extent_minx)); fprintf(conf_file, "# Height of Dem-Area in Srid-Units\n"); fprintf(conf_file, "dem_extent_height=%2.7f\n", (config_struct.dem_extent_maxy-config_struct.dem_extent_miny)); fprintf(conf_file, "# -- -- ---------------------------------- --\n"); fclose(conf_file); rc=1; } return rc; } // -- -- ---------------------------------- -- // From a given point, build area around it by 'resolution_dem' // - utm 0.999 meters, Solder Berlin 1.0375644 meters // (resolution_dem/2) could also be done // - but to insure that at least 1 point is returned, left as is // The nearest point will always be retrieved, or none at all. // -- -- ---------------------------------- -- static int insert_dem_points(sqlite3 *db_handle, struct config_dem *dem_config, double *xx_source, double *yy_source, double *zz_source, int verbose) { /* checking for 3D geometries - version 4 */ int ret=0; int ret_insert=SQLITE_OK; int i=0; char *sql_statement = NULL; sqlite3_stmt *stmt = NULL; char *sql_err = NULL; if (zz_source) { sql_statement = sqlite3_mprintf("INSERT INTO \"%s\" (point_x,point_y, point_z,\"%s\") " "VALUES(?,?,?,MakePointZ(?,?,?,%d)) ",dem_config->dem_table,dem_config->dem_geometry,dem_config->dem_srid); ret = sqlite3_prepare_v2( db_handle, sql_statement, -1, &stmt, NULL ); if ( ret == SQLITE_OK ) { sqlite3_free(sql_statement); if (sqlite3_exec(db_handle, "BEGIN", NULL, NULL, &sql_err) == SQLITE_OK) { for (i=0; i<(int)(dem_config->count_points); i++) { if (ret_insert != SQLITE_ABORT ) { // Note: sqlite3_bind_* index is 1-based, os apposed to sqlite3_column_* that is 0-based. sqlite3_bind_double(stmt, 1, xx_source[i]); sqlite3_bind_double(stmt, 2, yy_source[i]); sqlite3_bind_double(stmt, 3, zz_source[i]); sqlite3_bind_double(stmt, 4, xx_source[i]); sqlite3_bind_double(stmt, 5, yy_source[i]); sqlite3_bind_double(stmt, 6, zz_source[i]); dem_config->count_points_nr=i; ret_insert = sqlite3_step( stmt ); if ( ret_insert == SQLITE_DONE || ret_insert == SQLITE_ROW ) { ret_insert=SQLITE_OK; } else { ret_insert=SQLITE_ABORT; } } sqlite3_reset(stmt); sqlite3_clear_bindings(stmt); xx_source[i]=0.0; yy_source[i]=0.0; zz_source[i]=0.0; } ret=0; if (ret_insert == SQLITE_ABORT ) { if (sqlite3_exec(db_handle, "ROLLBACK", NULL, NULL, &sql_err) == SQLITE_OK) { ret=0; } } else { if (sqlite3_exec(db_handle, "COMMIT", NULL, NULL, &sql_err) == SQLITE_OK) { ret = 1; dem_config->dem_rows_count+=dem_config->count_points; dem_config->count_points=0; dem_config->count_points_nr=0; } } } sqlite3_finalize( stmt ); if (sql_err) { sqlite3_free(sql_err); } } else { if (verbose) { fprintf(stderr, "-W-> insert_dem_points: rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } } return ret; } // -- -- ---------------------------------- -- // From a given point, build area around it by 'resolution_dem' // - utm 0.999 meters, Solder Berlin 1.0375644 meters // (resolution_dem/2) could also be done // - but to insure that at least 1 point is returned, left as is // The nearest point will always be retrieved, or none at all. // -- -- ---------------------------------- -- static int retrieve_dem_points(sqlite3 *db_handle, struct config_dem *dem_config, int count_points, double *xx_source, double *yy_source, double *zz, double *mm, int *count_z, int *count_m, int verbose) { /* checking for 3D geometries - version 4 */ int ret=0; int i=0; char *sql_statement = NULL; sqlite3_stmt *stmt = NULL; int has_m = 0; double x_source=0.0; double y_source=0.0; double z_source=0.0; double m_source=0.0; *count_z=0; *count_m=0; if (mm) { has_m = 1; } if (zz) { for (i=0; i<count_points; i++) { dem_config->count_points_nr=i; x_source=xx_source[i]; y_source=yy_source[i]; /* checking the GEOMETRY_COLUMNS table */ if (has_m) { sql_statement = sqlite3_mprintf("SELECT ST_Z(\"%s\"), ST_M(\"%s\") " "FROM '%s'.'%s' WHERE (ROWID IN ( " "SELECT ROWID FROM SpatialIndex WHERE ( " "(f_table_name = 'DB=%s.%s') AND " "(f_geometry_column = '%s') AND " "(search_frame = ST_Buffer(MakePoint(%2.7f,%2.7f,%d),%2.7f)))) AND " "(ST_ClosestPoint(%s, MakePoint(%2.7f,%2.7f,%d)) IS NOT Null) ) " "ORDER BY ST_Distance(%s,MakePoint(%2.7f,%2.7f,%d)) ASC LIMIT 1" ,dem_config->dem_geometry,dem_config->dem_geometry,dem_config->schema,dem_config->dem_table,dem_config->schema,dem_config->dem_table ,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid,dem_config->dem_resolution ,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid); } else { sql_statement = sqlite3_mprintf("SELECT ST_Z(\"%s\") " "FROM '%s'.'%s' WHERE (ROWID IN ( " "SELECT ROWID FROM SpatialIndex WHERE (" "(f_table_name = 'DB=%s.%s') AND " "(f_geometry_column = '%s') AND " "(search_frame = ST_Buffer(MakePoint(%2.7f,%2.7f,%d),%2.7f)))) AND " "(ST_ClosestPoint(%s, MakePoint(%2.7f,%2.7f,%d)) IS NOT Null) ) " "ORDER BY ST_Distance(%s,MakePoint(%2.7f,%2.7f,%d)) ASC LIMIT 1" ,dem_config->dem_geometry,dem_config->schema,dem_config->dem_table,dem_config->schema,dem_config->dem_table ,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid,dem_config->dem_resolution ,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid,dem_config->dem_geometry,x_source,y_source,dem_config->dem_srid); } ret = sqlite3_prepare_v2( db_handle, sql_statement, -1, &stmt, NULL ); #if 0 if ((dem_config->id_rowid == 354) && (dem_config->count_points == 207)) { fprintf(stderr, "-III-> [EXTERIOR RING] -1a- cnt[%d,%d,%d] sql[%s] id_rowid[%d]\n",dem_config->count_points,dem_config->count_points_nr,ret,sql_statement,dem_config->id_rowid); } #endif if ( ret == SQLITE_OK ) { sqlite3_free(sql_statement); while ( sqlite3_step( stmt ) == SQLITE_ROW ) { if ( sqlite3_column_type( stmt, 0 ) != SQLITE_NULL ) { z_source = sqlite3_column_double (stmt, 0); if ( (z_source != 0.0 ) && (zz[i] != z_source ) ) {// Do not force an update if everything is 0 or has not otherwise changed zz[i] = z_source; *count_z += 1; } } if ( sqlite3_column_type( stmt, 1 ) != SQLITE_NULL ) { m_source = sqlite3_column_double (stmt, 1); if ( (m_source != 0.0 ) && (mm[i] != m_source ) ) {// Do not force an update if everything is 0 or has not otherwise changed mm[i] = m_source; *count_m += 1; } mm[i] = sqlite3_column_double (stmt, 1); } } sqlite3_finalize( stmt ); } else { if (verbose) { fprintf(stderr, "-W-> retrieve_dem_points: rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } } } // printf("-I-> retrieve_dem_points: total[%d] not 0.0: z[%d] m[%d]\n",count_points,*count_z,*count_m); if (*count_z > 0) return 1; return 0; } // -- -- ---------------------------------- -- // // -- -- ---------------------------------- -- static int callFetchZ(sqlite3 *db_handle, struct config_dem *dem_config, int verbose) { int ret=0; char *sql_statement = NULL; sqlite3_stmt *stmt = NULL; int i_count_z=0; int i_count_m=0; double *xx_use = NULL; double *yy_use = NULL; double *mm_use = NULL; double *zz = NULL; // -- -- ---------------------------------- -- dem_config->dem_z=0;; dem_config->dem_m=0; // -- -- ---------------------------------- -- if (dem_config->dem_srid != dem_config->default_srid ) { sql_statement = sqlite3_mprintf("SELECT ST_X(ST_Transform(MakePoint(%2.7f,%2.7f,%d),%d)), " "ST_Y(ST_Transform(MakePoint(%2.7f,%2.7f,%d),%d))" ,dem_config->fetchz_x, dem_config->fetchz_y, dem_config->default_srid,dem_config->dem_srid ,dem_config->fetchz_x, dem_config->fetchz_y, dem_config->default_srid,dem_config->dem_srid); ret = sqlite3_prepare_v2( db_handle, sql_statement, -1, &stmt, NULL ); if ( ret == SQLITE_OK ) { sqlite3_free(sql_statement); while ( sqlite3_step( stmt ) == SQLITE_ROW ) { if (( sqlite3_column_type( stmt, 0 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 1 ) != SQLITE_NULL ) ) { dem_config->fetchz_x = sqlite3_column_double(stmt, 0); dem_config->fetchz_y = sqlite3_column_double(stmt, 1); } } sqlite3_finalize( stmt ); } else { if (verbose) { fprintf(stderr, "-W-> callFetchZ : rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } } // -- -- ---------------------------------- -- ret=0; if ((dem_config->fetchz_x >= dem_config->dem_extent_minx) && (dem_config->fetchz_x <= dem_config->dem_extent_maxx) && (dem_config->fetchz_y >= dem_config->dem_extent_miny) && (dem_config->fetchz_y <= dem_config->dem_extent_maxy ) ) { xx_use = malloc(sizeof (double) * 1); yy_use = malloc(sizeof (double) * 1); zz = malloc(sizeof (double) * 1); mm_use = malloc(sizeof (double) * 1); xx_use[0] = dem_config->fetchz_x; yy_use[0] = dem_config->fetchz_y; zz[0] = dem_config->dem_z; mm_use[0] = dem_config->dem_m; dem_config->count_points=1; if (retrieve_dem_points(db_handle, dem_config, 1, xx_use, yy_use,zz,mm_use,&i_count_z, &i_count_m,verbose)) { ret=1; dem_config->dem_z=zz[0]; dem_config->dem_m=mm_use[0]; } free(xx_use); free(yy_use); free(zz); free(mm_use); xx_use = NULL; yy_use = NULL; mm_use = NULL; zz = NULL; } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // GNU libc (Linux, and FreeBSD) // - sys/param.h // -- -- ---------------------------------- -- #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) // -- -- ---------------------------------- -- // Based on gg_transform.c gaiaTransformCommon // if the source geometry is out of range of the dem area, NULL is returned // if the if the z or m values have not changed, NULL is returned // - in both cases no update should be done and is not an error // if the Dem-Database Geometry-Column uses a different Srid // - a second Geometry will be sent with the transfored values // --> those x,y values will be sent to retrieve_dem_points // to retrieve the nearst point // The retrieved z,m values will be copied WITHOUT any changes // -- -- ---------------------------------- -- static gaiaGeomCollPtr getDemCollect(sqlite3 *db_handle, gaiaGeomCollPtr source_geom, gaiaGeomCollPtr dem_geom, struct config_dem *dem_config, int *count_points_total, int *count_z_total, int *count_m_total, int verbose) { // creates a new GEOMETRY replacing found z-points from the original one int ib=0; int cnt=0; int i=0; double *xx = NULL; double *yy = NULL; double *xx_dem = NULL; double *yy_dem = NULL; double *zz = NULL; double *mm = NULL; double *xx_use = NULL; double *yy_use = NULL; double *mm_use = NULL; int count_z=0; int count_m=0; int i_count_z=0; int i_count_m=0; double x = 0.0; double y = 0.0; double z = 0.0; double m = 0.0; double extent_minx=0.0; double extent_miny=0.0; double extent_maxx=0.0; double extent_maxy=0.0; int error = 0; int isExtentWithin=0; gaiaPointPtr pt = NULL; gaiaPointPtr pt_dem = NULL; gaiaLinestringPtr ln = NULL; gaiaLinestringPtr ln_dem = NULL; gaiaLinestringPtr dst_ln = NULL; gaiaPolygonPtr pg = NULL; gaiaPolygonPtr pg_dem = NULL; gaiaPolygonPtr dst_pg = NULL; gaiaRingPtr rng = NULL; gaiaRingPtr rng_dem = NULL; gaiaRingPtr dst_rng = NULL; gaiaGeomCollPtr dst = NULL; if (source_geom->DimensionModel == GAIA_XY_Z) dst = gaiaAllocGeomCollXYZ(); else if (source_geom->DimensionModel == GAIA_XY_M) dst = gaiaAllocGeomCollXYM(); else if (source_geom->DimensionModel == GAIA_XY_Z_M) dst = gaiaAllocGeomCollXYZM(); else dst = gaiaAllocGeomColl (); cnt = 0; dst->Srid = source_geom->Srid; pt = source_geom->FirstPoint; extent_minx=source_geom->MinX; extent_miny=source_geom->MinY; extent_maxx=source_geom->MaxX; extent_maxy=source_geom->MaxY; if (dem_geom) { extent_minx=dem_geom->MinX; extent_miny=dem_geom->MinY; extent_maxx=dem_geom->MaxX; extent_maxy=dem_geom->MaxY; } // -- -- ---------------------------------- -- // Touches (partially within) // -- -- ---------------------------------- -- int left_x = MAX(extent_minx, dem_config->dem_extent_minx); int right_x = MIN(extent_maxx, dem_config->dem_extent_maxx); int bottom_y = MAX(extent_miny, dem_config->dem_extent_miny); int top_y = MIN(extent_maxy, dem_config->dem_extent_maxy); if ((right_x > left_x) && (top_y > bottom_y)) { isExtentWithin=1; } // -- -- ---------------------------------- -- #if 0 if ((extent_minx >= dem_config->dem_extent_minx) && (extent_maxx <= dem_config->dem_extent_maxx) && (extent_miny >= dem_config->dem_extent_miny) && (extent_maxy <= dem_config->dem_extent_maxy ) ) { isExtentWithin=1; } #endif if (!isExtentWithin) { error=1; goto stop; } // -- -- ---------------------------------- -- // Call only if geometry is partially within the Dem extent // -- -- ---------------------------------- -- // Points // -- -- ---------------------------------- -- while (pt) { // counting POINTs cnt++; pt = pt->Next; } if (cnt) { // reprojecting POINTs xx = malloc(sizeof (double) * cnt); yy = malloc(sizeof (double) * cnt); if (dem_geom) { xx_dem = malloc(sizeof (double) * cnt); yy_dem = malloc(sizeof (double) * cnt); xx_use = xx_dem; yy_use = yy_dem; } else { xx_use = xx; yy_use = yy; } zz = malloc(sizeof (double) * cnt); if (source_geom->DimensionModel == GAIA_XY_M || source_geom->DimensionModel == GAIA_XY_Z_M) mm = malloc(sizeof (double) * cnt); i = 0; pt = source_geom->FirstPoint; if (dem_geom) { pt_dem = dem_geom->FirstPoint; } while (pt) { // inserting points to be converted in temporary arrays xx[i] = pt->X; yy[i] = pt->Y; if (source_geom->DimensionModel == GAIA_XY_Z || source_geom->DimensionModel == GAIA_XY_Z_M) zz[i] = pt->Z; else zz[i] = 0.0; if (source_geom->DimensionModel == GAIA_XY_M || source_geom->DimensionModel == GAIA_XY_Z_M) mm[i] = pt->M; if (pt_dem) { xx_dem[i] = pt_dem->X; yy_dem[i] = pt_dem->Y; } i++; // -- -- ---------------------------------- -- // MultiPoints, next // -- -- ---------------------------------- -- pt = pt->Next; if (dem_geom) { pt_dem =pt_dem->Next; } } if ((dem_config->has_m) && (mm) ) { mm_use = mm; } // searching for nearest point *count_points_total+=cnt; i_count_z=0; i_count_m=0; dem_config->count_points=cnt; if (retrieve_dem_points(db_handle, dem_config, cnt, xx_use, yy_use,zz,mm_use,&i_count_z, &i_count_m,verbose)) { *count_z_total+=i_count_z; *count_m_total+=i_count_m; count_z+=i_count_z; count_m+=i_count_m; } xx_use = NULL; yy_use = NULL; mm_use = NULL; // inserting the reprojected POINTs in the new GEOMETRY for (i = 0; i < cnt; i++) { x = xx[i]; y = yy[i]; if (source_geom->DimensionModel == GAIA_XY_Z || source_geom->DimensionModel == GAIA_XY_Z_M) z = zz[i]; else z = 0.0; if (source_geom->DimensionModel == GAIA_XY_M || source_geom->DimensionModel == GAIA_XY_Z_M) m = mm[i]; else m = 0.0; if (dst->DimensionModel == GAIA_XY_Z) gaiaAddPointToGeomCollXYZ(dst, x, y, z); else if (dst->DimensionModel == GAIA_XY_M) gaiaAddPointToGeomCollXYM(dst, x, y, m); else if (dst->DimensionModel == GAIA_XY_Z_M) gaiaAddPointToGeomCollXYZM(dst, x, y, z, m); else gaiaAddPointToGeomColl(dst, x, y); } free(xx); free(yy); free(zz); xx = NULL; yy = NULL; zz = NULL; if (xx_dem) { free(xx_dem); xx_dem = NULL; free(yy_dem); yy_dem = NULL; } if (source_geom->DimensionModel == GAIA_XY_M || source_geom->DimensionModel == GAIA_XY_Z_M) { free(mm); mm = NULL; } } if (error) goto stop; // -- -- ---------------------------------- -- // Linestrings // -- -- ---------------------------------- -- ln = source_geom->FirstLinestring; if (dem_geom) { ln_dem = dem_geom->FirstLinestring; } // Call only if geometry is inside the Dem extent while (ln) { // reprojecting LINESTRINGs cnt = ln->Points; xx = malloc(sizeof (double) * cnt); yy = malloc(sizeof (double) * cnt); if (dem_geom) { xx_dem = malloc(sizeof (double) * cnt); yy_dem = malloc(sizeof (double) * cnt); xx_use = xx_dem; yy_use = yy_dem; } else { xx_use = xx; yy_use = yy; } zz = malloc(sizeof (double) * cnt); if (ln->DimensionModel == GAIA_XY_M || ln->DimensionModel == GAIA_XY_Z_M) mm = malloc(sizeof (double) * cnt); for (i = 0; i < cnt; i++) { // inserting points to be converted in temporary arrays if (ln->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(ln->Coords, i, &x, &y, &z); } else if (ln->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(ln->Coords, i, &x, &y, &m); } else if (ln->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(ln->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(ln->Coords, i, &x, &y); } xx[i] = x; yy[i] = y; if (ln_dem) { if (ln_dem->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(ln_dem->Coords, i, &x, &y, &z); } else if (ln_dem->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(ln->Coords, i, &x, &y, &m); } else if (ln_dem->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(ln_dem->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(ln_dem->Coords, i, &x, &y); } xx_dem[i] = x; yy_dem[i] = y; } if (ln->DimensionModel == GAIA_XY_Z || ln->DimensionModel == GAIA_XY_Z_M) zz[i] = z; else zz[i] = 0.0; if (ln->DimensionModel == GAIA_XY_M || ln->DimensionModel == GAIA_XY_Z_M) mm[i] = m; } if ((dem_config->has_m) && (mm) ) { mm_use = mm; } // searching for nearest point *count_points_total+=cnt; i_count_z=0; i_count_m=0; dem_config->count_points=cnt; if (retrieve_dem_points(db_handle, dem_config, cnt, xx_use, yy_use,zz,mm_use,&i_count_z, &i_count_m,verbose)) { *count_z_total+=i_count_z; *count_m_total+=i_count_m; count_z+=i_count_z; count_m+=i_count_m; } xx_use = NULL; yy_use = NULL; mm_use = NULL; // inserting the reprojected LINESTRING in the new GEOMETRY dst_ln = gaiaAddLinestringToGeomColl (dst, cnt); for (i = 0; i < cnt; i++) { // setting LINESTRING points x = xx[i]; y = yy[i]; if (ln->DimensionModel == GAIA_XY_Z || ln->DimensionModel == GAIA_XY_Z_M) z = zz[i]; else z = 0.0; if (ln->DimensionModel == GAIA_XY_M || ln->DimensionModel == GAIA_XY_Z_M) m = mm[i]; else m = 0.0; if (dst_ln->DimensionModel == GAIA_XY_Z) { gaiaSetPointXYZ (dst_ln->Coords, i, x, y, z); } else if (dst_ln->DimensionModel == GAIA_XY_M) { gaiaSetPointXYM(dst_ln->Coords, i, x, y, m); } else if (dst_ln->DimensionModel == GAIA_XY_Z_M) { gaiaSetPointXYZM(dst_ln->Coords, i, x, y, z, m); } else { gaiaSetPoint(dst_ln->Coords, i, x, y); } } free(xx); free(yy); xx = NULL; yy = NULL; if (xx_dem) { free(xx_dem); xx_dem = NULL; free(yy_dem); yy_dem = NULL; } free(zz); zz = NULL; if (ln->DimensionModel == GAIA_XY_M || ln->DimensionModel == GAIA_XY_Z_M) { free(mm); mm = NULL; } if (error) goto stop; // -- -- ---------------------------------- -- // MultiLinestrings, next // -- -- ---------------------------------- -- ln = ln->Next; if (dem_geom) { ln_dem = ln_dem->Next; } } // -- -- ---------------------------------- -- // Polygons // -- -- ---------------------------------- -- pg = source_geom->FirstPolygon; if (dem_geom) { pg_dem = dem_geom->FirstPolygon; } while (pg) { // -- -- ---------------------------------- -- // Polygons-ExteriorRing // -- -- ---------------------------------- -- rng = pg->Exterior; cnt = rng->Points; dst_pg = gaiaAddPolygonToGeomColl(dst, cnt, pg->NumInteriors); xx = malloc(sizeof (double) * cnt); yy = malloc(sizeof (double) * cnt); if (dem_geom) { xx_dem = malloc(sizeof (double) * cnt); yy_dem = malloc(sizeof (double) * cnt); rng_dem = pg_dem->Exterior; xx_use = xx_dem; yy_use = yy_dem; } else { xx_use = xx; yy_use = yy; } zz = malloc(sizeof (double) * cnt); if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) mm = malloc(sizeof (double) * cnt); for (i = 0; i < cnt; i++) { // inserting points to be converted in temporary arrays [EXTERIOR RING] if (rng->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(rng->Coords, i, &x, &y, &z); } else if (rng->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(rng->Coords, i, &x, &y, &m); } else if (rng->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(rng->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(rng->Coords, i, &x, &y); } xx[i] = x; yy[i] = y; if (rng_dem) { if (rng_dem->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(rng_dem->Coords, i, &x, &y, &z); } else if (rng_dem->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(rng_dem->Coords, i, &x, &y, &m); } else if (rng_dem->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(rng_dem->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(rng_dem->Coords, i, &x, &y); } xx_dem[i] = x; yy_dem[i] = y; } if (rng->DimensionModel == GAIA_XY_Z || rng->DimensionModel == GAIA_XY_Z_M) zz[i] = z; else zz[i] = 0.0; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) mm[i] = m; } if ((dem_config->has_m) && (mm) ) { mm_use = mm; } // searching for nearest point *count_points_total+=cnt; i_count_z=0; i_count_m=0; dem_config->count_points=cnt; if (retrieve_dem_points(db_handle, dem_config, cnt, xx_use, yy_use,zz,mm_use,&i_count_z, &i_count_m,verbose)) { *count_z_total+=i_count_z; *count_m_total+=i_count_m; count_z+=i_count_z; count_m+=i_count_m; } xx_use = NULL; yy_use = NULL; mm_use = NULL; // inserting the reprojected POLYGON in the new GEOMETRY dst_rng = dst_pg->Exterior; for (i = 0; i < cnt; i++) { // setting EXTERIOR RING points x = xx[i]; y = yy[i]; if (rng->DimensionModel == GAIA_XY_Z || rng->DimensionModel == GAIA_XY_Z_M) z = zz[i]; else z = 0.0; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) m = mm[i]; else m = 0.0; if (dst_rng->DimensionModel == GAIA_XY_Z) { gaiaSetPointXYZ (dst_rng->Coords, i, x, y, z); } else if (dst_rng->DimensionModel == GAIA_XY_M) { gaiaSetPointXYM(dst_rng->Coords, i, x, y, m); } else if (dst_rng->DimensionModel == GAIA_XY_Z_M) { gaiaSetPointXYZM(dst_rng->Coords, i, x, y, z, m); } else { gaiaSetPoint(dst_rng->Coords, i, x, y); } } free(xx); free(yy); xx = NULL; yy = NULL; if (xx_dem) { free(xx_dem); xx_dem = NULL; free(yy_dem); yy_dem = NULL; } free(zz); zz = NULL; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) { free(mm); mm = NULL; } if (error) goto stop; // -- -- ---------------------------------- -- // Polygons-InteriorRings // -- -- ---------------------------------- -- for (ib = 0; ib < pg->NumInteriors; ib++) { // processing INTERIOR RINGS rng = pg->Interiors + ib; cnt = rng->Points; xx = malloc(sizeof (double) * cnt); yy = malloc(sizeof (double) * cnt); if (dem_geom) { xx_dem = malloc(sizeof (double) * cnt); yy_dem = malloc(sizeof (double) * cnt); rng_dem = pg_dem->Interiors + ib; xx_use = xx_dem; yy_use = yy_dem; } else { xx_use = xx; yy_use = yy; } zz = malloc(sizeof (double) * cnt); if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) mm = malloc(sizeof (double) * cnt); for (i = 0; i < cnt; i++) { // inserting points to be converted in temporary arrays [INTERIOR RING] if (rng->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(rng->Coords, i, &x, &y, &z); } else if (rng->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(rng->Coords, i, &x, &y, &m); } else if (rng->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(rng->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(rng->Coords, i, &x, &y); } xx[i] = x; yy[i] = y; if (rng_dem) { if (rng_dem->DimensionModel == GAIA_XY_Z) { gaiaGetPointXYZ(rng_dem->Coords, i, &x, &y, &z); } else if (rng_dem->DimensionModel == GAIA_XY_M) { gaiaGetPointXYM(rng_dem->Coords, i, &x, &y, &m); } else if (rng_dem->DimensionModel == GAIA_XY_Z_M) { gaiaGetPointXYZM(rng_dem->Coords, i, &x, &y, &z, &m); } else { gaiaGetPoint(rng_dem->Coords, i, &x, &y); } xx_dem[i] = x; yy_dem[i] = y; } if (rng->DimensionModel == GAIA_XY_Z || rng->DimensionModel == GAIA_XY_Z_M) zz[i] = z; else zz[i] = 0.0; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) mm[i] = m; } if ((dem_config->has_m) && (mm) ) { mm_use = mm; } // searching for nearest point *count_points_total+=cnt; i_count_z=0; i_count_m=0; dem_config->count_points=cnt; if (retrieve_dem_points(db_handle, dem_config, cnt, xx_use, yy_use,zz,mm_use,&i_count_z, &i_count_m,verbose)) { *count_z_total+=i_count_z; *count_m_total+=i_count_m; count_z+=i_count_z; count_m+=i_count_m; } xx_use = NULL; yy_use = NULL; mm_use = NULL; // inserting the reprojected POLYGON in the new GEOMETRY dst_rng = gaiaAddInteriorRing(dst_pg, ib, cnt); for (i = 0; i < cnt; i++) { // setting INTERIOR RING points x = xx[i]; y = yy[i]; if (rng->DimensionModel == GAIA_XY_Z || rng->DimensionModel == GAIA_XY_Z_M) z = zz[i]; else z = 0.0; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) m = mm[i]; else m = 0.0; if (dst_rng->DimensionModel == GAIA_XY_Z) { gaiaSetPointXYZ(dst_rng->Coords, i, x, y, z); } else if (dst_rng->DimensionModel == GAIA_XY_M) { gaiaSetPointXYM(dst_rng->Coords, i, x, y, m); } else if (dst_rng->DimensionModel == GAIA_XY_Z_M) { gaiaSetPointXYZM(dst_rng->Coords, i, x, y, z, m); } else { gaiaSetPoint(dst_rng->Coords, i, x, y); } } free(xx); free(yy); xx = NULL; yy = NULL; if (xx_dem) { free(xx_dem); xx_dem = NULL; free(yy_dem); yy_dem = NULL; } free(zz); zz = NULL; if (rng->DimensionModel == GAIA_XY_M || rng->DimensionModel == GAIA_XY_Z_M) { free(mm); mm = NULL; } if (error) goto stop; } // -- -- ---------------------------------- -- // MultiPolygons, next // -- -- ---------------------------------- -- pg = pg->Next; if (dem_geom) { pg_dem = pg_dem->Next; } } // -- -- ---------------------------------- -- // -end- Geometry types // -- -- ---------------------------------- -- stop: if ((count_z+count_m) == 0) {// Do not force an update if everything is 0 or has not otherwise changed error=1; } if (error) { // some error occurred, or no changes needed gaiaPointPtr pP; gaiaPointPtr pPn; gaiaLinestringPtr pL; gaiaLinestringPtr pLn; gaiaPolygonPtr pA; gaiaPolygonPtr pAn; pP = dst->FirstPoint; while (pP != NULL) { pPn = pP->Next; gaiaFreePoint(pP); pP = pPn; } pL = dst->FirstLinestring; while (pL != NULL) { pLn = pL->Next; gaiaFreeLinestring(pL); pL = pLn; } pA = dst->FirstPolygon; while (pA != NULL) { pAn = pA->Next; gaiaFreePolygon(pA); pA = pAn; } dst->FirstPoint = NULL; dst->LastPoint = NULL; dst->FirstLinestring = NULL; dst->LastLinestring = NULL; dst->FirstPolygon = NULL; dst->LastPolygon = NULL; gaiaFreeGeomColl(dst); dst = NULL; // -- -- ---------------------------------- -- // if the source geometry is out of range of the dem area, NULL is returned // -- -- ---------------------------------- -- return NULL; } if (dst) { gaiaMbrGeometry(dst); dst->DeclaredType = source_geom->DeclaredType; } return dst; } // -- -- ---------------------------------- -- // if the source geometry is out of range of the dem area, NULL is returned // - no update should be done and is not an error // if the source geometry cannot be updated, when changed // - this is an error and the loop should stop // The source must be a SpatialTable, // - since ROWID is used for a (possibly) needed update // -- -- ---------------------------------- -- static int retrieve_geometries(sqlite3 *db_handle, struct config_dem *source_config, struct config_dem *dem_config, int *count_total_geometries, int *count_changed_geometries, int *count_points_total, int *count_z_total, int *count_m_total, int verbose) { char *sql_statement = NULL; sqlite3_stmt *stmt = NULL; sqlite3_stmt *stmt_update = NULL; char *sql_err = NULL; unsigned char *blob_value = NULL; int blob_bytes=0; unsigned char *blob_update = NULL; int blob_bytes_update=0; int id_rowid=0; int ret=0; int ret_update=SQLITE_ABORT; unsigned int i_sleep=1; // 1 second int count_geometries_remainder=100; int transaction_update_changed_last=0; int transaction_count_loops=0; double remainder_calc=0.10; gaiaGeomCollPtr source_geom = NULL; gaiaGeomCollPtr geom_dem = NULL; gaiaGeomCollPtr geom_result = NULL; *count_total_geometries=0; *count_changed_geometries=0; *count_points_total=0; *count_z_total=0; *count_m_total=0; // -- -- ---------------------------------- -- count_geometries_remainder=source_config->dem_rows_count/100; if (count_geometries_remainder > 1000) {// Display results every 1.25% of total geometries, when verbose remainder_calc=remainder_calc/8; } else if (source_config->dem_rows_count > 500) {// Display results every 2.5% of total geometries, when verbose remainder_calc=remainder_calc/4; } else if (source_config->dem_rows_count > 100) {// Display results every 5% of total geometries, when verbose remainder_calc=remainder_calc/2; } // else: Display results every 10% of total geometries, when verbose count_geometries_remainder=(int)(source_config->dem_rows_count*remainder_calc); // -- -- ---------------------------------- -- if (verbose) { fprintf(stderr, "-I-> retrieve_geometries: results will be shown after each group of %d geometries, total[%u] \n",count_geometries_remainder,source_config->dem_rows_count); } if (dem_config->default_srid == dem_config->dem_srid) { sql_statement = sqlite3_mprintf("SELECT ROWID, \"%s\" FROM '%s'.'%s' WHERE \"%s\" IS NOT NULL", source_config->dem_geometry, source_config->schema,source_config->dem_table, source_config->dem_geometry); } else { sql_statement = sqlite3_mprintf("SELECT ROWID, \"%s\", ST_Transform(\"%s\",%d) FROM '%s'.'%s' WHERE \"%s\" IS NOT NULL", source_config->dem_geometry,source_config->dem_geometry, dem_config->dem_srid, source_config->schema,source_config->dem_table,source_config->dem_geometry); } ret = sqlite3_prepare_v2(db_handle, sql_statement, -1, &stmt, NULL ); if ( ret == SQLITE_OK ) { sqlite3_free(sql_statement); while ( sqlite3_step( stmt ) == SQLITE_ROW ) { if (( sqlite3_column_type( stmt, 0 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 1 ) != SQLITE_NULL ) ) { id_rowid = sqlite3_column_int (stmt, 0); dem_config->id_rowid=id_rowid; // for debugging blob_value = (unsigned char *)sqlite3_column_blob(stmt, 1); blob_bytes = sqlite3_column_bytes(stmt,1); source_geom = gaiaFromSpatiaLiteBlobWkb(blob_value, blob_bytes); *count_total_geometries+=1; } if ( sqlite3_column_type( stmt, 2 ) != SQLITE_NULL ) { blob_value = (unsigned char *)sqlite3_column_blob(stmt, 2); blob_bytes = sqlite3_column_bytes(stmt,2); geom_dem = gaiaFromSpatiaLiteBlobWkb(blob_value, blob_bytes); } if (source_geom) { // if the source geometry is out of range of the dem area, NULL is returned: this is not an error, but no update geom_result=getDemCollect(db_handle, source_geom, geom_dem, dem_config, count_points_total,count_z_total,count_m_total,verbose); gaiaFreeGeomColl(source_geom); source_geom = NULL; if (geom_dem) { gaiaFreeGeomColl(geom_dem); geom_dem = NULL; } ret_update=SQLITE_OK; if (geom_result) { sql_statement = sqlite3_mprintf("UPDATE '%s'.'%s' SET '%s'=? WHERE ROWID=%d", source_config->schema,source_config->dem_table,source_config->dem_geometry,id_rowid); ret=sqlite3_prepare_v2(db_handle, sql_statement, -1, &stmt_update, NULL); if ( ret == SQLITE_OK) { sqlite3_free(sql_statement); gaiaToSpatiaLiteBlobWkb(geom_result, &blob_update, &blob_bytes_update); // Note: sqlite3_bind_* index is 1-based, os apposed to sqlite3_column_* that is 0-based. sqlite3_bind_blob(stmt_update, 1, blob_update, blob_bytes_update, free); ret_update = sqlite3_step( stmt_update ); if ( ret_update == SQLITE_DONE || ret_update == SQLITE_ROW ) { ret_update=SQLITE_OK; *count_changed_geometries += 1; } else { ret_update=SQLITE_ABORT; } sqlite3_finalize( stmt_update ); } else { if (verbose) { fprintf(stderr, "-W-> retrieve_geometries [UPDATE]: rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } } gaiaFreeGeomColl(geom_result); geom_result = NULL; if (((*count_total_geometries % count_geometries_remainder) == 0)) { if (*count_changed_geometries > transaction_update_changed_last) {// Store results only if something has changed // Note: while testing, this process stopped, with no further updates being reported. // The assumption was that there was a logical error else where, which was not the case. // This saving was build in to get to this point and analyse. [cause: missing Next for Linestrings/Polygon for dem_geom] // Since the logic exists, that UPDATEs are only done after changes have been made // This sporadic COMMIT/BEGIN has been retained. What is done is done. if (sqlite3_exec(db_handle, "COMMIT", NULL, NULL, &sql_err) == SQLITE_OK) { sleep(i_sleep); if (sqlite3_exec(db_handle, "BEGIN", NULL, NULL, &sql_err) == SQLITE_OK) { } } if (sql_err) { sqlite3_free(sql_err); } } if (verbose) { double procent_diff=(double)(*count_total_geometries)/source_config->dem_rows_count; remainder_calc=procent_diff*100; if (transaction_count_loops == 0) {// Show only once fprintf(stderr,"-I-> converted geometries commited to Database: \n"); } transaction_count_loops++; if (dem_config->has_m) {// overwrite the previous message [\r] fprintf(stderr, "\r %02.2f%% total read[%d] changed[%d] ; points total[%d] changed z[%d] changed m[%d] ",remainder_calc,*count_total_geometries,*count_changed_geometries,*count_points_total,*count_z_total,*count_m_total); } else {// overwrite the previous message [\r] fprintf(stderr, "\r %02.2f%% total read[%d] changed[%d] ; points total[%d] changed z[%d] ",remainder_calc,*count_total_geometries,*count_changed_geometries,*count_points_total,*count_z_total); } } transaction_update_changed_last=*count_changed_geometries; } } if (ret_update == SQLITE_ABORT ) { break; } } sqlite3_finalize( stmt ); if (verbose) {// new line after last message [\n] fprintf(stderr, "\n"); } } else { if (verbose) { fprintf(stderr, "-W-> retrieve_geometries [SELECT]: rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } if (ret_update == SQLITE_ABORT ) { return 0; } return 1; } // -- -- ---------------------------------- -- // Retrieve information about given // - table and geometry-column // -> for Source and Dem geometries // Dem // - must be a POINTZ or POINTZM // - SpatialIndex must exist // - Extent and row_count // -> to calculate resolution // Source // - must have a Z or ZM Dimension // Both // - Srid of geometries // -- -- ---------------------------------- -- static int check_geometry_dimension(sqlite3 *db_handle, struct config_dem *use_config, int *geometry_type, int verbose) { /* checking the table, geometry exists and if the geometry supports z-values */ int ret=0; char *sql_statement = NULL; sqlite3_stmt *stmt = NULL; int *srid_default = NULL; use_config->has_z = 0; use_config->has_m = 0; use_config->dem_extent_minx=0.0; use_config->dem_extent_miny=0.0; use_config->dem_extent_maxx=0.0; use_config->dem_extent_maxy=0.0; use_config->has_spatial_index=0; use_config->is_spatial_table=0; if (use_config->config_type == CONF_TYPE_DEM ) { srid_default = &use_config->dem_srid; } else { srid_default = &use_config->default_srid; } *geometry_type = 0; *srid_default = 0; // 390718.000000 5818887.000000 392757.000000 5820847.000000 // 392757-390718=2039 // 5820847-5818887=1960 // 1960*2039=3996440/4000440=0.99900011 resolution sql_statement = sqlite3_mprintf("SELECT a.geometry_type, a.srid, a.spatial_index_enabled, a.layer_type, " "b.extent_min_x, b.extent_min_y, b.extent_max_x, b.extent_max_y, b.row_count " "FROM '%s'.vector_layers AS a LEFT JOIN '%s'.vector_layers_statistics AS b " "ON a.table_name=b.table_name AND a.geometry_column=b.geometry_column " "WHERE a.table_name='%s' AND a.geometry_column='%s'", use_config->schema, use_config->schema, use_config->dem_table, use_config->dem_geometry); ret = sqlite3_prepare_v2(db_handle, sql_statement, -1, &stmt, NULL ); if ( ret == SQLITE_OK ) { sqlite3_free(sql_statement); while ( sqlite3_step( stmt ) == SQLITE_ROW ) { if (( sqlite3_column_type( stmt, 0 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 1 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 2 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 3 ) != SQLITE_NULL )) { *geometry_type = sqlite3_column_int( stmt, 0 ); *srid_default = sqlite3_column_int( stmt, 1 ); use_config->has_spatial_index = sqlite3_column_int( stmt, 2 ); if (strcmp((const char *)sqlite3_column_text( stmt, 3 ),"SpatialTable") == 0) { // The source Database must be in a SpatialTable to be updated [no checking for writable SpatialView's] // will be using ROWID to UPDATE use_config->is_spatial_table = 1; } // printf("-I-> check_geometry_dimension: coord_dimension=%d GAIA_XY_*l[%d,%d,%d]\n",coord_dimension,GAIA_XY_Z,GAIA_XY_Z_M,GAIA_XY_M); switch (*geometry_type) { case GAIA_POINTZ: case GAIA_LINESTRINGZ: case GAIA_POLYGONZ: case GAIA_MULTIPOINTZ: case GAIA_MULTILINESTRINGZ: case GAIA_MULTIPOLYGONZ: case GAIA_GEOMETRYCOLLECTIONZ: use_config->has_z = 1; break; } switch (*geometry_type) { case GAIA_POINTZM: case GAIA_LINESTRINGZM: case GAIA_POLYGONZM: case GAIA_MULTIPOINTZM: case GAIA_MULTILINESTRINGZM: case GAIA_MULTIPOLYGONZM: case GAIA_GEOMETRYCOLLECTIONZM: use_config->has_z = 1; use_config->has_m = 1; break; } switch (*geometry_type) { case GAIA_POINTM: case GAIA_LINESTRINGM: case GAIA_POLYGONM: case GAIA_MULTIPOINTM: case GAIA_MULTILINESTRINGM: case GAIA_MULTIPOLYGONM: case GAIA_GEOMETRYCOLLECTIONM: use_config->has_m = 1; break; } } if (( sqlite3_column_type( stmt, 4 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 5 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 6 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 7 ) != SQLITE_NULL ) && ( sqlite3_column_type( stmt, 8 ) != SQLITE_NULL )) { use_config->dem_extent_minx = sqlite3_column_double( stmt, 4 ); use_config->dem_extent_miny = sqlite3_column_double( stmt, 5 ); use_config->dem_extent_maxx = sqlite3_column_double( stmt, 6 ); use_config->dem_extent_maxy = sqlite3_column_double( stmt, 7 ); use_config->dem_rows_count = sqlite3_column_int64( stmt, 8 ); } } sqlite3_finalize( stmt ); if ((use_config->is_spatial_table == 1) && (use_config->has_z) && (use_config->dem_rows_count > 0)) { ret=1; // Valid for usage } } else { if (verbose) { fprintf(stderr, "-W-> check_geometry_dimension: rc=%d sql[%s]\n",ret,sql_statement); } sqlite3_free(sql_statement); } return ret; } static void spatialite_autocreate(sqlite3 *db_handle) { /* attempting to perform self-initialization for a newly created DB */ int ret; char sql[1024]; char *err_msg = NULL; int count; int i; char **results; int rows; int columns; /* checking if this DB is really empty */ strcpy(sql, "SELECT Count(*) from sqlite_master"); ret = sqlite3_get_table(db_handle, sql, &results, &rows, &columns, NULL); if (ret != SQLITE_OK) return; if (rows < 1) ; else { for (i = 1; i <= rows; i++) count = atoi (results[(i * columns) + 0]); } sqlite3_free_table(results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy(sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec(db_handle, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf(stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free(err_msg); return; } } // -- -- ---------------------------------- -- // Collecting a list of Dem-xyz file // - with checks on the first record // Case 1: a single xyz.file is given // -> the file will be checked and added to the list // Case 2: a directory is given // -> each file will be checked and added to the list // Case 3: a single list.file is given // - contains a list of single xyz.files to be read // -> expected to be inside the given directory // -> each file will be checked and added to the list // -- -- ---------------------------------- -- // The list is the TABLE db_memory.xyz_files // Goal is to read the files in a specific order: // --> y='South to North' and x='West to East' // -- -- ---------------------------------- -- static int collect_xyz_files(sqlite3 *db_handle,const char *xyz_filename, int *count_xyz_files, int verbose) { int ret=0; int i_count_fields=0; int i_count_fields_check=3; int ret_insert=SQLITE_OK; if (*count_xyz_files < 0) { *count_xyz_files=0; } double point_x=0.0; double point_y=0.0; double point_z=0.0; char *sql_statement = NULL; int result_file_type=0; char *directory_from_filename = NULL; // -- -- ---------------------------------- -- FILE *xyz_file = fopen(xyz_filename, "rt"); if (xyz_file != NULL) { if (verbose) { fprintf(stderr,"-I-> collect_xyz_files:reading xyz_filename[%s] \n", xyz_filename); } char line[MAXBUF]; while(fgets(line, sizeof(line), xyz_file) != NULL) { if (strcmp(line, "SQLite format 3") != 0) { line[strcspn(line, "\r\n")] = 0; char *token; char *ptr_strtod; char *saveptr; i_count_fields=0; token = strtok_r(line, " ",&saveptr); point_x=strtod(token, &ptr_strtod); // atof will cause a signal 11 (SIGSEGV), if token does not contain a double if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; while(token != NULL) { token = strtok_r(NULL," ",&saveptr); switch (i_count_fields) { case 1: point_y=strtod(token, &ptr_strtod); if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; } break; case 2: point_z=strtod(token, &ptr_strtod); if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; } break; } } } if (i_count_fields == 0) { // This may be a list of xyz.file-names, // - contained in the same directory // - that should be read [possibly not all of the xyz.files should be read] // - order is not important, will be sorted by point_y ASC, point_x ASC of the first record if (!directory_from_filename) { const char *slash = strrchr(xyz_filename,'/'); directory_from_filename=malloc(sizeof(char)*((slash-xyz_filename)+1)); strncpy(directory_from_filename,xyz_filename,slash-xyz_filename); directory_from_filename[(slash-xyz_filename)]=0; } sql_statement = sqlite3_mprintf("%s/%s", directory_from_filename,token); // the first record will be read. If 3 doubles, seperated by a space, can be created // 1 : will be returned, after adding the path/file-name, point_x and point_y to db_memory.xyz_files result_file_type=collect_xyz_files(db_handle,sql_statement, count_xyz_files, 0); if (result_file_type == 1) {//file_name has been added to db_memory.xyz_files ret=1; // xyz-format } sqlite3_free(sql_statement); } if (i_count_fields == i_count_fields_check) { sql_statement = sqlite3_mprintf("INSERT INTO db_memory.xyz_files (point_x,point_y,file_name) " "VALUES(%2.7f,%2.7f,'%s') ",point_x,point_y,xyz_filename); if (db_handle) { if (sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL) == SQLITE_OK) { *count_xyz_files+=1; // xyz-format result_file_type=1; } } sqlite3_free(sql_statement); ret_insert = SQLITE_ABORT; } if (verbose) { fprintf(stderr,"-I-> collect_xyz_files: i_count_fields[%d] check[%d] count_files[%d]\n", i_count_fields,i_count_fields_check,*count_xyz_files); } } else { result_file_type=2; // Sqlite3-format } if (ret_insert == SQLITE_ABORT ) { break; } if (ret_insert != SQLITE_ABORT ) { // if this is a list of .xyz files that are being added, // result_file_type will be 1, but not SQLITE_ABORT // - since all entries must be read if (result_file_type != 1) { break; // unknown format } } } // End while fclose(xyz_file); if (directory_from_filename) { free(directory_from_filename); directory_from_filename=NULL; } } // Checking for a file else { #if defined(_WIN32) && !defined(__MINGW32__) /* Visual Studio .NET */ struct _finddata_t c_file; intptr_t hFile; char *name; int len; int ret; if (_chdir (in_dir) < 0) return ret; if ((hFile = _findfirst ("*.xyz", &c_file)) == -1L) ; else { while (1) {// A directory with .xyz files if ((c_file.attrib & _A_RDONLY) == _A_RDONLY || (c_file.attrib & _A_NORMAL) == _A_NORMAL) { sql_statement = sqlite3_mprintf("%s/%s", xyz_filename,c_file.name); if (collect_xyz_files(db_handle,sql_statement, count_xyz_files, 0) == 1) {//file_name has been added to db_memory.xyz_files } sqlite3_free(sql_statement); } if (_findnext (hFile, &c_file) != 0) break; } _findclose (hFile); } #else DIR *xyz_dir = opendir(xyz_filename); struct dirent *dir; if (xyz_dir) { while ((dir = readdir(xyz_dir)) != NULL) { if (dir->d_type == DT_REG) { const char *ext = strrchr(dir->d_name,'.'); if ((ext) || (ext != dir->d_name)) { if (strcmp(ext, ".xyz") == 0) {// A directory with .xyz files // - order is not important, will be sorted by point_y ASC, point_x ASC of the first record sql_statement = sqlite3_mprintf("%s/%s", xyz_filename,dir->d_name); // the first record will be read. If 3 doubles, seperated by a space, can be created // 1 : will be returned, after adding the path/file-name, point_x and point_y to db_memory.xyz_files result_file_type=collect_xyz_files(db_handle,sql_statement, count_xyz_files, 0); if (result_file_type == 1) {//file_name has been added to db_memory.xyz_files } sqlite3_free(sql_statement); } } } } closedir(xyz_dir); } // Checking for a directory #endif } // -- -- ---------------------------------- -- if (*count_xyz_files > 0) { ret=1; // xyz-format } else { ret=0; // not supported if (verbose) { fprintf(stderr,"-E-> collect_xyz_files: import.xyz file format not found [%s]\n", xyz_filename); } } // -- -- ---------------------------------- - return ret; } // -- -- ---------------------------------- -- // Read list of Dem-xyz files // - from db_memory.xyz_files // Goal is to INSERT the points in a specific order: // --> y='South to North' and x='West to East' // -- -- ---------------------------------- -- static int import_xyz(sqlite3 *db_handle, struct config_dem *dem_config, int count_xyz_files, int verbose) { int ret=0; int ret_select=0; sqlite3_stmt *stmt = NULL; char *sql_statement = NULL; int i_count_loop=100000; int i_count_fields=0; int i_count_fields_check=3; int i_count_in_loop=0; int i_file_count=0; const char *xyz_path_filename; // 18.446.744.073.709.551.615 unsigned int i_sleep=1; // 1 second double point_x=0.0; double point_y=0.0; double point_z=0.0; double *xx = NULL; double *yy = NULL; double *zz = NULL; int ret_insert=SQLITE_OK; if (count_xyz_files > 0) {// input-files should be sorted from y='South to North' and x='West to East': sort -n -k2 -k1 input_file.xyz -o output_file.sort.xyz // Select files sorted by y='South to North' and x='West to East' sql_statement = sqlite3_mprintf("SELECT file_name FROM db_memory.xyz_files ORDER BY point_y ASC, point_x ASC"); ret_select = sqlite3_prepare_v2(db_handle, sql_statement, -1, &stmt, NULL ); sqlite3_free(sql_statement); if ( ret_select == SQLITE_OK ) { while ( sqlite3_step( stmt ) == SQLITE_ROW ) { if ( sqlite3_column_type( stmt, 0 ) != SQLITE_NULL ) { xyz_path_filename=(const char *) sqlite3_column_text (stmt, 0); // -- -- ---------------------------------- -- FILE *xyz_file = fopen(xyz_path_filename, "rt"); if (xyz_file != NULL) { char line[MAXBUF]; i_file_count++; i_count_in_loop=0; if (verbose) { // CPU: 4-11% ; memory 9.3 Ḿib ; normal working with mouse and applications fprintf(stderr,"import_xyz: reading xyz_filename[%s]\n (file %d of %d) in steps of [%u].\n",xyz_path_filename,i_file_count,count_xyz_files, i_count_loop); } xx = malloc(sizeof (double) * i_count_loop); yy = malloc(sizeof (double) * i_count_loop); zz = malloc(sizeof (double) * i_count_loop); while(fgets(line, sizeof(line), xyz_file) != NULL) { line[strcspn(line, "\r\n")] = 0; char *token; char *ptr_strtod; char *saveptr; i_count_fields=0; token = strtok_r(line, " ",&saveptr); point_x=strtod(token, &ptr_strtod); // atof will cause a signal 11 (SIGSEGV), if token does not contain a double if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; while(token != NULL) { token = strtok_r(NULL," ",&saveptr); switch (i_count_fields) { case 1: point_y=strtod(token, &ptr_strtod); if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; } break; case 2: point_z=strtod(token, &ptr_strtod); if ((int)strlen(ptr_strtod) == 0) { i_count_fields++; } break; } } } if (i_count_fields == i_count_fields_check) { if (i_count_in_loop < i_count_loop) { xx[i_count_in_loop]=point_x; yy[i_count_in_loop]=point_y; zz[i_count_in_loop]=point_z; i_count_in_loop++; } if (i_count_in_loop == i_count_loop) { dem_config->count_points=i_count_in_loop; if (!insert_dem_points(db_handle, dem_config, xx, yy, zz, verbose)) { // Inserting failed, abort ret_insert = SQLITE_ABORT; } else { if (verbose) { fprintf(stderr,"\r inserted [%u] ... ", dem_config->dem_rows_count); } } // xx,yy,zz values are reset to 0.0 in insert_dem_points i_count_in_loop=0; sleep(i_sleep); } } else { ret_insert = SQLITE_ABORT; } if (ret_insert == SQLITE_ABORT ) { break; } } // End while fclose(xyz_file); // -- -- ---------------------------------- -- // Complete what is left over, when no abort // -- -- ---------------------------------- -- if (ret_insert != SQLITE_ABORT ) { ret=1; if ( i_count_in_loop < i_count_loop) { ret=0; dem_config->count_points=i_count_in_loop; fprintf(stderr,"import_xyz: calling insert_dem_points: i_count_in_loop[%d].\n",dem_config->count_points); if (insert_dem_points(db_handle, dem_config, xx, yy, zz, verbose)) { ret=1; if (verbose) { fprintf(stderr,"\r file%d: inserting compleated [%u]\n",i_file_count, dem_config->dem_rows_count); } } } } // -- -- ---------------------------------- -- // clean up // -- -- ---------------------------------- -- if (xx) { free(xx); xx=NULL; } if (yy) { free(yy); yy=NULL; } if (zz) { free(zz); zz=NULL; } } else { if (verbose) { fprintf(stderr,"-E-> import_xyz: import.xyz file not found [%s]\n", xyz_path_filename); } } } } sqlite3_finalize( stmt ); } } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Recover Dem-Geometry with SpatialIndex // - recovering a full Geometry Column // -- -- ---------------------------------- -- static int recover_geometry_dem(sqlite3 *db_handle, struct config_dem *dem_config, int verbose) { /* recovering a full Geometry Column */ int ret; char *err_msg; char *sql_statement = NULL; if (verbose) { fprintf(stderr,"Recovering Geometry: %s(%s) as POINTZ with srid=%d\n", dem_config->dem_table,dem_config->dem_geometry, dem_config->dem_srid); } sql_statement = sqlite3_mprintf("SELECT RecoverGeometryColumn(%Q, %Q, %d, %Q, %Q)", dem_config->dem_table,dem_config->dem_geometry, dem_config->dem_srid, "POINT", "XYZ"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, &err_msg); sqlite3_free(sql_statement); if (ret != SQLITE_OK) { if (verbose) { fprintf(stderr, "RecoverGeometryColumn error: %s\n", err_msg); } sqlite3_free(err_msg); return 0; } if (verbose) { fprintf(stderr, "Creating Spatial Index: %s(%s)\n", dem_config->dem_table,dem_config->dem_geometry); } sql_statement = sqlite3_mprintf("SELECT CreateSpatialIndex(%Q, %Q)", dem_config->dem_table,dem_config->dem_geometry); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, &err_msg); sqlite3_free(sql_statement); if (ret != SQLITE_OK) { fprintf(stderr, "CreateSpatialIndex error: %s\n", err_msg); sqlite3_free(err_msg); return 0; } if (verbose) { fprintf(stderr,"UpdateLayerStatistics: %s(%s)\n", dem_config->dem_table,dem_config->dem_geometry); } sql_statement = sqlite3_mprintf("SELECT UpdateLayerStatistics(%Q, %Q)", dem_config->dem_table,dem_config->dem_geometry); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, &err_msg); sqlite3_free(sql_statement); if (ret != SQLITE_OK) { fprintf(stderr, "UpdateLayerStatistics error: %s\n", err_msg); sqlite3_free(err_msg); return 0; } return 1; } // -- -- ---------------------------------- -- // Create the Database for Dem // - CREATE TABLE for minimal Dem-Data // -> db_memory.xyz_files // -- -- ---------------------------------- -- static int create_dem_db(const char *path_dem, sqlite3 ** handle, void *cache, const char *table_dem, const char *column_dem, int verbose) { /* opening the DB */ sqlite3 *db_handle = NULL; int ret=0; char *sql_statement = NULL; *handle = NULL; if ( verbose ) { fprintf(stderr,"SQLite version: %s\n", sqlite3_libversion()); fprintf(stderr,"SpatiaLite version: %s\n\n", spatialite_version()); } FILE *db_file = fopen(path_dem, "r"); if (db_file != NULL) { fclose(db_file); return ret; } ret = sqlite3_open_v2(path_dem, &db_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); if (ret != SQLITE_OK) { fprintf(stderr, "cannot open '%s': %s\n", path_dem, sqlite3_errmsg (db_handle)); sqlite3_close(db_handle); return ret; } spatialite_init_ex(db_handle, cache, 0); spatialite_autocreate(db_handle); if ( (table_dem) && ( column_dem ) ) { sql_statement = sqlite3_mprintf("CREATE TABLE \"%s\" (" "id_dem INTEGER PRIMARY KEY AUTOINCREMENT, " "point_x DOUBLE DEFAULT 0, " "point_y DOUBLE DEFAULT 0, " "point_z DOUBLE DEFAULT 0, " "%s BLOB DEFAULT NULL)" ,table_dem, column_dem); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); if (ret != SQLITE_OK) { fprintf(stderr, "cannot CREATE Table: '%s' sql[%s]\n\t: %s\n", table_dem, sql_statement, sqlite3_errmsg (db_handle)); sqlite3_free(sql_statement); sqlite3_close(db_handle); return ret; } sqlite3_free(sql_statement); if (verbose) { fprintf(stderr,"Created table(geometry): %s(%s)\n", table_dem, column_dem); } sql_statement = sqlite3_mprintf("ATTACH DATABASE ':memory:' AS db_memory"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); if (ret == SQLITE_OK) { sql_statement = sqlite3_mprintf("CREATE TABLE db_memory.xyz_files (" "file_name TEXT DEFAULT '', " "point_x DOUBLE DEFAULT 0, " "point_y DOUBLE DEFAULT 0)"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); if (ret != SQLITE_OK) { } } } *handle = db_handle; ret=1; return ret; } // -- -- ---------------------------------- -- // Close the Database // - DETACH a connected Database if needed // -> db_memory // -- -- ---------------------------------- -- static void close_db(sqlite3 *db_handle, void *cache, const char *schema_dem) { char *sql_statement = NULL; int ret=0; if (schema_dem) { if (strcmp(schema_dem, "main") != 0) { sql_statement = sqlite3_mprintf("DETACH DATABASE %s", schema_dem); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); } } sql_statement = sqlite3_mprintf("DETACH DATABASE db_memory"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); sqlite3_close(db_handle); if (cache) { spatialite_cleanup_ex(cache); } spatialite_shutdown(); return; } // -- -- ---------------------------------- -- // Open the Database // - ATTACH a connected Database if needed // While 'sniffing' a second source may not be needed // - CREATE TABLE for minimal Dem-Data // -> db_memory.xyz_files // -- -- ---------------------------------- -- static int open_db(sqlite3 **handle, void *cache, struct config_dem *source_config, struct config_dem *dem_config, int verbose) { /* opening the DB */ sqlite3 *db_handle = NULL; int ret=0; char *sql_statement = NULL; const char *path_db=NULL; const char *path_attach=NULL; const char *schema_db=NULL; const char *schema_attach=NULL; *handle = NULL; if ( verbose ) { fprintf(stderr,"SQLite version: %s\n", sqlite3_libversion()); fprintf(stderr,"SpatiaLite version: %s\n\n", spatialite_version()); } if ((strlen(dem_config->dem_path) > 0) && ( (source_config) && (strlen(source_config->dem_path) == 0))) { // Open the Dem-Database as source [sniff without source or fetchz] path_db=dem_config->dem_path; dem_config->schema="main"; schema_attach=dem_config->schema; } else { path_db=source_config->dem_path; schema_db=source_config->schema; path_attach=dem_config->dem_path; schema_attach=dem_config->schema; } ret = sqlite3_open_v2(path_db, &db_handle, SQLITE_OPEN_READWRITE, NULL); if (ret != SQLITE_OK) { fprintf(stderr, "cannot open '%s': %s\n", path_db, sqlite3_errmsg (db_handle)); close_db(db_handle, cache, NULL); return 0; } if (path_attach) { sql_statement = sqlite3_mprintf("ATTACH DATABASE \"%s\" AS %s",path_attach, schema_attach); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); if (ret != SQLITE_OK) { fprintf(stderr, "cannot ATTACH Database: '%s' sql[%s]\n\t: %s\n", path_attach, sql_statement, sqlite3_errmsg (db_handle)); sqlite3_free(sql_statement); close_db(db_handle, cache, NULL); return 0; } sqlite3_free(sql_statement); } sql_statement = sqlite3_mprintf("ATTACH DATABASE ':memory:' AS db_memory"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); if (ret == SQLITE_OK) { sql_statement = sqlite3_mprintf("CREATE TABLE db_memory.xyz_files (" "file_name TEXT DEFAULT '', " "point_x DOUBLE DEFAULT 0, " "point_y DOUBLE DEFAULT 0)"); ret = sqlite3_exec(db_handle, sql_statement, NULL, NULL, NULL); sqlite3_free(sql_statement); if (ret != SQLITE_OK) { } } spatialite_init_ex(db_handle, cache, 0); *handle = db_handle; return 1; } // -- -- ---------------------------------- -- // Help Messages // -- -- ---------------------------------- -- static void do_help() { /* printing the argument list */ fprintf(stderr, "\n\nusage: spatialite_dem ARGLIST\n"); fprintf(stderr, "==============================================================\n"); fprintf(stderr, "-h or --help print this help message\n"); fprintf(stderr, "========================== Parameters ========================\n"); fprintf(stderr, " -- -- ---------------- Dem-Data Database ---------------- --\n"); fprintf(stderr, "-ddem or --dem-path pathname to the SpatiaLite Dem DB \n"); fprintf(stderr, "-tdem or --table-dem table_name [SpatialTable or SpatialView]\n"); fprintf(stderr, "-gdem or --geometry-dem-column col_name the Geometry column\n"); fprintf(stderr, "\t must be a POINT Z or a POINT ZM type\n"); fprintf(stderr, "-rdem or --dem-resolution of the dem points while searching\n"); fprintf(stderr, "\t the automatic resolution calculation is based on the row_count\n"); fprintf(stderr, "\t within the extent, which may not be correct!\n"); fprintf(stderr, "\t Use '-rdem' to set a realistic value\n"); fprintf(stderr, "\n -- -- ----------------- Source Database ----------------- --\n"); fprintf(stderr, "-d or --db-path pathname to the SpatiaLite DB\n"); fprintf(stderr, "-t or --table table_name, must be a SpatialTable\n"); fprintf(stderr, "-g or --geometry-column the Geometry column to update\n"); fprintf(stderr, "\t must be a Z or a ZM Dimension type\n\t use CastToXYZ(geom) or CastToXYZM(geom) to convert \n"); fprintf(stderr, " -- -- --------------- General Parameters ---------------- --\n"); fprintf(stderr, "-mdem or --copy-m [0=no, 1= yes [default] if exists]\n"); fprintf(stderr, "-default_srid or --srid for use with -fetchz\n"); fprintf(stderr, "-fetchz_xy x- and y-value for use with -fetchz\n"); fprintf(stderr, "-v or --verbose messages during -updatez and -fetchz\n"); fprintf(stderr, "-save_conf based on active -ddem , -tdem, -gdem and -srid when valid\n"); fprintf(stderr, "\n -- -- -------------------- Notes: ---------------------- --\n"); fprintf(stderr, "-I-> the Z value will be copied from the nearest point found\n"); fprintf(stderr, "-I-> the Srid of the source Geometry and the Dem-POINT can be different\n"); fprintf(stderr, "-I-> when -fetchz_xy is used in a bash script, -v should not be used\n"); fprintf(stderr, "\t the z-value will then be retured as the result\n"); fprintf(stderr, "\n -- -- -------------------- Conf file: ------------------- --\n"); fprintf(stderr, "-I-> if 'SPATIALITE_DEM' is set with the path to a file\n"); fprintf(stderr, "-I--> 'export SPATIALITE_DEM=/long/path/to/file/berlin_dhh92.conf'\n"); fprintf(stderr, "-I-> then '-save_conf' save the config to that file\n"); fprintf(stderr, "-I-> this file will be read on each application start, setting those values\n"); fprintf(stderr, "-I--> the parameters for :\n"); fprintf(stderr, "\t which Dem-Database and Geometry and the default_srid to use for queries\n"); fprintf(stderr, "\t -> would then not be needed\n"); fprintf(stderr, "\n -- -- ---------------- Importing .xyz files: ------------------- --\n"); fprintf(stderr, "-I-> a single xyz.file or a directory containing .xyz files can be given\n"); fprintf(stderr, "\t for directories: only files with the extension .xyz will be searched for\n"); fprintf(stderr, "-I-> a single list.file inside a directory containing .xyz files can be given\n"); fprintf(stderr, "\t each line containing the file-name that must exist in that directory\n"); fprintf(stderr, "-I-> validty checks are done before importing xyz-files\n"); fprintf(stderr, "\t the first line may contain only 3 double values (point_x/y/z)\n"); fprintf(stderr, "\t if valid, the file-name and the point_x/y points are stored\n"); fprintf(stderr, "\t when importing, the list will be read based of the y/x points\n"); fprintf(stderr, "\n -- -- ---------------- Sorting .xyz files: ---------------------- --\n"); fprintf(stderr, "-I-> xyz.files should be sorted:\n"); fprintf(stderr, "\t y='South to North' and x='West to East': \n"); fprintf(stderr, "\t sort -n -k2 -k1 input_file.xyz -o output_file.sort.xyz"); fprintf(stderr, "\n=========================== Commands ===========================\n"); fprintf(stderr, "-sniff [default] analyse settings without UPDATE of z-values \n"); fprintf(stderr, "-updatez Perform UPDATE of z-values \n"); fprintf(stderr, "-fetchz Perform Query of z-values using -fetchz_x_y and default_srid\n"); fprintf(stderr, "\t will be assumed when using -fetchz_x_y\n"); fprintf(stderr, "-create_dem create Dem-Database using -ddem,-tdem, -gdem and -srid for the Database \n"); fprintf(stderr, "\t -d as a dem.xyz file \n"); fprintf(stderr, "-import_xyz import another .xyz file into a Dem-Database created with -create_dem \n"); fprintf(stderr, "\t these points will not be sorted, but added to the end "); fprintf(stderr, "\n=========================== Sample ===========================\n"); fprintf(stderr, "--> with 'SPATIALITE_DEM' set: \n"); fprintf(stderr, "spatialite_dem -fetchz_xy 24700.55278283251 20674.74537357586\n"); fprintf(stderr, "33.5600000 \n"); fprintf(stderr, "==============================================================\n"); } // -- -- ---------------------------------- -- // Checking the status of the Dem-Database // - used by differenct command types // -- -- ---------------------------------- -- static int command_check_source_db(sqlite3 *db_handle, struct config_dem*source_config, struct config_dem*dem_config, int verbose) { int ret=0; int geometry_type=0; if (strlen(source_config->dem_path) > 0) // -- -- ---------------------------------- -- if ((strlen(source_config->dem_path) > 0) && (strlen(source_config->dem_table) > 0) && (strlen(source_config->dem_geometry) > 0)) { if (check_geometry_dimension(db_handle,source_config, &geometry_type,verbose)) { if (verbose) { fprintf(stderr,"Source: srid %d\n", source_config->default_srid); fprintf(stderr,"Source: extent min x/y(%2.7f,%2.7f)\n\t max x/y(%2.7f,%2.7f)\n", source_config->dem_extent_minx,source_config->dem_extent_miny, source_config->dem_extent_maxx,source_config->dem_extent_maxy); fprintf(stderr,"Source: rows_count(%s) %d\n",source_config->dem_geometry, source_config->dem_rows_count); fprintf(stderr,"Source: geometry_type(%d) has_z[%d]\n",geometry_type,source_config->has_z); fprintf(stderr,"Source: spatial_index_enabled[%d]\n",source_config->has_spatial_index); } if (source_config->is_spatial_table == 1) { if (source_config->has_z) {// The source Database Table and geometry-columns exists and contains a z-value dimension. ret = 0; if (verbose) { fprintf(stderr,"Source '%s'\n", source_config->dem_path); fprintf(stderr," will set %s(%s) Z-Values\n\tfrom nearest POINT found in\n",source_config->dem_table, source_config->dem_geometry); } } else { ret = -1; if (verbose) { fprintf(stderr, "DB '%s'\n", source_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] does not contained in a SpatialTable [will not update]\n",source_config->dem_table, source_config->dem_geometry); fprintf(stderr, "\t command_check_source_db failed: sorry, cowardly quitting\n\n"); } } } else { ret = -1; if (verbose) { fprintf(stderr, "DB '%s'\n", source_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] does not contain a Z-Dimension\n",source_config->dem_table, source_config->dem_geometry); fprintf(stderr, "\t command_check_source_db failed: sorry, cowardly quitting\n\n"); } } } else {// The source Database Table or geometry-columns does not exist. ret = -1; if (verbose) { fprintf(stderr, "DB '%s'\n", source_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] not found\n",source_config->dem_table, source_config->dem_geometry); fprintf(stderr, "\t check_geometry_dimension failed: sorry, cowardly quitting\n\n"); } } if (ret == 0) { if (verbose) { fprintf(stderr, "Source Database: has passed all checks.\n\n"); } } } else { if ((strlen(source_config->dem_path) > 0) && (strcmp(source_config->dem_path,".xyz") != 1)) { if (verbose) { fprintf(stderr,"-E-> command_check_source_db: preconditions failed for check_source_db [%s(%s)]\n\t source[%s] \n",source_config->dem_table, source_config->dem_geometry,source_config->dem_path); } } } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Checking the status of the Dem-Database // - used by differenct command types // -- -- ---------------------------------- -- static int command_check_dem_db(sqlite3 *db_handle, struct config_dem*dem_config, struct config_dem*source_config, int verbose) { int ret=0; double resolution_calc=0.0; double resolution_dem=dem_config->dem_resolution; int geometry_type=0; // -- -- ---------------------------------- -- if ((strlen(dem_config->dem_path) > 0) && (strlen(dem_config->dem_table) > 0) && (strlen(dem_config->dem_geometry) > 0)) { if (check_geometry_dimension(db_handle,dem_config, &geometry_type, verbose)) { if (dem_config->dem_rows_count) { resolution_calc=(dem_config->dem_extent_maxx-dem_config->dem_extent_minx)*(dem_config->dem_extent_maxy-dem_config->dem_extent_miny)/(double)dem_config->dem_rows_count; } if (verbose) { fprintf(stderr,"Dem: srid %d\n", dem_config->dem_srid); fprintf(stderr,"Dem: extent min x/y(%2.7f,%2.7f)\n\t max x/y(%2.7f,%2.7f)\n", dem_config->dem_extent_minx,dem_config->dem_extent_miny, dem_config->dem_extent_maxx,dem_config->dem_extent_maxy); fprintf(stderr,"Dem: extent width(%2.7f)\n\t height(%2.7f)\n", (dem_config->dem_extent_maxx-dem_config->dem_extent_minx), (dem_config->dem_extent_maxy-dem_config->dem_extent_miny)); fprintf(stderr,"Dem: rows_count(%s) %u\n",dem_config->dem_geometry, dem_config->dem_rows_count); fprintf(stderr,"Dem: resolution(%s) %2.7f\n",dem_config->dem_geometry, resolution_calc); fprintf(stderr,"Dem: geometry_type(%d) has_z[%d] has_m[%d]\n",geometry_type,dem_config->has_z, dem_config->has_m); fprintf(stderr,"Dem: spatial_index_enabled[%d]\n",dem_config->has_spatial_index); } if (dem_config->has_z) {// The dem Database Table and geometry-columns exist and contains a z-value dimension. switch (geometry_type) { case GAIA_POINTZ: case GAIA_POINTZM: { if (dem_config->has_spatial_index == 1) { if ( (source_config) && (strlen(source_config->dem_path) > 0) && (strlen(source_config->dem_table) > 0)) {// No printing when .xyz file if (verbose) { fprintf(stderr,"Source '%s'\n", source_config->dem_path); fprintf(stderr," will set %s(%s) Z-Values\n\tfrom nearest POINT found in\n",source_config->dem_table, source_config->dem_geometry); } } if (verbose) { fprintf(stderr,"Dem '%s'\n", dem_config->dem_path); fprintf(stderr," TABLE[%s] with GEOMETRY-Column[%s]\n",dem_config->dem_table, dem_config->dem_geometry); } ret = 0; } else { if (verbose) { fprintf(stderr, "Dem '%s'\n", dem_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] must be a POINT with a Z-Dimension with a SpatialIndex\n",dem_config->dem_table, dem_config->dem_geometry); fprintf(stderr, "\t command_check_dem_db failed: sorry, cowardly quitting\n\n"); } ret = -1; } } break; default: if (verbose) { fprintf(stderr, "Dem '%s'\n", dem_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] must be a POINT with a Z-Dimension\n",dem_config->dem_table, dem_config->dem_geometry); fprintf(stderr, "\t command_check_dem_db failed: sorry, cowardly quitting\n\n"); } ret = -1; break; } } else { if (verbose) { fprintf(stderr, "Dem '%s'\n", dem_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] does not contain a Z-Dimension\n",dem_config->dem_table, dem_config->dem_geometry); fprintf(stderr, "\t command_check_dem_db failed: sorry, cowardly quitting\n\n"); } ret = -1; } } else {// The dem Database Table or geometry-columns does not exist. if (verbose) { fprintf(stderr, "Dem '%s'\n", dem_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] not found\n",dem_config->dem_table, dem_config->dem_geometry); fprintf(stderr, "\t check_geometry_dimension failed: sorry, cowardly quitting\n\n"); } ret = -1; } if (ret == 0) { if (resolution_dem <= 0.0) { if (verbose) { fprintf(stderr, "-W-> -rdem was not set. Using: resolution(%s) %2.7f\n",dem_config->dem_geometry, resolution_calc); } resolution_dem=resolution_calc; } else { if (verbose) { fprintf(stderr, "-W-> -rdem was set. Using: resolution(%2.7f), overriding the calculated value: %2.7f\n",resolution_dem, resolution_calc); } } dem_config->dem_resolution=resolution_dem; if ((source_config) && (source_config->has_z)) { dem_config->default_srid=source_config->default_srid; if (verbose) { if (dem_config->dem_srid == source_config->default_srid) { fprintf(stderr, "Dem srid[%d]: is the same as the Source srid[%d].\n", dem_config->dem_srid,dem_config->default_srid); if ( ( source_config->dem_extent_minx >= dem_config->dem_extent_minx ) && (source_config->dem_extent_maxx <= dem_config->dem_extent_maxx ) && ( source_config->dem_extent_miny >= dem_config->dem_extent_miny ) && (source_config->dem_extent_maxy <= dem_config->dem_extent_maxy ) ) { fprintf(stderr, "The Source[%s]: is totally within the Dem[%s] area.\n", source_config->dem_geometry,dem_config->dem_geometry); } else if ( ( source_config->dem_extent_minx < dem_config->dem_extent_minx ) && (source_config->dem_extent_maxx > dem_config->dem_extent_maxx ) && ( source_config->dem_extent_miny < dem_config->dem_extent_miny ) && (source_config->dem_extent_maxy > dem_config->dem_extent_maxy ) ) { fprintf(stderr, "The Source[%s]: is totally covers the Dem[%s] area.\n", source_config->dem_geometry,dem_config->dem_geometry); fprintf(stderr, "\t only geometries totally within the Dem area will be updated.\n"); } else if ( ( ( source_config->dem_extent_minx < dem_config->dem_extent_minx ) || ( source_config->dem_extent_minx > dem_config->dem_extent_maxx ) ) && ( ( source_config->dem_extent_maxx > dem_config->dem_extent_maxx ) || ( source_config->dem_extent_maxx < dem_config->dem_extent_minx ) ) && ( ( source_config->dem_extent_miny < dem_config->dem_extent_miny ) || (source_config->dem_extent_miny > dem_config->dem_extent_maxy) ) && ( ( source_config->dem_extent_maxy > dem_config->dem_extent_maxy ) || ( source_config->dem_extent_maxy < dem_config->dem_extent_miny ) ) ) { // ?? correct ?? fprintf(stderr, "The Dem[%s]: is totally outside of the Source[%s] area.\n", dem_config->dem_geometry,source_config->dem_geometry); } else { fprintf(stderr, "The Source[%s]: is partially inside of the Dem[%s] area.\n", source_config->dem_geometry,dem_config->dem_geometry); } } else { fprintf(stderr, "Dem default_srid[%d]: is different from the Source default_srid[%d].\n", dem_config->dem_srid,dem_config->default_srid); fprintf(stderr, "\t When searching for the nearest point, the Source points will be transformed to srid[%d].\n", dem_config->dem_srid); } fprintf(stderr, "Dem Database: has passed all checks.\n"); } } } } else { if (strlen(dem_config->dem_path) > 0) { if (verbose) { fprintf(stderr,"-E-> command_check_dem_db: preconditions failed [%s(%s)] \n",dem_config->dem_table, dem_config->dem_geometry); } } } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Implementation of command: updatez // - from a Table, geometry of Dem // --> update each z value with z value of // --> nearest Point of Dem // -- -- ---------------------------------- -- static int command_updatez_db(sqlite3 *db_handle, struct config_dem*source_config, struct config_dem*dem_config, int verbose) { int ret=0; char *time_message = NULL; struct timeval time_start; struct timeval time_end; struct timeval time_diff; char *sql_err = NULL; int count_total_geometries=0; int count_changed_geometries=0; int count_points_total=0; int count_z_total=0; int count_m_total=0; if ((strlen(dem_config->dem_path) > 0) && (strlen(dem_config->dem_table) > 0) && (strlen(dem_config->dem_geometry) > 0) && (dem_config->dem_srid > 0) && (dem_config->has_z) && (strlen(source_config->dem_path) > 0) && (strlen(source_config->dem_table) > 0) && (strlen(source_config->dem_geometry) > 0) && (source_config->default_srid > 0) && (source_config->has_z)) {// The dem Database Table and geometry-columns exist and contains a z-value dimension. // -- -- ---------------------------------- -- if (verbose) { fprintf(stderr,"-I-> starting update of [%s(%s)] where Z-Values are different.\n",source_config->dem_table, source_config->dem_geometry); } /* ok, going to convert */ /* the complete operation is handled as an unique SQL Transaction */ gettimeofday(&time_start, 0); if (sqlite3_exec(db_handle, "BEGIN", NULL, NULL, &sql_err) == SQLITE_OK) { if (retrieve_geometries(db_handle, source_config, dem_config, &count_total_geometries,&count_changed_geometries,&count_points_total,&count_z_total,&count_m_total, verbose) ) { /* committing the pending SQL Transaction */ if (sqlite3_exec(db_handle, "COMMIT", NULL, NULL, &sql_err) == SQLITE_OK) { ret = 0; } else { if (verbose) { fprintf(stderr, "COMMIT TRANSACTION error: %s\n", sql_err); } sqlite3_free(sql_err); if (sql_err) { sqlite3_free(sql_err); } ret = -1; } } else { ret = -1; if (sqlite3_exec(db_handle, "ROLLBACK", NULL, NULL, &sql_err) == SQLITE_OK) { } if (sql_err) { sqlite3_free(sql_err); } if (verbose) { fprintf(stderr, "DB '%s'\n", source_config->dem_path); fprintf(stderr, "TABLE[%s] or GEOMETRY-Column[%s] error durring UPDATE\n",source_config->dem_table, source_config->dem_geometry); fprintf(stderr, "*** ERROR: conversion failed\n\n"); } } gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (ret == 0) { if (verbose) { fprintf(stderr,"-I-> geometries total[%d] changed[%d] ; points total[%d] changed z[%d] changed m[%d]\n",count_total_geometries,count_changed_geometries,count_points_total,count_z_total,count_m_total); fprintf(stderr,"\tDatabase-file successfully updated found, changed, Z-Values !!!\n"); fprintf(stderr,"%s\n\n", time_message); } } } else { if (verbose) { fprintf(stderr, "BEGIN TRANSACTION error: %s\n", sql_err); } sqlite3_free(sql_err); if (sql_err) { sqlite3_free(sql_err); } ret = -1; } } else {// preconditions not fulfilled if (verbose) { fprintf(stderr,"-E-> command_updatez_db: preconditions failed [%s(%s)] \n",source_config->dem_table, source_config->dem_geometry); } } // -- -- ---------------------------------- -- if (time_message) { sqlite3_free(time_message); time_message = NULL; } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Implementation of command: fetchz // - from a given srid, point_x,point_y // --> return point_z value // -- -- ---------------------------------- -- static int command_fetchz(sqlite3 *db_handle, struct config_dem *dem_config, int verbose) { int ret=0; char *time_message = NULL; struct timeval time_start; struct timeval time_end; struct timeval time_diff; // -- -- ---------------------------------- -- if ( (dem_config->fetchz_x != 0.0) && (dem_config->fetchz_x != dem_config->fetchz_y) && (dem_config->default_srid > 0) && (dem_config->dem_srid > 0)) { if (verbose) { fprintf(stderr, "FetchZ modus: with default_srid[%d] x[%2.7f] y[%2.7f] has_m[%d]\n",dem_config->default_srid,dem_config->fetchz_x,dem_config->fetchz_y,dem_config->has_m); } gettimeofday(&time_start, 0); if (callFetchZ(db_handle,dem_config,verbose) ) { ret=1; gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (verbose) { if (dem_config->has_m) { fprintf(stderr, "FetchZ modus: with dem_srid[%d] x[%2.7f] y[%2.7f] z[%2.7f] m[%2.7f]\n",dem_config->dem_srid,dem_config->fetchz_x,dem_config->fetchz_y,dem_config->dem_z,dem_config->dem_m); fprintf(stderr,"%s\n", time_message); } else { fprintf(stderr, "FetchZ modus: with dem_srid[%d] x[%2.7f] y[%2.7f] z[%2.7f]\n",dem_config->dem_srid,dem_config->fetchz_x,dem_config->fetchz_y,dem_config->dem_z); fprintf(stderr,"%s\n", time_message); } } else {// Output for bash if (dem_config->has_m) { printf("%2.7f %2.7f\n", dem_config->dem_z,dem_config->dem_m); } else { printf("%2.7f\n", dem_config->dem_z); } } } else { // callFetchZ failed } } else { // preconditions failed if (verbose) { if ( dem_config->fetchz_x == 0.0) { fprintf(stderr, "did you forget setting the -fetchz_x argument ?\n"); } if ( dem_config->fetchz_y == 0.0) { fprintf(stderr, "did you forget setting the -fetchz_y argument ?\n"); } if ( dem_config->default_srid <= 0) { fprintf(stderr, "did you forget setting the -default_srid argument ?\n"); } if ( dem_config->dem_srid <= 0) { fprintf(stderr, "The dem-srid is invalid\n"); } fprintf(stderr, "-E command_fetchz: sorry, cowardly quitting\n\n"); } } // -- -- ---------------------------------- -- if (time_message) { sqlite3_free(time_message); time_message = NULL; } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Implementation of command: fetchz // - from a given srid, point_x,point_y // --> return point_z value // -- -- ---------------------------------- -- static int command_dem_create(sqlite3 **db_handle, void *cache, struct config_dem *source_config, struct config_dem *dem_config, int verbose) { int ret=0; char *time_message = NULL; struct timeval time_start; struct timeval time_end; struct timeval time_diff; int count_xyz_files=0; // -- -- ---------------------------------- -- if (cache) { if ( dem_config->dem_srid <= 0) { dem_config->dem_srid=dem_config->default_srid; } if ((strlen(dem_config->dem_path) > 0) && (strlen(dem_config->dem_table) > 0) && (strlen(dem_config->dem_geometry) > 0) && (dem_config->dem_srid > 0)) { gettimeofday(&time_start, 0); if (create_dem_db(dem_config->dem_path, db_handle, cache, dem_config->dem_table, dem_config->dem_geometry,verbose)) { if (verbose) { fprintf(stderr,"-I-> command_dem_createt: created [%s] \n", dem_config->dem_path); } if (collect_xyz_files(*db_handle,source_config->dem_path, &count_xyz_files, 0) == 1) { dem_config->dem_rows_count=0; if (import_xyz(*db_handle, dem_config,count_xyz_files,verbose)) {// Import completed correctly gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (verbose) { fprintf(stderr,"%s\n", time_message); } gettimeofday(&time_start, 0); if (recover_geometry_dem(*db_handle, dem_config,verbose)) {// Task completed correctly } else {// Task failed if (verbose) { fprintf(stderr,"-W-> command_dem_created: recover_geometry_dem failed [%s(%s)] srid[%d] \n", dem_config->dem_table, dem_config->dem_geometry, dem_config->dem_srid); } } // Sniff the results, set schema_dem to 'main' dem_config->schema=source_config->schema; source_config->schema=NULL; gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (verbose) { fprintf(stderr,"%s\n", time_message); } } else {// Import failed if (verbose) { fprintf(stderr,"-W-> command_dem_created: import_xyz failed [%d] [%s] \n", count_xyz_files,source_config->dem_path); } } } } else { // Database exits or cannot be created if (verbose) { fprintf(stderr, "Dem '%s'\n", dem_config->dem_path); fprintf(stderr, "Database exists and will not be overwritten, use -import_xyz to add new data\n"); fprintf(stderr, "-E-> command_dem_create: sorry, cowardly quitting\n\n"); } } } else { // preconditions failed if (verbose) { if (strlen(dem_config->dem_path) <= 0) { fprintf(stderr, "did you forget setting the -ddem argument ?\n"); } if (strlen(dem_config->dem_table) <= 0) { fprintf(stderr, "did you forget setting the -tdem argument ?\n"); } if (strlen(dem_config->dem_geometry) <= 0) { fprintf(stderr, "did you forget setting the -gdem argument ?\n"); } if ( dem_config->default_srid <= 0) { fprintf(stderr, "did you forget setting the -default_srid argument ?\n"); } if ( dem_config->dem_srid <= 0) { fprintf(stderr, "The dem-srid is invalid\n"); } fprintf(stderr, "-E command_fetchz: sorry, cowardly quitting\n\n"); } } } // -- -- ---------------------------------- -- if (time_message) { sqlite3_free(time_message); time_message = NULL; } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Implementation of command: -import_xyz // - from a given srid, point_x,point_y // --> return point_z value // -- -- ---------------------------------- -- static int command_import_xyz(sqlite3 *db_handle, struct config_dem *source_config, struct config_dem *dem_config, int verbose) { int ret=0; char *time_message = NULL; char *sql_statement = NULL; char *err_msg = NULL;; struct timeval time_start; struct timeval time_end; struct timeval time_diff; int count_xyz_files=0; // -- -- ---------------------------------- -- if ((strlen(source_config->dem_path) > 0) && (strlen(dem_config->dem_path) > 0) && (strlen(dem_config->dem_table) > 0) && (strlen(dem_config->dem_geometry) > 0)) { if ((dem_config->has_z) && (dem_config->dem_srid > 0)) { if (db_handle) { gettimeofday(&time_start, 0); if (verbose) { fprintf(stderr, "-import_xyz: with srid[%d] .xyz[%s] \n",source_config->default_srid,source_config->dem_path); } if (collect_xyz_files(db_handle,source_config->dem_path, &count_xyz_files, 0) == 1) { dem_config->dem_rows_count=0; // Set to 0, just in case if (import_xyz(db_handle, dem_config,count_xyz_files,verbose)) {// Import completed correctly gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (verbose) { fprintf(stderr,"%s\n", time_message); } gettimeofday(&time_start, 0); if (verbose) { fprintf(stderr,"UpdateLayerStatistics: %s(%s)\n", dem_config->dem_table,dem_config->dem_geometry); } sql_statement = sqlite3_mprintf("SELECT UpdateLayerStatistics(%Q, %Q)", dem_config->dem_table,dem_config->dem_geometry); int ret_update = sqlite3_exec(db_handle, sql_statement, NULL, NULL, &err_msg); sqlite3_free(sql_statement); if (ret_update != SQLITE_OK) { fprintf(stderr, "UpdateLayerStatistics error: %s\n", err_msg); sqlite3_free(err_msg); } else { ret=1; } gettimeofday(&time_end, 0); timeval_subtract(&time_diff,&time_end,&time_start,&time_message); if (verbose) { fprintf(stderr,"%s\n", time_message); } } } } } } // -- -- ---------------------------------- -- if (time_message) { sqlite3_free(time_message); time_message = NULL; } // -- -- ---------------------------------- -- return ret; } // -- -- ---------------------------------- -- // Main // Commands // - sniff // -> allows the user to prepair the 'update' command // -> Source and Dem can be done separately or together // - update // -- -- ---------------------------------- -- int main(int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ sqlite3 *db_handle = NULL; char *schema_db = "main"; char *schema_dem = "db_dem"; char *dem_geometry_default = "dem_point"; void *cache = NULL; int verbose=0; int copy_m = 1; int next_arg = ARG_NONE; int i_command_type=CMD_DEM_SNIFF; struct config_dem dem_config; struct config_dem source_config; int save_conf=0; int exit_code=1; // unix_exit_code: 0=correct, 1=error int i=0; int error = 0; // -- -- ---------------------------------- -- // Will look for conf [not an error if nothing found] // - if not found, all arguments must be set // -- -- ---------------------------------- -- char *dem_configfile = "spatialite_dem.conf"; char *spatialite_dem = getenv("SPATIALITE_DEM"); // -- -- ---------------------------------- -- // Reading the configuration, if found // - setting default values // -- -- ---------------------------------- -- if (spatialite_dem) { dem_configfile=spatialite_dem; } // -- -- ---------------------------------- -- // Warning, if non default, conf is given but not found // -- -- ---------------------------------- -- dem_config = get_demconfig(dem_configfile,1); dem_config.config_type = CONF_TYPE_DEM; // dem dem_config.schema = schema_dem; // dem // -- -- ---------------------------------- -- // No external source config // - returns default values only // -- -- ---------------------------------- -- source_config = get_demconfig(NULL,0); source_config.config_type = CONF_TYPE_SOURCE; // source source_config.schema = schema_db; // source // -- -- ---------------------------------- -- if (strlen(dem_config.dem_path) > 0) { if (dem_config.dem_srid > 0) { source_config.dem_srid=dem_config.dem_srid; } if (dem_config.default_srid > 0) { source_config.default_srid=dem_config.default_srid; } } // -- -- ---------------------------------- -- // Reading the arguments // -- -- ---------------------------------- -- for (i = 1; i < argc; i++) { // parsing the invocation arguments if (next_arg != ARG_NONE) { switch (next_arg) { case ARG_DB_PATH: strcpy(source_config.dem_path,argv[i]); break; case ARG_TABLE: strcpy(source_config.dem_table,argv[i]); break; case ARG_COL: strcpy(source_config.dem_geometry,argv[i]); break; case ARG_DEM_PATH: strcpy(dem_config.dem_path,argv[i]); break; case ARG_TABLE_DEM: strcpy(dem_config.dem_table,argv[i]); break; case ARG_COL_DEM: strcpy(dem_config.dem_geometry,argv[i]); break; case ARG_RESOLUTION_DEM: // this will override the calculated value (which may not be correct) // - it also gives the user the choice to change the area around a point to search for. dem_config.dem_resolution = atof(argv[i]); break; case ARG_COPY_M: copy_m = atoi(argv[i]); if (copy_m != 1 ) copy_m=0; break; case ARG_FETCHZ_X: dem_config.fetchz_x = atof(argv[i]); break; case ARG_FETCHZ_Y: dem_config.fetchz_y = atof(argv[i]); break; case ARG_FETCHZ_XY: dem_config.fetchz_x = atof(argv[i++]); dem_config.fetchz_y = atof(argv[i]); break; case ARG_DEFAULT_SRID: source_config.default_srid = atoi(argv[i]); dem_config.default_srid = atoi(argv[i]); break; }; next_arg = ARG_NONE; continue; } if (strcasecmp (argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { do_help (); return exit_code; } if (strcmp(argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--table") == 0) { next_arg = ARG_TABLE; continue; } if (strcmp(argv[i], "-t") == 0) { next_arg = ARG_TABLE; continue; } if (strcasecmp (argv[i], "--geometry-column") == 0) { next_arg = ARG_COL; continue; } if (strcmp(argv[i], "-g") == 0) { next_arg = ARG_COL; continue; } if (strcasecmp (argv[i], "--dem-path") == 0) { next_arg = ARG_DEM_PATH; continue; } if (strcmp(argv[i], "-ddem") == 0) { next_arg = ARG_DEM_PATH; continue; } if (strcasecmp (argv[i], "--table-dem") == 0) { next_arg = ARG_TABLE_DEM; continue; } if (strcmp(argv[i], "-tdem") == 0) { next_arg = ARG_TABLE_DEM; continue; } if (strcasecmp (argv[i], "--geometry-dem-column") == 0) { next_arg = ARG_COL_DEM; continue; } if (strcmp(argv[i], "-gdem") == 0) { next_arg = ARG_COL_DEM; continue; } if (strcasecmp (argv[i], "--dem-resolution") == 0) { next_arg = ARG_RESOLUTION_DEM; continue; } if (strcmp(argv[i], "-rdem") == 0) { next_arg = ARG_RESOLUTION_DEM; continue; } if (strcasecmp (argv[i], "--m-copy") == 0) { next_arg = ARG_COPY_M; continue; } if (strcmp(argv[i], "-mdem") == 0) { next_arg = ARG_COPY_M; continue; } if (strcmp(argv[i], "-sniff") == 0) { i_command_type=CMD_DEM_SNIFF; continue; } if (strcmp(argv[i], "-updatez") == 0) { i_command_type=CMD_DEM_UPDATEZ; continue; } if (strcmp(argv[i], "-fetchz") == 0) { i_command_type=CMD_DEM_FETCHZ; continue; } if (strcmp(argv[i], "-create_dem") == 0) { i_command_type=CMD_DEM_CREATE; continue; } if (strcmp(argv[i], "-import_xyz") == 0) { i_command_type=CMD_DEM_IMPORT_XYZ; continue; } if (strcmp(argv[i], "-fetchz_x") == 0) { next_arg = ARG_FETCHZ_X; continue; } if (strcmp(argv[i], "-fetchz_y") == 0) { next_arg = ARG_FETCHZ_Y; continue; } if (strcmp(argv[i], "-fetchz_xy") == 0) { next_arg = ARG_FETCHZ_XY; continue; } if ( (strcmp(argv[i], "-default_srid") == 0) || (strcmp(argv[i], "--srid") == 0) ) { next_arg = ARG_DEFAULT_SRID; continue; } if ( (strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "--verbose") == 0) ) { verbose = 1; continue; } if ( (strcmp(argv[i], "-save_conf") == 0) || (strcmp(argv[i], "--dem_conf") == 0) ) { save_conf=1; continue; } fprintf(stderr, "unknown argument: %s\n", argv[i]); error = 1; } // -- -- ---------------------------------- -- // Setting the default argument of dem_geometry // - dem_point // -- -- ---------------------------------- -- if (strlen(dem_config.dem_geometry) == 0) { strcpy(dem_config.dem_geometry,dem_geometry_default); } // -- -- ---------------------------------- -- // checking, resetting the arguments // -- -- ---------------------------------- -- if (i_command_type == CMD_DEM_SNIFF) { if ((strlen(dem_config.dem_path) > 0) && (strlen(dem_config.dem_table) > 0) && (strlen(dem_config.dem_geometry) > 0) && (dem_config.fetchz_x != 0.0) && (dem_config.fetchz_x != dem_config.fetchz_y) ) {// -fetchz was intended but forgotten, be tolerant to the lazy user i_command_type = CMD_DEM_FETCHZ; } else {// for -sniff -v is always active verbose=1; } } if (verbose) { if (strlen(dem_config.dem_path) == 0) { if (i_command_type == CMD_DEM_UPDATEZ) { fprintf(stderr, "did you forget setting the --dem-path argument ?\n"); error = 1; } else { fprintf(stderr, "Warning: --dem-path argument has not been set [assuming -sniff only]\n"); } } if (strlen(source_config.dem_path) == 0) { if (i_command_type == CMD_DEM_UPDATEZ) { fprintf(stderr, "did you forget setting the --db-path argument ?\n"); error = 1; } } } // -- -- ---------------------------------- -- // Bale out on errors // -- -- ---------------------------------- -- if (error) { do_help(); return exit_code; } // -- -- ---------------------------------- -- // opening the DB // - method 1: create a new Database // - method 2: input is not a Database, only Dem // - method 3: both input and dem are a Database, when given // -- -- ---------------------------------- -- cache = spatialite_alloc_connection(); if (i_command_type == CMD_DEM_CREATE) { if (command_dem_create(&db_handle, cache, &source_config, &dem_config, verbose)) { // Sniff the results, set schema_dem to 'main' i_command_type = CMD_DEM_SNIFF; dem_config.schema=schema_db; } } else { if (i_command_type == CMD_DEM_IMPORT_XYZ) {// Open the Dem-Database as the main source [not attached ; since db_path=import.xyz] open_db(&db_handle, cache, NULL, &dem_config,verbose); } else {// Open the Dem-Database as the main source if there is no source [otherwise attached, with source as main ] open_db(&db_handle, cache, &source_config, &dem_config,verbose); } } // -- -- ---------------------------------- -- // Bale out if no connection // -- -- ---------------------------------- -- if (!db_handle) { spatialite_cleanup_ex(cache); cache=NULL; return exit_code; } // -- -- ---------------------------------- -- // checking the Source-Database // -- -- ---------------------------------- -- command_check_source_db(db_handle,&source_config, &dem_config, verbose); // -- -- ---------------------------------- -- // checking the Dem-Database // -- -- ---------------------------------- -- if (command_check_dem_db(db_handle,&dem_config, &source_config, verbose) ) { if ( save_conf == 1) { if (write_demconfig(dem_configfile, dem_config)) { fprintf(stderr, "Dem-conf: with default_srid[%d] was saved to\n\t[%s].\n",dem_config.default_srid,dem_configfile); } } } // -- -- ---------------------------------- -- // After checking, the called functions // will check the result before running // -- -- ---------------------------------- -- if ( (i_command_type == CMD_DEM_SNIFF) && (dem_config.has_z) && (source_config.has_z)) { if (verbose) { fprintf(stderr, "Sniffing modus: All pre-conditions have been fulfilled.\n"); fprintf(stderr, "\t to start update, use the '-updatez' parameter.\n"); fprintf(stderr, "\t to save dem-conf, use the '-save_conf' parameter.\n"); } exit_code = 0; // correct } // -- -- ---------------------------------- -- // Start --update // -- -- ---------------------------------- -- if (i_command_type == CMD_DEM_UPDATEZ) { if (!copy_m) {// The User desires that m values be ignored dem_config.has_m=0; } if (command_updatez_db(db_handle, &source_config,&dem_config, verbose) ) { exit_code = 0; // correct } } // -- -- ---------------------------------- -- // Start -import_xyz // -- -- ---------------------------------- -- if (i_command_type == CMD_DEM_IMPORT_XYZ) { if (command_import_xyz(db_handle, &source_config, &dem_config, verbose)) { exit_code = 0; // correct } } // -- -- ---------------------------------- -- // Start -fetchz // -- -- ---------------------------------- -- if (i_command_type == CMD_DEM_FETCHZ) { if (command_fetchz(db_handle, &dem_config, verbose) ) { exit_code = 0; // correct } } // -- -- ---------------------------------- -- // Close Application // - DETACH when needed // -- -- ---------------------------------- -- if (db_handle) { close_db(db_handle,cache, schema_dem); cache=NULL; } return exit_code; // -- -- ---------------------------------- -- } |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to spatialite_dxf.c.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 .. 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 ... 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_dxf: %s\n", VERSION); fprintf (stderr, "target CPU ...: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite : %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ...: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_dxf ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); fprintf (stderr, "-x or --dxf-path pathname the input DXF path\n\n"); fprintf (stderr, "you can specify the following options as well:\n"); fprintf (stderr, "----------------------------------------------\n"); fprintf (stderr, "-s or --srid num an explicit SRID value\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { |
< < < < | | < < < < < < < < < < < < < < < < < < < < |
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 .. 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 ... 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include "config.h" #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_dxf ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); fprintf (stderr, "-x or --dxf-path pathname the input DXF path\n\n"); fprintf (stderr, "you can specify the following options as well:\n"); fprintf (stderr, "----------------------------------------------\n"); fprintf (stderr, "-s or --srid num an explicit SRID value\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { |
Changes to spatialite_gml.c.
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 .... 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 .... 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 .... 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 .... 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 .... 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 |
if (params->is_feature) check_end1_fid (params, el); if (params->is_fid) { *(params->CharData + params->CharDataLen) = '\0'; column_name (params, el); } *(params->CharData) = '\0'; params->CharDataLen = 0; } static void column_value (struct gml_params *params, const char *el) { /* handling a column value */ char prefix[1024]; ................................................................................ *(params->CharData + params->CharDataLen) = '\0'; column_value (params, el); } if (strcasecmp (el, "gml:coordinates") == 0) parse_coords_1 (params); if (strcasecmp (el, "gml:posList") == 0 || strcasecmp (el, "gml:pos") == 0) parse_coords_2 (params); *(params->CharData) = '\0'; params->CharDataLen = 0; } static void spatialite_autocreate (sqlite3 * db) { /* attempting to perform self-initialization for a newly created DB */ int ret; ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, void *cache) ................................................................................ col = col_n; } if (params->CharData) free (params->CharData); clean_geometry (params); } static void do_version () { /* printing version infos */ XML_Expat_Version expat; fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_gml: %s\n", VERSION); fprintf (stderr, "target CPU ...: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite : %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ...: %s\n", sqlite3_libversion ()); expat = XML_ExpatVersionInfo (); fprintf (stderr, "libexpat .....: %d.%d.%d\n", expat.major, expat.minor, expat.micro); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_gml ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-g or --gml-path pathname the GML-XML file path\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "-t or --table-name name the DB table name\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "-m or --in-memory using IN-MEMORY database\n"); ................................................................................ params.geometry = NULL; params.polygon.exterior = NULL; params.polygon.first = NULL; params.polygon.last = NULL; params.CharDataStep = 65536; params.CharDataMax = params.CharDataStep; params.CharData = malloc (params.CharDataStep); params.CharDataLen = 0; for (i = 1; i < argc; i++) { /* parsing the invocation arguments */ if (next_arg != ARG_NONE) { switch (next_arg) ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-g") == 0) { next_arg = ARG_GML_PATH; continue; } if (strcasecmp (argv[i], "--gml-path") == 0) { |
< < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < |
587 588 589 590 591 592 593 594 595 596 597 598 599 600 .... 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 .... 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 .... 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 .... 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 .... 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 |
if (params->is_feature) check_end1_fid (params, el); if (params->is_fid) { *(params->CharData + params->CharDataLen) = '\0'; column_name (params, el); } } static void column_value (struct gml_params *params, const char *el) { /* handling a column value */ char prefix[1024]; ................................................................................ *(params->CharData + params->CharDataLen) = '\0'; column_value (params, el); } if (strcasecmp (el, "gml:coordinates") == 0) parse_coords_1 (params); if (strcasecmp (el, "gml:posList") == 0 || strcasecmp (el, "gml:pos") == 0) parse_coords_2 (params); } static void spatialite_autocreate (sqlite3 * db) { /* attempting to perform self-initialization for a newly created DB */ int ret; ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, void *cache) ................................................................................ col = col_n; } if (params->CharData) free (params->CharData); clean_geometry (params); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_gml ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-g or --gml-path pathname the GML-XML file path\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "-t or --table-name name the DB table name\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "-m or --in-memory using IN-MEMORY database\n"); ................................................................................ params.geometry = NULL; params.polygon.exterior = NULL; params.polygon.first = NULL; params.polygon.last = NULL; params.CharDataStep = 65536; params.CharDataMax = params.CharDataStep; params.CharData = malloc (params.CharDataStep); for (i = 1; i < argc; i++) { /* parsing the invocation arguments */ if (next_arg != ARG_NONE) { switch (next_arg) ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-g") == 0) { next_arg = ARG_GML_PATH; continue; } if (strcasecmp (argv[i], "--gml-path") == 0) { |
Changes to spatialite_network.c.
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 .... 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 .... 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 .... 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 .... 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void validate (const char *path, const char *table, const char *from_column, ................................................................................ if (ret != SQLITE_OK) fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); graph_free (p_graph); } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_network: %s\n", VERSION); fprintf (stderr, "target CPU .......: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ....: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .......: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_network ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite db path\n"); fprintf (stderr, "-T or --table table_name the db table to be validated\n"); fprintf (stderr, "-f or --from-column col_name the column for FromNode\n"); fprintf (stderr, ................................................................................ "both columns are expected to contain BOOLEAN values [1-0];\n"); fprintf (stderr, "1 means that the arc connection in the given direction is\n"); fprintf (stderr, "valid, otherwise 0 means a forbidden connection\n\n"); fprintf (stderr, "in order to create a permanent NETWORK-DATA table\n"); fprintf (stderr, "you can select the following options:\n"); fprintf (stderr, "-o or --output-table table_name\n"); fprintf (stderr, "-vt or --virtual-table table_name\n"); fprintf (stderr, "--overwrite-output\n\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { ................................................................................ continue; } if (strcasecmp (argv[i], "--virtual-table") == 0) { next_arg = ARG_VIRT_TABLE; continue; } if (strcmp (argv[i], "-vt") == 0) { next_arg = ARG_VIRT_TABLE; continue; } if (strcasecmp (argv[i], "--from-column") == 0) { next_arg = ARG_FROM_COLUMN; |
| | < < < < < < < < < < < < < < | < < < < < < | |
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 .... 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 .... 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 .... 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 .... 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void validate (const char *path, const char *table, const char *from_column, ................................................................................ if (ret != SQLITE_OK) fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); graph_free (p_graph); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_network ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite db path\n"); fprintf (stderr, "-T or --table table_name the db table to be validated\n"); fprintf (stderr, "-f or --from-column col_name the column for FromNode\n"); fprintf (stderr, ................................................................................ "both columns are expected to contain BOOLEAN values [1-0];\n"); fprintf (stderr, "1 means that the arc connection in the given direction is\n"); fprintf (stderr, "valid, otherwise 0 means a forbidden connection\n\n"); fprintf (stderr, "in order to create a permanent NETWORK-DATA table\n"); fprintf (stderr, "you can select the following options:\n"); fprintf (stderr, "-o or --output-table table_name\n"); fprintf (stderr, "-v or --virtual-table table_name\n"); fprintf (stderr, "--overwrite-output\n\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--db-path") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcmp (argv[i], "-d") == 0) { ................................................................................ continue; } if (strcasecmp (argv[i], "--virtual-table") == 0) { next_arg = ARG_VIRT_TABLE; continue; } if (strcmp (argv[i], "-v") == 0) { next_arg = ARG_VIRT_TABLE; continue; } if (strcasecmp (argv[i], "--from-column") == 0) { next_arg = ARG_FROM_COLUMN; |
Changes to spatialite_osm_filter.c.
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 ... 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 ... 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 .... 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 .... 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 |
if (sqlite3_column_type (query, 9) != SQLITE_NULL) v = clean_xml ((const char *) sqlite3_column_text (query, 9)); if (first) { /* first NODE row */ char *timestamp = p_timestamp ? clean_xml (p_timestamp) : NULL; char *changeset = p_changeset ? clean_xml (p_changeset) : NULL; char *user = p_user ? clean_xml (p_user) : NULL; first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<node id=\"%I64d\"", id); #else fprintf (out, "\t<node id=\"%lld\"", id); #endif if (user) { fprintf (out, " user=\"%s\"", user); free (user); } if (changeset) { fprintf (out, " changeset=\"%s\"", changeset); free (changeset); } if (timestamp) { fprintf (out, " timestamp=\"%s\"", timestamp); free (timestamp); } if (!version) version = 1; fprintf (out, " version=\"%d\"", version); fprintf (out, " lat=\"%1.7f\" lon=\"%1.7f\" uid=\"%d\" ", y, x, uid); if (k == NULL && v == NULL) fprintf (out, "/>\n"); else fprintf (out, ">\n"); } if (k != NULL && v != NULL) { ................................................................................ (const char *) sqlite3_column_text (query, 5); sqlite3_int64 node_id = sqlite3_column_int64 (query, 6); if (first) { /* first WAY row */ char *timestamp = p_timestamp ? clean_xml (p_timestamp) : NULL; char *changeset = p_changeset ? clean_xml (p_changeset) : NULL; char *user = NULL; if (p_user) user = clean_xml (p_user); first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<way id=\"%I64d\"", id); #else fprintf (out, "\t<way id=\"%lld\"", id); #endif if (user) { fprintf (out, " user=\"%s\"", user); free (user); } if (changeset) { fprintf (out, " changeset=\"%s\"", changeset); free (changeset); } if (timestamp) { fprintf (out, " timestamp=\"%s\"", timestamp); free (timestamp); } if (!version) version = 1; fprintf (out, " version=\"%d\"", version); fprintf (out, " uid=\"%d\" >\n", uid); } /* NODE REF tag */ #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t\t<nd ref=\"%I64d\"/>\n", node_id); #else fprintf (out, "\t\t<nd ref=\"%lld\"/>\n", node_id); ................................................................................ clean_xml ((const char *) sqlite3_column_text (query_way, 6)); sqlite3_int64 way_id = sqlite3_column_int64 (query_way, 7); if (first) { /* first RELATION row */ char *timestamp = p_timestamp ? clean_xml (p_timestamp) : NULL; char *changeset = p_changeset ? clean_xml (p_changeset) : NULL; char *user = NULL; if (p_user) user = clean_xml (p_user); first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<relation id=\"%I64d\"", id); #else fprintf (out, "\t<relation id=\"%lld\"", id); #endif if (user) { fprintf (out, " user=\"%s\"", user); free (user); } if (changeset) { fprintf (out, " changeset=\"%s\"", changeset); free (changeset); } if (timestamp) { fprintf (out, " timestamp=\"%s\"", timestamp); free (timestamp); } if (!version) version = 1; fprintf (out, " version=\"%d\"", version); fprintf (out, " uid=\"%d\" >\n", uid); } /* NODE REF tag */ #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t\t<member type=\"way\" ref=\"%I64d\" role=\"%s\"/>\n", way_id, role); ................................................................................ if (db_handle) sqlite3_close (db_handle); fprintf (stderr, "DB '%s'\n", path); fprintf (stderr, "doesn't seems to contain valid OSM-RAW data ...\n\n"); return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_filter: %s\n", VERSION); fprintf (stderr, "target CPU ..........: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite .......: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ..........: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_filter ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML [output] file path\n"); fprintf (stderr, "-w or --wkt-mask-path pathname path of text file [WKT mask]\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "you can specify the following options as well\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
| < < | < | | | | | | | | | | | | | | | | | < < < < < < < < < | < < | < < | | | | | | | | | | | | | | < < < < < < < | | < < | < < | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 ... 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 ... 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 .... 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 .... 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 |
if (sqlite3_column_type (query, 9) != SQLITE_NULL) v = clean_xml ((const char *) sqlite3_column_text (query, 9)); if (first) { /* first NODE row */ char *timestamp = clean_xml (p_timestamp); char *changeset = clean_xml (p_changeset); char *user = NULL; if (p_user) user = clean_xml (p_user); first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<node id=\"%I64d\"", id); #else fprintf (out, "\t<node id=\"%lld\"", id); #endif if (!user) fprintf (out, " lat=\"%1.7f\" lon=\"%1.7f\" version=\"%d\" changeset=\"%s\" uid=\"%d\" timestamp=\"%s\"", y, x, version, changeset, uid, timestamp); else fprintf (out, " lat=\"%1.7f\" lon=\"%1.7f\" version=\"%d\" changeset=\"%s\" user=\"%s\" uid=\"%d\" timestamp=\"%s\"", y, x, version, changeset, user, uid, timestamp); free (changeset); if (user) free (user); free (timestamp); if (k == NULL && v == NULL) fprintf (out, "/>\n"); else fprintf (out, ">\n"); } if (k != NULL && v != NULL) { ................................................................................ (const char *) sqlite3_column_text (query, 5); sqlite3_int64 node_id = sqlite3_column_int64 (query, 6); if (first) { /* first WAY row */ char *timestamp = clean_xml (p_timestamp); char *changeset = clean_xml (p_changeset); char *user = NULL; if (p_user) user = clean_xml (p_user); first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<way id=\"%I64d\"", id); #else fprintf (out, "\t<way id=\"%lld\"", id); #endif if (!user) fprintf (out, " version=\"%d\" changeset=\"%s\" uid=\"%d\" timestamp=\"%s\">\n", version, changeset, uid, timestamp); else fprintf (out, " version=\"%d\" changeset=\"%s\" user=\"%s\" uid=\"%d\" timestamp=\"%s\">\n", version, changeset, user, uid, timestamp); free (changeset); if (user) free (user); free (timestamp); } /* NODE REF tag */ #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t\t<nd ref=\"%I64d\"/>\n", node_id); #else fprintf (out, "\t\t<nd ref=\"%lld\"/>\n", node_id); ................................................................................ clean_xml ((const char *) sqlite3_column_text (query_way, 6)); sqlite3_int64 way_id = sqlite3_column_int64 (query_way, 7); if (first) { /* first WAY row */ char *timestamp = clean_xml (p_timestamp); char *changeset = clean_xml (p_changeset); char *user = NULL; if (p_user) user = clean_xml (p_user); first = 0; #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t<relation id=\"%I64d\"", id); #else fprintf (out, "\t<relation id=\"%lld\"", id); #endif if (!user) fprintf (out, " version=\"%d\" changeset=\"%s\" uid=\"%d\" timestamp=\"%s\">\n", version, changeset, uid, timestamp); else fprintf (out, " version=\"%d\" changeset=\"%s\" user=\"%s\" uid=\"%d\" timestamp=\"%s\">\n", version, changeset, user, uid, timestamp); free (changeset); free (user); free (timestamp); } /* NODE REF tag */ #if defined(_WIN32) || defined(__MINGW32__) /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */ fprintf (out, "\t\t<member type=\"way\" ref=\"%I64d\" role=\"%s\"/>\n", way_id, role); ................................................................................ if (db_handle) sqlite3_close (db_handle); fprintf (stderr, "DB '%s'\n", path); fprintf (stderr, "doesn't seems to contain valid OSM-RAW data ...\n\n"); return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_filter ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML [output] file path\n"); fprintf (stderr, "-w or --wkt-mask-path pathname path of text file [WKT mask]\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "you can specify the following options as well\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
Changes to spatialite_osm_map.c.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 ... 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 ... 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 ... 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 ... 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 ... 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 ... 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 ... 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 ... 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 .... 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 .... 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 .... 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 .... 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 .... 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 .... 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 .... 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 |
gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (layer->ins_point_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_point_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_POINT %s (%s)\n", layer_name, sqlite3_errmsg (params->db_handle)); return 1; } return 1; } } return 1; } ................................................................................ gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (params->ins_generic_point_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_point_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POINT (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int address_insert (struct aux_params *params, const readosm_node * node, const char *country, const char *city, const char *postcode, ................................................................................ gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (params->ins_addresses_stmt, 8, blob, blob_size, free); ret = sqlite3_step (params->ins_addresses_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_ADDRESSES (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int tmp_nodes_insert (struct aux_params *params, const readosm_node * node) { ................................................................................ sqlite3_clear_bindings (params->ins_tmp_nodes_stmt); sqlite3_bind_int64 (params->ins_tmp_nodes_stmt, 1, node->id); sqlite3_bind_double (params->ins_tmp_nodes_stmt, 2, node->latitude); sqlite3_bind_double (params->ins_tmp_nodes_stmt, 3, node->longitude); ret = sqlite3_step (params->ins_tmp_nodes_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_TMP_NODES (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } static int consume_node (const void *user_data, const readosm_node * node) { /* processing an OSM Node (ReadOSM callback function) */ struct aux_params *params = (struct aux_params *) user_data; ................................................................................ SQLITE_STATIC); sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (layer->ins_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_LINESTRING %s (%s)\n", layer_name, sqlite3_errmsg (params->db_handle)); return 1; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (layer->ins_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_POLYGON %s (%s)\n", layer_name, sqlite3_errmsg (params->db_handle)); return 1; } return 1; } } return 1; } ................................................................................ sqlite3_bind_text (params->ins_generic_linestring_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_generic_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_LINESTRING (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int polygon_generic_insert (struct aux_params *params, sqlite3_int64 id, unsigned char *blob, int blob_size, const char *name) ................................................................................ sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_generic_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POLYGON (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int tmp_ways_insert (struct aux_params *params, sqlite3_int64 id, int area, unsigned char *blob, int blob_size) ................................................................................ sqlite3_bind_int (params->ins_tmp_ways_stmt, 2, area); sqlite3_bind_blob (params->ins_tmp_ways_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_tmp_ways_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_TMP_WAYS (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } static int eval_way (struct aux_params *params, const readosm_way * way, int area, unsigned char *blob, int blob_size) { int i_tag; ................................................................................ SQLITE_STATIC); sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_MULTILINESTRING %s (%s)\n", layer_name, sqlite3_errmsg (params->db_handle)); return 1; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_MULTIPOLYGON %s (%s)\n", layer_name, sqlite3_errmsg (params->db_handle)); return 1; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_MULTILINESTRING (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int multipolygon_generic_insert (struct aux_params *params, const readosm_relation * relation, ................................................................................ sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_MULTIPOLYGON (%s)\n", sqlite3_errmsg (params->db_handle)); return 1; } return 1; } static int consume_relation (const void *user_data, const readosm_relation * relation) { ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache) ................................................................................ geom = results[(i * columns) + 1]; do_spatial_index (db_handle, table, geom); } } sqlite3_free_table (results); } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_map: %s\n", VERSION); fprintf (stderr, "target CPU .......: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ....: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .......: %s\n", sqlite3_libversion ()); fprintf (stderr, "libreadosm .......: %s\n", readosm_version ()); fprintf (stderr, "libexpat .........: %s\n", readosm_expat_version ()); fprintf (stderr, "zlib .............: %s\n", readosm_zlib_version ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_map ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
< | > | > | | | > | | | > | | | > | | | > > | | | > > | < | > | | | | > | | | > | | | > > | | | > > | | | > | < | > | | | | < < < < < < < < < < < < < < < < < < < < < < < |
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 ... 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 ... 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 ... 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 ... 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 ... 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 ... 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 ... 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 ... 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 .... 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 .... 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 .... 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 .... 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 .... 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 .... 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 .... 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 |
gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (layer->ins_point_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_point_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_POINT %s\n", layer_name); sqlite3_finalize (layer->ins_point_stmt); layer->ins_point_stmt = NULL; return 0; } return 1; } } return 1; } ................................................................................ gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (params->ins_generic_point_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_point_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POINT\n"); sqlite3_finalize (params->ins_generic_point_stmt); params->ins_generic_point_stmt = NULL; return 0; } return 1; } static int address_insert (struct aux_params *params, const readosm_node * node, const char *country, const char *city, const char *postcode, ................................................................................ gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size); gaiaFreeGeomColl (geom); sqlite3_bind_blob (params->ins_addresses_stmt, 8, blob, blob_size, free); ret = sqlite3_step (params->ins_addresses_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_ADDRESSES\n"); sqlite3_finalize (params->ins_addresses_stmt); params->ins_addresses_stmt = NULL; return 0; } return 1; } static int tmp_nodes_insert (struct aux_params *params, const readosm_node * node) { ................................................................................ sqlite3_clear_bindings (params->ins_tmp_nodes_stmt); sqlite3_bind_int64 (params->ins_tmp_nodes_stmt, 1, node->id); sqlite3_bind_double (params->ins_tmp_nodes_stmt, 2, node->latitude); sqlite3_bind_double (params->ins_tmp_nodes_stmt, 3, node->longitude); ret = sqlite3_step (params->ins_tmp_nodes_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_TMP_NODES\n"); sqlite3_finalize (params->ins_tmp_nodes_stmt); params->ins_tmp_nodes_stmt = NULL; return 0; } static int consume_node (const void *user_data, const readosm_node * node) { /* processing an OSM Node (ReadOSM callback function) */ struct aux_params *params = (struct aux_params *) user_data; ................................................................................ SQLITE_STATIC); sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (layer->ins_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_LINESTRING %s\n", layer_name); sqlite3_finalize (layer->ins_linestring_stmt); layer->ins_linestring_stmt = NULL; return 0; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (layer->ins_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_POLYGON %s\n", layer_name); sqlite3_finalize (layer->ins_polygon_stmt); layer->ins_polygon_stmt = NULL; return 0; } return 1; } } return 1; } ................................................................................ sqlite3_bind_text (params->ins_generic_linestring_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_generic_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_LINESTRING\n"); sqlite3_finalize (params->ins_generic_linestring_stmt); params->ins_generic_linestring_stmt = NULL; return 0; } return 1; } static int polygon_generic_insert (struct aux_params *params, sqlite3_int64 id, unsigned char *blob, int blob_size, const char *name) ................................................................................ sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_generic_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POLYGON\n"); sqlite3_finalize (params->ins_generic_polygon_stmt); params->ins_generic_polygon_stmt = NULL; return 0; } return 1; } static int tmp_ways_insert (struct aux_params *params, sqlite3_int64 id, int area, unsigned char *blob, int blob_size) ................................................................................ sqlite3_bind_int (params->ins_tmp_ways_stmt, 2, area); sqlite3_bind_blob (params->ins_tmp_ways_stmt, 3, blob, blob_size, SQLITE_STATIC); ret = sqlite3_step (params->ins_tmp_ways_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_TMP_WAYS\n"); sqlite3_finalize (params->ins_tmp_ways_stmt); params->ins_tmp_ways_stmt = NULL; return 0; } static int eval_way (struct aux_params *params, const readosm_way * way, int area, unsigned char *blob, int blob_size) { int i_tag; ................................................................................ SQLITE_STATIC); sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_MULTILINESTRING %s\n", layer_name); sqlite3_finalize (layer->ins_linestring_stmt); layer->ins_linestring_stmt = NULL; return 0; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob, blob_size, free); ret = sqlite3_step (layer->ins_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_MULTIPOLYGON %s\n", layer_name); sqlite3_finalize (layer->ins_polygon_stmt); layer->ins_polygon_stmt = NULL; return 0; } return 1; } } return 1; } ................................................................................ strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_linestring_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_MULTILINESTRING\n"); sqlite3_finalize (params->ins_generic_linestring_stmt); params->ins_generic_linestring_stmt = NULL; return 0; } return 1; } static int multipolygon_generic_insert (struct aux_params *params, const readosm_relation * relation, ................................................................................ sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name, strlen (name), SQLITE_STATIC); sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob, blob_size, free); ret = sqlite3_step (params->ins_generic_polygon_stmt); if (ret == SQLITE_DONE || ret == SQLITE_ROW) return 1; fprintf (stderr, "sqlite3_step() error: INS_GENERIC_MULTIPOLYGON\n"); sqlite3_finalize (params->ins_generic_polygon_stmt); params->ins_generic_polygon_stmt = NULL; return 0; } return 1; } static int consume_relation (const void *user_data, const readosm_relation * relation) { ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache) ................................................................................ geom = results[(i * columns) + 1]; do_spatial_index (db_handle, table, geom); } } sqlite3_free_table (results); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_map ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
Changes to spatialite_osm_net.c.
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 .... 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 .... 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 |
for (i = 1; i <= rows; i++) count = atoi (results[(i * columns) + 0]); } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static sqlite3 * open_db (const char *path, const char *table, int double_arcs, int cache_size, ................................................................................ fprintf (out, "# SpeedClass:yet_anotherclass_3:3.0\n\n\n"); } fclose (out); return 1; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_net: %s\n", VERSION); fprintf (stderr, "target CPU .......: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ....: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .......: %s\n", sqlite3_libversion ()); fprintf (stderr, "libreadosm .......: %s\n", readosm_version ()); fprintf (stderr, "libexpat .........: %s\n", readosm_expat_version ()); fprintf (stderr, "zlib .............: %s\n", readosm_zlib_version ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_net ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
| | < < < < < < < < < < < < < < < < < < < < < < < |
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 .... 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 .... 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 |
for (i = 1; i <= rows; i++) count = atoi (results[(i * columns) + 0]); } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static sqlite3 * open_db (const char *path, const char *table, int double_arcs, int cache_size, ................................................................................ fprintf (out, "# SpeedClass:yet_anotherclass_3:3.0\n\n\n"); } fclose (out); return 1; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_net ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-XML file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
Changes to spatialite_osm_overpass.c.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 .... 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 .... 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 .... 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 .... 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 .... 4622 4623 4624 4625 4626 4627 4628 4629 4630 |
*/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <float.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef ENABLE_LIBXML2 /* only if LIBXML2 is enabled */ #include <libxml/parser.h> #include <libxml/nanohttp.h> #include <sqlite3.h> #include <spatialite/gaiageo.h> #include <spatialite.h> ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static int create_road_tables (struct aux_params *params) ................................................................................ *miny = *maxy; *maxy = save; ret = 0; } return ret; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_overpass: %s\n", VERSION); fprintf (stderr, "target CPU ............: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite .........: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ............: %s\n", sqlite3_libversion ()); fprintf (stderr, "libxml2 ...............: %s\n", LIBXML_DOTTED_VERSION); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_overpass ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); fprintf (stderr, "-minx or --bbox-minx coord BoundingBox - west longitude\n"); fprintf (stderr, "-maxx or --bbox-maxx coord BoundingBox - east longitude\n"); fprintf (stderr, ................................................................................ "-m or --in-memory using IN-MEMORY database\n"); fprintf (stderr, "-jo or --journal-off unsafe [but faster] mode\n"); fprintf (stderr, "-p or --preserve skipping final cleanup (preserving OSM tables)\n"); } #endif /* end LIBXML2 conditional */ int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ #ifndef ENABLE_LIBXML2 /* only if LIBXML2 is disabled */ fprintf (stderr, "\nthis copy of \"spatialite_osm_overpass\"\n" "was built by disabling LIBXML2 support.\n" "Sorry, cowardly quitting ...\n"); return 0; #else sqlite3 *handle; int i; int next_arg = ARG_NONE; const char *osm_url = "http://overpass-api.de/api"; const char *db_path = NULL; int in_memory = 0; int cache_size = 0; ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { ................................................................................ /* closing the DB connection */ sqlite3_close (handle); spatialite_cleanup_ex (cache); spatialite_shutdown (); downloader_cleanup (&downloader); return 0; #endif /* end LIBXML2 conditional */ } |
< < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
25 26 27 28 29 30 31 32 33 34 35 36 37 38 .... 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 .... 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 .... 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 .... 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 .... 4584 4585 4586 4587 4588 4589 4590 4591 |
*/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <float.h> #include <libxml/parser.h> #include <libxml/nanohttp.h> #include <sqlite3.h> #include <spatialite/gaiageo.h> #include <spatialite.h> ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static int create_road_tables (struct aux_params *params) ................................................................................ *miny = *maxy; *maxy = save; ret = 0; } return ret; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_overpass ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n"); fprintf (stderr, "-minx or --bbox-minx coord BoundingBox - west longitude\n"); fprintf (stderr, "-maxx or --bbox-maxx coord BoundingBox - east longitude\n"); fprintf (stderr, ................................................................................ "-m or --in-memory using IN-MEMORY database\n"); fprintf (stderr, "-jo or --journal-off unsafe [but faster] mode\n"); fprintf (stderr, "-p or --preserve skipping final cleanup (preserving OSM tables)\n"); } int main (int argc, char *argv[]) { /* the MAIN function simply perform arguments checking */ sqlite3 *handle; int i; int next_arg = ARG_NONE; const char *osm_url = "http://overpass-api.de/api"; const char *db_path = NULL; int in_memory = 0; int cache_size = 0; ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { ................................................................................ /* closing the DB connection */ sqlite3_close (handle); spatialite_cleanup_ex (cache); spatialite_shutdown (); downloader_cleanup (&downloader); return 0; } |
Changes to spatialite_osm_raw.c.
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 ... 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 .... 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache) ................................................................................ sqlite3_close (db_handle); fprintf (stderr, "DB '%s'\n", path); fprintf (stderr, "doesn't seems to contain valid Spatial Metadata ...\n\n"); fprintf (stderr, "Please, initialize Spatial Metadata\n\n"); return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_raw: %s\n", VERSION); fprintf (stderr, "target CPU .......: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ....: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .......: %s\n", sqlite3_libversion ()); fprintf (stderr, "libreadosm .......: %s\n", readosm_version ()); fprintf (stderr, "libexpat .........: %s\n", readosm_expat_version ()); fprintf (stderr, "zlib .............: %s\n", readosm_zlib_version ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_raw ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
| | < < < < < < < < < < < < < < < < < < < < < < < |
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 ... 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 .... 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache) ................................................................................ sqlite3_close (db_handle); fprintf (stderr, "DB '%s'\n", path); fprintf (stderr, "doesn't seems to contain valid Spatial Metadata ...\n\n"); fprintf (stderr, "Please, initialize Spatial Metadata\n\n"); return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_osm_raw ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-o or --osm-path pathname the OSM-file path\n"); fprintf (stderr, " both OSM-XML (*.osm) and OSM-ProtoBuf\n"); fprintf (stderr, " (*.osm.pbf) are indifferently supported.\n\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-o") == 0) { next_arg = ARG_OSM_PATH; continue; } if (strcasecmp (argv[i], "--osm-path") == 0) { |
Changes to spatialite_tool.c.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 ... 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 ... 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_import_dbf (char *db_path, char *dbf_path, char *table, char *charset) ................................................................................ ret = sqlite3_close (handle); if (ret != SQLITE_OK) fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "exif_loader .: %s\n", VERSION); fprintf (stderr, "target CPU ..: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ..: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatitalite_tool CMD ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "CMD has to be one of the followings:\n"); fprintf (stderr, "------------------------------------\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-i or --import import [CSV/TXT, DBF or SHP]\n"); fprintf (stderr, "-e or --export-shp exporting some shapefile\n"); fprintf (stderr, "\nsupported ARGs are:\n"); fprintf (stderr, "-------------------\n"); fprintf (stderr, "-dbf or --dbf-path pathname the full DBF path\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcasecmp (argv[i], "--shapefile") == 0) { next_arg = ARG_SHP; in_shp = 1; continue; } if (strcmp (argv[i], "-shp") == 0) |
| | < < < < < < < < < < < < < < < < < < < < |
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 ... 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 ... 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
} sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void do_import_dbf (char *db_path, char *dbf_path, char *table, char *charset) ................................................................................ ret = sqlite3_close (handle); if (ret != SQLITE_OK) fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (handle)); spatialite_cleanup_ex (cache); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatitalite_tool CMD ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "CMD has to be one of the followings:\n"); fprintf (stderr, "------------------------------------\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-i or --import import [CSV/TXT, DBF or SHP]\n"); fprintf (stderr, "-e or --export-shp exporting some shapefile\n"); fprintf (stderr, "\nsupported ARGs are:\n"); fprintf (stderr, "-------------------\n"); fprintf (stderr, "-dbf or --dbf-path pathname the full DBF path\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--shapefile") == 0) { next_arg = ARG_SHP; in_shp = 1; continue; } if (strcmp (argv[i], "-shp") == 0) |
Deleted spatialite_xml2utf8.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
/* / spatialite_xml2utf8 / / a tool converting the charset encoding for any XML as UTF-8 / / version 1.0, 2017 August 25 / / Author: Sandro Furieri a.furieri@lqt.it / / Copyright (C) 2017 Alessandro Furieri / / This program is free software: you can redistribute it and/or modify / it under the terms of the GNU General Public License as published by / the Free Software Foundation, either version 3 of the License, or / (at your option) any later version. / / This program is distributed in the hope that it will be useful, / but WITHOUT ANY WARRANTY; without even the implied warranty of / MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / GNU General Public License for more details. / / You should have received a copy of the GNU General Public License / along with this program. If not, see <http://www.gnu.org/licenses/>. / */ #include <stdlib.h> #include <stdio.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #if defined(__MINGW32__) || defined(_WIN32) #define LIBICONV_STATIC #include <iconv.h> #define LIBCHARSET_STATIC #ifdef _MSC_VER /* <localcharset.h> isn't supported on OSGeo4W */ /* applying a tricky workaround to fix this issue */ extern const char *locale_charset (void); #else /* sane Windows - not OSGeo4W */ #include <localcharset.h> #endif /* end localcharset */ #else /* not MINGW32 - WIN32 */ #if defined(__APPLE__) || defined(__ANDROID__) #include <iconv.h> #include <localcharset.h> #else /* neither Mac OsX nor Android */ #include <iconv.h> #include <langinfo.h> #endif #endif static void do_convert (iconv_t cvt, char *in, char *out, size_t i_len) { size_t i; size_t max_len = i_len * 4; size_t o_len = max_len; char *p_in = in; char *p_out = out; if (iconv (cvt, &p_in, &i_len, &p_out, &o_len) == (size_t) (-1)) { fprintf (stderr, "invalid character sequence !!!\n"); return; } for (i = 0; i < max_len - o_len; i++) putchar (out[i]); putchar ('\n'); } int main (int argc, const char *argv[]) { int lineno = 0; size_t count; char *out = malloc (1024 * 1024); char *in = malloc (1024 * 1924); char *p_in; iconv_t cvt; const char *charset = NULL; if (argc != 2) { fprintf (stderr, "usage: spatialite_utf8 input-charset <input >output\n"); return -1; } charset = argv[1]; cvt = iconv_open ("UTF-8", charset); if (cvt == (iconv_t) (-1)) { fprintf (stderr, "Unknown charset: %s\n", charset); goto stop; } count = 0; p_in = in; while (1) { int c = getchar (); if (c == EOF || c == '\n') { if (lineno > 0) do_convert (cvt, in, out, count); else printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); if (c == EOF) break; lineno++; count = 0; p_in = in; continue; } *p_in++ = c; count++; } iconv_close (cvt); stop: return 0; } |
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to spatialite_xml_collapse.c.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 .... 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 .... 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 .... 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 |
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sqlite3.h> #include <spatialite.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #define ARG_NONE 0 #define ARG_DB_PATH 1 #define ARG_CACHE_SIZE 2 #define ARG_NAME_LEVEL 3 struct resultset_values { ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static int check_xml_metacatalog (sqlite3 * db_handle) ................................................................................ /* enabling PK/FK constraints */ sqlite3_exec (db_handle, "PRAGMA foreign_keys = 1", NULL, NULL, NULL); *handle = db_handle; return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_osm_overpass: %s\n", VERSION); fprintf (stderr, "target CPU ............: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite .........: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 ............: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_xml_collapse ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "-dd or --delete-duplicates remove all duplicate rows except one\n"); fprintf (stderr, "-nl or --nl-level num tree-level for table-names (dft: 0)\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { |
< < < < < < | | < < < < < < < < < < < < < < < < < < < < |
42 43 44 45 46 47 48 49 50 51 52 53 54 55 .... 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 .... 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 .... 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 |
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sqlite3.h> #include <spatialite.h> #define ARG_NONE 0 #define ARG_DB_PATH 1 #define ARG_CACHE_SIZE 2 #define ARG_NAME_LEVEL 3 struct resultset_values { ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadata(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static int check_xml_metacatalog (sqlite3 * db_handle) ................................................................................ /* enabling PK/FK constraints */ sqlite3_exec (db_handle, "PRAGMA foreign_keys = 1", NULL, NULL, NULL); *handle = db_handle; return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_xml_collapse ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB path\n\n"); fprintf (stderr, "you can specify the following options as well\n"); fprintf (stderr, "-dd or --delete-duplicates remove all duplicate rows except one\n"); fprintf (stderr, "-nl or --nl-level num tree-level for table-names (dft: 0)\n\n"); ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-d") == 0) { next_arg = ARG_DB_PATH; continue; } if (strcasecmp (argv[i], "--db-path") == 0) { |
Changes to spatialite_xml_load.c.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
....
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
|
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <libgen.h> #include <expat.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite.h> ................................................................................ } sqlite3_free_table (results); if (count > 0) return; /* all right, it's empty: proceding to initialize */ strcpy (sql, "SELECT InitSpatialMetadataFull(1)"); ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg); if (ret != SQLITE_OK) { fprintf (stderr, "InitSpatialMetadataFull() error: %s\n", err_msg); sqlite3_free (err_msg); return; } } static void open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache) |
<
<
<
<
|
|
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
....
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include <expat.h>
#include "config.h"
#ifdef SPATIALITE_AMALGAMATION
#include <spatialite/sqlite3.h>
#else
#include <sqlite3.h>
#endif
#include <spatialite.h>
................................................................................
}
sqlite3_free_table (results);
if (count > 0)
return;
/* all right, it's empty: proceding to initialize */
strcpy (sql, "SELECT InitSpatialMetadata(1)");
ret = sqlite3_exec (db, sql, NULL, NULL, &err_msg);
if (ret != SQLITE_OK)
{
fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
sqlite3_free (err_msg);
return;
}
}
static void
open_db (const char *path, sqlite3 ** handle, int cache_size, void *cache)
|
Changes to spatialite_xml_print.c.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 ... 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 ... 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite.h> ................................................................................ /* enabling PK/FK constraints */ sqlite3_exec (db_handle, "PRAGMA foreign_keys = 1", NULL, NULL, NULL); *handle = db_handle; return; } static void do_version () { /* printing version infos */ fprintf( stderr, "\nVersion infos\n"); fprintf( stderr, "===========================================\n"); fprintf (stderr, "spatialite_xml_print: %s\n", VERSION); fprintf (stderr, "target CPU .........: %s\n", spatialite_target_cpu ()); fprintf (stderr, "libspatialite ......: %s\n", spatialite_version ()); fprintf (stderr, "libsqlite3 .........: %s\n", sqlite3_libversion ()); fprintf (stderr, "\n"); } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_xml_printf ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-v or --version print version infos\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB [INPUT] path\n\n"); fprintf (stderr, "-x or --xml-path pathname the XML file [OUTPUT] path\n"); fprintf (stderr, "-cs or --cache-size num DB cache size (how many pages)\n"); fprintf (stderr, ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcasecmp (argv[i], "--version") == 0 || strcmp (argv[i], "-v") == 0) { do_version (); return -1; } if (strcmp (argv[i], "-x") == 0) { next_arg = ARG_XML_PATH; continue; } if (strcasecmp (argv[i], "--xml-path") == 0) { |
< < < < < < < < < < < < < < < < < < < < < < < < |
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ... 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 ... 979 980 981 982 983 984 985 986 987 988 989 990 991 992 |
#include <sys/types.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include "config.h" #ifdef SPATIALITE_AMALGAMATION #include <spatialite/sqlite3.h> #else #include <sqlite3.h> #endif #include <spatialite.h> ................................................................................ /* enabling PK/FK constraints */ sqlite3_exec (db_handle, "PRAGMA foreign_keys = 1", NULL, NULL, NULL); *handle = db_handle; return; } static void do_help () { /* printing the argument list */ fprintf (stderr, "\n\nusage: spatialite_xml_printf ARGLIST\n"); fprintf (stderr, "==============================================================\n"); fprintf (stderr, "-h or --help print this help message\n"); fprintf (stderr, "-d or --db-path pathname the SpatiaLite DB [INPUT] path\n\n"); fprintf (stderr, "-x or --xml-path pathname the XML file [OUTPUT] path\n"); fprintf (stderr, "-cs or --cache-size num DB cache size (how many pages)\n"); fprintf (stderr, ................................................................................ } if (strcasecmp (argv[i], "--help") == 0 || strcmp (argv[i], "-h") == 0) { do_help (); return -1; } if (strcmp (argv[i], "-x") == 0) { next_arg = ARG_XML_PATH; continue; } if (strcasecmp (argv[i], "--xml-path") == 0) { |
Changes to spatialite_xml_validator.c.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 ... 726 727 728 729 730 731 732 733 734 |
/ */ #include <stdlib.h> #include <stdio.h> #include <string.h> #if defined(_WIN32) && !defined(__MINGW32__) #include "config-msvc.h" #else #include "config.h" #endif #ifdef ENABLE_LIBXML2 /* only if LIBXML2 is enabled */ #include <libxml/parser.h> #include <libxml/xmlschemas.h> #include <libxml/xpath.h> #include <libxml/xpathInternals.h> struct list_item ................................................................................ xmlFreeDoc (xml_doc); if (schemaURI != NULL) free (schemaURI); fprintf (stderr, "ERROR - invalid XML: %s\n\n", path); return 0; } #endif /* end LIBXML2 conditional */ int main (int argc, char *argv[]) { /* the MAIN function mainly perform arguments checking */ #ifndef ENABLE_LIBXML2 /* only if LIBXML2 is disabled */ fprintf (stderr, "\nthis copy of \"spatialite_xml_validator\"\n" "was built by disabling LIBXML2 support.\n" "Sorry, cowardly quitting ...\n"); return 0; #else const char *xml_path = NULL; const char *list_path = NULL; int single = 0; int list = 0; int err = 1; int valids = 0; int invalids = 0; ................................................................................ cache_cleanup (&cache); xmlCleanupParser (); return 0; error: cache_cleanup (&cache); xmlCleanupParser (); return -1; #endif /* end LIBXML2 conditional */ } |
< < < < < < < < < < < < < < < < |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 ... 711 712 713 714 715 716 717 718 |
/ */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "config.h" #include <libxml/parser.h> #include <libxml/xmlschemas.h> #include <libxml/xpath.h> #include <libxml/xpathInternals.h> struct list_item ................................................................................ xmlFreeDoc (xml_doc); if (schemaURI != NULL) free (schemaURI); fprintf (stderr, "ERROR - invalid XML: %s\n\n", path); return 0; } int main (int argc, char *argv[]) { /* the MAIN function mainly perform arguments checking */ const char *xml_path = NULL; const char *list_path = NULL; int single = 0; int list = 0; int err = 1; int valids = 0; int invalids = 0; ................................................................................ cache_cleanup (&cache); xmlCleanupParser (); return 0; error: cache_cleanup (&cache); xmlCleanupParser (); return -1; } |