udftools

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
udf_endian.h
Go to the documentation of this file.
1 /*
2 * udf_endian.h
3 *
4 * Copyright (c) 2001-2002 Ben Fennema <bfennema@falcon.csc.calpoly.edu>
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23 #ifndef __UDF_ENDIAN_H
24 #define __UDF_ENDIAN_H
25
26 #include <string.h>
27
28 #include "bswap.h"
29
30 static inline lb_addr lelb_to_cpu(lb_addr in)
31 {
32 lb_addr out;
33 out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
34 out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
35 return out;
36 }
37
38 static inline lb_addr cpu_to_lelb(lb_addr in)
39 {
40 lb_addr out;
41 out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
42 out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
43 return out;
44 }
45
46 static inline timestamp lets_to_cpu(timestamp in)
47 {
48 timestamp out;
49 memcpy(&out, &in, sizeof(timestamp));
50 out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
51 out.year = le16_to_cpu(in.year);
52 return out;
53 }
54
55 static inline short_ad lesa_to_cpu(short_ad in)
56 {
57 short_ad out;
58 out.extLength = le32_to_cpu(in.extLength);
59 out.extPosition = le32_to_cpu(in.extPosition);
60 return out;
61 }
62
63 static inline short_ad cpu_to_lesa(short_ad in)
64 {
65 short_ad out;
66 out.extLength = cpu_to_le32(in.extLength);
67 out.extPosition = cpu_to_le32(in.extPosition);
68 return out;
69 }
70
71 static inline long_ad lela_to_cpu(long_ad in)
72 {
73 long_ad out;
74 out.extLength = le32_to_cpu(in.extLength);
75 out.extLocation = lelb_to_cpu(in.extLocation);
76 return out;
77 }
78
79 static inline long_ad cpu_to_lela(long_ad in)
80 {
81 long_ad out;
82 out.extLength = cpu_to_le32(in.extLength);
83 out.extLocation = cpu_to_lelb(in.extLocation);
84 return out;
85 }
86
87 static inline extent_ad leea_to_cpu(extent_ad in)
88 {
89 extent_ad out;
90 out.extLength = le32_to_cpu(in.extLength);
91 out.extLocation = le32_to_cpu(in.extLocation);
92 return out;
93 }
94
95 static inline timestamp cpu_to_lets(timestamp in)
96 {
97 timestamp out;
98 memcpy(&out, &in, sizeof(timestamp));
99 out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
100 out.year = cpu_to_le16(in.year);
101 return out;
102 }
103
104 #endif /* __UDF_ENDIAN_H */
cpu_to_lets
static timestamp cpu_to_lets(timestamp in)
Definition: udf_endian.h:95
cpu_to_lela
static long_ad cpu_to_lela(long_ad in)
Definition: udf_endian.h:79
cpu_to_le32
#define cpu_to_le32(x)
Definition: bswap.h:247
leea_to_cpu
static extent_ad leea_to_cpu(extent_ad in)
Definition: udf_endian.h:87
cpu_to_le16
#define cpu_to_le16(x)
Definition: bswap.h:246
lesa_to_cpu
static short_ad lesa_to_cpu(short_ad in)
Definition: udf_endian.h:55
cpu_to_lelb
static lb_addr cpu_to_lelb(lb_addr in)
Definition: udf_endian.h:38
lela_to_cpu
static long_ad lela_to_cpu(long_ad in)
Definition: udf_endian.h:71
bswap.h
cpu_to_lesa
static short_ad cpu_to_lesa(short_ad in)
Definition: udf_endian.h:63
lelb_to_cpu
static lb_addr lelb_to_cpu(lb_addr in)
Definition: udf_endian.h:30
lets_to_cpu
static timestamp lets_to_cpu(timestamp in)
Definition: udf_endian.h:46