diff options
-rw-r--r-- | navit/cache.c | 8 | ||||
-rw-r--r-- | navit/cache.h | 1 | ||||
-rw-r--r-- | navit/file.c | 28 | ||||
-rw-r--r-- | navit/file.h | 6 | ||||
-rw-r--r-- | navit/map/binfile/binfile.c | 14 | ||||
-rw-r--r-- | navit/xslt/navit_drag_bitmap.xslt | 6 | ||||
-rw-r--r-- | navit/xslt/openmoko.xslt | 8 | ||||
-rw-r--r-- | navit/xslt/osd_enable_zoom.xslt | 6 |
8 files changed, 74 insertions, 3 deletions
diff --git a/navit/cache.c b/navit/cache.c index cd12a8286..0d37a06f8 100644 --- a/navit/cache.c +++ b/navit/cache.c @@ -248,6 +248,14 @@ cache_replace(struct cache *cache) return 1; } +void +cache_flush(struct cache *cache, void *id) +{ + struct cache_entry *entry=g_hash_table_lookup(cache->hash, id); + if (entry) + cache_remove(cache, entry); +} + void * cache_lookup(struct cache *cache, void *id) { diff --git a/navit/cache.h b/navit/cache.h index f67c0c087..b2e83b7f1 100644 --- a/navit/cache.h +++ b/navit/cache.h @@ -7,5 +7,6 @@ void cache_entry_destroy(struct cache *cache, void *data); void *cache_lookup(struct cache *cache, void *id); void cache_insert(struct cache *cache, void *data); void *cache_insert_new(struct cache *cache, void *id, int size); +void cache_flush(struct cache *cache, void *id); void cache_dump(struct cache *cache); /* end of prototypes */ diff --git a/navit/file.c b/navit/file.c index 890dcbf19..480277753 100644 --- a/navit/file.c +++ b/navit/file.c @@ -76,6 +76,19 @@ file_create(char *name) return file; } +struct file * +file_create_url(char *url) +{ + struct file *file= g_new0(struct file,1); + char *cmd=g_strdup_printf("curl %s",url); + file->name = g_strdup(url); + file->stdfile=popen(cmd,"r"); + file->fd=fileno(file->stdfile); + file->special=1; + g_free(cmd); + return file; +} + int file_is_dir(char *name) { struct stat buf; @@ -86,7 +99,7 @@ int file_is_dir(char *name) } -int +long long file_size(struct file *file) { return file->size; @@ -172,6 +185,19 @@ file_data_read_all(struct file *file) } int +file_data_write(struct file *file, long long offset, int size, unsigned char *data) +{ + if (file_cache) { + struct file_cache_id id={offset,size,file->name_id,0}; + cache_flush(file_cache,&id); + } + lseek(file->fd, offset, SEEK_SET); + if (write(file->fd, data, size) != size) + return 0; + return 1; +} + +int file_get_contents(char *name, unsigned char **buffer, int *size) { struct file *file; diff --git a/navit/file.h b/navit/file.h index f5dae8eab..a8003263d 100644 --- a/navit/file.h +++ b/navit/file.h @@ -27,6 +27,7 @@ #include <time.h> #endif #include "param.h" +#include <stdio.h> struct file { struct file *next; @@ -45,6 +46,8 @@ struct file { long map_file; #endif char *name; + FILE *stdfile; + int special; }; /* prototypes */ @@ -53,11 +56,12 @@ struct file_wordexp; struct param_list; struct file *file_create(char *name); int file_is_dir(char *name); -int file_size(struct file *file); +long long file_size(struct file *file); int file_mkdir(char *name, int pflag); int file_mmap(struct file *file); unsigned char *file_data_read(struct file *file, long long offset, int size); unsigned char *file_data_read_all(struct file *file); +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); void file_data_free(struct file *file, unsigned char *data); diff --git a/navit/map/binfile/binfile.c b/navit/map/binfile/binfile.c index 4bf27909d..be3dbaaaa 100644 --- a/navit/map/binfile/binfile.c +++ b/navit/map/binfile/binfile.c @@ -707,8 +707,20 @@ push_zipfile_tile(struct map_rect_priv *mr, int zipfile) struct map_priv *m=mr->m; struct file *f=m->fi; struct tile t; - struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, m->eoc->zipeofst + zipfile*m->cde_size, sizeof(struct zip_cd))); + struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, m->eoc->zipeofst + zipfile*m->cde_size, m->cde_size)); cd_to_cpu(cd); + if (!cd->zipcunc) { + char tilename[cd->zipcfnl+1]; + struct zip_cd *cd_copy=g_malloc(m->cde_size); + memcpy(cd_copy, cd, m->cde_size); + file_data_free(f, (unsigned char *)cd); + cd=NULL; + strncpy(tilename,(char *)(cd_copy+1),cd_copy->zipcfnl); + tilename[cd_copy->zipcfnl]='\0'; + dbg(0,"encountered missing tile %s, downloading at %Ld\n",tilename,file_size(m->file)); + g_free(cd_copy); + + } dbg(1,"enter %p %d\n", mr, zipfile); #ifdef DEBUG_SIZE mr->size+=cd->zipcunc; diff --git a/navit/xslt/navit_drag_bitmap.xslt b/navit/xslt/navit_drag_bitmap.xslt new file mode 100644 index 000000000..12b036a85 --- /dev/null +++ b/navit/xslt/navit_drag_bitmap.xslt @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude"> + <xsl:template match="/config/navit"> + <xsl:copy><xsl:copy-of select="@*"/><xsl:attribute name="drag_bitmap">yes</xsl:attribute><xsl:apply-templates/></xsl:copy> + </xsl:template> +</xsl:transform> diff --git a/navit/xslt/openmoko.xslt b/navit/xslt/openmoko.xslt new file mode 100644 index 000000000..c4b2ad0c7 --- /dev/null +++ b/navit/xslt/openmoko.xslt @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude"> + <xsl:output method="xml" doctype-system="navit.dtd" /> + <xsl:include href="gui_internal.xslt"/> + <xsl:include href="navit_drag_bitmap.xslt"/> + <xsl:include href="osd_enable_zoom.xslt"/> + <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template> +</xsl:transform> diff --git a/navit/xslt/osd_enable_zoom.xslt b/navit/xslt/osd_enable_zoom.xslt new file mode 100644 index 000000000..56eda1cbb --- /dev/null +++ b/navit/xslt/osd_enable_zoom.xslt @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude"> + <xsl:template match="/config/navit/osd[@type='button'][@command='zoom_in()' or @command='zoom_out()']"> + <xsl:copy><xsl:copy-of select="@*"/><xsl:attribute name="enabled">yes</xsl:attribute><xsl:apply-templates/></xsl:copy> + </xsl:template> +</xsl:transform> |