129 quit: |
129 quit: |
130 return NULL; |
130 return NULL; |
131 } |
131 } |
132 |
132 |
133 #ifdef _WIN32 |
133 #ifdef _WIN32 |
134 # ifdef _MSC_VER |
134 #ifdef _MSC_VER |
135 /* msvc 6.0 has problems */ |
135 /* msvc 6.0 has problems */ |
136 # define inline __inline |
136 #define inline __inline |
137 typedef unsigned long uint32_t; |
137 typedef unsigned long uint32_t; |
138 typedef unsigned __int64 uint64_t; |
138 typedef unsigned __int64 uint64_t; |
139 # else |
139 #else |
140 # include <stdint.h> |
140 #include <stdint.h> |
141 # endif |
141 #endif |
142 static uint32_t ntohl(uint32_t x) |
142 static uint32_t ntohl(uint32_t x) |
143 { |
143 { |
144 return ((x & 0x000000ffUL) << 24) | |
144 return ((x & 0x000000ffUL) << 24) | |
145 ((x & 0x0000ff00UL) << 8) | |
145 ((x & 0x0000ff00UL) << 8) | |
146 ((x & 0x00ff0000UL) >> 8) | |
146 ((x & 0x00ff0000UL) >> 8) | |
147 ((x & 0xff000000UL) >> 24); |
147 ((x & 0xff000000UL) >> 24); |
148 } |
148 } |
149 #else |
149 #else |
150 /* not windows */ |
150 /* not windows */ |
151 # include <sys/types.h> |
151 #include <sys/types.h> |
152 # if defined __BEOS__ && !defined __HAIKU__ |
152 #if defined __BEOS__ && !defined __HAIKU__ |
153 # include <ByteOrder.h> |
153 #include <ByteOrder.h> |
154 # else |
154 #else |
155 # include <arpa/inet.h> |
155 #include <arpa/inet.h> |
156 # endif |
156 #endif |
157 # include <inttypes.h> |
157 #include <inttypes.h> |
158 #endif |
158 #endif |
159 |
159 |
160 static PyObject *parse_dirstate(PyObject *self, PyObject *args) |
160 static PyObject *parse_dirstate(PyObject *self, PyObject *args) |
161 { |
161 { |
162 PyObject *dmap, *cmap, *parents = NULL, *ret = NULL; |
162 PyObject *dmap, *cmap, *parents = NULL, *ret = NULL; |
301 memcpy(decode, data, 64); |
301 memcpy(decode, data, 64); |
302 offset_flags = ntohl(*((uint32_t *) (decode + 4))); |
302 offset_flags = ntohl(*((uint32_t *) (decode + 4))); |
303 if (n == 0) /* mask out version number for the first entry */ |
303 if (n == 0) /* mask out version number for the first entry */ |
304 offset_flags &= 0xFFFF; |
304 offset_flags &= 0xFFFF; |
305 else { |
305 else { |
306 uint32_t offset_high = ntohl(*((uint32_t *) decode)); |
306 uint32_t offset_high = ntohl(*((uint32_t *)decode)); |
307 offset_flags |= ((uint64_t) offset_high) << 32; |
307 offset_flags |= ((uint64_t)offset_high) << 32; |
308 } |
308 } |
309 |
309 |
310 comp_len = ntohl(*((uint32_t *) (decode + 8))); |
310 comp_len = ntohl(*((uint32_t *)(decode + 8))); |
311 uncomp_len = ntohl(*((uint32_t *) (decode + 12))); |
311 uncomp_len = ntohl(*((uint32_t *)(decode + 12))); |
312 base_rev = ntohl(*((uint32_t *) (decode + 16))); |
312 base_rev = ntohl(*((uint32_t *)(decode + 16))); |
313 link_rev = ntohl(*((uint32_t *) (decode + 20))); |
313 link_rev = ntohl(*((uint32_t *)(decode + 20))); |
314 parent_1 = ntohl(*((uint32_t *) (decode + 24))); |
314 parent_1 = ntohl(*((uint32_t *)(decode + 24))); |
315 parent_2 = ntohl(*((uint32_t *) (decode + 28))); |
315 parent_2 = ntohl(*((uint32_t *)(decode + 28))); |
316 c_node_id = decode + 32; |
316 c_node_id = decode + 32; |
317 |
317 |
318 entry = _build_idx_entry(nodemap, n, offset_flags, |
318 entry = _build_idx_entry(nodemap, n, offset_flags, |
319 comp_len, uncomp_len, base_rev, |
319 comp_len, uncomp_len, base_rev, |
320 link_rev, parent_1, parent_2, |
320 link_rev, parent_1, parent_2, |