32
32
* Created.
33
33
*
34
34
*/
35
+ #ifndef _WIN32
36
+ #define _GNU_SOURCE
37
+ #endif
35
38
36
39
#define _CRT_SECURE_NO_WARNINGS 1
37
40
43
46
44
47
#ifdef USE_MSSQL2008
45
48
49
+ #ifdef _WIN32
46
50
#include <windows.h>
51
+ #endif
47
52
#include <sql.h>
48
53
#include <sqlext.h>
49
54
#include <sqltypes.h>
@@ -478,7 +483,7 @@ int ParseSqlGeometry(msMSSQL2008LayerInfo* layerinfo, shapeObj *shape)
478
483
ReadPoint (gpi , & shape -> line [0 ].point [0 ], 0 );
479
484
ReadPoint (gpi , & shape -> line [0 ].point [1 ], 1 );
480
485
} else {
481
- int iShape , iFigure , iSegment ;
486
+ int iShape , iFigure , iSegment = 0 ;
482
487
// complex geometries
483
488
gpi -> nNumPoints = ReadInt32 (6 );
484
489
@@ -658,33 +663,6 @@ void handleSQLError(layerObj *layer)
658
663
}
659
664
}
660
665
661
- /* remove white space */
662
- /* dont send in empty strings or strings with just " " in them! */
663
- static char * removeWhite (char * str )
664
- {
665
- size_t initial ;
666
- char * orig , * loc ;
667
-
668
- initial = strspn (str , " " );
669
- if (initial ) {
670
- memmove (str , str + initial , strlen (str ) - initial + 1 );
671
- }
672
- /* now final */
673
- if (strlen (str ) == 0 ) {
674
- return str ;
675
- }
676
- if (str [strlen (str ) - 1 ] == ' ' ) {
677
- /* have to remove from end */
678
- orig = str ;
679
- loc = & str [strlen (str ) - 1 ];
680
- while ((* loc = ' ' ) && (loc > orig )) {
681
- * loc = 0 ;
682
- loc -- ;
683
- }
684
- }
685
- return str ;
686
- }
687
-
688
666
/* TODO Take a look at glibc's strcasestr */
689
667
static char * strstrIgnoreCase (const char * haystack , const char * needle )
690
668
{
@@ -785,7 +763,7 @@ static msODBCconn * mssql2008Connect(char * connString)
785
763
}
786
764
else
787
765
{
788
- rc = SQLDriverConnect (conn -> hdbc , NULL , connString , SQL_NTS , outConnString , 1024 , & outConnStringLen , SQL_DRIVER_NOPROMPT );
766
+ rc = SQLDriverConnect (conn -> hdbc , NULL , ( SQLCHAR * ) connString , SQL_NTS , outConnString , 1024 , & outConnStringLen , SQL_DRIVER_NOPROMPT );
789
767
}
790
768
791
769
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
@@ -837,7 +815,6 @@ static int columnName(msODBCconn *conn, int index, char *buffer, int bufferLengt
837
815
SQLULEN columnSize ;
838
816
SQLSMALLINT decimalDigits ;
839
817
SQLSMALLINT nullable ;
840
- msMSSQL2008LayerInfo * layerinfo = getMSSQL2008LayerInfo (layer );
841
818
842
819
rc = SQLDescribeCol (
843
820
conn -> hstmt ,
@@ -1612,7 +1589,7 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
1612
1589
layerinfo -> itemtypes = msSmallMalloc (sizeof (SQLSMALLINT ) * (layer -> numitems + 1 ));
1613
1590
for (t = 0 ; t < layer -> numitems ; t ++ ) {
1614
1591
char colBuff [256 ];
1615
- SQLSMALLINT itemType ;
1592
+ SQLSMALLINT itemType = 0 ;
1616
1593
1617
1594
columnName (layerinfo -> conn , t + 1 , colBuff , sizeof (colBuff ), layer , pass_field_def , & itemType );
1618
1595
layerinfo -> itemtypes [t ] = itemType ;
@@ -1769,7 +1746,6 @@ static int force_to_points(char *wkb, shapeObj *shape)
1769
1746
/* we're going to make a 'line' for each entity (point, line or ring) in the geom collection */
1770
1747
1771
1748
int offset = 0 ;
1772
- int pt_offset ;
1773
1749
int ngeoms ;
1774
1750
int t , u , v ;
1775
1751
int type , nrings , npoints ;
@@ -1812,7 +1788,6 @@ static int force_to_points(char *wkb, shapeObj *shape)
1812
1788
1813
1789
memcpy (& nrings , & wkb [offset + 5 ],4 ); /* num rings */
1814
1790
/* add a line for each polygon ring */
1815
- pt_offset = 0 ;
1816
1791
offset += 9 ; /* now points at 1st linear ring */
1817
1792
for (u = 0 ; u < nrings ; u ++ ) {
1818
1793
/* for each ring, make a line */
@@ -1844,7 +1819,6 @@ static int force_to_points(char *wkb, shapeObj *shape)
1844
1819
static int force_to_lines (char * wkb , shapeObj * shape )
1845
1820
{
1846
1821
int offset = 0 ;
1847
- int pt_offset ;
1848
1822
int ngeoms ;
1849
1823
int t , u , v ;
1850
1824
int type , nrings , npoints ;
@@ -1878,7 +1852,6 @@ static int force_to_lines(char *wkb, shapeObj *shape)
1878
1852
1879
1853
memcpy (& nrings , & wkb [offset + 5 ], 4 ); /* num rings */
1880
1854
/* add a line for each polygon ring */
1881
- pt_offset = 0 ;
1882
1855
offset += 9 ; /* now points at 1st linear ring */
1883
1856
for (u = 0 ; u < nrings ; u ++ ) {
1884
1857
/* for each ring, make a line */
@@ -1907,7 +1880,6 @@ static int force_to_lines(char *wkb, shapeObj *shape)
1907
1880
static int force_to_polygons (char * wkb , shapeObj * shape )
1908
1881
{
1909
1882
int offset = 0 ;
1910
- int pt_offset ;
1911
1883
int ngeoms ;
1912
1884
int t , u , v ;
1913
1885
int type , nrings , npoints ;
@@ -1926,7 +1898,6 @@ static int force_to_polygons(char *wkb, shapeObj *shape)
1926
1898
1927
1899
memcpy (& nrings , & wkb [offset + 5 ], 4 ); /* num rings */
1928
1900
/* add a line for each polygon ring */
1929
- pt_offset = 0 ;
1930
1901
offset += 9 ; /* now points at 1st linear ring */
1931
1902
for (u = 0 ; u < nrings ; u ++ ) {
1932
1903
/* for each ring, make a line */
@@ -1988,6 +1959,7 @@ static int dont_force(char *wkb, shapeObj *shape)
1988
1959
return MS_FAILURE ; /* unknown type */
1989
1960
}
1990
1961
1962
+ #if 0
1991
1963
/* ******************************************************* */
1992
1964
/* wkb assumed to be same endian as this machine. */
1993
1965
/* Should be in little endian (default if created by Microsoft platforms) */
@@ -2079,6 +2051,7 @@ static int force_to_shapeType(char *wkb, shapeObj *shape, int msShapeType)
2079
2051
2080
2052
return MS_SUCCESS ;
2081
2053
}
2054
+ #endif
2082
2055
2083
2056
///* if there is any polygon in wkb, return force_polygon */
2084
2057
///* if there is any line in wkb, return force_line */
@@ -2187,7 +2160,6 @@ static void find_bounds(shapeObj *shape)
2187
2160
int msMSSQL2008LayerGetShapeRandom (layerObj * layer , shapeObj * shape , long * record )
2188
2161
{
2189
2162
msMSSQL2008LayerInfo * layerinfo ;
2190
- int result ;
2191
2163
SQLLEN needLen = 0 ;
2192
2164
SQLLEN retLen = 0 ;
2193
2165
char dummyBuffer [1 ];
@@ -2309,6 +2281,9 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor
2309
2281
case MS_LAYER_POLYGON :
2310
2282
shape -> type = MS_SHAPE_POLYGON ;
2311
2283
break ;
2284
+
2285
+ default :
2286
+ break ;
2312
2287
}
2313
2288
}
2314
2289
} else {
@@ -2335,20 +2310,20 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor
2335
2310
2336
2311
switch (layer -> type ) {
2337
2312
case MS_LAYER_POINT :
2338
- result = force_to_points (wkbBuffer , shape );
2313
+ /* result =*/ force_to_points (wkbBuffer , shape );
2339
2314
break ;
2340
2315
2341
2316
case MS_LAYER_LINE :
2342
- result = force_to_lines (wkbBuffer , shape );
2317
+ /* result =*/ force_to_lines (wkbBuffer , shape );
2343
2318
break ;
2344
2319
2345
2320
case MS_LAYER_POLYGON :
2346
- result = force_to_polygons (wkbBuffer , shape );
2321
+ /* result =*/ force_to_polygons (wkbBuffer , shape );
2347
2322
break ;
2348
2323
2349
2324
case MS_LAYER_QUERY :
2350
2325
case MS_LAYER_CHART :
2351
- result = dont_force (wkbBuffer , shape );
2326
+ /* result =*/ dont_force (wkbBuffer , shape );
2352
2327
break ;
2353
2328
2354
2329
case MS_LAYER_RASTER :
@@ -2394,7 +2369,7 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor
2394
2369
if (shape -> type != MS_SHAPE_NULL ) {
2395
2370
return MS_SUCCESS ;
2396
2371
} else {
2397
- msDebug ("msMSSQL2008LayerGetShapeRandom bad shape: %d \n" , * record );
2372
+ msDebug ("msMSSQL2008LayerGetShapeRandom bad shape: %ld \n" , * record );
2398
2373
}
2399
2374
/* if (layer->type == MS_LAYER_POINT) {return MS_DONE;} */
2400
2375
}
@@ -2441,7 +2416,7 @@ int msMSSQL2008LayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record
2441
2416
long resultindex = record -> resultindex ;
2442
2417
2443
2418
if (layer -> debug ) {
2444
- msDebug ("msMSSQL2008LayerGetShape called for shapeindex = %i \n" , shapeindex );
2419
+ msDebug ("msMSSQL2008LayerGetShape called for shapeindex = %ld \n" , shapeindex );
2445
2420
}
2446
2421
2447
2422
layerinfo = getMSSQL2008LayerInfo (layer );
@@ -2495,7 +2470,7 @@ int msMSSQL2008LayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record
2495
2470
}
2496
2471
2497
2472
/* index_name is ignored here since the hint should be for the spatial index, not the PK index */
2498
- snprintf (buffer , sizeof (buffer ), "select %s from %s where %s = %d " , columns_wanted , layerinfo -> geom_table , layerinfo -> urid_name , shapeindex );
2473
+ snprintf (buffer , sizeof (buffer ), "select %s from %s where %s = %ld " , columns_wanted , layerinfo -> geom_table , layerinfo -> urid_name , shapeindex );
2499
2474
2500
2475
query_str = msStrdup (buffer );
2501
2476
@@ -2722,7 +2697,7 @@ int msMSSQL2008LayerGetItems(layerObj *layer)
2722
2697
2723
2698
for (t = 0 ; t < cols ; t ++ ) {
2724
2699
char colBuff [256 ];
2725
- SQLSMALLINT itemType ;
2700
+ SQLSMALLINT itemType = 0 ;
2726
2701
2727
2702
columnName (layerinfo -> conn , t + 1 , colBuff , sizeof (colBuff ), layer , pass_field_def , & itemType );
2728
2703
@@ -2786,7 +2761,7 @@ int msMSSQL2008LayerRetrievePK(layerObj *layer, char **urid_name, char* table_na
2786
2761
tmp2 = (char * )msSmallMalloc (sizeof (char )* (strlen (tmp1 ) + strlen (sql ) + 1 ));
2787
2762
strcpy (tmp2 , tmp1 );
2788
2763
strcat (tmp2 , sql );
2789
- msSetError (MS_QUERYERR , tmp2 , "msMSSQL2008LayerRetrievePK()" );
2764
+ msSetError (MS_QUERYERR , "%s" , "msMSSQL2008LayerRetrievePK()" , tmp2 );
2790
2765
msFree (tmp2 );
2791
2766
return (MS_FAILURE );
2792
2767
}
0 commit comments