/[zanavi_public1]/navit/navit/data.h
ZANavi

Contents of /navit/navit/data.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 2256 byte(s)
import files
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library 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 Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License 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
20 #ifndef NAVIT_DATA_H
21 #define NAVIT_DATA_H
22
23 #include "config.h"
24
25 #ifdef WORDS_BIGENDIAN
26 #include <byteswap.h>
27 #endif
28
29 static inline unsigned char
30 get_u8(unsigned char **p)
31 {
32 return *((*p)++);
33 }
34
35 static inline unsigned short
36 get_u16(unsigned char **p) {
37 unsigned short ret;
38 ret=*((unsigned short *)*p);
39 *p+=sizeof(unsigned short);
40 #ifdef WORDS_BIGENDIAN
41 return __bswap_16(ret);
42 #else
43 return ret;
44 #endif
45 }
46
47 static inline unsigned short
48 get_u16_unal(unsigned char **p) {
49 unsigned short ret;
50 ret=*(*p)++;
51 ret|=(*(*p)++) << 8;
52 return ret;
53 }
54
55
56 static inline unsigned int
57 get_u24(unsigned char **p) {
58 unsigned long ret;
59 ret=get_u16(p);
60 ret|=*((*p)++) << 16;
61 return ret;
62 }
63
64
65 static inline unsigned int
66 get_u24_unal(unsigned char **p) {
67 unsigned long ret;
68 ret=get_u16_unal(p);
69 ret|=*((*p)++) << 16;
70 return ret;
71 }
72
73
74 static inline unsigned int
75 get_u32(unsigned char **p) {
76 unsigned long ret;
77 ret=*((unsigned int *)*p);
78 *p+=sizeof(unsigned int);
79 #ifdef WORDS_BIGENDIAN
80 return __bswap_32(ret);
81 #else
82 return ret;
83 #endif
84 }
85
86 static inline unsigned int
87 get_u32_unal(unsigned char **p) {
88 unsigned long ret;
89 ret=*(*p)++;
90 ret|=(*(*p)++) << 8;
91 ret|=(*(*p)++) << 16;
92 ret|=(*(*p)++) << 24;
93 return ret;
94 }
95
96 static inline char *
97 get_string(unsigned char **p)
98 {
99 char *ret=(char *)(*p);
100 while (**p) (*p)++;
101 (*p)++;
102 return ret;
103 }
104
105 #define L(x) ({ unsigned char *t=(unsigned char *)&(x); t[0] | (t[1] << 8) | (t[2] << 16) | (t[3] << 24); })
106
107 #endif
108

   
Visit the ZANavi Wiki