1
2
3
4
5
6
7
8
9gd_alter_endianness(3)              GETDATA             gd_alter_endianness(3)
10
11
12

NAME

14       gd_alter_endianness — modify the byte sex of fields in a Dirfile
15
16

SYNOPSIS

18       #include <getdata.h>
19
20       int gd_alter_endianness(DIRFILE *dirfile, unsigned long byte_sex, int
21              fragment_index, int recode);
22
23

DESCRIPTION

25       The gd_alter_endianness() function sets the  byte  sex  of  the  format
26       specification  fragment  given  by  fragment_index  to  byte_sex in the
27       dirfile(5) database specified by dirfile.  The byte sex of  a  fragment
28       indicate  the endianness of data stored in binary files associated with
29       RAW fields defined in the specified fragment.  The byte sex of a  frag‐
30       ment containing no RAW fields is ignored.
31
32       The byte_sex argument should be one of the following:
33
34       0 (zero)
35               Indicating that the byte sex should be the native endianness of
36               the host, whichever that may be.
37
38       GD_BIG_ENDIAN
39               Indicating that the byte sex should be big endian.
40
41       GD_LITTLE_ENDIAN
42               Indicating that the byte sex should be little endian.
43
44       (GD_BIG_ENDIAN | GD_LITTLE_ENDIAN)
45               Indicating that the byte sex should be the opposite of the  na‐
46               tive endianness of the host, whichever that may be.
47
48       Furthermore,  any  of  these  may be bitwise or'd with GD_ARM_ENDIAN or
49       GD_NOT_ARM_ENDIAN indicating that the floating point data are stored in
50       the ARM middle-endian format.
51
52       In  addition to being simply a valid fragment index, fragment_index may
53       also be the special value GD_ALL_FRAGMENTS, which  indicates  that  the
54       byte sex of all fragments in the database should be changed.
55
56       If the recode argument is non-zero, this call will byte swap the binary
57       data of affected RAW fields to account for the change in byte sex.   If
58       the  encoding of the fragment is endianness insensitive, or if the data
59       type is only one byte in size, no change is made.  The I/O  pointer  of
60       all affected RAW fields is reset to the beginning-of-frame.
61
62       If recode is zero, affected binary files are left untouched.
63
64

RETURN VALUE

66       Upon successful completion, gd_alter_endianness() returns zero.  On er‐
67       ror, it returns a negative-valued error  code.   Possible  error  codes
68       are:
69
70       GD_E_ACCMODE
71               The specified dirfile was opened read-only.
72
73       GD_E_ALLOC
74               The library was unable to allocate memory.
75
76       GD_E_ARGUMENT
77               The supplied byte_sex was invalid.
78
79       GD_E_BAD_DIRFILE
80               The supplied dirfile was invalid.
81
82       GD_E_BAD_INDEX
83               The supplied index was out of range.
84
85       GD_E_IO An  I/O  error  occurred while attempting to byte swap a binary
86               file.
87
88       GD_E_PROTECTED
89               The metadata of the indicated format specification fragment was
90               protected  from  change, or the binary data of the fragment was
91               protected from change and binary file  byte  swapping  was  re‐
92               quested.
93
94       GD_E_UNCLEAN_DB
95               An  error  occurred  while  moving  the  byte-swapped file into
96               place.  As a result, the database may be in an  unclean  state.
97               See the NOTES section below for recovery instructions.  In this
98               case, the dirfile will be flagged as invalid, to  prevent  fur‐
99               ther database corruption.  It should be immediately closed.
100
101       GD_E_UNKNOWN_ENCODING
102               The encoding scheme of the fragment is unknown.
103
104       GD_E_UNSUPPORTED
105               The  encoding  scheme  of  the fragment does not support binary
106               file byte swapping.
107
108       The error code is also stored in the DIRFILE  object  and  may  be  re‐
109       trieved after this function returns by calling gd_error(3).  A descrip‐
110       tive  error  string  for  the  error  may  be   obtained   by   calling
111       gd_error_string(3).
112
113

NOTES

115       A  binary  file byte swap occurs out-of-place.  As a result, sufficient
116       space must be present on the filesystem for the binary files of all RAW
117       fields in the fragment both before and after translation.  If all frag‐
118       ments are updated by specifying GD_ALL_FRAGMENTS, the byte swapping oc‐
119       curs one fragment at a time.
120
121       An  error  code  of  GD_E_UNCLEAN_DB  indicates a system error occurred
122       while moving the byte-swapped binary data into place or  when  deleting
123       the  old data.  If this happens, the database may be left in an unclean
124       state.  The caller should check the filesystem  directly  to  ascertain
125       the state of the dirfile data before continuing.  For recovery instruc‐
126       tions,  see  the  file   /usr/share/doc/getdata/unclean_database_recov‐
127       ery.txt.
128
129

HISTORY

131       The function dirfile_alter_endianness() appeared in GetData-0.5.0.
132
133       In  GetData-0.7.0,  this function was renamed to gd_alter_endianness().
134       The GD_E_ARM_ENDIAN and GD_NOT_ARM_ENDIAN flags also appeared  in  this
135       version.
136
137       in  GetData-0.10.0, the error return from this function changed from -1
138       to a negative-valued error code.
139
140

SEE ALSO

142       gd_open(3),    gd_error(3),    gd_error_string(3),    gd_endianness(3),
143       dirfile(5), dirfile-format(5)
144
145
146
147Version 0.10.0                 25 December 2016         gd_alter_endianness(3)
Impressum