You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(59) |
Sep
(43) |
Oct
(95) |
Nov
(135) |
Dec
(108) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(229) |
Feb
(141) |
Mar
(59) |
Apr
(70) |
May
(64) |
Jun
(87) |
Jul
(57) |
Aug
(108) |
Sep
(74) |
Oct
(203) |
Nov
(141) |
Dec
(108) |
2009 |
Jan
(114) |
Feb
(91) |
Mar
(101) |
Apr
(69) |
May
(54) |
Jun
(82) |
Jul
(49) |
Aug
(109) |
Sep
(81) |
Oct
(93) |
Nov
(100) |
Dec
(79) |
2010 |
Jan
(46) |
Feb
(36) |
Mar
(135) |
Apr
(103) |
May
(116) |
Jun
(130) |
Jul
(52) |
Aug
(31) |
Sep
(46) |
Oct
(48) |
Nov
(98) |
Dec
(110) |
2011 |
Jan
(234) |
Feb
(184) |
Mar
(150) |
Apr
(43) |
May
(53) |
Jun
(52) |
Jul
(112) |
Aug
(72) |
Sep
(79) |
Oct
(23) |
Nov
(6) |
Dec
(30) |
2012 |
Jan
(39) |
Feb
(37) |
Mar
(49) |
Apr
(60) |
May
(63) |
Jun
(38) |
Jul
(33) |
Aug
(24) |
Sep
(20) |
Oct
(14) |
Nov
(23) |
Dec
(50) |
2013 |
Jan
(30) |
Feb
(32) |
Mar
(27) |
Apr
(41) |
May
(59) |
Jun
(21) |
Jul
(10) |
Aug
(73) |
Sep
(23) |
Oct
(60) |
Nov
(14) |
Dec
(15) |
2014 |
Jan
(4) |
Feb
(8) |
Mar
(11) |
Apr
(6) |
May
(27) |
Jun
(4) |
Jul
(29) |
Aug
(62) |
Sep
(11) |
Oct
(17) |
Nov
(58) |
Dec
(9) |
2015 |
Jan
(23) |
Feb
(3) |
Mar
(26) |
Apr
(47) |
May
(8) |
Jun
(28) |
Jul
(10) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Martin S. <mar...@us...> - 2007-08-21 20:23:12
|
Update of /cvsroot/navit/navit/po In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6239 Modified Files: es.po Log Message: Made es.po work with older gettext versions Index: es.po =================================================================== RCS file: /cvsroot/navit/navit/po/es.po,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** es.po 9 Aug 2007 08:40:23 -0000 1.2 --- es.po 21 Aug 2007 20:10:06 -0000 1.3 *************** *** 6,15 **** msgid "" msgstr "" ! "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2007-08-03 14:49+0200\n" "PO-Revision-Date: 2007-07-15 20:44-0600\n" "Last-Translator: Chris Eubank <cte...@gm...>\n" ! "Language-Team: LANGUAGE <LL...@li...>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" --- 6,15 ---- msgid "" msgstr "" ! "Project-Id-Version: Navit 0.0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2007-08-03 14:49+0200\n" "PO-Revision-Date: 2007-07-15 20:44-0600\n" "Last-Translator: Chris Eubank <cte...@gm...>\n" ! "Language-Team: Chris Eubank <cte...@gm...>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" |
From: Martin S. <mar...@us...> - 2007-08-21 19:53:50
|
Update of /cvsroot/navit/navit/src/gui/sdl In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30127 Modified Files: gui_sdl_window.cpp sdl_events.cpp Log Message: Fixed a compile bug with sdl Index: gui_sdl_window.cpp =================================================================== RCS file: /cvsroot/navit/navit/src/gui/sdl/gui_sdl_window.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gui_sdl_window.cpp 13 Jul 2007 12:57:45 -0000 1.8 --- gui_sdl_window.cpp 21 Aug 2007 19:53:47 -0000 1.9 *************** *** 5,9 **** #include "projection.h" ! #include "navit.h" #include "profile.h" --- 5,9 ---- #include "projection.h" ! #include "item.h" #include "navit.h" #include "profile.h" *************** *** 16,20 **** #include "graphics.h" #include "gui_sdl.h" - #include "item.h" #include "navigation.h" #include "debug.h" --- 16,19 ---- Index: sdl_events.cpp =================================================================== RCS file: /cvsroot/navit/navit/src/gui/sdl/sdl_events.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sdl_events.cpp 11 Aug 2007 12:06:02 -0000 1.5 --- sdl_events.cpp 21 Aug 2007 19:53:47 -0000 1.6 *************** *** 6,9 **** --- 6,10 ---- // FIXME temporary fix for enum #include "projection.h" + #include "item.h" #include "navit.h" *************** *** 11,15 **** // Theses are needed for searches - #include "item.h" #include "search.h" --- 12,15 ---- |
From: Martin S. <mar...@us...> - 2007-08-11 21:58:18
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16287/src Modified Files: attr.c popup.c xmlconfig.c Log Message: Fixed some Bugs in poi_geodownload Index: popup.c =================================================================== RCS file: /cvsroot/navit/navit/src/popup.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** popup.c 13 Jul 2007 11:48:11 -0000 1.12 --- popup.c 11 Aug 2007 21:58:16 -0000 1.13 *************** *** 122,126 **** char *attr_name=attr_to_name(attr->type); - printf("attr\n"); if (attr->type == attr_limit) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); --- 122,125 ---- Index: attr.c =================================================================== RCS file: /cvsroot/navit/navit/src/attr.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** attr.c 11 Aug 2007 20:13:13 -0000 1.4 --- attr.c 11 Aug 2007 21:58:16 -0000 1.5 *************** *** 51,55 **** ret=g_new0(struct attr, 1); ! dbg(0,"enter name='%s' value='%s'\n", name, value); attr=attr_from_name(name); ret->type=attr; --- 51,55 ---- ret=g_new0(struct attr, 1); ! dbg(1,"enter name='%s' value='%s'\n", name, value); attr=attr_from_name(name); ret->type=attr; *************** *** 59,63 **** break; default: ! dbg(0,"default\n"); g_free(ret); ret=NULL; --- 59,63 ---- break; default: ! dbg(1,"default\n"); g_free(ret); ret=NULL; *************** *** 69,75 **** attr_search(struct attr **attrs, struct attr *last, enum attr_type attr) { ! dbg(0, "enter attrs=%p\n", attrs); while (*attrs) { ! dbg(0,"*attrs=%p\n", *attrs); if ((*attrs)->type == attr) { return *attrs; --- 69,75 ---- attr_search(struct attr **attrs, struct attr *last, enum attr_type attr) { ! dbg(1, "enter attrs=%p\n", attrs); while (*attrs) { ! dbg(1,"*attrs=%p\n", *attrs); if ((*attrs)->type == attr) { return *attrs; *************** *** 77,81 **** attrs++; } - exit(0); return NULL; } --- 77,80 ---- Index: xmlconfig.c =================================================================== RCS file: /cvsroot/navit/navit/src/xmlconfig.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** xmlconfig.c 11 Aug 2007 08:02:30 -0000 1.12 --- xmlconfig.c 11 Aug 2007 21:58:17 -0000 1.13 *************** *** 51,55 **** } ret[count]=NULL; ! dbg(0,"ret=%p\n", ret); return ret; } --- 51,55 ---- } ret[count]=NULL; ! dbg(1,"ret=%p\n", ret); return ret; } |
From: Martin S. <mar...@us...> - 2007-08-11 21:58:18
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16287/src/data/poi_geodownload Modified Files: poi_geodownload.c Log Message: Fixed some Bugs in poi_geodownload Index: poi_geodownload.c =================================================================== RCS file: /cvsroot/navit/navit/src/data/poi_geodownload/poi_geodownload.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** poi_geodownload.c 11 Aug 2007 08:02:32 -0000 1.1 --- poi_geodownload.c 11 Aug 2007 21:58:18 -0000 1.2 *************** *** 23,26 **** --- 23,27 ---- int idx_size; enum item_type type; + int name_col; }; *************** *** 29,33 **** --- 30,36 ---- struct item item; struct map_priv *m; + enum attr_type attr_next; int cidx; + char buffer[4096]; }; *************** *** 62,68 **** --- 65,75 ---- + #endif + static void print_col(MdbHandle *h, MdbColumn *col, char *buffer, int hex) { + char *s; + dbg(1,"type=%d\n", col->col_type); switch (col->col_type) { case MDB_BOOL: *************** *** 82,87 **** break; case MDB_TEXT: ! sprintf(buffer, "%s", mdb_col_to_string (h, h->pg_buf, col-> cur_value_start, ! col->col_type, col->cur_value_len)); break; default: --- 89,98 ---- break; case MDB_TEXT: ! dbg(1,"pg_buf %p start %d len %d\n", h->pg_buf, col->cur_value_start, col->cur_value_len); ! if (col->cur_value_len) { ! s=mdb_col_to_string (h, h->pg_buf, col->cur_value_start, col->col_type, col->cur_value_len); ! dbg(1,"s=%p\n", s); ! sprintf(buffer, "%s", s); ! } break; default: *************** *** 90,93 **** --- 101,106 ---- } + #if 0 + static void setup_idx_data(struct index_data *idx, struct coord *c, unsigned int geoflags, int size) *************** *** 131,136 **** } static int ! load_row(struct poi *poi, int pg, int row) { int row_start, row_end, offset; --- 144,151 ---- } + #endif + static int ! load_row(struct map_priv *poi, int pg, int row) { int row_start, row_end, offset; *************** *** 142,152 **** fmt=poi->h->fmt; mdb_read_pg(poi->h, pg); ! if (debug) ! printf("Page Type %d row_count_offset %d\n",poi->h->pg_buf[0], fmt->row_count_offset); ! if (debug > 1) { ! for (i = 0; i <= row; i++) { ! offset=(fmt->row_count_offset + 2) + i * 2; ! printf("row %d %d 0x%x\n", i, offset, mdb_pg_get_int16(poi->h, offset)); ! } } row_start = mdb_pg_get_int16(poi->h, (fmt->row_count_offset + 2) + row * 2); --- 157,165 ---- fmt=poi->h->fmt; mdb_read_pg(poi->h, pg); ! dbg(1, "enter poi=%p pg=%d row=%d\n", poi, pg, row); ! dbg(1,"Page Type %d row_count_offset %d\n",poi->h->pg_buf[0], fmt->row_count_offset); ! for (i = 0; i <= row; i++) { ! offset=(fmt->row_count_offset + 2) + i * 2; ! dbg(1,"row %d %d 0x%x\n", i, offset, mdb_pg_get_int16(poi->h, offset)); } row_start = mdb_pg_get_int16(poi->h, (fmt->row_count_offset + 2) + row * 2); *************** *** 160,168 **** poi->h->cur_pos=row_start & 0x1fff; ! poi->table->cur_row=row+1; num_fields = mdb_crack_row(poi->table, row_start & 0x1fff, row_end, fields); ! if (debug) ! printf("num_fields=%d\n", num_fields); for (i = 0; i < num_fields; i++) { poi->cols[i]->cur_value_start=fields[i].start; poi->cols[i]->cur_value_len=fields[i].siz; --- 173,181 ---- poi->h->cur_pos=row_start & 0x1fff; ! poi->table->cur_row=row; num_fields = mdb_crack_row(poi->table, row_start & 0x1fff, row_end, fields); ! dbg(1,"num_fields=%d\n", num_fields); for (i = 0; i < num_fields; i++) { + dbg(1,"i=%d/%d\n", i, num_fields); poi->cols[i]->cur_value_start=fields[i].start; poi->cols[i]->cur_value_len=fields[i].siz; *************** *** 171,174 **** --- 184,189 ---- } + #if 0 + static MdbIndexPage * index_next_row(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain) *************** *** 296,299 **** --- 311,319 ---- strcasecmp(m->cols[1]->name, "Y") || strcasecmp(m->cols[3]->name, "GEOFLAGS")) return 1; + m->name_col=-1; + for (j = 0; j < m->table_col->len ; j++) { + if (!strcasecmp(m->cols[j]->name, "NAME")) + m->name_col=j; + } for (j = 0; j < m->table->num_idxs; j++) { idx = m->table->indices->pdata[j]; *************** *** 545,548 **** --- 565,570 ---- poi_geodownload_attr_rewind(void *priv_data) { + struct map_rect_priv *mr=priv_data; + mr->attr_next=attr_label; } *************** *** 550,554 **** --- 572,622 ---- poi_geodownload_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { + struct map_rect_priv *mr=priv_data; + struct map_priv *m=mr->m; + MdbColumn *col; + char *v; + int j; + dbg(1,"enter\n"); + attr->type=attr_type; + switch (attr_type) { + case attr_any: + while (mr->attr_next != attr_none) { + if (poi_geodownload_attr_get(mr, mr->attr_next, attr)) + return 1; + } + return 0; + case attr_label: + mr->attr_next=attr_debug; + if (m->name_col == -1) + return 0; + col=m->cols[m->name_col]; + if (col->cur_value_len) + attr->u.str=mdb_col_to_string (m->h, m->h->pg_buf, col->cur_value_start, col->col_type, col->cur_value_len); + else + attr->u.str=""; + return 1; + case attr_debug: + mr->attr_next=attr_none; + v=mr->buffer; + *v='\0'; + for (j = 0; j < mr->m->table_col->len; j++) { + col = mr->m->table_col->pdata[j]; + printf("start: %d type:%d\n", col->cur_value_start, col->col_type); + sprintf(v, "%s:", col->name); + v += strlen(v); + if (!strcasecmp(col->name,"X") || !strcasecmp(col->name,"Y")) + print_col(mr->m->h, col, v, 1); + else + print_col(mr->m->h, col, v, 0); + v += strlen(v); + *v++='\n'; + *v='\0'; + } + attr->u.str=mr->buffer; + return 1; + default: + break; + } return 0; } *************** *** 590,595 **** { dbg(1,"enter\n"); ! if (mdb_fetch_row(mr->m->table)) return &mr->item; return NULL; } --- 658,667 ---- { dbg(1,"enter\n"); ! if (mdb_fetch_row(mr->m->table)) { ! mr->item.id_hi=mr->m->table->cur_phys_pg; ! mr->item.id_lo=mr->m->table->cur_row-1; ! poi_geodownload_attr_rewind(mr); return &mr->item; + } return NULL; } *************** *** 598,602 **** map_rect_get_item_byid_poi_geodownload(struct map_rect_priv *mr, int id_hi, int id_lo) { ! return NULL; } --- 670,693 ---- map_rect_get_item_byid_poi_geodownload(struct map_rect_priv *mr, int id_hi, int id_lo) { ! char *v, buffer[4096]; ! int j; ! MdbColumn *col; ! ! dbg(1,"enter\n"); ! load_row(mr->m, id_hi, id_lo); ! for (j = 0; j < mr->m->table_col->len; j++) { ! col = mr->m->table_col->pdata[j]; ! printf("start: %d type:%d\n", col->cur_value_start, col->col_type); ! sprintf(buffer, "%s:", col->name); ! v = buffer + strlen(buffer); ! if (!strcasecmp(col->name,"X") || !strcasecmp(col->name,"Y")) ! print_col(mr->m->h, col, v, 1); ! else ! print_col(mr->m->h, col, v, 0); ! printf("%s\n", buffer); ! } ! dbg(1,"ret=%p\n", &mr->item); ! poi_geodownload_attr_rewind(mr); ! return &mr->item; } *************** *** 631,638 **** attr=attr_search(attrs, NULL, attr_item_type); dbg(1,"attr_search result %p\n", attr); ! if (attr) { m->type=attr->u.item_type; - printf("type '%s'\n", item_to_name(m->type)); - } --- 722,727 ---- attr=attr_search(attrs, NULL, attr_item_type); dbg(1,"attr_search result %p\n", attr); ! if (attr) m->type=attr->u.item_type; *************** *** 658,661 **** --- 747,751 ---- dbg(1,"plugin_init\n"); plugin_register_map_type("poi_geodownload", map_new_poi_geodownload); + mdb_init(); } |
From: Horwitz <ho...@us...> - 2007-08-11 20:13:16
|
Update of /cvsroot/navit/navit/src/gui/gtk In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4560/gui/gtk Modified Files: datawindow.c Log Message: Cleanup. Fix some warnings Index: datawindow.c =================================================================== RCS file: /cvsroot/navit/navit/src/gui/gtk/datawindow.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** datawindow.c 22 Jul 2007 20:13:21 -0000 1.5 --- datawindow.c 11 Aug 2007 20:13:13 -0000 1.6 *************** *** 1,3 **** --- 1,4 ---- #include <malloc.h> + #include <stdlib.h> #include <stdio.h> #include <string.h> |
From: Horwitz <ho...@us...> - 2007-08-11 20:13:16
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4560 Modified Files: navit.c attr.c attr.h Log Message: Cleanup. Fix some warnings Index: attr.h =================================================================== RCS file: /cvsroot/navit/navit/src/attr.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** attr.h 11 Aug 2007 14:39:13 -0000 1.4 --- attr.h 11 Aug 2007 20:13:13 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- struct attr * attr_new_from_text(char *name, char *value); struct attr * attr_search(struct attr **attrs, struct attr *last, enum attr_type attr); + void attr_free(struct attr *attr); #endif Index: attr.c =================================================================== RCS file: /cvsroot/navit/navit/src/attr.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** attr.c 11 Aug 2007 08:02:28 -0000 1.3 --- attr.c 11 Aug 2007 20:13:13 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + #include <stdlib.h> #include <string.h> #include <glib.h> Index: navit.c =================================================================== RCS file: /cvsroot/navit/navit/src/navit.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** navit.c 11 Aug 2007 14:38:16 -0000 1.23 --- navit.c 11 Aug 2007 20:13:13 -0000 1.24 *************** *** 885,889 **** if (!this_->cursor_flag) return; ! if(this_->orient_north_flag) navit_set_center_cursor(this_, cursor_c, 0, 50 - 30.*sin(M_PI*dir/180.), 50 + 30.*cos(M_PI*dir/180.)); else --- 885,889 ---- if (!this_->cursor_flag) return; ! if (this_->orient_north_flag) navit_set_center_cursor(this_, cursor_c, 0, 50 - 30.*sin(M_PI*dir/180.), 50 + 30.*cos(M_PI*dir/180.)); else |
From: Horwitz <ho...@us...> - 2007-08-11 14:39:12
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10698/src Modified Files: attr.h Log Message: Fix some attr related warnings Index: attr.h =================================================================== RCS file: /cvsroot/navit/navit/src/attr.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** attr.h 11 Aug 2007 08:02:28 -0000 1.3 --- attr.h 11 Aug 2007 14:39:13 -0000 1.4 *************** *** 24,27 **** --- 24,29 ---- enum attr_type attr_from_name(char *name); char * attr_to_name(enum attr_type attr); + struct attr * attr_new_from_text(char *name, char *value); + struct attr * attr_search(struct attr **attrs, struct attr *last, enum attr_type attr); #endif |
From: Horwitz <ho...@us...> - 2007-08-11 14:38:19
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10127/src Modified Files: navit.c navit.h Log Message: Reenable orient north button and improve placement map reposistioning Index: navit.h =================================================================== RCS file: /cvsroot/navit/navit/src/navit.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** navit.h 11 Aug 2007 13:23:45 -0000 1.12 --- navit.h 11 Aug 2007 14:38:17 -0000 1.13 *************** *** 54,57 **** --- 54,58 ---- void navit_toggle_cursor(struct navit *this_); void navit_toggle_tracking(struct navit *this_); + void navit_toggle_orient_north(struct navit *this_); void navit_set_position(struct navit *this_, struct coord *c); struct navit_vehicle *navit_add_vehicle(struct navit *this_, struct vehicle *v, const char *name, struct color *c, int update, int follow); Index: navit.c =================================================================== RCS file: /cvsroot/navit/navit/src/navit.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** navit.c 11 Aug 2007 13:23:45 -0000 1.22 --- navit.c 11 Aug 2007 14:38:16 -0000 1.23 *************** *** 6,9 **** --- 6,10 ---- #include <glib.h> #include <libintl.h> + #include <math.h> #include "debug.h" #include "navit.h" *************** *** 67,70 **** --- 68,72 ---- int cursor_flag; int tracking_flag; + int orient_north_flag; GList *vehicles; GList *windows_items; *************** *** 856,859 **** --- 858,867 ---- } + void + navit_toggle_orient_north(struct navit *this_) + { + this_->orient_north_flag=1-this_->orient_north_flag; + } + static void navit_cursor_update(struct navit *this_, struct cursor *cursor) *************** *** 864,868 **** int speed=cursor_get_speed(cursor); enum projection pro; ! int border=10; if (!this_->vehicle || this_->vehicle->cursor != cursor) --- 872,876 ---- int speed=cursor_get_speed(cursor); enum projection pro; ! int border=30; if (!this_->vehicle || this_->vehicle->cursor != cursor) *************** *** 877,881 **** if (!this_->cursor_flag) return; ! navit_set_center(this_, cursor_c); transform(this_->trans, pro, cursor_c, &pnt); } --- 885,892 ---- if (!this_->cursor_flag) return; ! if(this_->orient_north_flag) ! navit_set_center_cursor(this_, cursor_c, 0, 50 - 30.*sin(M_PI*dir/180.), 50 + 30.*cos(M_PI*dir/180.)); ! else ! navit_set_center_cursor(this_, cursor_c, dir, 50, 80); transform(this_->trans, pro, cursor_c, &pnt); } |
From: Horwitz <ho...@us...> - 2007-08-11 14:38:15
|
Update of /cvsroot/navit/navit/src/gui/gtk In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10127/src/gui/gtk Modified Files: gui_gtk_action.c Log Message: Reenable orient north button and improve placement map reposistioning Index: gui_gtk_action.c =================================================================== RCS file: /cvsroot/navit/navit/src/gui/gtk/gui_gtk_action.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** gui_gtk_action.c 10 Aug 2007 12:07:13 -0000 1.18 --- gui_gtk_action.c 11 Aug 2007 14:38:16 -0000 1.19 *************** *** 56,62 **** { navit_toggle_cursor(gui->nav); - #if 0 - ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); - #endif } --- 56,59 ---- *************** *** 65,71 **** { navit_toggle_tracking(gui->nav); - #if 0 - ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); - #endif } --- 62,65 ---- *************** *** 73,79 **** orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! #if 0 ! ac->gui->co->flags->orient_north=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); ! #endif } --- 67,71 ---- orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_toggle_orient_north(gui->nav); } |
From: Horwitz <ho...@us...> - 2007-08-11 13:23:50
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2146 Modified Files: cursor.c cursor.h navit.c navit.h Log Message: Cleanup navit.c, remove navit_cb_cursor_offscreen Index: cursor.h =================================================================== RCS file: /cvsroot/navit/navit/src/cursor.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cursor.h 21 Jul 2007 08:35:04 -0000 1.8 --- cursor.h 11 Aug 2007 13:23:45 -0000 1.9 *************** *** 13,16 **** int cursor_get_speed(struct cursor *this); struct cursor *cursor_new(struct graphics *gra, struct vehicle *v, struct color *c, struct transformation *t); ! void cursor_add_callback(struct cursor *this, int offscreen, struct callback *cb); /* end of prototypes */ --- 13,16 ---- int cursor_get_speed(struct cursor *this); struct cursor *cursor_new(struct graphics *gra, struct vehicle *v, struct color *c, struct transformation *t); ! void cursor_add_callback(struct cursor *this, struct callback *cb); /* end of prototypes */ Index: navit.h =================================================================== RCS file: /cvsroot/navit/navit/src/navit.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** navit.h 22 Jul 2007 15:37:54 -0000 1.11 --- navit.h 11 Aug 2007 13:23:45 -0000 1.12 *************** *** 5,8 **** --- 5,9 ---- /* prototypes */ enum projection; + enum item_type; struct callback; struct color; *************** *** 43,46 **** --- 44,52 ---- void navit_speak(struct navit *this_); void navit_window_roadbook_new(struct navit *this_); + void navit_window_roadbook_destroy(struct navit *this_); + struct navit_window_items * navit_window_items_new(char *name, int distance); + void navit_window_items_add_item(struct navit_window_items *nwi, enum item_type type); + void navit_add_window_items(struct navit *this_, struct navit_window_items *nwi); + void navit_add_menu_windows_items(struct navit *this_, struct menu *men); void navit_init(struct navit *this_); void navit_set_center(struct navit *this_, struct coord *center); Index: navit.c =================================================================== RCS file: /cvsroot/navit/navit/src/navit.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** navit.c 11 Aug 2007 08:02:30 -0000 1.21 --- navit.c 11 Aug 2007 13:23:45 -0000 1.22 *************** *** 28,31 **** --- 28,32 ---- #include "speech.h" #include "track.h" + #include "vehicle.h" #define _(STRING) gettext(STRING) *************** *** 40,44 **** struct cursor *cursor; struct vehicle *vehicle; - struct callback *offscreen_cb; struct callback *update_cb; }; --- 41,44 ---- *************** *** 857,873 **** static void - navit_cursor_offscreen(struct navit *this_, struct cursor *cursor) - { - if (!this_->cursor_flag || !this_->vehicle || this_->vehicle->cursor != cursor) - return; - navit_set_center(this_, cursor_pos_get(cursor)); - } - - static void navit_cursor_update(struct navit *this_, struct cursor *cursor) { struct coord *cursor_c=cursor_pos_get(cursor); int dir=cursor_get_dir(cursor); int speed=cursor_get_speed(cursor); if (!this_->vehicle || this_->vehicle->cursor != cursor) --- 857,868 ---- static void navit_cursor_update(struct navit *this_, struct cursor *cursor) { + struct point pnt; struct coord *cursor_c=cursor_pos_get(cursor); int dir=cursor_get_dir(cursor); int speed=cursor_get_speed(cursor); + enum projection pro; + int border=10; if (!this_->vehicle || this_->vehicle->cursor != cursor) *************** *** 877,880 **** --- 872,883 ---- dir=cursor_get_dir(cursor); speed=cursor_get_speed(cursor); + pro=vehicle_projection(this_->vehicle); + + if (!transform(this_->trans, pro, cursor_c, &pnt) || !transform_within_border(this_->trans, &pnt, border)) { + if (!this_->cursor_flag) + return; + navit_set_center(this_, cursor_c); + transform(this_->trans, pro, cursor_c, &pnt); + } if (this_->pid && speed > 2) *************** *** 930,937 **** nv->follow_curr=nv->follow=follow; nv->cursor=cursor_new(this_->gra, v, c, this_->trans); - nv->offscreen_cb=callback_new_1(callback_cast(navit_cursor_offscreen), this_); - cursor_add_callback(nv->cursor, 1, nv->offscreen_cb); nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_); ! cursor_add_callback(nv->cursor, 0, nv->update_cb); this_->vehicles=g_list_append(this_->vehicles, nv); --- 933,938 ---- nv->follow_curr=nv->follow=follow; nv->cursor=cursor_new(this_->gra, v, c, this_->trans); nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_); ! cursor_add_callback(nv->cursor, nv->update_cb); this_->vehicles=g_list_append(this_->vehicles, nv); Index: cursor.c =================================================================== RCS file: /cvsroot/navit/navit/src/cursor.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** cursor.c 21 Jul 2007 08:35:03 -0000 1.13 --- cursor.c 11 Aug 2007 13:23:45 -0000 1.14 *************** *** 29,33 **** struct transformation *trans; struct point cursor_pnt; - struct callback_list *offscreen_cbl; struct callback_list *update_cbl; struct vehicle *v; --- 29,32 ---- *************** *** 212,216 **** double *speed; enum projection pro; - int border=10; if (v) { --- 211,214 ---- *************** *** 224,231 **** this->pro=pro; callback_list_call_1(this->update_cbl, this); ! if (!transform(this->trans, pro, &this->pos, &pnt) || !transform_within_border(this->trans, &pnt, border)) { ! callback_list_call_1(this->offscreen_cbl, this); ! transform(this->trans, this->pro, &this->pos, &pnt); ! } cursor_draw(this, &pnt, *dir-transform_get_angle(this->trans, 0), *speed > 2.5); } --- 222,226 ---- this->pro=pro; callback_list_call_1(this->update_cbl, this); ! transform(this->trans, pro, &this->pos, &pnt); cursor_draw(this, &pnt, *dir-transform_get_angle(this->trans, 0), *speed > 2.5); } *************** *** 240,244 **** --- 235,241 ---- dbg(2,"enter gra=%p v=%p c=%p t=%p\n", gra, v, c, t); struct cursor *this=g_new(struct cursor,1); + #if 0 this->offscreen_cbl=callback_list_new(); + #endif this->update_cbl=callback_list_new(); this->gra=gra; *************** *** 255,263 **** void ! cursor_add_callback(struct cursor *this, int offscreen, struct callback *cb) { ! if (offscreen) ! callback_list_add(this->offscreen_cbl, cb); ! else ! callback_list_add(this->update_cbl, cb); } --- 252,257 ---- void ! cursor_add_callback(struct cursor *this, struct callback *cb) { ! callback_list_add(this->update_cbl, cb); } |
From: Martin S. <mar...@us...> - 2007-08-11 12:06:02
|
Update of /cvsroot/navit/navit/src/gui/sdl In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29078 Modified Files: sdl_events.cpp Log Message: Fixed include files Index: sdl_events.cpp =================================================================== RCS file: /cvsroot/navit/navit/src/gui/sdl/sdl_events.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sdl_events.cpp 10 Jul 2007 14:35:39 -0000 1.4 --- sdl_events.cpp 11 Aug 2007 12:06:02 -0000 1.5 *************** *** 11,15 **** // Theses are needed for searches - #include "attr.h" #include "item.h" #include "search.h" --- 11,14 ---- |
From: Martin S. <mar...@us...> - 2007-08-11 10:30:05
|
Update of /cvsroot/navit/navit/src/binding/python In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7004 Modified Files: binding_python.c Log Message: Made it compile again Index: binding_python.c =================================================================== RCS file: /cvsroot/navit/navit/src/binding/python/binding_python.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** binding_python.c 8 Jul 2007 16:42:15 -0000 1.1 --- binding_python.c 11 Aug 2007 10:30:00 -0000 1.2 *************** *** 174,178 **** return NULL; ret=PyObject_NEW(mapObject, &map_Type); ! ret->m=map_new(type,filename); return (PyObject *)ret; } --- 174,178 ---- return NULL; ret=PyObject_NEW(mapObject, &map_Type); ! ret->m=map_new(type,filename,NULL); return (PyObject *)ret; } |
From: Martin S. <mar...@us...> - 2007-08-11 08:03:18
|
Update of /cvsroot/navit/navit/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src Modified Files: attr.c attr.h attr_def.h country.c graphics.c item.c item.h item_def.h map.c map.h mapset.c navit.c plugin_def.h search.c xmlconfig.c Log Message: Moved poi_geodownload to data and made it working with the new api Index: attr.c =================================================================== RCS file: /cvsroot/navit/navit/src/attr.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** attr.c 4 Jul 2007 22:44:19 -0000 1.2 --- attr.c 11 Aug 2007 08:02:28 -0000 1.3 *************** *** 1,3 **** --- 1,6 ---- #include <string.h> + #include <glib.h> + #include "debug.h" + #include "item.h" #include "attr.h" *************** *** 39,40 **** --- 42,86 ---- return NULL; } + + struct attr * + attr_new_from_text(char *name, char *value) + { + enum attr_type attr; + struct attr *ret; + + ret=g_new0(struct attr, 1); + dbg(0,"enter name='%s' value='%s'\n", name, value); + attr=attr_from_name(name); + ret->type=attr; + switch (attr) { + case attr_item_type: + ret->u.item_type=item_from_name(value); + break; + default: + dbg(0,"default\n"); + g_free(ret); + ret=NULL; + } + return ret; + } + + struct attr * + attr_search(struct attr **attrs, struct attr *last, enum attr_type attr) + { + dbg(0, "enter attrs=%p\n", attrs); + while (*attrs) { + dbg(0,"*attrs=%p\n", *attrs); + if ((*attrs)->type == attr) { + return *attrs; + } + attrs++; + } + exit(0); + return NULL; + } + + void + attr_free(struct attr *attr) + { + g_free(attr); + } Index: mapset.c =================================================================== RCS file: /cvsroot/navit/navit/src/mapset.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mapset.c 4 Jul 2007 22:44:26 -0000 1.2 --- mapset.c 11 Aug 2007 08:02:30 -0000 1.3 *************** *** 2,6 **** #include <glib/gprintf.h> #include "debug.h" ! #include "attr.h" #include "mapset.h" #include "map.h" --- 2,6 ---- #include <glib/gprintf.h> #include "debug.h" ! #include "item.h" #include "mapset.h" #include "map.h" Index: country.c =================================================================== RCS file: /cvsroot/navit/navit/src/country.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** country.c 13 Jul 2007 07:34:42 -0000 1.5 --- country.c 11 Aug 2007 08:02:28 -0000 1.6 *************** *** 4,8 **** #include <libintl.h> #include "debug.h" - #include "attr.h" #include "item.h" #include "country.h" --- 4,7 ---- Index: map.c =================================================================== RCS file: /cvsroot/navit/navit/src/map.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** map.c 9 Jul 2007 22:18:25 -0000 1.3 --- map.c 11 Aug 2007 08:02:29 -0000 1.4 *************** *** 27,34 **** struct map * ! map_new(const char *type, const char *filename) { struct map *m; ! struct map_priv *(*maptype_new)(struct map_methods *meth, const char *name, char **charset, enum projection *pro); maptype_new=plugin_get_map_type(type); --- 27,34 ---- struct map * ! map_new(const char *type, const char *filename, struct attr **attrs) { struct map *m; ! struct map_priv *(*maptype_new)(struct map_methods *meth, const char *name, struct attr *attrs, char **charset, enum projection *pro); maptype_new=plugin_get_map_type(type); *************** *** 40,44 **** m->filename=g_strdup(filename); m->type=g_strdup(type); ! m->priv=maptype_new(&m->meth, filename, &m->charset, &m->projection); return m; } --- 40,44 ---- m->filename=g_strdup(filename); m->type=g_strdup(type); ! m->priv=maptype_new(&m->meth, filename, attrs, &m->charset, &m->projection); return m; } Index: item_def.h =================================================================== RCS file: /cvsroot/navit/navit/src/item_def.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** item_def.h 17 Jul 2007 12:22:46 -0000 1.5 --- item_def.h 11 Aug 2007 08:02:29 -0000 1.6 *************** *** 90,93 **** --- 90,97 ---- ITEM(poi_camping) ITEM(poi_public_utilities) + ITEM(poi_burgerking) + ITEM(poi_kfc) + ITEM(poi_mcdonalds) + ITEM(poi_wienerwald) ITEM2(0x80000000,line) ITEM2(0x80000001,line_unspecified) Index: plugin_def.h =================================================================== RCS file: /cvsroot/navit/navit/src/plugin_def.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** plugin_def.h 8 Jul 2007 20:41:34 -0000 1.4 --- plugin_def.h 11 Aug 2007 08:02:30 -0000 1.5 *************** *** 1,3 **** --- 1,4 ---- enum projection; + struct attr; PLUGIN_FUNC1(draw, struct container *, co) PLUGIN_FUNC3(popup, struct container *, map, struct popup *, p, struct popup_item **, list) *************** *** 5,9 **** PLUGIN_TYPE(graphics, (struct graphics_methods *meth)) PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, int w, int h)) ! PLUGIN_TYPE(map, (struct map_methods *meth, char *data, char **charset, enum projection *pro)) PLUGIN_TYPE(osd, (struct osd_methods *meth)) PLUGIN_TYPE(speech, (char *data, struct speech_methods *meth)) --- 6,10 ---- PLUGIN_TYPE(graphics, (struct graphics_methods *meth)) PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, int w, int h)) ! PLUGIN_TYPE(map, (struct map_methods *meth, char *data, struct attr **attr, char **charset, enum projection *pro)) PLUGIN_TYPE(osd, (struct osd_methods *meth)) PLUGIN_TYPE(speech, (char *data, struct speech_methods *meth)) Index: search.c =================================================================== RCS file: /cvsroot/navit/navit/src/search.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** search.c 5 Jul 2007 20:43:59 -0000 1.4 --- search.c 11 Aug 2007 08:02:30 -0000 1.5 *************** *** 3,7 **** #include "map.h" #include "mapset.h" - #include "attr.h" #include "coord.h" #include "item.h" --- 3,6 ---- Index: attr_def.h =================================================================== RCS file: /cvsroot/navit/navit/src/attr_def.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** attr_def.h 4 Jul 2007 22:44:20 -0000 1.2 --- attr_def.h 11 Aug 2007 08:02:28 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- ATTR(street_item) ATTR(street_number_item) + ATTR(item_type) ATTR2(type_item_end,0x0001ffff) ATTR2(type_int_begin,0x00020000) Index: graphics.c =================================================================== RCS file: /cvsroot/navit/navit/src/graphics.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** graphics.c 9 Jul 2007 22:18:25 -0000 1.12 --- graphics.c 11 Aug 2007 08:02:28 -0000 1.13 *************** *** 467,472 **** if (item->type < type_line) { item_coord_get(item, &c, 1); ! if (!transform(t, pro, &c, &pnt[0])) continue; count=1; } else { --- 467,474 ---- if (item->type < type_line) { item_coord_get(item, &c, 1); ! if (!transform(t, pro, &c, &pnt[0])) { ! dbg(1,"not visible\n"); continue; + } count=1; } else { Index: attr.h =================================================================== RCS file: /cvsroot/navit/navit/src/attr.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** attr.h 4 Jul 2007 22:44:19 -0000 1.2 --- attr.h 11 Aug 2007 08:02:28 -0000 1.3 *************** *** 2,5 **** --- 2,7 ---- #define ATTR_H + enum item_type; + enum attr_type { #define ATTR2(x,y) attr_##x=y, *************** *** 16,19 **** --- 18,22 ---- int num; struct item *item; + enum item_type item_type; } u; }; Index: map.h =================================================================== RCS file: /cvsroot/navit/navit/src/map.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** map.h 5 Jul 2007 20:43:59 -0000 1.3 --- map.h 11 Aug 2007 08:02:30 -0000 1.4 *************** *** 29,33 **** struct map_search; struct map_selection; ! struct map *map_new(const char *type, const char *filename); char * map_convert_string(struct map *this, char *str); void map_convert_free(char *str); --- 29,33 ---- struct map_search; struct map_selection; ! struct map *map_new(const char *type, const char *filename, struct attr **attrs); char * map_convert_string(struct map *this, char *str); void map_convert_free(char *str); Index: item.c =================================================================== RCS file: /cvsroot/navit/navit/src/item.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** item.c 13 Jul 2007 07:34:44 -0000 1.4 --- item.c 11 Aug 2007 08:02:29 -0000 1.5 *************** *** 1,5 **** #include <string.h> #include <glib.h> - #include "attr.h" #include "coord.h" #include "debug.h" --- 1,4 ---- Index: xmlconfig.c =================================================================== RCS file: /cvsroot/navit/navit/src/xmlconfig.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** xmlconfig.c 22 Jul 2007 18:04:30 -0000 1.11 --- xmlconfig.c 11 Aug 2007 08:02:30 -0000 1.12 *************** *** 29,32 **** --- 29,59 ---- + static struct attr ** convert_to_attr(struct xmlstate *state) + { + const gchar **attribute_name=state->attribute_names; + const gchar **attribute_value=state->attribute_values; + int count=0; + struct attr **ret; + + while (*attribute_name) { + count++; + attribute_name++; + } + ret=g_new(struct attr, count+1); + attribute_name=state->attribute_names; + count=0; + while (*attribute_name) { + ret[count]=attr_new_from_text(*attribute_name,*attribute_value); + if (ret[count]) + count++; + attribute_name++; + attribute_value++; + } + ret[count]=NULL; + dbg(0,"ret=%p\n", ret); + return ret; + } + + static const char * find_attribute(struct xmlstate *state, const char *attribute, int required) { *************** *** 343,351 **** xmlconfig_map(struct xmlstate *state) { const char *type=find_attribute(state, "type", 1); const char *data=find_attribute(state, "data", 1); if (! type || ! data) return 0; ! state->element_object = map_new(type, data); if (! state->element_object) return 0; --- 370,380 ---- xmlconfig_map(struct xmlstate *state) { + struct attr **attr; const char *type=find_attribute(state, "type", 1); const char *data=find_attribute(state, "data", 1); if (! type || ! data) return 0; ! attr=convert_to_attr(state); ! state->element_object = map_new(type, data, attr); if (! state->element_object) return 0; Index: item.h =================================================================== RCS file: /cvsroot/navit/navit/src/item.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** item.h 12 Jul 2007 14:21:02 -0000 1.3 --- item.h 11 Aug 2007 08:02:29 -0000 1.4 *************** *** 1,3 **** - #include "attr.h" --- 1,2 ---- *************** *** 10,13 **** --- 9,14 ---- }; + #include "attr.h" + #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo) #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map) Index: navit.c =================================================================== RCS file: /cvsroot/navit/navit/src/navit.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** navit.c 22 Jul 2007 18:04:30 -0000 1.20 --- navit.c 11 Aug 2007 08:02:30 -0000 1.21 *************** *** 695,699 **** if (coord_rect_contains(&sel.rect, &c) && g_hash_table_lookup(nwi->hash, &item->type)) { if (! item_attr_get(item, attr_label, &attr)) ! attr.u.str=NULL; idist=transform_distance(center, &c); if (idist < dist) { --- 695,699 ---- if (coord_rect_contains(&sel.rect, &c) && g_hash_table_lookup(nwi->hash, &item->type)) { if (! item_attr_get(item, attr_label, &attr)) ! attr.u.str=""; idist=transform_distance(center, &c); if (idist < dist) { |
From: Martin S. <mar...@us...> - 2007-08-11 08:03:18
|
Update of /cvsroot/navit/navit/src/data/textfile In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data/textfile Modified Files: textfile.c Log Message: Moved poi_geodownload to data and made it working with the new api Index: textfile.c =================================================================== RCS file: /cvsroot/navit/navit/src/data/textfile/textfile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** textfile.c 8 Jul 2007 15:48:39 -0000 1.4 --- textfile.c 11 Aug 2007 08:02:46 -0000 1.5 *************** *** 292,296 **** static struct map_priv * ! map_new_textfile(struct map_methods *meth, char *filename, char **charset, enum projection *pro) { struct map_priv *m; --- 292,296 ---- static struct map_priv * ! map_new_textfile(struct map_methods *meth, char *filename, struct attr **attrs, char **charset, enum projection *pro) { struct map_priv *m; |
From: Martin S. <mar...@us...> - 2007-08-11 08:03:18
|
Update of /cvsroot/navit/navit/src/gui/gtk In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/gui/gtk Modified Files: destination.c Log Message: Moved poi_geodownload to data and made it working with the new api Index: destination.c =================================================================== RCS file: /cvsroot/navit/navit/src/gui/gtk/destination.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** destination.c 18 Jul 2007 22:42:28 -0000 1.5 --- destination.c 11 Aug 2007 08:02:47 -0000 1.6 *************** *** 8,14 **** #include "destination.h" #include "navit.h" - #include "attr.h" - #include "coord.h" #include "item.h" #include "search.h" --- 8,13 ---- #include "destination.h" #include "navit.h" #include "item.h" + #include "coord.h" #include "search.h" |
From: Martin S. <mar...@us...> - 2007-08-11 08:03:06
|
Update of /cvsroot/navit/navit/src/data/mg In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data/mg Modified Files: map.c mg.h Log Message: Moved poi_geodownload to data and made it working with the new api Index: map.c =================================================================== RCS file: /cvsroot/navit/navit/src/data/mg/map.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** map.c 4 Jul 2007 22:44:36 -0000 1.2 --- map.c 11 Aug 2007 08:02:31 -0000 1.3 *************** *** 8,12 **** ! struct map_priv * map_new_mg(struct map_methods *meth, char *dirname, char **charset, enum projection *pro); static int map_id; --- 8,12 ---- ! struct map_priv * map_new_mg(struct map_methods *meth, char *dirname, struct attr **attrs, char **charset, enum projection *pro); static int map_id; *************** *** 260,264 **** struct map_priv * ! map_new_mg(struct map_methods *meth, char *dirname, char **charset, enum projection *pro) { struct map_priv *m; --- 260,264 ---- struct map_priv * ! map_new_mg(struct map_methods *meth, char *dirname, struct attr **attrs, char **charset, enum projection *pro) { struct map_priv *m; Index: mg.h =================================================================== RCS file: /cvsroot/navit/navit/src/data/mg/mg.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mg.h 5 Jul 2007 20:44:00 -0000 1.4 --- mg.h 11 Aug 2007 08:02:31 -0000 1.5 *************** *** 1,7 **** #include <glib.h> #include "attr.h" #include "coord.h" #include "data.h" - #include "item.h" #include "map.h" #include "file.h" --- 1,7 ---- #include <glib.h> + #include "item.h" #include "attr.h" #include "coord.h" #include "data.h" #include "map.h" #include "file.h" |
From: Martin S. <mar...@us...> - 2007-08-11 08:03:06
|
Update of /cvsroot/navit/navit/src/data In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data Modified Files: Makefile.am Log Message: Moved poi_geodownload to data and made it working with the new api Index: Makefile.am =================================================================== RCS file: /cvsroot/navit/navit/src/data/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 4 Jul 2007 22:44:35 -0000 1.2 --- Makefile.am 11 Aug 2007 08:02:31 -0000 1.3 *************** *** 1 **** ! SUBDIRS=mg textfile garmin_img --- 1 ---- ! SUBDIRS=mg textfile garmin_img poi_geodownload |
From: Martin S. <mar...@us...> - 2007-08-11 08:02:57
|
Update of /cvsroot/navit/navit In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201 Modified Files: configure.in Log Message: Moved poi_geodownload to data and made it working with the new api Index: configure.in =================================================================== RCS file: /cvsroot/navit/navit/configure.in,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** configure.in 13 Jul 2007 07:54:05 -0000 1.24 --- configure.in 11 Aug 2007 08:02:27 -0000 1.25 *************** *** 254,257 **** --- 254,259 ---- src/data/textfile/Makefile src/data/garmin_img/Makefile + src/data/poi_geodownload/Makefile + src/data/poi_geodownload/libmdb/Makefile src/fib-1.1/Makefile src/graphics/Makefile |
From: Martin S. <mar...@us...> - 2007-08-11 08:02:46
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload/libmdb In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data/poi_geodownload/libmdb Added Files: Makefile.am backend.c catalog.c data.c dump.c file.c iconv.c index.c kkd.c like.c map.c mem.c money.c options.c props.c sargs.c stats.c table.c worktable.c write.c Log Message: Moved poi_geodownload to data and made it working with the new api --- NEW FILE: like.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include <stdio.h> #include <string.h> #include <mdbtools.h> #ifdef DMALLOC #include "dmalloc.h" #endif /** * mdb_like_cmp * @s: String to search within. * @r: Search pattern. * * Tests the string @s to see if it matches the search pattern @r. In the * search pattern, a percent sign indicates matching on any number of * characters, and an underscore indicates matching any single character. * * Returns: 1 if the string matches, 0 if the string does not match. */ int mdb_like_cmp(char *s, char *r) { unsigned int i; int ret; mdb_debug(MDB_DEBUG_LIKE, "comparing %s and %s", s, r); switch (r[0]) { case '\0': if (s[0]=='\0') { return 1; } else { return 0; } case '_': /* skip one character */ return mdb_like_cmp(&s[1],&r[1]); case '%': /* skip any number of characters */ /* the strlen(s)+1 is important so the next call can */ /* if there are trailing characters */ for(i=0;i<strlen(s)+1;i++) { if (mdb_like_cmp(&s[i],&r[1])) { return 1; } } return 0; default: for(i=0;i<strlen(r);i++) { if (r[i]=='_' || r[i]=='%') break; } if (strncmp(s,r,i)) { return 0; } else { mdb_debug(MDB_DEBUG_LIKE, "at pos %d comparing %s and %s", i, &s[i], &r[i]); ret = mdb_like_cmp(&s[i],&r[i]); mdb_debug(MDB_DEBUG_LIKE, "returning %d (%s and %s)", ret, &s[i], &r[i]); return ret; } } } --- NEW FILE: stats.c --- /* MDB Tools - A library for reading MS Access database files * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif /** * mdb_stats_on: * @mdb: Handle to the (open) MDB file to collect stats on. * * Begins collection of statistics on an MDBHandle. * * Statistics in LibMDB will track the number of reads from the MDB file. The * collection of statistics is started and stopped with the mdb_stats_on and * mdb_stats_off functions. Collected statistics are accessed by reading the * MdbStatistics structure or calling mdb_dump_stats. * */ void mdb_stats_on(MdbHandle *mdb) { if (!mdb->stats) mdb->stats = g_malloc0(sizeof(MdbStatistics)); mdb->stats->collect = TRUE; } /** * mdb_stats_off: * @mdb: pointer to handle of MDB file with active stats collection. * * Turns off statistics collection. * * If mdb_stats_off is not called, statistics will be turned off when handle * is freed using mdb_close. **/ void mdb_stats_off(MdbHandle *mdb) { if (!mdb->stats) return; mdb->stats->collect = FALSE; } /** * mdb_dump_stats: * @mdb: pointer to handle of MDB file with active stats collection. * * Dumps current statistics to stdout. **/ void mdb_dump_stats(MdbHandle *mdb) { if (!mdb->stats) return; fprintf(stdout, "Physical Page Reads: %lu\n", mdb->stats->pg_reads); } --- NEW FILE: kkd.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif /* ** Note: This code is mostly garbage right now...just a test to parse out the ** KKD structures. */ GArray *mdb_get_column_props(MdbCatalogEntry *entry, int start) { int pos, cnt=0; int len, tmp, cplen; MdbColumnProp prop; MdbHandle *mdb = entry->mdb; entry->props = g_array_new(FALSE,FALSE,sizeof(MdbColumnProp)); len = mdb_pg_get_int16(mdb,start); pos = start + 6; while (pos < start+len) { tmp = mdb_pg_get_int16(mdb,pos); /* length of string */ pos += 2; cplen = tmp > MDB_MAX_OBJ_NAME ? MDB_MAX_OBJ_NAME : tmp; g_memmove(prop.name,&mdb->pg_buf[pos],cplen); prop.name[cplen]='\0'; pos += tmp; g_array_append_val(entry->props, prop.name); cnt++; } entry->num_props = cnt; return entry->props; } GHashTable *mdb_get_column_def(MdbCatalogEntry *entry, int start) { GHashTable *hash = NULL; MdbHandle *mdb = entry->mdb; MdbColumnProp prop; int tmp, pos, col_num, val_len, i; int len, col_type; unsigned char c; int end; fprintf(stdout,"\n data\n"); fprintf(stdout,"-------\n"); len = mdb_pg_get_int16(mdb,start); fprintf(stdout,"length = %3d\n",len); pos = start + 6; end = start + len; while (pos < end) { fprintf(stdout,"pos = %3d\n",pos); start = pos; tmp = mdb_pg_get_int16(mdb,pos); /* length of field */ pos += 2; col_type = mdb_pg_get_int16(mdb,pos); /* ??? */ pos += 2; col_num = 0; if (col_type) { col_num = mdb_pg_get_int16(mdb,pos); pos += 2; } val_len = mdb_pg_get_int16(mdb,pos); pos += 2; fprintf(stdout,"length = %3d %04x %2d %2d ",tmp, col_type, col_num, val_len); for (i=0;i<val_len;i++) { c = mdb->pg_buf[pos+i]; if (isprint(c)) fprintf(stdout," %c",c); else fprintf(stdout," %02x",c); } pos = start + tmp; prop = g_array_index(entry->props,MdbColumnProp,col_num); fprintf(stdout," Property %s",prop.name); fprintf(stdout,"\n"); } return hash; } void mdb_kkd_dump(MdbCatalogEntry *entry) { int rows; int kkd_start, kkd_end; int i, tmp, pos, row_type, datapos=0; MdbColumnProp prop; MdbHandle *mdb = entry->mdb; int rowid = entry->kkd_rowid; mdb_read_pg(mdb, entry->kkd_pg); rows = mdb_pg_get_int16(mdb,8); fprintf(stdout,"number of rows = %d\n",rows); kkd_start = mdb_pg_get_int16(mdb,10+rowid*2); fprintf(stdout,"kkd start = %d %04x\n",kkd_start,kkd_start); kkd_end = mdb->fmt->pg_size; for (i=0;i<rows;i++) { tmp = mdb_pg_get_int16(mdb, 10+i*2); if (tmp < mdb->fmt->pg_size && tmp > kkd_start && tmp < kkd_end) { kkd_end = tmp; } } fprintf(stdout,"kkd end = %d %04x\n",kkd_end,kkd_end); pos = kkd_start + 4; /* 4 = K K D \0 */ while (pos < kkd_end) { tmp = mdb_pg_get_int16(mdb,pos); row_type = mdb_pg_get_int16(mdb,pos+4); fprintf(stdout,"row size = %3d type = 0x%02x\n",tmp,row_type); if (row_type==0x80) { fprintf(stdout,"\nColumn Properties\n"); fprintf(stdout,"-----------------\n"); mdb_get_column_props(entry,pos); for (i=0;i<entry->num_props;i++) { prop = g_array_index(entry->props,MdbColumnProp,i); fprintf(stdout,"%3d %s\n",i,prop.name); } } if (row_type==0x01) datapos = pos; pos += tmp; } if (datapos) { mdb_get_column_def(entry, datapos); } } --- NEW FILE: sargs.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * code for handling searchable arguments (sargs) used primary by the sql * engine to support where clause handling. The sargs are configured in * a tree with AND/OR operators connecting the child nodes. NOT operations * have only one child on the left side. Logical operators (=,<,>,etc..) * have no children. * * datatype support is a bit weak at this point. To add more types create * a mdb_test_[type]() function and invoke it from mdb_test_sarg() */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif void mdb_sql_walk_tree(MdbSargNode *node, MdbSargTreeFunc func, gpointer data) { if (func(node, data)) return; if (node->left) mdb_sql_walk_tree(node->left, func, data); if (node->right) mdb_sql_walk_tree(node->right, func, data); } int mdb_test_string(MdbSargNode *node, char *s) { int rc; if (node->op == MDB_LIKE) { return mdb_like_cmp(s,node->value.s); } rc = strncmp(node->value.s, s, 255); switch (node->op) { case MDB_EQUAL: if (rc==0) return 1; break; case MDB_GT: if (rc<0) return 1; break; case MDB_LT: if (rc>0) return 1; break; case MDB_GTEQ: if (rc<=0) return 1; break; case MDB_LTEQ: if (rc>=0) return 1; break; default: fprintf(stderr, "Calling mdb_test_sarg on unknown operator. Add code to mdb_test_string() for operator %d\n",node->op); break; } return 0; } int mdb_test_int(MdbSargNode *node, gint32 i) { switch (node->op) { case MDB_EQUAL: printf("comparing %x and %x %d\n", i, node->value.i, node->value.i == i); if (node->value.i == i) return 1; break; case MDB_GT: if (node->value.i < i) return 1; break; case MDB_LT: if (node->value.i > i) return 1; break; case MDB_GTEQ: if (node->value.i <= i) return 1; break; case MDB_LTEQ: if (node->value.i >= i) return 1; break; default: fprintf(stderr, "Calling mdb_test_sarg on unknown operator. Add code to mdb_test_int() for operator %d\n",node->op); break; } return 0; } #if 0 #endif int mdb_find_indexable_sargs(MdbSargNode *node, gpointer data) { MdbSarg sarg; if (node->op == MDB_OR || node->op == MDB_NOT) return 1; /* * right now all we do is look for sargs that are anded together from * the root. Later we may put together OR ops into a range, and then * range scan the leaf pages. That is col1 = 2 or col1 = 4 becomes * col1 >= 2 and col1 <= 4 for the purpose of index scans, and then * extra rows are thrown out when the row is tested against the main * sarg tree. range scans are generally only a bit better than table * scanning anyway. * * also, later we should support the NOT operator, but it's generally * a pretty worthless test for indexes, ie NOT col1 = 3, we are * probably better off table scanning. */ if (mdb_is_relational_op(node->op) && node->col) { //printf("op = %d value = %s\n", node->op, node->value.s); sarg.op = node->op; sarg.value = node->value; mdb_add_sarg(node->col, &sarg); } return 0; } int mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, MdbField *field) { char tmpbuf[256]; int lastchar; if (node->op == MDB_ISNULL) { if (field->is_null) return 0; else return 1; } else if (node->op == MDB_NOTNULL) { if (field->is_null) return 1; else return 0; } switch (col->col_type) { case MDB_BOOL: return mdb_test_int(node, !field->is_null); break; case MDB_BYTE: return mdb_test_int(node, (gint32)((char *)field->value)[0]); break; case MDB_INT: return mdb_test_int(node, (gint32)mdb_get_int16(field->value, 0)); break; case MDB_LONGINT: return mdb_test_int(node, (gint32)mdb_get_int32(field->value, 0)); break; case MDB_TEXT: if (IS_JET4(mdb)) { mdb_unicode2ascii(mdb, field->value, 0, field->siz, tmpbuf); } else { strncpy(tmpbuf, field->value, 255); lastchar = field->siz > 255 ? 255 : field->siz; tmpbuf[lastchar]='\0'; } return mdb_test_string(node, tmpbuf); default: fprintf(stderr, "Calling mdb_test_sarg on unknown type. Add code to mdb_test_sarg() for type %d\n",col->col_type); break; } return 1; } int mdb_find_field(int col_num, MdbField *fields, int num_fields) { int i; for (i=0;i<num_fields;i++) { if (fields[i].colnum == col_num) return i; } return -1; } int mdb_test_sarg_node(MdbHandle *mdb, MdbSargNode *node, MdbField *fields, int num_fields) { int elem; MdbColumn *col; int rc; if (mdb_is_relational_op(node->op)) { col = node->col; /* for const = const expressions */ if (!col) { return (node->value.i); } elem = mdb_find_field(col->col_num, fields, num_fields); if (!mdb_test_sarg(mdb, col, node, &fields[elem])) return 0; } else { /* logical op */ switch (node->op) { case MDB_NOT: rc = mdb_test_sarg_node(mdb, node->left, fields, num_fields); return !rc; break; case MDB_AND: if (!mdb_test_sarg_node(mdb, node->left, fields, num_fields)) return 0; return mdb_test_sarg_node(mdb, node->right, fields, num_fields); break; case MDB_OR: if (mdb_test_sarg_node(mdb, node->left, fields, num_fields)) return 1; return mdb_test_sarg_node(mdb, node->right, fields, num_fields); break; } } return 1; } int mdb_test_sargs(MdbTableDef *table, MdbField *fields, int num_fields) { MdbSargNode *node; MdbCatalogEntry *entry = table->entry; MdbHandle *mdb = entry->mdb; node = table->sarg_tree; /* there may not be a sarg tree */ if (!node) return 1; return mdb_test_sarg_node(mdb, node, fields, num_fields); } #if 0 int mdb_test_sargs(MdbHandle *mdb, MdbColumn *col, int offset, int len) { MdbSarg *sarg; int i; for (i=0;i<col->num_sargs;i++) { sarg = g_ptr_array_index (col->sargs, i); if (!mdb_test_sarg(mdb, col, sarg, offset, len)) { /* sarg didn't match, no sense going on */ return 0; } } return 1; } #endif int mdb_add_sarg(MdbColumn *col, MdbSarg *in_sarg) { MdbSarg *sarg; if (!col->sargs) { col->sargs = g_ptr_array_new(); } sarg = g_memdup(in_sarg,sizeof(MdbSarg)); g_ptr_array_add(col->sargs, sarg); col->num_sargs++; return 1; } int mdb_add_sarg_by_name(MdbTableDef *table, char *colname, MdbSarg *in_sarg) { MdbColumn *col; unsigned int i; for (i=0;i<table->num_cols;i++) { col = g_ptr_array_index (table->columns, i); if (!strcasecmp(col->name,colname)) { return mdb_add_sarg(col, in_sarg); } } /* else didn't find the column return 0! */ return 0; } --- NEW FILE: table.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif static gint mdb_col_comparer(MdbColumn **a, MdbColumn **b) { if ((*a)->col_num > (*b)->col_num) return 1; else if ((*a)->col_num < (*b)->col_num) return -1; else return 0; } unsigned char mdb_col_needs_size(int col_type) { if (col_type == MDB_TEXT) { return TRUE; } else { return FALSE; } } MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry) { MdbTableDef *table; table = (MdbTableDef *) g_malloc0(sizeof(MdbTableDef)); table->entry=entry; strcpy(table->name, entry->object_name); return table; } void mdb_free_tabledef(MdbTableDef *table) { if (!table) return; if (table->is_temp_table) { unsigned int i; for (i=0; i<table->temp_table_pages->len; i++) g_free(g_ptr_array_index(table->temp_table_pages,i)); g_ptr_array_free(table->temp_table_pages, TRUE); } mdb_free_columns(table->columns); mdb_free_indices(table->indices); g_free(table->usage_map); g_free(table->free_usage_map); g_free(table); } MdbTableDef *mdb_read_table(MdbCatalogEntry *entry) { MdbTableDef *table; MdbHandle *mdb = entry->mdb; MdbFormatConstants *fmt = mdb->fmt; int len, row_start, pg_row; char *buf; table = mdb_alloc_tabledef(entry); mdb_read_pg(mdb, entry->table_pg); if (mdb->pg_buf[0] != 0x02) return NULL; /* not a valid table def page */ len = mdb_pg_get_int16(mdb,8); table->num_rows = mdb_pg_get_int32(mdb, fmt->tab_num_rows_offset); table->num_var_cols = mdb_pg_get_int16(mdb, fmt->tab_num_cols_offset-2); table->num_cols = mdb_pg_get_int16(mdb, fmt->tab_num_cols_offset); table->num_idxs = mdb_pg_get_int32(mdb, fmt->tab_num_idxs_offset); table->num_real_idxs = mdb_pg_get_int32(mdb, fmt->tab_num_ridxs_offset); /* grab a copy of the usage map */ pg_row = mdb_pg_get_int32(mdb, fmt->tab_usage_map_offset); mdb_find_pg_row(mdb, pg_row, &buf, &row_start, &(table->map_sz)); table->usage_map = g_memdup(buf + row_start, table->map_sz); if (mdb_get_option(MDB_DEBUG_USAGE)) buffer_dump(buf, row_start, row_start+table->map_sz-1); mdb_debug(MDB_DEBUG_USAGE,"usage map found on page %ld row %d start %d len %d", pg_row >> 8, pg_row & 0xff, row_start, table->map_sz); /* grab a copy of the free space page map */ pg_row = mdb_pg_get_int32(mdb, fmt->tab_free_map_offset); mdb_find_pg_row(mdb, pg_row, &buf, &row_start, &(table->freemap_sz)); table->free_usage_map = g_memdup(buf + row_start, table->freemap_sz); mdb_debug(MDB_DEBUG_USAGE,"free map found on page %ld row %d start %d len %d\n", pg_row >> 8, pg_row & 0xff, row_start, table->freemap_sz); table->first_data_pg = mdb_pg_get_int16(mdb, fmt->tab_first_dpg_offset); return table; } MdbTableDef *mdb_read_table_by_name(MdbHandle *mdb, gchar *table_name, int obj_type) { unsigned int i; MdbCatalogEntry *entry; mdb_read_catalog(mdb, obj_type); for (i=0; i<mdb->num_catalog; i++) { entry = g_ptr_array_index(mdb->catalog, i); if (!strcasecmp(entry->object_name, table_name)) return mdb_read_table(entry); } return NULL; } /* ** read the next page if offset is > pg_size ** return true if page was read */ int read_pg_if(MdbHandle *mdb, int *cur_pos, int offset) { if (*cur_pos + offset >= mdb->fmt->pg_size) { mdb_read_pg(mdb, mdb_pg_get_int32(mdb,4)); *cur_pos = 8 - (mdb->fmt->pg_size - (*cur_pos)); return 1; } return 0; } guint32 read_pg_if_32(MdbHandle *mdb, int *cur_pos) { unsigned char c[4]; int i, rc = 0; for (i=0;i<4;i++) { rc += read_pg_if(mdb, cur_pos, i); c[i] = mdb->pg_buf[(*cur_pos) + i]; } return mdb_get_int32(c, 0); } guint16 read_pg_if_16(MdbHandle *mdb, int *cur_pos) { unsigned char low_byte, high_byte; int rc = 0; rc += read_pg_if(mdb, cur_pos, 0); low_byte = mdb->pg_buf[*cur_pos]; rc += read_pg_if(mdb, cur_pos, 1); high_byte = mdb->pg_buf[(*cur_pos) + 1]; return (high_byte * 256 + low_byte); } guint16 read_pg_if_n(MdbHandle *mdb, unsigned char *buf, int *cur_pos, int len) { if (*cur_pos + len < mdb->fmt->pg_size) { memcpy(buf, &mdb->pg_buf[*cur_pos], len); return 0; } else { int half = mdb->fmt->pg_size - *cur_pos; memcpy(buf, &mdb->pg_buf[*cur_pos], half); mdb_read_pg(mdb, mdb_pg_get_int32(mdb,4)); memcpy(buf + half, &mdb->pg_buf[8], len - half); *cur_pos = 8 - half; return 1; } } void mdb_append_column(GPtrArray *columns, MdbColumn *in_col) { g_ptr_array_add(columns, g_memdup(in_col,sizeof(MdbColumn))); } void mdb_free_columns(GPtrArray *columns) { unsigned int i; if (!columns) return; for (i=0; i<columns->len; i++) g_free (g_ptr_array_index(columns, i)); g_ptr_array_free(columns, TRUE); } GPtrArray *mdb_read_columns(MdbTableDef *table) { MdbHandle *mdb = table->entry->mdb; MdbFormatConstants *fmt = mdb->fmt; MdbColumn *pcol; unsigned char *col; unsigned int i; int cur_pos, name_sz; table->columns = g_ptr_array_new(); col = (unsigned char *) g_malloc(fmt->tab_col_entry_size); cur_pos = fmt->tab_cols_start_offset + (table->num_real_idxs * fmt->tab_ridx_entry_size); /* new code based on patch submitted by Tim Nelson 2000.09.27 */ /* ** column attributes */ for (i=0;i<table->num_cols;i++) { #ifdef MDB_DEBUG /* printf("column %d\n", i); buffer_dump(mdb->pg_buf, cur_pos ,cur_pos + 18); */ #endif read_pg_if_n(mdb, col, &cur_pos, fmt->tab_col_entry_size); cur_pos += fmt->tab_col_entry_size; pcol = (MdbColumn *) g_malloc0(sizeof(MdbColumn)); pcol->col_type = col[0]; // col_num_offset == 1 or 5 pcol->col_num = col[fmt->col_num_offset]; //fprintf(stdout,"----- column %d -----\n",pcol->col_num); // col_var == 3 or 7 pcol->var_col_num = mdb_get_int16(col, fmt->tab_col_offset_var); //fprintf(stdout,"var column pos %d\n",pcol->var_col_num); // col_var == 5 or 9 pcol->row_col_num = mdb_get_int16(col, fmt->tab_row_col_num_offset); //fprintf(stdout,"row column num %d\n",pcol->row_col_num); /* FIXME: can this be right in Jet3 and Jet4? */ if (pcol->col_type == MDB_NUMERIC) { pcol->col_prec = col[11]; pcol->col_scale = col[12]; } // col_fixed_offset == 13 or 15 pcol->is_fixed = col[fmt->col_fixed_offset] & 0x01 ? 1 : 0; // col_fixed_offset == 13 or 15 pcol->fixed_offset = mdb_get_int16(col, fmt->tab_col_offset_fixed); //fprintf(stdout,"fixed column offset %d\n",pcol->fixed_offset); //fprintf(stdout,"col type %s\n",pcol->is_fixed ? "fixed" : "variable"); if (pcol->col_type != MDB_BOOL) { // col_size_offset == 16 or 23 pcol->col_size = mdb_get_int16(col, fmt->col_size_offset); } else { pcol->col_size=0; } g_ptr_array_add(table->columns, pcol); } g_free (col); /* ** column names - ordered the same as the column attributes table */ for (i=0;i<table->num_cols;i++) { pcol = g_ptr_array_index(table->columns, i); if (IS_JET4(mdb)) { char *tmp_buf; name_sz = read_pg_if_16(mdb, &cur_pos); cur_pos += 2; tmp_buf = (char *) g_malloc(name_sz); read_pg_if_n(mdb, tmp_buf, &cur_pos, name_sz); mdb_unicode2ascii(mdb, tmp_buf, 0, name_sz, pcol->name); g_free(tmp_buf); cur_pos += name_sz; } else if (IS_JET3(mdb)) { read_pg_if(mdb, &cur_pos, 0); name_sz = mdb->pg_buf[cur_pos]; cur_pos++; read_pg_if_n(mdb, pcol->name, &cur_pos, name_sz); pcol->name[name_sz]='\0'; cur_pos += name_sz; } else { fprintf(stderr,"Unknown MDB version\n"); } } /* Sort the columns by col_num */ g_ptr_array_sort(table->columns, (GCompareFunc)mdb_col_comparer); table->index_start = cur_pos; return table->columns; } void mdb_table_dump(MdbCatalogEntry *entry) { MdbTableDef *table; MdbColumn *col; int coln; MdbIndex *idx; MdbHandle *mdb = entry->mdb; unsigned int i, bitn; guint32 pgnum; table = mdb_read_table(entry); fprintf(stdout,"definition page = %lu\n",entry->table_pg); fprintf(stdout,"number of datarows = %d\n",table->num_rows); fprintf(stdout,"number of columns = %d\n",table->num_cols); fprintf(stdout,"number of indices = %d\n",table->num_real_idxs); mdb_read_columns(table); mdb_read_indices(table); for (i=0;i<table->num_cols;i++) { col = g_ptr_array_index(table->columns,i); fprintf(stdout,"column %d Name: %-20s Type: %s(%d)\n", i, col->name, mdb_get_coltype_string(mdb->default_backend, col->col_type), col->col_size); } for (i=0;i<table->num_idxs;i++) { idx = g_ptr_array_index (table->indices, i); mdb_index_dump(table, idx); } if (table->usage_map) { printf("pages reserved by this object\n"); printf("usage map pg %" G_GUINT32_FORMAT "\n", table->map_base_pg); printf("free map pg %" G_GUINT32_FORMAT "\n", table->freemap_base_pg); pgnum = mdb_get_int32(table->usage_map,1); /* the first 5 bytes of the usage map mean something */ coln = 0; for (i=5;i<table->map_sz;i++) { for (bitn=0;bitn<8;bitn++) { if (table->usage_map[i] & 1 << bitn) { coln++; printf("%6" G_GUINT32_FORMAT, pgnum); if (coln==10) { printf("\n"); coln = 0; } else { printf(" "); } } pgnum++; } } printf("\n"); } } int mdb_is_user_table(MdbCatalogEntry *entry) { return ((entry->object_type == MDB_TABLE) && !(entry->flags & 0x80000002)) ? 1 : 0; } int mdb_is_system_table(MdbCatalogEntry *entry) { return ((entry->object_type == MDB_TABLE) && (entry->flags & 0x80000002)) ? 1 : 0; } --- NEW FILE: mem.c --- /* MDB Tools - A library for reading MS Access database files * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #include <locale.h> #ifdef DMALLOC #include "dmalloc.h" #endif /** * mdb_init: * * Initializes the LibMDB library. This function should be called exactly once * by calling program and prior to any other function. * **/ void mdb_init() { mdb_init_backends(); } /** * mdb_exit: * * Cleans up the LibMDB library. This function should be called exactly once * by the calling program prior to exiting (or prior to final use of LibMDB * functions). * **/ void mdb_exit() { mdb_remove_backends(); } --- NEW FILE: props.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000 Brian Bruns * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" GPtrArray * mdb_read_props_list(gchar *kkd, int len) { guint32 record_len; int pos = 0; gchar *name; GPtrArray *names = NULL; int i = 0; names = g_ptr_array_new(); #ifdef MDB_DEBUG buffer_dump(kkd, 0, len - 1); #endif pos = 0; while (pos < len) { record_len = mdb_get_int16(kkd, pos); pos += 2; #ifdef MDB_DEBUG printf("%02d ",i++); buffer_dump(kkd, pos - 2, pos + record_len - 1); #endif name = g_malloc(record_len + 1); strncpy(name, &kkd[pos], record_len); name[record_len] = '\0'; pos += record_len; g_ptr_array_add(names, name); #ifdef MDB_DEBUG printf("new len = %d\n", names->len); #endif } return names; } void mdb_free_props(MdbProperties *props) { if (!props) return; if (props->name) g_free(props->name); g_free(props); } MdbProperties * mdb_alloc_props() { MdbProperties *props; props = g_malloc0(sizeof(MdbProperties)); return props; } MdbProperties * mdb_read_props(MdbHandle *mdb, GPtrArray *names, gchar *kkd, int len) { guint32 record_len, name_len; int pos = 0; int elem, dtype, dsize; gchar *name, *value; MdbProperties *props; int i = 0; #ifdef MDB_DEBUG buffer_dump(kkd, 0, len - 1); #endif pos = 0; /* skip the name record */ record_len = mdb_get_int16(kkd, pos); pos += 4; name_len = mdb_get_int16(kkd, pos); pos += 2; props = mdb_alloc_props(); if (name_len) { props->name = g_malloc(name_len + 1); strncpy(props->name, &kkd[pos], name_len); props->name[name_len]='\0'; } pos += name_len; props->hash = g_hash_table_new(g_str_hash, g_str_equal); while (pos < len) { record_len = mdb_get_int16(kkd, pos); elem = mdb_get_int16(kkd, pos + 4); dtype = kkd[pos + 3]; dsize = mdb_get_int16(kkd, pos + 6); value = g_malloc(dsize + 1); strncpy(value, &kkd[pos + 8], dsize); value[dsize] = '\0'; name = g_ptr_array_index(names,elem); #ifdef MDB_DEBUG printf("%02d ",i++); buffer_dump(kkd, pos, pos + record_len - 1); printf("elem %d dsize %d dtype %d\n", elem, dsize, dtype); #endif if (dtype == MDB_MEMO) dtype = MDB_TEXT; if (dtype == MDB_BOOL) { g_hash_table_insert(props->hash, g_strdup(name), g_strdup(kkd[pos + 8] ? "yes" : "no")); } else { g_hash_table_insert(props->hash, g_strdup(name), g_strdup(mdb_col_to_string(mdb, kkd, pos + 8, dtype, dsize))); } g_free(value); pos += record_len; } return props; } --- NEW FILE: index.c --- /* MDB Tools - A library for reading MS Access database file * Copyright (C) 2000-2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif MdbIndexPage *mdb_index_read_bottom_pg(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain); MdbIndexPage *mdb_chain_add_page(MdbHandle *mdb, MdbIndexChain *chain, guint32 pg); char idx_to_text[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0-7 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8-15 0x09-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 16-23 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 24-31 0x19-0x1f */ ' ', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 32-39 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, ' ', ' ', 0x00, /* 40-47 0x29-0x2f */ 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', /* 48-55 0x30-0x37 */ '^', '_', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56-63 0x39-0x3f */ 0x00, '`', 'a', 'b', 'd', 'f', 'g', 'h', /* 64-71 0x40-0x47 */ 'i', 'j', 'k', 'l', 'm', 'o', 'p', 'r', /* 72-79 0x49-0x4f H */ 's', 't', 'u', 'v', 'w', 'x', 'z', '{', /* 80-87 0x50-0x57 P */ '|', '}', '~', '5', '6', '7', '8', '9', /* 88-95 0x59-0x5f */ 0x00, '`', 'a', 'b', 'd', 'f', 'g', 'h', /* 96-103 0x60-0x67 */ 'i', 'j', 'k', 'l', 'm', 'o', 'p', 'r', /* 014-111 0x69-0x6f h */ 's', 't', 'u', 'v', 'w', 'x', 'z', '{', /* 112-119 0x70-0x77 p */ '|', '}', '~', 0x00, 0x00, 0x00, 0x00, 0x00, /* 120-127 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 128-135 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ 0x00, 0x00, 0x00, 0x00, 0x00, '`', 0x00, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ 0x00, '`', 0x00, '`', '`', '`', 0x00, 0x00, /* 0xe0-0xe7 */ 'f', 'f', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 'r', 0x00, 0x00, 'r', 0x00, /* 0xf0-0xf7 */ 0x81, 0x00, 0x00, 0x00, 'x', 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; GPtrArray * mdb_read_indices(MdbTableDef *table) { MdbCatalogEntry *entry = table->entry; MdbHandle *mdb = entry->mdb; MdbFormatConstants *fmt = mdb->fmt; MdbIndex *pidx; unsigned int i, j; int idx_num, key_num, col_num; int cur_pos, name_sz, idx2_sz, type_offset; int index_start_pg = mdb->cur_pg; gchar *tmpbuf; table->indices = g_ptr_array_new(); if (IS_JET4(mdb)) { cur_pos = table->index_start + 52 * table->num_real_idxs; idx2_sz = 28; type_offset = 23; } else { cur_pos = table->index_start + 39 * table->num_real_idxs; idx2_sz = 20; type_offset = 19; } tmpbuf = (gchar *) g_malloc(idx2_sz); for (i=0;i<table->num_idxs;i++) { read_pg_if_n(mdb, tmpbuf, &cur_pos, idx2_sz); cur_pos += idx2_sz; pidx = (MdbIndex *) g_malloc0(sizeof(MdbIndex)); pidx->table = table; pidx->index_num = mdb_get_int16(tmpbuf, 4); pidx->index_type = tmpbuf[type_offset]; g_ptr_array_add(table->indices, pidx); } g_free(tmpbuf); for (i=0;i<table->num_idxs;i++) { pidx = g_ptr_array_index (table->indices, i); if (IS_JET4(mdb)) { name_sz=read_pg_if_16(mdb, &cur_pos); cur_pos += 2; tmpbuf = g_malloc(name_sz); read_pg_if_n(mdb, tmpbuf, &cur_pos, name_sz); cur_pos += name_sz; mdb_unicode2ascii(mdb, tmpbuf, 0, name_sz, pidx->name); g_free(tmpbuf); } else { read_pg_if(mdb, &cur_pos, 0); name_sz=mdb->pg_buf[cur_pos++]; read_pg_if_n(mdb, pidx->name, &cur_pos, name_sz); cur_pos += name_sz; pidx->name[name_sz]='\0'; } //fprintf(stderr, "index name %s\n", pidx->name); } mdb_read_alt_pg(mdb, entry->table_pg); mdb_read_pg(mdb, index_start_pg); cur_pos = table->index_start; idx_num=0; for (i=0;i<table->num_real_idxs;i++) { if (IS_JET4(mdb)) cur_pos += 4; do { pidx = g_ptr_array_index (table->indices, idx_num++); } while (pidx && pidx->index_type==2); /* if there are more real indexes than index entries left after removing type 2's decrement real indexes and continue. Happens on Northwind Orders table. */ if (!pidx) { table->num_real_idxs--; continue; } pidx->num_rows = mdb_get_int32(mdb->alt_pg_buf, fmt->tab_cols_start_offset + (i*fmt->tab_ridx_entry_size)); key_num=0; for (j=0;j<MDB_MAX_IDX_COLS;j++) { col_num=read_pg_if_16(mdb,&cur_pos); cur_pos += 2; read_pg_if(mdb, &cur_pos, 0); cur_pos++; if (col_num == 0xFFFF) continue; /* set column number to a 1 based column number and store */ pidx->key_col_num[key_num] = col_num + 1; pidx->key_col_order[key_num] = (mdb->pg_buf[cur_pos-1]) ? MDB_ASC : MDB_DESC; key_num++; } pidx->num_keys = key_num; cur_pos += 4; pidx->first_pg = read_pg_if_32(mdb, &cur_pos); cur_pos += 4; read_pg_if(mdb, &cur_pos, 0); pidx->flags = mdb->pg_buf[cur_pos++]; if (IS_JET4(mdb)) cur_pos += 9; } return NULL; } void mdb_index_hash_text(guchar *text, guchar *hash) { unsigned int k; for (k=0;k<strlen(text);k++) { hash[k] = idx_to_text[text[k]]; if (!(hash[k])) fprintf(stderr, "No translation available for %02x %d\n", text[k],text[k]); } hash[strlen(text)]=0; } void mdb_index_swap_n(unsigned char *src, int sz, unsigned char *dest) { int i, j = 0; for (i = sz; i > 0; i--) { dest[j++] = src[i]; } } void mdb_index_cache_sarg(MdbColumn *col, MdbSarg *sarg, MdbSarg *idx_sarg) { //guint32 cache_int; unsigned char *c; switch (col->col_type) { case MDB_TEXT: mdb_index_hash_text(sarg->value.s, idx_sarg->value.s); break; case MDB_LONGINT: idx_sarg->value.i = GUINT32_SWAP_LE_BE(sarg->value.i); //cache_int = sarg->value.i * -1; c = (unsigned char *) &(idx_sarg->value.i); c[0] |= 0x80; //printf("int %08x %02x %02x %02x %02x\n", sarg->value.i, c[0], c[1], c[2], c[3]); break; case MDB_INT: break; default: break; } } #if 0 int mdb_index_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSarg *sarg, int offset, int len) { char tmpbuf[256]; int lastchar; switch (col->col_type) { case MDB_BYTE: return mdb_test_int(sarg, mdb_pg_get_byte(mdb, offset)); break; case MDB_INT: return mdb_test_int(sarg, mdb_pg_get_int16(mdb, offset)); break; case MDB_LONGINT: return mdb_test_int(sarg, mdb_pg_get_int32(mdb, offset)); break; case MDB_TEXT: strncpy(tmpbuf, &mdb->pg_buf[offset],255); lastchar = len > 255 ? 255 : len; tmpbuf[lastchar]='\0'; return mdb_test_string(sarg, tmpbuf); default: fprintf(stderr, "Calling mdb_test_sarg on unknown type. Add code to mdb_test_sarg() for type %d\n",col->col_type); break; } return 1; } #endif int mdb_index_test_sargs(MdbHandle *mdb, MdbIndex *idx, unsigned char *buf, int len) { unsigned int i, j; MdbColumn *col; MdbTableDef *table = idx->table; MdbSarg *idx_sarg; MdbSarg *sarg; MdbField field; MdbSargNode node; //int c_offset = 0, int c_len; #if 0 fprintf(stderr,"mdb_index_test_sargs called on "); for (i=0;i<len;i++) fprintf(stderr,"%02x ",buf[i]); //mdb->pg_buf[offset+i]); fprintf(stderr,"\n"); #endif for (i=0;i<idx->num_keys;i++) { //c_offset++; /* the per column null indicator/flags */ col=g_ptr_array_index(table->columns,idx->key_col_num[i]-1); /* * This will go away eventually */ if (col->col_type==MDB_TEXT) { //c_len = strlen(&mdb->pg_buf[offset + c_offset]); c_len = strlen(buf); } else { c_len = col->col_size; //fprintf(stderr,"Only text types currently supported. How did we get here?\n"); } /* * If we have no cached index values for this column, * create them. */ if (col->num_sargs && !col->idx_sarg_cache) { col->idx_sarg_cache = g_ptr_array_new(); for (j=0;j<col->num_sargs;j++) { sarg = g_ptr_array_index (col->sargs, j); idx_sarg = g_memdup(sarg,sizeof(MdbSarg)); //printf("calling mdb_index_cache_sarg\n"); mdb_index_cache_sarg(col, sarg, idx_sarg); g_ptr_array_add(col->idx_sarg_cache, idx_sarg); } } for (j=0;j<col->num_sargs;j++) { sarg = g_ptr_array_index (col->idx_sarg_cache, j); /* XXX - kludge */ node.op = sarg->op; node.value = sarg->value; //field.value = &mdb->pg_buf[offset + c_offset]; field.value = buf; field.siz = c_len; field.is_null = FALSE; if (!mdb_test_sarg(mdb, col, &node, &field)) { /* sarg didn't match, no sense going on */ return 0; } } } return 1; } /* * pack the pages bitmap */ int mdb_index_pack_bitmap(MdbHandle *mdb, MdbIndexPage *ipg) { int mask_bit = 0; int mask_pos = 0x16; int mask_byte = 0; int elem = 0; int len, start, i; start = ipg->idx_starts[elem++]; while (start) { len = ipg->idx_starts[elem] - start; fprintf(stdout, "len is %d\n", len); for (i=0; i < len; i++) { mask_bit++; if (mask_bit==8) { mask_bit=0; mdb->pg_buf[mask_pos++] = mask_byte; mask_byte = 0; } /* upon reaching the len, set the bit */ } mask_byte = (1 << mask_bit) | mask_byte; fprintf(stdout, "mask byte is %02x at %d\n", mask_byte, mask_pos); start = ipg->idx_starts[elem++]; } /* flush the last byte if any */ mdb->pg_buf[mask_pos++] = mask_byte; /* remember to zero the rest of the bitmap */ for (i = mask_pos; i < 0xf8; i++) { mdb->pg_buf[mask_pos++] = 0; } return 0; } /* * unpack the pages bitmap */ int mdb_index_unpack_bitmap(MdbHandle *mdb, MdbIndexPage *ipg) { int mask_bit = 0; int mask_pos = 0x16; int mask_byte; int start = 0xf8; int elem = 0; int len = 0; ipg->idx_starts[elem++]=start; #if 0 fprintf(stdout, "Unpacking index page %u\n", ipg->pg); #endif do { len = 0; do { mask_bit++; if (mask_bit==8) { mask_bit=0; mask_pos++; } mask_byte = mdb->pg_buf[mask_pos]; len++; } while (mask_pos <= 0xf8 && !((1 << mask_bit) & mask_byte)); //fprintf(stdout, "%d %d %d %d\n", mask_pos, mask_bit, mask_byte, len); start += len; if (mask_pos < 0xf8) ipg->idx_starts[elem++]=start; } while (mask_pos < 0xf8); /* if we zero the next element, so we don't pick up the last pages starts*/ ipg->idx_starts[elem]=0; return elem; } /* * find the next entry on a page (either index or leaf). Uses state information * stored in the MdbIndexPage across calls. */ int mdb_index_find_next_on_page(MdbHandle *mdb, MdbIndexPage *ipg) { if (!ipg->pg) return 0; /* if this page has not been unpacked to it */ if (!ipg->idx_starts[0]){ //fprintf(stdout, "Unpacking page %d\n", ipg->pg); mdb_index_unpack_bitmap(mdb, ipg); } if (ipg->idx_starts[ipg->start_pos + 1]==0) return 0; ipg->len = ipg->idx_starts[ipg->start_pos+1] - ipg->idx_starts[ipg->start_pos]; ipg->start_pos++; //fprintf(stdout, "Start pos %d\n", ipg->start_pos); return ipg->len; } void mdb_index_page_reset(MdbIndexPage *ipg) { ipg->offset = 0xf8; /* start byte of the index entries */ ipg->start_pos=0; ipg->len = 0; ipg->idx_starts[0]=0; } void mdb_index_page_init(MdbIndexPage *ipg) { memset(ipg, 0, sizeof(MdbIndexPage)); mdb_index_page_reset(ipg); } /* * find the next leaf page if any given a chain. Assumes any exhausted leaf * pages at the end of the chain have been peeled off before the call. */ MdbIndexPage * mdb_find_next_leaf(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain) { MdbIndexPage *ipg, *newipg; guint32 pg; guint passed = 0; ipg = mdb_index_read_bottom_pg(mdb, idx, chain); /* * If we are at the first page deep and it's not an index page then * we are simply done. (there is no page to find */ if (mdb->pg_buf[0]==MDB_PAGE_LEAF) { /* Indexes can have leaves at the end that don't appear * in the upper tree, stash the last index found so * we can follow it at the end. */ chain->last_leaf_found = ipg->pg; return ipg; } /* * apply sargs here, currently we don't */ do { ipg->len = 0; //printf("finding next on pg %lu\n", ipg->pg); if (!mdb_index_find_next_on_page(mdb, ipg)) { //printf("find_next_on_page returned 0\n"); return 0; } pg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 3); //printf("Looking at pg %lu at %lu %d\n", pg, ipg->offset, ipg->len); ipg->offset += ipg->len; /* * add to the chain and call this function * recursively. */ newipg = mdb_chain_add_page(mdb, chain, pg); newipg = mdb_find_next_leaf(mdb, idx, chain); //printf("returning pg %lu\n",newipg->pg); return newipg; } while (!passed); /* no more pages */ return NULL; } MdbIndexPage * mdb_chain_add_page(MdbHandle *mdb, MdbIndexChain *chain, guint32 pg) { MdbIndexPage *ipg; chain->cur_depth++; if (chain->cur_depth > MDB_MAX_INDEX_DEPTH) { fprintf(stderr,"Error! maximum index depth of %d exceeded. This is probably due to a programming bug, If you are confident that your indexes really are this deep, adjust MDB_MAX_INDEX_DEPTH in mdbtools.h and recompile.\n", MDB_MAX_INDEX_DEPTH); exit(1); } ipg = &(chain->pages[chain->cur_depth - 1]); mdb_index_page_init(ipg); ipg->pg = pg; return ipg; } /* * returns the bottom page of the IndexChain, if IndexChain is empty it * initializes it by reading idx->first_pg (the root page) */ MdbIndexPage * mdb_index_read_bottom_pg(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain) { MdbIndexPage *ipg; /* * if it's new use the root index page (idx->first_pg) */ if (!chain->cur_depth) { ipg = &(chain->pages[0]); mdb_index_page_init(ipg); chain->cur_depth = 1; ipg->pg = idx->first_pg; if (!(ipg = mdb_find_next_leaf(mdb, idx, chain))) return 0; } else { ipg = &(chain->pages[chain->cur_depth - 1]); ipg->len = 0; } mdb_read_pg(mdb, ipg->pg); return ipg; } /* * unwind the stack and search for new leaf node */ MdbIndexPage * mdb_index_unwind(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain) { MdbIndexPage *ipg; //printf("page %lu finished\n",ipg->pg); if (chain->cur_depth==1) { //printf("cur_depth == 1 we're out\n"); return NULL; } /* * unwind the stack until we find something or reach * the top. */ ipg = NULL; while (chain->cur_depth>1 && ipg==NULL) { //printf("chain depth %d\n", chain->cur_depth); chain->cur_depth--; ipg = mdb_find_next_leaf(mdb, idx, chain); if (ipg) mdb_index_find_next_on_page(mdb, ipg); } if (chain->cur_depth==1) { //printf("last leaf %lu\n", chain->last_leaf_found); return NULL; } return ipg; } /* * the main index function. * caller provides an index chain which is the current traversal of index * pages from the root page to the leaf. Initially passed as blank, * mdb_index_find_next will store it's state information here. Each invocation * then picks up where the last one left off, allowing us to scroll through * the index one by one. * * Sargs are applied here but also need to be applied on the whole row b/c * text columns may return false positives due to hashing and non-index * columns with sarg values can't be tested here. */ int mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 *pg, guint16 *row) { MdbIndexPage *ipg; int passed = 0; int idx_sz; int idx_start = 0; MdbColumn *col; ipg = mdb_index_read_bottom_pg(mdb, idx, chain); /* * loop while the sargs don't match */ do { ipg->len = 0; /* * if no more rows on this leaf, try to find a new leaf */ if (!mdb_index_find_next_on_page(mdb, ipg)) { if (!chain->clean_up_mode) { if (!(ipg = mdb_index_unwind(mdb, idx, chain))) chain->clean_up_mode = 1; } if (chain->clean_up_mode) { //fprintf(stdout,"in cleanup mode\n"); if (!chain->last_leaf_found) return 0; mdb_read_pg(mdb, chain->last_leaf_found); chain->last_leaf_found = mdb_pg_get_int24(mdb, 0x0c); //printf("next leaf %lu\n", chain->last_leaf_found); mdb_read_pg(mdb, chain->last_leaf_found); /* reuse the chain for cleanup mode */ chain->cur_depth = 1; ipg = &chain->pages[0]; mdb_index_page_init(ipg); ipg->pg = chain->last_leaf_found; //printf("next on page %d\n", if (!mdb_index_find_next_on_page(mdb, ipg)) return 0; } } *row = mdb->pg_buf[ipg->offset + ipg->len - 1]; #if 0 printf("page: "); buffer_dump(mdb->pg_buf, ipg->offset+ipg->len-4, ipg->offset+ipg->len-2); #endif *pg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 4); #if 0 printf("row = %d pg = %lu ipg->pg = %lu offset = %lu len = %d\n", *row, *pg, ipg->pg, ipg->offset, ipg->len); #endif col=g_ptr_array_index(idx->table->columns,idx->key_col_num[0]-1); idx_sz = mdb_col_fixed_size(col); /* handle compressed indexes, single key indexes only? */ if (idx->num_keys==1 && idx_sz>0 && ipg->len - 4 < idx_sz) { #if 0 printf("short index found\n"); buffer_dump(ipg->cache_value, 0, idx_sz); #endif memcpy(&ipg->cache_value[idx_sz - (ipg->len - 4)], &mdb->pg_buf[ipg->offset], ipg->len); #if 0 buffer_dump(ipg->cache_value, 0, idx_sz); #endif } else { idx_start = ipg->offset + (ipg->len - 4 - idx_sz); memcpy(ipg->cache_value, &mdb->pg_buf[idx_start], idx_sz); } //idx_start = ipg->offset + (ipg->len - 4 - idx_sz); passed = mdb_index_test_sargs(mdb, idx, ipg->cache_value, idx_sz); // printf("passed=%d\n", passed); buffer_dump(mdb->pg_buf, ipg->offset, ipg->offset+ipg->len-1); ipg->offset += ipg->len; } while (!passed); #if 0 fprintf(stdout,"len = %d pos %d\n", ipg->len, ipg->len); buffer_dump(mdb->pg_buf, ipg->offset, ipg->offset+ipg->len-1); #endif return ipg->len; } /* * XXX - FIX ME * This function is grossly inefficient. It scans the entire index building * an IndexChain to a specific row. We should be checking the index pages * for matches against the indexed fields to find the proper leaf page, but * getting it working first and then make it fast! */ int mdb_index_find_row(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 pg, guint16 row) { MdbIndexPage *ipg; int passed = 0; guint32 datapg; guint16 datarow; ipg = mdb_index_read_bottom_pg(mdb, idx, chain); do { ipg->len = 0; /* * if no more rows on this leaf, try to find a new leaf */ if (!mdb_index_find_next_on_page(mdb, ipg)) { /* back to top? We're done */ if (chain->cur_depth==1) return 0; /* * unwind the stack until we find something or reach * the top. */ while (chain->cur_depth>1) { chain->cur_depth--; if (!(ipg = mdb_find_next_leaf(mdb, idx, chain))) return 0; mdb_index_find_next_on_page(mdb, ipg); } if (chain->cur_depth==1) return 0; } /* test row and pg */ datarow = mdb->pg_buf[ipg->offset + ipg->len - 1]; datapg = mdb_pg_get_int24_msb(mdb, ipg->offset + ipg->len - 4); if (datapg == pg && datarow == row) { passed = 1; } ipg->offset += ipg->len; } while (!passed); /* index chain from root to leaf should now be in "chain" */ return 1; } void mdb_index_walk(MdbTableDef *table, MdbIndex *idx) { MdbHandle *mdb = table->entry->mdb; int cur_pos = 0; unsigned char marker; MdbColumn *col; unsigned int i; if (idx->num_keys!=1) return; mdb_read_pg(mdb, idx->first_pg); cur_pos = 0xf8; for (i=0;i<idx->num_keys;i++) { marker = mdb->pg_buf[cur_pos++]; col=g_ptr_array_index(table->columns,idx->key_col_num[i]-1); //printf("column %d coltype %d col_size %d (%d)\n",i,col->col_type, mdb_col_fixed_size(col), col->col_size); } } void mdb_index_dump(MdbTableDef *table, MdbIndex *idx) { unsigned int i; MdbColumn *col; fprintf(stdout,"index number %d\n", idx->index_num); fprintf(stdout,"index name %s\n", idx->name); fprintf(stdout,"index first page %d\n", idx->first_pg); fprintf(stdout,"index rows %d\n", idx->num_rows); if (idx->index_type==1) fprintf(stdout,"index is a primary key\n"); for (i=0;i<idx->num_keys;i++) { col=g_ptr_array_index(table->columns,idx->key_col_num[i]-1); fprintf(stdout,"Column %s(%d) Sorted %s Unique: %s\n", col->name, idx->key_col_num[i], idx->key_col_order[i]==MDB_ASC ? "ascending" : "descending", idx->flags & MDB_IDX_UNIQUE ? "Yes" : "No" ); } mdb_index_walk(table, idx); } /* * compute_cost tries to assign a cost to a given index using the sargs * available in this query. * * Indexes with no matching sargs are assigned 0 * Unique indexes are preferred over non-uniques * Operator preference is equal, like, isnull, others */ int mdb_index_compute_cost(MdbTableDef *table, MdbIndex *idx) { unsigned int i; MdbColumn *col; MdbSarg *sarg = NULL; int not_all_equal = 0; if (!idx->num_keys) return 0; if (idx->num_keys > 1) { for (i=0;i<idx->num_keys;i++) { col=g_ptr_array_index(table->columns,idx->key_col_num[i]-1); if (col->sargs) sarg = g_ptr_array_index (col->sargs, 0); if (!sarg || sarg->op != MDB_EQUAL) not_all_equal++; } } col=g_ptr_array_index(table->columns,idx->key_col_num[0]-1); /* * if this is the first key column and there are no sargs, * then this index is useless. */ if (!col->num_sargs) return 0; sarg = g_ptr_array_index (col->sargs, 0); /* * a like with a wild card first is useless as a sarg */ if (sarg->op == MDB_LIKE && sarg->value.s[0]=='%') return 0; /* * this needs a lot of tweaking. */ if (idx->flags & MDB_IDX_UNIQUE) { if (idx->num_keys == 1) { //printf("op is %d\n", sarg->op); switch (sarg->op) { case MDB_EQUAL: return 1; break; case MDB_LIKE: return 4; break; case MDB_ISNULL: return 12; break; default: return 8; break; } } else { switch (sarg->op) { case MDB_EQUAL: if (not_all_equal) return 2; else return 1; break; case MDB_LIKE: return 6; break; case MDB_ISNULL: return 12; break; default: return 9; break; } } } else { if (idx->num_keys == 1) { switch (sarg->op) { case MDB_EQUAL: return 2; break; case MDB_LIKE: return 5; break; case MDB_ISNULL: return 12; break; default: return 10; break; } } else { switch (sarg->op) { case MDB_EQUAL: if (not_all_equal) return 3; else return 2; break; case MDB_LIKE: return 7; break; case MDB_ISNULL: return 12; break; default: return 11; break; } } } return 0; } /* * choose_index runs mdb_index_compute_cost for each available index and picks * the best. * * Returns strategy to use (table scan, or index scan) */ MdbStrategy mdb_choose_index(MdbTableDef *table, int *choice) { unsigned int i; MdbIndex *idx; int cost = 0; int least = 99; *choice = -1; for (i=0;i<table->num_idxs;i++) { idx = g_ptr_array_index (table->indices, i); cost = mdb_index_compute_cost(table, idx); //printf("cost for %s is %d\n", idx->name, cost); if (cost && cost < least) { least = cost; *choice = i; } } /* and the winner is: *choice */ if (least==99) return MDB_TABLE_SCAN; return MDB_INDEX_SCAN; } void mdb_index_scan_init(MdbHandle *mdb, MdbTableDef *table) { int i; if (mdb_get_option(MDB_USE_INDEX) && mdb_choose_index(table, &i) == MDB_INDEX_SCAN) { table->strategy = MDB_INDEX_SCAN; table->scan_idx = g_ptr_array_index (table->indices, i); table->chain = g_malloc0(sizeof(MdbIndexChain)); table->mdbidx = mdb_clone_handle(mdb); mdb_read_pg(table->mdbidx, table->scan_idx->first_pg); //printf("best index is %s\n",table->scan_idx->name); } //printf("TABLE SCAN? %d\n", table->strategy); } void mdb_index_scan_free(MdbTableDef *table) { if (table->chain) { g_free(table->chain); table->chain = NULL; } if (table->mdbidx) { mdb_close(table->mdbidx); table->mdbidx = NULL; } } void mdb_free_indices(GPtrArray *indices) { unsigned int i; if (!indices) return; for (i=0; i<indices->len; i++) g_free (g_ptr_array_index(indices, i)); g_ptr_array_free(indices, TRUE); } --- NEW FILE: file.c --- /* MDB Tools - A library for reading MS Access database files * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "mdbtools.h" #ifdef DMALLOC #include "dmalloc.h" #endif /* typedef struct { int pg_size; guint16 row_count_offset; guint16 tab_num_rows_offset; guint16 tab_num_cols_offset; guint16 tab_num_idxs_offset; guint16 tab_num_ridxs_offset; guint16 tab_usage_map_offset; guint16 tab_first_dpg_offset; guint16 tab_cols_start_offset; guint16 tab_ridx_entry_size; guint16 col_fixed_offset; guint16 col_size_offset; guint16 col_num_offset; guint16 tab_col_entry_size; guint16 tab_free_map_offset; guint16 tab_col_offset_var; guint16 tab_col_offset_fixed; guint16 tab_row_col_num_offset; } MdbFormatConstants; */ MdbFormatConstants MdbJet4Constants = { 4096, 0x0c, 16, 45, 47, 51, 55, 56, 63, 12, 15, 23, 5, 25, 59, 7, 21, 9 }; MdbFormatConstants MdbJet3Constants = { 2048, 0x08, 12, 25, 27, 31, 35, 36, 43, 8, 13, 16, 1, 18, 39, 3, 14, 5 /* not sure on 5, need to check */ }; static ssize_t _mdb_read_pg(MdbHandle *mdb, unsigned char *pg_buf, unsigned long pg); /** * mdb_find_file: * @filename: path to MDB (database) file * * Finds and returns the absolute path to an MDB file. Function will first try * to fstat file as passed, then search through the $MDBPATH if not found. * * Return value: gchar pointer to absolute path. Caller is responsible for * freeing. **/ static gchar *mdb_find_file(char *file_name) { struct stat status; gchar *mdbpath, **dir, *tmpfname; unsigned int i = 0; /* try the provided file name first */ if (!stat(file_name, &status)) { return g_strdup(file_name); } /* Now pull apart $MDBPATH and try those */ mdbpath = (gchar *) getenv("MDBPATH"); /* no path, can't find file */ if (!mdbpath || !strlen(mdbpath)) return NULL; dir = g_strsplit(mdbpath, ":", 0); while (dir[i]) { if (!strlen(dir[i])) continue; tmpfname = g_strconcat(dir[i++], "/", file_name, NULL); if (!stat(tmpfname, &status)) { g_strfreev(dir); return tmpfname; } g_free(tmpfname); } g_strfreev(dir); return NULL; } /** * mdb_open: * @filename: path to MDB (database) file * @flags: MDB_NOFLAGS for read-only, MDB_WRITABLE for read/write * * Opens an MDB file and returns an MdbHandle to it. MDB File may be relative * to the current directory, a full path to the file, or relative to a * component of $MDBPATH. * * Return value: pointer to MdbHandle structure. **/ MdbHandle *mdb_open(char *filename, MdbFileFlags flags) { MdbHandle *mdb; mdb = (MdbHandle *) g_malloc0(sizeof(MdbHandle)); mdb_set_default_backend(mdb, "access"); /* need something to bootstrap with, reassign after page 0 is read */ mdb->fmt = &MdbJet3Constants; mdb->f = (MdbFile *) g_malloc0(sizeof(MdbFile)); mdb->f->refs = 1; mdb->f->fd = -1; mdb->f->filename = (char *) mdb_find_file(filename); if (!mdb->f->filename) { fprintf(stderr, "Can't alloc filename\n"); mdb_close(mdb); return NULL; } if (flags & MDB_WRITABLE) { mdb->f->writable = TRUE; mdb->f->fd = open(mdb->f->filename,O_RDWR); } else { mdb->f->fd = open(mdb->f->filename,O_RDONLY); } if (mdb->f->fd==-1) { fprintf(stderr,"Couldn't open file %s\n",mdb->f->filename); mdb_close(mdb); return NULL; } if (!mdb_read_pg(mdb, 0)) { fprintf(stderr,"Couldn't read first page.\n"); mdb_close(mdb); return NULL; } if (mdb->pg_buf[0] != 0) { mdb_close(mdb); return NULL; } mdb->f->jet_version = mdb_pg_get_int32(mdb, 0x14); if (IS_JET4(mdb)) { mdb->fmt = &MdbJet4Constants; } else if (IS_JET3(mdb)) { mdb->fmt = &MdbJet3Constants; } else { fprintf(stderr,"Unknown Jet version.\n"); mdb_close(mdb); return NULL; } return mdb; } /** * mdb_close: * @mdb: Handle to open MDB database file * * Dereferences MDB file, closes if reference count is 0, and destroys handle. * **/ void mdb_close(MdbHandle *mdb) { if (!mdb) return; ... [truncated message content] |
From: Martin S. <mar...@us...> - 2007-08-11 08:02:46
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload/libmdb/include In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data/poi_geodownload/libmdb/include Added Files: mdbtools.h Log Message: Moved poi_geodownload to data and made it working with the new api --- NEW FILE: mdbtools.h --- /* MDB Tools - A library for reading MS Access database files * Copyright (C) 2000 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _mdbtools_h_ #define _mdbtools_h_ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <ctype.h> #include <string.h> #include <glib.h> #ifdef HAVE_ICONV #include <iconv.h> #endif #define MDB_DEBUG 0 #define MDB_PGSIZE 4096 #define MDB_MAX_OBJ_NAME 256 #define MDB_MAX_COLS 256 #define MDB_MAX_IDX_COLS 10 #define MDB_CATALOG_PG 18 #define MDB_MEMO_OVERHEAD 12 #define MDB_BIND_SIZE 16384 enum { MDB_PAGE_DB = 0, MDB_PAGE_DATA, MDB_PAGE_TABLE, MDB_PAGE_INDEX, MDB_PAGE_LEAF, MDB_PAGE_MAP }; enum { MDB_VER_JET3 = 0, MDB_VER_JET4 = 1 }; enum { MDB_FORM = 0, MDB_TABLE, MDB_MACRO, MDB_SYSTEM_TABLE, MDB_REPORT, MDB_QUERY, MDB_LINKED_TABLE, MDB_MODULE, MDB_RELATIONSHIP, MDB_UNKNOWN_09, MDB_UNKNOWN_0A, MDB_DATABASE_PROPERTY, MDB_ANY = -1 }; enum { MDB_BOOL = 0x01, MDB_BYTE = 0x02, MDB_INT = 0x03, MDB_LONGINT = 0x04, MDB_MONEY = 0x05, MDB_FLOAT = 0x06, MDB_DOUBLE = 0x07, MDB_SDATETIME = 0x08, MDB_TEXT = 0x0a, MDB_OLE = 0x0b, MDB_MEMO = 0x0c, MDB_REPID = 0x0f, MDB_NUMERIC = 0x10 }; /* SARG operators */ enum { MDB_OR = 1, MDB_AND, MDB_NOT, MDB_EQUAL, MDB_GT, MDB_LT, MDB_GTEQ, MDB_LTEQ, MDB_LIKE, MDB_ISNULL, MDB_NOTNULL }; typedef enum { MDB_TABLE_SCAN, MDB_LEAF_SCAN, MDB_INDEX_SCAN } MdbStrategy; typedef enum { MDB_NOFLAGS = 0x00, MDB_WRITABLE = 0x01 } MdbFileFlags; enum { MDB_DEBUG_LIKE = 0x0001, MDB_DEBUG_WRITE = 0x0002, MDB_DEBUG_USAGE = 0x0004, MDB_DEBUG_OLE = 0x0008, MDB_DEBUG_ROW = 0x0010, MDB_USE_INDEX = 0x0020 }; #define mdb_is_logical_op(x) (x == MDB_OR || \ x == MDB_AND || \ x == MDB_NOT ) #define mdb_is_relational_op(x) (x == MDB_EQUAL || \ x == MDB_GT || \ x == MDB_LT || \ x == MDB_GTEQ || \ x == MDB_LTEQ || \ x == MDB_LIKE || \ x == MDB_ISNULL || \ x == MDB_NOTNULL ) enum { MDB_ASC, MDB_DESC }; enum { MDB_IDX_UNIQUE = 0x01, MDB_IDX_IGNORENULLS = 0x02, MDB_IDX_REQUIRED = 0x08 }; #define IS_JET4(mdb) (mdb->f->jet_version==MDB_VER_JET4) #define IS_JET3(mdb) (mdb->f->jet_version==MDB_VER_JET3) /* hash to store registered backends */ /* extern GHashTable *mdb_backends; */ /* forward declarations */ typedef struct mdbindex MdbIndex; typedef struct mdbsargtree MdbSargNode; typedef struct { char *name; unsigned char needs_length; /* or precision */ unsigned char needs_scale; unsigned char needs_quotes; } MdbBackendType; typedef struct { MdbBackendType *types_table; } MdbBackend; typedef struct { gboolean collect; unsigned long pg_reads; } MdbStatistics; typedef struct { int fd; gboolean writable; char *filename; guint32 jet_version; guint32 db_key; char db_passwd[14]; MdbBackend *default_backend; char *backend_name; MdbStatistics *stats; /* free map */ int map_sz; unsigned char *free_map; /* reference count */ int refs; } MdbFile; /* offset to row count on data pages...version dependant */ typedef struct { int pg_size; guint16 row_count_offset; guint16 tab_num_rows_offset; guint16 tab_num_cols_offset; guint16 tab_num_idxs_offset; guint16 tab_num_ridxs_offset; guint16 tab_usage_map_offset; guint16 tab_first_dpg_offset; guint16 tab_cols_start_offset; guint16 tab_ridx_entry_size; guint16 col_fixed_offset; guint16 col_size_offset; guint16 col_num_offset; guint16 tab_col_entry_size; guint16 tab_free_map_offset; guint16 tab_col_offset_var; guint16 tab_col_offset_fixed; guint16 tab_row_col_num_offset; } MdbFormatConstants; typedef struct { MdbFile *f; guint32 cur_pg; guint16 row_num; unsigned int cur_pos; unsigned char pg_buf[MDB_PGSIZE]; unsigned char alt_pg_buf[MDB_PGSIZE]; unsigned int num_catalog; GPtrArray *catalog; MdbBackend *default_backend; char *backend_name; MdbFormatConstants *fmt; MdbStatistics *stats; #ifdef HAVE_ICONV iconv_t iconv_out; #endif } MdbHandle; typedef struct { MdbHandle *mdb; char object_name[MDB_MAX_OBJ_NAME+1]; int object_type; unsigned long table_pg; /* misnomer since object may not be a table */ unsigned long kkd_pg; unsigned int kkd_rowid; int num_props; GArray *props; GArray *columns; int flags; } MdbCatalogEntry; typedef struct { gchar *name; GHashTable *hash; } MdbProperties; typedef union { int i; double d; char s[256]; } MdbAny; typedef struct { char name[MDB_MAX_OBJ_NAME+1]; int col_type; int col_size; void *bind_ptr; int *len_ptr; GHashTable *properties; unsigned int num_sargs; GPtrArray *sargs; GPtrArray *idx_sarg_cache; unsigned char is_fixed; int query_order; /* col_num is the current column order, * does not include deletes */ int col_num; int cur_value_start; int cur_value_len; /* MEMO/OLE readers */ guint32 cur_blob_pg; int cur_blob_row; int chunk_size; /* numerics only */ int col_prec; int col_scale; MdbProperties *props; /* info needed for handling deleted/added columns */ int fixed_offset; int var_col_num; /* row_col_num is the row column number order, * including deleted columns */ int row_col_num; } MdbColumn; struct mdbsargtree { int op; MdbColumn *col; MdbAny value; void *parent; MdbSargNode *left; MdbSargNode *right; }; typedef struct { guint32 pg; int start_pos; int offset; int len; guint16 idx_starts[2000]; unsigned char cache_value[256]; } MdbIndexPage; typedef int (*MdbSargTreeFunc)(MdbSargNode *, gpointer *data); #define MDB_MAX_INDEX_DEPTH 10 typedef struct { int cur_depth; guint32 last_leaf_found; int clean_up_mode; MdbIndexPage pages[MDB_MAX_INDEX_DEPTH]; } MdbIndexChain; typedef struct { MdbCatalogEntry *entry; char name[MDB_MAX_OBJ_NAME+1]; unsigned int num_cols; GPtrArray *columns; unsigned int num_rows; int index_start; unsigned int num_real_idxs; unsigned int num_idxs; GPtrArray *indices; guint32 first_data_pg; guint32 cur_pg_num; guint32 cur_phys_pg; unsigned int cur_row; int noskip_del; /* don't skip deleted rows */ /* object allocation map */ guint32 map_base_pg; unsigned int map_sz; unsigned char *usage_map; /* pages with free space left */ guint32 freemap_base_pg; unsigned int freemap_sz; unsigned char *free_usage_map; /* query planner */ MdbSargNode *sarg_tree; MdbStrategy strategy; MdbIndex *scan_idx; MdbHandle *mdbidx; MdbIndexChain *chain; MdbProperties *props; unsigned int num_var_cols; /* to know if row has variable columns */ /* temp table */ unsigned int is_temp_table; GPtrArray *temp_table_pages; } MdbTableDef; struct mdbindex { int index_num; char name[MDB_MAX_OBJ_NAME+1]; unsigned char index_type; guint32 first_pg; int num_rows; /* number rows in index */ unsigned int num_keys; short key_col_num[MDB_MAX_IDX_COLS]; unsigned char key_col_order[MDB_MAX_IDX_COLS]; unsigned char flags; MdbTableDef *table; }; typedef struct { char name[MDB_MAX_OBJ_NAME+1]; } MdbColumnProp; typedef struct { void *value; int siz; int start; unsigned char is_null; unsigned char is_fixed; int colnum; int offset; } MdbField; typedef struct { int op; MdbAny value; } MdbSarg; /* mem.c */ extern void mdb_init(); extern void mdb_exit(); /* file.c */ extern ssize_t mdb_read_pg(MdbHandle *mdb, unsigned long pg); extern ssize_t mdb_read_alt_pg(MdbHandle *mdb, unsigned long pg); extern unsigned char mdb_get_byte(unsigned char *buf, int offset); extern int mdb_get_int16(unsigned char *buf, int offset); extern gint32 mdb_get_int24(unsigned char *buf, int offset); extern long mdb_get_int32(unsigned char *buf, int offset); extern float mdb_get_single(unsigned char *buf, int offset); extern double mdb_get_double(unsigned char *buf, int offset); extern unsigned char mdb_pg_get_byte(MdbHandle *mdb, int offset); extern int mdb_pg_get_int16(MdbHandle *mdb, int offset); extern gint32 mdb_pg_get_int24(MdbHandle *mdb, int offset); extern long mdb_pg_get_int32(MdbHandle *mdb, int offset); extern float mdb_pg_get_single(MdbHandle *mdb, int offset); extern double mdb_pg_get_double(MdbHandle *mdb, int offset); extern gint32 mdb_pg_get_int24_msb(MdbHandle *mdb, int offset); extern MdbHandle *mdb_open(char *filename, MdbFileFlags flags); extern void mdb_close(MdbHandle *mdb); extern MdbHandle *mdb_clone_handle(MdbHandle *mdb); extern void mdb_swap_pgbuf(MdbHandle *mdb); extern long _mdb_get_int32(unsigned char *buf, int offset); /* catalog.c */ extern void mdb_free_catalog(MdbHandle *mdb); extern GPtrArray *mdb_read_catalog(MdbHandle *mdb, int obj_type); extern void mdb_dump_catalog(MdbHandle *mdb, int obj_type); extern char *mdb_get_objtype_string(int obj_type); /* table.c */ extern MdbTableDef *mdb_alloc_tabledef(MdbCatalogEntry *entry); extern void mdb_free_tabledef(MdbTableDef *table); extern MdbTableDef *mdb_read_table(MdbCatalogEntry *entry); extern MdbTableDef *mdb_read_table_by_name(MdbHandle *mdb, gchar *table_name, int obj_type); extern void mdb_append_column(GPtrArray *columns, MdbColumn *in_col); extern void mdb_free_columns(GPtrArray *columns); extern GPtrArray *mdb_read_columns(MdbTableDef *table); extern void mdb_table_dump(MdbCatalogEntry *entry); extern guint16 read_pg_if_16(MdbHandle *mdb, int *cur_pos); extern guint32 read_pg_if_32(MdbHandle *mdb, int *cur_pos); extern int read_pg_if(MdbHandle *mdb, int *cur_pos, int offset); extern guint16 read_pg_if_n(MdbHandle *mdb, unsigned char *buf, int *cur_pos, int len); extern int mdb_is_user_table(MdbCatalogEntry *entry); extern int mdb_is_system_table(MdbCatalogEntry *entry); /* data.c */ extern int mdb_bind_column_by_name(MdbTableDef *table, gchar *col_name, void *bind_ptr); extern void mdb_data_dump(MdbTableDef *table); extern void mdb_bind_column(MdbTableDef *table, int col_num, void *bind_ptr); extern int mdb_rewind_table(MdbTableDef *table); extern int mdb_fetch_row(MdbTableDef *table); extern int mdb_is_fixed_col(MdbColumn *col); extern char *mdb_col_to_string(MdbHandle *mdb, unsigned char *buf, int start, int datatype, int size); extern int mdb_find_pg_row(MdbHandle *mdb, int pg_row, char **buf, int *off, int *len); extern int mdb_find_end_of_row(MdbHandle *mdb, int row); extern int mdb_col_fixed_size(MdbColumn *col); extern int mdb_col_disp_size(MdbColumn *col); extern void mdb_bind_len(MdbTableDef *table, int col_num, int *len_ptr); extern int mdb_ole_read_next(MdbHandle *mdb, MdbColumn *col, void *ole_ptr); extern int mdb_ole_read(MdbHandle *mdb, MdbColumn *col, void *ole_ptr, int chunk_size); extern void mdb_set_date_fmt(const char *); extern int mdb_read_row(MdbTableDef *table, unsigned int row); /* dump.c */ extern void buffer_dump(const unsigned char* buf, int start, int end); /* backend.c */ extern char *mdb_get_coltype_string(MdbBackend *backend, int col_type); extern int mdb_coltype_takes_length(MdbBackend *backend, int col_type); extern void mdb_init_backends(); extern void mdb_register_backend(MdbBackendType *backend, char *backend_name); extern void mdb_remove_backends(); extern int mdb_set_default_backend(MdbHandle *mdb, char *backend_name); extern char *mdb_get_relationships(MdbHandle *mdb); /* sargs.c */ extern int mdb_test_sargs(MdbTableDef *table, MdbField *fields, int num_fields); extern int mdb_test_sarg(MdbHandle *mdb, MdbColumn *col, MdbSargNode *node, MdbField *field); extern void mdb_sql_walk_tree(MdbSargNode *node, MdbSargTreeFunc func, gpointer data); extern int mdb_find_indexable_sargs(MdbSargNode *node, gpointer data); extern int mdb_add_sarg_by_name(MdbTableDef *table, char *colname, MdbSarg *in_sarg); extern int mdb_test_string(MdbSargNode *node, char *s); extern int mdb_test_int(MdbSargNode *node, gint32 i); extern int mdb_add_sarg(MdbColumn *col, MdbSarg *in_sarg); /* index.c */ extern GPtrArray *mdb_read_indices(MdbTableDef *table); extern void mdb_index_dump(MdbTableDef *table, MdbIndex *idx); extern void mdb_index_scan_free(MdbTableDef *table); extern int mdb_index_find_next_on_page(MdbHandle *mdb, MdbIndexPage *ipg); extern int mdb_index_find_next(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 *pg, guint16 *row); extern void mdb_index_hash_text(guchar *text, guchar *hash); extern void mdb_index_scan_init(MdbHandle *mdb, MdbTableDef *table); extern int mdb_index_find_row(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 pg, guint16 row); extern void mdb_index_swap_n(unsigned char *src, int sz, unsigned char *dest); extern void mdb_free_indices(GPtrArray *indices); void mdb_index_page_reset(MdbIndexPage *ipg); extern MdbIndexPage *mdb_index_read_bottom_pg(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain); extern MdbIndexPage *mdb_index_unwind(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain); extern void mdb_index_page_init(MdbIndexPage *ipg); /* stats.c */ extern void mdb_stats_on(MdbHandle *mdb); extern void mdb_stats_off(MdbHandle *mdb); extern void mdb_dump_stats(MdbHandle *mdb); /* like.c */ extern int mdb_like_cmp(char *s, char *r); /* write.c */ extern int mdb_crack_row(MdbTableDef *table, int row_start, int row_end, MdbField *fields); extern guint16 mdb_add_row_to_pg(MdbTableDef *table, unsigned char *row_buffer, int new_row_size); extern int mdb_update_index(MdbTableDef *table, MdbIndex *idx, unsigned int num_fields, MdbField *fields, guint32 pgnum, guint16 rownum); extern int mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fields, MdbField *fields); extern int mdb_replace_row(MdbTableDef *table, int row, unsigned char *new_row, int new_row_size); extern int mdb_pg_get_freespace(MdbHandle *mdb); extern int mdb_update_row(MdbTableDef *table); extern unsigned char *mdb_new_data_pg(MdbCatalogEntry *entry); /* map.c */ extern guint32 mdb_map_find_next_freepage(MdbTableDef *table, int row_size); guint32 mdb_map_find_next(MdbHandle *mdb, unsigned char *map, unsigned int map_sz, guint32 start_pg); /* props.c */ extern GPtrArray *mdb_read_props_list(gchar *kkd, int len); extern void mdb_free_props(MdbProperties *props); extern MdbProperties *mdb_read_props(MdbHandle *mdb, GPtrArray *names, gchar *kkd, int len); /* worktable.c */ extern MdbTableDef *mdb_create_temp_table(MdbHandle *mdb, char *name); extern void mdb_temp_table_add_col(MdbTableDef *table, MdbColumn *col); extern void mdb_fill_temp_col(MdbColumn *tcol, char *col_name, int col_size, int col_type, int is_fixed); extern void mdb_fill_temp_field(MdbField *field, void *value, int siz, int is_fixed, int is_null, int start, int column); extern void mdb_temp_columns_end(MdbTableDef *table); /* options.c */ extern int mdb_get_option(unsigned long optnum); extern void mdb_debug(int klass, char *fmt, ...); /* iconv.c */ extern int mdb_unicode2ascii(MdbHandle *mdb, unsigned char *buf, int offset, unsigned int len, char *dest); extern int mdb_ascii2unicode(MdbHandle *mdb, unsigned char *buf, int offset, unsigned int len, char *dest); #endif /* _mdbtools_h_ */ |
From: Martin S. <mar...@us...> - 2007-08-11 08:02:33
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv28201/src/data/poi_geodownload Added Files: Makefile.am poi_geodownload.c Log Message: Moved poi_geodownload to data and made it working with the new api --- NEW FILE: poi_geodownload.c --- #include <mdbtools.h> #include "debug.h" #include "coord.h" #include "map.h" #include "item.h" #include "projection.h" #include "plugin.h" #include <stdio.h> #include <sys/types.h> #include <dirent.h> struct map_priv { char *filename; MdbHandle *h; MdbHandle *h_idx; MdbTableDef *table; GPtrArray *table_col; MdbColumn **cols; MdbIndex *idx; int idx_size; enum item_type type; }; struct map_rect_priv { struct item item; struct map_priv *m; int cidx; }; #if 0 struct index_data { unsigned char data[15]; }; struct poi { char filename[1024]; char icon[1024]; long pos; MdbHandle *h; MdbHandle *h_idx; MdbTableDef *table; GPtrArray *table_col; MdbColumn **cols; MdbIndex *idx; int idx_size; struct index_data index_data; MdbIndexChain chain; struct poi *next; } *poi_list; struct poi_data { struct poi *poi; int page; int row; }; char poipath[256]; char poibmp[256]; static void print_col(MdbHandle *h, MdbColumn *col, char *buffer, int hex) { switch (col->col_type) { case MDB_BOOL: strcpy(buffer, mdb_pg_get_byte(h, col->cur_value_start) ? "True" : "False"); break; case MDB_BYTE: sprintf(buffer, "%d", mdb_pg_get_byte(h, col->cur_value_start)); break; case MDB_LONGINT: if (hex) sprintf(buffer, "0x%lx", mdb_pg_get_int32(h, col->cur_value_start)); else sprintf(buffer, "%ld", mdb_pg_get_int32(h, col->cur_value_start)); break; case MDB_DOUBLE: sprintf(buffer, "%f", mdb_pg_get_double(h, col->cur_value_start)); break; case MDB_TEXT: sprintf(buffer, "%s", mdb_col_to_string (h, h->pg_buf, col-> cur_value_start, col->col_type, col->cur_value_len)); break; default: sprintf(buffer, "unknown (%d)", col->col_type); } } static void setup_idx_data(struct index_data *idx, struct coord *c, unsigned int geoflags, int size) { /* 7f 80 1c 91 0a 7f 80 5c f5 41 7f 80 00 00 05 */ idx->data[0]=0x7f; idx->data[1]=(c->x >> 24) ^ 0x80; idx->data[2]=c->x >> 16; idx->data[3]=c->x >> 8; idx->data[4]=c->x; idx->data[5]=0x7f; idx->data[6]=(c->y >> 24) ^ 0x80; idx->data[7]=c->y >> 16; idx->data[8]=c->y >> 8; idx->data[9]=c->y; idx->data[10]=0x7f; if (size > 12) { idx->data[11]=0x80 | (geoflags >> 24); idx->data[12]=geoflags >> 16; idx->data[13]=geoflags >> 8; idx->data[14]=geoflags; } else { idx->data[11]=geoflags; } } static void setup_idx_rect(struct coord *rect, struct index_data *idx, int size) { struct coord r[2]; r[0].x=rect[0].x; r[0].y=rect[1].y; r[1].x=rect[1].x; r[1].y=rect[0].y; #if 0 printf("low 0x%x 0%x\n", r[0].x, r[0].y); printf("high 0x%x 0%x\n", r[1].x, r[1].y); #endif setup_idx_data(idx, r, 0, size); setup_idx_data(idx+1, r+1, 0xffffffff, size); } static int load_row(struct poi *poi, int pg, int row) { int row_start, row_end, offset; unsigned int num_fields, i; MdbField fields[256]; MdbFormatConstants *fmt; int debug=0; fmt=poi->h->fmt; mdb_read_pg(poi->h, pg); if (debug) printf("Page Type %d row_count_offset %d\n",poi->h->pg_buf[0], fmt->row_count_offset); if (debug > 1) { for (i = 0; i <= row; i++) { offset=(fmt->row_count_offset + 2) + i * 2; printf("row %d %d 0x%x\n", i, offset, mdb_pg_get_int16(poi->h, offset)); } } row_start = mdb_pg_get_int16(poi->h, (fmt->row_count_offset + 2) + row * 2); if (row_start & 0x4000) return 1; row_end = mdb_find_end_of_row(poi->h, row); if (debug) { printf("start=0x%x end=0x%x\n", row_start, row_end); buffer_dump(poi->h->pg_buf, row_start, row_end); } poi->h->cur_pos=row_start & 0x1fff; poi->table->cur_row=row+1; num_fields = mdb_crack_row(poi->table, row_start & 0x1fff, row_end, fields); if (debug) printf("num_fields=%d\n", num_fields); for (i = 0; i < num_fields; i++) { poi->cols[i]->cur_value_start=fields[i].start; poi->cols[i]->cur_value_len=fields[i].siz; } return 0; } static MdbIndexPage * index_next_row(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain) { MdbIndexPage *ipg; ipg = mdb_index_read_bottom_pg(mdb, idx, chain); if (!mdb_index_find_next_on_page(mdb, ipg)) { #if 0 printf("no next\n"); #endif if (!chain->clean_up_mode) { #if 0 printf("no cleanup\n"); #endif if (!(ipg = mdb_index_unwind(mdb, idx, chain))) chain->clean_up_mode = 1; } if (chain->clean_up_mode) { #if 0 printf("cleanup\n"); #endif //fprintf(stdout,"in cleanup mode\n"); if (!chain->last_leaf_found) { printf("no last_leaf_found\n"); return NULL; } mdb_read_pg(mdb, chain->last_leaf_found); chain->last_leaf_found = mdb_pg_get_int24(mdb, 0x0c); //printf("next leaf %lu\n", chain->last_leaf_found); mdb_read_pg(mdb, chain->last_leaf_found); /* reuse the chain for cleanup mode */ chain->cur_depth = 1; ipg = &chain->pages[0]; mdb_index_page_init(ipg); ipg->pg = chain->last_leaf_found; //printf("next on page %d\n", if (!mdb_index_find_next_on_page(mdb, ipg)) { #if 0 printf("no find_next_on_page\n"); #endif return NULL; } } } return ipg; } static int index_next(struct poi *poi, struct index_data *idx) { MdbIndexPage *ipg; MdbIndexChain *chain = &poi->chain; int row; int pg; int offset; char *cmp, *low, *high; int debug=0; for(;;) { for(;;) { ipg=index_next_row(poi->h_idx, poi->idx, chain); if (! ipg) return 0; row = poi->h_idx->pg_buf[ipg->offset + ipg->len - 1]; pg = mdb_pg_get_int24_msb(poi->h_idx, ipg->offset + ipg->len - 4); offset=poi->idx_size+4-ipg->len; memcpy(poi->index_data.data+offset, poi->h_idx->pg_buf+ipg->offset, ipg->len - 4); cmp=poi->index_data.data; low=idx[0].data; high=idx[1].data; if (debug > 1) { buffer_dump(low, 0, poi->idx_size-1); buffer_dump(cmp, 0, poi->idx_size-1); buffer_dump(high, 0, poi->idx_size-1); printf("%d %d %d\n", memcmp(cmp, low, poi->idx_size), memcmp(cmp, high, poi->idx_size), offset); } #if 0 buffer_dump(poi->h_idx->pg_buf, ipg->offset, ipg->offset+ipg->len-1); #endif ipg->offset += ipg->len; if (memcmp(cmp, low, poi->idx_size) >= 0) { if (memcmp(cmp, high, poi->idx_size) <=0 ) { if (debug) { printf("match\n"); buffer_dump(low, 0, poi->idx_size-1); buffer_dump(cmp, 0, poi->idx_size-1); buffer_dump(high, 0, poi->idx_size-1); printf("%d %d %d\n", memcmp(cmp, low, poi->idx_size), memcmp(cmp, high, poi->idx_size), offset); } break; } else { return 0; } } if (debug > 1) printf("row=0x%x pg=0x%x len=%d\n", row, pg, ipg->len); } if (debug) printf("match: row=0x%x pg=0x%x len=%d\n", row, pg, ipg->len); if (!load_row(poi, pg, row)) break; } return 1; } #endif static int load_poi_table(struct map_priv *m, MdbCatalogEntry *entry) { int j; MdbIndex *idx; m->h_idx=NULL; m->table = mdb_read_table(entry); m->table_col = mdb_read_columns(m->table); mdb_read_indices(m->table); m->cols = (MdbColumn **) (m->table_col->pdata); if (m->table_col->len < 4 || strcasecmp(m->cols[0]->name, "X") || strcasecmp(m->cols[1]->name, "Y") || strcasecmp(m->cols[3]->name, "GEOFLAGS")) return 1; for (j = 0; j < m->table->num_idxs; j++) { idx = m->table->indices->pdata[j]; if (idx->num_keys == 3 && idx->key_col_num[0] == 1 && idx->key_col_num[1] == 2 && idx->key_col_num[2] == 4) { m->idx = idx; m->idx_size=3+m->cols[0]->col_size+m->cols[1]->col_size+m->cols[3]->col_size; m->h_idx=mdb_clone_handle(m->h); } } return 0; } #if 0 static void load_poi(char *filename, char *icon, int type) { int i; MdbCatalogEntry *entry; GPtrArray *catalog; struct poi *new = g_new0(struct poi, 1); FILE *fp = fopen(filename,"r"); if( fp ) { fclose(fp); } else { printf("ERR : POI file %s does not exists!\n",filename); exit(0); return -1; } fp = fopen(icon,"r"); if( fp ) { fclose(fp); } else { printf("ERR : WARNING INCORRECT PICTURE! %s!\n",icon); exit(0); return -1; } strcpy(new->filename,filename); strcpy(new->icon,icon); new->type = type; if (type == 0) { new->h = mdb_open(filename, MDB_NOFLAGS); catalog = mdb_read_catalog(new->h, MDB_TABLE); for (i = 0; i < catalog->len; i++) { entry = catalog->pdata[i]; if (!strcasecmp(entry->object_name, "_INDEXDATA")) { if (load_poi_table(new, entry)) { printf("%s invalid\n", filename); g_free(new); new=NULL; } } } g_ptr_array_free(catalog, 1); } if (new) { new->next = poi_list; poi_list = new; } } static void get_coord(struct poi *p, struct coord *c) { c->x=mdb_pg_get_int32(p->h, p->cols[0]->cur_value_start); c->y=mdb_pg_get_int32(p->h, p->cols[1]->cur_value_start); } static void poi_info(struct display_list *list, struct popup_item **popup) { struct poi_data *data=list->data; struct poi *poi=data->poi; struct popup_item *popup_last, *popup_val_last; char *text,buffer[4096]; int j; MdbColumn *col; char *v; popup_last = *popup; popup_val_last = NULL; sprintf(buffer,"File:%s", poi->filename); popup_item_new_text(&popup_val_last, buffer, 1); sprintf(buffer,"Icon:%s", poi->icon); popup_item_new_text(&popup_val_last, buffer, 2); if (poi->type == 0) { printf("poi_info pg=%d row=%d\n", data->page, data->row); load_row(poi, data->page, data->row); sprintf(buffer,"Page:%d", data->page); popup_item_new_text(&popup_val_last, buffer, 3); sprintf(buffer,"Row:%d", data->row); popup_item_new_text(&popup_val_last, buffer, 4); for (j = 0; j < poi->table_col->len; j++) { col = poi->table_col->pdata[j]; #if 0 printf("start: %d type:%d\n", col->cur_value_start, col->col_type); #endif sprintf(buffer, "%s:", col->name); v = buffer + strlen(buffer); if (!strcasecmp(col->name,"X") || !strcasecmp(col->name,"Y")) print_col(poi->h, col, v, 1); else print_col(poi->h, col, v, 0); #if 0 printf("%s\n", buffer); #endif text=g_convert(buffer,-1,"utf-8","iso8859-1",NULL,NULL,NULL); popup_item_new_text(&popup_val_last, buffer, j+10); g_free(text); } } popup_item_new_text(&popup_last, "POI", 20)->submenu = popup_val_last; *popup=popup_last; } static void draw_poi(struct poi *p, struct container *co, struct point *pnt) { struct poi_data data; data.poi=p; if (p->type == 0) { data.page=p->h->cur_pg; data.row=p->table->cur_row-1; } if (p->type == 1) { data.row=p->pos; } display_add(&co->disp[display_poi], 5, 0, p->icon, 1, pnt, poi_info, &data, sizeof(data)); } static void plugin_draw(struct container *co) { struct coord c; struct point pnt; struct poi *p; struct index_data idx[2]; int use_index=0; int debug=1; p = poi_list; if (co->trans->scale > 1024) return; if (debug) { printf("scale=%ld\n", co->trans->scale); printf("rect 0x%lx,0%lx-0x%lx,0x%lx\n", co->trans->rect[0].x, co->trans->rect[0].y, co->trans->rect[1].x, co->trans->rect[1].y); } while (p) { if (p->type == 0) { if (use_index) setup_idx_rect(co->trans->rect, idx, p->idx_size); if (! use_index) { printf("rewind %s %p\n", p->filename, p->table); mdb_rewind_table(p->table); while (mdb_fetch_row(p->table)) { get_coord(p, &c); if (transform(co->trans, &c, &pnt)) { if (debug) printf("coord 0x%lx,0x%lx pg %d row %d\n", c.x, c.y, p->h->cur_pg, p->table->cur_row); draw_poi(p, co, &pnt); } } } else { memset(&p->chain, 0, sizeof(p->chain)); while (index_next(p, idx)) { get_coord(p, &c); if (transform(co->trans, &c, &pnt)) { if (debug) printf("coord 0x%lx,0x%lx pg %d row %d\n", c.x, c.y, p->h->cur_pg, p->table->cur_row); draw_poi(p, co, &pnt); } } } } if (p->type == 1) { FILE *f; char line[1024]; struct text_poi tpoi; if(!(f=fopen(p->filename, "r"))){ printf("can't open poi file for drawing!\n"); exit(0); } #if 0 printf("opened poi file %s for drawing!\n",p->filename); #endif p->pos=ftell(f); fgets(line, 1024, f); while (!feof(f)) { if (strlen(line)) { line[strlen(line)-1]='\0'; } if (parse_text_poi(line, &tpoi)) { transform_mercator(&tpoi.lat,&tpoi.lng,&c); // printf("%ld %ld\n", c.x, c.y); if (transform(co->trans, &c, &pnt)) { draw_poi(p, co, &pnt); } } p->pos=ftell(f); fgets(line, 1024, f); } fclose(f); } p = p->next; } } #endif static void map_destroy_poi_geodownload(struct map_priv *m) { dbg(1,"enter\n"); g_free(m); } static void poi_geodownload_coord_rewind(void *priv_data) { struct map_rect_priv *mr=priv_data; mr->cidx=0; } static int poi_geodownload_coord_get(void *priv_data, struct coord *c, int count) { struct map_rect_priv *mr=priv_data; dbg(1,"enter\n"); if (mr->cidx || !count) return 0; c->x=mdb_pg_get_int32(mr->m->h, mr->m->cols[0]->cur_value_start); c->y=mdb_pg_get_int32(mr->m->h, mr->m->cols[1]->cur_value_start); dbg(1,"x=0x%x y=0x%x\n", c->x, c->y); return 1; } static void poi_geodownload_attr_rewind(void *priv_data) { } static int poi_geodownload_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { dbg(1,"enter\n"); return 0; } static struct item_methods methods_poi_geodownload = { poi_geodownload_coord_rewind, poi_geodownload_coord_get, poi_geodownload_attr_rewind, poi_geodownload_attr_get, }; static struct map_rect_priv * map_rect_new_poi_geodownload(struct map_priv *map, struct map_selection *sel) { struct map_rect_priv *mr; dbg(1,"enter\n"); mr=g_new0(struct map_rect_priv, 1); mr->item.meth=&methods_poi_geodownload; mr->item.id_hi=0; mr->item.id_lo=0; mr->item.priv_data=mr; mr->item.type=map->type; mr->m=map; mdb_rewind_table(map->table); return mr; } static void map_rect_destroy_poi_geodownload(struct map_rect_priv *mr) { g_free(mr); } static struct item * map_rect_get_item_poi_geodownload(struct map_rect_priv *mr) { dbg(1,"enter\n"); if (mdb_fetch_row(mr->m->table)) return &mr->item; return NULL; } static struct item * map_rect_get_item_byid_poi_geodownload(struct map_rect_priv *mr, int id_hi, int id_lo) { return NULL; } static struct map_methods map_methods_poi_geodownload = { map_destroy_poi_geodownload, map_rect_new_poi_geodownload, map_rect_destroy_poi_geodownload, map_rect_get_item_poi_geodownload, map_rect_get_item_byid_poi_geodownload, }; static struct map_priv * map_new_poi_geodownload(struct map_methods *meth, char *filename, struct attr **attrs, char **charset, enum projection *pro) { struct map_priv *m; dbg(1,"filename %s\n",filename); MdbCatalogEntry *entry; GPtrArray *catalog; int i; struct attr *attr; *meth=map_methods_poi_geodownload; *charset="iso8859-1"; *pro=projection_mg; m=g_new(struct map_priv, 1); m->filename=g_strdup(filename); m->h = mdb_open(m->filename, MDB_NOFLAGS); m->type=type_none; dbg(1,"attr_search\n"); attr=attr_search(attrs, NULL, attr_item_type); dbg(1,"attr_search result %p\n", attr); if (attr) { m->type=attr->u.item_type; printf("type '%s'\n", item_to_name(m->type)); } catalog = mdb_read_catalog(m->h, MDB_TABLE); for (i = 0; i < catalog->len; i++) { entry = catalog->pdata[i]; dbg(1,"object name '%s'\n", entry->object_name); if (!strcasecmp(entry->object_name, "_INDEXDATA")) { if (load_poi_table(m, entry)) { printf("%s invalid\n", filename); g_free(m); m=NULL; } } } g_ptr_array_free(catalog, 1); return m; } void plugin_init(void) { dbg(1,"plugin_init\n"); plugin_register_map_type("poi_geodownload", map_new_poi_geodownload); } --- NEW FILE: Makefile.am --- SUBDIRS=libmdb include $(top_srcdir)/Makefile.inc AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/src -Ilibmdb/include -DMODULE=\"data_poi_geodownload\" moduledata_LTLIBRARIES = libdata_poi_geodownload.la libdata_poi_geodownload_la_SOURCES = poi_geodownload.c libdata_poi_geodownload_la_LIBADD = -Llibmdb -lmdb |
From: Martin S. <mar...@us...> - 2007-08-11 07:56:26
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload/libmdb/include In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24743/include Log Message: Directory /cvsroot/navit/navit/src/data/poi_geodownload/libmdb/include added to the repository |
From: Martin S. <mar...@us...> - 2007-08-11 07:54:38
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload/libmdb In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23625/libmdb Log Message: Directory /cvsroot/navit/navit/src/data/poi_geodownload/libmdb added to the repository |
From: Martin S. <mar...@us...> - 2007-08-11 07:53:38
|
Update of /cvsroot/navit/navit/src/data/poi_geodownload In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22815/poi_geodownload Log Message: Directory /cvsroot/navit/navit/src/data/poi_geodownload added to the repository |
From: Horwitz <ho...@us...> - 2007-08-10 12:07:16
|
Update of /cvsroot/navit/navit/src/gui/gtk In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18657/src/gui/gtk Modified Files: gui_gtk_action.c Log Message: add fullscreen option to display menu of main window Index: gui_gtk_action.c =================================================================== RCS file: /cvsroot/navit/navit/src/gui/gtk/gui_gtk_action.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** gui_gtk_action.c 22 Jul 2007 18:04:31 -0000 1.17 --- gui_gtk_action.c 10 Aug 2007 12:07:13 -0000 1.18 *************** *** 29,59 **** static void ! zoom_in_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_zoom_in(nav, 2); } static void ! zoom_out_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_zoom_out(nav, 2); } static void ! refresh_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_draw(nav); } static void ! roadbook_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_window_roadbook_new(nav); } static void ! cursor_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_toggle_cursor(nav); #if 0 ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); --- 29,59 ---- static void ! zoom_in_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_zoom_in(gui->nav, 2); } static void ! zoom_out_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_zoom_out(gui->nav, 2); } static void ! refresh_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_draw(gui->nav); } static void ! roadbook_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_window_roadbook_new(gui->nav); } static void ! cursor_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_toggle_cursor(gui->nav); #if 0 ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); *************** *** 62,68 **** static void ! tracking_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_toggle_tracking(nav); #if 0 ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); --- 62,68 ---- static void ! tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_toggle_tracking(gui->nav); #if 0 ac->gui->co->flags->track=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); *************** *** 71,75 **** static void ! orient_north_action(GtkWidget *w, struct navit *nav, void *dummy) { #if 0 --- 71,75 ---- static void ! orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { #if 0 *************** *** 78,81 **** --- 78,90 ---- } + static void + window_fullscreen_action(GtkWidget *w, struct gui_priv *gui, void *dummy) + { + if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) + gtk_window_fullscreen(GTK_WINDOW(gui->win)); + else + gtk_window_unfullscreen(GTK_WINDOW(gui->win)); + } + #include <stdlib.h> #include "point.h" *************** *** 83,87 **** static void ! info_action(GtkWidget *w, struct navit *nav, void *dummy) { char buffer[512]; --- 92,96 ---- static void ! info_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { char buffer[512]; *************** *** 91,95 **** struct transformation *t; ! t=navit_get_trans(nav); transform_get_size(t, &mw, &mh); p.x=0; --- 100,104 ---- struct transformation *t; ! t=navit_get_trans(gui->nav); transform_get_size(t, &mw, &mh); p.x=0; *************** *** 107,126 **** static void ! route_clear_action(GtkWidget *w, struct navit *nav, void *dummy) { ! navit_set_destination(nav, NULL, NULL); } static void ! destination_action(GtkWidget *w, struct navit *nav, void *dummy) { ! destination_address(nav); } static void ! quit_action (GtkWidget *w, struct navit *nav, void *dummy) { ! navit_destroy(nav); } --- 116,135 ---- static void ! route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_set_destination(gui->nav, NULL, NULL); } static void ! destination_action(GtkWidget *w, struct gui_priv *gui, void *dummy) { ! destination_address(gui->nav); } static void ! quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy) { ! navit_destroy(gui->nav); } *************** *** 195,199 **** { "CursorAction", "cursor_icon",_n("Cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE }, { "TrackingAction", NULL ,_n("Tracking"), NULL, NULL, G_CALLBACK(tracking_action),TRUE }, ! { "OrientationAction", "orientation_icon", _n("Orientation"), NULL, NULL, G_CALLBACK(orient_north_action),FALSE } }; --- 204,209 ---- { "CursorAction", "cursor_icon",_n("Cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE }, { "TrackingAction", NULL ,_n("Tracking"), NULL, NULL, G_CALLBACK(tracking_action),TRUE }, ! { "OrientationAction", "orientation_icon", _n("Orientation"), NULL, NULL, G_CALLBACK(orient_north_action),FALSE }, ! { "FullscreenAction",GTK_STOCK_FULLSCREEN, _n("Fullscreen"), NULL, NULL, G_CALLBACK(window_fullscreen_action), FALSE } }; *************** *** 346,349 **** --- 356,360 ---- <menuitem name=\"Orientation\" action=\"OrientationAction\"/>\ <menuitem name=\"Roadbook\" action=\"RoadbookAction\"/>\ + <menuitem name=\"Fullscreen\" action=\"FullscreenAction\"/>\ <menuitem name=\"Quit\" action=\"QuitAction\" />\ <placeholder name=\"RouteMenuAdditions\" />\ *************** *** 502,509 **** gtk_action_group_set_translation_domain(this->debug_group,"navit"); gtk_action_group_set_translation_domain(this->dyn_group,"navit"); ! gtk_action_group_add_actions (this->base_group, entries, n_entries, this->nav); ! gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this->nav); gtk_ui_manager_insert_action_group (this->menu_manager, this->base_group, 0); ! gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this->nav); gtk_ui_manager_insert_action_group (this->menu_manager, this->debug_group, 0); gtk_ui_manager_add_ui_from_string (this->menu_manager, layout, strlen(layout), &error); --- 513,520 ---- gtk_action_group_set_translation_domain(this->debug_group,"navit"); gtk_action_group_set_translation_domain(this->dyn_group,"navit"); ! gtk_action_group_add_actions (this->base_group, entries, n_entries, this); ! gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this); gtk_ui_manager_insert_action_group (this->menu_manager, this->base_group, 0); ! gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this); gtk_ui_manager_insert_action_group (this->menu_manager, this->debug_group, 0); gtk_ui_manager_add_ui_from_string (this->menu_manager, layout, strlen(layout), &error); |