69 #ifdef SHPAPI_UTF8_HOOKS 70 # ifdef SHPAPI_WINDOWS 71 # define WIN32_LEAN_AND_MEAN 74 # pragma comment(lib, "kernel32.lib") 87 void SADError(
const char *message );
97 return (
SAFile) fopen( pszFilename, pszAccess );
107 return (
SAOffset) fread( p, (
size_t) size, (
size_t) nmemb,
118 if (!nmemb || !p)
return 0;
119 return (
SAOffset) fwrite( p, (
size_t) size, (
size_t) nmemb,
131 return (
SAOffset) fseeko( (FILE *) file, (off_t) offset, whence );
133 return (
SAOffset) fseek( (FILE *) file, (
long) offset, whence );
145 return (
SAOffset) ftello( (FILE *) file );
147 return (
SAOffset) ftell( (FILE *) file );
158 return fflush( (FILE *) file );
168 return fclose( (FILE *) file );
178 return remove( filename );
188 fprintf( stderr,
"%s\n", message );
208 psHooks->
Atof = atof;
214 #ifdef SHPAPI_WINDOWS 220 const wchar_t* Utf8ToWideChar(
const char *pszFilename )
223 wchar_t *pwszFileName;
225 nMulti = strlen(pszFilename) + 1;
226 nWide = MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, 0, 0);
231 pwszFileName = (
wchar_t*)
malloc(nWide *
sizeof(
wchar_t));
232 if ( pwszFileName == NULL )
236 if( MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, pwszFileName, nWide ) == 0 )
238 free( pwszFileName );
248 SAFile SAUtf8WFOpen(
const char *pszFilename,
const char *pszAccess )
251 const wchar_t *pwszFileName, *pwszAccess;
252 pwszFileName = Utf8ToWideChar( pszFilename );
253 pwszAccess = Utf8ToWideChar( pszAccess );
254 if( pwszFileName != NULL && pwszFileName != NULL)
256 file = (
SAFile) _wfopen( pwszFileName, pwszAccess );
258 free ((
wchar_t*) pwszFileName);
259 free ((
wchar_t*) pwszAccess);
267 int SAUtf8WRemove(
const char *pszFilename )
269 const wchar_t *pwszFileName = Utf8ToWideChar( pszFilename );
271 if( pwszFileName != NULL )
273 rc = _wremove( pwszFileName );
275 free ((
wchar_t*) pwszFileName);
281 #ifdef SHPAPI_UTF8_HOOKS 287 void SASetupUtf8Hooks(
SAHooks *psHooks )
289 #ifdef SHPAPI_WINDOWS 290 psHooks->
FOpen = SAUtf8WFOpen;
291 psHooks->
Remove = SAUtf8WRemove;
293 # error "no implementations of UTF-8 hooks available for this platform" 303 psHooks->
Atof = atof;
SAFile SADFOpen(const char *pszFilename, const char *pszAccess)
SAOffset SADFTell(SAFile file)
SAOffset(* FTell)(SAFile file)
int(* FFlush)(SAFile file)
SAOffset SADFSeek(SAFile file, SAOffset offset, int whence)
int(* FClose)(SAFile file)
void SADError(const char *message)
#define SHP_CVSID(string)
SAOffset SADFWrite(void *p, SAOffset size, SAOffset nmemb, SAFile file)
int SADFFlush(SAFile file)
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
int SADFClose(SAFile file)
int(* Remove)(const char *filename)
int SADRemove(const char *filename)
double(* Atof)(const char *str)
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)
SAFile(* FOpen)(const char *filename, const char *access)
void(* Error)(const char *message)
SAOffset(* FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset SADFRead(void *p, SAOffset size, SAOffset nmemb, SAFile file)
void SASetupDefaultHooks(SAHooks *psHooks)