Mercurial > libpst
comparison src/define.h @ 129:fc11b1d1ad34
fix initial from header in mbox format.
start moving to PST_LE_GET* rather than LE*_CPU macros so we can eventually remove the pragma packing.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 05 Feb 2009 12:09:04 -0800 |
parents | 7f747c8c9d02 |
children | e35fd42bac05 |
comparison
equal
deleted
inserted
replaced
128:7f747c8c9d02 | 129:fc11b1d1ad34 |
---|---|
7 | 7 |
8 #ifndef DEFINEH_H | 8 #ifndef DEFINEH_H |
9 #define DEFINEH_H | 9 #define DEFINEH_H |
10 | 10 |
11 #include "common.h" | 11 #include "common.h" |
12 #include "libpst.h" | |
13 #include "timeconv.h" | |
14 #include "libstrfunc.h" | |
15 #include "vbuf.h" | |
16 | |
17 | |
12 | 18 |
13 #ifdef HAVE_CONFIG_H | 19 #ifdef HAVE_CONFIG_H |
14 #include "config.h" | 20 #include "config.h" |
15 #endif | 21 #endif |
16 | 22 |
326 # error "Byte order not supported by this library" | 332 # error "Byte order not supported by this library" |
327 #endif // BYTE_ORDER | 333 #endif // BYTE_ORDER |
328 | 334 |
329 | 335 |
330 #define PST_LE_GET_UINT64(p) \ | 336 #define PST_LE_GET_UINT64(p) \ |
331 (uint64_t)((((uint8_t const *)(p))[0] << 0) | \ | 337 (uint64_t)((((uint8_t const *)(p))[0] << 0) | \ |
338 (((uint8_t const *)(p))[1] << 8) | \ | |
339 (((uint8_t const *)(p))[2] << 16) | \ | |
340 (((uint8_t const *)(p))[3] << 24) | \ | |
341 (((uint8_t const *)(p))[4] << 32) | \ | |
342 (((uint8_t const *)(p))[5] << 40) | \ | |
343 (((uint8_t const *)(p))[6] << 48) | \ | |
344 (((uint8_t const *)(p))[7] << 56)) | |
345 | |
346 #define PST_LE_GET_INT64(p) \ | |
347 (int64_t)((((uint8_t const *)(p))[0] << 0) | \ | |
332 (((uint8_t const *)(p))[1] << 8) | \ | 348 (((uint8_t const *)(p))[1] << 8) | \ |
333 (((uint8_t const *)(p))[2] << 16) | \ | 349 (((uint8_t const *)(p))[2] << 16) | \ |
334 (((uint8_t const *)(p))[3] << 24) | \ | 350 (((uint8_t const *)(p))[3] << 24) | \ |
335 (((uint8_t const *)(p))[4] << 32) | \ | 351 (((uint8_t const *)(p))[4] << 32) | \ |
336 (((uint8_t const *)(p))[5] << 40) | \ | 352 (((uint8_t const *)(p))[5] << 40) | \ |
337 (((uint8_t const *)(p))[6] << 48) | \ | 353 (((uint8_t const *)(p))[6] << 48) | \ |
338 (((uint8_t const *)(p))[7] << 56)) | 354 (((uint8_t const *)(p))[7] << 56)) |
339 | 355 |
340 #define PST_LE_GET_INT64(p) \ | |
341 (int64_t)((((uint8_t const *)(p))[0] << 0) | \ | |
342 (((uint8_t const *)(p))[1] << 8) | \ | |
343 (((uint8_t const *)(p))[2] << 16) | \ | |
344 (((uint8_t const *)(p))[3] << 24) | \ | |
345 (((uint8_t const *)(p))[4] << 32) | \ | |
346 (((uint8_t const *)(p))[5] << 40) | \ | |
347 (((uint8_t const *)(p))[6] << 48) | \ | |
348 (((uint8_t const *)(p))[7] << 56)) | |
349 | |
350 #define PST_LE_GET_UINT32(p) \ | 356 #define PST_LE_GET_UINT32(p) \ |
351 (uint32_t)((((uint8_t const *)(p))[0] << 0) | \ | 357 (uint32_t)((((uint8_t const *)(p))[0] << 0) | \ |
352 (((uint8_t const *)(p))[1] << 8) | \ | 358 (((uint8_t const *)(p))[1] << 8) | \ |
353 (((uint8_t const *)(p))[2] << 16) | \ | 359 (((uint8_t const *)(p))[2] << 16) | \ |
354 (((uint8_t const *)(p))[3] << 24)) | 360 (((uint8_t const *)(p))[3] << 24)) |
355 | 361 |
356 #define PST_LE_GET_INT32(p) \ | 362 #define PST_LE_GET_INT32(p) \ |
357 (int32_t)((((uint8_t const *)(p))[0] << 0) | \ | 363 (int32_t)((((uint8_t const *)(p))[0] << 0) | \ |
358 (((uint8_t const *)(p))[1] << 8) | \ | 364 (((uint8_t const *)(p))[1] << 8) | \ |
359 (((uint8_t const *)(p))[2] << 16) | \ | 365 (((uint8_t const *)(p))[2] << 16) | \ |
360 (((uint8_t const *)(p))[3] << 24)) | 366 (((uint8_t const *)(p))[3] << 24)) |
361 | 367 |
362 #define PST_LE_GET_UINT16(p) \ | 368 #define PST_LE_GET_UINT16(p) \ |
363 (uint16_t)((((uint8_t const *)(p))[0] << 0) | \ | 369 (uint16_t)((((uint8_t const *)(p))[0] << 0) | \ |
364 (((uint8_t const *)(p))[1] << 8)) | 370 (((uint8_t const *)(p))[1] << 8)) |
365 | 371 |
366 #define PST_LE_GET_INT16(p) \ | 372 #define PST_LE_GET_INT16(p) \ |
367 (int16_t)((((uint8_t const *)(p))[0] << 0) | \ | 373 (int16_t)((((uint8_t const *)(p))[0] << 0) | \ |
368 (((uint8_t const *)(p))[1] << 8)) | 374 (((uint8_t const *)(p))[1] << 8)) |
369 | 375 |
370 #define PST_LE_GET_UINT8(p) (*(uint8_t const *)(p)) | 376 #define PST_LE_GET_UINT8(p) (*(uint8_t const *)(p)) |
371 | 377 |
372 #define PST_LE_GET_INT8(p) (*(int8_t const *)(p)) | 378 #define PST_LE_GET_INT8(p) (*(int8_t const *)(p)) |
373 | 379 |
380 | |
381 // switch to maximal packing for our own internal structures | |
382 // use the same code as in common.h | |
383 #ifdef _MSC_VER | |
384 #pragma pack(push, 1) | |
385 #endif | |
386 #if defined(__GNUC__) || defined (__SUNPRO_C) || defined(__SUNPRO_CC) | |
387 #pragma pack(1) | |
388 #endif | |
389 | |
390 | |
391 | |
374 #endif //DEFINEH_H | 392 #endif //DEFINEH_H |