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 |
struct item_bin *
|
29 |
read_item(FILE *in)
|
30 |
{
|
31 |
struct item_bin *ib=(struct item_bin *) buffer;
|
32 |
for (;;) {
|
33 |
switch (item_bin_read(ib, in)) {
|
34 |
case 0:
|
35 |
return NULL;
|
36 |
case 2:
|
37 |
dbg_assert((ib->len+1)*4 < sizeof(buffer));
|
38 |
bytes_read+=(ib->len+1)*sizeof(int);
|
39 |
return ib;
|
40 |
default:
|
41 |
continue;
|
42 |
}
|
43 |
}
|
44 |
}
|
45 |
|
46 |
struct item_bin *
|
47 |
read_item_range(FILE *in, int *min, int *max)
|
48 |
{
|
49 |
struct range r;
|
50 |
|
51 |
if (fread(&r, sizeof(r), 1, in) != 1)
|
52 |
return NULL;
|
53 |
*min=r.min;
|
54 |
*max=r.max;
|
55 |
return read_item(in);
|
56 |
}
|
57 |
|
58 |
struct item_bin *
|
59 |
init_item(enum item_type type)
|
60 |
{
|
61 |
struct item_bin *ib=(struct item_bin *) buffer;
|
62 |
|
63 |
item_bin_init(ib, type);
|
64 |
return ib;
|
65 |
}
|