/[public]/psiconv/trunk/lib/psiconv/parse_simple.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_simple.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 110 Revision 182
24#include <math.h> 24#include <math.h>
25 25
26#include "parse_routines.h" 26#include "parse_routines.h"
27#include "error.h" 27#include "error.h"
28 28
29#ifdef DMALLOC
30#include <dmalloc.h>
31#endif
32
33static psiconv_float_t pow2(int n);
34static psiconv_string_t psiconv_read_string_aux(const psiconv_config config,
35 const psiconv_buffer buf,int lev,
36 psiconv_u32 off,int *length, int *status,
37 int kind);
38
39/* Very inefficient, but good enough for now. By implementing it ourselves,
40 we do not have to link with -lm */
41psiconv_float_t pow2(int n)
42{
43 psiconv_float_t res=1.0;
44 int i;
45
46 for (i = 0; i < (n<0?-n:n); i++)
47 res *= 2.0;
48
49 return n<0?1/res:res;
50}
29psiconv_u8 psiconv_read_u8(const psiconv_buffer buf,int lev,psiconv_u32 off, 51psiconv_u8 psiconv_read_u8(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
30 int *status) 52 int *status)
31{ 53{
32 psiconv_u8 *ptr; 54 psiconv_u8 *ptr;
33 ptr = psiconv_buffer_get(buf,off); 55 ptr = psiconv_buffer_get(buf,off);
34 if (!ptr) { 56 if (!ptr) {
35 psiconv_warn(lev,off,"Trying byte read past the end of the file"); 57 psiconv_warn(config,lev,off,"Trying byte read past the end of the file");
36 if (status) 58 if (status)
37 *status = -PSICONV_E_PARSE; 59 *status = -PSICONV_E_PARSE;
38 return 0; 60 return 0;
39 } 61 }
40 if (status) 62 if (status)
41 *status = 0; 63 *status = 0;
42 return *ptr; 64 return *ptr;
43} 65}
44 66
45psiconv_u16 psiconv_read_u16(const psiconv_buffer buf,int lev,psiconv_u32 off, 67psiconv_u16 psiconv_read_u16(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
46 int *status) 68 int *status)
47{ 69{
48 psiconv_u8 *ptr0,*ptr1; 70 psiconv_u8 *ptr0,*ptr1;
49 ptr0 = psiconv_buffer_get(buf,off); 71 ptr0 = psiconv_buffer_get(buf,off);
50 ptr1 = psiconv_buffer_get(buf,off+1); 72 ptr1 = psiconv_buffer_get(buf,off+1);
51 if (!ptr0 || !ptr1) { 73 if (!ptr0 || !ptr1) {
52 psiconv_warn(lev,off,"Trying word read past the end of the file"); 74 psiconv_warn(config,lev,off,"Trying word read past the end of the file");
53 if (status) 75 if (status)
54 *status = -PSICONV_E_PARSE; 76 *status = -PSICONV_E_PARSE;
55 return 0; 77 return 0;
56 } 78 }
57 if (status) 79 if (status)
58 *status = 0; 80 *status = 0;
59 return *ptr0 + (*ptr1 << 8); 81 return *ptr0 + (*ptr1 << 8);
60} 82}
61 83
62psiconv_u32 psiconv_read_u32(const psiconv_buffer buf,int lev,psiconv_u32 off, 84psiconv_u32 psiconv_read_u32(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
63 int *status) 85 int *status)
64{ 86{
65 psiconv_u8 *ptr0,*ptr1,*ptr2,*ptr3; 87 psiconv_u8 *ptr0,*ptr1,*ptr2,*ptr3;
66 ptr0 = psiconv_buffer_get(buf,off); 88 ptr0 = psiconv_buffer_get(buf,off);
67 ptr1 = psiconv_buffer_get(buf,off+1); 89 ptr1 = psiconv_buffer_get(buf,off+1);
68 ptr2 = psiconv_buffer_get(buf,off+2); 90 ptr2 = psiconv_buffer_get(buf,off+2);
69 ptr3 = psiconv_buffer_get(buf,off+3); 91 ptr3 = psiconv_buffer_get(buf,off+3);
70 if (!ptr0 || !ptr1 || !ptr2 || !ptr3) { 92 if (!ptr0 || !ptr1 || !ptr2 || !ptr3) {
71 psiconv_warn(lev,off,"Trying long read past the end of the file"); 93 psiconv_warn(config,lev,off,"Trying long read past the end of the file");
72 if (status) 94 if (status)
73 *status = -PSICONV_E_PARSE; 95 *status = -PSICONV_E_PARSE;
74 return 0; 96 return 0;
75 } 97 }
76 if (status) 98 if (status)
77 *status = 0; 99 *status = 0;
78 return *ptr0 + (*ptr1 << 8) + (*ptr2 << 16) + (*ptr3 << 24); 100 return *ptr0 + (*ptr1 << 8) + (*ptr2 << 16) + (*ptr3 << 24);
79} 101}
80 102
103psiconv_s32 psiconv_read_sint(const psiconv_config config,const psiconv_buffer buf,int lev,psiconv_u32 off,
104 int *length,int *status)
105{
106 int localstatus;
107 psiconv_u32 temp;
108
109 temp=psiconv_read_u32(config,buf,lev,off,&localstatus);
110 if (status)
111 *status = localstatus;
112 if (length)
113 *length = localstatus?0:4;
114
115 return localstatus?0:(temp & 0x7fffffff)*(temp&0x80000000?-1:1);
116}
117
81psiconv_S_t psiconv_read_S(const psiconv_buffer buf, int lev, psiconv_u32 off, 118psiconv_S_t psiconv_read_S(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
82 int *length,int *status) 119 int *length,int *status)
83{ 120{
84 psiconv_u8 temp; 121 psiconv_u8 temp;
85 psiconv_S_t res; 122 psiconv_S_t res;
86 int len,localstatus; 123 int len,localstatus;
87 124
88 psiconv_progress(lev+1,off,"Going to read a S length indicator"); 125 psiconv_progress(config,lev+1,off,"Going to read a S length indicator");
89 temp = psiconv_read_u8(buf,lev+2,off,&localstatus); 126 temp = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
90 if (localstatus) 127 if (localstatus)
91 goto ERROR; 128 goto ERROR;
92 if ((temp & 0x03) == 0x02) { 129 if ((temp & 0x03) == 0x02) {
93 res = psiconv_read_u8(buf,lev+2,off,&localstatus) >> 2; 130 res = psiconv_read_u8(config,buf,lev+2,off,&localstatus) >> 2;
94 if (localstatus) 131 if (localstatus)
95 goto ERROR; 132 goto ERROR;
96 len = 1; 133 len = 1;
97 psiconv_debug(lev+2,off,"Indicator (1 byte): %02x",res); 134 psiconv_debug(config,lev+2,off,"Indicator (1 byte): %02x",res);
98 } else if ((temp & 0x07) == 0x03) { 135 } else if ((temp & 0x07) == 0x05) {
99 res = psiconv_read_u16(buf,lev+2,off,&localstatus) >> 3; 136 res = psiconv_read_u16(config,buf,lev+2,off,&localstatus) >> 3;
100 if (localstatus) 137 if (localstatus)
101 goto ERROR; 138 goto ERROR;
102 len = 2; 139 len = 2;
103 psiconv_debug(lev+2,off,"Indicator (2 bytes): %04x",res); 140 psiconv_debug(config,lev+2,off,"Indicator (2 bytes): %04x",res);
104 } else { 141 } else {
105 psiconv_warn(lev+2,off,"S indicator: unknown encoding!"); 142 psiconv_warn(config,lev+2,off,"S indicator: unknown encoding!");
106 psiconv_debug(lev+2,off,"Raw data first byte: %02x",temp); 143 psiconv_debug(config,lev+2,off,"Raw data first byte: %02x",temp);
107 goto ERROR; 144 goto ERROR;
108 } 145 }
109 146
110 if (length) 147 if (length)
111 *length = len; 148 *length = len;
112 if (status) 149 if (status)
113 *status = 0; 150 *status = 0;
114 151
115 psiconv_progress(lev+1,off+len-1, 152 psiconv_progress(config,lev+1,off+len-1,
116 "End of S length indicator (total length: %08x)", len); 153 "End of S length indicator (total length: %08x)", len);
117 154
118 return res; 155 return res;
119 156
120ERROR: 157ERROR:
121 psiconv_warn(lev+1,off,"Reading of S indicator failed"); 158 psiconv_warn(config,lev+1,off,"Reading of S indicator failed");
122 if (status) 159 if (status)
123 *status = localstatus; 160 *status = localstatus;
124 if (length) 161 if (length)
125 *length = 0; 162 *length = 0;
126 return 0; 163 return 0;
127} 164}
128 165
129psiconv_X_t psiconv_read_X(const psiconv_buffer buf, int lev, psiconv_u32 off, 166psiconv_X_t psiconv_read_X(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
130 int *length, int *status) 167 int *length, int *status)
131{ 168{
132 psiconv_u8 temp; 169 psiconv_u8 temp;
133 psiconv_X_t res; 170 psiconv_X_t res;
134 int len,localstatus; 171 int len,localstatus;
135 172
136 psiconv_progress(lev+1,off,"Going to read a X length indicator"); 173 psiconv_progress(config,lev+1,off,"Going to read a X length indicator");
137 temp = psiconv_read_u8(buf,lev+2,off,&localstatus); 174 temp = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
138 if (localstatus) 175 if (localstatus)
139 goto ERROR; 176 goto ERROR;
140 if ((temp & 0x01) == 0x00) { 177 if ((temp & 0x01) == 0x00) {
141 res = psiconv_read_u8(buf,lev+2,off,&localstatus) >> 1; 178 res = psiconv_read_u8(config,buf,lev+2,off,&localstatus) >> 1;
142 if (localstatus) 179 if (localstatus)
143 goto ERROR; 180 goto ERROR;
144 len = 1; 181 len = 1;
145 psiconv_debug(lev+2,off,"Indicator (1 byte): %02x",res); 182 psiconv_debug(config,lev+2,off,"Indicator (1 byte): %02x",res);
146 } else if ((temp & 0x03) == 0x01) { 183 } else if ((temp & 0x03) == 0x01) {
147 res = psiconv_read_u16(buf,lev+2,off,&localstatus) >> 2; 184 res = psiconv_read_u16(config,buf,lev+2,off,&localstatus) >> 2;
148 if (localstatus) 185 if (localstatus)
149 goto ERROR; 186 goto ERROR;
150 len = 2; 187 len = 2;
151 psiconv_debug(lev+2,off,"Indicator (2 bytes): %04x",res); 188 psiconv_debug(config,lev+2,off,"Indicator (2 bytes): %04x",res);
152 } else if ((temp & 0x07) == 0x03) { 189 } else if ((temp & 0x07) == 0x03) {
153 res = psiconv_read_u32(buf,lev+2,off,&localstatus) >> 3; 190 res = psiconv_read_u32(config,buf,lev+2,off,&localstatus) >> 3;
154 if (localstatus) 191 if (localstatus)
155 goto ERROR; 192 goto ERROR;
156 len = 4; 193 len = 4;
157 psiconv_debug(lev+2,off,"Indicator (4 bytes): %08x",res); 194 psiconv_debug(config,lev+2,off,"Indicator (4 bytes): %08x",res);
158 } else { 195 } else {
159 psiconv_warn(lev+2,off,"X indicator: unknown encoding!"); 196 psiconv_warn(config,lev+2,off,"X indicator: unknown encoding!");
160 psiconv_debug(lev+2,off,"Raw data first byte: %02x",temp); 197 psiconv_debug(config,lev+2,off,"Raw data first byte: %02x",temp);
161 goto ERROR; 198 goto ERROR;
162 } 199 }
163 200
164 if (length) 201 if (length)
165 *length = len; 202 *length = len;
166 if (status) 203 if (status)
167 *status = 0; 204 *status = 0;
168 205
169 psiconv_progress(lev+1,off+len-1, 206 psiconv_progress(config,lev+1,off+len-1,
170 "End of X length indicator (total length: %08x)", len); 207 "End of X length indicator (total length: %08x)", len);
171 208
172 return res; 209 return res;
173 210
174ERROR: 211ERROR:
175 psiconv_warn(lev+1,off,"Reading of X indicator failed"); 212 psiconv_warn(config,lev+1,off,"Reading of X indicator failed");
176 if (status) 213 if (status)
177 *status = localstatus; 214 *status = localstatus;
178 if (length) 215 if (length)
179 *length = 0; 216 *length = 0;
180 return 0; 217 return 0;
181} 218}
182 219
183psiconv_length_t psiconv_read_length(const psiconv_buffer buf, int lev, 220psiconv_length_t psiconv_read_length(const psiconv_config config,const psiconv_buffer buf, int lev,
184 psiconv_u32 off, int *length, int *status) 221 psiconv_u32 off, int *length, int *status)
185{ 222{
186 psiconv_length_t res; 223 psiconv_length_t res;
187 int localstatus; 224 int localstatus;
188 225
189 res = (2.54/1440.0) * ((psiconv_s32) psiconv_read_u32(buf,lev,off, 226 res = (2.54/1440.0) * ((psiconv_s32) psiconv_read_u32(config,buf,lev,off,
190 &localstatus)); 227 &localstatus));
191 if (localstatus) { 228 if (localstatus) {
192 psiconv_warn(lev+1,off,"Reading of length failed"); 229 psiconv_warn(config,lev+1,off,"Reading of length failed");
193 if (length) 230 if (length)
194 *length = 0; 231 *length = 0;
195 if (status) 232 if (status)
196 *status = localstatus; 233 *status = localstatus;
197 return 0; 234 return 0;
198 } 235 }
199 psiconv_debug(lev+1,off,"Length: %f",res); 236 psiconv_debug(config,lev+1,off,"Length: %f",res);
200 if (length) 237 if (length)
201 *length = 4; 238 *length = 4;
202 if (status) 239 if (status)
203 *status = 0; 240 *status = 0;
204 return res; 241 return res;
205} 242}
206 243
207psiconv_size_t psiconv_read_size(const psiconv_buffer buf, int lev, 244psiconv_size_t psiconv_read_size(const psiconv_config config,const psiconv_buffer buf, int lev,
208 psiconv_u32 off, int *length, int *status) 245 psiconv_u32 off, int *length, int *status)
209{ 246{
210 psiconv_size_t res; 247 psiconv_size_t res;
211 int localstatus; 248 int localstatus;
212 res = ((psiconv_s32) psiconv_read_u32(buf,lev,off,&localstatus)) / 20.0; 249 res = ((psiconv_s32) psiconv_read_u32(config,buf,lev,off,&localstatus)) / 20.0;
213 if (localstatus) { 250 if (localstatus) {
214 psiconv_warn(lev+1,off,"Reading of size failed"); 251 psiconv_warn(config,lev+1,off,"Reading of size failed");
215 if (length) 252 if (length)
216 *length = 0; 253 *length = 0;
217 if (status) 254 if (status)
218 *status = localstatus; 255 *status = localstatus;
219 return 0; 256 return 0;
220 } 257 }
221 psiconv_debug(lev+1,off,"Size: %f",res); 258 psiconv_debug(config,lev+1,off,"Size: %f",res);
222 if (status) 259 if (status)
223 *status = 0; 260 *status = 0;
224 if (length) 261 if (length)
225 *length = 4; 262 *length = 4;
226 return res; 263 return res;
227} 264}
228 265
229int psiconv_parse_bool(const psiconv_buffer buf, int lev, psiconv_u32 off, 266int psiconv_parse_bool(const psiconv_config config,const psiconv_buffer buf, int lev, psiconv_u32 off,
230 int *length, psiconv_bool_t *result) 267 int *length, psiconv_bool_t *result)
231{ 268{
232 psiconv_u8 temp; 269 psiconv_u8 temp;
233 int localstatus; 270 int localstatus;
234 temp = psiconv_read_u8(buf,lev,off,&localstatus); 271 temp = psiconv_read_u8(config,buf,lev,off,&localstatus);
235 if (localstatus) { 272 if (localstatus) {
236 psiconv_warn(lev+1,off,"Reading of bool failed"); 273 psiconv_warn(config,lev+1,off,"Reading of bool failed");
237 if (length) 274 if (length)
238 *length = 0; 275 *length = 0;
239 return localstatus; 276 return localstatus;
240 } 277 }
241 if (length) 278 if (length)
245 return 0; 282 return 0;
246 } else if (temp == 1) { 283 } else if (temp == 1) {
247 *result = psiconv_bool_true; 284 *result = psiconv_bool_true;
248 return 0; 285 return 0;
249 } 286 }
250 psiconv_warn(lev+1,off,"Unknown value for boolean"); 287 psiconv_warn(config,lev+1,off,"Unknown value for boolean");
251 psiconv_debug(lev+1,off,"Boolean value: %02x",temp); 288 psiconv_debug(config,lev+1,off,"Boolean value: %02x",temp);
252 *result = psiconv_bool_true; 289 *result = psiconv_bool_true;
253 return 0; 290 return 0;
254} 291}
255 292
256psiconv_string_t psiconv_read_string(const psiconv_buffer buf,int lev, 293psiconv_string_t psiconv_read_string(const psiconv_config config,
294 const psiconv_buffer buf,int lev,
257 psiconv_u32 off,int *length, int *status) 295 psiconv_u32 off,int *length, int *status)
296{
297 return psiconv_read_string_aux(config,buf,lev,off,length,status,0);
298}
299
300psiconv_string_t psiconv_read_short_string(const psiconv_config config,
301 const psiconv_buffer buf,int lev,
302 psiconv_u32 off,int *length, int *status)
303{
304 return psiconv_read_string_aux(config,buf,lev,off,length,status,1);
305}
306
307psiconv_string_t psiconv_read_string_aux(const psiconv_config config,
308 const psiconv_buffer buf,int lev,
309 psiconv_u32 off,int *length, int *status,
310 int kind)
258{ 311{
259 int stringlen,i,leng,len,localstatus; 312 int stringlen,i,leng,len,localstatus;
260 psiconv_string_t result; 313 psiconv_string_t result;
261 char *res_copy; 314 char *res_copy;
262 315
263 psiconv_progress(lev+1,off,"Going to read a string"); 316 psiconv_progress(config,lev+1,off,"Going to read a string");
264 317
318 if (kind == 0)
265 stringlen = psiconv_read_S(buf,lev+2,off,&leng,&localstatus); 319 stringlen = psiconv_read_S(config,buf,lev+2,off,&leng,&localstatus);
320 else {
321 stringlen = psiconv_read_u8(config,buf,lev+2,off,&localstatus);
322 leng = 1;
323 }
324
266 if (localstatus) 325 if (localstatus)
267 goto ERROR1; 326 goto ERROR1;
268 psiconv_debug(lev+2,off,"Length: %i",stringlen); 327 psiconv_debug(config,lev+2,off,"Length: %i",stringlen);
269 len = leng; 328 len = leng;
270 329
271 result = malloc(stringlen + 1); 330 result = malloc(stringlen + 1);
272 if (!result) 331 if (!result)
273 goto ERROR1; 332 goto ERROR1;
274 for (i = 0; (i < stringlen) && !localstatus; i++) 333 for (i = 0; (i < stringlen) && !localstatus; i++)
275 result[i] = psiconv_read_u8(buf,lev,off+i+len,&localstatus); 334 result[i] = psiconv_read_u8(config,buf,lev,off+i+len,&localstatus);
276 if (localstatus) 335 if (localstatus)
277 goto ERROR2; 336 goto ERROR2;
278 result[stringlen] = 0; 337 result[stringlen] = 0;
279 len += stringlen; 338 len += stringlen;
280 339
281 res_copy = psiconv_make_printable(result); 340 res_copy = psiconv_make_printable(result);
282 if (!res_copy) 341 if (!res_copy)
283 goto ERROR2; 342 goto ERROR2;
284 psiconv_debug(lev+2,off,"Contents: `%s'",res_copy); 343 psiconv_debug(config,lev+2,off,"Contents: `%s'",res_copy);
285 free(res_copy); 344 free(res_copy);
286 345
287 if (length) 346 if (length)
288 *length = len; 347 *length = len;
289 348
290 if (status) 349 if (status)
291 *status = 0; 350 *status = 0;
292 351
293 psiconv_progress(lev+1,off+len-1,"End of string (total length: %08x)",len); 352 psiconv_progress(config,lev+1,off+len-1,"End of string (total length: %08x)",len);
294 353
295 return result; 354 return result;
296 355
297ERROR2: 356ERROR2:
298 free(result); 357 free(result);
299ERROR1: 358ERROR1:
300 psiconv_warn(lev+1,off,"Reading of string failed"); 359 psiconv_warn(config,lev+1,off,"Reading of string failed");
301 if (status) 360 if (status)
302 *status = localstatus; 361 *status = localstatus;
303 if (length) 362 if (length)
304 *length = 0; 363 *length = 0;
305 return NULL; 364 return NULL;
306} 365}
307 366
308psiconv_string_t psiconv_read_short_string(const psiconv_buffer buf,
309 int lev,
310 psiconv_u32 off,int *length, int *status)
311{
312 int stringlen,i,len,localstatus;
313 psiconv_string_t result;
314 char *res_copy;
315
316 psiconv_progress(lev+1,off,"Going to read a short string");
317
318 stringlen = psiconv_read_u8(buf,lev+2,off,&localstatus);
319 if (localstatus)
320 goto ERROR1;
321 psiconv_debug(lev+2,off,"Length: %i",stringlen);
322 len = 1;
323
324 result = malloc(stringlen + 1);
325 if (!result)
326 goto ERROR1;
327 for (i = 0; (i < stringlen) && !localstatus; i++)
328 result[i] = psiconv_read_u8(buf,lev,off+i+len,&localstatus);
329 if (localstatus)
330 goto ERROR2;
331 result[stringlen] = 0;
332 len += stringlen;
333
334 res_copy = psiconv_make_printable(result);
335 if (!res_copy)
336 goto ERROR2;
337 psiconv_debug(lev+2,off,"Contents: `%s'",res_copy);
338 free(res_copy);
339
340 if (length)
341 *length = len;
342
343 if (status)
344 *status = 0;
345
346 psiconv_progress(lev+1,off+len-1,"End of short string (total length: %08x)",
347 len);
348
349 return result;
350
351
352ERROR2:
353 free(result);
354ERROR1:
355 psiconv_warn(lev+1,off,"Reading of short string failed");
356 if (status)
357 *status = localstatus;
358 if (length)
359 *length = 0;
360 return NULL;
361}
362
363psiconv_float_t psiconv_read_float(const psiconv_buffer buf, int lev, 367psiconv_float_t psiconv_read_float(const psiconv_config config,const psiconv_buffer buf, int lev,
364 psiconv_u32 off, int *length, int *status) 368 psiconv_u32 off, int *length, int *status)
365{ 369{
366 psiconv_float_t result,bitvalue; 370 psiconv_float_t result,bitvalue;
367 int res,bit; 371 int res,bit;
368 psiconv_u32 temp=0; 372 psiconv_u32 temp=0;
369 373
370 psiconv_progress(lev+1,off,"Going to read a float"); 374 psiconv_progress(config,lev+1,off,"Going to read a float");
371 375
372 bitvalue = 0.5; 376 bitvalue = 0.5;
373 result = 1.0; 377 result = 1.0;
374 for (bit = 0x33; bit > 0; bit--) { 378 for (bit = 0x33; bit > 0; bit--) {
375 if ((bit == 0x33) || ((bit & 0x07) == 0x07)) 379 if ((bit == 0x33) || ((bit & 0x07) == 0x07))
376 temp = psiconv_read_u8(buf,lev+2,off+ (bit >> 3),&res); 380 temp = psiconv_read_u8(config,buf,lev+2,off+ (bit >> 3),&res);
377 if (res) 381 if (res)
378 goto ERROR; 382 goto ERROR;
379 if (temp & (0x01 << (bit & 0x07))) 383 if (temp & (0x01 << (bit & 0x07)))
380 result += bitvalue; 384 result += bitvalue;
381 bitvalue /= 2.0; 385 bitvalue /= 2.0;
382 } 386 }
383 temp = psiconv_read_u16(buf,lev+2,off+6,&res); 387 temp = psiconv_read_u16(config,buf,lev+2,off+6,&res);
384 if (res) 388 if (res)
385 goto ERROR; 389 goto ERROR;
386 if (temp & 0x8000) 390 if (temp & 0x8000)
387 result = -result; 391 result = -result;
388 temp = (temp & 0x7ff0) >> 4; 392 temp = (temp & 0x7ff0) >> 4;
389 result *= pow(2.0,((int) temp)-0x3ff); 393 result *= pow2(((int) temp)-0x3ff);
390 psiconv_debug(lev+1,off,"Float value: %f",result); 394 psiconv_debug(config,lev+1,off,"Float value: %f",result);
391 if (length) 395 if (length)
392 *length = 8; 396 *length = 8;
393 if (*status) 397 if (*status)
394 *status = res; 398 *status = res;
395 return result; 399 return result;
396ERROR: 400ERROR:
397 psiconv_warn(lev+1,off,"Reading of float failed"); 401 psiconv_warn(config,lev+1,off,"Reading of float failed");
398 if (length) 402 if (length)
399 *length = 0; 403 *length = 0;
400 if (*status) 404 if (*status)
401 *status = res; 405 *status = res;
402 return 0.0; 406 return 0.0;
403} 407}
408

Legend:
Removed from v.110  
changed lines
  Added in v.182

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26