Debian Codegraph @

src/bniutils/fileio.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2000 Marco Ziech ([email protected])
3 Copyright (C) 2000 Ross Combs ([email protected])
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
20 #include "fileio.h"cxx . . $ `<file>/src/bniutils/fileio.h`/
21
22 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
23 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
24
25 namespace pvpgncxx . . $ pvpgn/
26 {
27
28 namespace bnicxx . . $ pvpgn/bni/
29 {
30
31 typedef struct t_filecxx . . $ pvpgn/bni/t_file# {
32 std::FILEcxx . . $ std/FILE# *fcxx . . $ pvpgn/bni/t_file#f.;
33 struct t_filecxx . . $ pvpgn/bni/t_file# *nextcxx . . $ pvpgn/bni/t_file#next.;
34 } t_filecxx . . $ pvpgn/bni/t_file#;
35
36 namespacecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/
37 {
38
39 t_filecxx . . $ pvpgn/bni/t_file# *r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
40 t_filecxx . . $ pvpgn/bni/t_file# *w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
41
42 }
43
44 /* ----------------------------------------------------------------- */
45
46 extern void file_rpushcxx . . $ pvpgn/bni/file_rpush(8d4262d45fc644ab).(std::FILEcxx . . $ std/FILE# *f) {
47 t_filecxx . . $ pvpgn/bni/t_file# *tf = (t_filecxx . . $ pvpgn/bni/t_file#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_file));
48 tf->nextcxx . . $ pvpgn/bni/t_file#next. = r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.;
49 tf->fcxx . . $ pvpgn/bni/t_file#f. = f;
50 r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file. = tf;
51 return;
52 }
53
54 extern void file_rpopcxx . . $ pvpgn/bni/file_rpop(49f6e7a06ebc5aa8).(void) {
55 t_filecxx . . $ pvpgn/bni/t_file# *tf;
56 tf = r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.;
57 r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file. = tf->nextcxx . . $ pvpgn/bni/t_file#next.;
58 xfreecxx . . $ `src/common/xalloc.h:51:9`!(tf);
59 return;
60 }
61
62 /* ----------------------------------------------------------------- */
63
64 extern void file_wpushcxx . . $ pvpgn/bni/file_wpush(8d4262d45fc644ab).(std::FILEcxx . . $ std/FILE# *f) {
65 t_filecxx . . $ pvpgn/bni/t_file# *tf = (t_filecxx . . $ pvpgn/bni/t_file#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_file));
66 tf->nextcxx . . $ pvpgn/bni/t_file#next. = w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.;
67 tf->fcxx . . $ pvpgn/bni/t_file#f. = f;
68 w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file. = tf;
69 return;
70 }
71
72 extern void file_wpopcxx . . $ pvpgn/bni/file_wpop(49f6e7a06ebc5aa8).(void) {
73 t_filecxx . . $ pvpgn/bni/t_file# *tf;
74 tf = w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.;
75 w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file. = tf->nextcxx . . $ pvpgn/bni/t_file#next.;
76 xfreecxx . . $ `src/common/xalloc.h:51:9`!(tf);
77 return;
78 }
79
80 /* ----------------------------------------------------------------- */
81
82 extern std::uint8_tcxx . . $ std/uint8_t# file_readbcxx . . $ pvpgn/bni/file_readb(7c4be072098b358f).(void) {
83 unsigned char buff[1];
84 if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff, 1, sizeof(buff), r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
85 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_readb: std::fread");
86 return 0;
87 }
88 return (((std::uint8_tcxx . . $ std/uint8_t#)buff[0]));
89 }
90
91
92 extern std::uint16_tcxx . . $ std/uint16_t# file_readw_lecxx . . $ pvpgn/bni/file_readw_le(32a7769d58713265).(void) {
93 unsigned char buff[2];
94 if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff, 1, sizeof(buff), r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
95 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_readw_le: std::fread");
96 return 0;
97 }
98 return (((std::uint16_tcxx . . $ std/uint16_t#)buff[0])) |
99 (((std::uint16_tcxx . . $ std/uint16_t#)buff[1]) << 8);
100 }
101
102
103 extern std::uint16_tcxx . . $ std/uint16_t# file_readw_becxx . . $ pvpgn/bni/file_readw_be(32a7769d58713265).(void) {
104 unsigned char buff[2];
105 if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff, 1, sizeof(buff), r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
106 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_readw_be: std::fread");
107 return 0;
108 }
109 return (((std::uint16_tcxx . . $ std/uint16_t#)buff[0]) << 8) |
110 (((std::uint16_tcxx . . $ std/uint16_t#)buff[1]));
111 }
112
113
114 extern std::uint32_tcxx . . $ std/uint32_t# file_readd_lecxx . . $ pvpgn/bni/file_readd_le(db52760e79bf9054).(void) {
115 unsigned char buff[4];
116 if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff, 1, sizeof(buff), r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
117 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_readd_le: std::fread");
118 return 0;
119 }
120 return (((std::uint32_tcxx . . $ std/uint32_t#)buff[0])) |
121 (((std::uint32_tcxx . . $ std/uint32_t#)buff[1]) << 8) |
122 (((std::uint32_tcxx . . $ std/uint32_t#)buff[2]) << 16) |
123 (((std::uint32_tcxx . . $ std/uint32_t#)buff[3]) << 24);
124 }
125
126
127 extern std::uint32_tcxx . . $ std/uint32_t# file_readd_becxx . . $ pvpgn/bni/file_readd_be(db52760e79bf9054).(void) {
128 unsigned char buff[4];
129 if (std::freadcxx . . $ std/fread(738fc8ac1d711e58).(buff, 1, sizeof(buff), r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
130 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(r_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/r_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_readd_be: std::fread");
131 return 0;
132 }
133 return (((std::uint32_tcxx . . $ std/uint32_t#)buff[0]) << 24) |
134 (((std::uint32_tcxx . . $ std/uint32_t#)buff[1]) << 16) |
135 (((std::uint32_tcxx . . $ std/uint32_t#)buff[2]) << 8) |
136 (((std::uint32_tcxx . . $ std/uint32_t#)buff[3]));
137 }
138
139
140 extern int file_writebcxx . . $ pvpgn/bni/file_writeb(b27dbea426b7b93).(std::uint8_tcxx . . $ std/uint8_t# u) {
141 unsigned char buff[1];
142 buff[0] = (u);
143 if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buff, 1, sizeof(buff), w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
144 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_writeb: std::fwrite");
145 return -1;
146 }
147 return 0;
148 }
149
150
151 extern int file_writew_lecxx . . $ pvpgn/bni/file_writew_le(377f6a3136964dac).(std::uint16_tcxx . . $ std/uint16_t# u) {
152 unsigned char buff[2];
153 buff[0] = (u);
154 buff[1] = (u >> 8);
155 if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buff, 1, sizeof(buff), w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
156 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_writew_le: std::fwrite");
157 return -1;
158 }
159 return 0;
160 }
161
162
163 extern int file_writew_becxx . . $ pvpgn/bni/file_writew_be(377f6a3136964dac).(std::uint16_tcxx . . $ std/uint16_t# u) {
164 unsigned char buff[2];
165 buff[0] = (u >> 8);
166 buff[1] = (u);
167 if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buff, 1, sizeof(buff), w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
168 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_writew_be: std::fwrite");
169 return -1;
170 }
171 return 0;
172 }
173
174
175 extern int file_writed_lecxx . . $ pvpgn/bni/file_writed_le(4c679297bf94b9eb).(std::uint32_tcxx . . $ std/uint32_t# u) {
176 unsigned char buff[4];
177 buff[0] = (u);
178 buff[1] = (u >> 8);
179 buff[2] = (u >> 16);
180 buff[3] = (u >> 24);
181 if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buff, 1, sizeof(buff), w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
182 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_writed_le: std::fwrite");
183 return -1;
184 }
185 return 0;
186 }
187
188
189 extern int file_writed_becxx . . $ pvpgn/bni/file_writed_be(4c679297bf94b9eb).(std::uint32_tcxx . . $ std/uint32_t# u) {
190 unsigned char buff[4];
191 buff[0] = (u >> 24);
192 buff[1] = (u >> 16);
193 buff[2] = (u >> 8);
194 buff[3] = (u);
195 if (std::fwritecxx . . $ std/fwrite(ab0609fa07c47d6e).(buff, 1, sizeof(buff), w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.) < sizeof(buff)) {
196 if (std::ferrorcxx . . $ std/ferror(7a688d7338757b98).(w_filecxx . . $ pvpgn/bni/`$anonymous_namespace_src/bniutils/fileio.cpp`/w_file.->fcxx . . $ pvpgn/bni/t_file#f.)) std::perrorcxx . . $ std/perror(85c52e162fed56f9).("file_writed_be: std::fwrite");
197 return -1;
198 }
199 return 0;
200 }
201
202 }
203
204 }