Add:xslt:More scripts
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Aug 2009 10:17:11 +0000 (10:17 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Aug 2009 10:17:11 +0000 (10:17 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2513 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/cache.c
navit/cache.h
navit/file.c
navit/file.h
navit/map/binfile/binfile.c
navit/xslt/navit_drag_bitmap.xslt [new file with mode: 0644]
navit/xslt/openmoko.xslt [new file with mode: 0644]
navit/xslt/osd_enable_zoom.xslt [new file with mode: 0644]

index cd12a82..0d37a06 100644 (file)
@@ -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) {
index f67c0c0..b2e83b7 100644 (file)
@@ -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 */
index 890dcbf..4802777 100644 (file)
@@ -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;
index f5dae8e..a800326 100644 (file)
@@ -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);
index 4bf2790..be3dbaa 100644 (file)
@@ -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 (file)
index 0000000..12b036a
--- /dev/null
@@ -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 (file)
index 0000000..c4b2ad0
--- /dev/null
@@ -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 (file)
index 0000000..56eda1c
--- /dev/null
@@ -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>