]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
1c79356b | 11 | * |
de355530 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | #ifndef __HFS_ENDIAN_H__ | |
23 | #define __HFS_ENDIAN_H__ | |
24 | ||
9bccf70c A |
25 | #include <sys/appleapiopts.h> |
26 | ||
27 | #ifdef KERNEL | |
28 | #ifdef __APPLE_API_PRIVATE | |
1c79356b A |
29 | /* |
30 | * hfs_endian.h | |
31 | * | |
32 | * This file prototypes endian swapping routines for the HFS/HFS Plus | |
33 | * volume format. | |
34 | */ | |
35 | #include "hfs.h" | |
36 | #include "hfscommon/headers/BTreesInternal.h" | |
37 | #include <architecture/byte_order.h> | |
38 | ||
39 | /*********************/ | |
40 | /* BIG ENDIAN Macros */ | |
41 | /*********************/ | |
42 | #if BYTE_ORDER == BIG_ENDIAN | |
43 | ||
44 | /* HFS is always big endian, make swaps into no-ops */ | |
45 | #define SWAP_BE16(__a) (__a) | |
46 | #define SWAP_BE32(__a) (__a) | |
47 | #define SWAP_BE64(__a) (__a) | |
48 | ||
49 | /* HFS is always big endian, no swapping needed */ | |
50 | #define SWAP_HFS_PLUS_FORK_DATA(__a) | |
51 | #define SWAP_BT_NODE(__a, __b, __c) | |
52 | ||
53 | /************************/ | |
54 | /* LITTLE ENDIAN Macros */ | |
55 | /************************/ | |
56 | #elif BYTE_ORDER == LITTLE_ENDIAN | |
57 | ||
58 | /* HFS is always big endian, make swaps actually swap */ | |
59 | #define SWAP_BE16(__a) NXSwapBigShortToHost (__a) | |
60 | #define SWAP_BE32(__a) NXSwapBigLongToHost (__a) | |
61 | #define SWAP_BE64(__a) NXSwapBigLongLongToHost (__a) | |
62 | ||
63 | #define SWAP_HFS_PLUS_FORK_DATA(__a) hfs_swap_HFSPlusForkData ((__a)) | |
64 | #define SWAP_BT_NODE(__a, __b, __c, __d) hfs_swap_BTNode ((__a), (__b), (__c), (__d)) | |
65 | ||
66 | #else | |
67 | #warning Unknown byte order | |
68 | #error | |
69 | #endif | |
70 | ||
71 | #ifdef __cplusplus | |
72 | extern "C" { | |
73 | #endif | |
74 | ||
75 | void hfs_swap_HFSPlusForkData (HFSPlusForkData *src); | |
76 | int hfs_swap_BTNode (BlockDescriptor *src, int isHFSPlus, HFSCatalogNodeID fileID, int unswap); | |
77 | ||
78 | #ifdef __cplusplus | |
79 | } | |
80 | #endif | |
81 | ||
9bccf70c A |
82 | #endif /* __APPLE_API_PRIVATE */ |
83 | #endif /* KERNEL */ | |
1c79356b | 84 | #endif /* __HFS_FORMAT__ */ |