navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
data.h
Go to the documentation of this file.
1 
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 
unsigned char p[5]
Definition: mg.h:48
static unsigned int get_u32_unal(unsigned char **p)
Definition: data.h:87
static char * get_string(unsigned char **p)
Definition: data.h:97
static unsigned int get_u24_unal(unsigned char **p)
Definition: data.h:66
#define __bswap_16(__bsx)
Definition: endianess.h:86
static unsigned int get_u24(unsigned char **p)
Definition: data.h:57
static unsigned char get_u8(unsigned char **p)
Definition: data.h:30
static unsigned short get_u16_unal(unsigned char **p)
Definition: data.h:48
static unsigned short get_u16(unsigned char **p)
Definition: data.h:36
static unsigned int get_u32(unsigned char **p)
Definition: data.h:75
typedef int(WINAPI *FP_SetStretchBltMode)(HDC dc
#define __bswap_32(__bsx)
Definition: endianess.h:87