/[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 118 Revision 142
23#include <stdlib.h> 23#include <stdlib.h>
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
29#ifdef DMALLOC
30#include <dmalloc.h>
31#endif
28 32
29/* Very inefficient, but good enough for now. By implementing it ourselves, 33/* Very inefficient, but good enough for now. By implementing it ourselves,
30 we do not have to link with -lm */ 34 we do not have to link with -lm */
31psiconv_float_t pow2(int n) 35psiconv_float_t pow2(int n)
32{ 36{
88 if (status) 92 if (status)
89 *status = 0; 93 *status = 0;
90 return *ptr0 + (*ptr1 << 8) + (*ptr2 << 16) + (*ptr3 << 24); 94 return *ptr0 + (*ptr1 << 8) + (*ptr2 << 16) + (*ptr3 << 24);
91} 95}
92 96
97psiconv_s32 psiconv_read_sint(const psiconv_buffer buf,int lev,psiconv_u32 off,
98 int *length,int *status)
99{
100 int localstatus;
101 psiconv_u32 temp;
102
103 temp=psiconv_read_u32(buf,lev,off,&localstatus);
104 if (status)
105 *status = localstatus;
106 if (length)
107 *length = localstatus?0:4;
108
109 return localstatus?0:(temp & 0x7fffffff)*(temp&0x80000000?-1:1);
110}
111
93psiconv_S_t psiconv_read_S(const psiconv_buffer buf, int lev, psiconv_u32 off, 112psiconv_S_t psiconv_read_S(const psiconv_buffer buf, int lev, psiconv_u32 off,
94 int *length,int *status) 113 int *length,int *status)
95{ 114{
96 psiconv_u8 temp; 115 psiconv_u8 temp;
97 psiconv_S_t res; 116 psiconv_S_t res;
105 res = psiconv_read_u8(buf,lev+2,off,&localstatus) >> 2; 124 res = psiconv_read_u8(buf,lev+2,off,&localstatus) >> 2;
106 if (localstatus) 125 if (localstatus)
107 goto ERROR; 126 goto ERROR;
108 len = 1; 127 len = 1;
109 psiconv_debug(lev+2,off,"Indicator (1 byte): %02x",res); 128 psiconv_debug(lev+2,off,"Indicator (1 byte): %02x",res);
110 } else if ((temp & 0x07) == 0x03) { 129 } else if ((temp & 0x07) == 0x05) {
111 res = psiconv_read_u16(buf,lev+2,off,&localstatus) >> 3; 130 res = psiconv_read_u16(buf,lev+2,off,&localstatus) >> 3;
112 if (localstatus) 131 if (localstatus)
113 goto ERROR; 132 goto ERROR;
114 len = 2; 133 len = 2;
115 psiconv_debug(lev+2,off,"Indicator (2 bytes): %04x",res); 134 psiconv_debug(lev+2,off,"Indicator (2 bytes): %04x",res);

Legend:
Removed from v.118  
changed lines
  Added in v.142

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