/[zanavi_public1]/navit/navit/maptool/itembin_buffer.c
ZANavi

Contents of /navit/navit/maptool/itembin_buffer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations) (download)
Sat Mar 8 17:10:49 2014 UTC (10 years, 1 month ago) by zoff99
File MIME type: text/plain
File size: 1774 byte(s)
new market version, lots of new features
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2011 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19 #include <string.h>
20 #include <stdlib.h>
21 #include "maptool.h"
22 #include "debug.h"
23
24
25 static char buffer[800000];
26 struct item_bin *item_bin=(struct item_bin *)(void *)buffer;
27
28 static struct node_item *node_item=(struct node_item *)(void *)buffer;
29
30 struct node_item *
31 read_node_item(FILE *in)
32 {
33 if (fread(node_item, sizeof(struct node_item), 1, in) != 1)
34 return NULL;
35 return node_item;
36 }
37
38 struct item_bin *
39 read_item(FILE *in)
40 {
41 struct item_bin *ib=(struct item_bin *) buffer;
42 for (;;) {
43 switch (item_bin_read(ib, in)) {
44 case 0:
45 return NULL;
46 case 2:
47 dbg_assert((ib->len+1)*4 < sizeof(buffer));
48 bytes_read+=(ib->len+1)*sizeof(int);
49 return ib;
50 default:
51 continue;
52 }
53 }
54 }
55
56 struct item_bin *
57 read_item_range(FILE *in, int *min, int *max)
58 {
59 struct range r;
60
61 if (fread(&r, sizeof(r), 1, in) != 1)
62 return NULL;
63 *min=r.min;
64 *max=r.max;
65 return read_item(in);
66 }
67
68 struct item_bin *
69 init_item(enum item_type type)
70 {
71 struct item_bin *ib=(struct item_bin *) buffer;
72
73 item_bin_init(ib, type);
74 return ib;
75 }

   
Visit the ZANavi Wiki