diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-01-09 20:25:11 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-01-09 20:25:11 +0000 |
commit | 512fabd3e06c4b32b948d03325acf9130e4735b5 (patch) | |
tree | 5db6f537e77055e83a3db4553f901281e5463a5c | |
parent | f0ca7c43e44e1f3ed58f1fef02c35fd8f972d60a (diff) | |
download | navit-512fabd3e06c4b32b948d03325acf9130e4735b5.tar.gz |
Fix:Core:Defined LONGLONG_FMT for android
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3900 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/attr.c | 3 | ||||
-rw-r--r-- | navit/file.c | 14 | ||||
-rw-r--r-- | navit/file.h | 1 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal.c | 9 | ||||
-rw-r--r-- | navit/map/binfile/binfile.c | 20 | ||||
-rw-r--r-- | navit/types.h | 11 |
6 files changed, 45 insertions, 13 deletions
diff --git a/navit/attr.c b/navit/attr.c index 13e1f0351..21c876631 100644 --- a/navit/attr.c +++ b/navit/attr.c @@ -31,6 +31,7 @@ #include "config.h" #include "endianess.h" #include "util.h" +#include "types.h" struct attr_name { enum attr_type attr; @@ -287,7 +288,7 @@ attr_to_text(struct attr *attr, struct map *map, int pretty) if (type >= attr_type_int_begin && type <= attr_type_int_end) return g_strdup_printf("%d", attr->u.num); if (type >= attr_type_int64_begin && type <= attr_type_int64_end) - return g_strdup_printf("%Ld", *attr->u.num64); + return g_strdup_printf(LONGLONG_FMT, *attr->u.num64); if (type >= attr_type_double_begin && type <= attr_type_double_end) return g_strdup_printf("%f", *attr->u.numd); if (type >= attr_type_object_begin && type <= attr_type_object_end) diff --git a/navit/file.c b/navit/file.c index 9096a0f5b..e6da9d5bd 100644 --- a/navit/file.c +++ b/navit/file.c @@ -38,6 +38,7 @@ #include "config.h" #include "item.h" #include "util.h" +#include "types.h" #ifdef HAVE_SOCKET #include <sys/socket.h> #include <netdb.h> @@ -228,7 +229,7 @@ file_create(char *name, struct attr **options) dbg(1,"fd=%d\n", file->fd); fstat(file->fd, &stat); file->size=stat.st_size; - dbg(1,"size=%Ld\n", file->size); + dbg(1,"size="LONGLONG_FMT"\n", file->size); file->name_id = (int)atom(name); } #ifdef CACHE_SIZE @@ -434,13 +435,20 @@ file_data_read_all(struct file *file) return file_data_read(file, 0, file->size); } -int -file_data_write(struct file *file, long long offset, int size, unsigned char *data) +void +file_data_flush(struct file *file, long long offset, int size) { if (file_cache) { struct file_cache_id id={offset,size,file->name_id,0}; cache_flush(file_cache,&id); + dbg(1,"Flushing "LONGLONG_FMT" %d bytes\n",offset,size); } +} + +int +file_data_write(struct file *file, long long offset, int size, unsigned char *data) +{ + file_data_flush(file, offset, size); lseek(file->fd, offset, SEEK_SET); if (write(file->fd, data, size) != size) return 0; diff --git a/navit/file.h b/navit/file.h index 6a037fa5a..ad186a4d0 100644 --- a/navit/file.h +++ b/navit/file.h @@ -70,6 +70,7 @@ int file_mmap(struct file *file); unsigned char *file_data_read(struct file *file, long long offset, int size); unsigned char *file_data_read_special(struct file *file, int size, int *size_ret); unsigned char *file_data_read_all(struct file *file); +void file_data_flush(struct file *file, long long offset, int size); int file_data_write(struct file *file, long long offset, int size, unsigned char *data); int file_get_contents(char *name, unsigned char **buffer, int *size); unsigned char *file_data_read_compressed(struct file *file, long long offset, int size, int size_uncomp); diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c index 676d103d8..154beba27 100644 --- a/navit/gui/internal/gui_internal.c +++ b/navit/gui/internal/gui_internal.c @@ -72,6 +72,7 @@ #include "bookmarks.h" #include "debug.h" #include "fib.h" +#include "types.h" extern char *version; @@ -2572,13 +2573,13 @@ gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm url=NULL; switch (attr.type) { case attr_osm_nodeid: - url=g_strdup_printf("http://www.openstreetmap.org/browse/node/%Ld\n",*attr.u.num64); + url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64); break; case attr_osm_wayid: - url=g_strdup_printf("http://www.openstreetmap.org/browse/way/%Ld\n",*attr.u.num64); + url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64); break; case attr_osm_relationid: - url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/%Ld\n",*attr.u.num64); + url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64); break; default: break; @@ -6293,7 +6294,7 @@ gui_internal_cmd_map_downloader(struct gui_priv *this, char *function, struct at break; } downloaded+=size; - dbg(0,"%Ld of %Ld\n",downloaded,f->size); + dbg(0,LONGLONG_FMT" of "LONGLONG_FMT"\n",downloaded,f->size); } g_free(data); if (!size) diff --git a/navit/map/binfile/binfile.c b/navit/map/binfile/binfile.c index 7bf0c93c5..5f7b55d0f 100644 --- a/navit/map/binfile/binfile.c +++ b/navit/map/binfile/binfile.c @@ -37,6 +37,7 @@ #include "linguistics.h" #include "endianess.h" #include "callback.h" +#include "types.h" static int map_id; @@ -248,6 +249,7 @@ binfile_read_cd(struct map_priv *m, int offset, int len) } cd=(struct zip_cd *)file_data_read(m->fi,cdoffset+offset, sizeof(*cd)+len); if (cd) { + dbg(1,"cd at "LONGLONG_FMT" %d bytes\n",cdoffset+offset, sizeof(*cd)+len); cd_to_cpu(cd); dbg(1,"sig 0x%x\n", cd->zipcensig); if (cd->zipcensig != zip_cd_sig) { @@ -931,6 +933,7 @@ map_binfile_download_size(struct map_priv *m) } while (map_binfile_handle_redirect(m)); ret=file_size(m->http); + dbg(1,"file size "LONGLONG_FMT"\n",ret); return ret; } @@ -961,7 +964,7 @@ map_binfile_http_range(struct map_priv *m, long long offset, int size) attrs[3]=NULL; url.u.str=m->url; - http_header.u.str=g_strdup_printf("Range: bytes=%Ld-%Ld",offset, offset+size-1); + http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset, offset+size-1); map_binfile_http_request(m, attrs); g_free(http_header.u.str); return m->http; @@ -976,6 +979,7 @@ map_binfile_download_range(struct map_priv *m, long long offset, int size) ret=file_data_read_special(http, size, &size_ret); if (size_ret != size) { + dbg(0,"size %d vs %d\n",size,size_ret); g_free(ret); return NULL; } @@ -1012,12 +1016,12 @@ download_request(struct map_download *download) long long offset=binfile_cd_offset(download->cd_copy); int size=download->cd_copy->zipcsiz+sizeof(struct zip_lfh)+download->cd_copy->zipcfnl; url.u.str=g_strdup(download->m->url); - http_header.u.str=g_strdup_printf("Range: bytes=%Ld-%Ld",offset,offset+size-1); + http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset,offset+size-1); attrs[2]=&http_header; attrs[3]=NULL; download->dl_size=size; } - dbg(0,"encountered missing tile %d %s(%s), Downloading %d bytes at %Ld\n",download->zipfile, url.u.str,(char *)(download->cd_copy+1), download->dl_size, download->offset); + dbg(0,"encountered missing tile %d %s(%s), Downloading %d bytes at "LONGLONG_FMT"\n",download->zipfile, url.u.str,(char *)(download->cd_copy+1), download->dl_size, download->offset); map_binfile_http_request(download->m, attrs); g_free(url.u.str); download->http=download->m->http; @@ -1065,7 +1069,7 @@ download_download(struct map_download *download) return 0; } - dbg(1,"got %d bytes writing at offset %Ld\n",size_ret,download->offset); + dbg(1,"got %d bytes writing at offset "LONGLONG_FMT"\n",size_ret,download->offset); if (size_ret <= 0) { g_free(data); return 1; @@ -1101,6 +1105,7 @@ download_finish(struct map_download *download) file_data_free(download->file,(void *)lfh_filename); file_data_free(download->file,(void *)lfh); file_data_write(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, binfile_cd_extra(download->cd_copy)+sizeof(struct zip_cd), (void *)download->cd_copy); + file_data_flush(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, sizeof(struct zip_cd)); g_free(download->cd_copy); download->cd=(struct zip_cd *)(file_data_read(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, download->m->cde_size)); @@ -1113,6 +1118,7 @@ static int download_planet_size(struct map_download *download) { download->size=map_binfile_download_size(download->m); + dbg(0,"Planet size "LONGLONG_FMT"\n",download->size); if (!download->size) return 0; return 1; @@ -1128,6 +1134,7 @@ download_eoc(struct map_download *download) download->zip_eoc=(struct zip_eoc *)(download->zip64_eocl+1); if (download->zip64_eoc->zip64esig != zip64_eoc_sig || download->zip64_eocl->zip64lsig != zip64_eocl_sig || download->zip_eoc->zipesig != zip_eoc_sig) { + dbg(0,"wrong signature on zip64_eoc downloaded from "LONGLONG_FMT"\n",download->size-98); g_free(download->zip64_eoc); return 0; } @@ -1323,8 +1330,10 @@ download(struct map_priv *m, struct map_rect_priv *mr, struct zip_cd *cd, int zi callback_list_call_attr_0(m->cbl, attr_progress); if (download_eoc(download)) download->state=6; - else + else { + dbg(0,"download of eoc failed\n"); download->state=0; + } break; case 6: g_free(m->progress); @@ -1371,6 +1380,7 @@ push_zipfile_tile(struct map_rect_priv *mr, int zipfile, int offset, int length, struct file *f=m->fi; long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst; struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, cdoffset + zipfile*m->cde_size, m->cde_size)); + dbg(1,"read from "LONGLONG_FMT" %d bytes\n",cdoffset + zipfile*m->cde_size, m->cde_size); cd_to_cpu(cd); if (!cd->zipcunc && m->url) { cd=download(m, mr, cd, zipfile, offset, length, async); diff --git a/navit/types.h b/navit/types.h index 60d297f3d..28701c59c 100644 --- a/navit/types.h +++ b/navit/types.h @@ -28,4 +28,15 @@ typedef uint16_t u16; typedef int32_t s32; typedef uint32_t u32; +#ifdef HAVE_API_WIN32_BASE +#define LONGLONG_FMT "%I64d" +#else +#ifdef HAVE_API_ANDROID +#define LONGLONG_FMT "%lld" +#else +#define LONGLONG_FMT "%Ld" +#endif +#endif + + #endif |