… | |
… | |
303 | if (length) |
303 | if (length) |
304 | *length = 0; |
304 | *length = 0; |
305 | return NULL; |
305 | return NULL; |
306 | } |
306 | } |
307 | |
307 | |
|
|
308 | psiconv_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 | |
|
|
352 | ERROR2: |
|
|
353 | free(result); |
|
|
354 | ERROR1: |
|
|
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 | |
308 | psiconv_float_t psiconv_read_float(const psiconv_buffer buf, int lev, |
363 | psiconv_float_t psiconv_read_float(const psiconv_buffer buf, int lev, |
309 | psiconv_u32 off, int *length, int *status) |
364 | psiconv_u32 off, int *length, int *status) |
310 | { |
365 | { |
311 | psiconv_float_t result,bitvalue; |
366 | psiconv_float_t result,bitvalue; |
312 | int res,bit; |
367 | int res,bit; |