Use correct format for c strings
Remove unnecessary argument cast
Remove use of deprecated spatialite functions

Use *_ex threadsafe functions instead.